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