mirror of
https://github.com/dingusdev/dingusppc.git
synced 2025-01-11 05:29:43 +00:00
Fix IDE functionality
This commit is contained in:
parent
a58ce8aeb3
commit
311538b81d
@ -43,6 +43,7 @@ enum HWCompType {
|
|||||||
SCSI_BUS = 1ULL << 20, /* SCSI bus */
|
SCSI_BUS = 1ULL << 20, /* SCSI bus */
|
||||||
SCSI_HOST = 1ULL << 21, /* SCSI host adapter */
|
SCSI_HOST = 1ULL << 21, /* SCSI host adapter */
|
||||||
SCSI_DEV = 1ULL << 22, /* SCSI device */
|
SCSI_DEV = 1ULL << 22, /* SCSI device */
|
||||||
|
IDE_BUS = 1ULL << 23, /* IDE bus */
|
||||||
IDE_DEV = 1ULL << 25, /* IDE device */
|
IDE_DEV = 1ULL << 25, /* IDE device */
|
||||||
SND_SERVER = 1ULL << 31, /* host sound server */
|
SND_SERVER = 1ULL << 31, /* host sound server */
|
||||||
FLOPPY_CTRL = 1ULL << 32, /* floppy disk controller */
|
FLOPPY_CTRL = 1ULL << 32, /* floppy disk controller */
|
||||||
|
@ -33,12 +33,12 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
IdeHardDisk::IdeHardDisk() {
|
IdeHardDisk::IdeHardDisk() {
|
||||||
this->name = "IDE0";
|
this->name = "IdeHardDisk";
|
||||||
supports_types(HWCompType::IDE_DEV);
|
supports_types(HWCompType::IDE_DEV);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdeHardDisk::insert_image(std::string filename) {
|
void IdeHardDisk::insert_image(std::string filename) {
|
||||||
hdd_img.open(filename);
|
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
|
||||||
@ -82,25 +82,37 @@ void IdeHardDisk::write(int reg, uint32_t value) {
|
|||||||
switch (reg) {
|
switch (reg) {
|
||||||
case IDE_Reg::IDE_DATA:
|
case IDE_Reg::IDE_DATA:
|
||||||
regs[IDE_Reg::IDE_DATA] = value;
|
regs[IDE_Reg::IDE_DATA] = value;
|
||||||
|
break;
|
||||||
|
break;
|
||||||
case IDE_Reg::FEATURES:
|
case IDE_Reg::FEATURES:
|
||||||
regs[IDE_Reg::FEATURES] = value;
|
regs[IDE_Reg::FEATURES] = value;
|
||||||
|
break;
|
||||||
case IDE_Reg::SEC_COUNT:
|
case IDE_Reg::SEC_COUNT:
|
||||||
regs[IDE_Reg::SEC_COUNT] = value;
|
regs[IDE_Reg::SEC_COUNT] = value;
|
||||||
|
break;
|
||||||
case IDE_Reg::SEC_NUM:
|
case IDE_Reg::SEC_NUM:
|
||||||
regs[IDE_Reg::SEC_NUM] = value;
|
regs[IDE_Reg::SEC_NUM] = value;
|
||||||
|
break;
|
||||||
case IDE_Reg::CYL_LOW:
|
case IDE_Reg::CYL_LOW:
|
||||||
regs[IDE_Reg::CYL_LOW] = value;
|
regs[IDE_Reg::CYL_LOW] = value;
|
||||||
|
break;
|
||||||
case IDE_Reg::CYL_HIGH:
|
case IDE_Reg::CYL_HIGH:
|
||||||
regs[IDE_Reg::CYL_HIGH] = value;
|
regs[IDE_Reg::CYL_HIGH] = value;
|
||||||
|
break;
|
||||||
case IDE_Reg::DRIVE_HEAD:
|
case IDE_Reg::DRIVE_HEAD:
|
||||||
regs[IDE_Reg::DRIVE_HEAD] = value;
|
regs[IDE_Reg::DRIVE_HEAD] = value;
|
||||||
|
break;
|
||||||
case IDE_Reg::COMMAND:
|
case IDE_Reg::COMMAND:
|
||||||
|
regs[IDE_Reg::COMMAND] = value;
|
||||||
LOG_F(0, "Executing COMMAND for IDE: %x", value);
|
LOG_F(0, "Executing COMMAND for IDE: %x", value);
|
||||||
perform_command(value);
|
perform_command(value);
|
||||||
|
break;
|
||||||
case IDE_Reg::DEV_CTRL:
|
case IDE_Reg::DEV_CTRL:
|
||||||
regs[IDE_Reg::DEV_CTRL] = value;
|
regs[IDE_Reg::DEV_CTRL] = value;
|
||||||
|
break;
|
||||||
case IDE_Reg::TIME_CONFIG:
|
case IDE_Reg::TIME_CONFIG:
|
||||||
regs[IDE_Reg::TIME_CONFIG] = value;
|
regs[IDE_Reg::TIME_CONFIG] = value;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
LOG_F(WARNING, "Attempted to write unknown IDE register: %x", reg);
|
LOG_F(WARNING, "Attempted to write unknown IDE register: %x", reg);
|
||||||
}
|
}
|
||||||
@ -110,8 +122,10 @@ void IdeHardDisk::perform_command(uint32_t command) {
|
|||||||
switch (command) {
|
switch (command) {
|
||||||
case IDE_Cmd::READ_SECTOR:
|
case IDE_Cmd::READ_SECTOR:
|
||||||
LOG_F(WARNING, "Trying to read sector with: %x", command);
|
LOG_F(WARNING, "Trying to read sector with: %x", command);
|
||||||
|
break;
|
||||||
case IDE_Cmd::WRITE_SECTOR:
|
case IDE_Cmd::WRITE_SECTOR:
|
||||||
LOG_F(WARNING, "Trying to write sector with: %x", command);
|
LOG_F(WARNING, "Trying to write sector with: %x", command);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
LOG_F(WARNING, "Attempted to execute IDE command: %x", command);
|
LOG_F(WARNING, "Attempted to execute IDE command: %x", command);
|
||||||
}
|
}
|
||||||
|
@ -80,10 +80,12 @@ HeathrowIC::HeathrowIC() : PCIDevice("mac-io/heathrow"), InterruptCtrl()
|
|||||||
this->mesh = dynamic_cast<MESHController*>(gMachineObj->get_comp_by_name("Mesh"));
|
this->mesh = dynamic_cast<MESHController*>(gMachineObj->get_comp_by_name("Mesh"));
|
||||||
|
|
||||||
// connect IDE HW
|
// connect IDE HW
|
||||||
this->ide_0 = dynamic_cast<IdeHardDisk*>(gMachineObj->get_comp_by_name("IDE0"));
|
this->ide_1 = dynamic_cast<IdeHardDisk*>(gMachineObj->get_comp_by_name("IdeHardDisk"));
|
||||||
if (!StrProperty("hdd_img").get_string().empty()) {
|
|
||||||
this->ide_0->insert_image(GET_STR_PROP("hdd_img"));
|
//std::string hd_image_path = GET_STR_PROP("hdd_img");
|
||||||
}
|
//if (!hd_image_path.empty()) {
|
||||||
|
// this->ide_1->insert_image(hd_image_path);
|
||||||
|
//}
|
||||||
|
|
||||||
// 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"));
|
||||||
@ -168,8 +170,9 @@ uint32_t HeathrowIC::read(uint32_t rgn_start, uint32_t offset, int size) {
|
|||||||
case 0x17:
|
case 0x17:
|
||||||
res = this->viacuda->read((offset - 0x16000) >> 9);
|
res = this->viacuda->read((offset - 0x16000) >> 9);
|
||||||
break;
|
break;
|
||||||
case 0x20:
|
case 0x21: //IDE 1
|
||||||
res = this->ide_0->read((offset - 0x20000) >> 4);
|
LOG_F(0, "Read IDE offset=0x%X", offset);
|
||||||
|
res = this->ide_1->read((offset - 0x21000) >> 4);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (sub_addr >= 0x60) {
|
if (sub_addr >= 0x60) {
|
||||||
@ -216,8 +219,9 @@ void HeathrowIC::write(uint32_t rgn_start, uint32_t offset, uint32_t value, int
|
|||||||
case 0x17:
|
case 0x17:
|
||||||
this->viacuda->write((offset - 0x16000) >> 9, value);
|
this->viacuda->write((offset - 0x16000) >> 9, value);
|
||||||
break;
|
break;
|
||||||
case 0x20:
|
case 0x21:
|
||||||
this->ide_0->write((offset - 0x20000) >> 4, value);
|
LOG_F(0, "Write IDE offset=0x%X", offset);
|
||||||
|
this->ide_1->write(((offset - 0x21000) >> 4), value);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (sub_addr >= 0x60) {
|
if (sub_addr >= 0x60) {
|
||||||
@ -395,8 +399,7 @@ void HeathrowIC::clear_cpu_int()
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const vector<string> Heathrow_Subdevices = {
|
static const vector<string> Heathrow_Subdevices = {
|
||||||
"NVRAM", "ViaCuda", "Mesh", "Escc", "Swim3"
|
"NVRAM", "ViaCuda", "Mesh", "Escc", "Swim3", "IdeHardDisk"};
|
||||||
};
|
|
||||||
|
|
||||||
static const DeviceDescription Heathrow_Descriptor = {
|
static const DeviceDescription Heathrow_Descriptor = {
|
||||||
HeathrowIC::create, Heathrow_Subdevices, {}
|
HeathrowIC::create, Heathrow_Subdevices, {}
|
||||||
|
@ -231,7 +231,7 @@ private:
|
|||||||
ViaCuda* viacuda; // VIA cell with Cuda MCU attached to it
|
ViaCuda* viacuda; // VIA cell with Cuda MCU attached to it
|
||||||
MESHController* mesh; // MESH SCSI cell instance
|
MESHController* mesh; // MESH SCSI cell instance
|
||||||
EsccController* escc; // ESCC serial controller
|
EsccController* escc; // ESCC serial controller
|
||||||
IdeHardDisk* ide_0; // Internal ATA
|
IdeHardDisk* ide_1; // Internal ATA
|
||||||
Swim3::Swim3Ctrl* swim3; // floppy disk controller
|
Swim3::Swim3Ctrl* swim3; // floppy disk controller
|
||||||
|
|
||||||
std::unique_ptr<DMAChannel> snd_out_dma;
|
std::unique_ptr<DMAChannel> snd_out_dma;
|
||||||
|
@ -164,7 +164,7 @@ static const PropMap gossamer_settings = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static vector<string> pmg3_devices = {
|
static vector<string> pmg3_devices = {
|
||||||
"Grackle", "Heathrow", "AtiRageGT"
|
"Grackle", "Heathrow", "AtiRageGT", "IdeHardDisk"
|
||||||
};
|
};
|
||||||
|
|
||||||
static const MachineDescription pmg3dt_descriptor = {
|
static const MachineDescription pmg3dt_descriptor = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user