Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/ewsd #376

Merged
merged 3 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/SCSI2SD/include/scsi2sd.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ typedef enum
S2S_CFG_QUIRKS_OMTI = 2,
S2S_CFG_QUIRKS_XEBEC = 4,
S2S_CFG_QUIRKS_VMS = 8,
S2S_CFG_QUIRKS_X68000 = 16
S2S_CFG_QUIRKS_X68000 = 16,
S2S_CFG_QUIRKS_EWSD = 32
} S2S_CFG_QUIRKS;

typedef enum
Expand Down
28 changes: 26 additions & 2 deletions lib/SCSI2SD/src/firmware/scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ void process_Status()
{
scsiEnterPhase(STATUS);

if (scsiDev.target->cfg->quirks == S2S_CFG_QUIRKS_EWSD)
{
s2s_delay_ms(1);
}

uint8_t message;

uint8_t control = scsiDev.cdb[scsiDev.cdbLen - 1];
Expand Down Expand Up @@ -537,6 +542,12 @@ static void process_Command()
scsiDev.data[7] = 10; // additional length
scsiDev.data[12] = scsiDev.target->sense.asc >> 8;
scsiDev.data[13] = scsiDev.target->sense.asc;
if ((scsiDev.target->cfg->quirks == S2S_CFG_QUIRKS_EWSD))
{
/* EWSD seems not to want something behind additional length. (8 + 0x0e = 22) */
allocLength=22;
scsiDev.data[7] = 0x0e;
}
}

// Silently truncate results. SCSI-2 spec 8.2.14.
Expand All @@ -551,8 +562,15 @@ static void process_Command()
// on receiving the unit attention response on boot, thus
// triggering another unit attention condition.
else if (scsiDev.target->unitAttention &&
(scsiDev.boardCfg.flags & S2S_CFG_ENABLE_UNIT_ATTENTION))
scsiDev.target->unitAttentionStop == 0 &&
((scsiDev.boardCfg.flags & S2S_CFG_ENABLE_UNIT_ATTENTION) ||
(scsiDev.target->cfg->quirks == S2S_CFG_QUIRKS_EWSD)))
{
/* EWSD requires unitAttention to be sent only once. */
if (scsiDev.target->cfg->quirks == S2S_CFG_QUIRKS_EWSD)
{
scsiDev.target->unitAttentionStop = 1;
}
scsiDev.target->sense.code = UNIT_ATTENTION;
scsiDev.target->sense.asc = scsiDev.target->unitAttention;

Expand Down Expand Up @@ -1280,7 +1298,13 @@ void scsiInit()
scsiDev.targets[i].reserverId = -1;
if (firstInit)
{
scsiDev.targets[i].unitAttention = POWER_ON_RESET;
if ((cfg->deviceType == S2S_CFG_MO) && (scsiDev.target->cfg->quirks == S2S_CFG_QUIRKS_EWSD))
{
scsiDev.targets[i].unitAttention = POWER_ON_RESET_OR_BUS_DEVICE_RESET_OCCURRED;
} else
{
scsiDev.targets[i].unitAttention = POWER_ON_RESET;
}
}
else
{
Expand Down
1 change: 1 addition & 0 deletions lib/SCSI2SD/src/firmware/scsi.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ typedef struct
ScsiSense sense;

uint16_t unitAttention; // Set to the sense qualifier key to be returned.
uint8_t unitAttentionStop; // Indicates if unit attention has to be stopped.

// Only let the reserved initiator talk to us.
// A 3rd party may be sending the RESERVE/RELEASE commands
Expand Down
4 changes: 4 additions & 0 deletions src/ZuluSCSI_disk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,10 @@ static void doReadCapacity()
{
uint32_t highestBlock = capacity - 1;

if (pmi && scsiDev.target->cfg->quirks == S2S_CFG_QUIRKS_EWSD)
{
highestBlock = 0x00001053;
}
scsiDev.data[0] = highestBlock >> 24;
scsiDev.data[1] = highestBlock >> 16;
scsiDev.data[2] = highestBlock >> 8;
Expand Down
2 changes: 1 addition & 1 deletion zuluscsi.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# The PhyMode parameter has no effect on ZuluSCSI RP2040-based platforms, as there is only one PHY mode.

# Settings that can be needed for compatibility with some hosts
#Quirks = 0 # 0: Standard, 1: Apple, 2: OMTI, 4: Xebec, 8: VMS, 16: X68000
#Quirks = 0 # 0: Standard, 1: Apple, 2: OMTI, 4: Xebec, 8: VMS, 16: X68000, 32: EWSD
#EnableUnitAttention = 0 # Post UNIT_ATTENTION status on power-on or SD card hotplug
#EnableSCSI2 = 1 # Enable faster speeds of SCSI2
#EnableSelLatch = 0 # For Philips P2000C and other devices that release SEL signal before BSY
Expand Down
Loading