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