--- nono/vm/dmac.h 2026/04/29 17:05:14 1.1.1.11 +++ nono/vm/dmac.h 2026/04/29 17:05:25 1.1.1.13 @@ -11,11 +11,17 @@ #pragma once #include "device.h" +#include "bus.h" #include "fixedqueue.h" #include "monitor.h" #include "event.h" #include +class ADPCMDevice; +class FDCDevice; +class InterruptDevice; +class MainbusDevice; + struct DMAC { static const uint32 CSR = 0x00; // .B @@ -217,10 +223,10 @@ class DMACChan uint32 bar; uint8 niv; uint8 eiv; - uint8 mfc; uint8 cpr; - uint8 dfc; - uint8 bfc; + busaddr mfc; + busaddr dfc; + busaddr bfc; void SetNIV(uint8); void SetEIV(uint8); void SetMFC(uint8); @@ -262,29 +268,26 @@ class DMACDevice : public IODevice public: DMACDevice(); - virtual ~DMACDevice() override; + ~DMACDevice() override; + bool Init() override; void ResetHard(bool poweron) override; - uint64 Read8(uint32 addr) override; - uint64 Read16(uint32 addr) override; - uint64 Write8(uint32 addr, uint32 data) override; - uint64 Write16(uint32 addr, uint32 data) override; - uint64 Peek8(uint32 addr) 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; // 外部デバイスが REQ 信号を操作する void AssertREQ(int ch); void NegateREQ(int ch); // 割り込みアクノリッジ - int InterruptAcknowledge(); + busdata InterruptAcknowledge(); - protected: - // BusIO インタフェース - static const uint NPORT = 256; - uint64 Read(uint32 offset); - uint64 Write(uint32 offset, uint32 data); - uint64 Peek(uint32 offset); + // ユーザ空間制御 + void SetUdevice(uint32 start, uint32 end, bool accessible); private: DECLARE_MONITOR_CALLBACK(MonitorUpdate); @@ -309,8 +312,11 @@ class DMACDevice : public IODevice void StartCallback(Event& ev); void TransferCallback(Event& ev); + // ログ出力 + void TransferLog(DMACChan *, int op, busaddr addr, busdata r, uint64 data); + // 転送中エラー - void TransferError(DMACChan *, int op, uint64); + void TransferError(DMACChan *, int op, busdata r, uint32 data); // エラー発生 void Error(DMACChan *chan, uint8 errcode); @@ -322,6 +328,14 @@ class DMACDevice : public IODevice std::array channel {}; uint8 gcr; + // ユーザ空間制御 + std::array useraccess {}; + + ADPCMDevice *adpcm {}; + FDCDevice *fdc {}; + InterruptDevice *interrupt {}; + MainbusDevice *mainbus {}; + Event event { this }; Monitor monitor { this }; @@ -329,4 +343,6 @@ class DMACDevice : public IODevice static const char * const errnames[]; }; -extern DMACDevice *gDMAC; +static inline DMACDevice *GetDMACDevice() { + return Object::GetObject(OBJ_DMAC); +}