From ae903082d85338465a05be350669de8825732510 Mon Sep 17 00:00:00 2001 From: Maxim Poliakovski Date: Wed, 1 Nov 2023 16:13:12 +0100 Subject: [PATCH] amic: implement SCSI DRQ callback. --- devices/common/scsi/sc53c94.h | 8 ++++++++ devices/ioctrl/amic.cpp | 9 ++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/devices/common/scsi/sc53c94.h b/devices/common/scsi/sc53c94.h index 98c01ab..3f1a93c 100644 --- a/devices/common/scsi/sc53c94.h +++ b/devices/common/scsi/sc53c94.h @@ -32,6 +32,7 @@ along with this program. If not, see . #include #include +#include #include class DmaBidirChannel; @@ -145,6 +146,8 @@ typedef struct { int status; } SeqDesc; +typedef std::function DrqCb; + class Sc53C94 : public ScsiDevice { public: Sc53C94(uint8_t chip_id=12, uint8_t my_id=7); @@ -169,6 +172,10 @@ public: this->dma_ch = dma_ch; }; + void set_drq_callback(DrqCb cb) { + this->drq_cb = cb; + } + // ScsiDevice methods void notify(ScsiMsg msg_type, int param); bool prepare_data() { return false; }; @@ -233,6 +240,7 @@ private: // DMA related stuff DmaBidirChannel* dma_ch; + DrqCb drq_cb = nullptr; }; #endif // SC_53C94_H diff --git a/devices/ioctrl/amic.cpp b/devices/ioctrl/amic.cpp index da31b8c..b66b472 100644 --- a/devices/ioctrl/amic.cpp +++ b/devices/ioctrl/amic.cpp @@ -47,7 +47,7 @@ along with this program. If not, see . AMIC::AMIC() : MMIODevice() { - this->name = "Apple Memory-mapped I/O Controller"; + this->set_name("Apple Memory-mapped I/O Controller"); supports_types(HWCompType::MMIO_DEV | HWCompType::INT_CTRL); @@ -55,6 +55,13 @@ AMIC::AMIC() : MMIODevice() this->scsi = dynamic_cast(gMachineObj->get_comp_by_name("Sc53C94")); this->scsi_dma = std::unique_ptr (new AmicScsiDma()); this->scsi->set_dma_channel(this->scsi_dma.get()); + this->scsi->set_drq_callback([this](const uint8_t drq_state) { + if (drq_state & 1) + via2_ifr |= VIA2_INT_SCSI_DRQ; + else + via2_ifr &= ~VIA2_INT_SCSI_DRQ; + this->update_via2_irq(); + }); // connect serial HW this->escc = dynamic_cast(gMachineObj->get_comp_by_name("Escc"));