From 2d364f16d8018288906c5074d4b78f24f45227dc Mon Sep 17 00:00:00 2001 From: Uwe Seimet Date: Wed, 25 Aug 2021 00:18:21 +0200 Subject: [PATCH] Device factory sets device features --- src/raspberrypi/devices/device_factory.cpp | 49 ++++++++++++++++---- src/raspberrypi/devices/sasihd.cpp | 1 - src/raspberrypi/devices/scsi_daynaport.cpp | 6 --- src/raspberrypi/devices/scsi_host_bridge.cpp | 4 -- src/raspberrypi/devices/scsicd.cpp | 5 -- src/raspberrypi/devices/scsihd.cpp | 2 - src/raspberrypi/devices/scsihd_nec.cpp | 4 -- src/raspberrypi/devices/scsimo.cpp | 4 -- 8 files changed, 40 insertions(+), 35 deletions(-) diff --git a/src/raspberrypi/devices/device_factory.cpp b/src/raspberrypi/devices/device_factory.cpp index 266ff03f..518509d6 100644 --- a/src/raspberrypi/devices/device_factory.cpp +++ b/src/raspberrypi/devices/device_factory.cpp @@ -44,33 +44,64 @@ Device *DeviceFactory::CreateDevice(PbDeviceType& type, const string& filename, } } + Device *device = NULL; + switch (type) { case SAHD: - return new SASIHD(); + device = new SASIHD(); + break; case SCHD: if (ext == "hdn" || ext == "hdi" || ext == "nhd") { - return new SCSIHD_NEC(); + device = new SCSIHD_NEC(); + ((Disk *)device)->SetVendor("NEC"); } else { - return new SCSIHD(); + device = new SCSIHD(); + device->SetProtectable(true); + ((Disk *)device)->SetSectorSizeConfigurable(true); } + break; + case SCRM: - return new SCSIHD(true); + device = new SCSIHD(true); + device->SetProtectable(true); + device->SetLockable(true); + ((Disk *)device)->SetSectorSizeConfigurable(true); + break; case SCMO: - return new SCSIMO(); + device = new SCSIMO(); + device->SetProtectable(true); + device->SetRemovable(true); + device->SetLockable(true); + device->SetProduct("SCSI MO"); + break; case SCCD: - return new SCSICD(); + device = new SCSICD(); + device->SetReadOnly(true); + device->SetRemovable(true); + device->SetLockable(true); + device->SetProduct("SCSI CD-ROM"); + break; case SCBR: - return new SCSIBR(); + device = new SCSIBR(); + device->SetProduct("BRIDGE"); + break; case SCDP: - return new SCSIDaynaPort(); + device = new SCSIDaynaPort(); + device->SetVendor("Dayna"); + device->SetProduct("SCSI/Link"); + device->SetRevision("1.4a"); + break; default: - return NULL; + assert(false); + break; } + + return device; } diff --git a/src/raspberrypi/devices/sasihd.cpp b/src/raspberrypi/devices/sasihd.cpp index 00b40236..97f136fc 100644 --- a/src/raspberrypi/devices/sasihd.cpp +++ b/src/raspberrypi/devices/sasihd.cpp @@ -31,7 +31,6 @@ //--------------------------------------------------------------------------- SASIHD::SASIHD() : Disk("SAHD") { - SetProtectable(true); } //--------------------------------------------------------------------------- diff --git a/src/raspberrypi/devices/scsi_daynaport.cpp b/src/raspberrypi/devices/scsi_daynaport.cpp index ed06f471..6a712697 100644 --- a/src/raspberrypi/devices/scsi_daynaport.cpp +++ b/src/raspberrypi/devices/scsi_daynaport.cpp @@ -45,12 +45,6 @@ const BYTE SCSIDaynaPort::m_apple_talk_addr[6] = { 0x09, 0x00, 0x07, 0xff, 0xff, //--------------------------------------------------------------------------- SCSIDaynaPort::SCSIDaynaPort() : Disk("SCDP") { - SetRemovable(false); - - SetVendor("Dayna"); - SetProduct("SCSI/Link"); - SetRevision("1.4a"); - AddCommand(SCSIDEV::eCmdTestUnitReady, "TestUnitReady", &SCSIDaynaPort::TestUnitReady); AddCommand(SCSIDEV::eCmdRead6, "Read6", &SCSIDaynaPort::Read6); AddCommand(SCSIDEV::eCmdWrite6, "Write6", &SCSIDaynaPort::Write6); diff --git a/src/raspberrypi/devices/scsi_host_bridge.cpp b/src/raspberrypi/devices/scsi_host_bridge.cpp index a60d52db..1cdb85dd 100644 --- a/src/raspberrypi/devices/scsi_host_bridge.cpp +++ b/src/raspberrypi/devices/scsi_host_bridge.cpp @@ -36,10 +36,6 @@ using namespace std; //--------------------------------------------------------------------------- SCSIBR::SCSIBR() : Disk("SCBR") { - SetRemovable(false); - - SetProduct("BRIDGE"); - fsoptlen = 0; fsoutlen = 0; fsresult = 0; diff --git a/src/raspberrypi/devices/scsicd.cpp b/src/raspberrypi/devices/scsicd.cpp index 48e354f9..f8272838 100644 --- a/src/raspberrypi/devices/scsicd.cpp +++ b/src/raspberrypi/devices/scsicd.cpp @@ -226,11 +226,6 @@ bool CDTrack::IsAudio() const //--------------------------------------------------------------------------- SCSICD::SCSICD() : Disk("SCCD"), MmcDevice(), FileSupport() { - SetRemovable(true); - SetReadOnly(true); - - SetProduct("SCSI CD-ROM"); - // NOT in raw format rawfile = false; diff --git a/src/raspberrypi/devices/scsihd.cpp b/src/raspberrypi/devices/scsihd.cpp index e670a9b4..57cbc7f6 100644 --- a/src/raspberrypi/devices/scsihd.cpp +++ b/src/raspberrypi/devices/scsihd.cpp @@ -33,8 +33,6 @@ SCSIHD::SCSIHD(bool removable) : Disk(removable ? "SCRM" : "SCHD") { SetRemovable(removable); - SetProtectable(true); - SetSectorSizeConfigurable(true); } //--------------------------------------------------------------------------- diff --git a/src/raspberrypi/devices/scsihd_nec.cpp b/src/raspberrypi/devices/scsihd_nec.cpp index f22e6e13..3c461d82 100644 --- a/src/raspberrypi/devices/scsihd_nec.cpp +++ b/src/raspberrypi/devices/scsihd_nec.cpp @@ -31,10 +31,6 @@ //--------------------------------------------------------------------------- SCSIHD_NEC::SCSIHD_NEC() : SCSIHD() { - SetSectorSizeConfigurable(false); - - SetVendor("NEC"); - // Work initialization cylinders = 0; heads = 0; diff --git a/src/raspberrypi/devices/scsimo.cpp b/src/raspberrypi/devices/scsimo.cpp index 60dfbfb7..112a6536 100644 --- a/src/raspberrypi/devices/scsimo.cpp +++ b/src/raspberrypi/devices/scsimo.cpp @@ -32,10 +32,6 @@ //--------------------------------------------------------------------------- SCSIMO::SCSIMO() : Disk("SCMO") { - SetRemovable(true); - SetProtectable(true); - - SetProduct("SCSI MO"); } //---------------------------------------------------------------------------