--- nono/vm/mpu680x0.h 2026/04/29 17:04:39 1.1.1.3 +++ nono/vm/mpu680x0.h 2026/04/29 17:04:52 1.1.1.7 @@ -8,6 +8,7 @@ #pragma once +#include "event.h" #include "mpu.h" #include "m68030.h" @@ -15,14 +16,19 @@ class MPU680x0Device : public MPUDevice { using inherited = MPUDevice; public: - MPU680x0Device(uint32); - ~MPU680x0Device() override; + MPU680x0Device(); + virtual ~MPU680x0Device() override; bool Init() override; + bool PowerOn() override; void ResetHard() override; void MonitorUpdate(TextScreen&) 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,20 +37,17 @@ class MPU680x0Device : public MPUDevice uint32 GetLaddr() const override { return cpu->bus.laddr; } uint32 GetPaddr() const override { return cpu->bus.paddr; } - // 割り込み発生を 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); @@ -64,7 +67,16 @@ class MPU680x0Device : public MPUDevice } private: - m68kcpu *cpu = NULL; + // イベントコールバック + void Callback(Event& ev); + + // 割り込み用イベント + Event event {}; + + // 割り込み確定のためのディレイ [nsec] + uint64 intdelay {}; + + m68kcpu *cpu {}; }; // ATC モニタ @@ -77,7 +89,7 @@ class MPUATC : public Object void MonitorUpdate(TextScreen&) override; private: - m68kcpu *cpu = NULL; + m68kcpu *cpu {}; }; extern std::unique_ptr gMPUATC;