--- nono/vm/mpu680x0.h 2026/04/29 17:04:32 1.1.1.1 +++ nono/vm/mpu680x0.h 2026/04/29 17:04:42 1.1.1.4 @@ -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,48 @@ class MPU680x0Device : public MPUDevice { - typedef MPUDevice inherited; + using inherited = MPUDevice; public: MPU680x0Device(uint32); - virtual ~MPU680x0Device(); + ~MPU680x0Device() override; - virtual bool Init(); - virtual void ResetHard(); - - virtual uint32 Run(uint64 request); - - virtual bool MonitorUpdate(); + bool Init() override; + void MonitorUpdate(TextScreen&) override; + uint32 Run(uint64 request) 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; } + + // アクセスウェイトを加算 + void AddCycle(uint64 cycle) override { cpu->total_cycle += cycle; } // 割り込み発生を MPU に通知 (オートベクタ) - virtual void Interrupt(int level); + void Interrupt(Object *src, int level) override; // 割り込み発生を MPU に通知 (ベクタ) - void Interrupt(int level, int vector); + void Interrupt(Object *src, int level, int vector); // MPU の処理をこの命令で中断させる。 // スケジューラのイベントリストに追加が発生した時に VM 側から // MPU へ処理の中断を指示する。 - virtual void Release() { cpu->atomic_reqflag |= CPU_REQ_RELEASE; } + void Release() override { cpu->atomic_reqflag |= CPU_REQ_RELEASE; } // 基準サイクル数を取得 - virtual uint64 total_cycle() const { return cpu->total_cycle; } + uint64 total_cycle() const override { return cpu->total_cycle; } // 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 +66,10 @@ class MPU680x0Device : public MPUDevice } private: - m68kcpu *cpu = NULL; + // リセット例外イベントコールバック + void ResetCallback(Event& ev); + + m68kcpu *cpu {}; }; // ATC モニタ @@ -70,28 +77,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()))