--- nono/vm/mpu680x0.h 2026/04/29 17:04:42 1.1.1.4 +++ nono/vm/mpu680x0.h 2026/04/29 17:04:55 1.1.1.8 @@ -8,6 +8,7 @@ #pragma once +#include "event.h" #include "mpu.h" #include "m68030.h" @@ -15,13 +16,18 @@ class MPU680x0Device : public MPUDevice { using inherited = MPUDevice; public: - MPU680x0Device(uint32); - ~MPU680x0Device() override; + MPU680x0Device(); + virtual ~MPU680x0Device() override; bool Init() override; - void MonitorUpdate(TextScreen&) override; + bool PowerOn() override; + void ResetHard() override; - uint32 Run(uint64 request) override; + // MPU を vtime [nsec] 分実行する + uint32 Run(uint32 vtime) override; + + // 現在の仮想時刻 [nsec] を取得する + uint64 GetVirtTime() const override; // 現在の PPC を取得 uint32 GetPPC() const override { return RegPPC; } @@ -31,22 +37,16 @@ class MPU680x0Device : public MPUDevice uint32 GetPaddr() const override { return cpu->bus.paddr; } // アクセスウェイトを加算 - void AddCycle(uint64 cycle) override { cpu->total_cycle += cycle; } - - // 割り込み発生を MPU に通知 (オートベクタ) - void Interrupt(Object *src, int level) override; + void AddCycle(int32 cycle) override { cpu->used_cycle += cycle; } - // 割り込み発生を MPU に通知 (ベクタ) - void Interrupt(Object *src, int level, int vector); + // 割り込みレベルが変わったことを MPU に通知 + void Interrupt(int level) override; // MPU の処理をこの命令で中断させる。 // スケジューラのイベントリストに追加が発生した時に VM 側から // MPU へ処理の中断を指示する。 void Release() override { cpu->atomic_reqflag |= CPU_REQ_RELEASE; } - // 基準サイクル数を取得 - uint64 total_cycle() const override { return cpu->total_cycle; } - // A-Line, F-Line 命令エミュレーションのコールバックを指定する。 // (Human68k エミュレーションで使用) void SetALineCallback(bool (*callback)(m68kcpu*, void*), void *arg); @@ -66,25 +66,24 @@ class MPU680x0Device : public MPUDevice } private: - // リセット例外イベントコールバック - void ResetCallback(Event& ev); + // イベントコールバック + void Callback(Event& ev); - m68kcpu *cpu {}; -}; + // 割り込み用イベント + Event event { this }; -// ATC モニタ -class MPUATC : public Object -{ - public: - MPUATC(m68kcpu *cpu); - ~MPUATC() override { } + // レジスタモニター + DECLARE_MONITOR_CALLBACK(MonitorUpdateReg); + Monitor reg_monitor { this }; + + // ATC モニター + DECLARE_MONITOR_CALLBACK(MonitorUpdateATC); + Monitor atc_monitor { this }; - void MonitorUpdate(TextScreen&) override; + // 割り込み確定のためのディレイ [nsec] + uint64 intdelay {}; - private: m68kcpu *cpu {}; }; -extern std::unique_ptr gMPUATC; - #define gMPU680x0 (dynamic_cast(gMPU.get()))