Slight code clean-up

Prevents crashing
This commit is contained in:
dingusdev 2022-10-30 15:38:09 -07:00
parent 46a0e82258
commit b480903c7a
6 changed files with 40 additions and 11 deletions

View File

@ -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": []
}
]

View File

@ -21,6 +21,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
/** @file Heathrow hard drive controller */
#include <devices/deviceregistry.h>
#include <devices/common/ide/ide_hd.h>
#include <fstream>
#include <limits>
@ -114,4 +115,10 @@ void IdeHardDisk::perform_command(uint32_t command) {
default:
LOG_F(WARNING, "Attempted to execute IDE command: %x", command);
}
}
}
static const DeviceDescription IDE_Descriptor = {
IdeHardDisk::create, {}, {}
};
REGISTER_DEVICE(IdeHardDisk, IDE_Descriptor);

View File

@ -190,7 +190,7 @@ private:
std::array<ScsiDevice*, SCSI_MAX_DEVS> 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;

View File

@ -37,15 +37,15 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
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);

View File

@ -35,6 +35,11 @@ public:
ScsiHardDisk(int my_id);
~ScsiHardDisk() = default;
static std::unique_ptr<HWComponent> create() {
return std::unique_ptr<ScsiHardDisk>(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;

View File

@ -81,6 +81,9 @@ HeathrowIC::HeathrowIC() : PCIDevice("mac-io/heathrow"), InterruptCtrl()
// connect IDE HW
this->ide_0 = dynamic_cast<IdeHardDisk*>(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<EsccController*>(gMachineObj->get_comp_by_name("Escc"));