--- nono/vm/mpu680x0.h 2026/04/29 17:04:32 1.1.1.1 +++ nono/vm/mpu680x0.h 2026/04/29 17:04:45 1.1.1.5 @@ -1,6 +1,7 @@ // // nono -// Copyright (C) 2017 isaki@NetBSD.org +// Copyright (C) 2020 nono project +// Licensed under nono-license.txt // // MPU (m680x0) @@ -12,45 +13,46 @@ class MPU680x0Device : public MPUDevice { - typedef MPUDevice inherited; + using inherited = MPUDevice; public: MPU680x0Device(uint32); - virtual ~MPU680x0Device(); + virtual ~MPU680x0Device() override; - virtual bool Init(); - virtual void ResetHard(); + bool Init() override; + void MonitorUpdate(TextScreen&) override; - virtual uint32 Run(uint64 request); - - virtual bool MonitorUpdate(); + // MPU を vtime [nsec] 分実行する + uint32 Run(uint32 vtime) override; + // 現在の仮想時刻 [nsec] を取得する + uint64 GetVirtTime() override; // 現在の PPC を取得 - virtual uint32 GetPPC() const { return RegPPC; } + uint32 GetPPC() const override { return RegPPC; } // 現在アクセス中の論理アドレス、物理アドレスを取得。 - virtual uint32 GetLaddr() const { return cpu->bus.laddr; } - virtual uint32 GetPaddr() const { return cpu->bus.paddr; } + uint32 GetLaddr() const override { return cpu->bus.laddr; } + uint32 GetPaddr() const override { return cpu->bus.paddr; } - // 割り込み発生を MPU に通知 (オートベクタ) - virtual void Interrupt(int level); + // アクセスウェイトを加算 + void AddCycle(int32 cycle) override { cpu->used_cycle += cycle; } - // 割り込み発生を MPU に通知 (ベクタ) - void Interrupt(int level, int vector); + // 割り込みレベルが変わったことを MPU に通知 + void Interrupt(int level) override; // MPU の処理をこの命令で中断させる。 // スケジューラのイベントリストに追加が発生した時に VM 側から // MPU へ処理の中断を指示する。 - virtual void Release() { cpu->atomic_reqflag |= CPU_REQ_RELEASE; } - - // 基準サイクル数を取得 - virtual uint64 total_cycle() const { return cpu->total_cycle; } + void Release() override { cpu->atomic_reqflag |= CPU_REQ_RELEASE; } // A-Line, F-Line 命令エミュレーションのコールバックを指定する。 // (Human68k エミュレーションで使用) void SetALineCallback(bool (*callback)(m68kcpu*, void*), void *arg); void SetFLineCallback(bool (*callback)(m68kcpu*, void*), void *arg); + // ダブルバスフォールトのコールバックを指定する。 + void SetHaltCallback(void (*callback)(void*), void *arg); + // FPU を持っているか bool HaveFPU() const { return cpu->has_fpu; @@ -62,7 +64,13 @@ class MPU680x0Device : public MPUDevice } private: - m68kcpu *cpu = NULL; + // イベントコールバック + void Callback(Event& ev); + + // 割り込み確定のためのディレイ [nsec] + uint64 intdelay {}; + + m68kcpu *cpu {}; }; // ATC モニタ @@ -70,28 +78,14 @@ class MPUATC : public Object { public: MPUATC(m68kcpu *cpu); - virtual ~MPUATC() { } - - virtual bool MonitorUpdate(); - - private: - m68kcpu *cpu = NULL; -}; - -// ブランチ履歴モニタ -class MPUBrHist : public Object -{ - public: - MPUBrHist(m68kcpu *cpu); - virtual ~MPUBrHist() { } + ~MPUATC() override { } - virtual bool MonitorUpdate(); + void MonitorUpdate(TextScreen&) override; private: - m68kcpu *cpu = NULL; + m68kcpu *cpu {}; }; extern std::unique_ptr gMPUATC; -extern std::unique_ptr gMPUBrHist; #define gMPU680x0 (dynamic_cast(gMPU.get()))