--- nono/vm/lance.h 2026/04/29 17:05:10 1.1.1.9 +++ nono/vm/lance.h 2026/04/29 17:05:25 1.1.1.12 @@ -16,6 +16,9 @@ #include "message.h" #include "monitor.h" +class InterruptDevice; +class SubRAMDevice; + struct AM7990 { int rap; // レジスタアドレス (0..3) @@ -165,7 +168,7 @@ class LanceDevice : public EthernetDevic public: LanceDevice(); - virtual ~LanceDevice() override; + ~LanceDevice() override; bool Init() override; void ResetHard(bool poweron) override; @@ -173,9 +176,9 @@ class LanceDevice : public EthernetDevic protected: // BusIO インタフェース static const uint32 NPORT = 2; - uint64 Read(uint32 offset); - uint64 Write(uint32 offset, uint32 data); - uint64 Peek(uint32 offset); + busdata Read(uint32 offset); + busdata Write(uint32 offset, uint32 data); + busdata Peek(uint32 offset); private: DECLARE_MONITOR_CALLBACK(MonitorUpdate); @@ -212,8 +215,8 @@ class LanceDevice : public EthernetDevic void ChangePhase(TXPhase new_phase, uint64 time = 100_nsec); void ChangePhase(RXPhase new_phase, uint64 time = 100_nsec); - // パケット受信通知 (HostNet から) - void HostRxCallback(MessageID, uint32); + // パケット受信通知 (HostNet から EthernetDevice 経由で呼ばれる) + void RxMessage(MessageID, uint32); const std::string BitToString(const char * const name[], uint16 bits); const std::string CSR0ToString(uint16 bits); @@ -232,10 +235,10 @@ class LanceDevice : public EthernetDevic macaddr_t padr {}; - uint32 rmd_base {}; // 受信ディスクリプタの(ZRAM での)開始アドレス + uint32 rmd_base {}; // 受信ディスクリプタの(SubRAMでの)開始アドレス int rmd_num {}; // 受信ディスクリプタ数 int rmd_cur {}; // RMD 内の現在の注目インデックス - uint32 tmd_base {}; // 送信ディスクリプタの(ZRAM での)開始アドレス + uint32 tmd_base {}; // 送信ディスクリプタの(SubRAMでの)開始アドレス int tmd_num {}; // 送信ディスクリプタ数 int tmd_cur {}; // TMD 内の現在の注目インデックス @@ -251,12 +254,19 @@ class LanceDevice : public EthernetDevic RXPhase rx_phase {}; // 受信フェーズ TXPhase tx_phase {}; // 送信フェーズ + // 前回の TMD 状態文字列 (デバッグ表示用) + std::string last_tmdstr {}; + + InterruptDevice *interrupt {}; + SubRAMDevice *subram {}; + // 待ち時間用イベント Event rx_event { this }; Event tx_event { this }; Monitor monitor { this }; - - // 前回の TMD 状態文字列 (デバッグ表示用) - std::string last_tmdstr {}; }; + +static inline LanceDevice *GetLanceDevice() { + return Object::GetObject(OBJ_ETHERNET(0)); +}