--- nono/vm/dmac.h 2026/04/29 17:04:35 1.1.1.3 +++ nono/vm/dmac.h 2026/04/29 17:04:55 1.1.1.8 @@ -7,6 +7,7 @@ #pragma once #include "device.h" +#include "monitor.h" #include "scheduler.h" struct DMAC @@ -116,6 +117,10 @@ struct DMAC bool active; // ACT bool pcl; // PCL の状態 (High が true) bool prev_pcl; // 前回の PCL の状態 (High が true) + bool IsINTR() const { // CSR の割り込み要因が立っていれば true + // XXX PCT は未対応 + return (csr & (CSR_COC | CSR_BTC | CSR_NDT | CSR_ERR)); + } uint8 cer; uint8 dcr; @@ -138,7 +143,6 @@ struct DMAC uint32 GetDAC() const { return (scr & 3); } uint8 ccr; - bool int_enable; // INT: 割り込み許可なら true uint16 mtc; uint32 mar; @@ -154,21 +158,17 @@ struct DMAC uint8 PeekCSR() const; void WriteCSR(uint32 data); - uint8 PeekCCR() const; void WriteCCR(uint32 data); // 転送開始 void StartTransfer(); - // 割り込み - void SetINT(uint32 val); } chan[4]; // 全体 uint8 gcr; }; -class DMACDevice - : public IODevice +class DMACDevice : public IODevice { using inherited = IODevice; @@ -176,29 +176,40 @@ class DMACDevice public: DMACDevice(); - ~DMACDevice() override; + virtual ~DMACDevice() override; - bool MonitorUpdate() override; + void ResetHard() override; // 転送 + void StartTransfer(DMAC::Channel *chan); void AbortTransfer(DMAC::Channel *chan); - void Transfer(int arg); + void Transfer(Event& ev); int64 TransferM8toD8(DMAC::Channel *chan); int64 TransferD8toM8(DMAC::Channel *chan); + // 割り込みアクノリッジ + int InterruptAcknowledge(); + protected: // BusIO インタフェース static const uint NPORT = 256; - uint64 Read(uint32 addr); - uint64 Write(uint32 addr, uint32 data); - uint64 Peek(uint32 addr); + uint64 Read(uint32 offset); + uint64 Write(uint32 offset, uint32 data); + uint64 Peek(uint32 offset); private: - void MonitorReg4(int x, int y, uint32 reg, const char * const *names); + DECLARE_MONITOR_CALLBACK(MonitorUpdate); + void MonitorReg4(TextScreen&, + int x, int y, uint32 reg, const char * const *names); + + // 割り込み信号線の状態を変更 + void ChangeInterrupt(); struct DMAC dmac {}; Event event[4] {}; + Monitor monitor { this }; + static const char * const errnames[]; };