diff --git a/CMakeSettings.json b/CMakeSettings.json index cec0924..87bed30 100644 --- a/CMakeSettings.json +++ b/CMakeSettings.json @@ -9,8 +9,7 @@ "installRoot": "${projectDir}\\out\\install\\${name}", "cmakeCommandArgs": "", "buildCommandArgs": "-v", - "ctestCommandArgs": "", - "variables": [] + "ctestCommandArgs": "" }, { "name": "x64-Release", @@ -21,7 +20,18 @@ "cmakeCommandArgs": "", "buildCommandArgs": "-v", "ctestCommandArgs": "", - "inheritEnvironments": [ "clang_cl_x64" ], + "inheritEnvironments": [ "clang_cl_x64" ] + }, + { + "name": "x86-Debug", + "generator": "Ninja", + "configurationType": "Debug", + "buildRoot": "${projectDir}\\out\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "msvc_x86" ], "variables": [] } ] diff --git a/devices/common/ide/ide_hd.cpp b/devices/common/ide/ide_hd.cpp index 3a7d97b..9b71c46 100644 --- a/devices/common/ide/ide_hd.cpp +++ b/devices/common/ide/ide_hd.cpp @@ -21,6 +21,7 @@ along with this program. If not, see . /** @file Heathrow hard drive controller */ +#include #include #include #include @@ -114,4 +115,10 @@ void IdeHardDisk::perform_command(uint32_t command) { default: LOG_F(WARNING, "Attempted to execute IDE command: %x", command); } -} \ No newline at end of file +} + +static const DeviceDescription IDE_Descriptor = { + IdeHardDisk::create, {}, {} +}; + +REGISTER_DEVICE(IdeHardDisk, IDE_Descriptor); \ No newline at end of file diff --git a/devices/common/scsi/scsi.h b/devices/common/scsi/scsi.h index 05c78fd..d59fd77 100644 --- a/devices/common/scsi/scsi.h +++ b/devices/common/scsi/scsi.h @@ -190,7 +190,7 @@ private: std::array devices; // per-device state of the control lines - uint16_t dev_ctrl_lines[SCSI_MAX_DEVS]; + uint16_t dev_ctrl_lines[SCSI_MAX_DEVS] = {}; uint16_t ctrl_lines; int cur_phase; diff --git a/devices/common/scsi/scsi_hd.cpp b/devices/common/scsi/scsi_hd.cpp index 13fbdb1..d725fe5 100644 --- a/devices/common/scsi/scsi_hd.cpp +++ b/devices/common/scsi/scsi_hd.cpp @@ -37,15 +37,15 @@ along with this program. If not, see . using namespace std; -ScsiHardDisk::ScsiHardDisk(int my_id) : ScsiDevice(my_id) -{ +ScsiHardDisk::ScsiHardDisk(int my_id) : ScsiDevice(my_id) { supports_types(HWCompType::SCSI_DEV); - - std::string hd_image_path = GET_STR_PROP("hdd_img"); +} + + 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(hd_image_path, 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 @@ -232,3 +232,8 @@ static const PropMap SCSI_HD_Properties = { {"hdd_img", new StrProperty("")}, {"hdd_wr_prot", new BinProperty(0)}, }; + +static const DeviceDescription SCSI_HD_Descriptor = + {ScsiHardDisk::create, {}, SCSI_HD_Properties}; + +REGISTER_DEVICE(ScsiDevice, SCSI_HD_Descriptor); \ No newline at end of file diff --git a/devices/common/scsi/scsi_hd.h b/devices/common/scsi/scsi_hd.h index 24d1aaf..a4a75dc 100644 --- a/devices/common/scsi/scsi_hd.h +++ b/devices/common/scsi/scsi_hd.h @@ -35,6 +35,11 @@ public: ScsiHardDisk(int my_id); ~ScsiHardDisk() = default; + static std::unique_ptr create() { + return std::unique_ptr(new ScsiHardDisk(0)); + } + + void insert_image(std::string filename); void process_command(); bool send_bytes(uint8_t* dst_ptr, int count) { return true; }; @@ -57,7 +62,6 @@ protected: std::fstream hdd_img; uint64_t img_size; char img_buffer[1 << 17]; - uint8_t scsi_command[12]; uint64_t file_offset = 0; uint8_t status = ScsiError::NO_ERROR; diff --git a/devices/ioctrl/heathrow.cpp b/devices/ioctrl/heathrow.cpp index 2e6ceb0..9697a9b 100644 --- a/devices/ioctrl/heathrow.cpp +++ b/devices/ioctrl/heathrow.cpp @@ -81,6 +81,9 @@ HeathrowIC::HeathrowIC() : PCIDevice("mac-io/heathrow"), InterruptCtrl() // connect IDE HW this->ide_0 = dynamic_cast(gMachineObj->get_comp_by_name("IDE0")); + if (!StrProperty("hdd_img").get_string().empty()) { + this->ide_0->insert_image(GET_STR_PROP("hdd_img")); + } // connect serial HW this->escc = dynamic_cast(gMachineObj->get_comp_by_name("Escc"));