Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 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 - 2016, Intel Corporation. All rights reserved.<BR> |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 6 | This program and the accompanying materials are licensed and made available under |
| 7 | the terms and conditions of the BSD License that accompanies this distribution. |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 8 | The full text of the license may be found at |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 9 | http://opensource.org/licenses/bsd-license.php. |
| 10 | |
| 11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 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 mainly for backward-compatibility support. |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 24 | /// Old drivers may reference fields that are marked "obsolete" in |
| 25 | /// ATA_IDENTIFY_DATA, which currently conforms to ATA-8.) |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 26 | /// |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 27 | typedef struct { |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 28 | UINT16 config; ///< General Configuration. |
| 29 | UINT16 cylinders; ///< Number of Cylinders. |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 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]; |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 77 | } ATA5_IDENTIFY_DATA; |
| 78 | |
| 79 | /// |
| 80 | /// ATA_IDENTIFY_DATA strictly complies 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; |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 89 | UINT16 retired_4_5[2]; |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 90 | UINT16 obsolete_6; |
| 91 | UINT16 cfa_reserved_7_8[2]; |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 92 | UINT16 retired_9; |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 93 | CHAR8 SerialNo[20]; ///< word 10~19 |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 94 | UINT16 retired_20_21[2]; |
| 95 | UINT16 obsolete_22; |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 96 | CHAR8 FirmwareVer[8]; ///< word 23~26 |
| 97 | CHAR8 ModelName[40]; ///< word 27~46 |
| 98 | UINT16 multi_sector_cmd_max_sct_cnt; |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 99 | UINT16 trusted_computing_support; |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 100 | UINT16 capabilities_49; |
| 101 | UINT16 capabilities_50; |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 102 | UINT16 obsolete_51_52[2]; |
| 103 | UINT16 field_validity; |
| 104 | UINT16 obsolete_54_58[5]; |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 105 | UINT16 multi_sector_setting; |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 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; |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 115 | UINT16 additional_supported; ///< word 69 |
| 116 | UINT16 reserved_70; |
| 117 | UINT16 reserved_71_74[4]; ///< Reserved for IDENTIFY PACKET DEVICE cmd. |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 118 | UINT16 queue_depth; |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 119 | UINT16 serial_ata_capabilities; |
| 120 | UINT16 reserved_77; ///< Reserved for Serial ATA |
| 121 | UINT16 serial_ata_features_supported; |
| 122 | UINT16 serial_ata_features_enabled; |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 123 | UINT16 major_version_no; |
| 124 | UINT16 minor_version_no; |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 125 | UINT16 command_set_supported_82; ///< word 82 |
| 126 | UINT16 command_set_supported_83; ///< word 83 |
| 127 | UINT16 command_set_feature_extn; ///< word 84 |
| 128 | UINT16 command_set_feature_enb_85; ///< word 85 |
| 129 | UINT16 command_set_feature_enb_86; ///< word 86 |
| 130 | UINT16 command_set_feature_default; ///< word 87 |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 131 | UINT16 ultra_dma_mode; ///< word 88 |
| 132 | UINT16 time_for_security_erase_unit; |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 133 | UINT16 time_for_enhanced_security_erase_unit; |
| 134 | UINT16 advanced_power_management_level; |
| 135 | UINT16 master_password_identifier; |
| 136 | UINT16 hardware_configuration_test_result; |
| 137 | UINT16 obsolete_94; |
| 138 | UINT16 stream_minimum_request_size; |
| 139 | UINT16 streaming_transfer_time_for_dma; |
| 140 | UINT16 streaming_access_latency_for_dma_and_pio; |
| 141 | UINT16 streaming_performance_granularity[2]; ///< word 98~99 |
| 142 | UINT16 maximum_lba_for_48bit_addressing[4]; ///< word 100~103 |
| 143 | UINT16 streaming_transfer_time_for_pio; |
| 144 | UINT16 max_no_of_512byte_blocks_per_data_set_cmd; |
| 145 | UINT16 phy_logic_sector_support; ///< word 106 |
| 146 | UINT16 interseek_delay_for_iso7779; |
| 147 | UINT16 world_wide_name[4]; ///< word 108~111 |
| 148 | UINT16 reserved_for_128bit_wwn_112_115[4]; |
| 149 | UINT16 reserved_for_technical_report; |
| 150 | UINT16 logic_sector_size_lo; ///< word 117 |
| 151 | UINT16 logic_sector_size_hi; ///< word 118 |
| 152 | UINT16 features_and_command_sets_supported_ext; ///< word 119 |
| 153 | UINT16 features_and_command_sets_enabled_ext; ///< word 120 |
| 154 | UINT16 reserved_121_126[6]; |
| 155 | UINT16 obsolete_127; |
| 156 | UINT16 security_status; ///< word 128 |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 157 | UINT16 vendor_specific_129_159[31]; |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 158 | UINT16 cfa_power_mode; ///< word 160 |
| 159 | UINT16 reserved_for_compactflash_161_167[7]; |
| 160 | UINT16 device_nominal_form_factor; |
| 161 | UINT16 is_data_set_cmd_supported; |
| 162 | CHAR8 additional_product_identifier[8]; |
| 163 | UINT16 reserved_174_175[2]; |
| 164 | CHAR8 media_serial_number[60]; ///< word 176~205 |
| 165 | UINT16 sct_command_transport; ///< word 206 |
| 166 | UINT16 reserved_207_208[2]; |
| 167 | UINT16 alignment_logic_in_phy_blocks; ///< word 209 |
| 168 | UINT16 write_read_verify_sector_count_mode3[2]; ///< word 210~211 |
| 169 | UINT16 verify_sector_count_mode2[2]; |
| 170 | UINT16 nv_cache_capabilities; |
| 171 | UINT16 nv_cache_size_in_logical_block_lsw; ///< word 215 |
| 172 | UINT16 nv_cache_size_in_logical_block_msw; ///< word 216 |
| 173 | UINT16 nominal_media_rotation_rate; |
| 174 | UINT16 reserved_218; |
| 175 | UINT16 nv_cache_options; ///< word 219 |
| 176 | UINT16 write_read_verify_mode; ///< word 220 |
| 177 | UINT16 reserved_221; |
| 178 | UINT16 transport_major_revision_number; |
| 179 | UINT16 transport_minor_revision_number; |
| 180 | UINT16 reserved_224_229[6]; |
| 181 | UINT64 extended_no_of_addressable_sectors; |
| 182 | UINT16 min_number_per_download_microcode_mode3; ///< word 234 |
| 183 | UINT16 max_number_per_download_microcode_mode3; ///< word 235 |
| 184 | UINT16 reserved_236_254[19]; |
| 185 | UINT16 integrity_word; |
| 186 | } ATA_IDENTIFY_DATA; |
| 187 | |
| 188 | /// |
| 189 | /// ATAPI_IDENTIFY_DATA strictly complies with ATA/ATAPI-8 Spec |
| 190 | /// to define the data returned by an ATAPI device upon successful |
| 191 | /// completion of the ATA IDENTIFY_PACKET_DEVICE command. |
| 192 | /// |
| 193 | typedef struct { |
| 194 | UINT16 config; ///< General Configuration. |
| 195 | UINT16 reserved_1; |
| 196 | UINT16 specific_config; ///< Specific Configuration. |
| 197 | UINT16 reserved_3_9[7]; |
| 198 | CHAR8 SerialNo[20]; ///< word 10~19 |
| 199 | UINT16 reserved_20_22[3]; |
| 200 | CHAR8 FirmwareVer[8]; ///< word 23~26 |
| 201 | CHAR8 ModelName[40]; ///< word 27~46 |
| 202 | UINT16 reserved_47_48[2]; |
| 203 | UINT16 capabilities_49; |
| 204 | UINT16 capabilities_50; |
| 205 | UINT16 obsolete_51; |
| 206 | UINT16 reserved_52; |
| 207 | UINT16 field_validity; ///< word 53 |
| 208 | UINT16 reserved_54_61[8]; |
| 209 | UINT16 dma_dir; |
| 210 | UINT16 multi_word_dma_mode; ///< word 63 |
| 211 | UINT16 advanced_pio_modes; ///< word 64 |
| 212 | UINT16 min_multi_word_dma_cycle_time; |
| 213 | UINT16 rec_multi_word_dma_cycle_time; |
| 214 | UINT16 min_pio_cycle_time_without_flow_control; |
| 215 | UINT16 min_pio_cycle_time_with_flow_control; |
| 216 | UINT16 reserved_69_70[2]; |
| 217 | UINT16 obsolete_71_72[2]; |
| 218 | UINT16 reserved_73_74[2]; |
| 219 | UINT16 obsolete_75; |
| 220 | UINT16 serial_ata_capabilities; |
| 221 | UINT16 reserved_77; ///< Reserved for Serial ATA |
| 222 | UINT16 serial_ata_features_supported; |
| 223 | UINT16 serial_ata_features_enabled; |
| 224 | UINT16 major_version_no; ///< word 80 |
| 225 | UINT16 minor_version_no; ///< word 81 |
| 226 | UINT16 cmd_set_support_82; |
| 227 | UINT16 cmd_set_support_83; |
| 228 | UINT16 cmd_feature_support; |
| 229 | UINT16 cmd_feature_enable_85; |
| 230 | UINT16 cmd_feature_enable_86; |
| 231 | UINT16 cmd_feature_default; |
| 232 | UINT16 ultra_dma_select; |
| 233 | UINT16 time_required_for_sec_erase; ///< word 89 |
| 234 | UINT16 time_required_for_enhanced_sec_erase; ///< word 90 |
| 235 | UINT16 advanced_power_management_level; |
| 236 | UINT16 master_pwd_revison_code; |
| 237 | UINT16 hardware_reset_result; ///< word 93 |
| 238 | UINT16 obsolete_94; |
| 239 | UINT16 reserved_95_107[13]; |
| 240 | UINT16 world_wide_name[4]; ///< word 108~111 |
| 241 | UINT16 reserved_for_128bit_wwn_112_115[4]; |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 242 | UINT16 reserved_116_118[3]; |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 243 | UINT16 command_and_feature_sets_supported; ///< word 119 |
| 244 | UINT16 command_and_feature_sets_supported_enabled; |
| 245 | UINT16 reserved_121_124[4]; |
| 246 | UINT16 atapi_byte_count_0_behavior; ///< word 125 |
| 247 | UINT16 obsolete_126_127[2]; |
| 248 | UINT16 security_status; |
| 249 | UINT16 reserved_129_159[31]; |
| 250 | UINT16 cfa_reserved_160_175[16]; |
| 251 | UINT16 reserved_176_221[46]; |
| 252 | UINT16 transport_major_version; |
| 253 | UINT16 transport_minor_version; |
| 254 | UINT16 reserved_224_254[31]; |
| 255 | UINT16 integrity_word; |
| 256 | } ATAPI_IDENTIFY_DATA; |
| 257 | |
| 258 | |
| 259 | /// |
| 260 | /// Standard Quiry Data format, defined in SFF-8070i(ATAPI Removable Rewritable Specification). |
| 261 | /// |
| 262 | typedef struct { |
| 263 | UINT8 peripheral_type; |
| 264 | UINT8 RMB; |
| 265 | UINT8 version; |
| 266 | UINT8 response_data_format; |
| 267 | UINT8 addnl_length; ///< n - 4, Numbers of bytes following this one. |
| 268 | UINT8 reserved_5; |
| 269 | UINT8 reserved_6; |
| 270 | UINT8 reserved_7; |
| 271 | UINT8 vendor_info[8]; |
| 272 | UINT8 product_id[16]; |
| 273 | UINT8 product_revision_level[4]; |
| 274 | UINT8 vendor_specific_36_55[55 - 36 + 1]; |
| 275 | UINT8 reserved_56_95[95 - 56 + 1]; |
| 276 | /// |
| 277 | /// Vendor-specific parameters fields. The sizeof (ATAPI_INQUIRY_DATA) is 254 |
| 278 | /// since allocation_length is one byte in ATAPI_INQUIRY_CMD. |
| 279 | /// |
| 280 | UINT8 vendor_specific_96_253[253 - 96 + 1]; |
| 281 | } ATAPI_INQUIRY_DATA; |
| 282 | |
| 283 | /// |
| 284 | /// Request Sense Standard Data, defined in SFF-8070i(ATAPI Removable Rewritable Specification). |
| 285 | /// |
| 286 | typedef struct { |
| 287 | UINT8 error_code : 7; |
| 288 | UINT8 valid : 1; |
| 289 | UINT8 reserved_1; |
| 290 | UINT8 sense_key : 4; |
| 291 | UINT8 reserved_2 : 1; |
| 292 | UINT8 Vendor_specifc_1 : 3; |
| 293 | UINT8 vendor_specific_3; |
| 294 | UINT8 vendor_specific_4; |
| 295 | UINT8 vendor_specific_5; |
| 296 | UINT8 vendor_specific_6; |
| 297 | UINT8 addnl_sense_length; ///< n - 7 |
| 298 | UINT8 vendor_specific_8; |
| 299 | UINT8 vendor_specific_9; |
| 300 | UINT8 vendor_specific_10; |
| 301 | UINT8 vendor_specific_11; |
| 302 | UINT8 addnl_sense_code; ///< mandatory |
| 303 | UINT8 addnl_sense_code_qualifier; ///< mandatory |
| 304 | UINT8 field_replaceable_unit_code; ///< optional |
| 305 | UINT8 sense_key_specific_15 : 7; |
| 306 | UINT8 SKSV : 1; |
| 307 | UINT8 sense_key_specific_16; |
| 308 | UINT8 sense_key_specific_17; |
| 309 | } ATAPI_REQUEST_SENSE_DATA; |
| 310 | |
| 311 | /// |
| 312 | /// READ CAPACITY Data, defined in SFF-8070i(ATAPI Removable Rewritable Specification). |
| 313 | /// |
| 314 | typedef struct { |
| 315 | UINT8 LastLba3; |
| 316 | UINT8 LastLba2; |
| 317 | UINT8 LastLba1; |
| 318 | UINT8 LastLba0; |
| 319 | UINT8 BlockSize3; |
| 320 | UINT8 BlockSize2; |
| 321 | UINT8 BlockSize1; |
| 322 | UINT8 BlockSize0; |
| 323 | } ATAPI_READ_CAPACITY_DATA; |
| 324 | |
| 325 | /// |
| 326 | /// Capacity List Header + Current/Maximum Capacity Descriptor, |
| 327 | /// defined in SFF-8070i(ATAPI Removable Rewritable Specification). |
| 328 | /// |
| 329 | typedef struct { |
| 330 | UINT8 reserved_0; |
| 331 | UINT8 reserved_1; |
| 332 | UINT8 reserved_2; |
| 333 | UINT8 Capacity_Length; |
| 334 | UINT8 LastLba3; |
| 335 | UINT8 LastLba2; |
| 336 | UINT8 LastLba1; |
| 337 | UINT8 LastLba0; |
| 338 | UINT8 DesCode : 2; |
| 339 | UINT8 reserved_9 : 6; |
| 340 | UINT8 BlockSize2; |
| 341 | UINT8 BlockSize1; |
| 342 | UINT8 BlockSize0; |
| 343 | } ATAPI_READ_FORMAT_CAPACITY_DATA; |
| 344 | |
| 345 | /// |
| 346 | /// Test Unit Ready Command, defined in SFF-8070i(ATAPI Removable Rewritable Specification). |
| 347 | /// |
| 348 | typedef struct { |
| 349 | UINT8 opcode; |
| 350 | UINT8 reserved_1; |
| 351 | UINT8 reserved_2; |
| 352 | UINT8 reserved_3; |
| 353 | UINT8 reserved_4; |
| 354 | UINT8 reserved_5; |
| 355 | UINT8 reserved_6; |
| 356 | UINT8 reserved_7; |
| 357 | UINT8 reserved_8; |
| 358 | UINT8 reserved_9; |
| 359 | UINT8 reserved_10; |
| 360 | UINT8 reserved_11; |
| 361 | } ATAPI_TEST_UNIT_READY_CMD; |
| 362 | |
| 363 | /// |
| 364 | /// INQUIRY Command, defined in SFF-8070i(ATAPI Removable Rewritable Specification). |
| 365 | /// |
| 366 | typedef struct { |
| 367 | UINT8 opcode; |
| 368 | UINT8 reserved_1 : 5; |
| 369 | UINT8 lun : 3; |
| 370 | UINT8 page_code; ///< defined in SFF8090i, V6 |
| 371 | UINT8 reserved_3; |
| 372 | UINT8 allocation_length; |
| 373 | UINT8 reserved_5; |
| 374 | UINT8 reserved_6; |
| 375 | UINT8 reserved_7; |
| 376 | UINT8 reserved_8; |
| 377 | UINT8 reserved_9; |
| 378 | UINT8 reserved_10; |
| 379 | UINT8 reserved_11; |
| 380 | } ATAPI_INQUIRY_CMD; |
| 381 | |
| 382 | /// |
| 383 | /// REQUEST SENSE Command, defined in SFF-8070i(ATAPI Removable Rewritable Specification). |
| 384 | /// |
| 385 | typedef struct { |
| 386 | UINT8 opcode; |
| 387 | UINT8 reserved_1 : 5; |
| 388 | UINT8 lun : 3; |
| 389 | UINT8 reserved_2; |
| 390 | UINT8 reserved_3; |
| 391 | UINT8 allocation_length; |
| 392 | UINT8 reserved_5; |
| 393 | UINT8 reserved_6; |
| 394 | UINT8 reserved_7; |
| 395 | UINT8 reserved_8; |
| 396 | UINT8 reserved_9; |
| 397 | UINT8 reserved_10; |
| 398 | UINT8 reserved_11; |
| 399 | } ATAPI_REQUEST_SENSE_CMD; |
| 400 | |
| 401 | /// |
| 402 | /// READ (10) Command, defined in SFF-8070i(ATAPI Removable Rewritable Specification). |
| 403 | /// |
| 404 | typedef struct { |
| 405 | UINT8 opcode; |
| 406 | UINT8 reserved_1 : 5; |
| 407 | UINT8 lun : 3; |
| 408 | UINT8 Lba0; |
| 409 | UINT8 Lba1; |
| 410 | UINT8 Lba2; |
| 411 | UINT8 Lba3; |
| 412 | UINT8 reserved_6; |
| 413 | UINT8 TranLen0; |
| 414 | UINT8 TranLen1; |
| 415 | UINT8 reserved_9; |
| 416 | UINT8 reserved_10; |
| 417 | UINT8 reserved_11; |
| 418 | } ATAPI_READ10_CMD; |
| 419 | |
| 420 | /// |
| 421 | /// READ Format Capacity Command, defined in SFF-8070i(ATAPI Removable Rewritable Specification). |
| 422 | /// |
| 423 | typedef struct { |
| 424 | UINT8 opcode; |
| 425 | UINT8 reserved_1 : 5; |
| 426 | UINT8 lun : 3; |
| 427 | UINT8 reserved_2; |
| 428 | UINT8 reserved_3; |
| 429 | UINT8 reserved_4; |
| 430 | UINT8 reserved_5; |
| 431 | UINT8 reserved_6; |
| 432 | UINT8 allocation_length_hi; |
| 433 | UINT8 allocation_length_lo; |
| 434 | UINT8 reserved_9; |
| 435 | UINT8 reserved_10; |
| 436 | UINT8 reserved_11; |
| 437 | } ATAPI_READ_FORMAT_CAP_CMD; |
| 438 | |
| 439 | /// |
| 440 | /// MODE SENSE Command, defined in SFF-8070i(ATAPI Removable Rewritable Specification). |
| 441 | /// |
| 442 | typedef struct { |
| 443 | UINT8 opcode; |
| 444 | UINT8 reserved_1 : 5; |
| 445 | UINT8 lun : 3; |
| 446 | UINT8 page_code : 6; |
| 447 | UINT8 page_control : 2; |
| 448 | UINT8 reserved_3; |
| 449 | UINT8 reserved_4; |
| 450 | UINT8 reserved_5; |
| 451 | UINT8 reserved_6; |
| 452 | UINT8 parameter_list_length_hi; |
| 453 | UINT8 parameter_list_length_lo; |
| 454 | UINT8 reserved_9; |
| 455 | UINT8 reserved_10; |
| 456 | UINT8 reserved_11; |
| 457 | } ATAPI_MODE_SENSE_CMD; |
| 458 | |
| 459 | /// |
| 460 | /// ATAPI_PACKET_COMMAND is not defined in the ATA specification. |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 461 | /// We add it here for the convenience of ATA/ATAPI module writers. |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 462 | /// |
| 463 | typedef union { |
| 464 | UINT16 Data16[6]; |
| 465 | ATAPI_TEST_UNIT_READY_CMD TestUnitReady; |
| 466 | ATAPI_READ10_CMD Read10; |
| 467 | ATAPI_REQUEST_SENSE_CMD RequestSence; |
| 468 | ATAPI_INQUIRY_CMD Inquiry; |
| 469 | ATAPI_MODE_SENSE_CMD ModeSense; |
| 470 | ATAPI_READ_FORMAT_CAP_CMD ReadFormatCapacity; |
| 471 | } ATAPI_PACKET_COMMAND; |
| 472 | |
| 473 | #pragma pack() |
| 474 | |
| 475 | |
| 476 | #define ATAPI_MAX_DMA_EXT_CMD_SECTORS 0x10000 |
| 477 | #define ATAPI_MAX_DMA_CMD_SECTORS 0x100 |
| 478 | |
| 479 | // ATA/ATAPI Signature equates |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 480 | #define ATA_SIGNATURE 0x0101 ///< defined in ACS-3 |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 481 | #define ATAPI_SIGNATURE 0xeb14 ///< defined in ACS-3 |
| 482 | #define ATAPI_SIGNATURE_32 0xeb140101 ///< defined in ACS-3 |
| 483 | |
| 484 | // Spin Up Configuration definitions |
| 485 | #define ATA_SPINUP_CFG_REQUIRED_IDD_INCOMPLETE 0x37c8 ///< defined in ACS-3 |
| 486 | #define ATA_SPINUP_CFG_REQUIRED_IDD_COMPLETE 0x738c ///< defined in ACS-3 |
| 487 | #define ATA_SPINUP_CFG_NOT_REQUIRED_IDD_INCOMPLETE 0x8c73 ///< defined in ACS-3 |
| 488 | #define ATA_SPINUP_CFG_NOT_REQUIRED_IDD_COMPLETE 0xc837 ///< defined in ACS-3 |
| 489 | |
| 490 | // |
| 491 | // ATA Packet Command Code |
| 492 | // |
| 493 | #define ATA_CMD_FORMAT_UNIT 0x04 ///< defined in ATAPI Removable Rewritable Media Devcies |
| 494 | #define ATA_CMD_SOFT_RESET 0x08 ///< defined from ATA-3 |
| 495 | #define ATA_CMD_PACKET 0xA0 ///< defined from ATA-3 |
| 496 | #define ATA_CMD_IDENTIFY_DEVICE 0xA1 ///< defined from ATA-3 |
| 497 | #define ATA_CMD_SERVICE 0xA2 ///< defined from ATA-3 |
| 498 | #define ATA_CMD_TEST_UNIT_READY 0x00 ///< defined from ATA-1 |
| 499 | #define ATA_CMD_REQUEST_SENSE 0x03 ///< defined from ATA-4 |
| 500 | #define ATA_CMD_INQUIRY 0x12 ///< defined in ATAPI Removable Rewritable Media Devcies |
| 501 | #define ATA_CMD_READ_FORMAT_CAPACITY 0x23 ///< defined in ATAPI Removable Rewritable Media Devcies |
| 502 | #define ATA_CMD_READ_CAPACITY 0x25 ///< defined in ATAPI Removable Rewritable Media Devcies |
| 503 | #define ATA_CMD_READ_10 0x28 ///< defined in ATAPI Removable Rewritable Media Devcies |
| 504 | #define ATA_CMD_WRITE_10 0x2A ///< defined in ATAPI Removable Rewritable Media Devcies |
| 505 | #define ATA_CMD_ATAPI_SEEK 0x2B ///< defined in ATAPI Removable Rewritable Media Devcies |
| 506 | #define ATA_CMD_WRITE_AND_VERIFY 0x2E ///< defined in ATAPI Removable Rewritable Media Devcies |
| 507 | #define ATA_CMD_VERIFY 0x2F ///< defined in ATAPI Removable Rewritable Media Devcies |
| 508 | #define ATA_CMD_READ_12 0xA8 ///< defined in ATAPI Removable Rewritable Media Devcies |
| 509 | #define ATA_CMD_WRITE_12 0xAA ///< defined in ATAPI Removable Rewritable Media Devcies |
| 510 | #define ATA_CMD_START_STOP_UNIT 0x1B ///< defined in ATAPI Removable Rewritable Media Devcies |
| 511 | #define ATA_CMD_PREVENT_ALLOW_MEDIA_REMOVAL 0x1E ///< defined in ATAPI Removable Rewritable Media Devcies |
| 512 | #define ATA_CMD_MODE_SELECT 0x55 ///< defined in ATAPI Removable Rewritable Media Devcies |
| 513 | |
| 514 | #define ATA_CMD_MODE_SENSE 0x5A ///< defined in ATAPI Removable Rewritable Media Devcies |
| 515 | #define ATA_PAGE_CODE_READ_WRITE_ERROR 0x01 ///< defined in ATAPI Removable Rewritable Media Devcies |
| 516 | #define ATA_PAGE_CODE_CACHING_PAGE 0x08 ///< defined in ATAPI Removable Rewritable Media Devcies |
| 517 | #define ATA_PAGE_CODE_REMOVABLE_BLOCK_CAPABILITIES 0x1B ///< defined in ATAPI Removable Rewritable Media Devcies |
| 518 | #define ATA_PAGE_CODE_TIMER_PROTECT_PAGE 0x1C ///< defined in ATAPI Removable Rewritable Media Devcies |
| 519 | #define ATA_PAGE_CODE_RETURN_ALL_PAGES 0x3F ///< defined in ATAPI Removable Rewritable Media Devcies |
| 520 | |
| 521 | #define ATA_CMD_GET_CONFIGURATION 0x46 ///< defined in ATAPI Multimedia Devices |
| 522 | #define ATA_GCCD_RT_FIELD_VALUE_ALL 0x00 ///< defined in ATAPI Multimedia Devices |
| 523 | #define ATA_GCCD_RT_FIELD_VALUE_CURRENT 0x01 ///< defined in ATAPI Multimedia Devices |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 524 | #define ATA_GCCD_RT_FIELD_VALUE_SINGLE 0x02 ///< defined in ATAPI Multimedia Devices |
| 525 | #define ATA_GCCD_RT_FIELD_VALUE_RESERVED 0x03 ///< defined in ATAPI Multimedia Devices |
| 526 | |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 527 | #define ATA_FEATURE_LIST_PROFILE_LIST 0x0000 ///< defined in ATAPI Multimedia Devices |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 528 | #define ATA_FEATURE_LIST_CORE 0x0001 ///< defined in ATAPI Multimedia Devices |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 529 | #define ATA_FEATURE_LIST_MORPHING 0x0002 ///< defined in ATAPI Multimedia Devices |
| 530 | #define ATA_FEATURE_LIST_REMOVEABLE_MEDIUM 0x0003 ///< defined in ATAPI Multimedia Devices |
| 531 | #define ATA_FEATURE_LIST_WRITE_PROTECT 0x0004 ///< defined in ATAPI Multimedia Devices |
| 532 | |
| 533 | /// |
| 534 | /// Start/Stop and Eject Operations |
| 535 | /// |
| 536 | ///@{ |
| 537 | #define ATA_CMD_SUBOP_STOP_DISC 0x00 ///< Stop the Disc |
| 538 | #define ATA_CMD_SUBOP_START_DISC 0x01 ///< Start the Disc and acquire the format type |
| 539 | #define ATA_CMD_SUBOP_EJECT_DISC 0x02 ///< Eject the Disc if possible |
| 540 | #define ATA_CMD_SUBOP_CLOSE_TRAY 0x03 ///< Load the Disc (Close Tray) |
| 541 | ///@} |
| 542 | |
| 543 | // |
| 544 | // ATA Commands Code |
| 545 | // |
| 546 | |
| 547 | // |
| 548 | // Class 1: PIO Data-In Commands |
| 549 | // |
| 550 | #define ATA_CMD_IDENTIFY_DRIVE 0xec ///< defined from ATA-3 |
| 551 | #define ATA_CMD_READ_BUFFER 0xe4 ///< defined from ATA-1 |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 552 | #define ATA_CMD_READ_SECTORS 0x20 ///< defined from ATA-1 |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 553 | #define ATA_CMD_READ_SECTORS_WITH_RETRY 0x21 ///< defined from ATA-1, obsoleted from ATA-5 |
| 554 | #define ATA_CMD_READ_LONG 0x22 ///< defined from ATA-1, obsoleted from ATA-5 |
| 555 | #define ATA_CMD_READ_LONG_WITH_RETRY 0x23 ///< defined from ATA-1, obsoleted from ATA-5 |
| 556 | #define ATA_CMD_READ_SECTORS_EXT 0x24 ///< defined from ATA-6 |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 557 | #define ATA_CMD_READ_MULTIPLE 0xc4 ///< defined in ACS-3 |
| 558 | #define ATA_CMD_READ_MULTIPLE_EXT 0x29 ///< defined in ACS-3 |
| 559 | #define ATA_CMD_READ_LOG_EXT 0x2f ///< defined in ACS-3 |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 560 | |
| 561 | // |
| 562 | // Class 2: PIO Data-Out Commands |
| 563 | // |
| 564 | #define ATA_CMD_FORMAT_TRACK 0x50 ///< defined from ATA-1, obsoleted from ATA-4 |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 565 | #define ATA_CMD_WRITE_BUFFER 0xe8 ///< defined from ATA-1 |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 566 | #define ATA_CMD_WRITE_SECTORS 0x30 ///< defined from ATA-1 |
| 567 | #define ATA_CMD_WRITE_SECTORS_WITH_RETRY 0x31 ///< defined from ATA-1, obsoleted from ATA-5 |
| 568 | #define ATA_CMD_WRITE_LONG 0x32 ///< defined from ATA-1, obsoleted from ATA-5 |
| 569 | #define ATA_CMD_WRITE_LONG_WITH_RETRY 0x33 ///< defined from ATA-1, obsoleted from ATA-5 |
| 570 | #define ATA_CMD_WRITE_VERIFY 0x3c ///< defined from ATA-1, obsoleted from ATA-5 |
| 571 | #define ATA_CMD_WRITE_SECTORS_EXT 0x34 ///< defined from ATA-6 |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 572 | #define ATA_CMD_WRITE_MULTIPLE 0xc5 ///< defined in ACS-3 |
| 573 | #define ATA_CMD_WRITE_MULTIPLE_EXT 0x39 ///< defined in ACS-3 |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 574 | |
| 575 | // |
| 576 | // Class 3 No Data Command |
| 577 | // |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 578 | #define ATA_CMD_ACK_MEDIA_CHANGE 0xdb ///< defined from ATA-1, obsoleted from ATA-5 |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 579 | #define ATA_CMD_BOOT_POST_BOOT 0xdc ///< defined from ATA-1, obsoleted from ATA-3 |
| 580 | #define ATA_CMD_BOOT_PRE_BOOT 0xdd ///< defined from ATA-1, obsoleted from ATA-3 |
| 581 | #define ATA_CMD_CHECK_POWER_MODE 0x98 ///< defined from ATA-1, obsoleted from ATA-4 |
| 582 | #define ATA_CMD_CHECK_POWER_MODE_ALIAS 0xe5 ///< defined from ATA-1 |
| 583 | #define ATA_CMD_DOOR_LOCK 0xde ///< defined from ATA-1 |
| 584 | #define ATA_CMD_DOOR_UNLOCK 0xdf ///< defined from ATA-1 |
| 585 | #define ATA_CMD_EXEC_DRIVE_DIAG 0x90 ///< defined from ATA-1 |
| 586 | #define ATA_CMD_IDLE_ALIAS 0x97 ///< defined from ATA-1, obsoleted from ATA-4 |
| 587 | #define ATA_CMD_IDLE 0xe3 ///< defined from ATA-1 |
| 588 | #define ATA_CMD_IDLE_IMMEDIATE 0x95 ///< defined from ATA-1, obsoleted from ATA-4 |
| 589 | #define ATA_CMD_IDLE_IMMEDIATE_ALIAS 0xe1 ///< defined from ATA-1 |
| 590 | #define ATA_CMD_INIT_DRIVE_PARAM 0x91 ///< defined from ATA-1, obsoleted from ATA-6 |
| 591 | #define ATA_CMD_RECALIBRATE 0x10 ///< defined from ATA-1, obsoleted from ATA-4 |
| 592 | #define ATA_CMD_READ_DRIVE_STATE 0xe9 ///< defined from ATA-1, obsoleted from ATA-3 |
| 593 | #define ATA_CMD_SET_MULTIPLE_MODE 0xC6 ///< defined from ATA-2 |
| 594 | #define ATA_CMD_READ_VERIFY 0x40 ///< defined from ATA-1 |
| 595 | #define ATA_CMD_READ_VERIFY_WITH_RETRY 0x41 ///< defined from ATA-1, obsoleted from ATA-5 |
| 596 | #define ATA_CMD_SEEK 0x70 ///< defined from ATA-1 |
| 597 | #define ATA_CMD_SET_FEATURES 0xef ///< defined from ATA-1 |
| 598 | #define ATA_CMD_STANDBY 0x96 ///< defined from ATA-1, obsoleted from ATA-4 |
| 599 | #define ATA_CMD_STANDBY_ALIAS 0xe2 ///< defined from ATA-1 |
| 600 | #define ATA_CMD_STANDBY_IMMEDIATE 0x94 ///< defined from ATA-1, obsoleted from ATA-4 |
| 601 | #define ATA_CMD_STANDBY_IMMEDIATE_ALIAS 0xe0 ///< defined from ATA-1 |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 602 | #define ATA_CMD_SLEEP 0xe6 ///< defined in ACS-3 |
| 603 | #define ATA_CMD_READ_NATIVE_MAX_ADDRESS 0xf8 ///< defined in ATA-6 |
| 604 | #define ATA_CMD_READ_NATIVE_MAX_ADDRESS_EXT 0x27 ///< defined in ATA-6 |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 605 | |
| 606 | // |
| 607 | // Set Features Sub Command |
| 608 | // |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 609 | #define ATA_SUB_CMD_ENABLE_VOLATILE_WRITE_CACHE 0x02 ///< defined in ACS-3 |
| 610 | #define ATA_SUB_CMD_SET_TRANSFER_MODE 0x03 ///< defined in ACS-3 |
| 611 | #define ATA_SUB_CMD_ENABLE_APM 0x05 ///< defined in ACS-3 |
| 612 | #define ATA_SUB_CMD_ENABLE_PUIS 0x06 ///< defined in ACS-3 |
| 613 | #define ATA_SUB_CMD_PUIS_SET_DEVICE_SPINUP 0x07 ///< defined in ACS-3 |
| 614 | #define ATA_SUB_CMD_ENABLE_WRITE_READ_VERIFY 0x0b ///< defined in ACS-3 |
| 615 | #define ATA_SUB_CMD_ENABLE_SATA_FEATURE 0x10 ///< defined in ACS-3 |
| 616 | #define ATA_SUB_CMD_DISABLE_MEDIA_STATUS_NOTIFICATION 0x31 ///< defined in ACS-3 |
| 617 | #define ATA_SUB_CMD_ENABLE_FREE_FALL_CONTROL 0x41 ///< defined in ACS-3 |
| 618 | #define ATA_SUB_CMD_ACOUSTIC_MANAGEMENT_ENABLE 0x42 ///< defined in ACS-3 |
| 619 | #define ATA_SUB_CMD_SET_MAX_HOST_INTERFACE_SECTOR_TIMES 0x43 ///< defined in ACS-3 |
| 620 | #define ATA_SUB_CMD_EXTENDED_POWER_CONDITIONS 0x4a ///< defined in ACS-3 |
| 621 | #define ATA_SUB_CMD_DISABLE_READ_LOOK_AHEAD 0x55 ///< defined in ACS-3 |
| 622 | #define ATA_SUB_CMD_EN_DIS_DSN_FEATURE 0x63 ///< defined in ACS-3 |
| 623 | #define ATA_SUB_CMD_DISABLE_REVERT_TO_POWER_ON_DEFAULTS 0x66 ///< defined in ACS-3 |
| 624 | #define ATA_SUB_CMD_DISABLE_VOLATILE_WRITE_CACHE 0x82 ///< defined in ACS-3 |
| 625 | #define ATA_SUB_CMD_DISABLE_APM 0x85 ///< defined in ACS-3 |
| 626 | #define ATA_SUB_CMD_DISABLE_PUIS 0x86 ///< defined in ACS-3 |
| 627 | #define ATA_SUB_CMD_DISABLE_WRITE_READ_VERIFY 0x8b ///< defined in ACS-3 |
| 628 | #define ATA_SUB_CMD_DISABLE_SATA_FEATURE 0x90 ///< defined in ACS-3 |
| 629 | #define ATA_SUB_CMD_ENABLE_MEDIA_STATUS_NOTIFICATION 0x95 ///< defined in ACS-3 |
| 630 | #define ATA_SUB_CMD_ENABLE_READ_LOOK_AHEAD 0xaa ///< defined in ACS-3 |
| 631 | #define ATA_SUB_CMD_DISABLE_FREE_FALL_CONTROL 0xc1 ///< defined in ACS-3 |
| 632 | #define ATA_SUB_CMD_ACOUSTIC_MANAGEMENT_DISABLE 0xc2 ///< defined in ACS-3 |
| 633 | #define ATA_SUB_CMD_EN_DIS_SENSE_DATA_REPORTING 0xc3 ///< defined in ACS-3 |
| 634 | #define ATA_SUB_CMD_ENABLE_REVERT_TO_POWER_ON_DEFAULTS 0xcc ///< defined in ACS-3 |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 635 | |
| 636 | // |
| 637 | // S.M.A.R.T |
| 638 | // |
| 639 | #define ATA_CMD_SMART 0xb0 ///< defined from ATA-3 |
| 640 | #define ATA_CONSTANT_C2 0xc2 ///< reserved |
| 641 | #define ATA_CONSTANT_4F 0x4f ///< reserved |
| 642 | |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 643 | #define ATA_SMART_READ_DATA 0xd0 ///< defined in ACS-3 |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 644 | |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 645 | #define ATA_SMART_AUTOSAVE 0xd2 ///< defined in ACS-3 |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 646 | #define ATA_AUTOSAVE_DISABLE_ATTR 0x00 |
| 647 | #define ATA_AUTOSAVE_ENABLE_ATTR 0xf1 |
| 648 | |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 649 | #define ATA_SMART_EXECUTE_OFFLINE_IMMEDIATE 0xd4 ///< defined in ACS-3 |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 650 | #define ATA_EXECUTE_SMART_OFFLINE_ROUTINE 0x00 ///< defined in ACS-3 |
| 651 | #define ATA_EXECUTE_SMART_OFFLINE_SHORT_SELFTEST 0x01 ///< defined in ACS-3 |
| 652 | #define ATA_EXECUTE_SMART_OFFLINE_EXTENDED_SELFTEST 0x02 ///< defined in ACS-3 |
| 653 | #define ATA_EXECUTE_SMART_OFFLINE_CONVEYANCE_SELFTEST 0x03 ///< defined in ACS-3 |
| 654 | #define ATA_EXECUTE_SMART_OFFLINE_SELECTIVE_SELFTEST 0x04 ///< defined in ACS-3 |
| 655 | #define ATA_SMART_ABORT_SELF_TEST_SUBROUTINE 0x7f ///< defined in ACS-3 |
| 656 | #define ATA_EXECUTE_SMART_CAPTIVE_SHORT_SELFTEST 0x81 ///< defined in ACS-3 |
| 657 | #define ATA_EXECUTE_SMART_CAPTIVE_EXTENDED_SELFTEST 0x82 ///< defined in ACS-3 |
| 658 | #define ATA_EXECUTE_SMART_CAPTIVE_CONVEYANCE_SELFTEST 0x83 ///< defined in ACS-3 |
| 659 | #define ATA_EXECUTE_SMART_CAPTIVE_SELECTIVE_SELFTEST 0x84 ///< defined in ACS-3 |
| 660 | |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 661 | #define ATA_SMART_READLOG 0xd5 ///< defined in ACS-3 |
| 662 | #define ATA_SMART_WRITELOG 0xd6 ///< defined in ACS-3 |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 663 | #define ATA_SMART_ENABLE_OPERATION 0xd8 ///< reserved |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 664 | #define ATA_SMART_DISABLE_OPERATION 0xd9 ///< defined in ACS-3 |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 665 | #define ATA_SMART_RETURN_STATUS 0xda ///< defined from ATA-3 |
| 666 | |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 667 | #define ATA_SMART_THRESHOLD_NOT_EXCEEDED_VALUE 0xc24f ///< defined in ACS-3 |
| 668 | #define ATA_SMART_THRESHOLD_EXCEEDED_VALUE 0x2cf4 ///< defined in ACS-3 |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 669 | |
| 670 | // SMART Log Definitions |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 671 | #define ATA_SMART_LOG_DIRECTORY 0x00 ///< defined in ACS-3 |
| 672 | #define ATA_SMART_SUM_SMART_ERROR_LOG 0x01 ///< defined in ACS-3 |
| 673 | #define ATA_SMART_COMP_SMART_ERROR_LOG 0x02 ///< defined in ACS-3 |
| 674 | #define ATA_SMART_EXT_COMP_SMART_ERROR_LOG 0x03 ///< defined in ACS-3 |
| 675 | #define ATA_SMART_SMART_SELFTEST_LOG 0x06 ///< defined in ACS-3 |
| 676 | #define ATA_SMART_EXT_SMART_SELFTEST_LOG 0x07 ///< defined in ACS-3 |
| 677 | #define ATA_SMART_SELECTIVE_SELFTEST_LOG 0x09 ///< defined in ACS-3 |
| 678 | #define ATA_SMART_HOST_VENDOR_SPECIFIC 0x80 ///< defined in ACS-3 |
| 679 | #define ATA_SMART_DEVICE_VENDOR_SPECIFIC 0xa0 ///< defined in ACS-3 |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 680 | |
| 681 | // |
| 682 | // Class 4: DMA Command |
| 683 | // |
| 684 | #define ATA_CMD_READ_DMA 0xc8 ///< defined from ATA-1 |
| 685 | #define ATA_CMD_READ_DMA_WITH_RETRY 0xc9 ///< defined from ATA-1, obsoleted from ATA-5 |
| 686 | #define ATA_CMD_READ_DMA_EXT 0x25 ///< defined from ATA-6 |
| 687 | #define ATA_CMD_WRITE_DMA 0xca ///< defined from ATA-1 |
| 688 | #define ATA_CMD_WRITE_DMA_WITH_RETRY 0xcb ///< defined from ATA-1, obsoleted from ATA- |
| 689 | #define ATA_CMD_WRITE_DMA_EXT 0x35 ///< defined from ATA-6 |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 690 | |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 691 | // |
| 692 | // ATA Security commands |
| 693 | // |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 694 | #define ATA_CMD_SECURITY_SET_PASSWORD 0xf1 ///< defined in ACS-3 |
| 695 | #define ATA_CMD_SECURITY_UNLOCK 0xf2 ///< defined in ACS-3 |
| 696 | #define ATA_CMD_SECURITY_ERASE_PREPARE 0xf3 ///< defined in ACS-3 |
| 697 | #define ATA_CMD_SECURITY_ERASE_UNIT 0xf4 ///< defined in ACS-3 |
| 698 | #define ATA_CMD_SECURITY_FREEZE_LOCK 0xf5 ///< defined in ACS-3 |
| 699 | #define ATA_CMD_SECURITY_DISABLE_PASSWORD 0xf6 ///< defined in ACS-3 |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 700 | |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 701 | #define ATA_SECURITY_BUFFER_LENGTH 512 ///< defined in ACS-3 |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 702 | |
| 703 | // |
| 704 | // ATA Device Config Overlay |
| 705 | // |
| 706 | #define ATA_CMD_DEV_CONFIG_OVERLAY 0xb1 ///< defined from ATA-6 |
| 707 | #define ATA_CMD_DEV_CONFIG_RESTORE_FEATURE 0xc0 ///< defined from ATA-6 |
| 708 | #define ATA_CMD_DEV_CONFIG_FREEZELOCK_FEATURE 0xc1 ///< defined from ATA-6 |
| 709 | #define ATA_CMD_DEV_CONFIG_IDENTIFY_FEATURE 0xc2 ///< defined from ATA-6 |
| 710 | #define ATA_CMD_DEV_CONFIG_SET_FEATURE 0xc3 ///< defined from ATA-6 |
| 711 | |
| 712 | // |
| 713 | // ATA Trusted Computing Feature Set Commands |
| 714 | // |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 715 | #define ATA_CMD_TRUSTED_NON_DATA 0x5b ///< defined in ACS-3 |
| 716 | #define ATA_CMD_TRUSTED_RECEIVE 0x5c ///< defined in ACS-3 |
| 717 | #define ATA_CMD_TRUSTED_RECEIVE_DMA 0x5d ///< defined in ACS-3 |
| 718 | #define ATA_CMD_TRUSTED_SEND 0x5e ///< defined in ACS-3 |
| 719 | #define ATA_CMD_TRUSTED_SEND_DMA 0x5f ///< defined in ACS-3 |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 720 | |
| 721 | // |
| 722 | // ATA Trusted Receive Fields |
| 723 | // |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 724 | #define ATA_TR_RETURN_SECURITY_PROTOCOL_INFORMATION 0x00 ///< defined in ACS-3 |
| 725 | #define ATA_TR_SECURITY_PROTOCOL_JEDEC_RESERVED 0xec ///< defined in ACS-3 |
| 726 | #define ATA_TR_SECURITY_PROTOCOL_SDCARD_RESERVED 0xed ///< defined in ACS-3 |
| 727 | #define ATA_TR_SECURITY_PROTOCOL_IEEE1667_RESERVED 0xee ///< defined in ACS-3 |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 728 | |
| 729 | // |
| 730 | // Equates used for Acoustic Flags |
| 731 | // |
| 732 | #define ATA_ACOUSTIC_LEVEL_BYPASS 0xff ///< defined from ATA-6 |
| 733 | #define ATA_ACOUSTIC_LEVEL_MAXIMUM_PERFORMANCE 0xfe ///< defined from ATA-6 |
| 734 | #define ATA_ACOUSTIC_LEVEL_QUIET 0x80 ///< defined from ATA-6 |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 735 | |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 736 | // |
| 737 | // Equates used for DiPM Support |
| 738 | // |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 739 | #define ATA_CMD_DIPM_SUB 0x03 // defined in ACS-3 : Count value in SetFeature identification : 03h Device-initiated interface power state transitions |
| 740 | #define ATA_DIPM_ENABLE 0x10 // defined in ACS-3 |
| 741 | #define ATA_DIPM_DISABLE 0x90 // defined in ACS-3 |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 742 | |
| 743 | // |
| 744 | // Equates used for DevSleep Support |
| 745 | // |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 746 | #define ATA_CMD_DEVSLEEP_SUB 0x09 // defined in SATA 3.2 Gold Spec : Count value in SetFeature identification : 09h Device Sleep |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 747 | #define ATA_DEVSLEEP_ENABLE 0x10 // defined in SATA 3.2 Gold Spec |
| 748 | #define ATA_DEVSLEEP_DISABLE 0x90 // defined in SATA 3.2 Gold Spec |
| 749 | |
| 750 | #define ATA_DEVSLP_EXIT_TIMEOUT 20 // MDAT - 20 ms |
| 751 | #define ATA_DEVSLP_MINIMUM_DETECTION_TIME 10 // DMDT - 10 us |
| 752 | #define ATA_DEVSLP_MINIMUM_ASSERTION_TIME 10 // DETO - 10 ms |
| 753 | |
| 754 | // |
| 755 | // Set MAX Commands |
| 756 | // |
| 757 | #define ATA_CMD_SET_MAX_ADDRESS_EXT 0x37 ///< defined from ATA-6 |
| 758 | #define ATA_CMD_SET_MAX_ADDRESS 0xf9 ///< defined from ATA-6 |
| 759 | #define ATA_SET_MAX_SET_PASSWORD 0x01 ///< defined from ATA-6 |
| 760 | #define ATA_SET_MAX_LOCK 0x02 ///< defined from ATA-6 |
| 761 | #define ATA_SET_MAX_UNLOCK 0x03 ///< defined from ATA-6 |
| 762 | #define ATA_SET_MAX_FREEZE_LOCK 0x04 ///< defined from ATA-6 |
| 763 | |
| 764 | /// |
| 765 | /// Default content of device control register, disable INT, |
| 766 | /// Bit3 is set to 1 according ATA-1 |
| 767 | /// |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 768 | #define ATA_DEFAULT_CTL (0x0a) |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 769 | /// |
| 770 | /// Default context of Device/Head Register, |
| 771 | /// Bit7 and Bit5 are set to 1 for back-compatibilities. |
| 772 | /// |
| 773 | #define ATA_DEFAULT_CMD (0xa0) |
| 774 | |
| 775 | #define ATAPI_MAX_BYTE_COUNT (0xfffe) |
| 776 | |
| 777 | #define ATA_REQUEST_SENSE_ERROR (0x70) ///< defined in SFF-8070i |
| 778 | |
| 779 | // |
| 780 | // Sense Key, Additional Sense Codes and Additional Sense Code Qualifier |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 781 | // defined in MultiMedia Commands (MMC, MMC-2) |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 782 | // |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 783 | // Sense Key |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 784 | // |
| 785 | #define ATA_SK_NO_SENSE (0x0) |
| 786 | #define ATA_SK_RECOVERY_ERROR (0x1) |
| 787 | #define ATA_SK_NOT_READY (0x2) |
| 788 | #define ATA_SK_MEDIUM_ERROR (0x3) |
| 789 | #define ATA_SK_HARDWARE_ERROR (0x4) |
| 790 | #define ATA_SK_ILLEGAL_REQUEST (0x5) |
| 791 | #define ATA_SK_UNIT_ATTENTION (0x6) |
| 792 | #define ATA_SK_DATA_PROTECT (0x7) |
| 793 | #define ATA_SK_BLANK_CHECK (0x8) |
| 794 | #define ATA_SK_VENDOR_SPECIFIC (0x9) |
| 795 | #define ATA_SK_RESERVED_A (0xA) |
| 796 | #define ATA_SK_ABORT (0xB) |
| 797 | #define ATA_SK_RESERVED_C (0xC) |
| 798 | #define ATA_SK_OVERFLOW (0xD) |
| 799 | #define ATA_SK_MISCOMPARE (0xE) |
| 800 | #define ATA_SK_RESERVED_F (0xF) |
| 801 | |
| 802 | // |
| 803 | // Additional Sense Codes |
| 804 | // |
| 805 | #define ATA_ASC_NOT_READY (0x04) |
| 806 | #define ATA_ASC_MEDIA_ERR1 (0x10) |
| 807 | #define ATA_ASC_MEDIA_ERR2 (0x11) |
| 808 | #define ATA_ASC_MEDIA_ERR3 (0x14) |
| 809 | #define ATA_ASC_MEDIA_ERR4 (0x30) |
| 810 | #define ATA_ASC_MEDIA_UPSIDE_DOWN (0x06) |
| 811 | #define ATA_ASC_INVALID_CMD (0x20) |
| 812 | #define ATA_ASC_LBA_OUT_OF_RANGE (0x21) |
| 813 | #define ATA_ASC_INVALID_FIELD (0x24) |
| 814 | #define ATA_ASC_WRITE_PROTECTED (0x27) |
| 815 | #define ATA_ASC_MEDIA_CHANGE (0x28) |
| 816 | #define ATA_ASC_RESET (0x29) ///< Power On Reset or Bus Reset occurred. |
| 817 | #define ATA_ASC_ILLEGAL_FIELD (0x26) |
| 818 | #define ATA_ASC_NO_MEDIA (0x3A) |
| 819 | #define ATA_ASC_ILLEGAL_MODE_FOR_THIS_TRACK (0x64) |
| 820 | |
| 821 | // |
| 822 | // Additional Sense Code Qualifier |
| 823 | // |
| 824 | #define ATA_ASCQ_IN_PROGRESS (0x01) |
| 825 | |
| 826 | // |
| 827 | // Error Register |
Peter Lemenkov | 7bbe3bb | 2018-12-07 11:23:21 +0100 | [diff] [blame] | 828 | // |
Subrata Banik | 8b9f289 | 2018-01-25 10:50:39 +0530 | [diff] [blame] | 829 | #define ATA_ERRREG_BBK BIT7 ///< Bad block detected defined from ATA-1, obsoleted from ATA-2 |
| 830 | #define ATA_ERRREG_UNC BIT6 ///< Uncorrectable Data defined from ATA-1, obsoleted from ATA-4 |
| 831 | #define ATA_ERRREG_MC BIT5 ///< Media Change defined from ATA-1, obsoleted from ATA-4 |
| 832 | #define ATA_ERRREG_IDNF BIT4 ///< ID Not Found defined from ATA-1, obsoleted from ATA-4 |
| 833 | #define ATA_ERRREG_MCR BIT3 ///< Media Change Requested defined from ATA-1, obsoleted from ATA-4 |
| 834 | #define ATA_ERRREG_ABRT BIT2 ///< Aborted Command defined from ATA-1 |
| 835 | #define ATA_ERRREG_TK0NF BIT1 ///< Track 0 Not Found defined from ATA-1, obsoleted from ATA-4 |
| 836 | #define ATA_ERRREG_AMNF BIT0 ///< Address Mark Not Found defined from ATA-1, obsoleted from ATA-4 |
| 837 | |
| 838 | // |
| 839 | // Status Register |
| 840 | // |
| 841 | #define ATA_STSREG_BSY BIT7 ///< Controller Busy defined from ATA-1 |
| 842 | #define ATA_STSREG_DRDY BIT6 ///< Drive Ready defined from ATA-1 |
| 843 | #define ATA_STSREG_DWF BIT5 ///< Drive Write Fault defined from ATA-1, obsoleted from ATA-4 |
| 844 | #define ATA_STSREG_DF BIT5 ///< Drive Fault defined from ATA-6 |
| 845 | #define ATA_STSREG_DSC BIT4 ///< Disk Seek Complete defined from ATA-1, obsoleted from ATA-4 |
| 846 | #define ATA_STSREG_DRQ BIT3 ///< Data Request defined from ATA-1 |
| 847 | #define ATA_STSREG_CORR BIT2 ///< Corrected Data defined from ATA-1, obsoleted from ATA-4 |
| 848 | #define ATA_STSREG_IDX BIT1 ///< Index defined from ATA-1, obsoleted from ATA-4 |
| 849 | #define ATA_STSREG_ERR BIT0 ///< Error defined from ATA-1 |
| 850 | |
| 851 | // |
| 852 | // Device Control Register |
| 853 | // |
| 854 | #define ATA_CTLREG_SRST BIT2 ///< Software Reset. |
| 855 | #define ATA_CTLREG_IEN_L BIT1 ///< Interrupt Enable #. |
| 856 | |
| 857 | #endif |