Skip to content

Commit f2676e0

Browse files
joevtdingusdev
authored andcommitted
maciotwo: Make Ide1 optional.
Some Macs that use OHare do not have a second ATA bus exposed by Open Firmware. Allow Ide1 to not be included. # Conflicts: # devices/ioctrl/maciotwo.cpp
1 parent 48adf99 commit f2676e0

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

devices/ioctrl/maciotwo.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,13 @@ MacIoTwo::MacIoTwo(std::string name, uint16_t dev_id) : MacIoBase(name, dev_id)
4444
this->ide0_dma->connect(this->ide_0);
4545
this->ide_0->connect(this->ide0_dma.get());
4646

47-
this->ide_1 = dynamic_cast<IdeChannel*>(gMachineObj->get_comp_by_name("Ide1"));
47+
this->ide_1 = dynamic_cast<IdeChannel*>(gMachineObj->get_comp_by_name_optional("Ide1"));
4848
this->ide1_dma = std::unique_ptr<DMAChannel> (new DMAChannel("Ide1-Dma"));
4949
this->ide1_dma->register_dma_int(this, this->register_dma_int(IntSrc::DMA_IDE1));
50-
this->ide1_dma->connect(this->ide_1);
51-
this->ide_1->connect(this->ide1_dma.get());
50+
if (this->ide_1) {
51+
this->ide1_dma->connect(this->ide_1);
52+
this->ide_1->connect(this->ide1_dma.get());
53+
}
5254

5355
// connect Ethernet HW (Heathrow and Paddington)
5456
if (this->device_id != MIO_DEV_ID_OHARE) {
@@ -111,7 +113,7 @@ uint32_t MacIoTwo::read(uint32_t rgn_start, uint32_t offset, int size) {
111113
value = this->ide_0->read((offset >> 4) & 0x1F, size);
112114
break;
113115
case 0x21: // IDE 1
114-
value = this->ide_1->read((offset >> 4) & 0x1F, size);
116+
value = this->ide_1 ? this->ide_1->read((offset >> 4) & 0x1F, size) : 0;
115117
break;
116118
default:
117119
if (sub_addr >= 0x60) {
@@ -173,7 +175,8 @@ void MacIoTwo::write(uint32_t rgn_start, uint32_t offset, uint32_t value, int si
173175
this->ide_0->write((offset >> 4) & 0x1F, value, size);
174176
break;
175177
case 0x21: // IDE 1
176-
this->ide_1->write((offset >> 4) & 0x1F, value, size);
178+
if (this->ide_1)
179+
this->ide_1->write((offset >> 4) & 0x1F, value, size);
177180
break;
178181
default:
179182
if (sub_addr >= 0x60) {

0 commit comments

Comments
 (0)