]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/IndustryStandard/Atapi.h
276d364e674442f037bec426c62195dc10e35541
[mirror_edk2.git] / MdePkg / Include / IndustryStandard / Atapi.h
1 /** @file
2 This file contains just some basic definitions that are needed by drivers
3 that dealing with ATA/ATAPI interface.
4
5 Copyright (c) 2007 - 2010, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #ifndef _ATAPI_H_
17 #define _ATAPI_H_
18
19 #pragma pack(1)
20
21 ///
22 /// ATA5_IDENTIFY_DATA is defined in ATA-5
23 /// (This structure is provided here mainly for backward-compatibility support.
24 /// Old drivers may reference some field that is marked "obsolete" in
25 /// ATA_IDENTIFY_DATA, which current conforms to ATA-8)
26 ///
27 typedef struct {
28 UINT16 config; ///< General Configuration
29 UINT16 cylinders; ///< Number of Cylinders
30 UINT16 reserved_2;
31 UINT16 heads; ///< Number of logical heads
32 UINT16 vendor_data1;
33 UINT16 vendor_data2;
34 UINT16 sectors_per_track;
35 UINT16 vendor_specific_7_9[3];
36 CHAR8 SerialNo[20]; ///< ASCII
37 UINT16 vendor_specific_20_21[2];
38 UINT16 ecc_bytes_available;
39 CHAR8 FirmwareVer[8]; ///< ASCII
40 CHAR8 ModelName[40]; ///< ASCII
41 UINT16 multi_sector_cmd_max_sct_cnt;
42 UINT16 reserved_48;
43 UINT16 capabilities;
44 UINT16 reserved_50;
45 UINT16 pio_cycle_timing;
46 UINT16 reserved_52;
47 UINT16 field_validity;
48 UINT16 current_cylinders;
49 UINT16 current_heads;
50 UINT16 current_sectors;
51 UINT16 CurrentCapacityLsb;
52 UINT16 CurrentCapacityMsb;
53 UINT16 reserved_59;
54 UINT16 user_addressable_sectors_lo;
55 UINT16 user_addressable_sectors_hi;
56 UINT16 reserved_62;
57 UINT16 multi_word_dma_mode;
58 UINT16 advanced_pio_modes;
59 UINT16 min_multi_word_dma_cycle_time;
60 UINT16 rec_multi_word_dma_cycle_time;
61 UINT16 min_pio_cycle_time_without_flow_control;
62 UINT16 min_pio_cycle_time_with_flow_control;
63 UINT16 reserved_69_79[11];
64 UINT16 major_version_no;
65 UINT16 minor_version_no;
66 UINT16 command_set_supported_82; ///< word 82
67 UINT16 command_set_supported_83; ///< word 83
68 UINT16 command_set_feature_extn; ///< word 84
69 UINT16 command_set_feature_enb_85; ///< word 85
70 UINT16 command_set_feature_enb_86; ///< word 86
71 UINT16 command_set_feature_default; ///< word 87
72 UINT16 ultra_dma_mode; ///< word 88
73 UINT16 reserved_89_127[39];
74 UINT16 security_status;
75 UINT16 vendor_data_129_159[31];
76 UINT16 reserved_160_255[96];
77 } ATA5_IDENTIFY_DATA;
78
79 ///
80 /// ATA_IDENTIFY_DATA is strictly complied with ATA/ATAPI-8 Spec
81 /// to define the data returned by an ATA device upon successful
82 /// completion of the ATA IDENTIFY_DEVICE command
83 ///
84 typedef struct {
85 UINT16 config; ///< General Configuration
86 UINT16 obsolete_1;
87 UINT16 specific_config; ///< Specific Configuration
88 UINT16 obsolete_3;
89 UINT16 retired_4_5[2];
90 UINT16 obsolete_6;
91 UINT16 cfa_reserved_7_8[2];
92 UINT16 retired_9;
93 CHAR8 SerialNo[20]; ///< word 10~19
94 UINT16 retired_20_21[2];
95 UINT16 obsolete_22;
96 CHAR8 FirmwareVer[8]; ///< word 23~26
97 CHAR8 ModelName[40]; ///< word 27~46
98 UINT16 multi_sector_cmd_max_sct_cnt;
99 UINT16 trusted_computing_support;
100 UINT16 capabilities_49;
101 UINT16 capabilities_50;
102 UINT16 obsolete_51_52[2];
103 UINT16 field_validity;
104 UINT16 obsolete_54_58[5];
105 UINT16 multi_sector_setting;
106 UINT16 user_addressable_sectors_lo;
107 UINT16 user_addressable_sectors_hi;
108 UINT16 obsolete_62;
109 UINT16 multi_word_dma_mode;
110 UINT16 advanced_pio_modes;
111 UINT16 min_multi_word_dma_cycle_time;
112 UINT16 rec_multi_word_dma_cycle_time;
113 UINT16 min_pio_cycle_time_without_flow_control;
114 UINT16 min_pio_cycle_time_with_flow_control;
115 UINT16 reserved_69_74[6];
116 UINT16 queue_depth;
117 UINT16 reserved_76_79[4]; ///< reserved for Serial ATA
118 UINT16 major_version_no;
119 UINT16 minor_version_no;
120 UINT16 command_set_supported_82; ///< word 82
121 UINT16 command_set_supported_83; ///< word 83
122 UINT16 command_set_feature_extn; ///< word 84
123 UINT16 command_set_feature_enb_85; ///< word 85
124 UINT16 command_set_feature_enb_86; ///< word 86
125 UINT16 command_set_feature_default; ///< word 87
126 UINT16 ultra_dma_mode; ///< word 88
127 UINT16 time_for_security_erase_unit;
128 UINT16 time_for_enhanced_security_erase_unit;
129 UINT16 advanced_power_management_level;
130 UINT16 master_password_identifier;
131 UINT16 hardware_configuration_test_result;
132 UINT16 acoustic_management_value;
133 UINT16 stream_minimum_request_size;
134 UINT16 streaming_transfer_time_for_dma;
135 UINT16 streaming_access_latency_for_dma_and_pio;
136 UINT16 streaming_performance_granularity[2]; ///< word 98~99
137 UINT16 maximum_lba_for_48bit_addressing[4]; ///< word 100~103
138 UINT16 streaming_transfer_time_for_pio;
139 UINT16 reserved_105;
140 UINT16 phy_logic_sector_support; ///< word 106
141 UINT16 interseek_delay_for_iso7779;
142 UINT16 world_wide_name[4]; ///< word 108~111
143 UINT16 reserved_for_128bit_wwn_112_115[4];
144 UINT16 reserved_for_technical_report;
145 UINT16 logic_sector_size_lo; ///< word 117
146 UINT16 logic_sector_size_hi; ///< word 118
147 UINT16 features_and_command_sets_supported_ext; ///< word 119
148 UINT16 features_and_command_sets_enabled_ext; ///< word 120
149 UINT16 reserved_121_126[6];
150 UINT16 obsolete_127;
151 UINT16 security_status; ///< word 128
152 UINT16 vendor_specific_129_159[31];
153 UINT16 cfa_power_mode; ///< word 160
154 UINT16 reserved_for_compactflash_161_175[15];
155 CHAR8 media_serial_number[60]; ///< word 176~205
156 UINT16 sct_command_transport; ///< word 206
157 UINT16 reserved_207_208[2];
158 UINT16 alignment_logic_in_phy_blocks; ///< word 209
159 UINT16 write_read_verify_sector_count_mode3[2]; ///< word 210~211
160 UINT16 verify_sector_count_mode2[2];
161 UINT16 nv_cache_capabilities;
162 UINT16 nv_cache_size_in_logical_block_lsw; ///< word 215
163 UINT16 nv_cache_size_in_logical_block_msw; ///< word 216
164 UINT16 nv_cache_read_speed;
165 UINT16 nv_cache_write_speed;
166 UINT16 nv_cache_options; ///< word 219
167 UINT16 write_read_verify_mode; ///< word 220
168 UINT16 reserved_221;
169 UINT16 transport_major_revision_number;
170 UINT16 transport_minor_revision_number;
171 UINT16 reserved_224_233[10];
172 UINT16 min_number_per_download_microcode_mode3; ///< word 234
173 UINT16 max_number_per_download_microcode_mode3; ///< word 235
174 UINT16 reserved_236_254[19];
175 UINT16 integrity_word;
176 } ATA_IDENTIFY_DATA;
177
178 ///
179 /// ATAPI_IDENTIFY_DATA is strictly complied with ATA/ATAPI-8 Spec
180 /// to define the data returned by an ATAPI device upon successful
181 /// completion of the ATA IDENTIFY_PACKET_DEVICE command
182 ///
183 typedef struct {
184 UINT16 config; ///< General Configuration
185 UINT16 reserved_1;
186 UINT16 specific_config; ///< Specific Configuration
187 UINT16 reserved_3_9[7];
188 CHAR8 SerialNo[20]; ///< word 10~19
189 UINT16 reserved_20_22[3];
190 CHAR8 FirmwareVer[8]; ///< word 23~26
191 CHAR8 ModelName[40]; ///< word 27~46
192 UINT16 reserved_47_48[2];
193 UINT16 capabilities_49;
194 UINT16 capabilities_50;
195 UINT16 obsolete_51;
196 UINT16 reserved_52;
197 UINT16 field_validity; ///< word 53
198 UINT16 reserved_54_61[8];
199 UINT16 dma_dir;
200 UINT16 multi_word_dma_mode; ///< word 63
201 UINT16 advanced_pio_modes; ///< word 64
202 UINT16 min_multi_word_dma_cycle_time;
203 UINT16 rec_multi_word_dma_cycle_time;
204 UINT16 min_pio_cycle_time_without_flow_control;
205 UINT16 min_pio_cycle_time_with_flow_control;
206 UINT16 reserved_69_70[2];
207 UINT16 obsolete_71_72[2];
208 UINT16 reserved_73_74[2];
209 UINT16 queue_depth;
210 UINT16 reserved_76_79[4];
211 UINT16 major_version_no; ///< word 80
212 UINT16 minor_version_no; ///< word 81
213 UINT16 cmd_set_support_82;
214 UINT16 cmd_set_support_83;
215 UINT16 cmd_feature_support;
216 UINT16 cmd_feature_enable_85;
217 UINT16 cmd_feature_enable_86;
218 UINT16 cmd_feature_default;
219 UINT16 ultra_dma_select;
220 UINT16 time_required_for_sec_erase; ///< word 89
221 UINT16 time_required_for_enhanced_sec_erase; ///< word 90
222 UINT16 reserved_91;
223 UINT16 master_pwd_revison_code;
224 UINT16 hardware_reset_result; ///< word 93
225 UINT16 current_auto_acoustic_mgmt_value;
226 UINT16 reserved_95_107[13];
227 UINT16 world_wide_name[4]; ///< word 108~111
228 UINT16 reserved_for_128bit_wwn_112_115[4];
229 UINT16 reserved_116_124[9];
230 UINT16 atapi_byte_count_0_behavior; ///< word 125
231 UINT16 obsolete_126;
232 UINT16 removable_media_status_notification_support;
233 UINT16 security_status;
234 UINT16 reserved_129_160[32];
235 UINT16 cfa_reserved_161_175[15];
236 UINT16 reserved_176_254[79];
237 UINT16 integrity_word;
238 } ATAPI_IDENTIFY_DATA;
239
240
241 ///
242 /// Standard Quiry Data format, defined in SFF-8070i(ATAPI Removable Rewritable Specification)
243 ///
244 typedef struct {
245 UINT8 peripheral_type;
246 UINT8 RMB;
247 UINT8 version;
248 UINT8 response_data_format;
249 UINT8 addnl_length; ///< n - 4, Numbers of bytes following this one
250 UINT8 reserved_5;
251 UINT8 reserved_6;
252 UINT8 reserved_7;
253 UINT8 vendor_info[8];
254 UINT8 product_id[16];
255 UINT8 product_revision_level[4];
256 UINT8 vendor_specific_36_55[55 - 36 + 1];
257 UINT8 reserved_56_95[95 - 56 + 1];
258 ///
259 /// Vendor specific parameters fields, the sizeof (ATAPI_INQUIRY_DATA) is 254
260 /// since allocation_length is one byte in ATAPI_INQUIRY_CMD.
261 ///
262 UINT8 vendor_specific_96_253[253 - 96 + 1];
263 } ATAPI_INQUIRY_DATA;
264
265 ///
266 /// Request Sense Standard Data, defined in SFF-8070i(ATAPI Removable Rewritable Specification)
267 ///
268 typedef struct {
269 UINT8 error_code : 7;
270 UINT8 valid : 1;
271 UINT8 reserved_1;
272 UINT8 sense_key : 4;
273 UINT8 reserved_2 : 1;
274 UINT8 Vendor_specifc_1 : 3;
275 UINT8 vendor_specific_3;
276 UINT8 vendor_specific_4;
277 UINT8 vendor_specific_5;
278 UINT8 vendor_specific_6;
279 UINT8 addnl_sense_length; ///< n - 7
280 UINT8 vendor_specific_8;
281 UINT8 vendor_specific_9;
282 UINT8 vendor_specific_10;
283 UINT8 vendor_specific_11;
284 UINT8 addnl_sense_code; ///< mandatory
285 UINT8 addnl_sense_code_qualifier; ///< mandatory
286 UINT8 field_replaceable_unit_code; ///< optional
287 UINT8 sense_key_specific_15 : 7;
288 UINT8 SKSV : 1;
289 UINT8 sense_key_specific_16;
290 UINT8 sense_key_specific_17;
291 } ATAPI_REQUEST_SENSE_DATA;
292
293 ///
294 /// READ CAPACITY Data, defined in SFF-8070i(ATAPI Removable Rewritable Specification)
295 ///
296 typedef struct {
297 UINT8 LastLba3;
298 UINT8 LastLba2;
299 UINT8 LastLba1;
300 UINT8 LastLba0;
301 UINT8 BlockSize3;
302 UINT8 BlockSize2;
303 UINT8 BlockSize1;
304 UINT8 BlockSize0;
305 } ATAPI_READ_CAPACITY_DATA;
306
307 ///
308 /// Capacity List Header + Current/Maximum Capacity Descriptor,
309 /// defined in SFF-8070i(ATAPI Removable Rewritable Specification)
310 ///
311 typedef struct {
312 UINT8 reserved_0;
313 UINT8 reserved_1;
314 UINT8 reserved_2;
315 UINT8 Capacity_Length;
316 UINT8 LastLba3;
317 UINT8 LastLba2;
318 UINT8 LastLba1;
319 UINT8 LastLba0;
320 UINT8 DesCode : 2;
321 UINT8 reserved_9 : 6;
322 UINT8 BlockSize2;
323 UINT8 BlockSize1;
324 UINT8 BlockSize0;
325 } ATAPI_READ_FORMAT_CAPACITY_DATA;
326
327 ///
328 /// Test Unit Ready Command, defined in SFF-8070i(ATAPI Removable Rewritable Specification)
329 ///
330 typedef struct {
331 UINT8 opcode;
332 UINT8 reserved_1;
333 UINT8 reserved_2;
334 UINT8 reserved_3;
335 UINT8 reserved_4;
336 UINT8 reserved_5;
337 UINT8 reserved_6;
338 UINT8 reserved_7;
339 UINT8 reserved_8;
340 UINT8 reserved_9;
341 UINT8 reserved_10;
342 UINT8 reserved_11;
343 } ATAPI_TEST_UNIT_READY_CMD;
344
345 ///
346 /// INQUIRY Command, defined in SFF-8070i(ATAPI Removable Rewritable Specification)
347 ///
348 typedef struct {
349 UINT8 opcode;
350 UINT8 reserved_1 : 5;
351 UINT8 lun : 3;
352 UINT8 page_code; ///< defined in SFF8090i, V6
353 UINT8 reserved_3;
354 UINT8 allocation_length;
355 UINT8 reserved_5;
356 UINT8 reserved_6;
357 UINT8 reserved_7;
358 UINT8 reserved_8;
359 UINT8 reserved_9;
360 UINT8 reserved_10;
361 UINT8 reserved_11;
362 } ATAPI_INQUIRY_CMD;
363
364 ///
365 /// REQUEST SENSE Command, defined in SFF-8070i(ATAPI Removable Rewritable Specification)
366 ///
367 typedef struct {
368 UINT8 opcode;
369 UINT8 reserved_1 : 5;
370 UINT8 lun : 3;
371 UINT8 reserved_2;
372 UINT8 reserved_3;
373 UINT8 allocation_length;
374 UINT8 reserved_5;
375 UINT8 reserved_6;
376 UINT8 reserved_7;
377 UINT8 reserved_8;
378 UINT8 reserved_9;
379 UINT8 reserved_10;
380 UINT8 reserved_11;
381 } ATAPI_REQUEST_SENSE_CMD;
382
383 ///
384 /// READ (10) Command, defined in SFF-8070i(ATAPI Removable Rewritable Specification)
385 ///
386 typedef struct {
387 UINT8 opcode;
388 UINT8 reserved_1 : 5;
389 UINT8 lun : 3;
390 UINT8 Lba0;
391 UINT8 Lba1;
392 UINT8 Lba2;
393 UINT8 Lba3;
394 UINT8 reserved_6;
395 UINT8 TranLen0;
396 UINT8 TranLen1;
397 UINT8 reserved_9;
398 UINT8 reserved_10;
399 UINT8 reserved_11;
400 } ATAPI_READ10_CMD;
401
402 ///
403 /// READ Format Capacity Command, defined in SFF-8070i(ATAPI Removable Rewritable Specification)
404 ///
405 typedef struct {
406 UINT8 opcode;
407 UINT8 reserved_1 : 5;
408 UINT8 lun : 3;
409 UINT8 reserved_2;
410 UINT8 reserved_3;
411 UINT8 reserved_4;
412 UINT8 reserved_5;
413 UINT8 reserved_6;
414 UINT8 allocation_length_hi;
415 UINT8 allocation_length_lo;
416 UINT8 reserved_9;
417 UINT8 reserved_10;
418 UINT8 reserved_11;
419 } ATAPI_READ_FORMAT_CAP_CMD;
420
421 ///
422 /// MODE SENSE Command, defined in SFF-8070i(ATAPI Removable Rewritable Specification)
423 ///
424 typedef struct {
425 UINT8 opcode;
426 UINT8 reserved_1 : 5;
427 UINT8 lun : 3;
428 UINT8 page_code : 6;
429 UINT8 page_control : 2;
430 UINT8 reserved_3;
431 UINT8 reserved_4;
432 UINT8 reserved_5;
433 UINT8 reserved_6;
434 UINT8 parameter_list_length_hi;
435 UINT8 parameter_list_length_lo;
436 UINT8 reserved_9;
437 UINT8 reserved_10;
438 UINT8 reserved_11;
439 } ATAPI_MODE_SENSE_CMD;
440
441 ///
442 /// ATAPI_PACKET_COMMAND is not defined in ATA specification.
443 /// We add it here for the convenience for ATA/ATAPI module writer.
444 ///
445 typedef union {
446 UINT16 Data16[6];
447 ATAPI_TEST_UNIT_READY_CMD TestUnitReady;
448 ATAPI_READ10_CMD Read10;
449 ATAPI_REQUEST_SENSE_CMD RequestSence;
450 ATAPI_INQUIRY_CMD Inquiry;
451 ATAPI_MODE_SENSE_CMD ModeSense;
452 ATAPI_READ_FORMAT_CAP_CMD ReadFormatCapacity;
453 } ATAPI_PACKET_COMMAND;
454
455 #pragma pack()
456
457
458 #define ATAPI_MAX_DMA_EXT_CMD_SECTORS 0x10000
459 #define ATAPI_MAX_DMA_CMD_SECTORS 0x100
460
461 //
462 // ATA Packet Command Code
463 //
464 #define ATA_CMD_SOFT_RESET 0x08 ///< defined from ATA-3
465 #define ATA_CMD_PACKET 0xA0 ///< defined from ATA-3
466 #define ATA_CMD_IDENTIFY_DEVICE 0xA1 ///< defined from ATA-3
467 #define ATA_CMD_SERVICE 0xA2 ///< defined from ATA-3
468 #define ATA_CMD_TEST_UNIT_READY 0x00 ///< defined from ATA-1
469 #define ATA_CMD_REQUEST_SENSE 0x03 ///< defined from ATA-4
470 #define ATA_CMD_INQUIRY 0x12 ///< defined in ATAPI Removable Rewritable Media Devcies
471 #define ATA_CMD_READ_FORMAT_CAPACITY 0x23 ///< defined in ATAPI Removable Rewritable Media Devcies
472 #define ATA_CMD_READ_CAPACITY 0x25 ///< defined in ATAPI Removable Rewritable Media Devcies
473 #define ATA_CMD_READ_10 0x28 ///< defined in ATAPI Removable Rewritable Media Devcies
474 #define ATA_CMD_WRITE_10 0x2A ///< defined in ATAPI Removable Rewritable Media Devcies
475
476 //
477 // ATA Commands Code
478 //
479
480 //
481 // Class 1: PIO Data-In Commands
482 //
483 #define ATA_CMD_IDENTIFY_DRIVE 0xec ///< defined from ATA-3
484 #define ATA_CMD_READ_BUFFER 0xe4 ///< defined from ATA-1
485 #define ATA_CMD_READ_SECTORS 0x20 ///< defined from ATA-1
486 #define ATA_CMD_READ_SECTORS_WITH_RETRY 0x21 ///< defined from ATA-1, obsoleted from ATA-5
487 #define ATA_CMD_READ_LONG 0x22 ///< defined from ATA-1, obsoleted from ATA-5
488 #define ATA_CMD_READ_LONG_WITH_RETRY 0x23 ///< defined from ATA-1, obsoleted from ATA-5
489 #define ATA_CMD_READ_SECTORS_EXT 0x24 ///< defined from ATA-6
490
491 //
492 // Class 2: PIO Data-Out Commands
493 //
494 #define ATA_CMD_FORMAT_TRACK 0x50 ///< defined from ATA-1, obsoleted from ATA-4
495 #define ATA_CMD_WRITE_BUFFER 0xe8 ///< defined from ATA-1
496 #define ATA_CMD_WRITE_SECTORS 0x30 ///< defined from ATA-1
497 #define ATA_CMD_WRITE_SECTORS_WITH_RETRY 0x31 ///< defined from ATA-1, obsoleted from ATA-5
498 #define ATA_CMD_WRITE_LONG 0x32 ///< defined from ATA-1, obsoleted from ATA-5
499 #define ATA_CMD_WRITE_LONG_WITH_RETRY 0x33 ///< defined from ATA-1, obsoleted from ATA-5
500 #define ATA_CMD_WRITE_VERIFY 0x3c ///< defined from ATA-1, obsoleted from ATA-5
501 #define ATA_CMD_WRITE_SECTORS_EXT 0x34 ///< defined from ATA-6
502
503 //
504 // Class 3 No Data Command
505 //
506 #define ATA_CMD_ACK_MEDIA_CHANGE 0xdb ///< defined from ATA-1, obsoleted from ATA-5
507 #define ATA_CMD_BOOT_POST_BOOT 0xdc ///< defined from ATA-1, obsoleted from ATA-3
508 #define ATA_CMD_BOOT_PRE_BOOT 0xdd ///< defined from ATA-1, obsoleted from ATA-3
509 #define ATA_CMD_CHECK_POWER_MODE 0x98 ///< defined from ATA-1, obsoleted from ATA-4
510 #define ATA_CMD_CHECK_POWER_MODE_ALIAS 0xe5 ///< defined from ATA-1
511 #define ATA_CMD_DOOR_LOCK 0xde ///< defined from ATA-1
512 #define ATA_CMD_DOOR_UNLOCK 0xdf ///< defined from ATA-1
513 #define ATA_CMD_EXEC_DRIVE_DIAG 0x90 ///< defined from ATA-1
514 #define ATA_CMD_IDLE_ALIAS 0x97 ///< defined from ATA-1, obsoleted from ATA-4
515 #define ATA_CMD_IDLE 0xe3 ///< defined from ATA-1
516 #define ATA_CMD_IDLE_IMMEDIATE 0x95 ///< defined from ATA-1, obsoleted from ATA-4
517 #define ATA_CMD_IDLE_IMMEDIATE_ALIAS 0xe1 ///< defined from ATA-1
518 #define ATA_CMD_INIT_DRIVE_PARAM 0x91 ///< defined from ATA-1, obsoleted from ATA-6
519 #define ATA_CMD_RECALIBRATE 0x10 ///< defined from ATA-1, obsoleted from ATA-4
520 #define ATA_CMD_READ_DRIVE_STATE 0xe9 ///< defined from ATA-1, obsoleted from ATA-3
521 #define ATA_CMD_SET_MULTIPLE_MODE 0xC6 ///< defined from ATA-2
522 #define ATA_CMD_READ_VERIFY 0x40 ///< defined from ATA-1
523 #define ATA_CMD_READ_VERIFY_WITH_RETRY 0x41 ///< defined from ATA-1, obsoleted from ATA-5
524 #define ATA_CMD_SEEK 0x70 ///< defined from ATA-1
525 #define ATA_CMD_SET_FEATURES 0xef ///< defined from ATA-1
526 #define ATA_CMD_STANDBY 0x96 ///< defined from ATA-1, obsoleted from ATA-4
527 #define ATA_CMD_STANDBY_ALIAS 0xe2 ///< defined from ATA-1
528 #define ATA_CMD_STANDBY_IMMEDIATE 0x94 ///< defined from ATA-1, obsoleted from ATA-4
529 #define ATA_CMD_STANDBY_IMMEDIATE_ALIAS 0xe0 ///< defined from ATA-1
530 //
531 // S.M.A.R.T
532 //
533 #define ATA_CMD_SMART 0xb0 ///< defined from ATA-3
534 #define ATA_CONSTANT_C2 0xc2 ///< reserved
535 #define ATA_CONSTANT_4F 0x4f ///< reserved
536 #define ATA_SMART_ENABLE_OPERATION 0xd8 ///< reserved
537 #define ATA_SMART_RETURN_STATUS 0xda ///< defined from ATA-3
538
539 //
540 // Class 4: DMA Command
541 //
542 #define ATA_CMD_READ_DMA 0xc8 ///< defined from ATA-1
543 #define ATA_CMD_READ_DMA_WITH_RETRY 0xc9 ///< defined from ATA-1, obsoleted from ATA-5
544 #define ATA_CMD_READ_DMA_EXT 0x25 ///< defined from ATA-6
545 #define ATA_CMD_WRITE_DMA 0xca ///< defined from ATA-1
546 #define ATA_CMD_WRITE_DMA_WITH_RETRY 0xcb ///< defined from ATA-1, obsoleted from ATA-
547 #define ATA_CMD_WRITE_DMA_EXT 0x35 ///< defined from ATA-6
548
549 ///
550 /// default content of device control register, disable INT,
551 /// Bit3 is set to 1 according ATA-1
552 ///
553 #define ATA_DEFAULT_CTL (0x0a)
554 ///
555 /// default context of Device/Head Register,
556 /// Bit7 and Bit5 are set to 1 for back-compatibilities
557 ///
558 #define ATA_DEFAULT_CMD (0xa0)
559
560 #define ATAPI_MAX_BYTE_COUNT (0xfffe)
561
562 #define ATA_REQUEST_SENSE_ERROR (0x70) ///< defined in SFF-8070i
563
564 //
565 // Sense Key, Additional Sense Codes and Additional Sense Code Qualifier
566 // defined in MultiMedia Commands (MMC, MMC-2)
567 //
568 // Sense Key
569 //
570 #define ATA_SK_NO_SENSE (0x0)
571 #define ATA_SK_RECOVERY_ERROR (0x1)
572 #define ATA_SK_NOT_READY (0x2)
573 #define ATA_SK_MEDIUM_ERROR (0x3)
574 #define ATA_SK_HARDWARE_ERROR (0x4)
575 #define ATA_SK_ILLEGAL_REQUEST (0x5)
576 #define ATA_SK_UNIT_ATTENTION (0x6)
577 #define ATA_SK_DATA_PROTECT (0x7)
578 #define ATA_SK_BLANK_CHECK (0x8)
579 #define ATA_SK_VENDOR_SPECIFIC (0x9)
580 #define ATA_SK_RESERVED_A (0xA)
581 #define ATA_SK_ABORT (0xB)
582 #define ATA_SK_RESERVED_C (0xC)
583 #define ATA_SK_OVERFLOW (0xD)
584 #define ATA_SK_MISCOMPARE (0xE)
585 #define ATA_SK_RESERVED_F (0xF)
586
587 //
588 // Additional Sense Codes
589 //
590 #define ATA_ASC_NOT_READY (0x04)
591 #define ATA_ASC_MEDIA_ERR1 (0x10)
592 #define ATA_ASC_MEDIA_ERR2 (0x11)
593 #define ATA_ASC_MEDIA_ERR3 (0x14)
594 #define ATA_ASC_MEDIA_ERR4 (0x30)
595 #define ATA_ASC_MEDIA_UPSIDE_DOWN (0x06)
596 #define ATA_ASC_INVALID_CMD (0x20)
597 #define ATA_ASC_LBA_OUT_OF_RANGE (0x21)
598 #define ATA_ASC_INVALID_FIELD (0x24)
599 #define ATA_ASC_WRITE_PROTECTED (0x27)
600 #define ATA_ASC_MEDIA_CHANGE (0x28)
601 #define ATA_ASC_RESET (0x29) ///< Power On Reset or Bus Reset occurred
602 #define ATA_ASC_ILLEGAL_FIELD (0x26)
603 #define ATA_ASC_NO_MEDIA (0x3A)
604 #define ATA_ASC_ILLEGAL_MODE_FOR_THIS_TRACK (0x64)
605
606 //
607 // Additional Sense Code Qualifier
608 //
609 #define ATA_ASCQ_IN_PROGRESS (0x01)
610
611 //
612 // Error Register
613 //
614 #define ATA_ERRREG_BBK BIT7 ///< Bad block detected defined from ATA-1, obsoleted from ATA-2
615 #define ATA_ERRREG_UNC BIT6 ///< Uncorrectable Data defined from ATA-1, obsoleted from ATA-4
616 #define ATA_ERRREG_MC BIT5 ///< Media Change defined from ATA-1, obsoleted from ATA-4
617 #define ATA_ERRREG_IDNF BIT4 ///< ID Not Found defined from ATA-1, obsoleted from ATA-4
618 #define ATA_ERRREG_MCR BIT3 ///< Media Change Requested defined from ATA-1, obsoleted from ATA-4
619 #define ATA_ERRREG_ABRT BIT2 ///< Aborted Command defined from ATA-1
620 #define ATA_ERRREG_TK0NF BIT1 ///< Track 0 Not Found defined from ATA-1, obsoleted from ATA-4
621 #define ATA_ERRREG_AMNF BIT0 ///< Address Mark Not Found defined from ATA-1, obsoleted from ATA-4
622
623 //
624 // Status Register
625 //
626 #define ATA_STSREG_BSY BIT7 ///< Controller Busy defined from ATA-1
627 #define ATA_STSREG_DRDY BIT6 ///< Drive Ready defined from ATA-1
628 #define ATA_STSREG_DWF BIT5 ///< Drive Write Fault defined from ATA-1, obsoleted from ATA-4
629 #define ATA_STSREG_DF BIT5 ///< Drive Fault defined from ATA-6
630 #define ATA_STSREG_DSC BIT4 ///< Disk Seek Complete defined from ATA-1, obsoleted from ATA-4
631 #define ATA_STSREG_DRQ BIT3 ///< Data Request defined from ATA-1
632 #define ATA_STSREG_CORR BIT2 ///< Corrected Data defined from ATA-1, obsoleted from ATA-4
633 #define ATA_STSREG_IDX BIT1 ///< Index defined from ATA-1, obsoleted from ATA-4
634 #define ATA_STSREG_ERR BIT0 ///< Error defined from ATA-1
635
636 //
637 // Device Control Register
638 //
639 #define ATA_CTLREG_SRST BIT2 ///< Software Reset
640 #define ATA_CTLREG_IEN_L BIT1 ///< Interrupt Enable #
641
642 #endif
643