mirror of
https://github.com/dingusdev/dingusppc.git
synced 2025-01-11 05:29:43 +00:00
Slight code clean-up
Prevents crashing
This commit is contained in:
parent
46a0e82258
commit
b480903c7a
@ -9,8 +9,7 @@
|
|||||||
"installRoot": "${projectDir}\\out\\install\\${name}",
|
"installRoot": "${projectDir}\\out\\install\\${name}",
|
||||||
"cmakeCommandArgs": "",
|
"cmakeCommandArgs": "",
|
||||||
"buildCommandArgs": "-v",
|
"buildCommandArgs": "-v",
|
||||||
"ctestCommandArgs": "",
|
"ctestCommandArgs": ""
|
||||||
"variables": []
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "x64-Release",
|
"name": "x64-Release",
|
||||||
@ -21,7 +20,18 @@
|
|||||||
"cmakeCommandArgs": "",
|
"cmakeCommandArgs": "",
|
||||||
"buildCommandArgs": "-v",
|
"buildCommandArgs": "-v",
|
||||||
"ctestCommandArgs": "",
|
"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": []
|
"variables": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -21,6 +21,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
/** @file Heathrow hard drive controller */
|
/** @file Heathrow hard drive controller */
|
||||||
|
|
||||||
|
#include <devices/deviceregistry.h>
|
||||||
#include <devices/common/ide/ide_hd.h>
|
#include <devices/common/ide/ide_hd.h>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
@ -114,4 +115,10 @@ void IdeHardDisk::perform_command(uint32_t command) {
|
|||||||
default:
|
default:
|
||||||
LOG_F(WARNING, "Attempted to execute IDE command: %x", command);
|
LOG_F(WARNING, "Attempted to execute IDE command: %x", command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const DeviceDescription IDE_Descriptor = {
|
||||||
|
IdeHardDisk::create, {}, {}
|
||||||
|
};
|
||||||
|
|
||||||
|
REGISTER_DEVICE(IdeHardDisk, IDE_Descriptor);
|
@ -190,7 +190,7 @@ private:
|
|||||||
std::array<ScsiDevice*, SCSI_MAX_DEVS> devices;
|
std::array<ScsiDevice*, SCSI_MAX_DEVS> devices;
|
||||||
|
|
||||||
// per-device state of the control lines
|
// 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;
|
uint16_t ctrl_lines;
|
||||||
int cur_phase;
|
int cur_phase;
|
||||||
|
@ -37,15 +37,15 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
ScsiHardDisk::ScsiHardDisk(int my_id) : ScsiDevice(my_id)
|
ScsiHardDisk::ScsiHardDisk(int my_id) : ScsiDevice(my_id) {
|
||||||
{
|
|
||||||
supports_types(HWCompType::SCSI_DEV);
|
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 don't want to store everything in memory, but
|
||||||
//we want to keep the hard disk available.
|
//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:
|
// Taken from:
|
||||||
// https://stackoverflow.com/questions/22984956/tellg-function-give-wrong-size-of-file/22986486
|
// 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_img", new StrProperty("")},
|
||||||
{"hdd_wr_prot", new BinProperty(0)},
|
{"hdd_wr_prot", new BinProperty(0)},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const DeviceDescription SCSI_HD_Descriptor =
|
||||||
|
{ScsiHardDisk::create, {}, SCSI_HD_Properties};
|
||||||
|
|
||||||
|
REGISTER_DEVICE(ScsiDevice, SCSI_HD_Descriptor);
|
@ -35,6 +35,11 @@ public:
|
|||||||
ScsiHardDisk(int my_id);
|
ScsiHardDisk(int my_id);
|
||||||
~ScsiHardDisk() = default;
|
~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();
|
void process_command();
|
||||||
bool send_bytes(uint8_t* dst_ptr, int count) { return true; };
|
bool send_bytes(uint8_t* dst_ptr, int count) { return true; };
|
||||||
|
|
||||||
@ -57,7 +62,6 @@ protected:
|
|||||||
std::fstream hdd_img;
|
std::fstream hdd_img;
|
||||||
uint64_t img_size;
|
uint64_t img_size;
|
||||||
char img_buffer[1 << 17];
|
char img_buffer[1 << 17];
|
||||||
uint8_t scsi_command[12];
|
|
||||||
uint64_t file_offset = 0;
|
uint64_t file_offset = 0;
|
||||||
uint8_t status = ScsiError::NO_ERROR;
|
uint8_t status = ScsiError::NO_ERROR;
|
||||||
|
|
||||||
|
@ -81,6 +81,9 @@ HeathrowIC::HeathrowIC() : PCIDevice("mac-io/heathrow"), InterruptCtrl()
|
|||||||
|
|
||||||
// connect IDE HW
|
// connect IDE HW
|
||||||
this->ide_0 = dynamic_cast<IdeHardDisk*>(gMachineObj->get_comp_by_name("IDE0"));
|
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
|
// connect serial HW
|
||||||
this->escc = dynamic_cast<EsccController*>(gMachineObj->get_comp_by_name("Escc"));
|
this->escc = dynamic_cast<EsccController*>(gMachineObj->get_comp_by_name("Escc"));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user