--- nono/vm/scsibus.h 2026/04/29 17:04:29 1.1.1.1 +++ nono/vm/scsibus.h 2026/04/29 17:05:25 1.1.1.8 @@ -1,14 +1,16 @@ // // nono -// Copyright (C) 2020 isaki@NetBSD.org +// Copyright (C) 2020 nono project +// Licensed under nono-license.txt // +// // SCSI バス +// #pragma once -#include "device.h" -#include "scheduler.h" +#include "event.h" #include "scsi.h" // フェーズ遷移についてのメモ。 @@ -101,9 +103,12 @@ // class SCSIBus : public Device { + using inherited = Device; public: SCSIBus(); - virtual ~SCSIBus(); + ~SCSIBus() override; + + void ResetHard(bool poweron) override; // このバスにデバイスを接続する bool Attach(SCSIDevice *dev, int id); @@ -156,13 +161,18 @@ class SCSIBus : public Device return NULL; } + // 次の REQ アサートの前に指定のウェイトを入れる + // (シークタイムなどを簡易的に再現するため)。 + // ウェイトは一度適用されると 0 に戻る。 + void SetOneshotReqWait(uint64 nsec) { req_wait += nsec; } + private: void BusFree(int id); - void SelectionStart(); - void Selected(int code); - void SelectionAck(int code); - void StartTransfer(int code); - void TransferReq(int code); + void SelectionStart(Event& ev); + void Selected(Event& ev); + void SelectionAck(Event& ev); + void StartTransfer(Event& ev); + void TransferReq(Event& ev); // 現在のフェーズ SCSI::Phase phase {}; @@ -182,7 +192,10 @@ class SCSIBus : public Device // 前回 ACK を立てた時刻。 // 転送速度をここで律速させている。 - uint64 last_req_time = 0; + uint64 last_req_time {}; + + // 次の REQ アサートに入れるウェイト [nsec] + uint64 req_wait {}; // 実際のバスではそんなことはないが、ここではバスがイニシエータと // ターゲットの ID を把握している。どちらも非選択状態なら -1。 @@ -194,7 +207,7 @@ class SCSIBus : public Device SCSIDevice *device[8] {}; // イベント - Event event {}; + Event event { this }; }; // (1<