Add the following Pcds declaration in EdkModulePkg.spd file. EdkModulePkg PeiVariable...
[mirror_edk2.git] / EdkModulePkg / Bus / Usb / UsbMassStorage / Dxe / UsbMassStorageData.h
1 /*++
2 Copyright (c) 2006, Intel Corporation
3 All rights reserved. This program and the accompanying materials
4 are licensed and made available under the terms and conditions of the BSD License
5 which accompanies this distribution. The full text of the license may be found at
6 http://opensource.org/licenses/bsd-license.php
7
8 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
9 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
10
11 Module Name:
12
13 UsbMassStorageData.h
14
15 Abstract:
16
17 Header file for USB Mass Storage Device related Data Structures
18
19 Revision History
20 --*/
21
22 #ifndef _USB_FLP_DATA_H
23 #define _USB_FLP_DATA_H
24
25 //
26 // bit definition
27 //
28 #define bit(a) 1 << (a)
29
30 //
31 // timeout unit is in millisecond.
32 //
33 #define USBFLPTIMEOUT 2000
34 #define STALL_1_MILLI_SECOND 1000
35
36 //
37 // ATAPI Packet Command
38 //
39 #pragma pack(1)
40
41 typedef struct {
42 UINT8 opcode;
43 UINT8 reserved_1;
44 UINT8 reserved_2;
45 UINT8 reserved_3;
46 UINT8 reserved_4;
47 UINT8 reserved_5;
48 UINT8 reserved_6;
49 UINT8 reserved_7;
50 UINT8 reserved_8;
51 UINT8 reserved_9;
52 UINT8 reserved_10;
53 UINT8 reserved_11;
54 } TEST_UNIT_READY_CMD;
55
56 typedef struct {
57 UINT8 opcode;
58 UINT8 reserved_1 : 4;
59 UINT8 lun : 4;
60 UINT8 page_code;
61 UINT8 reserved_3;
62 UINT8 allocation_length;
63 UINT8 reserved_5;
64 UINT8 reserved_6;
65 UINT8 reserved_7;
66 UINT8 reserved_8;
67 UINT8 reserved_9;
68 UINT8 reserved_10;
69 UINT8 reserved_11;
70 } INQUIRY_CMD;
71
72 typedef struct {
73 UINT8 opcode;
74 UINT8 reserved_1 : 4;
75 UINT8 lun : 4;
76 UINT8 reserved_2;
77 UINT8 reserved_3;
78 UINT8 allocation_length;
79 UINT8 reserved_5;
80 UINT8 reserved_6;
81 UINT8 reserved_7;
82 UINT8 reserved_8;
83 UINT8 reserved_9;
84 UINT8 reserved_10;
85 UINT8 reserved_11;
86 } REQUEST_SENSE_CMD;
87
88 typedef struct {
89 UINT8 opcode;
90 UINT8 reserved_1 : 4;
91 UINT8 lun : 4;
92 UINT8 page_code : 6;
93 UINT8 page_control : 2;
94 UINT8 reserved_3;
95 UINT8 reserved_4;
96 UINT8 reserved_5;
97 UINT8 reserved_6;
98 UINT8 parameter_list_length_hi;
99 UINT8 parameter_list_length_lo;
100 UINT8 reserved_9;
101 UINT8 reserved_10;
102 UINT8 reserved_11;
103 } MODE_SENSE_CMD_UFI;
104
105 typedef struct {
106 UINT8 opcode;
107 UINT8 reserved_1 : 3;
108 UINT8 dbd : 1;
109 UINT8 reserved_2 : 1;
110 UINT8 lun : 3;
111 UINT8 page_code : 6;
112 UINT8 page_control : 2;
113 UINT8 reserved_3;
114 UINT8 allocation_length;
115 UINT8 control;
116 } MODE_SENSE_CMD_SCSI;
117
118 typedef struct {
119 UINT8 opcode;
120 UINT8 reserved_1 : 5;
121 UINT8 lun : 3;
122 UINT8 Lba0;
123 UINT8 Lba1;
124 UINT8 Lba2;
125 UINT8 Lba3;
126 UINT8 reserved_6;
127 UINT8 TranLen0;
128 UINT8 TranLen1;
129 UINT8 reserved_9;
130 UINT8 reserved_10;
131 UINT8 reserved_11;
132 } READ10_CMD;
133
134 typedef struct {
135 UINT8 opcode;
136 UINT8 reserved_1;
137 UINT8 reserved_2;
138 UINT8 reserved_3;
139 UINT8 reserved_4;
140 UINT8 reserved_5;
141 UINT8 reserved_6;
142 UINT8 allocation_length_hi;
143 UINT8 allocation_length_lo;
144 UINT8 reserved_9;
145 UINT8 reserved_10;
146 UINT8 reserved_11;
147 } READ_FORMAT_CAP_CMD;
148
149 typedef union {
150 UINT16 Data16[6];
151 TEST_UNIT_READY_CMD TestUnitReady;
152 READ10_CMD Read10;
153 REQUEST_SENSE_CMD RequestSense;
154 INQUIRY_CMD Inquiry;
155 MODE_SENSE_CMD_UFI ModeSenseUFI;
156 READ_FORMAT_CAP_CMD ReadFormatCapacity;
157 MODE_SENSE_CMD_SCSI ModeSenseSCSI;
158 } ATAPI_PACKET_COMMAND;
159
160 #pragma pack()
161 //
162 // Packet Command Code
163 //
164 #define TEST_UNIT_READY 0x00
165 #define REZERO 0x01
166 #define REQUEST_SENSE 0x03
167 #define FORMAT_UNIT 0x04
168 #define REASSIGN_BLOCKS 0x07
169 #define INQUIRY 0x12
170 #define START_STOP_UNIT 0x1B
171 #define PREVENT_ALLOW_MEDIA_REMOVAL 0x1E
172 #define READ_FORMAT_CAPACITY 0x23
173 #define OLD_FORMAT_UNIT 0x24
174 #define READ_CAPACITY 0x25
175 #define READ_10 0x28
176 #define WRITE_10 0x2A
177 #define SEEK 0x2B
178 #define SEND_DIAGNOSTICS 0x3D
179 #define WRITE_VERIFY 0x2E
180 #define VERIFY 0x2F
181 #define READ_DEFECT_DATA 0x37
182 #define WRITE_BUFFER 0x38
183 #define READ_BUFFER 0x3C
184 #define READ_LONG 0x3E
185 #define WRITE_LONG 0x3F
186 #define MODE_SELECT 0x55
187 #define UFI_MODE_SENSE5A 0x5A
188 #define SCSI_MODE_SENSE1A 0x1A
189 #define READ_12 0xA8
190 #define WRITE_12 0xAA
191 #define MAX_ATAPI_BYTE_COUNT (0xfffe)
192
193 //
194 // Sense Key
195 //
196 #define REQUEST_SENSE_ERROR (0x70)
197 #define SK_NO_SENSE (0x0)
198 #define SK_RECOVERY_ERROR (0x1)
199 #define SK_NOT_READY (0x2)
200 #define SK_MEDIUM_ERROR (0x3)
201 #define SK_HARDWARE_ERROR (0x4)
202 #define SK_ILLEGAL_REQUEST (0x5)
203 #define SK_UNIT_ATTENTION (0x6)
204 #define SK_DATA_PROTECT (0x7)
205 #define SK_BLANK_CHECK (0x8)
206 #define SK_VENDOR_SPECIFIC (0x9)
207 #define SK_RESERVED_A (0xA)
208 #define SK_ABORT (0xB)
209 #define SK_RESERVED_C (0xC)
210 #define SK_OVERFLOW (0xD)
211 #define SK_MISCOMPARE (0xE)
212 #define SK_RESERVED_F (0xF)
213
214 //
215 // Additional Sense Codes
216 //
217 #define ASC_NOT_READY (0x04)
218 #define ASC_MEDIA_ERR1 (0x10)
219 #define ASC_MEDIA_ERR2 (0x11)
220 #define ASC_MEDIA_ERR3 (0x14)
221 #define ASC_MEDIA_ERR4 (0x30)
222 #define ASC_MEDIA_UPSIDE_DOWN (0x06)
223 #define ASC_INVALID_CMD (0x20)
224 #define ASC_LBA_OUT_OF_RANGE (0x21)
225 #define ASC_INVALID_FIELD (0x24)
226 #define ASC_WRITE_PROTECTED (0x27)
227 #define ASC_MEDIA_CHANGE (0x28)
228 #define ASC_RESET (0x29) /* Power On Reset or Bus Reset occurred */
229 #define ASC_ILLEGAL_FIELD (0x26)
230 #define ASC_NO_MEDIA (0x3A)
231 #define ASC_ILLEGAL_MODE_FOR_THIS_TRACK (0x64)
232 #define ASC_LOGICAL_UNIT_STATUS (0x08)
233
234 //
235 // Additional Sense Code Qualifier
236 //
237 #define ASCQ_IN_PROGRESS (0x01)
238 #define ASCQ_DEVICE_BUSY (0xff)
239 #define ASCQ_LOGICAL_UNIT_FAILURE (0x00)
240 #define ASCQ_LOGICAL_UNIT_TIMEOUT (0x01)
241 #define ASCQ_LOGICAL_UNIT_OVERRUN (0x80)
242
243 #define SETFEATURE TRUE
244 #define CLEARFEATURE FALSE
245
246 //
247 // ATAPI Data structure
248 //
249 #pragma pack(1)
250
251 typedef struct {
252 UINT8 peripheral_type;
253 UINT8 RMB;
254 UINT8 version;
255 UINT8 response_data_format;
256 UINT8 addnl_length;
257 UINT8 reserved_5;
258 UINT8 reserved_6;
259 UINT8 reserved_7;
260 UINT8 vendor_info[8];
261 UINT8 product_id[12];
262 UINT8 eeprom_product_code[4];
263 UINT8 firmware_rev_level[4];
264 } USB_INQUIRY_DATA;
265
266 typedef struct {
267 UINT8 error_code : 7;
268 UINT8 valid : 1;
269 UINT8 reserved_1;
270 UINT8 sense_key : 4;
271 UINT8 reserved_21 : 1;
272 UINT8 ILI : 1;
273 UINT8 reserved_22 : 2;
274 UINT8 vendor_specific_3;
275 UINT8 vendor_specific_4;
276 UINT8 vendor_specific_5;
277 UINT8 vendor_specific_6;
278 UINT8 addnl_sense_length; // n - 7
279 UINT8 vendor_specific_8;
280 UINT8 vendor_specific_9;
281 UINT8 vendor_specific_10;
282 UINT8 vendor_specific_11;
283 UINT8 addnl_sense_code; // mandatory
284 UINT8 addnl_sense_code_qualifier; // mandatory
285 UINT8 field_replaceable_unit_code; // optional
286 UINT8 reserved_15;
287 UINT8 reserved_16;
288 UINT8 reserved_17;
289 //
290 // Followed by additional sense bytes : FIXME
291 //
292 } REQUEST_SENSE_DATA;
293
294 typedef struct {
295 UINT8 LastLba3;
296 UINT8 LastLba2;
297 UINT8 LastLba1;
298 UINT8 LastLba0;
299 UINT8 BlockSize3;
300 UINT8 BlockSize2;
301 UINT8 BlockSize1;
302 UINT8 BlockSize0;
303 } READ_CAPACITY_DATA;
304
305 typedef struct {
306 UINT8 reserved_0;
307 UINT8 reserved_1;
308 UINT8 reserved_2;
309 UINT8 Capacity_Length;
310 UINT8 LastLba3;
311 UINT8 LastLba2;
312 UINT8 LastLba1;
313 UINT8 LastLba0;
314 UINT8 DesCode : 2;
315 UINT8 reserved_9 : 6;
316 UINT8 BlockSize2;
317 UINT8 BlockSize1;
318 UINT8 BlockSize0;
319 } READ_FORMAT_CAPACITY_DATA;
320
321 typedef struct {
322 UINT8 mode_data_len_hi;
323 UINT8 mode_data_len_lo;
324 UINT8 media_type_code;
325 UINT8 reserved_3_0 : 4;
326 UINT8 dpofua : 1;
327 UINT8 reserved_3_1 : 2;
328 UINT8 write_protected : 1;
329 UINT8 reserved_4;
330 UINT8 reserved_5;
331 UINT8 reserved_6;
332 UINT8 reserved_7;
333 } UFI_MODE_PARAMETER_HEADER;
334
335 typedef struct {
336 UINT8 mode_data_len;
337 UINT8 media_type_code;
338 UINT8 speed : 4;
339 UINT8 buffered_mode : 3;
340 UINT8 write_protected : 1;
341 UINT8 block_descritptor_length;
342 } SCSI_MODE_PARAMETER_HEADER6;
343
344 typedef struct {
345 UINT8 page_code : 6;
346 UINT8 reserved_0 : 1;
347 UINT8 parameter_savable : 1;
348 UINT8 page_length;
349 UINT8 transfer_rate_msb;
350 UINT8 transfer_rate_lsb;
351 UINT8 number_of_heads;
352 UINT8 sectors_per_track;
353 UINT8 databytes_per_sector_msb;
354 UINT8 databytes_per_sector_lsb;
355 UINT8 number_of_cylinders_msb;
356 UINT8 number_of_cylinders_lsb;
357 UINT8 reserved_10_18[9];
358 UINT8 motor_on_delay;
359 UINT8 motor_off_delay;
360 UINT8 reserved_21_27[7];
361 UINT8 medium_rotation_rate_msb;
362 UINT8 medium_rotation_rate_lsb;
363 UINT8 reserved_30_31[2];
364 } FLEXIBLE_DISK_PAGE;
365
366 typedef struct {
367 UFI_MODE_PARAMETER_HEADER mode_param_header;
368 FLEXIBLE_DISK_PAGE flex_disk_page;
369 } UFI_MODE_PARAMETER_PAGE_5;
370
371 typedef struct {
372 UINT8 page_code : 6;
373 UINT8 reserved_0 : 1;
374 UINT8 parameter_savable : 1;
375 UINT8 page_length;
376 UINT8 reserved_2;
377 UINT8 inactive_time_multplier : 4;
378 UINT8 reserved_3 : 4;
379 UINT8 software_write_protect : 1;
380 UINT8 disable_media_access : 1;
381 UINT8 reserved_4 : 6;
382 UINT8 reserved_5;
383 UINT8 reserved_6;
384 UINT8 reserved_7;
385 } TIMER_AND_PROTECT_PAGE;
386
387 typedef struct {
388 UFI_MODE_PARAMETER_HEADER mode_param_header;
389 TIMER_AND_PROTECT_PAGE time_and_protect_page;
390 } UFI_MODE_PARAMETER_PAGE_1C;
391
392 #pragma pack()
393
394 #endif