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

Add ModeSense page 0x25 (DEC special function control page) #1412

Merged
merged 3 commits into from
Jan 19, 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
24 changes: 24 additions & 0 deletions cpp/devices/scsihd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,32 @@ void SCSIHD::AddFormatPage(map<int, vector<byte>>& pages, bool changeable) const
EnrichFormatPage(pages, changeable, 1 << GetSectorSizeShiftCount());
}

// Page code 37 (25h) - DEC Special Function Control page

void SCSIHD::AddDECSpecialFunctionControlPage(map<int, vector<byte>>& pages, bool changeable) const
{
vector<byte> buf(25);

// No changeable area
if (changeable) {
pages[0x25] = buf;

return;
}

buf[0] = static_cast<byte> (0x25 | 0x80); // page code, high bit set
buf[1] = static_cast<byte> (sizeof(buf) - 1);
buf[2] = static_cast<byte> (0x01); // drive does not auto-start

pages[0x25] = buf;
}

void SCSIHD::AddVendorPage(map<int, vector<byte>>& pages, int page, bool changeable) const
{
// Page code 0x25: DEC Special Function Control page
if (page == 0x25 || page == 0x3f) {
rdmark marked this conversation as resolved.
Show resolved Hide resolved
AddDECSpecialFunctionControlPage(pages, changeable);
}
// Page code 48
if (page == 0x30 || page == 0x3f) {
AddAppleVendorModePage(pages, changeable);
Expand Down
1 change: 1 addition & 0 deletions cpp/devices/scsihd.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class SCSIHD : public Disk
void ModeSelect(scsi_defs::scsi_command, cdb_t, span<const uint8_t>, int) override;

void AddFormatPage(map<int, vector<byte>>&, bool) const override;
void AddDECSpecialFunctionControlPage(map<int, vector<byte>>&, bool) const;
void AddVendorPage(map<int, vector<byte>>&, int, bool) const override;

private:
Expand Down
1 change: 1 addition & 0 deletions cpp/test/mocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ class MockSCSIHD : public SCSIHD //NOSONAR Ignore inheritance hierarchy depth in
FRIEND_TEST(ScsiHdTest, FinalizeSetup);
FRIEND_TEST(ScsiHdTest, GetProductData);
FRIEND_TEST(ScsiHdTest, SetUpModePages);
FRIEND_TEST(ScsiHdTest, DECSpecialFunctionControlPage);
FRIEND_TEST(ScsiHdTest, GetSectorSizes);
FRIEND_TEST(ScsiHdTest, ModeSelect);
FRIEND_TEST(PiscsiExecutorTest, SetSectorSize);
Expand Down
3 changes: 2 additions & 1 deletion cpp/test/scsihd_nec_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ using namespace filesystem;

void ScsiHdNecTest_SetUpModePages(map<int, vector<byte>>& pages)
{
EXPECT_EQ(5, pages.size()) << "Unexpected number of mode pages";
EXPECT_EQ(6, pages.size()) << "Unexpected number of mode pages";
EXPECT_EQ(12, pages[1].size());
EXPECT_EQ(24, pages[3].size());
EXPECT_EQ(20, pages[4].size());
EXPECT_EQ(12, pages[8].size());
EXPECT_EQ(25, pages[37].size());
EXPECT_EQ(30, pages[48].size());
}

Expand Down
17 changes: 16 additions & 1 deletion cpp/test/scsihd_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@

void ScsiHdTest_SetUpModePages(map<int, vector<byte>>& pages)
{
EXPECT_EQ(5, pages.size()) << "Unexpected number of mode pages";
EXPECT_EQ(6, pages.size()) << "Unexpected number of mode pages";
EXPECT_EQ(12, pages[1].size());
EXPECT_EQ(24, pages[3].size());
EXPECT_EQ(24, pages[4].size());
EXPECT_EQ(12, pages[8].size());
EXPECT_EQ(25, pages[37].size());
EXPECT_EQ(30, pages[48].size());
}

Expand Down Expand Up @@ -101,6 +102,20 @@ TEST(ScsiHdTest, SetUpModePages)
ScsiHdTest_SetUpModePages(pages);
}

TEST(ScsiHdTest, DECSpecialFunctionControlPage)
{
map<int, vector<byte>> pages;
vector<byte> buf;
MockSCSIHD hd(0, false);

EXPECT_NO_THROW(hd.SetUpModePages(pages, 0x25, false)) << "MODE SENSE(6) DEC unique page is supported";
EXPECT_NE(pages.end(), pages.find(0x25));
buf = pages[0x25];
EXPECT_EQ(static_cast<byte> (0x25 | 0x80), buf[0]);
EXPECT_EQ(static_cast<byte> (0x17), buf[1]);
EXPECT_EQ(static_cast<byte> (0x01), buf[2]);
}

TEST(ScsiHdTest, ModeSelect)
{
MockSCSIHD hd({ 512 });
Expand Down
Loading