1 /*++
2 
3 Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution.  The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8 
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11 
12 Module Name:
13 
14     scsi.h
15 
16 Abstract:
17     support for SCSI standard
18 
19 Revision History
20 --*/
21 
22 #ifndef _SCSI_H
23 #define _SCSI_H
24 
25 //
26 // SCSI command OP Code
27 //
28 //
29 // Commands for all device types
30 //
31 #define EFI_SCSI_OP_CHANGE_DEFINITION 0x40
32 #define EFI_SCSI_OP_COMPARE           0x39
33 #define EFI_SCSI_OP_COPY              0x18
34 #define EFI_SCSI_OP_COPY_VERIFY       0x3a
35 #define EFI_SCSI_OP_INQUIRY           0x12
36 #define EFI_SCSI_OP_LOG_SELECT        0x4c
37 #define EFI_SCSI_OP_LOG_SENSE         0x4d
38 #define EFI_SCSI_OP_MODE_SEL6         0x15
39 #define EFI_SCSI_OP_MODE_SEL10        0x55
40 #define EFI_SCSI_OP_MODE_SEN6         0x1a
41 #define EFI_SCSI_OP_MODE_SEN10        0x5a
42 #define EFI_SCSI_OP_READ_BUFFER       0x3c
43 #define EFI_SCSI_OP_REQUEST_SENSE     0x03
44 #define EFI_SCSI_OP_SEND_DIAG         0x1d
45 #define EFI_SCSI_OP_TEST_UNIT_READY   0x00
46 #define EFI_SCSI_OP_WRITE_BUFF        0x3b
47 
48 //
49 // Commands unique to Direct Access Devices
50 //
51 #define EFI_SCSI_OP_COMPARE         0x39
52 #define EFI_SCSI_OP_FORMAT          0x04
53 #define EFI_SCSI_OP_LOCK_UN_CACHE   0x36
54 #define EFI_SCSI_OP_PREFETCH        0x34
55 #define EFI_SCSI_OP_MEDIA_REMOVAL   0x1e
56 #define EFI_SCSI_OP_READ6           0x08
57 #define EFI_SCSI_OP_READ10          0x28
58 #define EFI_SCSI_OP_READ_CAPACITY   0x25
59 #define EFI_SCSI_OP_READ_CAPACITY16 0x9e
60 #define EFI_SCSI_OP_READ_DEFECT     0x37
61 #define EFI_SCSI_OP_READ_LONG       0x3e
62 #define EFI_SCSI_OP_REASSIGN_BLK    0x07
63 #define EFI_SCSI_OP_RECEIVE_DIAG    0x1c
64 #define EFI_SCSI_OP_RELEASE         0x17
65 #define EFI_SCSI_OP_REZERO          0x01
66 #define EFI_SCSI_OP_SEARCH_DATA_E   0x31
67 #define EFI_SCSI_OP_SEARCH_DATA_H   0x30
68 #define EFI_SCSI_OP_SEARCH_DATA_L   0x32
69 #define EFI_SCSI_OP_SEEK6           0x0b
70 #define EFI_SCSI_OP_SEEK10          0x2b
71 #define EFI_SCSI_OP_SEND_DIAG       0x1d
72 #define EFI_SCSI_OP_SET_LIMIT       0x33
73 #define EFI_SCSI_OP_START_STOP_UNIT 0x1b
74 #define EFI_SCSI_OP_SYNC_CACHE      0x35
75 #define EFI_SCSI_OP_VERIFY          0x2f
76 #define EFI_SCSI_OP_WRITE6          0x0a
77 #define EFI_SCSI_OP_WRITE10         0x2a
78 #define EFI_SCSI_OP_WRITE_VERIFY    0x2e
79 #define EFI_SCSI_OP_WRITE_LONG      0x3f
80 #define EFI_SCSI_OP_WRITE_SAME      0x41
81 
82 //
83 // Commands unique to Sequential Access Devices
84 //
85 #define EFI_SCSI_OP_ERASE             0x19
86 #define EFI_SCSI_OP_LOAD_UNLOAD       0x1b
87 #define EFI_SCSI_OP_LOCATE            0x2b
88 #define EFI_SCSI_OP_READ_BLOCK_LIMIT  0x05
89 #define EFI_SCSI_OP_READ_POS          0x34
90 #define EFI_SCSI_OP_READ_REVERSE      0x0f
91 #define EFI_SCSI_OP_RECOVER_BUF_DATA  0x14
92 #define EFI_SCSI_OP_RESERVE_UNIT      0x16
93 #define EFI_SCSI_OP_REWIND            0x01
94 #define EFI_SCSI_OP_SPACE             0x11
95 #define EFI_SCSI_OP_VERIFY_TAPE       0x13
96 #define EFI_SCSI_OP_WRITE_FILEMARK    0x10
97 
98 //
99 // Commands unique to Printer Devices
100 //
101 #define EFI_SCSI_OP_PRINT       0x0a
102 #define EFI_SCSI_OP_SLEW_PRINT  0x0b
103 #define EFI_SCSI_OP_STOP_PRINT  0x1b
104 #define EFI_SCSI_OP_SYNC_BUFF   0x10
105 
106 //
107 // Commands unique to Processor Devices
108 //
109 #define EFI_SCSI_OP_RECEIVE 0x08
110 #define EFI_SCSI_OP_SEND    0x0a
111 
112 //
113 // Commands unique to Write-Once Devices
114 //
115 #define EFI_SCSI_OP_MEDIUM_SCAN     0x38
116 #define EFI_SCSI_OP_SEARCH_DAT_E10  0x31
117 #define EFI_SCSI_OP_SEARCH_DAT_E12  0xb1
118 #define EFI_SCSI_OP_SEARCH_DAT_H10  0x30
119 #define EFI_SCSI_OP_SEARCH_DAT_H12  0xb0
120 #define EFI_SCSI_OP_SEARCH_DAT_L10  0x32
121 #define EFI_SCSI_OP_SEARCH_DAT_L12  0xb2
122 #define EFI_SCSI_OP_SET_LIMIT10     0x33
123 #define EFI_SCSI_OP_SET_LIMIT12     0xb3
124 #define EFI_SCSI_OP_VERIFY10        0x2f
125 #define EFI_SCSI_OP_VERIFY12        0xaf
126 #define EFI_SCSI_OP_WRITE12         0xaa
127 #define EFI_SCSI_OP_WRITE_VERIFY10  0x2e
128 #define EFI_SCSI_OP_WRITE_VERIFY12  0xae
129 
130 //
131 // Commands unique to CD-ROM Devices
132 //
133 #define EFI_SCSI_OP_PLAY_AUD_10       0x45
134 #define EFI_SCSI_OP_PLAY_AUD_12       0xa5
135 #define EFI_SCSI_OP_PLAY_AUD_MSF      0x47
136 #define EFI_SCSI_OP_PLAY_AUD_TKIN     0x48
137 #define EFI_SCSI_OP_PLAY_TK_REL10     0x49
138 #define EFI_SCSI_OP_PLAY_TK_REL12     0xa9
139 #define EFI_SCSI_OP_READ_CD_CAPACITY  0x25
140 #define EFI_SCSI_OP_READ_HEADER       0x44
141 #define EFI_SCSI_OP_READ_SUB_CHANNEL  0x42
142 #define EFI_SCSI_OP_READ_TOC          0x43
143 
144 //
145 // Commands unique to Scanner Devices
146 //
147 #define EFI_SCSI_OP_GET_DATABUFF_STAT 0x34
148 #define EFI_SCSI_OP_GET_WINDOW        0x25
149 #define EFI_SCSI_OP_OBJECT_POS        0x31
150 #define EFI_SCSI_OP_SCAN              0x1b
151 #define EFI_SCSI_OP_SET_WINDOW        0x24
152 
153 //
154 // Commands unique to Optical Memory Devices
155 //
156 #define EFI_SCSI_OP_UPDATE_BLOCK  0x3d
157 
158 //
159 // Commands unique to Medium Changer Devices
160 //
161 #define EFI_SCSI_OP_EXCHANGE_MEDIUM   0xa6
162 #define EFI_SCSI_OP_INIT_ELEMENT_STAT 0x07
163 #define EFI_SCSI_OP_POS_TO_ELEMENT    0x2b
164 #define EFI_SCSI_OP_REQUEST_VE_ADDR   0xb5
165 #define EFI_SCSI_OP_SEND_VOL_TAG      0xb6
166 
167 //
168 // Commands unique to Communition Devices
169 //
170 #define EFI_SCSI_OP_GET_MESSAGE6    0x08
171 #define EFI_SCSI_OP_GET_MESSAGE10   0x28
172 #define EFI_SCSI_OP_GET_MESSAGE12   0xa8
173 #define EFI_SCSI_OP_SEND_MESSAGE6   0x0a
174 #define EFI_SCSI_OP_SEND_MESSAGE10  0x2a
175 #define EFI_SCSI_OP_SEND_MESSAGE12  0xaa
176 
177 //
178 // SCSI Data Transfer Direction
179 //
180 #define EFI_SCSI_DATA_IN  0
181 #define EFI_SCSI_DATA_OUT 1
182 
183 //
184 // Peripheral Device Type Definitions
185 //
186 #define EFI_SCSI_TYPE_DISK          0x00  // Disk device
187 #define EFI_SCSI_TYPE_TAPE          0x01  // Tape device
188 #define EFI_SCSI_TYPE_PRINTER       0x02  // Printer
189 #define EFI_SCSI_TYPE_PROCESSOR     0x03  // Processor
190 #define EFI_SCSI_TYPE_WORM          0x04  // Write-once read-multiple
191 #define EFI_SCSI_TYPE_CDROM         0x05  // CD-ROM device
192 #define EFI_SCSI_TYPE_SCANNER       0x06  // Scanner device
193 #define EFI_SCSI_TYPE_OPTICAL       0x07  // Optical memory device
194 #define EFI_SCSI_TYPE_MEDIUMCHANGER 0x08  // Medium Changer device
195 #define EFI_SCSI_TYPE_COMMUNICATION 0x09  // Communications device
196 #define EFI_SCSI_TYPE_RESERVED_LOW  0x0A  // Reserved (low)
197 #define EFI_SCSI_TYPE_RESERVED_HIGH 0x1E  // Reserved (high)
198 #define EFI_SCSI_TYPE_UNKNOWN       0x1F  // Unknown or no device type
199 #pragma pack(1)
200 //
201 // Data structures for scsi command use
202 //
203 typedef struct {
204   UINT8 Peripheral_Type : 5;
205   UINT8 Peripheral_Qualifier : 3;
206   UINT8 DeviceType_Modifier : 7;
207   UINT8 RMB : 1;
208   UINT8 Version;
209   UINT8 Response_Data_Format;
210   UINT8 Addnl_Length;
211   UINT8 Reserved_5_95[95 - 5 + 1];
212 } EFI_SCSI_INQUIRY_DATA;
213 
214 typedef struct {
215   UINT8 Error_Code : 7;
216   UINT8 Valid : 1;
217   UINT8 Segment_Number;
218   UINT8 Sense_Key : 4;
219   UINT8 Reserved_21 : 1;
220   UINT8 ILI : 1;
221   UINT8 Reserved_22 : 2;
222   UINT8 Information_3_6[4];
223   UINT8 Addnl_Sense_Length;           // n - 7
224   UINT8 Vendor_Specific_8_11[4];
225   UINT8 Addnl_Sense_Code;             // mandatory
226   UINT8 Addnl_Sense_Code_Qualifier;   // mandatory
227   UINT8 Field_Replaceable_Unit_Code;  // optional
228   UINT8 Reserved_15_17[3];
229 } EFI_SCSI_SENSE_DATA;
230 
231 typedef struct {
232   UINT8 LastLba3;
233   UINT8 LastLba2;
234   UINT8 LastLba1;
235   UINT8 LastLba0;
236   UINT8 BlockSize3;
237   UINT8 BlockSize2;
238   UINT8 BlockSize1;
239   UINT8 BlockSize0;
240 } EFI_SCSI_DISK_CAPACITY_DATA;
241 
242 typedef struct {
243   UINT8 LastLba7;
244   UINT8 LastLba6;
245   UINT8 LastLba5;
246   UINT8 LastLba4;
247   UINT8 LastLba3;
248   UINT8 LastLba2;
249   UINT8 LastLba1;
250   UINT8 LastLba0;
251   UINT8 BlockSize3;
252   UINT8 BlockSize2;
253   UINT8 BlockSize1;
254   UINT8 BlockSize0;
255   UINT8 Protection;
256   UINT8 LogicPerPhysical;
257   UINT8 LowestAlignLogic2;
258   UINT8 LowestAlignLogic1;
259   UINT8 Reserved[16];
260 } EFI_SCSI_DISK_CAPACITY_DATA16;
261 
262 
263 #pragma pack()
264 //
265 // Sense Key
266 //
267 #define EFI_SCSI_REQUEST_SENSE_ERROR  (0x70)
268 #define EFI_SCSI_SK_NO_SENSE          (0x0)
269 #define EFI_SCSI_SK_RECOVERY_ERROR    (0x1)
270 #define EFI_SCSI_SK_NOT_READY         (0x2)
271 #define EFI_SCSI_SK_MEDIUM_ERROR      (0x3)
272 #define EFI_SCSI_SK_HARDWARE_ERROR    (0x4)
273 #define EFI_SCSI_SK_ILLEGAL_REQUEST   (0x5)
274 #define EFI_SCSI_SK_UNIT_ATTENTION    (0x6)
275 #define EFI_SCSI_SK_DATA_PROTECT      (0x7)
276 #define EFI_SCSI_SK_BLANK_CHECK       (0x8)
277 #define EFI_SCSI_SK_VENDOR_SPECIFIC   (0x9)
278 #define EFI_SCSI_SK_RESERVED_A        (0xA)
279 #define EFI_SCSI_SK_ABORT             (0xB)
280 #define EFI_SCSI_SK_RESERVED_C        (0xC)
281 #define EFI_SCSI_SK_OVERFLOW          (0xD)
282 #define EFI_SCSI_SK_MISCOMPARE        (0xE)
283 #define EFI_SCSI_SK_RESERVED_F        (0xF)
284 
285 //
286 // Additional Sense Codes
287 //
288 #define EFI_SCSI_ASC_NOT_READY                    (0x04)
289 #define EFI_SCSI_ASC_MEDIA_ERR1                   (0x10)
290 #define EFI_SCSI_ASC_MEDIA_ERR2                   (0x11)
291 #define EFI_SCSI_ASC_MEDIA_ERR3                   (0x14)
292 #define EFI_SCSI_ASC_MEDIA_ERR4                   (0x30)
293 #define EFI_SCSI_ASC_MEDIA_UPSIDE_DOWN            (0x06)
294 #define EFI_SCSI_ASC_INVALID_CMD                  (0x20)
295 #define EFI_SCSI_ASC_LBA_OUT_OF_RANGE             (0x21)
296 #define EFI_SCSI_ASC_INVALID_FIELD                (0x24)
297 #define EFI_SCSI_ASC_WRITE_PROTECTED              (0x27)
298 #define EFI_SCSI_ASC_MEDIA_CHANGE                 (0x28)
299 #define EFI_SCSI_ASC_RESET                        (0x29)  /* Power On Reset or Bus Reset occurred */
300 #define EFI_SCSI_ASC_ILLEGAL_FIELD                (0x26)
301 #define EFI_SCSI_ASC_NO_MEDIA                     (0x3A)
302 #define EFI_SCSI_ASC_ILLEGAL_MODE_FOR_THIS_TRACK  (0x64)
303 
304 //
305 // Additional Sense Code Qualifier
306 //
307 #define EFI_SCSI_ASCQ_IN_PROGRESS (0x01)
308 
309 //
310 // Max bytes needed to represent ID of a SCSI device
311 //
312 #define EFI_SCSI_TARGET_MAX_BYTES (0x10)
313 
314 #endif
315