--- nono/vm/dmac.h 2026/04/29 17:05:25 1.1.1.13 +++ nono/vm/dmac.h 2026/04/29 17:05:51 1.1.1.17 @@ -13,14 +13,13 @@ #include "device.h" #include "bus.h" #include "fixedqueue.h" -#include "monitor.h" -#include "event.h" #include class ADPCMDevice; class FDCDevice; class InterruptDevice; class MainbusDevice; +class Syncer; struct DMAC { @@ -235,13 +234,13 @@ class DMACChan void SetBFC(uint8); // 転送シーケンス - std::vector seq {}; + std::vector seq {}; int seq_index {}; // 転送リトライカウンタ。 // 実際には (SPC からの) DTACK を待つのだが、 // 待つのは大変なのでこちらでポーリングしている。 - int retry {}; + uint retry {}; // 転送中データ FixedQueue data; @@ -251,7 +250,7 @@ class DMACDevice : public IODevice { using inherited = IODevice; - static const int baseaddr = 0xe84000; + static const uint32 baseaddr = 0xe84000; // 転送シーケンス enum { @@ -264,6 +263,7 @@ class DMACDevice : public IODevice WR_M16, WR_D8, WR_D16, + SEQ_MAX, }; public: @@ -273,15 +273,13 @@ class DMACDevice : public IODevice bool Init() override; void ResetHard(bool poweron) override; - busdata Read8(uint32 addr) override; - busdata Read16(uint32 addr) override; - busdata Write8(uint32 addr, uint32 data) override; - busdata Write16(uint32 addr, uint32 data) override; - busdata Peek8(uint32 addr) override; + busdata Read(busaddr addr) override; + busdata Write(busaddr addr, uint32 data) override; + busdata Peek1(uint32 addr) override; // 外部デバイスが REQ 信号を操作する - void AssertREQ(int ch); - void NegateREQ(int ch); + void AssertREQ(uint ch); + void NegateREQ(uint ch); // 割り込みアクノリッジ busdata InterruptAcknowledge(); @@ -295,11 +293,17 @@ class DMACDevice : public IODevice void MonitorReg4(TextScreen&, int x, int y, uint32 reg, const char * const *names); + busdata WriteByte(DMACChan *chan, uint32 n, uint32 data); + busdata WriteWord(DMACChan *chan, uint32 n, uint32 data); + // チャンネル操作 void WriteCSR(DMACChan *chan, uint32 data); void WriteCCR(DMACChan *chan, uint32 data, uint8 up); void WriteGCR(uint8 data); + // ACT ビットの状態を変更 + void ChangeACT(DMACChan *, bool); + // 割り込み信号線の状態を変更 void ChangeInterrupt(); @@ -309,14 +313,14 @@ class DMACDevice : public IODevice DMACChan *SelectChannel(); // 転送イベントコールバック - void StartCallback(Event& ev); - void TransferCallback(Event& ev); + void StartCallback(Event *); + void TransferCallback(Event *); // ログ出力 - void TransferLog(DMACChan *, int op, busaddr addr, busdata r, uint64 data); + void TransferLog(DMACChan *, uint op, busaddr addr, busdata r, uint64 data); // 転送中エラー - void TransferError(DMACChan *, int op, busdata r, uint32 data); + void TransferError(DMACChan *, uint op, busdata r, uint32 data); // エラー発生 void Error(DMACChan *chan, uint8 errcode); @@ -335,12 +339,16 @@ class DMACDevice : public IODevice FDCDevice *fdc {}; InterruptDevice *interrupt {}; MainbusDevice *mainbus {}; + Syncer *syncer {}; - Event event { this }; + Event *event {}; - Monitor monitor { this }; + Monitor *monitor {}; static const char * const errnames[]; + static const char * const regname1[0x40]; + static const char * const regname2[0x20]; + static const char * const seqname[SEQ_MAX]; }; static inline DMACDevice *GetDMACDevice() {