Skip to content

Commit

Permalink
Support Apple mode sense page 0x30.
Browse files Browse the repository at this point in the history
Support for mode sense page control 01b (changeable values).
Change SYNCHRONIZE CACHE (10) to be a no-op rather than an error.
  • Loading branch information
mactcp committed Mar 24, 2022
1 parent f904486 commit e42291e
Showing 1 changed file with 31 additions and 14 deletions.
45 changes: 31 additions & 14 deletions src/BlueSCSI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,7 @@ byte onModeSenseCommand(byte scsi_cmd, byte dbd, int cmd2, uint32_t len)
return 0x00;
}
#else
byte onModeSenseCommand(byte scsi_cmd, byte dbd, int cmd2, uint32_t len)
byte onModeSenseCommand(byte scsi_cmd, byte dbd, byte cmd2, uint32_t len)
{
if(!m_img) return 0x02; // No image file

Expand All @@ -1121,6 +1121,7 @@ byte onModeSenseCommand(byte scsi_cmd, byte dbd, int cmd2, uint32_t len)

memset(m_buf, 0, sizeof(m_buf));
int pageCode = cmd2 & 0x3F;
int pageControl = cmd2 >> 6;
int a = 4;
if(scsi_cmd == 0x5A) a = 8;

Expand Down Expand Up @@ -1151,24 +1152,37 @@ byte onModeSenseCommand(byte scsi_cmd, byte dbd, int cmd2, uint32_t len)
case 0x03: //Drive parameters
m_buf[a + 0] = 0x03; //Page code
m_buf[a + 1] = 0x16; // Page length
m_buf[a + 11] = 0x3F;//Number of sectors / track
m_buf[a + 12] = (byte)(m_img->m_blocksize >> 8);
m_buf[a + 13] = (byte)m_img->m_blocksize;
m_buf[a + 15] = 0x1; // Interleave
if(pageControl != 1) {
m_buf[a + 11] = 0x3F;//Number of sectors / track
m_buf[a + 12] = (byte)(m_img->m_blocksize >> 8);
m_buf[a + 13] = (byte)m_img->m_blocksize;
m_buf[a + 15] = 0x1; // Interleave
}
a += 0x18;
if(pageCode != 0x3F) break;

case 0x04: //Drive parameters
m_buf[a + 0] = 0x04; //Page code
m_buf[a + 1] = 0x16; // Page length
if(pageControl != 1) {
unsigned cylinders = bc / (16 * 63);
m_buf[a + 2] = (byte)(cylinders >> 16); // Cylinders
m_buf[a + 3] = (byte)(cylinders >> 8);
m_buf[a + 4] = (byte)cylinders;
m_buf[a + 5] = 16; //Number of heads
}
a += 0x18;
if(pageCode != 0x3F) break;
case 0x30:
{
unsigned cylinders = bc / (16 * 63);
m_buf[a + 0] = 0x04; //Page code
m_buf[a + 1] = 0x16; // Page length
m_buf[a + 2] = (byte)(cylinders >> 16); // Cylinders
m_buf[a + 3] = (byte)(cylinders >> 8);
m_buf[a + 4] = (byte)cylinders;
m_buf[a + 5] = 16; //Number of heads
a += 0x18;
if(pageCode != 0x3F) break;
const byte page30[0x14] = {0x41, 0x50, 0x50, 0x4C, 0x45, 0x20, 0x43, 0x4F, 0x4D, 0x50, 0x55, 0x54, 0x45, 0x52, 0x2C, 0x20, 0x49, 0x4E, 0x43, 0x20};
m_buf[a + 0] = 0x30; // Page code
m_buf[a + 1] = sizeof(page30); // Page length
if(pageControl != 1) {
memcpy(&m_buf[a + 2], page30, sizeof(page30));
}
a += 2 + sizeof(page30);
if(pageCode != 0x3F) break;
}
break; // Don't want 0x3F falling through to error condition

Expand Down Expand Up @@ -1466,6 +1480,9 @@ void loop()
case 0x2B:
LOGN("[Seek10]");
break;
case 0x35:
LOGN("[SynchronizeCache10]");
break;
case 0x5A:
LOGN("[ModeSense10]");
m_sts |= onModeSenseCommand(cmd[0], cmd[1] & 0x80, cmd[2], ((uint32_t)cmd[7] << 8) | cmd[8]);
Expand Down

0 comments on commit e42291e

Please sign in to comment.