--- nono/vm/virtio_def.h 2026/04/29 17:05:24 1.1 +++ nono/vm/virtio_def.h 2026/04/29 17:05:42 1.1.1.3 @@ -51,8 +51,12 @@ class VirtIO // DEVICE_ID static const uint32 DEVICE_ID_INVALID = 0; - static const uint32 DEVICE_ID_NET = 1; + static const uint32 DEVICE_ID_NETWORK = 1; static const uint32 DEVICE_ID_BLOCK = 2; + static const uint32 DEVICE_ID_CONSOLE = 3; + static const uint32 DEVICE_ID_ENTROPY = 4; + static const uint32 DEVICE_ID_BALLOON = 5; + static const uint32 DEVICE_ID_SCSI = 8; static std::string DeviceIDStr(uint32); // STATUS @@ -111,6 +115,11 @@ static const uint VIRTIO_BLK_F_TOPOLOGY static const uint VIRTIO_BLK_F_CONFIG_WCE = 11; static const uint VIRTIO_BLK_F_DISCARD = 13; static const uint VIRTIO_BLK_F_WRITE_ZEROES = 14; +// FEATURES (SCSIDevice) +static const uint VIRTIO_SCSI_F_INOUT = 0; +static const uint VIRTIO_SCSI_F_HOTPLUG = 1; +static const uint VIRTIO_SCSI_F_CHANGE = 2; +static const uint VIRTIO_SCSI_F_T10_PI = 4; // こっちは仕様上の構造体定義。クラスのほうを使うこと。 @@ -158,7 +167,7 @@ struct virtq_used { static const uint16 VIRTQ_USED_F_NO_NOTIFY = 1; -// NetworkCard +// NetworkDevice struct virtio_net_hdr { u8 flags; @@ -209,3 +218,56 @@ struct virtio_blk_discard_write_zeroes { //} flags; le32 flags; }; + +// SCSIDevice + +struct virtio_scsi_req_cmd { + // Device-readable part + u8 lun[8]; + le64 id; + u8 task_attr; + u8 prio; + u8 crn; + u8 cdb[0]; // [cdb_size] + // The next three fields are only present if VIRTIO_SCSI_F_T10_PI + // is negotiated. + //le32 pi_bytesout; + //le32 pi_bytesin; + //u8 pi_out[pi_bytesout]; + u8 dataout[0]; + + // Device-writable part + le32 sense_len; + le32 residual; + le16 status_qualifier; + u8 status; + u8 response; + u8 sense[0]; // [sense_size] + // The next field is only present if VIRTIO_SCS_IF_T10_PI + // is negotiated. + //u8 pi_in[pi_bytesin]; + u8 datain[0]; +}; + +struct virtio_scsi_ctrl { + le32 type; + // + u8 response; +}; + +static const uint8 VIRTIO_SCSI_S_OK = 0; +static const uint8 VIRTIO_SCSI_S_OVERRUN = 1; +static const uint8 VIRTIO_SCSI_S_ABORTED = 2; +static const uint8 VIRTIO_SCSI_S_BAD_TARGET = 3; +static const uint8 VIRTIO_SCSI_S_RESET = 4; +static const uint8 VIRTIO_SCSI_S_BUSY = 5; +static const uint8 VIRTIO_SCSI_S_TRANSPORT_FAILURE = 6; +static const uint8 VIRTIO_SCSI_S_TARGET_FAILURE = 7; +static const uint8 VIRTIO_SCSI_S_NEXUS_FAILURE = 8; +static const uint8 VIRTIO_SCSI_S_FAILURE = 9; +static const uint8 VIRTIO_SCSI_S_INCORRECT_LUN = 12; +// task_attr +static const uint8 VIRTIO_SCSI_S_SIMPLE = 0; +static const uint8 VIRTIO_SCSI_S_ORDERED = 1; +static const uint8 VIRTIO_SCSI_S_HEAD = 2; +static const uint8 VIRTIO_SCSI_S_ACA = 3;