mirror of
https://github.com/dingusdev/dingusppc.git
synced 2024-12-23 21:29:28 +00:00
machinepdm: properly insert SCSI hard disk image.
Skip SCSI hard disk registration if no disk image was given.
This commit is contained in:
parent
6ffe28a8a4
commit
8abefb8f8d
@ -40,12 +40,11 @@ using namespace std;
|
||||
ScsiHardDisk::ScsiHardDisk(int my_id) : ScsiDevice(my_id) {
|
||||
supports_types(HWCompType::SCSI_DEV);
|
||||
}
|
||||
|
||||
void ScsiHardDisk::insert_image(std::string filename) {
|
||||
|
||||
void ScsiHardDisk::insert_image(std::string filename) {
|
||||
//We don't want to store everything in memory, but
|
||||
//we want to keep the hard disk available.
|
||||
this->hdd_img.open(filename, ios::out | ios::in | ios::binary);
|
||||
this->hdd_img.open(filename, ios::out | ios::in | ios::binary);
|
||||
|
||||
// Taken from:
|
||||
// https://stackoverflow.com/questions/22984956/tellg-function-give-wrong-size-of-file/22986486
|
||||
@ -247,7 +246,7 @@ static const PropMap SCSI_HD_Properties = {
|
||||
{"hdd_wr_prot", new BinProperty(0)},
|
||||
};
|
||||
|
||||
static const DeviceDescription SCSI_HD_Descriptor =
|
||||
static const DeviceDescription SCSI_HD_Descriptor =
|
||||
{ScsiHardDisk::create, {}, SCSI_HD_Properties};
|
||||
|
||||
REGISTER_DEVICE(ScsiDevice, SCSI_HD_Descriptor);
|
||||
REGISTER_DEVICE(ScsiHD, SCSI_HD_Descriptor);
|
||||
|
@ -83,9 +83,15 @@ int initialize_pdm(std::string& id)
|
||||
gMachineObj->add_device("SCSI0", std::unique_ptr<ScsiBus>(new ScsiBus()));
|
||||
auto scsi_bus = dynamic_cast<ScsiBus*>(gMachineObj->get_comp_by_name("SCSI0"));
|
||||
|
||||
// attach SCSI HD to the main bus, ID #0
|
||||
gMachineObj->add_device("SCSI_HD", std::unique_ptr<ScsiHardDisk>(new ScsiHardDisk(0)));
|
||||
scsi_bus->register_device(0, dynamic_cast<ScsiDevice*>(gMachineObj->get_comp_by_name("SCSI_HD")));
|
||||
std::string hd_image_path = GET_STR_PROP("hdd_img");
|
||||
if (!hd_image_path.empty()) {
|
||||
// attach SCSI HD to the main bus, ID #0
|
||||
gMachineObj->add_device("SCSI_HD", std::unique_ptr<ScsiHardDisk>(new ScsiHardDisk(0)));
|
||||
scsi_bus->register_device(0, dynamic_cast<ScsiDevice*>(gMachineObj->get_comp_by_name("SCSI_HD")));
|
||||
// insert specified disk image
|
||||
auto my_hd = dynamic_cast<ScsiHardDisk*>(gMachineObj->get_comp_by_name("SCSI_HD"));
|
||||
my_hd->insert_image(hd_image_path);
|
||||
}
|
||||
|
||||
// Init virtual CPU and request MPC601
|
||||
ppc_cpu_init(hmc_obj, PPC_VER::MPC601, 7812500ULL);
|
||||
@ -113,7 +119,7 @@ static const PropMap pm6100_settings = {
|
||||
};
|
||||
|
||||
static vector<string> pm6100_devices = {
|
||||
"HMC", "Amic"
|
||||
"HMC", "Amic", "ScsiHD"
|
||||
};
|
||||
|
||||
static const MachineDescription pm6100_descriptor = {
|
||||
|
Loading…
Reference in New Issue
Block a user