--- nono/vm/lance.h 2026/04/29 17:04:55 1.1.1.8 +++ nono/vm/lance.h 2026/04/29 17:05:10 1.1.1.9 @@ -4,11 +4,17 @@ // Licensed under nono-license.txt // +// +// Lance (AM7990) +// + #pragma once #include "ethernet.h" +#include "event.h" +#include "hostnet.h" +#include "message.h" #include "monitor.h" -#include "scheduler.h" struct AM7990 { @@ -142,14 +148,16 @@ class LanceDevice : public EthernetDevic // 受信フェーズ enum class RXPhase { - IDLE = 0, // ポーリング + STOP = 0, // (動作していない) + IDLE, // ポーリング COPY, // バッファ書き込み NEXT, // RMD 更新 MISS, // 受信ミス }; // 送信フェーズ enum class TXPhase { - IDLE = 0, // ポーリング + STOP = 0, // (動作していない) + IDLE, // ポーリング COPY, // バッファ読み込み SEND, // 送信 NEXT, // TMD 更新 @@ -160,7 +168,7 @@ class LanceDevice : public EthernetDevic virtual ~LanceDevice() override; bool Init() override; - void ResetHard() override; + void ResetHard(bool poweron) override; protected: // BusIO インタフェース @@ -169,9 +177,6 @@ class LanceDevice : public EthernetDevic uint64 Write(uint32 offset, uint32 data); uint64 Peek(uint32 offset); - // パケット受信通知 (親クラスから) - void NotifyRecvPacket() override; - private: DECLARE_MONITOR_CALLBACK(MonitorUpdate); void MonitorReg(TextScreen&, @@ -194,20 +199,22 @@ class LanceDevice : public EthernetDevic void ChangeInterrupt(); void TXIdle(Event&); - void TXCopy(Event&); + void TXCopy(); void TXSend(Event&); void TXNext(Event&); void RXIdle(Event&); - void RXCopy(Event&); + void RXCopy(); void RXNext(Event&); - void RXRecv(Event&); - void RXMiss(Event&); + void RXMiss(); // フェーズ遷移 void ChangePhase(TXPhase new_phase, uint64 time = 100_nsec); void ChangePhase(RXPhase new_phase, uint64 time = 100_nsec); + // パケット受信通知 (HostNet から) + void HostRxCallback(MessageID, uint32); + const std::string BitToString(const char * const name[], uint16 bits); const std::string CSR0ToString(uint16 bits); const std::string CSR3ToString(uint16 bits); @@ -223,7 +230,7 @@ class LanceDevice : public EthernetDevic // Initialization Block uint16 initblock[12] {}; - uint64 padr {}; // PADR を下位詰めしたもの + macaddr_t padr {}; uint32 rmd_base {}; // 受信ディスクリプタの(ZRAM での)開始アドレス int rmd_num {}; // 受信ディスクリプタ数 @@ -235,11 +242,11 @@ class LanceDevice : public EthernetDevic uint16 rmd1 {}; // 現在の RMD1 uint32 rmd1_ahead {}; // 次の RMD1 先読み (負なら先読みしてない状態) - RXPacket rxpacket {}; // 受信バッファ - uint16 tmd1 {}; // 現在の TMD1 uint32 tmd1_ahead {}; // 次の TMD1 先読み (負なら先読みしてない状態) - std::vector txq {}; // 送信バッファ + + NetPacket rx_packet {}; // 受信バッファ + NetPacket tx_packet {}; // 送信バッファ RXPhase rx_phase {}; // 受信フェーズ TXPhase tx_phase {}; // 送信フェーズ