--- nono/vm/mpu88xx0.h 2026/04/29 17:05:18 1.1.1.12 +++ nono/vm/mpu88xx0.h 2026/04/29 17:05:25 1.1.1.13 @@ -20,6 +20,7 @@ class MPU88xx0Device : public MPUDevice, private M88100 { using inherited = MPUDevice; + friend class Luna88kPROMEmuDevice; static const uint32 CPU_STATE_NORMAL = 0; static const uint32 CPU_STATE_STOP = 1; // 疑似 STOP 状態 @@ -34,22 +35,13 @@ class MPU88xx0Device : public MPUDevice, public: MPU88xx0Device(); - virtual ~MPU88xx0Device() override; + ~MPU88xx0Device() override; bool Init() override; void ResetHard(bool poweron) override; - // MPU からのアクセスをエミュレートする。 - // アドレスは論理アドレス。 - // 空間は現在のデータ空間。 - // ミスアラインドアクセスも可能。 - // アクセスエラーは -1 を返す。 - uint64 Read8(uint32 addr) override; - uint64 Read16(uint32 addr) override; - uint64 Read32(uint32 addr) override; - uint64 Write8(uint32 addr, uint32 data) override; - uint64 Write16(uint32 addr, uint32 data) override; - uint64 Write32(uint32 addr, uint32 data) override; + // キャッシュ禁止通知 (LUNA-88K では使っていない?) + void SetCI() override { } // 現在実行中の命令の PC を取得 uint32 GetPPC() const override { return reg.xip; } @@ -57,6 +49,9 @@ class MPU88xx0Device : public MPUDevice, // 現在の VBR を取得 uint32 GetVBR() const override { return reg.vbr; } + // MPU 名を取得 + const char *GetMPUName() const override { return "MC88100"; } + // スーパーバイザ/ユーザモードなら true bool IsSuper() const { return (reg.psr & PSR_SUPER) != 0; } bool IsUser() const { return (reg.psr & PSR_SUPER) == 0; } @@ -71,13 +66,18 @@ class MPU88xx0Device : public MPUDevice, uint32 GetLaddr() const override; uint32 GetPaddr() const override; - // アクセスウェイトを加算 - void AddCycle(int32 cycle) override { + // アクセスウェイト [clock] を加算。m88200 が呼ぶ。 + void AddCycle(int32 cycle) { // XXX 本来は今アクセスしてきている(= バスマスターの) CMMU に // 対して加算するべき?かもだが、まだその辺の概念がない。 used_cycle += cycle; } + // アクセスウェイト [nsec] を加算。m88200 が呼ぶ。 + void AddWait(uint32 nsec) { + buswait += nsec; + } + // 割り込み発生を MPU に通知 void Interrupt(int level) override; @@ -223,6 +223,9 @@ OP_PROTO(illegal); // 電源オンからの累積消費サイクル uint64 used_cycle {}; + // 今回のバスウェイト [nsec] + uint64 buswait {}; + // ペンディング中の割り込みレベル int intr_pending {}; @@ -245,6 +248,7 @@ OP_PROTO(illegal); EventCallback_t exec_normal {}; }; -static inline MPU88xx0Device *GetMPU88xx0Device() { - return Object::GetObject(OBJ_MPU); +// これを呼びたい人は mpu を持ってるはず。 +static inline MPU88xx0Device *GetMPU88xx0Device(Device *mpu_) { + return dynamic_cast(mpu_); }