--- nono/vm/mpu.cpp 2026/04/29 17:05:06 1.1.1.8 +++ nono/vm/mpu.cpp 2026/04/29 17:05:09 1.1.1.9 @@ -4,12 +4,16 @@ // Licensed under nono-license.txt // +// // MPU 共通部 +// #include "mpu.h" #include "config.h" +#include "scheduler.h" -std::unique_ptr gMPU; +// グローバル参照用 +MPUDevice *gMPU; // コンストラクタ MPUDevice::MPUDevice(const std::string& objname_) @@ -17,16 +21,22 @@ MPUDevice::MPUDevice(const std::string& { ClearAlias(); AddAlias("MPU"); + + exec_event.Regist("MPU Execute"); } // デストラクタ MPUDevice::~MPUDevice() { + gMPU = NULL; } bool MPUDevice::Init() { + gScheduler->ConnectMessage(MessageID::MPU_TRACE, this, + ToMessageCallback(&MPUDevice::TraceMessage)); + // MPU クロック const ConfigItem& item = gConfig->Find("mpu-clock"); const std::string& val = item.AsString(); @@ -49,10 +59,25 @@ MPUDevice::Init() item.Err(); return false; } + clock_nsec = 1000 * 1000 / clock_khz; return true; } +void +MPUDevice::PowerOff() +{ + gScheduler->StopEvent(exec_event); +} + +// MPU トレース状態設定要求メッセージ +void +MPUDevice::TraceMessage(MessageID msgid, uint32 arg) +{ + // デバッガから MPU のトレース状態を設定してくれと言われた + SetTrace((bool)arg); +} + // Round Mode (モニタ表示用) /*static*/ const char * const MPUDevice::rmstr[4] = {