Apple Mode Page support for SCHD & SCCD (#835)

Co-authored-by: Troy <jokker@gmail.com>
This commit is contained in:
Troy 2022-09-07 22:37:07 -04:00 committed by GitHub
parent 05db0e4688
commit a56aae6d78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 39 additions and 17 deletions

View File

@ -81,3 +81,24 @@ void scsi_command_util::EnrichFormatPage(map<int, vector<BYTE>>& pages, bool cha
format_page[13] = sector_size;
}
}
//---------------------------------------------------------------------------
//
// Add Vendor special page to make drive Apple compatible
//
//---------------------------------------------------------------------------
void scsi_command_util::AddAppleVendorModePage(map<int, vector<BYTE>>& 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<BYTE> buf(30);
// No changeable area
if (!changeable) {
BYTE apple_data[] = "APPLE COMPUTER, INC ";
memcpy(&buf[2], apple_data, sizeof(apple_data));
}
pages[0x30] = buf;
}

View File

@ -21,4 +21,6 @@ namespace scsi_command_util
{
void ModeSelect(const DWORD *, const BYTE *, int, int);
void EnrichFormatPage(map<int, vector<BYTE>>&, bool, int);
void AddAppleVendorModePage(map<int, vector<BYTE>>&, int, bool);
}

View File

@ -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<int, vector<BYTE>>& pages, bool) const
pages[14] = buf;
}
void SCSICD::AddVendorPage(map<int, vector<BYTE>>& 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);

View File

@ -86,6 +86,7 @@ public:
protected:
void AddModePages(map<int, vector<BYTE>>&, int, bool) const override;
void AddVendorPage(map<int, vector<BYTE>>&, int, bool) const override;
private:
using super = Disk;

View File

@ -110,24 +110,10 @@ void SCSIHD::AddFormatPage(map<int, vector<BYTE>>& 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<int, vector<BYTE>>& 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<BYTE> buf(30);
// No changeable area
if (!changeable) {
memcpy(&buf[0xa], "APPLE COMPUTER, INC.", 20);
}
pages[48] = buf;
}

View File

@ -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)