From ef6cd97656e3e8d9d1fc7d9b308624cf0fd95a89 Mon Sep 17 00:00:00 2001 From: Uwe Seimet <48174652+uweseimet@users.noreply.github.com> Date: Wed, 15 Mar 2023 22:38:44 +0100 Subject: [PATCH] Improve OpenVMS/VAX compatibility (issue #1117) (#1123) * Set TB, PER and DTE bits in read/write error recovery page * Fixed typo * Added unit test * Comment update --- cpp/devices/disk.cpp | 7 ++++++- cpp/test/mocks.h | 3 ++- cpp/test/scsihd_nec_test.cpp | 16 +++++++++++++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/cpp/devices/disk.cpp b/cpp/devices/disk.cpp index 63574ad3..8649103f 100644 --- a/cpp/devices/disk.cpp +++ b/cpp/devices/disk.cpp @@ -396,7 +396,12 @@ void Disk::SetUpModePages(map>& pages, int page, bool changeab void Disk::AddErrorPage(map>& pages, bool) const { // Retry count is 0, limit time uses internal default value - pages[1] = vector(12); + vector buf(12); + + // TB, PER, DTE (required for OpenVMS/VAX compatibility, see issue #1117) + buf[2] = (byte)0x26; + + pages[1] = buf; } void Disk::AddFormatPage(map>& pages, bool changeable) const diff --git a/cpp/test/mocks.h b/cpp/test/mocks.h index ef49fa6b..f654054d 100644 --- a/cpp/test/mocks.h +++ b/cpp/test/mocks.h @@ -3,7 +3,7 @@ // SCSI Target Emulator PiSCSI // for Raspberry Pi // -// Copyright (C) 2022 Uwe Seimet +// Copyright (C) 2022-2023 Uwe Seimet // //--------------------------------------------------------------------------- @@ -358,6 +358,7 @@ class MockSCSIHD : public SCSIHD //NOSONAR Ignore inheritance hierarchy depth in class MockSCSIHD_NEC : public SCSIHD_NEC //NOSONAR Ignore inheritance hierarchy depth in unit tests { FRIEND_TEST(ScsiHdNecTest, SetUpModePages); + FRIEND_TEST(ScsiHdNecTest, TestAddErrorPage); FRIEND_TEST(ScsiHdNecTest, TestAddFormatPage); FRIEND_TEST(ScsiHdNecTest, TestAddDrivePage); FRIEND_TEST(PiscsiExecutorTest, ProcessDeviceCmd); diff --git a/cpp/test/scsihd_nec_test.cpp b/cpp/test/scsihd_nec_test.cpp index 9ddf9a11..cfff8485 100644 --- a/cpp/test/scsihd_nec_test.cpp +++ b/cpp/test/scsihd_nec_test.cpp @@ -3,7 +3,7 @@ // SCSI Target Emulator PiSCSI // for Raspberry Pi // -// Copyright (C) 2022 Uwe Seimet +// Copyright (C) 2022-2023 Uwe Seimet // //--------------------------------------------------------------------------- @@ -47,6 +47,20 @@ TEST(ScsiHdNecTest, SetUpModePages) ScsiHdNecTest_SetUpModePages(pages); } +TEST(ScsiHdNecTest, TestAddErrorPage) +{ + map> pages; + MockSCSIHD_NEC hd(0); + + hd.SetBlockCount(0x1234); + hd.SetReady(true); + // Non changeable + hd.SetUpModePages(pages, 0x01, false); + EXPECT_EQ(1, pages.size()) << "Unexpected number of mode pages"; + const vector& page_1 = pages[1]; + EXPECT_EQ(0x26, to_integer(page_1[2])); +} + TEST(ScsiHdNecTest, TestAddFormatPage) { map> pages;