--- nono/vm/spc.h 2026/04/29 17:04:50 1.1.1.8 +++ nono/vm/spc.h 2026/04/29 17:05:17 1.1.1.14 @@ -4,13 +4,19 @@ // Licensed under nono-license.txt // +// +// SPC (MB89352) +// + #pragma once #include "device.h" +#include "event.h" #include "fixedqueue.h" -#include "scheduler.h" +#include "monitor.h" #include "scsidev.h" -#include "vm.h" + +class InterruptDevice; struct SPC { @@ -120,9 +126,10 @@ struct SPC static const int SERR_SHORT_XFER = 0x02; // Short Transfer Period // PCTL レジスタ - // ここでは BusFree INT Enable ビットだけを保持。 - // 残りの MSG, C/D, I/O は親クラスの信号線フラグから生成。 + // BusFree INT Enable は独立して保持。 + // MSG, CD, IO の3ビットは pctl_out で保持。 bool busfree_intr_enable; + uint8 pctl_out; static const int PCTL_MASK = 0x87; // 書き込みマスク static const int PCTL_BFINT_EN = 0x80; // BusFree INT Enable static const int PCTL_MSG = 0x04; @@ -152,9 +159,7 @@ class SPCDevice : public SCSIHostDevice virtual ~SPCDevice() override; bool Init() override; - void ResetHard() override; - - void MonitorUpdate(TextScreen&) override; + void ResetHard(bool poweron) override; // SCSIBus コールバック @@ -178,6 +183,8 @@ class SPCDevice : public SCSIHostDevice uint64 Peek(uint32 offset); private: + DECLARE_MONITOR_CALLBACK(MonitorUpdate); + void MonitorReg(TextScreen&, int x, int y, uint32 reg, const char * const *names); @@ -212,6 +219,8 @@ class SPCDevice : public SCSIHostDevice // SERR レジスタ値の取得 uint32 GetSERR() const; + // PCTL レジスタへの書き込み + void WritePCTL(uint32); // PCTL レジスタ値の取得 uint32 GetPCTL() const; @@ -241,7 +250,6 @@ class SPCDevice : public SCSIHostDevice // Transfer コマンド実行 void TransferCommand(); - void TransferCommandStart(Event& ev); void HardwareTransfer(Event& ev); void TransferComplete(); // Transfer コマンド実行中なら true @@ -254,7 +262,7 @@ class SPCDevice : public SCSIHostDevice struct SPC spc {}; // VM 種別 - vmtype_t vmtype {}; + VMType vmtype {}; // SPC に入力されるクロック周期 [nsec] int t_CLF {}; @@ -266,12 +274,13 @@ class SPCDevice : public SCSIHostDevice // 割り込み信号線の接続先デバイス InterruptDevice *interrupt {}; - // 接続中のデバイス(イニシエータ含む)を ID 順に並べたリスト (モニタ用) - std::vector connected_devices {}; - // イベント - Event event {}; - Event event_tc {}; + Event event { this }; + Event event_tc { this }; + + Monitor monitor { this }; }; -extern std::unique_ptr gSPC; +static inline SPCDevice *GetSPCDevice() { + return Object::GetObject(OBJ_SPC); +}