mirror of
https://github.com/akuker/RASCSI.git
synced 2025-04-06 22:37:17 +00:00
Added support for .hd1 (SCSI-1) image files (#828)
* Added support for .hd1 (SCSI-1) image files * Update c-cpp.yml * Fixed unit test warnings * Fixed wrong scan default default (must be 1, not -1) * Updated max length check * Removed file not present in develop branch * Added unit test * Added workflow configurations and README updates (#832) * automated test try 1 * filter branches * filter branches * filter branches * filter branches * filter branches * Configured build and test CI workflows * enable for all branches * Update README.md * Update README.md Co-authored-by: Tony Kuker <akuker@gmail.com> * Fix simple SonarCloud issues (#834) * Fixing SonarCloud issues, first round * Fixing SonarCLoud issues, next round * Fixing SonarQube issues, next round * Fixed warning * Replaced empty constructors/destructors with = default; * Fixed warning * Replaced new * Use constants instead of macros * Use structured binding declarations * Use init statements for if * Use string views * Use enum class, use using instead of typedef * Fixed more SonarCloud warnings * Replaced redundant/duplicate types with auto * Devlared methods const * Memory management update * Fixed warning * Added missing const * Improved RaScsiResponse memory management * Improved memory management * Improved memory management * Replaced macros by constants, removed unused constants * Made member private * Fixed warning * Added comment * Fixed shadowing warnings * Cleanup * Cleanup * Cleanup * Fixed shadowing warning * Removed unused code * Fixed more warnings * Removed obsolete casts * Fixed warnings * Removed unused field * Removed library not needed by rasctl * Include cleanup * Updated platform check for better compatibility * Improved check for invalid option. This prevents rasctl to break on macos. * Updated option check * Fixed typo * Added TODO * Removed macro * Scope update * Replaced macro * Added TODO, update memory management * Fixed typo * Replaced NULL by nullptr * Use more structured bindings * Added TODO * Use calloc instead of mallco to not need memset * Fixed warnings * Fixed SonarQube initialization issues * Fixed warning * Cleaned up override/virtual/final * Fixed warnings * Constructor update * Fixed tests * Improved memory management * Added missing const * Added const * Fixed two bugs reported by SonarCloud * Fix SonarCloud hotspot * Fixed memory management * Memory management update * Addressing hotspot by using strncpy * Fixed SonarCloud issues * Fixed SonarQube issues * Added missing const * Added const * Added const * Suppress false positive * Added SonarQube suppressions for false positives * Added suppresoin * Fixed code smells * Reverted changes that is a SonarQube issue, but caused problems with -O3 * Removed TODO based on review * Update c-cpp.yml * Finalized merge Co-authored-by: akuker <34318535+akuker@users.noreply.github.com> Co-authored-by: Tony Kuker <akuker@gmail.com>
This commit is contained in:
parent
e7004e4ea9
commit
d80fbec03d
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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<SCSIHD_NEC>();
|
||||
} else {
|
||||
device = make_unique<SCSIHD>(sector_sizes[SCHD], false);
|
||||
device = make_unique<SCSIHD>(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") {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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<uint32_t>& sector_sizes, bool removable) : Disk(removable ? "SCRM" : "SCHD")
|
||||
SCSIHD::SCSIHD(const unordered_set<uint32_t>& 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<BYTE> 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)
|
||||
|
@ -22,8 +22,9 @@
|
||||
class SCSIHD : public Disk, public FileSupport
|
||||
{
|
||||
public:
|
||||
SCSIHD(const unordered_set<uint32_t>&, bool);
|
||||
~SCSIHD() override = default;
|
||||
|
||||
SCSIHD(const unordered_set<uint32_t>&, 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<int, vector<BYTE>>&, bool) const override;
|
||||
void AddVendorPage(map<int, vector<BYTE>>&, int, bool) const override;
|
||||
|
||||
private:
|
||||
|
||||
scsi_defs::scsi_level scsi_level;
|
||||
};
|
||||
|
@ -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");
|
||||
|
@ -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<Device *> devices = device_factory.GetAllDevices();
|
||||
EXPECT_EQ(1, devices.size());
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user