--- nono/vm/spc.h 2026/04/29 17:05:33 1.1.1.17 +++ nono/vm/spc.h 2026/04/29 17:05:50 1.1.1.19 @@ -11,11 +11,13 @@ #pragma once #include "device.h" -#include "event.h" #include "fixedqueue.h" #include "mainapp.h" +#include "scsi.h" +#include "scsibus.h" class InterruptDevice; +class SCSIDomain; class SCSIHostDevice; struct SPC @@ -66,11 +68,14 @@ struct SPC // xfer ビット(SERR_XFER_OUT) もここの bit8 に含めている。 // 残りの下位8ビットは INTS と同じ。 // - // | b7 | b6 | b5 | b4 | b3 | b2 | b1 | b0 | + // b8 b7 b6 b5 b4 b3 b2 b1 b0 + // +----+----+----+----+----+----+----+----+ // INTS |SEL |RESL|DIS |CMPL|SERV|TOUT|HERR|REST| - // b8 - // ints変数 |xfer|SEL |RESL|DIS |CMPL|SERV|TOUT|HERR|REST| + // +----+----+----+----+----+----+----+----+ // + // +----+----+----+----+----+----+----+----+----+ + // ints変数 |xfer|SEL |RESL|DIS |CMPL|SERV|TOUT|HERR|REST| + // +----+----+----+----+----+----+----+----+----+ uint16 ints; static const uint INTS_SELECTED = 0x80; // Selected static const uint INTS_RESELECTED = 0x40; // Reselected @@ -158,11 +163,12 @@ class SPCDevice : public IODevice SPCDevice(); ~SPCDevice() override; + void SetLogLevel(int loglevel_) override; bool Create() override; bool Init() override; void ResetHard(bool poweron) override; - SCSIHostDevice *GetSCSI() const { return scsi.get(); } + SCSIDomain *GetDomain() const noexcept { return domain.get(); } // BusIO インタフェース // (内蔵 ROM からのアクセス用に特別に public にしてある) @@ -238,10 +244,10 @@ class SPCDevice : public IODevice // Select コマンド実行 void SelectCommand(); - void Arbitration1(Event& ev); - void Arbitration2(Event& ev); - void Selection1(Event& ev); - void SelectionTimeout(Event& ev); + void Arbitration1(Event *); + void Arbitration2(Event *); + void Selection1(Event *); + void SelectionTimeout(Event *); // SetATN コマンド実行 void SetATNCommand(); @@ -250,7 +256,7 @@ class SPCDevice : public IODevice // Transfer コマンド実行 void TransferCommand(); - void HardwareTransfer(Event& ev); + void HardwareTransfer(Event *); void TransferComplete(); // Transfer コマンド実行中なら true bool transfer_command_running {}; @@ -258,6 +264,37 @@ class SPCDevice : public IODevice // SCSI コマンド void ExecCommand(); + // + // 信号線制御 + // (ソースコード的なショートカットのため) + // + bool GetRST() const { return bus->GetRST(); } + void AssertRST() { bus->AssertRST(); } + void NegateRST() { bus->NegateRST(); } + bool GetREQ() const { return bus->GetREQ(); } + void AssertREQ() { bus->AssertREQ(); } + void NegateREQ() { bus->NegateREQ(); } + bool GetACK() const { return bus->GetACK(); } + void AssertACK() { bus->AssertACK(); } + void NegateACK() { bus->NegateACK(); } + bool GetATN() const { return bus->GetATN(); } + void AssertATN() { bus->AssertATN(); } + void NegateATN() { bus->NegateATN(); } + uint8 GetSEL() const { return bus->GetSEL(); } + void AssertSEL() { bus->AssertSEL(myid); } + void NegateSEL() { bus->NegateSEL(myid); } + uint8 GetBSY() const { return bus->GetBSY(); } + void AssertBSY() { bus->AssertBSY(myid); } + void NegateBSY() { bus->NegateBSY(myid); } + bool GetMSG() const { return bus->GetMSG(); } + bool GetCD() const { return bus->GetCD(); } + bool GetIO() const { return bus->GetIO(); } + SCSI::XferPhase GetXfer() const { return bus->GetXfer(); } + void SetXfer(uint8 val) { bus->SetXfer(val); } + SCSI::Phase GetPhase() const { return bus->GetPhase(); } + uint8 GetData() const { return bus->GetData(); } + void SetData(uint8 val) const { bus->SetData(val); } + // レジスタ struct SPC spc {}; @@ -282,10 +319,17 @@ class SPCDevice : public IODevice InterruptDevice *interrupt {}; // イベント - Event phase_event { this }; - Event timer_event { this }; + Event *phase_event {}; + Event *timer_event {}; + + // SCSI 管理 + std::unique_ptr domain /*{}*/; + + // SCSI ホストアダプタ + SCSIHostDevice *host {}; - std::unique_ptr scsi /*{}*/; + // SCSI バス + std::unique_ptr bus /*{}*/; Monitor *monitor {}; };