--- nono/vm/lance.cpp 2026/04/29 17:04:32 1.1.1.3 +++ nono/vm/lance.cpp 2026/04/29 17:04:35 1.1.1.4 @@ -1,15 +1,16 @@ // // nono -// Copyright (C) 2018 isaki@NetBSD.org +// Copyright (C) 2020 nono project +// Licensed under nono-license.txt // #include "lance.h" -#include "config.h" #include "bus.h" +#include "config.h" #include "mpu.h" -#include "romimg_luna.h" -#include "zram.h" #include "mystring.h" +#include "mythread.h" +#include "zram.h" static void *lance_run(void *); @@ -50,9 +51,8 @@ LanceDevice::Init() return false; } - const ConfigItem& item = gConfig->Get("ethernet-macaddr"); + const ConfigItem& item = gConfig->Find("ethernet-macaddr"); const std::string& config_macaddr = item.AsString(); - macaddr_t macaddr; if (config_macaddr == "rom") { // ROM に書いてあるのを使うので、ここでは何もしなくていい } else { @@ -71,13 +71,7 @@ LanceDevice::Init() } } - putmsg(1, "macaddr=%s", macaddr.to_string().c_str()); - - // ROM に書き込む - if (gPROM->SetMacAddr(macaddr) == false) { - warnx("LanceDevice initialization failed: unexpected PROM"); - return false; - } + putmsg(1, "macaddr=%s", macaddr.to_string(':').c_str()); } // ワーカスレッド起動 @@ -184,9 +178,7 @@ LADRF:$12345678_12345678 TDRP: // name を表示。(var & bit) ならオン(反転)表示。 // bitpos は 0..15 で [0] が MSB にあたる。 #define MonitorBit(var, bit, name) do { \ - monitor.Print(x, y, \ - (((var) & (bit)) ? TA::On : TA::Off), \ - "%s", name); \ + monitor.Puts(x, y, TA::OnOff((var) & (bit)), name); \ x += strlen(name) + 1; \ } while (0) @@ -214,7 +206,7 @@ LADRF:$12345678_12345678 TDRP: MonitorBit(reg.csr3, AM7990::CSR3_BCON, csr3names[15]); y++; - monitor.Print(0, y, ""); + monitor.Puts(0, y, ""); y++; // MODE は bit15 と bit6-0 の8ビットだけ使われてるので // 途中を省略して 8ビットとして表示する @@ -255,7 +247,7 @@ LADRF:$12345678_12345678 TDRP: y++; // RMD - monitor.Print(0, y, ""); + monitor.Puts(0, y, ""); uint16 rmd[4]; uint32 rmd_addr; @@ -325,7 +317,7 @@ LADRF:$12345678_12345678 TDRP: y += 17; // TMD - monitor.Print(0, y, ""); + monitor.Puts(0, y, ""); uint16 tmd[4]; uint32 tmd_addr; @@ -399,8 +391,7 @@ LanceDevice::MonitorReg(int x, int y, ui { for (int i = 0; i < 8; i++) { bool b = data & (1 << (7 - i)); - uint attr = b ? TA::On : TA::Off; - monitor.Print(x + i * 5, y, attr, "%s", names[i]); + monitor.Puts(x + i * 5, y, TA::OnOff(b), names[i]); } } @@ -734,7 +725,7 @@ LanceDevice::Interrupt() { if ((reg.csr0 & AM7990::CSR0_INEA)) { putlog(2, "割り込み"); - gMPU->Interrupt(3); + gMPU->Interrupt(this, 3); } else { putlog(2, "割り込みはマスクされている"); } @@ -744,7 +735,7 @@ LanceDevice::Interrupt() void * lance_run(void *dummy) { - pthread_setname_np("Lance worker"); + PTHREAD_SETNAME("Lance worker"); dynamic_cast(gEthernet.get())->ThreadRun(); return NULL; @@ -785,11 +776,12 @@ LanceDevice::ThreadRun() } } -#define dispatch(flag, func) \ +#define dispatch(flag, func) do { \ if ((req & (flag))) { \ req &= ~(flag); \ (func)(); \ - } + } \ +} while (0) dispatch(REQ_TXIDLE, TXIdle); dispatch(REQ_TXCOPY, TXCopy);