--- nono/vm/mpu.cpp 2026/04/29 17:05:37 1.1.1.15 +++ nono/vm/mpu.cpp 2026/04/29 17:05:54 1.1.1.18 @@ -25,6 +25,7 @@ #include "mpu.h" #include "config.h" #include "debugger.h" +#include "event.h" #include "mainbus.h" #include "scheduler.h" #include "syncer.h" @@ -50,8 +51,8 @@ MPUDevice::Init() { debugger = GetDebugger(); - // パラメータは継承側でセットしている。 - scheduler->RegistEvent(exec_event); + auto evman = GetEventManager(); + exec_event = evman->Regist(this, NULL, "MPU Execute"); return true; } @@ -112,8 +113,6 @@ MainMPUDevice::Init() scheduler->ConnectMessage(MessageID::MPU_TRACE_MAIN, this, ToMessageCallback(&MainMPUDevice::TraceMessage)); - exec_event.SetName("MPU Execute"); - return true; } @@ -130,6 +129,23 @@ MainMPUDevice::TraceMessage(MessageID ms SetTrace((bool)arg); } +void +MainMPUDevice::ChangeState(uint32 new_state) +{ + // new_mode (CPU_STATE_*) と + // NotifyCPUMode() の引数 Syncer::SYNCMODE_CPU_* は + // 実は同じ値なのでそのまま渡してよいことにする。 + static_assert(CPU_STATE_NORMAL == Syncer::SYNCMODE_CPU_NORMAL, ""); + static_assert(CPU_STATE_STOP == Syncer::SYNCMODE_CPU_STOP, ""); + static_assert(CPU_STATE_HALT == Syncer::SYNCMODE_CPU_HALT, ""); + + if (cpu_state != new_state) { + cpu_state = new_state; + // スケジューラに通知 + syncer->NotifyCPUMode(cpu_state); + } +} + // Round Mode (モニタ表示用) /*static*/ const char * const MainMPUDevice::rmstr[4] = {