1 /** @file 2 Support for SCSI-2 standard 3 4 Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR> 5 This program and the accompanying materials 6 are licensed and made available under the terms and conditions of the BSD License 7 which accompanies this distribution. The full text of the license may be found at 8 http://opensource.org/licenses/bsd-license.php 9 10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 12 13 **/ 14 15 #ifndef __SCSI_H__ 16 #define __SCSI_H__ 17 18 // 19 // SCSI command OP Code 20 // 21 // 22 // Commands for all device types 23 // 24 #define EFI_SCSI_OP_CHANGE_DEFINITION 0x40 25 #define EFI_SCSI_OP_COMPARE 0x39 26 #define EFI_SCSI_OP_COPY 0x18 27 #define EFI_SCSI_OP_COPY_VERIFY 0x3a 28 #define EFI_SCSI_OP_INQUIRY 0x12 29 #define EFI_SCSI_OP_LOG_SELECT 0x4c 30 #define EFI_SCSI_OP_LOG_SENSE 0x4d 31 #define EFI_SCSI_OP_MODE_SEL6 0x15 32 #define EFI_SCSI_OP_MODE_SEL10 0x55 33 #define EFI_SCSI_OP_MODE_SEN6 0x1a 34 #define EFI_SCSI_OP_MODE_SEN10 0x5a 35 #define EFI_SCSI_OP_READ_BUFFER 0x3c 36 #define EFI_SCSI_OP_RECEIVE_DIAG 0x1c 37 #define EFI_SCSI_OP_REQUEST_SENSE 0x03 38 #define EFI_SCSI_OP_SEND_DIAG 0x1d 39 #define EFI_SCSI_OP_TEST_UNIT_READY 0x00 40 #define EFI_SCSI_OP_WRITE_BUFF 0x3b 41 42 // 43 // Additional commands for Direct Access Devices 44 // 45 #define EFI_SCSI_OP_FORMAT 0x04 46 #define EFI_SCSI_OP_LOCK_UN_CACHE 0x36 47 #define EFI_SCSI_OP_PREFETCH 0x34 48 #define EFI_SCSI_OP_MEDIA_REMOVAL 0x1e 49 #define EFI_SCSI_OP_READ6 0x08 50 #define EFI_SCSI_OP_READ10 0x28 51 #define EFI_SCSI_OP_READ16 0x88 52 #define EFI_SCSI_OP_READ_CAPACITY 0x25 53 #define EFI_SCSI_OP_READ_CAPACITY16 0x9e 54 #define EFI_SCSI_OP_READ_DEFECT 0x37 55 #define EFI_SCSI_OP_READ_LONG 0x3e 56 #define EFI_SCSI_OP_REASSIGN_BLK 0x07 57 #define EFI_SCSI_OP_RELEASE 0x17 58 #define EFI_SCSI_OP_REZERO 0x01 59 #define EFI_SCSI_OP_SEARCH_DATA_E 0x31 60 #define EFI_SCSI_OP_SEARCH_DATA_H 0x30 61 #define EFI_SCSI_OP_SEARCH_DATA_L 0x32 62 #define EFI_SCSI_OP_SEEK6 0x0b 63 #define EFI_SCSI_OP_SEEK10 0x2b 64 #define EFI_SCSI_OP_SEND_DIAG 0x1d 65 #define EFI_SCSI_OP_SET_LIMIT 0x33 66 #define EFI_SCSI_OP_START_STOP_UNIT 0x1b 67 #define EFI_SCSI_OP_SYNC_CACHE 0x35 68 #define EFI_SCSI_OP_VERIFY 0x2f 69 #define EFI_SCSI_OP_WRITE6 0x0a 70 #define EFI_SCSI_OP_WRITE10 0x2a 71 #define EFI_SCSI_OP_WRITE16 0x8a 72 #define EFI_SCSI_OP_WRITE_VERIFY 0x2e 73 #define EFI_SCSI_OP_WRITE_LONG 0x3f 74 #define EFI_SCSI_OP_WRITE_SAME 0x41 75 #define EFI_SCSI_OP_UNMAP 0x42 76 77 // 78 // Additional commands for Sequential Access Devices 79 // 80 #define EFI_SCSI_OP_ERASE 0x19 81 #define EFI_SCSI_OP_LOAD_UNLOAD 0x1b 82 #define EFI_SCSI_OP_LOCATE 0x2b 83 #define EFI_SCSI_OP_READ_BLOCK_LIMIT 0x05 84 #define EFI_SCSI_OP_READ_POS 0x34 85 #define EFI_SCSI_OP_READ_REVERSE 0x0f 86 #define EFI_SCSI_OP_RECOVER_BUF_DATA 0x14 87 #define EFI_SCSI_OP_RESERVE_UNIT 0x16 88 #define EFI_SCSI_OP_REWIND 0x01 89 #define EFI_SCSI_OP_SPACE 0x11 90 #define EFI_SCSI_OP_VERIFY_TAPE 0x13 91 #define EFI_SCSI_OP_WRITE_FILEMARK 0x10 92 93 // 94 // Additional commands for Printer Devices 95 // 96 #define EFI_SCSI_OP_PRINT 0x0a 97 #define EFI_SCSI_OP_SLEW_PRINT 0x0b 98 #define EFI_SCSI_OP_STOP_PRINT 0x1b 99 #define EFI_SCSI_OP_SYNC_BUFF 0x10 100 101 // 102 // Additional commands for Processor Devices 103 // 104 #define EFI_SCSI_OP_RECEIVE 0x08 105 #define EFI_SCSI_OP_SEND 0x0a 106 107 // 108 // Additional commands for Write-Once Devices 109 // 110 #define EFI_SCSI_OP_MEDIUM_SCAN 0x38 111 #define EFI_SCSI_OP_SEARCH_DAT_E10 0x31 112 #define EFI_SCSI_OP_SEARCH_DAT_E12 0xb1 113 #define EFI_SCSI_OP_SEARCH_DAT_H10 0x30 114 #define EFI_SCSI_OP_SEARCH_DAT_H12 0xb0 115 #define EFI_SCSI_OP_SEARCH_DAT_L10 0x32 116 #define EFI_SCSI_OP_SEARCH_DAT_L12 0xb2 117 #define EFI_SCSI_OP_SET_LIMIT10 0x33 118 #define EFI_SCSI_OP_SET_LIMIT12 0xb3 119 #define EFI_SCSI_OP_VERIFY10 0x2f 120 #define EFI_SCSI_OP_VERIFY12 0xaf 121 #define EFI_SCSI_OP_WRITE12 0xaa 122 #define EFI_SCSI_OP_WRITE_VERIFY10 0x2e 123 #define EFI_SCSI_OP_WRITE_VERIFY12 0xae 124 125 // 126 // Additional commands for CD-ROM Devices 127 // 128 #define EFI_SCSI_OP_PLAY_AUD_10 0x45 129 #define EFI_SCSI_OP_PLAY_AUD_12 0xa5 130 #define EFI_SCSI_OP_PLAY_AUD_MSF 0x47 131 #define EFI_SCSI_OP_PLAY_AUD_TKIN 0x48 132 #define EFI_SCSI_OP_PLAY_TK_REL10 0x49 133 #define EFI_SCSI_OP_PLAY_TK_REL12 0xa9 134 #define EFI_SCSI_OP_READ_CD_CAPACITY 0x25 135 #define EFI_SCSI_OP_READ_HEADER 0x44 136 #define EFI_SCSI_OP_READ_SUB_CHANNEL 0x42 137 #define EFI_SCSI_OP_READ_TOC 0x43 138 139 // 140 // Additional commands for Scanner Devices 141 // 142 #define EFI_SCSI_OP_GET_DATABUFF_STAT 0x34 143 #define EFI_SCSI_OP_GET_WINDOW 0x25 144 #define EFI_SCSI_OP_OBJECT_POS 0x31 145 #define EFI_SCSI_OP_SCAN 0x1b 146 #define EFI_SCSI_OP_SET_WINDOW 0x24 147 148 // 149 // Additional commands for Optical Memory Devices 150 // 151 #define EFI_SCSI_OP_UPDATE_BLOCK 0x3d 152 153 // 154 // Additional commands for Medium Changer Devices 155 // 156 #define EFI_SCSI_OP_EXCHANGE_MEDIUM 0xa6 157 #define EFI_SCSI_OP_INIT_ELEMENT_STAT 0x07 158 #define EFI_SCSI_OP_POS_TO_ELEMENT 0x2b 159 #define EFI_SCSI_OP_REQUEST_VE_ADDR 0xb5 160 #define EFI_SCSI_OP_SEND_VOL_TAG 0xb6 161 162 // 163 // Additional commands for Communition Devices 164 // 165 #define EFI_SCSI_OP_GET_MESSAGE6 0x08 166 #define EFI_SCSI_OP_GET_MESSAGE10 0x28 167 #define EFI_SCSI_OP_GET_MESSAGE12 0xa8 168 #define EFI_SCSI_OP_SEND_MESSAGE6 0x0a 169 #define EFI_SCSI_OP_SEND_MESSAGE10 0x2a 170 #define EFI_SCSI_OP_SEND_MESSAGE12 0xaa 171 172 // 173 // SCSI Data Transfer Direction 174 // 175 #define EFI_SCSI_DATA_IN 0 176 #define EFI_SCSI_DATA_OUT 1 177 178 // 179 // Peripheral Device Type Definitions 180 // 181 #define EFI_SCSI_TYPE_DISK 0x00 ///< Direct-access device (e.g. magnetic disk) 182 #define EFI_SCSI_TYPE_TAPE 0x01 ///< Sequential-access device (e.g. magnetic tape) 183 #define EFI_SCSI_TYPE_PRINTER 0x02 ///< Printer device 184 #define EFI_SCSI_TYPE_PROCESSOR 0x03 ///< Processor device 185 #define EFI_SCSI_TYPE_WORM 0x04 ///< Write-once device (e.g. some optical disks) 186 #define EFI_SCSI_TYPE_CDROM 0x05 ///< CD-ROM device 187 #define EFI_SCSI_TYPE_SCANNER 0x06 ///< Scanner device 188 #define EFI_SCSI_TYPE_OPTICAL 0x07 ///< Optical memory device (e.g. some optical disks) 189 #define EFI_SCSI_TYPE_MEDIUMCHANGER 0x08 ///< Medium changer device (e.g. jukeboxes) 190 #define EFI_SCSI_TYPE_COMMUNICATION 0x09 ///< Communications device 191 #define EFI_SCSI_TYPE_ASCIT8_1 0x0A ///< Defined by ASC IT8 (Graphic arts pre-press devices) 192 #define EFI_SCSI_TYPE_ASCIT8_2 0x0B ///< Defined by ASC IT8 (Graphic arts pre-press devices) 193 // 194 // 0Ch - 1Eh are reserved 195 // 196 #define EFI_SCSI_TYPE_UNKNOWN 0x1F ///< Unknown or no device type 197 198 // 199 // Page Codes for INQUIRY command 200 // 201 #define EFI_SCSI_PAGE_CODE_SUPPORTED_VPD 0x00 202 #define EFI_SCSI_PAGE_CODE_BLOCK_LIMITS_VPD 0xB0 203 204 #pragma pack(1) 205 /// 206 /// Standard INQUIRY data format 207 /// 208 typedef struct { 209 UINT8 Peripheral_Type : 5; 210 UINT8 Peripheral_Qualifier : 3; 211 UINT8 DeviceType_Modifier : 7; 212 UINT8 Rmb : 1; 213 UINT8 Version; 214 UINT8 Response_Data_Format; 215 UINT8 Addnl_Length; 216 UINT8 Reserved_5_95[95 - 5 + 1]; 217 } EFI_SCSI_INQUIRY_DATA; 218 219 /// 220 /// Supported VPD Pages VPD page 221 /// 222 typedef struct { 223 UINT8 Peripheral_Type : 5; 224 UINT8 Peripheral_Qualifier : 3; 225 UINT8 PageCode; 226 UINT8 PageLength2; 227 UINT8 PageLength1; 228 UINT8 SupportedVpdPageList[0x100]; 229 } EFI_SCSI_SUPPORTED_VPD_PAGES_VPD_PAGE; 230 231 /// 232 /// Block Limits VPD page 233 /// 234 typedef struct { 235 UINT8 Peripheral_Type : 5; 236 UINT8 Peripheral_Qualifier : 3; 237 UINT8 PageCode; 238 UINT8 PageLength2; 239 UINT8 PageLength1; 240 UINT8 WriteSameNonZero : 1; 241 UINT8 Reserved_4 : 7; 242 UINT8 MaximumCompareAndWriteLength; 243 UINT8 OptimalTransferLengthGranularity2; 244 UINT8 OptimalTransferLengthGranularity1; 245 UINT8 MaximumTransferLength4; 246 UINT8 MaximumTransferLength3; 247 UINT8 MaximumTransferLength2; 248 UINT8 MaximumTransferLength1; 249 UINT8 OptimalTransferLength4; 250 UINT8 OptimalTransferLength3; 251 UINT8 OptimalTransferLength2; 252 UINT8 OptimalTransferLength1; 253 UINT8 MaximumPrefetchXdreadXdwriteTransferLength4; 254 UINT8 MaximumPrefetchXdreadXdwriteTransferLength3; 255 UINT8 MaximumPrefetchXdreadXdwriteTransferLength2; 256 UINT8 MaximumPrefetchXdreadXdwriteTransferLength1; 257 UINT8 MaximumUnmapLbaCount4; 258 UINT8 MaximumUnmapLbaCount3; 259 UINT8 MaximumUnmapLbaCount2; 260 UINT8 MaximumUnmapLbaCount1; 261 UINT8 MaximumUnmapBlockDescriptorCount4; 262 UINT8 MaximumUnmapBlockDescriptorCount3; 263 UINT8 MaximumUnmapBlockDescriptorCount2; 264 UINT8 MaximumUnmapBlockDescriptorCount1; 265 UINT8 OptimalUnmapGranularity4; 266 UINT8 OptimalUnmapGranularity3; 267 UINT8 OptimalUnmapGranularity2; 268 UINT8 OptimalUnmapGranularity1; 269 UINT8 UnmapGranularityAlignment4 : 7; 270 UINT8 UnmapGranularityAlignmentValid : 1; 271 UINT8 UnmapGranularityAlignment3; 272 UINT8 UnmapGranularityAlignment2; 273 UINT8 UnmapGranularityAlignment1; 274 UINT8 MaximumWriteSameLength4; 275 UINT8 MaximumWriteSameLength3; 276 UINT8 MaximumWriteSameLength2; 277 UINT8 MaximumWriteSameLength1; 278 UINT8 MaximumAtomicTransferLength4; 279 UINT8 MaximumAtomicTransferLength3; 280 UINT8 MaximumAtomicTransferLength2; 281 UINT8 MaximumAtomicTransferLength1; 282 UINT8 AtomicAlignment4; 283 UINT8 AtomicAlignment3; 284 UINT8 AtomicAlignment2; 285 UINT8 AtomicAlignment1; 286 UINT8 AtomicTransferLengthGranularity4; 287 UINT8 AtomicTransferLengthGranularity3; 288 UINT8 AtomicTransferLengthGranularity2; 289 UINT8 AtomicTransferLengthGranularity1; 290 UINT8 MaximumAtomicTransferLengthWithAtomicBoundary4; 291 UINT8 MaximumAtomicTransferLengthWithAtomicBoundary3; 292 UINT8 MaximumAtomicTransferLengthWithAtomicBoundary2; 293 UINT8 MaximumAtomicTransferLengthWithAtomicBoundary1; 294 UINT8 MaximumAtomicBoundarySize4; 295 UINT8 MaximumAtomicBoundarySize3; 296 UINT8 MaximumAtomicBoundarySize2; 297 UINT8 MaximumAtomicBoundarySize1; 298 } EFI_SCSI_BLOCK_LIMITS_VPD_PAGE; 299 300 /// 301 /// Error codes 70h and 71h sense data format 302 /// 303 typedef struct { 304 UINT8 Error_Code : 7; 305 UINT8 Valid : 1; 306 UINT8 Segment_Number; 307 UINT8 Sense_Key : 4; 308 UINT8 Reserved_21 : 1; 309 UINT8 Ili : 1; 310 UINT8 Reserved_22 : 2; 311 UINT8 Information_3_6[4]; 312 UINT8 Addnl_Sense_Length; ///< Additional sense length (n-7) 313 UINT8 Vendor_Specific_8_11[4]; 314 UINT8 Addnl_Sense_Code; ///< Additional sense code 315 UINT8 Addnl_Sense_Code_Qualifier; ///< Additional sense code qualifier 316 UINT8 Field_Replaceable_Unit_Code; ///< Field replaceable unit code 317 UINT8 Reserved_15_17[3]; 318 } EFI_SCSI_SENSE_DATA; 319 320 /// 321 /// SCSI Disk READ CAPACITY Data 322 /// 323 typedef struct { 324 UINT8 LastLba3; 325 UINT8 LastLba2; 326 UINT8 LastLba1; 327 UINT8 LastLba0; 328 UINT8 BlockSize3; 329 UINT8 BlockSize2; 330 UINT8 BlockSize1; 331 UINT8 BlockSize0; 332 } EFI_SCSI_DISK_CAPACITY_DATA; 333 334 typedef struct { 335 UINT8 LastLba7; 336 UINT8 LastLba6; 337 UINT8 LastLba5; 338 UINT8 LastLba4; 339 UINT8 LastLba3; 340 UINT8 LastLba2; 341 UINT8 LastLba1; 342 UINT8 LastLba0; 343 UINT8 BlockSize3; 344 UINT8 BlockSize2; 345 UINT8 BlockSize1; 346 UINT8 BlockSize0; 347 UINT8 Protection; 348 UINT8 LogicPerPhysical; 349 UINT8 LowestAlignLogic2; 350 UINT8 LowestAlignLogic1; 351 UINT8 Reserved[16]; 352 } EFI_SCSI_DISK_CAPACITY_DATA16; 353 354 typedef struct { 355 UINT16 DataLen; 356 UINT16 BlkDespDataLen; 357 UINT8 Reserved[4]; 358 } EFI_SCSI_DISK_UNMAP_PARAM_LIST_HEADER; 359 360 typedef struct { 361 UINT64 Lba; 362 UINT32 BlockNum; 363 UINT8 Reserved[4]; 364 } EFI_SCSI_DISK_UNMAP_BLOCK_DESP; 365 366 367 #pragma pack() 368 369 // 370 // Sense Key 371 // 372 #define EFI_SCSI_SK_NO_SENSE (0x0) 373 #define EFI_SCSI_SK_RECOVERY_ERROR (0x1) 374 #define EFI_SCSI_SK_NOT_READY (0x2) 375 #define EFI_SCSI_SK_MEDIUM_ERROR (0x3) 376 #define EFI_SCSI_SK_HARDWARE_ERROR (0x4) 377 #define EFI_SCSI_SK_ILLEGAL_REQUEST (0x5) 378 #define EFI_SCSI_SK_UNIT_ATTENTION (0x6) 379 #define EFI_SCSI_SK_DATA_PROTECT (0x7) 380 #define EFI_SCSI_SK_BLANK_CHECK (0x8) 381 #define EFI_SCSI_SK_VENDOR_SPECIFIC (0x9) 382 #define EFI_SCSI_SK_RESERVED_A (0xA) 383 #define EFI_SCSI_SK_ABORT (0xB) 384 #define EFI_SCSI_SK_RESERVED_C (0xC) 385 #define EFI_SCSI_SK_OVERFLOW (0xD) 386 #define EFI_SCSI_SK_MISCOMPARE (0xE) 387 #define EFI_SCSI_SK_RESERVED_F (0xF) 388 389 // 390 // Additional Sense Codes and Sense Code Qualifiers. 391 // Only some frequently used additional sense codes and qualifiers are 392 // defined here. Please refer to SCSI standard for full value definition. 393 // 394 #define EFI_SCSI_ASC_NOT_READY (0x04) 395 #define EFI_SCSI_ASCQ_IN_PROGRESS (0x01) 396 397 #define EFI_SCSI_ASC_MEDIA_ERR1 (0x10) 398 #define EFI_SCSI_ASC_MEDIA_ERR2 (0x11) 399 #define EFI_SCSI_ASC_MEDIA_ERR3 (0x14) 400 #define EFI_SCSI_ASC_MEDIA_ERR4 (0x30) 401 #define EFI_SCSI_ASC_MEDIA_UPSIDE_DOWN (0x06) 402 #define EFI_SCSI_ASC_INVALID_CMD (0x20) 403 #define EFI_SCSI_ASC_LBA_OUT_OF_RANGE (0x21) 404 #define EFI_SCSI_ASC_INVALID_FIELD (0x24) 405 #define EFI_SCSI_ASC_WRITE_PROTECTED (0x27) 406 #define EFI_SCSI_ASC_MEDIA_CHANGE (0x28) 407 #define EFI_SCSI_ASC_RESET (0x29) ///< Power On Reset or Bus Reset occurred 408 #define EFI_SCSI_ASC_ILLEGAL_FIELD (0x26) 409 #define EFI_SCSI_ASC_NO_MEDIA (0x3A) 410 #define EFI_SCSI_ASC_ILLEGAL_MODE_FOR_THIS_TRACK (0x64) 411 412 #endif 413