diff --git a/doc/rascsi.1 b/doc/rascsi.1 index 5b7c0877..92652948 100644 --- a/doc/rascsi.1 +++ b/doc/rascsi.1 @@ -25,6 +25,7 @@ The number (n) after the ID or HD identifier specifies the ID number for that de For SCSI: The ID is limited from 0-7. However, typically SCSI ID 7 is reserved for the "initiator" (the host computer). The LUN is limited from 0-31. .PP RaSCSI will determine the type of device based upon the file extension of the FILE argument. + hd1: SCSI Hard Disk image (generic, non-removable, SCSI-1) hds: SCSI Hard Disk image (generic, non-removable) hdr: SCSI Hard Disk image (generic, removable) hdn: SCSI Hard Disk image (NEC GENUINE) diff --git a/doc/rascsi_man_page.txt b/doc/rascsi_man_page.txt index f2187222..9950e90c 100644 --- a/doc/rascsi_man_page.txt +++ b/doc/rascsi_man_page.txt @@ -23,6 +23,7 @@ DESCRIPTION RaSCSI will determine the type of device based upon the file extension of the FILE argument. + hd1: SCSI Hard Disk image (generic, non-removable, SCSI-1) hds: SCSI Hard Disk image (generic, non-removable) hdr: SCSI Hard Disk image (generic, removable) hdn: SCSI Hard Disk image (NEC GENUINE) diff --git a/src/raspberrypi/devices/device_factory.cpp b/src/raspberrypi/devices/device_factory.cpp index d58b43f4..f8ba24cf 100644 --- a/src/raspberrypi/devices/device_factory.cpp +++ b/src/raspberrypi/devices/device_factory.cpp @@ -55,6 +55,7 @@ DeviceFactory::DeviceFactory() : sector_sizes({}), geometries({}), default_param default_params[SCLP]["cmd"] = "lp -oraw %f"; default_params[SCLP]["timeout"] = "30"; + extension_mapping["hd1"] = SCHD; extension_mapping["hds"] = SCHD; extension_mapping["hda"] = SCHD; extension_mapping["hdn"] = SCHD; @@ -172,7 +173,7 @@ Device *DeviceFactory::CreateDevice(PbDeviceType type, const string& filename, i if (string ext = GetExtension(filename); ext == "hdn" || ext == "hdi" || ext == "nhd") { device = make_unique(); } else { - device = make_unique(sector_sizes[SCHD], false); + device = make_unique(sector_sizes[SCHD], false, ext == "hd1" ? scsi_level::SCSI_1_CCS : scsi_level::SCSI_2); // Some Apple tools require a particular drive identification if (ext == "hda") { diff --git a/src/raspberrypi/devices/mode_page_device.cpp b/src/raspberrypi/devices/mode_page_device.cpp index 9f71ddeb..22399631 100644 --- a/src/raspberrypi/devices/mode_page_device.cpp +++ b/src/raspberrypi/devices/mode_page_device.cpp @@ -32,7 +32,7 @@ bool ModePageDevice::Dispatch() int ModePageDevice::AddModePages(const DWORD *cdb, BYTE *buf, int max_length) const { - if (max_length <= 0) { + if (max_length < 0) { return 0; } diff --git a/src/raspberrypi/devices/scsihd.cpp b/src/raspberrypi/devices/scsihd.cpp index acca418a..3173701b 100644 --- a/src/raspberrypi/devices/scsihd.cpp +++ b/src/raspberrypi/devices/scsihd.cpp @@ -13,6 +13,7 @@ // [ SCSI hard disk ] // //--------------------------------------------------------------------------- + #include "scsihd.h" #include "fileio.h" #include "rascsi_exceptions.h" @@ -21,8 +22,11 @@ static const char *DEFAULT_PRODUCT = "SCSI HD"; -SCSIHD::SCSIHD(const unordered_set& sector_sizes, bool removable) : Disk(removable ? "SCRM" : "SCHD") +SCSIHD::SCSIHD(const unordered_set& sector_sizes, bool removable, scsi_defs::scsi_level level) + : Disk(removable ? "SCRM" : "SCHD") { + this->scsi_level = level; + SetSectorSizes(sector_sizes); } @@ -95,7 +99,7 @@ void SCSIHD::Open(const Filepath& path) vector SCSIHD::InquiryInternal() const { - return HandleInquiry(device_type::DIRECT_ACCESS, scsi_level::SCSI_2, IsRemovable()); + return HandleInquiry(device_type::DIRECT_ACCESS, scsi_level, IsRemovable()); } void SCSIHD::ModeSelect(const DWORD *cdb, const BYTE *buf, int length) diff --git a/src/raspberrypi/devices/scsihd.h b/src/raspberrypi/devices/scsihd.h index eea8dd11..271701f4 100644 --- a/src/raspberrypi/devices/scsihd.h +++ b/src/raspberrypi/devices/scsihd.h @@ -22,8 +22,9 @@ class SCSIHD : public Disk, public FileSupport { public: - SCSIHD(const unordered_set&, bool); - ~SCSIHD() override = default; + + SCSIHD(const unordered_set&, bool, scsi_defs::scsi_level = scsi_level::SCSI_2); + virtual ~SCSIHD() {} void FinalizeSetup(const Filepath&, off_t); @@ -36,4 +37,8 @@ public: void AddFormatPage(map>&, bool) const override; void AddVendorPage(map>&, int, bool) const override; + +private: + + scsi_defs::scsi_level scsi_level; }; diff --git a/src/raspberrypi/rascsi.cpp b/src/raspberrypi/rascsi.cpp index ecc29921..7105220c 100644 --- a/src/raspberrypi/rascsi.cpp +++ b/src/raspberrypi/rascsi.cpp @@ -106,7 +106,8 @@ void Banner(int argc, char* argv[]) FPRT(stdout," m is the optional logical unit (LUN) (0-31).\n"); FPRT(stdout," FILE is a disk image file, \"daynaport\", \"bridge\", \"printer\" or \"services\".\n\n"); FPRT(stdout," Image type is detected based on file extension if no explicit type is specified.\n"); - FPRT(stdout," hds : SCSI HD image (Non-removable generic HD image)\n"); + FPRT(stdout," hd1 : SCSI-1 HD image (Non-removable generic SCSI-1 HD image)\n"); + FPRT(stdout," hds : SCSI HD image (Non-removable generic SCSI HD image)\n"); FPRT(stdout," hdr : SCSI HD image (Removable generic HD image)\n"); FPRT(stdout," hdn : SCSI HD image (NEC GENUINE)\n"); FPRT(stdout," hdi : SCSI HD image (Anex86 HD image)\n"); diff --git a/src/raspberrypi/test/device_factory_test.cpp b/src/raspberrypi/test/device_factory_test.cpp index 1a57ea42..ef1fd2e1 100644 --- a/src/raspberrypi/test/device_factory_test.cpp +++ b/src/raspberrypi/test/device_factory_test.cpp @@ -15,6 +15,7 @@ TEST(DeviceFactoryTest, GetTypeForFile) { + EXPECT_EQ(device_factory.GetTypeForFile("test.hd1"), SCHD); EXPECT_EQ(device_factory.GetTypeForFile("test.hds"), SCHD); EXPECT_EQ(device_factory.GetTypeForFile("test.HDS"), SCHD); EXPECT_EQ(device_factory.GetTypeForFile("test.hda"), SCHD); @@ -37,6 +38,7 @@ TEST(DeviceFactoryTest, LifeCycle) { Device *device = device_factory.CreateDevice(UNDEFINED, "services", -1); EXPECT_NE(nullptr, device); + EXPECT_EQ("SCHS", device->GetType()); list devices = device_factory.GetAllDevices(); EXPECT_EQ(1, devices.size()); diff --git a/src/raspberrypi/test/mode_pages_test.cpp b/src/raspberrypi/test/mode_pages_test.cpp index 5c0de6a9..403db572 100644 --- a/src/raspberrypi/test/mode_pages_test.cpp +++ b/src/raspberrypi/test/mode_pages_test.cpp @@ -29,6 +29,7 @@ TEST(ModePagesTest, ModePageDevice_AddModePages) MockModePageDevice device; cdb[2] = 0x3f; + EXPECT_EQ(0, device.AddModePages(cdb, buf, 0)) << "Allocation length was not limited"; EXPECT_EQ(1, device.AddModePages(cdb, buf, 1)) << "Allocation length was not limited"; cdb[2] = 0x00;