diff --git a/src/raspberrypi/devices/scsi_command_util.cpp b/src/raspberrypi/devices/scsi_command_util.cpp index a31fb481..c3e0f6df 100644 --- a/src/raspberrypi/devices/scsi_command_util.cpp +++ b/src/raspberrypi/devices/scsi_command_util.cpp @@ -81,3 +81,24 @@ void scsi_command_util::EnrichFormatPage(map>& pages, bool cha format_page[13] = sector_size; } } + +//--------------------------------------------------------------------------- +// +// Add Vendor special page to make drive Apple compatible +// +//--------------------------------------------------------------------------- +void scsi_command_util::AddAppleVendorModePage(map>& pages, int page, bool changeable) +{ + // Page code 48 (30h) - Apple Vendor Mode Page + // Needed for SCCD for stock Apple driver support + // Needed for SCHD for stock Apple HD SC Setup + vector buf(30); + + // No changeable area + if (!changeable) { + BYTE apple_data[] = "APPLE COMPUTER, INC "; + memcpy(&buf[2], apple_data, sizeof(apple_data)); + } + + pages[0x30] = buf; +} diff --git a/src/raspberrypi/devices/scsi_command_util.h b/src/raspberrypi/devices/scsi_command_util.h index 1530aa64..166767f0 100644 --- a/src/raspberrypi/devices/scsi_command_util.h +++ b/src/raspberrypi/devices/scsi_command_util.h @@ -21,4 +21,6 @@ namespace scsi_command_util { void ModeSelect(const DWORD *, const BYTE *, int, int); void EnrichFormatPage(map>&, bool, int); + + void AddAppleVendorModePage(map>&, int, bool); } diff --git a/src/raspberrypi/devices/scsicd.cpp b/src/raspberrypi/devices/scsicd.cpp index f909bb9e..9ba5ef6e 100644 --- a/src/raspberrypi/devices/scsicd.cpp +++ b/src/raspberrypi/devices/scsicd.cpp @@ -17,6 +17,8 @@ #include "scsicd.h" #include "fileio.h" #include "rascsi_exceptions.h" +#include "scsi_command_util.h" + using namespace scsi_defs; @@ -415,6 +417,15 @@ void SCSICD::AddCDDAPage(map>& pages, bool) const pages[14] = buf; } +void SCSICD::AddVendorPage(map>& pages, int page, bool changeable) const +{ + // Page code 48 + if (page == 0x30 || page == 0x3f) { + scsi_command_util::AddAppleVendorModePage(pages, page, changeable); + } +} + + int SCSICD::Read(const DWORD *cdb, BYTE *buf, uint64_t block) { assert(buf); diff --git a/src/raspberrypi/devices/scsicd.h b/src/raspberrypi/devices/scsicd.h index cb037116..bdbf4cf9 100644 --- a/src/raspberrypi/devices/scsicd.h +++ b/src/raspberrypi/devices/scsicd.h @@ -86,6 +86,7 @@ public: protected: void AddModePages(map>&, int, bool) const override; + void AddVendorPage(map>&, int, bool) const override; private: using super = Disk; diff --git a/src/raspberrypi/devices/scsihd.cpp b/src/raspberrypi/devices/scsihd.cpp index 69521fc4..acca418a 100644 --- a/src/raspberrypi/devices/scsihd.cpp +++ b/src/raspberrypi/devices/scsihd.cpp @@ -110,24 +110,10 @@ void SCSIHD::AddFormatPage(map>& pages, bool changeable) const scsi_command_util::EnrichFormatPage(pages, changeable, 1 << GetSectorSizeShiftCount()); } -//--------------------------------------------------------------------------- -// -// Add Vendor special page to make drive Apple compatible -// -//--------------------------------------------------------------------------- void SCSIHD::AddVendorPage(map>& pages, int page, bool changeable) const { // Page code 48 - if (page != 0x30 && page != 0x3f) { - return; + if (page == 0x30 || page == 0x3f) { + scsi_command_util::AddAppleVendorModePage(pages, page, changeable); } - - vector buf(30); - - // No changeable area - if (!changeable) { - memcpy(&buf[0xa], "APPLE COMPUTER, INC.", 20); - } - - pages[48] = buf; } diff --git a/src/raspberrypi/test/mode_pages_test.cpp b/src/raspberrypi/test/mode_pages_test.cpp index bd551931..5c0de6a9 100644 --- a/src/raspberrypi/test/mode_pages_test.cpp +++ b/src/raspberrypi/test/mode_pages_test.cpp @@ -72,13 +72,14 @@ TEST(ModePagesTest, SCSICD_AddModePages) MockSCSICD device(sector_sizes); device.AddModePages(mode_pages, 0x3f, false); - EXPECT_EQ(6, mode_pages.size()) << "Unexpected number of code pages"; + EXPECT_EQ(7, mode_pages.size()) << "Unexpected number of code pages"; EXPECT_EQ(12, mode_pages[1].size()); EXPECT_EQ(24, mode_pages[3].size()); EXPECT_EQ(24, mode_pages[4].size()); EXPECT_EQ(12, mode_pages[8].size()); EXPECT_EQ(8, mode_pages[13].size()); EXPECT_EQ(16, mode_pages[14].size()); + EXPECT_EQ(30, mode_pages[48].size()); } TEST(ModePagesTest, SCSIMO_AddModePages)