--- nono/vm/scsidev.h 2026/04/29 17:05:03 1.1.1.11 +++ nono/vm/scsidev.h 2026/04/29 17:05:18 1.1.1.14 @@ -4,13 +4,9 @@ // Licensed under nono-license.txt // -// SCSI デバイス共通部分 - -#pragma once - -#include "diskimage.h" -#include "scsibus.h" -#include "scsicmd.h" +// +// SCSI デバイス +// // IODevice (SPCDevice の親になるため) // | @@ -24,6 +20,14 @@ // v v // SPCDevice SCSIDisk (各デバイス、各ターゲット固有部分) +#pragma once + +#include "diskimage.h" +#include "message.h" +#include "monitor.h" +#include "scsibus.h" +#include "scsicmd.h" + // // SCSI デバイスとしての共通部分。 // これ自体は IODevice ではないが SCSI ホストアダプタがこれを継承するため。 @@ -32,7 +36,7 @@ class SCSIDevice : public IODevice { using inherited = IODevice; public: - SCSIDevice(const std::string& objname_); + SCSIDevice(int objid_); virtual ~SCSIDevice() override; // バスに接続 (SCSIBus::Attach から呼ばれる) @@ -125,7 +129,7 @@ class SCSIHostDevice : public SCSIDevice { using inherited = SCSIDevice; public: - SCSIHostDevice(const std::string& objname_); + SCSIHostDevice(int objid_); virtual ~SCSIHostDevice() override; bool Create() override; @@ -201,10 +205,10 @@ class SCSITarget : public SCSIDevice { using inherited = SCSIDevice; public: - SCSITarget(const std::string& objname_, SCSIHostDevice *h, int id); + SCSITarget(SCSIHostDevice *h, int id); virtual ~SCSITarget() override; - bool PowerOn() override; + void ResetHard(bool poweron) override; // Inquiry データを返す (Cmd から呼ばれる) virtual bool Inquiry(std::vector& buf, int lun) = 0; @@ -212,6 +216,9 @@ class SCSITarget : public SCSIDevice // 現在のコマンド列を返す (モニタ用) std::vector GetCmdSeq() const { return cmdseq; } + // コマンドを選択する (ROM30 エミュレーション用) + SCSICmd *SelectCommand(const std::vector& cmdseq_); + // 論理ブロック長 uint32 GetBlocksize() const { return blocksize; } void SetBlocksize(uint32 val) { blocksize = val; } @@ -247,19 +254,20 @@ class SCSITarget : public SCSIDevice void TransferAckCB() override; protected: + // SCSI コマンドのディスパッチャ + virtual void DispatchCmd(); + // ホスト SCSIHostDevice *host {}; // コマンド std::vector cmdseq {}; + // このコマンドの長さ。 // cmdseq の1バイト目で決まるやつのことで、受信目標バイト数。 // 今何バイト受信しているかは cmdseq.size()。 int cmdlen {}; - // SCSI コマンドのディスパッチャ - virtual void DispatchCmd(); - // 現在実行中の SCSI コマンド std::unique_ptr cmd {}; @@ -300,7 +308,7 @@ class SCSIDisk : public SCSITarget virtual ~SCSIDisk() override; bool Init() override; - bool PowerOn() override; + void ResetHard(bool poweron) override; void DispatchCmd() override; bool Inquiry(std::vector& buf, int lun) override; @@ -339,6 +347,8 @@ class SCSIDisk : public SCSITarget // メディアの書き込みモードを返す RW GetWriteMode() const { return write_mode; } + // メディアの書き込みモードを文字列で返す (モニタ用) + const char *GetWriteModeStr() const; // メディア(ディスク)イメージを開く/閉じる。(同一スレッドから呼ぶこと) bool LoadDisk(const std::string& path_); @@ -372,8 +382,8 @@ class SCSIDisk : public SCSITarget void MediaChanged() const; // メディア挿入/排出コールバック - void LoadCallback(Event&); - void UnloadCallback(Event&); + void LoadCallback(MessageID, uint32); + void UnloadCallback(MessageID, uint32); // イメージファイルのフルパス std::string pathname {}; @@ -396,8 +406,4 @@ class SCSIDisk : public SCSITarget bool medium_removal_prevented {}; uint64 seektime {}; - - // UI からの指示を受け取るイベント - // (リムーバブルデバイスでのみ作成するので、ポインタ) - Event *event {}; };