--- nono/vm/mpu.cpp 2026/04/29 17:05:09 1.1.1.9 +++ nono/vm/mpu.cpp 2026/04/29 17:05:17 1.1.1.11 @@ -5,23 +5,33 @@ // // -// MPU 共通部 +// メイン MPU (680x0/88xx0) 共通部 // +// Device +// | +-----------+ +// +--| MPUDevice | (680x0/88xx0 の共通部) +// | +-----------+ +// | | +// | +-- MPU680x0Device +// | +-- MPU88xx0Device +// | +// +-------- MPU64180Device + #include "mpu.h" #include "config.h" +#include "debugger.h" +#include "mainbus.h" #include "scheduler.h" +#include "syncer.h" // グローバル参照用 MPUDevice *gMPU; // コンストラクタ -MPUDevice::MPUDevice(const std::string& objname_) - : inherited(objname_) +MPUDevice::MPUDevice() + : inherited(OBJ_MPU) { - ClearAlias(); - AddAlias("MPU"); - exec_event.Regist("MPU Execute"); } @@ -31,10 +41,23 @@ MPUDevice::~MPUDevice() gMPU = NULL; } +// 初期化 bool MPUDevice::Init() { - gScheduler->ConnectMessage(MessageID::MPU_TRACE, this, + if (inherited::Init() == false) { + return false; + } + + // XXX 主に m680x0 配下がグローバル変数じゃないと色々解決できない。 + // そのうちなんとかする。 + gMPU = this; + + debugger = GetDebugger(); + mainbus = GetMainbusDevice(); + syncer = GetSyncer(); + + scheduler->ConnectMessage(MessageID::MPU_TRACE_MAIN, this, ToMessageCallback(&MPUDevice::TraceMessage)); // MPU クロック @@ -67,13 +90,18 @@ MPUDevice::Init() void MPUDevice::PowerOff() { - gScheduler->StopEvent(exec_event); + scheduler->StopEvent(exec_event); } // MPU トレース状態設定要求メッセージ void MPUDevice::TraceMessage(MessageID msgid, uint32 arg) { + // リセット中は SetTrace しない + if (resetting) { + return; + } + // デバッガから MPU のトレース状態を設定してくれと言われた SetTrace((bool)arg); }