macio: properly wire floppy DMA.

This commit is contained in:
Maxim Poliakovski 2022-11-17 14:18:58 +01:00
parent a4ff58e9ee
commit a0dd1884b3
3 changed files with 20 additions and 5 deletions

View File

@ -74,6 +74,8 @@ GrandCentral::GrandCentral() : PCIDevice("mac-io/grandcentral"), InterruptCtrl()
// connect floppy disk HW // connect floppy disk HW
this->swim3 = dynamic_cast<Swim3::Swim3Ctrl*>(gMachineObj->get_comp_by_name("Swim3")); this->swim3 = dynamic_cast<Swim3::Swim3Ctrl*>(gMachineObj->get_comp_by_name("Swim3"));
this->floppy_dma = std::unique_ptr<DMAChannel> (new DMAChannel());
this->swim3->set_dma_channel(this->floppy_dma.get());
// set EMMO pin status (active low) // set EMMO pin status (active low)
this->emmo_pin = GET_BIN_PROP("emmo") ^ 1; this->emmo_pin = GET_BIN_PROP("emmo") ^ 1;
@ -139,6 +141,8 @@ uint32_t GrandCentral::read(uint32_t rgn_start, uint32_t offset, int size)
unsigned subdev_num = (offset >> 8) & 0xF; unsigned subdev_num = (offset >> 8) & 0xF;
switch (subdev_num) { switch (subdev_num) {
case 1:
return this->floppy_dma->reg_read(offset & 0xFF, size);
case 8: case 8:
return this->snd_out_dma->reg_read(offset & 0xFF, size); return this->snd_out_dma->reg_read(offset & 0xFF, size);
default: default:
@ -226,6 +230,9 @@ void GrandCentral::write(uint32_t rgn_start, uint32_t offset, uint32_t value, in
unsigned subdev_num = (offset >> 8) & 0xF; unsigned subdev_num = (offset >> 8) & 0xF;
switch (subdev_num) { switch (subdev_num) {
case 1:
this->floppy_dma->reg_write(offset & 0xFF, value, size);
break;
case 8: case 8:
this->snd_out_dma->reg_write(offset & 0xFF, value, size); this->snd_out_dma->reg_write(offset & 0xFF, value, size);
break; break;

View File

@ -81,8 +81,10 @@ HeathrowIC::HeathrowIC() : PCIDevice("mac-io/heathrow"), InterruptCtrl()
// 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"));
// connect floppy disk HW // connect floppy disk HW and initialize its DMA channel
this->swim3 = dynamic_cast<Swim3::Swim3Ctrl*>(gMachineObj->get_comp_by_name("Swim3")); this->swim3 = dynamic_cast<Swim3::Swim3Ctrl*>(gMachineObj->get_comp_by_name("Swim3"));
this->floppy_dma = std::unique_ptr<DMAChannel> (new DMAChannel());
this->swim3->set_dma_channel(this->floppy_dma.get());
// set EMMO pin status (active low) // set EMMO pin status (active low)
this->emmo_pin = GET_BIN_PROP("emmo") ^ 1; this->emmo_pin = GET_BIN_PROP("emmo") ^ 1;
@ -104,21 +106,24 @@ void HeathrowIC::notify_bar_change(int bar_num)
} }
uint32_t HeathrowIC::dma_read(uint32_t offset, int size) { uint32_t HeathrowIC::dma_read(uint32_t offset, int size) {
uint32_t res = 0;
switch (offset >> 8) { switch (offset >> 8) {
case 1:
return this->floppy_dma->reg_read(offset & 0xFF, size);
case 8: case 8:
res = this->snd_out_dma->reg_read(offset & 0xFF, size); return this->snd_out_dma->reg_read(offset & 0xFF, size);
break; break;
default: default:
LOG_F(WARNING, "Unsupported DMA channel read, offset=0x%X", offset); LOG_F(WARNING, "Unsupported DMA channel read, offset=0x%X", offset);
} }
return res; return 0;
} }
void HeathrowIC::dma_write(uint32_t offset, uint32_t value, int size) { void HeathrowIC::dma_write(uint32_t offset, uint32_t value, int size) {
switch (offset >> 8) { switch (offset >> 8) {
case 1:
this->floppy_dma->reg_write(offset & 0xFF, value, size);
break;
case 8: case 8:
this->snd_out_dma->reg_write(offset & 0xFF, value, size); this->snd_out_dma->reg_write(offset & 0xFF, value, size);
break; break;

View File

@ -141,6 +141,7 @@ private:
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;
std::unique_ptr<DMAChannel> floppy_dma;
}; };
/** /**
@ -231,7 +232,9 @@ private:
EsccController* escc; // ESCC serial controller EsccController* escc; // ESCC serial controller
Swim3::Swim3Ctrl* swim3; // floppy disk controller Swim3::Swim3Ctrl* swim3; // floppy disk controller
// DMA channels
std::unique_ptr<DMAChannel> snd_out_dma; std::unique_ptr<DMAChannel> snd_out_dma;
std::unique_ptr<DMAChannel> floppy_dma;
}; };
#endif /* MACIO_H */ #endif /* MACIO_H */