--- nono/vm/spc.h 2026/04/29 17:04:59 1.1.1.11 +++ nono/vm/spc.h 2026/04/29 17:05:25 1.1.1.15 @@ -4,14 +4,19 @@ // Licensed under nono-license.txt // +// +// SPC (MB89352) +// + #pragma once #include "device.h" +#include "event.h" #include "fixedqueue.h" #include "monitor.h" -#include "scheduler.h" #include "scsidev.h" -#include "vm.h" + +class InterruptDevice; struct SPC { @@ -151,10 +156,10 @@ class SPCDevice : public SCSIHostDevice using inherited = SCSIHostDevice; public: SPCDevice(); - virtual ~SPCDevice() override; + ~SPCDevice() override; bool Init() override; - void ResetHard() override; + void ResetHard(bool poweron) override; // SCSIBus コールバック @@ -169,13 +174,13 @@ class SPCDevice : public SCSIHostDevice // BusIO インタフェース // (内蔵 ROM からのアクセス用に特別に public にしてある) - uint64 Write(uint32 offset, uint32 data); + busdata Write(uint32 offset, uint32 data); protected: // BusIO インタフェース static const uint32 NPORT = 16; - uint64 Read(uint32 offset); - uint64 Peek(uint32 offset); + busdata Read(uint32 offset); + busdata Peek(uint32 offset); private: DECLARE_MONITOR_CALLBACK(MonitorUpdate); @@ -220,8 +225,8 @@ class SPCDevice : public SCSIHostDevice uint32 GetPCTL() const; // DREG レジスタアクセス - uint64 ReadDREG(); - uint64 WriteDREG(uint32 data); + busdata ReadDREG(); + busdata WriteDREG(uint32 data); // バスフリーフェーズに移行する void BusFree(); @@ -257,14 +262,14 @@ class SPCDevice : public SCSIHostDevice struct SPC spc {}; // VM 種別 - vmtype_t vmtype {}; + VMType vmtype {}; // SPC に入力されるクロック周期 [nsec] int t_CLF {}; // アクセスウェイト - uint32 read_wait {}; - uint32 write_wait {}; + busdata read_wait {}; + busdata write_wait {}; // 割り込み信号線の接続先デバイス InterruptDevice *interrupt {}; @@ -276,4 +281,6 @@ class SPCDevice : public SCSIHostDevice Monitor monitor { this }; }; -extern std::unique_ptr gSPC; +static inline SPCDevice *GetSPCDevice() { + return Object::GetObject(OBJ_SPC); +}