--- nono/vm/lance.h 2026/04/29 17:04:32 1.1.1.2 +++ nono/vm/lance.h 2026/04/29 17:04:50 1.1.1.7 @@ -1,6 +1,7 @@ // // nono -// Copyright (C) 2018 isaki@NetBSD.org +// Copyright (C) 2020 nono project +// Licensed under nono-license.txt // #pragma once @@ -137,7 +138,7 @@ struct AM7990 class LanceDevice : public EthernetDevice { - typedef EthernetDevice inherited; + using inherited = EthernetDevice; public: static const uint32 REQ_TXIDLE = 0x00000001; // ポーリングフェーズ static const uint32 REQ_TXCOPY = 0x00000002; // バッファ読込フェーズ @@ -152,34 +153,35 @@ class LanceDevice public: LanceDevice(); - virtual ~LanceDevice(); + virtual ~LanceDevice() override; - virtual bool Init(); - virtual void ResetHard(); + bool Init() override; + void ResetHard() override; - virtual bool MonitorUpdate(); + void MonitorUpdate(TextScreen&) override; // ワーカスレッド (エントリポイントから呼ばれる) - void ThreadRun(); + void ThreadRun() override; // パケットを受信した (ホストネットワークスレッドから呼ばれる) - virtual bool RecvPacket(qvector& buf); + bool RecvPacket(qvector& buf) override; protected: // BusIO インタフェース static const uint32 NPORT = 2; - 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: - pthread_t thread; - bool thread_created = false; // スレッドが作成されたら true + pthread_t thread {}; + bool thread_created {}; // スレッドが作成されたら true // スレッドの終了を指示 void Terminate(); - void MonitorReg(int x, int y, uint32 data, const char * const * names); + void MonitorReg(TextScreen&, + int x, int y, uint32 data, const char * const * names); uint32 ReadData(); void WriteData(uint32 data); @@ -194,8 +196,8 @@ class LanceDevice // 割り込み要因をセットし、許可されていれば割り込みを上げる void SetInterrupt(uint32 bit); - // 許可されていれば割り込みを上げる - void Interrupt(); + // 割り込み信号線の状態を変える + void ChangeInterrupt(); void TXIdle(); void TXCopy(); @@ -206,7 +208,7 @@ class LanceDevice void RXNext(); void RXRecv(); void RXMiss(); - void Callback(int arg); + void Callback(Event& ev); const std::string BitToString(const char * const name[], uint16 bits); const std::string CSR0ToString(uint16 bits); @@ -223,19 +225,19 @@ class LanceDevice // Initialization Block uint16 initblock[12] {}; - uint32 rmd_base = 0; // 受信ディスクリプタの(ZRAM での)開始アドレス - int rmd_num = 0; // 受信ディスクリプタ数 - int rmd_cur = 0; // RMD 内の現在の注目インデックス - uint32 tmd_base = 0; // 送信ディスクリプタの(ZRAM での)開始アドレス - int tmd_num = 0; // 送信ディスクリプタ数 - int tmd_cur = 0; // TMD 内の現在の注目インデックス - - uint16 rmd1 = 0; // 現在の RMD1 - uint32 rmd1_ahead = 0; // 次の RMD1 先読み (負なら先読みしてない状態) - qvector rxq {}; // 受信バッファ + uint32 rmd_base {}; // 受信ディスクリプタの(ZRAM での)開始アドレス + int rmd_num {}; // 受信ディスクリプタ数 + int rmd_cur {}; // RMD 内の現在の注目インデックス + uint32 tmd_base {}; // 送信ディスクリプタの(ZRAM での)開始アドレス + int tmd_num {}; // 送信ディスクリプタ数 + int tmd_cur {}; // TMD 内の現在の注目インデックス + + uint16 rmd1 {}; // 現在の RMD1 + uint32 rmd1_ahead {}; // 次の RMD1 先読み (負なら先読みしてない状態) + qvector rxq {}; // 受信バッファ - uint16 tmd1 = 0; // 現在の TMD1 - uint32 tmd1_ahead = 0; // 次の TMD1 先読み (負なら先読みしてない状態) + uint16 tmd1 {}; // 現在の TMD1 + uint32 tmd1_ahead {}; // 次の TMD1 先読み (負なら先読みしてない状態) std::vector txq {}; // 送信バッファ // 待ち時間用イベント