--- nono/vm/dmac.h 2026/04/29 17:04:44 1.1.1.6 +++ nono/vm/dmac.h 2026/04/29 17:05:11 1.1.1.10 @@ -4,10 +4,16 @@ // Licensed under nono-license.txt // +// +// DMAC (HD63450) +// + #pragma once #include "device.h" -#include "scheduler.h" +#include "monitor.h" +#include "event.h" +#include struct DMAC { @@ -108,6 +114,7 @@ struct DMAC int ch; // チャンネル番号 const char *desc; // チャンネルの用途(モニタ表示用) DMACDevice *parent; + uint8 priority; // 現在の実効プライオリティ // レジスタ @@ -167,8 +174,7 @@ struct DMAC uint8 gcr; }; -class DMACDevice - : public IODevice +class DMACDevice : public IODevice { using inherited = IODevice; @@ -178,15 +184,11 @@ class DMACDevice DMACDevice(); virtual ~DMACDevice() override; - void ResetHard() override; - void MonitorUpdate(TextScreen&) override; + void ResetHard(bool poweron) override; // 転送 - void StartTransfer(DMAC::Channel *chan); + void StartTransfer(); void AbortTransfer(DMAC::Channel *chan); - void Transfer(Event& ev); - int64 TransferM8toD8(DMAC::Channel *chan); - int64 TransferD8toM8(DMAC::Channel *chan); // 割り込みアクノリッジ int InterruptAcknowledge(); @@ -194,21 +196,41 @@ class DMACDevice 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: + DECLARE_MONITOR_CALLBACK(MonitorUpdate); + void MonitorReg4(TextScreen&, int x, int y, uint32 reg, const char * const *names); // 割り込み信号線の状態を変更 void ChangeInterrupt(); + // 転送イベントコールバック + void StartCallback(Event& ev); + void ReadCallback(Event& ev); + void WriteCallback(Event& ev); + void DoneCallback(Event& ev); + + // 転送中エラー + void Error(uint64); + struct DMAC dmac {}; - Event event[4] {}; + + Event event { this }; + + DMAC::Channel *xfer_chan {}; // 現在転送中のチャンネル + uint32 xfer_src; // 転送中ソースアドレス + uint32 xfer_dst; // 転送中ディスティネーションアドレス + uint32 xfer_data; // 転送中データ + int xfer_retry {}; // 転送リトライ + + Monitor monitor { this }; static const char * const errnames[]; }; -extern std::unique_ptr gDMAC; +extern DMACDevice *gDMAC;