--- nono/vm/sysctlr.h 2026/04/29 17:04:45 1.1.1.3 +++ nono/vm/sysctlr.h 2026/04/29 17:05:25 1.1.1.9 @@ -4,15 +4,17 @@ // Licensed under nono-license.txt // -// LUNA88K のシステムコントローラのような何か +// +// LUNA-88K のシステムコントローラのような何か +// #pragma once -#include "device.h" #include "interrupt.h" -class SysCtlrDevice - : public InterruptDevice +class MPU88xx0Device; + +class SysCtlrDevice : public InterruptDevice { using inherited = InterruptDevice; @@ -20,47 +22,34 @@ class SysCtlrDevice static const uint32 IntmapNMI = 0x80000000; static const uint32 IntmapSysClk = 0x08000000; static const uint32 IntmapSIO = 0x00800000; + static const uint32 IntmapXPHigh = 0x00400000; static const uint32 IntmapLance = 0x00080000; static const uint32 IntmapSPC = 0x00008000; - static const uint32 IntmapSoft3 = 0x00000080; - static const uint32 IntmapSoft2 = 0x00000040; - static const uint32 IntmapSoft1 = 0x00000020; - static const uint32 IntmapSoft0 = 0x00000010; + static const uint32 IntmapXPLow = 0x00000080; + static const uint32 IntmapSoft = 0x00000040; public: SysCtlrDevice(); - virtual ~SysCtlrDevice() override; + ~SysCtlrDevice() override; - void ResetHard() override; + bool Init() override; + void ResetHard(bool poweron) override; - void MonitorUpdate(TextScreen&) override; - - uint64 Read32(uint32 addr) override; - uint64 Write32(uint32 addr, uint32 data) override; - uint64 Peek8(uint32 addr) override; + busdata Read32(uint32 addr) override; + busdata Write32(uint32 addr, uint32 data) override; + busdata Peek8(uint32 addr) override; // InterruptDevice インタフェース - void AssertINT(Device *soruce) override; - void NegateINT(Device *source) override; - int InterruptAcknowledge(int lv) override; + busdata InterruptAcknowledge(int lv) override; private: - // デバイスから Intmap 値を引く - uint32 GetIntmap(Device *source) const; - // 割り込み状態を更新 - void ChangeInterrupt(); + void ChangeInterrupt() override; // マスク設定レジスタの書き込み値から内部用マスクを作成 static uint32 MakeIntMask(uint32 data, int n); - // 割り込みマップ (M680x0Interrupt::intmap と同じ構造) - uint32 intmap {}; - - // 割り込み回数 (アサートのエッジでカウントアップする) - // [0] が Intmap の bit31 割り込みのカウント。 - // [27] が Intmap の bit 4 割り込みのカウント。 - uint32 counter[28] {}; + DECLARE_MONITOR_CALLBACK(MonitorUpdate); // CPU ごとのパラメータ struct { @@ -73,8 +62,18 @@ class SysCtlrDevice // 現在の最高位の割り込みレベル int ipl; + + // ソフトウェア割り込みの Intmap (アサート中なら IntmapSoft) + uint32 softint; + + // ソフトウェア割り込み回数 + uint64 softint_count; } cpu[4] {}; + + MPU88xx0Device *mpu88xx0 {}; + + Monitor monitor { this }; }; -// グローバルインスタンスはここではなく gInterrupt を使用する -// (LUNA88K ではこれがメインの割り込みコントローラなので) +// 参照はここではなく GetInterruptDevice() を使用する +// (LUNA-88K ではこれがメインの割り込みコントローラなので)