--- nono/vm/sysctlr.cpp 2026/04/29 17:04:50 1.1.1.4 +++ nono/vm/sysctlr.cpp 2026/04/29 17:05:07 1.1.1.7 @@ -9,6 +9,7 @@ #include "sysctlr.h" #include "ethernet.h" #include "mpu88xx0.h" +#include "prom.h" #include "sio.h" #include "spc.h" #include "sysclk.h" @@ -146,11 +147,13 @@ // コンストラクタ SysCtlrDevice::SysCtlrDevice() + : inherited("SystemCtlr") { - logname = "sysctlr"; - devname = "SysCtlr"; + AddAlias("SysCtlr"); - monitor_size = nnSize(24, 10); + monitor.func = (MonitorCallback_t)&SysCtlrDevice::MonitorUpdate; + monitor.SetSize(25, 10); + monitor.Regist(ID_MONITOR_INTERRUPT); } // デストラクタ @@ -162,8 +165,8 @@ void SysCtlrDevice::ResetHard() { // さすがにリセットくらいはされるだろう… - intmap = 0x00000001; - memset(&counter, 0, sizeof(counter)); + inherited::ResetHard(); + for (int i = 0; i < 4; i++) { // XXX 初期値は分からないがとりあえず割り込み禁止にしておく cpu[i].maskval = 0xfc000000; @@ -242,7 +245,9 @@ SysCtlrDevice::Write32(uint32 addr, uint } if (addr == 0x6d000010) { putlog(1, "Reset All CPUs"); + gPROM0->ResetHard(); gMPU->ResetHard(); + gMPU->Release(); return 0; } @@ -277,7 +282,7 @@ SysCtlrDevice::Peek8(uint32 addr) } void -SysCtlrDevice::MonitorUpdate(TextScreen& monitor) +SysCtlrDevice::MonitorUpdate(Monitor *, TextScreen& screen) { int y; struct { @@ -298,18 +303,18 @@ SysCtlrDevice::MonitorUpdate(TextScreen& // CPU の割り込み可否は本当は関係ないけど、便宜的に一緒に表示したい bool ei = gMPU88xx0->GetCPU()->IsIntrEnable(); - monitor.Clear(); + screen.Clear(); y = 0; // XXX CPU の実装数によってウィンドウ幅を変える。 // はみ出したところは描画されないのでヘッダは4つ分出力しておく - monitor.Print(0, y++, "Lv Device Count CPU0 CPU1 CPU2 CPU3"); + screen.Print(0, y++, "Lv Device Count CPU0 CPU1 CPU2 CPU3"); for (int i = 0; i < countof(table); i++) { uint32 map = table[i].map; int clz = __builtin_clz(map); int lv = (31 - clz) / 4; - monitor.Print(0, y, "%d", lv); - monitor.Print(2, y, TA::OnOff(intmap & map), "%s", table[i].name); - monitor.Print(8, y, "%10u", counter[clz]); + screen.Print(0, y, "%d", lv); + screen.Print(2, y, TA::OnOff(intmap & map), "%s", table[i].name); + screen.Print(8, y, "%11" PRIu64, counter[clz]); // CPU ごとのマスク // XXX 今は CPU は1つしかない @@ -318,11 +323,11 @@ SysCtlrDevice::MonitorUpdate(TextScreen& // 動作としては常にマスクされてて通過しないから問題ないが、 // 見せる分にはマスクされているではなく無効と見せたほうがいい。 if (lv == 1 && map != (IntmapSoft0 << n)) { - monitor.Puts(20 + n * 5, y, "----"); + screen.Puts(21 + n * 5, y, "----"); } else if ((cpu[n].intmask & map) == 0) { - monitor.Puts(20 + n * 5, y, "Mask"); + screen.Puts(21 + n * 5, y, "Mask"); } else if (!ei) { - monitor.Puts(20 + n * 5, y, "IND"); + screen.Puts(21 + n * 5, y, "IND"); } } @@ -349,34 +354,6 @@ SysCtlrDevice::GetIntmap(Device *source) PANIC("Unknown interrupt source?"); } -// 外部デバイスが割り込み信号線をアサートした -void -SysCtlrDevice::AssertINT(Device *source) -{ - uint32 oldmap; - uint32 srcmap; - - oldmap = intmap; - srcmap = GetIntmap(source); - intmap |= srcmap; - - if ((oldmap ^ intmap) != 0) { - // 立ち上がりエッジでカウント - counter[__builtin_clz(srcmap)]++; - } - - ChangeInterrupt(); -} - -// 外部デバイスが割り込み信号線をネゲートした -void -SysCtlrDevice::NegateINT(Device *source) -{ - intmap &= ~GetIntmap(source); - - ChangeInterrupt(); -} - // 割り込みアクノリッジはない int SysCtlrDevice::InterruptAcknowledge(int lv) @@ -395,7 +372,7 @@ SysCtlrDevice::ChangeInterrupt() // intmap の最下位ビットは常に立ててあり localmap は 0 にならない int newipl = (uint)(31 - __builtin_clz(localmap)) / 4; - // アサートによって割り込みレベルが変わったら、新しいレベルを通知 + // 割り込みレベルが変わったら、新しいレベルを通知 if (newipl != cpu[i].ipl) { cpu[i].ipl = newipl; // MPU 側は 1 レベルしかない