Skip to content
Open
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 @@ -92,7 +92,8 @@ typedef enum
S2S_CFG_QUIRKS_XEBEC = 4,
S2S_CFG_QUIRKS_VMS = 8,
S2S_CFG_QUIRKS_X68000 = 16,
S2S_CFG_QUIRKS_EWSD = 32
S2S_CFG_QUIRKS_EWSD = 32,
S2S_CFG_QUIRKS_PC98_55 = 64
} S2S_CFG_QUIRKS;

typedef enum
Expand Down
34 changes: 29 additions & 5 deletions lib/SCSI2SD/src/firmware/mode.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,14 @@ static void doModeSense(
}
}

// The PC-9801-55 SCSI-1 controller, and its derivatives will
// ask for all pages (0x3F), expecting only those pages back:
// 0x01 - Read-write error recovery page
// 0x03 - Format device page
// 0x04 - Rigid disk geometry page
// This quirk is expected to be used with SCSI-1 mode only
uint8_t oldNecHddMode = scsiDev.target->cfg->quirks == S2S_CFG_QUIRKS_PC98_55;

////////////// Block Descriptor
////////////////////////////////////
if (!dbd)
Expand All @@ -410,9 +418,15 @@ static void doModeSense(
// Number of blocks
// Zero == all remaining blocks shall have the medium
// characteristics specified.
scsiDev.data[idx++] = 0;
scsiDev.data[idx++] = 0;
scsiDev.data[idx++] = 0;
uint32_t blocks = 0;
if (oldNecHddMode)
{
// NEC PC-9801-55 needs explicit block count
blocks = scsiDev.target->cfg->scsiSectors;
}
scsiDev.data[idx++] = (blocks >> 16) & 0xFF;
scsiDev.data[idx++] = (blocks >> 8) & 0xFF;
scsiDev.data[idx++] = blocks & 0xFF;

scsiDev.data[idx++] = 0; // reserved

Expand Down Expand Up @@ -440,7 +454,7 @@ static void doModeSense(
}
}

if (pageCode == 0x02 || pageCode == 0x3F)
if (!oldNecHddMode && (pageCode == 0x02 || pageCode == 0x3F))
{
pageFound = 1;
if ((scsiDev.compatMode >= COMPAT_SCSI2))
Expand All @@ -462,6 +476,16 @@ static void doModeSense(
pageIn(pc, idx, FormatDevicePage, sizeof(FormatDevicePage));
if (pc != 0x01)
{
if (oldNecHddMode)
{
// This mimics ArdSCSino-stm32 behavior,
// setting "Tracks per zone" to heads per cylinder value
// If left as 0, PC-9801FA doesn't detect the drive properly
scsiDev.data[idx+2] = 0x00;
scsiDev.data[idx+3] = scsiDev.target->cfg->headsPerCylinder;
// Interleave field
scsiDev.data[idx+15] = 0x00;
}
uint16_t sectorsPerTrack = scsiDev.target->cfg->sectorsPerTrack;
scsiDev.data[idx+10] = sectorsPerTrack >> 8;
scsiDev.data[idx+11] = sectorsPerTrack & 0xFF;
Expand Down Expand Up @@ -627,7 +651,7 @@ static void doModeSense(
}

// SCSI 2 standard says page 0 is always last.
if (pageCode == 0x00 || pageCode == 0x3F)
if (!oldNecHddMode && (pageCode == 0x00 || pageCode == 0x3F))
{
pageFound = 1;
pageIn(pc, idx, OperatingPage, sizeof(OperatingPage));
Expand Down
2 changes: 2 additions & 0 deletions src/BlueSCSI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ static const char * quirksToChar(int quirks)
{
switch (quirks)
{
case S2S_CFG_QUIRKS_PC98_55:
return "PC-9801-55";
case S2S_CFG_QUIRKS_APPLE:
return "Apple";
case S2S_CFG_QUIRKS_OMTI:
Expand Down
21 changes: 19 additions & 2 deletions src/BlueSCSI_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
// SCSI system and device settings
BlueSCSISettings g_scsi_settings;

const char *systemPresetName[] = {"", "Mac", "MacPlus", "MPC3000", "MegaSTE", "X68000", "X68000-SCSI", "X68000-SASI", "NeXT", "Generic"};
const char *systemPresetName[] = {"", "Mac", "MacPlus", "MPC3000", "MegaSTE", "X68000", "X68000-SCSI", "X68000-SASI", "NeXT", "PC-9801-55", "Generic"};
const char *devicePresetName[] = {"", "ST32430N"};

// must be in the same order as bluescsi_speed_grade_t in BlueSCSI_settings.h
Expand Down Expand Up @@ -539,6 +539,14 @@ scsi_system_settings_t *BlueSCSISettings::initSystem(const char *presetName)
cfgSys.enableParity = false;
cfgSys.maxSyncSpeed = 5;
}
else if (strequals(systemPresetName[SYS_PRESET_PC_9801_55], presetName))
{
m_sysPreset = SYS_PRESET_PC_9801_55;
cfgSys.quirks = S2S_CFG_QUIRKS_PC98_55;
cfgSys.enableSCSI2 = false;
cfgDev.sectorsPerTrack = 25;
cfgDev.headsPerCylinder = 8;
}
else if (strequals(systemPresetName[SYS_PRESET_NeXT], presetName))
{
m_sysPreset = SYS_PRESET_NeXT;
Expand All @@ -558,7 +566,16 @@ scsi_system_settings_t *BlueSCSISettings::initSystem(const char *presetName)
}

// Clear SCSI device strings
memset(cfgDev.vendor, 0, sizeof(cfgDev.vendor));
if (m_sysPreset == SYS_PRESET_PC_9801_55)
{
// Controller requires that Vendor starts with "NEC"
const char *necVendor = "NECBLUE";
strncpy(cfgDev.vendor, necVendor, sizeof(cfgDev.vendor));
}
else
{
memset(cfgDev.vendor, 0, sizeof(cfgDev.vendor));
}
memset(cfgDev.prodId, 0, sizeof(cfgDev.prodId));
memset(cfgDev.revision, 0, sizeof(cfgDev.revision));
memset(cfgDev.serial, 0, sizeof(cfgDev.serial));
Expand Down
1 change: 1 addition & 0 deletions src/BlueSCSI_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ typedef enum
SYS_PRESET_X68000_SCSI,
SYS_PRESET_X68000_SASI,
SYS_PRESET_NeXT,
SYS_PRESET_PC_9801_55,
SYS_PRESET_GENERIC,
} scsi_system_preset_t;

Expand Down
Loading