From 91611b43ae118fbbd88424b0613e4715b5b7de7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20K=C3=A4mpf?= Date: Sat, 13 Jan 2024 17:47:58 +0100 Subject: [PATCH 1/3] Add ModeSense page 0x25 (DEC unique page) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit VAXServer 3100 (CPU KA41-E) console firmware issues ModeSense(6) page 0x25 when probing for disks. A disk won't be recognized if this returns an error. The DEC SCSI specification[1], section 8.5 documents this page. [1] https://manx-docs.org/collections/antonio/dec/dec-scsi.pdf Fixes #1410 Signed-off-by: Klaus Kämpf --- cpp/devices/scsihd.cpp | 24 ++++++++++++++++++++++++ cpp/devices/scsihd.h | 1 + 2 files changed, 25 insertions(+) diff --git a/cpp/devices/scsihd.cpp b/cpp/devices/scsihd.cpp index 51384c6ae7..6a2a86343b 100644 --- a/cpp/devices/scsihd.cpp +++ b/cpp/devices/scsihd.cpp @@ -97,8 +97,32 @@ void SCSIHD::AddFormatPage(map>& pages, bool changeable) const EnrichFormatPage(pages, changeable, 1 << GetSectorSizeShiftCount()); } +// Page code 37 (25h) - DEC Unique Page + +void SCSIHD::AddDECUniquePage(map>& pages, bool changeable) const +{ + vector buf(25); + + // No changeable area + if (changeable) { + pages[0x25] = buf; + + return; + } + + buf[0] = static_cast (0x25 | 0x80); // page code, high bit set + buf[1] = static_cast (sizeof(buf) - 1); + buf[2] = static_cast (0x01); // drive does not auto-start + + pages[0x25] = buf; +} + void SCSIHD::AddVendorPage(map>& pages, int page, bool changeable) const { + // Page code 0x25: DEC unique + if (page == 0x25 || page == 0x3f) { + AddDECUniquePage(pages, changeable); + } // Page code 48 if (page == 0x30 || page == 0x3f) { AddAppleVendorModePage(pages, changeable); diff --git a/cpp/devices/scsihd.h b/cpp/devices/scsihd.h index 95ded11aad..8f5c5121b7 100644 --- a/cpp/devices/scsihd.h +++ b/cpp/devices/scsihd.h @@ -40,6 +40,7 @@ class SCSIHD : public Disk void ModeSelect(scsi_defs::scsi_command, cdb_t, span, int) override; void AddFormatPage(map>&, bool) const override; + void AddDECUniquePage(map>&, bool) const; void AddVendorPage(map>&, int, bool) const override; private: From e5b00324f56921285234033bbf475e25f0fd54f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20K=C3=A4mpf?= Date: Sun, 14 Jan 2024 11:53:01 +0100 Subject: [PATCH 2/3] Add test for ModeSense page 0x25 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Klaus Kämpf --- cpp/test/mocks.h | 1 + cpp/test/scsihd_nec_test.cpp | 3 ++- cpp/test/scsihd_test.cpp | 17 ++++++++++++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/cpp/test/mocks.h b/cpp/test/mocks.h index 919afd8de9..103a911dfe 100644 --- a/cpp/test/mocks.h +++ b/cpp/test/mocks.h @@ -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, DECUniquePage); FRIEND_TEST(ScsiHdTest, GetSectorSizes); FRIEND_TEST(ScsiHdTest, ModeSelect); FRIEND_TEST(PiscsiExecutorTest, SetSectorSize); diff --git a/cpp/test/scsihd_nec_test.cpp b/cpp/test/scsihd_nec_test.cpp index 6b5cbd7ce4..bbcfed3946 100644 --- a/cpp/test/scsihd_nec_test.cpp +++ b/cpp/test/scsihd_nec_test.cpp @@ -18,11 +18,12 @@ using namespace filesystem; void ScsiHdNecTest_SetUpModePages(map>& 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()); } diff --git a/cpp/test/scsihd_test.cpp b/cpp/test/scsihd_test.cpp index 693f450bfe..921b9f6383 100644 --- a/cpp/test/scsihd_test.cpp +++ b/cpp/test/scsihd_test.cpp @@ -13,11 +13,12 @@ void ScsiHdTest_SetUpModePages(map>& 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()); } @@ -101,6 +102,20 @@ TEST(ScsiHdTest, SetUpModePages) ScsiHdTest_SetUpModePages(pages); } +TEST(ScsiHdTest, DECUniquePage) +{ + map> pages; + vector 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 (0x25 | 0x80), buf[0]); + EXPECT_EQ(static_cast (0x17), buf[1]); + EXPECT_EQ(static_cast (0x01), buf[2]); +} + TEST(ScsiHdTest, ModeSelect) { MockSCSIHD hd({ 512 }); From 753a614f3c4a88b298c4c0376e03bf5a1a46851d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20K=C3=A4mpf?= Date: Mon, 15 Jan 2024 18:56:25 +0100 Subject: [PATCH 3/3] Rename DECUniquePage to DECSpecialFunctionControlPage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Klaus Kämpf --- cpp/devices/scsihd.cpp | 8 ++++---- cpp/devices/scsihd.h | 2 +- cpp/test/mocks.h | 2 +- cpp/test/scsihd_test.cpp | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cpp/devices/scsihd.cpp b/cpp/devices/scsihd.cpp index 6a2a86343b..ed3bc153e2 100644 --- a/cpp/devices/scsihd.cpp +++ b/cpp/devices/scsihd.cpp @@ -97,9 +97,9 @@ void SCSIHD::AddFormatPage(map>& pages, bool changeable) const EnrichFormatPage(pages, changeable, 1 << GetSectorSizeShiftCount()); } -// Page code 37 (25h) - DEC Unique Page +// Page code 37 (25h) - DEC Special Function Control page -void SCSIHD::AddDECUniquePage(map>& pages, bool changeable) const +void SCSIHD::AddDECSpecialFunctionControlPage(map>& pages, bool changeable) const { vector buf(25); @@ -119,9 +119,9 @@ void SCSIHD::AddDECUniquePage(map>& pages, bool changeable) co void SCSIHD::AddVendorPage(map>& pages, int page, bool changeable) const { - // Page code 0x25: DEC unique + // Page code 0x25: DEC Special Function Control page if (page == 0x25 || page == 0x3f) { - AddDECUniquePage(pages, changeable); + AddDECSpecialFunctionControlPage(pages, changeable); } // Page code 48 if (page == 0x30 || page == 0x3f) { diff --git a/cpp/devices/scsihd.h b/cpp/devices/scsihd.h index 8f5c5121b7..cd00191af5 100644 --- a/cpp/devices/scsihd.h +++ b/cpp/devices/scsihd.h @@ -40,7 +40,7 @@ class SCSIHD : public Disk void ModeSelect(scsi_defs::scsi_command, cdb_t, span, int) override; void AddFormatPage(map>&, bool) const override; - void AddDECUniquePage(map>&, bool) const; + void AddDECSpecialFunctionControlPage(map>&, bool) const; void AddVendorPage(map>&, int, bool) const override; private: diff --git a/cpp/test/mocks.h b/cpp/test/mocks.h index 103a911dfe..dd3c8268ff 100644 --- a/cpp/test/mocks.h +++ b/cpp/test/mocks.h @@ -360,7 +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, DECUniquePage); + FRIEND_TEST(ScsiHdTest, DECSpecialFunctionControlPage); FRIEND_TEST(ScsiHdTest, GetSectorSizes); FRIEND_TEST(ScsiHdTest, ModeSelect); FRIEND_TEST(PiscsiExecutorTest, SetSectorSize); diff --git a/cpp/test/scsihd_test.cpp b/cpp/test/scsihd_test.cpp index 921b9f6383..81efae30ad 100644 --- a/cpp/test/scsihd_test.cpp +++ b/cpp/test/scsihd_test.cpp @@ -102,7 +102,7 @@ TEST(ScsiHdTest, SetUpModePages) ScsiHdTest_SetUpModePages(pages); } -TEST(ScsiHdTest, DECUniquePage) +TEST(ScsiHdTest, DECSpecialFunctionControlPage) { map> pages; vector buf;