1 /** @file 2 3 Virtio SCSI Host Device specific type and macro definitions corresponding to 4 the virtio-0.9.5 specification. 5 6 Copyright (C) 2012, Red Hat, Inc. 7 8 SPDX-License-Identifier: BSD-2-Clause-Patent 9 10 **/ 11 12 #ifndef _VIRTIO_SCSI_H_ 13 #define _VIRTIO_SCSI_H_ 14 15 #include <IndustryStandard/Virtio.h> 16 17 18 // 19 // virtio-0.9.5, Appendix I: SCSI Host Device 20 // 21 #pragma pack(1) 22 typedef struct { 23 UINT32 NumQueues; 24 UINT32 SegMax; 25 UINT32 MaxSectors; 26 UINT32 CmdPerLun; 27 UINT32 EventInfoSize; 28 UINT32 SenseSize; 29 UINT32 CdbSize; 30 UINT16 MaxChannel; 31 UINT16 MaxTarget; 32 UINT32 MaxLun; 33 } VIRTIO_SCSI_CONFIG; 34 #pragma pack() 35 36 #define OFFSET_OF_VSCSI(Field) OFFSET_OF (VIRTIO_SCSI_CONFIG, Field) 37 #define SIZE_OF_VSCSI(Field) (sizeof ((VIRTIO_SCSI_CONFIG *) 0)->Field) 38 39 #define VIRTIO_SCSI_F_INOUT BIT0 40 #define VIRTIO_SCSI_F_HOTPLUG BIT1 41 42 // 43 // We expect these maximum sizes from the host. Also we force the CdbLength and 44 // SenseDataLength parameters of EFI_EXT_SCSI_PASS_THRU_PROTOCOL.PassThru() not 45 // to exceed these limits. See UEFI 2.3.1 errata C 14.7. 46 // 47 #define VIRTIO_SCSI_CDB_SIZE 32 48 #define VIRTIO_SCSI_SENSE_SIZE 96 49 50 // 51 // We pass the dynamically sized buffers ("dataout", "datain") in separate ring 52 // descriptors. 53 // 54 #pragma pack(1) 55 typedef struct { 56 UINT8 Lun[8]; 57 UINT64 Id; 58 UINT8 TaskAttr; 59 UINT8 Prio; 60 UINT8 Crn; 61 UINT8 Cdb[VIRTIO_SCSI_CDB_SIZE]; 62 } VIRTIO_SCSI_REQ; 63 64 typedef struct { 65 UINT32 SenseLen; 66 UINT32 Residual; 67 UINT16 StatusQualifier; 68 UINT8 Status; 69 UINT8 Response; 70 UINT8 Sense[VIRTIO_SCSI_SENSE_SIZE]; 71 } VIRTIO_SCSI_RESP; 72 #pragma pack() 73 74 // 75 // selector of first virtio queue usable for request transfer 76 // 77 #define VIRTIO_SCSI_REQUEST_QUEUE 2 78 79 // 80 // host response codes 81 // 82 #define VIRTIO_SCSI_S_OK 0 83 #define VIRTIO_SCSI_S_OVERRUN 1 84 #define VIRTIO_SCSI_S_ABORTED 2 85 #define VIRTIO_SCSI_S_BAD_TARGET 3 86 #define VIRTIO_SCSI_S_RESET 4 87 #define VIRTIO_SCSI_S_BUSY 5 88 #define VIRTIO_SCSI_S_TRANSPORT_FAILURE 6 89 #define VIRTIO_SCSI_S_TARGET_FAILURE 7 90 #define VIRTIO_SCSI_S_NEXUS_FAILURE 8 91 #define VIRTIO_SCSI_S_FAILURE 9 92 93 #endif // _VIRTIO_SCSI_H_ 94