11713e81bSScott Long /* 2d2bd3ab9SScott Long * Copyright (c) 2004-2005 HighPoint Technologies, Inc. 31713e81bSScott Long * All rights reserved. 41713e81bSScott Long * 51713e81bSScott Long * Redistribution and use in source and binary forms, with or without 61713e81bSScott Long * modification, are permitted provided that the following conditions 71713e81bSScott Long * are met: 81713e81bSScott Long * 1. Redistributions of source code must retain the above copyright 91713e81bSScott Long * notice, this list of conditions and the following disclaimer. 101713e81bSScott Long * 2. Redistributions in binary form must reproduce the above copyright 111713e81bSScott Long * notice, this list of conditions and the following disclaimer in the 121713e81bSScott Long * documentation and/or other materials provided with the distribution. 131713e81bSScott Long * 141713e81bSScott Long * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 151713e81bSScott Long * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 161713e81bSScott Long * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 171713e81bSScott Long * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 181713e81bSScott Long * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 191713e81bSScott Long * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 201713e81bSScott Long * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 211713e81bSScott Long * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 221713e81bSScott Long * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 231713e81bSScott Long * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 241713e81bSScott Long * SUCH DAMAGE. 25d38d9c9eSScott Long * 26d38d9c9eSScott Long * $FreeBSD$ 271713e81bSScott Long */ 281713e81bSScott Long 291713e81bSScott Long #ifndef _ATAPI_H_ 301713e81bSScott Long #define _ATAPI_H_ 311713e81bSScott Long 321713e81bSScott Long #pragma pack(1) 331713e81bSScott Long 341713e81bSScott Long /*************************************************************************** 351713e81bSScott Long * IDE IO Register File 361713e81bSScott Long ***************************************************************************/ 371713e81bSScott Long 381713e81bSScott Long /* 391713e81bSScott Long * IDE IO Port definition 401713e81bSScott Long */ 411713e81bSScott Long typedef struct _IDE_REGISTERS_1 { 421713e81bSScott Long USHORT Data; /* RW: Data port feature register */ 431713e81bSScott Long UCHAR BlockCount; /* RW: Sector count */ 441713e81bSScott Long UCHAR BlockNumber; /* RW: Sector number & LBA 0-7 */ 451713e81bSScott Long UCHAR CylinderLow; /* RW: Cylinder low & LBA 8-15 */ 461713e81bSScott Long UCHAR CylinderHigh; /* RW: Cylinder hign & LBA 16-23 */ 471713e81bSScott Long UCHAR DriveSelect; /* RW: Drive/head & LBA 24-27 */ 481713e81bSScott Long UCHAR Command; /* RO: Status WR:Command */ 491713e81bSScott Long } IDE_REGISTERS_1, *PIDE_REGISTERS_1; 501713e81bSScott Long 511713e81bSScott Long 521713e81bSScott Long /* 531713e81bSScott Long * IDE status definitions 541713e81bSScott Long */ 551713e81bSScott Long #define IDE_STATUS_ERROR 0x01 /* Error Occurred in Execution */ 561713e81bSScott Long #define IDE_STATUS_INDEX 0x02 /* is vendor specific */ 571713e81bSScott Long #define IDE_STATUS_CORRECTED_ERROR 0x04 /* Corrected Data */ 581713e81bSScott Long #define IDE_STATUS_DRQ 0x08 /* Ready to transfer data */ 591713e81bSScott Long #define IDE_STATUS_DSC 0x10 /* not defined in ATA-2 */ 601713e81bSScott Long #define IDE_STATUS_DWF 0x20 /* Device Fault has been detected */ 611713e81bSScott Long #define IDE_STATUS_DRDY 0x40 /* Device Ready to accept command */ 621713e81bSScott Long #define IDE_STATUS_IDLE 0x50 /* Device is OK */ 631713e81bSScott Long #define IDE_STATUS_BUSY 0x80 /* Device Busy, must wait */ 641713e81bSScott Long 651713e81bSScott Long 661713e81bSScott Long #define IDE_ERROR_BAD_BLOCK 0x80 /* Reserved now */ 671713e81bSScott Long #define IDE_ERROR_DATA_ERROR 0x40 /* Uncorreectable Data Error */ 681713e81bSScott Long #define IDE_ERROR_MEDIA_CHANGE 0x20 /* Media Changed */ 691713e81bSScott Long #define IDE_ERROR_ID_NOT_FOUND 0x10 /* ID Not Found */ 701713e81bSScott Long #define IDE_ERROR_MEDIA_CHANGE_REQ 0x08 /* Media Change Requested */ 711713e81bSScott Long #define IDE_ERROR_COMMAND_ABORTED 0x04 /* Aborted Command */ 721713e81bSScott Long #define IDE_ERROR_TRACK0_NOT_FOUND 0x02 /* Track 0 Not Found */ 731713e81bSScott Long #define IDE_ERROR_ADDRESS_NOT_FOUND 0x01 /* Address Mark Not Found */ 741713e81bSScott Long 751713e81bSScott Long 761713e81bSScott Long #define LBA_MODE 0x40 771713e81bSScott Long 781713e81bSScott Long /* 791713e81bSScott Long * IDE command definitions 801713e81bSScott Long */ 811713e81bSScott Long 821713e81bSScott Long #define IDE_COMMAND_RECALIBRATE 0x10 /* Recalibrate */ 831713e81bSScott Long #define IDE_COMMAND_READ 0x20 /* Read Sectors with retry */ 841713e81bSScott Long #define IDE_COMMAND_WRITE 0x30 /* Write Sectors with retry */ 851713e81bSScott Long #define IDE_COMMAND_VERIFY 0x40 /* Read Verify Sectors with Retry */ 861713e81bSScott Long #define IDE_COMMAND_SEEK 0x70 /* Seek */ 871713e81bSScott Long #define IDE_COMMAND_SET_DRIVE_PARAMETER 0x91 /* Initialize Device Parmeters */ 881713e81bSScott Long #define IDE_COMMAND_GET_MEDIA_STATUS 0xDA 891713e81bSScott Long #define IDE_COMMAND_DOOR_LOCK 0xDE /* Door Lock */ 901713e81bSScott Long #define IDE_COMMAND_DOOR_UNLOCK 0xDF /* Door Unlock */ 911713e81bSScott Long #define IDE_COMMAND_ENABLE_MEDIA_STATUS 0xEF /* Set Features */ 921713e81bSScott Long #define IDE_COMMAND_IDENTIFY 0xEC /* Identify Device */ 931713e81bSScott Long #define IDE_COMMAND_MEDIA_EJECT 0xED 941713e81bSScott Long #define IDE_COMMAND_SET_FEATURES 0xEF /* IDE set features command */ 951713e81bSScott Long 961713e81bSScott Long #define IDE_COMMAND_FLUSH_CACHE 0xE7 971713e81bSScott Long #define IDE_COMMAND_STANDBY_IMMEDIATE 0xE0 981713e81bSScott Long 991713e81bSScott Long #ifndef NOT_SUPPORT_MULTIPLE 1001713e81bSScott Long #define IDE_COMMAND_READ_MULTIPLE 0xC4 /* Read Multiple */ 1011713e81bSScott Long #define IDE_COMMAND_WRITE_MULTIPLE 0xC5 /* Write Multiple */ 1021713e81bSScott Long #define IDE_COMMAND_SET_MULTIPLE 0xC6 /* Set Multiple Mode */ 1031713e81bSScott Long #endif 1041713e81bSScott Long 1051713e81bSScott Long #ifndef NOT_SUPPORT_DMA 1061713e81bSScott Long #define IDE_COMMAND_DMA_READ 0xc8 /* IDE DMA read command */ 1071713e81bSScott Long #define IDE_COMMAND_DMA_WRITE 0xca /* IDE DMA write command */ 1081713e81bSScott Long #endif 1091713e81bSScott Long 1101713e81bSScott Long #define IDE_COMMAND_READ_DMA_QUEUE 0xc7 /* IDE read DMA queue command */ 1111713e81bSScott Long #define IDE_COMMAND_WRITE_DMA_QUEUE 0xcc /* IDE write DMA queue command */ 1121713e81bSScott Long #define IDE_COMMAND_SERVICE 0xA2 /* IDE service command command */ 1131713e81bSScott Long #define IDE_COMMAND_NOP 0x00 /* IDE NOP command */ 1141713e81bSScott Long #define IDE_STATUS_SRV 0x10 1151713e81bSScott Long #define IDE_RELEASE_BUS 4 1161713e81bSScott Long 1171713e81bSScott Long /*#define IDE_COMMAND_FLUSH_CACHE_EXT */ 1181713e81bSScott Long #define IDE_COMMAND_READ_DMA_EXT 0x25 1191713e81bSScott Long #define IDE_COMMAND_READ_QUEUE_EXT 0x26 1201713e81bSScott Long #define IDE_COMMAND_READ_MULTIPLE_EXT 0x29 1211713e81bSScott Long #define IDE_COMMAND_READ_MAX_ADDR 0x27 1221713e81bSScott Long #define IDE_COMMAND_READ_EXT 0x24 1231713e81bSScott Long #define IDE_COMMAND_VERIFY_EXT 0x42 1241713e81bSScott Long #define IDE_COMMAND_SET_MULTIPLE_EXT 0x37 1251713e81bSScott Long #define IDE_COMMAND_WRITE_DMA_EXT 0x35 1261713e81bSScott Long #define IDE_COMMAND_WRITE_QUEUE_EXT 0x36 1271713e81bSScott Long #define IDE_COMMAND_WRITE_EXT 0x34 1281713e81bSScott Long #define IDE_COMMAND_WRITE_MULTIPLE_EXT 0x39 1291713e81bSScott Long 1301713e81bSScott Long /* 1311713e81bSScott Long * IDE_COMMAND_SET_FEATURES 1321713e81bSScott Long */ 1331713e81bSScott Long #define FT_USE_ULTRA 0x40 /* Set feature for Ultra DMA */ 1341713e81bSScott Long #define FT_USE_MWDMA 0x20 /* Set feature for MW DMA */ 1351713e81bSScott Long #define FT_USE_SWDMA 0x10 /* Set feature for SW DMA */ 1361713e81bSScott Long #define FT_USE_PIO 0x8 /* Set feature for PIO */ 1371713e81bSScott Long #define FT_DISABLE_IORDY 0x10 /* Set feature for disabling IORDY */ 1381713e81bSScott Long 1391713e81bSScott Long /* 1401713e81bSScott Long * S.M.A.R.T. commands 1411713e81bSScott Long */ 1421713e81bSScott Long #define IDE_COMMAND_SMART 0xB0 1431713e81bSScott Long #define SMART_READ_VALUES 0xd0 1441713e81bSScott Long #define SMART_READ_THRESHOLDS 0xd1 1451713e81bSScott Long #define SMART_AUTOSAVE 0xd2 1461713e81bSScott Long #define SMART_SAVE 0xd3 1471713e81bSScott Long #define SMART_IMMEDIATE_OFFLINE 0xd4 1481713e81bSScott Long #define SMART_READ_LOG_SECTOR 0xd5 1491713e81bSScott Long #define SMART_WRITE_LOG_SECTOR 0xd6 1501713e81bSScott Long #define SMART_ENABLE 0xd8 1511713e81bSScott Long #define SMART_DISABLE 0xd9 1521713e81bSScott Long #define SMART_STATUS 0xda 1531713e81bSScott Long #define SMART_AUTO_OFFLINE 0xdb 1541713e81bSScott Long 1551713e81bSScott Long /*************************************************************************** 1561713e81bSScott Long * IDE Control Register File 1571713e81bSScott Long ***************************************************************************/ 1581713e81bSScott Long 1591713e81bSScott Long typedef struct _IDE_REGISTERS_2 { 1601713e81bSScott Long UCHAR AlternateStatus; /* RW: device control port */ 1611713e81bSScott Long } IDE_REGISTERS_2, *PIDE_REGISTERS_2; 1621713e81bSScott Long 1631713e81bSScott Long 1641713e81bSScott Long /* 1651713e81bSScott Long * IDE drive control definitions 1661713e81bSScott Long */ 1671713e81bSScott Long #define IDE_DC_DISABLE_INTERRUPTS 0x02 1681713e81bSScott Long #define IDE_DC_RESET_CONTROLLER 0x04 1691713e81bSScott Long #define IDE_DC_REENABLE_CONTROLLER 0x00 1701713e81bSScott Long 1711713e81bSScott Long /*************************************************************************** 1721713e81bSScott Long * MSNS: Removable device 1731713e81bSScott Long ***************************************************************************/ 1741713e81bSScott Long /* 1751713e81bSScott Long * Media syatus 1761713e81bSScott Long */ 1771713e81bSScott Long #define MSNS_NO_MEDIA 2 1781713e81bSScott Long #define MSNS_MEDIA_CHANGE_REQUEST 8 1791713e81bSScott Long #define MSNS_MIDIA_CHANGE 0x20 1801713e81bSScott Long #define MSNS_WRITE_PROTECT 0x40 1811713e81bSScott Long #define MSNS_READ_PROTECT 0x80 1821713e81bSScott Long 1831713e81bSScott Long /*************************************************************************** 1841713e81bSScott Long * ATAPI IO Register File 1851713e81bSScott Long ***************************************************************************/ 1861713e81bSScott Long 1871713e81bSScott Long /* 1881713e81bSScott Long * ATAPI register definition 1891713e81bSScott Long */ 1901713e81bSScott Long 1911713e81bSScott Long typedef struct _ATAPI_REGISTERS_1 { 1921713e81bSScott Long USHORT Data; 1931713e81bSScott Long UCHAR InterruptReason; /* Atapi Phase Port */ 1941713e81bSScott Long UCHAR Unused1; 1951713e81bSScott Long UCHAR ByteCountLow; /* Byte Count LSB */ 1961713e81bSScott Long UCHAR ByteCountHigh; /* Byte Count MSB */ 1971713e81bSScott Long UCHAR DriveSelect; 1981713e81bSScott Long UCHAR Command; 1991713e81bSScott Long } ATAPI_REGISTERS_1, *PATAPI_REGISTERS_1; 2001713e81bSScott Long 2011713e81bSScott Long /* 2021713e81bSScott Long * Atapi Error Status 2031713e81bSScott Long */ 2041713e81bSScott Long #define IDE_ERROR_END_OF_MEDIA IDE_ERROR_TRACK0_NOT_FOUND 2051713e81bSScott Long #define IDE_ERROR_ILLEGAL_LENGTH IDE_ERROR_ADDRESS_NOT_FOUND 2061713e81bSScott Long 2071713e81bSScott Long /* 2081713e81bSScott Long * ATAPI interrupt reasons 2091713e81bSScott Long */ 2101713e81bSScott Long #define ATAPI_IR_COD 0x01 2111713e81bSScott Long #define ATAPI_IR_IO 0x02 2121713e81bSScott Long 2131713e81bSScott Long /* sense key */ 2141713e81bSScott Long #define ATAPI_SENSE_NO_SENSE 0x00 2151713e81bSScott Long #define ATAPI_SENSE_RECOVERED_ERROR 0x01 2161713e81bSScott Long #define ATAPI_SENSE_NOT_READY 0x02 2171713e81bSScott Long #define ATAPI_SENSE_MEDIUM_ERROR 0x03 2181713e81bSScott Long #define ATAPI_SENSE_HARDWARE_ERROR 0x04 2191713e81bSScott Long #define ATAPI_SENSE_ILLEGAL_REQUEST 0x05 2201713e81bSScott Long #define ATAPI_SENSE_UNIT_ATTENTION 0x06 2211713e81bSScott Long #define ATAPI_SENSE_DATA_PROTECT 0x07 2221713e81bSScott Long #define ATAPI_SENSE_BLANK_CHECK 0x08 2231713e81bSScott Long #define ATAPI_SENSE_UNIQUE 0x09 2241713e81bSScott Long #define ATAPI_SENSE_COPY_ABORTED 0x0A 2251713e81bSScott Long #define ATAPI_SENSE_ABORTED_COMMAND 0x0B 2261713e81bSScott Long #define ATAPI_SENSE_EQUAL 0x0C 2271713e81bSScott Long #define ATAPI_SENSE_VOL_OVERFLOW 0x0D 2281713e81bSScott Long #define ATAPI_SENSE_MISCOMPARE 0x0E 2291713e81bSScott Long #define ATAPI_SENSE_RESERVED 0x0F 2301713e81bSScott Long 2311713e81bSScott Long /* Additional Sense codes */ 2321713e81bSScott Long #define ATAPI_ASC_NO_SENSE 0x00 2331713e81bSScott Long #define ATAPI_ASC_LUN_NOT_READY 0x04 2341713e81bSScott Long #define ATAPI_ASC_TRACK_ERROR 0x14 2351713e81bSScott Long #define ATAPI_ASC_SEEK_ERROR 0x15 2361713e81bSScott Long #define ATAPI_ASC_REC_DATA_NOECC 0x17 2371713e81bSScott Long #define ATAPI_ASC_REC_DATA_ECC 0x18 2381713e81bSScott Long #define ATAPI_ASC_ILLEGAL_COMMAND 0x20 2391713e81bSScott Long #define ATAPI_ASC_ILLEGAL_BLOCK 0x21 2401713e81bSScott Long #define ATAPI_ASC_INVALID_CDB 0x24 2411713e81bSScott Long #define ATAPI_ASC_INVALID_LUN 0x25 2421713e81bSScott Long #define ATAPI_ASC_PROTECT 0x27 2431713e81bSScott Long #define ATAPI_ASC_MEDIUM_CHANGED 0x28 2441713e81bSScott Long #define ATAPI_ASC_BUS_RESET 0x29 2451713e81bSScott Long #define ATAPI_ASC_NO_MEDIA_IN_DEVICE 0x3a 2461713e81bSScott Long #define ATAPI_ASC_MUSIC_AREA 0xA0 2471713e81bSScott Long #define ATAPI_ASC_DATA_AREA 0xA1 2481713e81bSScott Long #define ATAPI_ASC_VOLUME_OVERFLOW 0xA7 2491713e81bSScott Long 2501713e81bSScott Long /* 2511713e81bSScott Long * IDE command definitions ( for ATAPI ) 2521713e81bSScott Long */ 2531713e81bSScott Long 2541713e81bSScott Long #define IDE_COMMAND_ATAPI_RESET 0x08 /* Atapi Software Reset command */ 2551713e81bSScott Long #define IDE_COMMAND_ATAPI_PACKET 0xA0 /* Atapi Identify command */ 2561713e81bSScott Long #define IDE_COMMAND_ATAPI_IDENTIFY 0xA1 /* Atapi Packet Command */ 2571713e81bSScott Long 2581713e81bSScott Long 2591713e81bSScott Long /* 2601713e81bSScott Long * ATAPI command definitions 2611713e81bSScott Long */ 2621713e81bSScott Long 2631713e81bSScott Long #define ATAPI_TEST_UNIT_READY 0x00 2641713e81bSScott Long #define ATAPI_REZERO_UNIT 0x01 2651713e81bSScott Long #define ATAPI_REQUEST_SENSE 0x03 2661713e81bSScott Long #define ATAPI_FORMAT_UNIT6 0x04 2671713e81bSScott Long #define ATAPI_FORMAT_UNIT 0x24 2681713e81bSScott Long #define ATAPI_INQUIRY 0x12 2691713e81bSScott Long #define ATAPI_MODE_SELECT 0x15 270d2bd3ab9SScott Long #define ATAPI_RELEASE6 0x17 2711713e81bSScott Long #define ATAPI_MODE_SENSE 0x1A 2721713e81bSScott Long #define ATAPI_START_STOP_UNIT 0x1B 2731713e81bSScott Long #define ATAPI_LOAD_UNLOAD 0x1B 274d2bd3ab9SScott Long #define ATAPI_RECEIVE_DIAGNOSTIC 0x1C 275d2bd3ab9SScott Long #define ATAPI_SEND_DIAGNOSTIC 0x1D 2761713e81bSScott Long #define ATAPI_MEDIUM_REMOVAL 0x1E 277d2bd3ab9SScott Long #define ATAPI_READ_FORMAT_CAPACITY 0x23 2781713e81bSScott Long #define ATAPI_READ_CAPACITY 0x25 2791713e81bSScott Long #define ATAPI_READ 0x28 2801713e81bSScott Long #define ATAPI_WRITE 0x2A 2811713e81bSScott Long #define ATAPI_SEEK 0x2B 282d2bd3ab9SScott Long #define ATAPI_ERASE 0x2C 2831713e81bSScott Long #define ATAPI_VERIFY 0x2F 284d2bd3ab9SScott Long #define ATAPI_WRITE_VERIFY 0x2E 285d2bd3ab9SScott Long #define ATAPI_SYNCHRONIZE_CACHE 0x35 286d2bd3ab9SScott Long #define ATAPI_LOCK_CACHE 0x36 287d2bd3ab9SScott Long #define ATAPI_COMPARE 0x39 288d2bd3ab9SScott Long #define ATAPI_WRITE_BUFFER 0x3B 2891713e81bSScott Long #define ATAPI_READ_DATA_BUFF 0x3C 2901713e81bSScott Long #define ATAPI_READ_SUB_CHANNEL 0x42 2911713e81bSScott Long #define ATAPI_READ_TOC 0x43 2921713e81bSScott Long #define ATAPI_READ_HEADER 0x44 293d2bd3ab9SScott Long #define ATAPI_PLAY_AUDIO10 0x45 2941713e81bSScott Long #define ATAPI_GET_CONFIGURATION 0x46 2951713e81bSScott Long #define ATAPI_PLAY_AUDIO_MSF 0x47 2961713e81bSScott Long #define ATAPI_GET_EVENT_STATUS_NOTIFICATION 0x4A 2971713e81bSScott Long #define ATAPI_PAUSE_RESUME 0x4B 298d2bd3ab9SScott Long #define ATAPI_LOG_SELECT 0x4C 299d2bd3ab9SScott Long #define ATAPI_LOG_SENSE 0x4D 3001713e81bSScott Long #define ATAPI_STOP_PLAY_SCAN 0x4E 3011713e81bSScott Long #define ATAPI_READ_DISK_INFORMATION 0x51 3021713e81bSScott Long #define ATAPI_READ_TRACK_INFORMATION 0x52 303d2bd3ab9SScott Long #define ATAPI_RESERVE_TRACK_RZONE 0x53 304d2bd3ab9SScott Long #define ATAPI_SEND_OPC_INFORMATION 0x54 3051713e81bSScott Long #define ATAPI_MODE_SELECT10 0x55 306d2bd3ab9SScott Long #define ATAPI_RELEASE10 0x57 307d2bd3ab9SScott Long #define ATAPI_REPAIR_ZONE 0x58 3081713e81bSScott Long #define ATAPI_MODE_SENSE10 0x5A 3091713e81bSScott Long #define ATAPI_CLOSE_TRACK_SESSION 0x5B 3101713e81bSScott Long #define ATAPI_READ_BUFFER_CAPACITY 0x5C 311d2bd3ab9SScott Long #define ATAPI_SEND_CUE_SHEET 0x5D 3121713e81bSScott Long #define ATAPI_BLANK_COMMAND 0xA1 /*Provide the ability to erase any part of a CD-RW disc.*/ 313d2bd3ab9SScott Long #define ATAPI_SEND_EVENT 0xA2 /* add for DVD */ 314d2bd3ab9SScott Long #define ATAPI_SEND_KEY 0xA3 /* add for DVD */ 3151713e81bSScott Long #define ATAPI_REPORT_KEY 0xA4 3161713e81bSScott Long #define ATAPI_PLAY_AUDIO 0xA5 317d2bd3ab9SScott Long #define ATAPI_LOAD_UNLOAD_MEDIUM 0xA6 318d2bd3ab9SScott Long #define ATAPI_SET_READ_AHEAD 0xA7 3191713e81bSScott Long #define ATAPI_READ12 0xA8 3201713e81bSScott Long #define ATAPI_READ_DVD_STRUCTURE 0xAD 321d2bd3ab9SScott Long #define ATAPI_WRITE12 0xAA 322d2bd3ab9SScott Long #define ATAPI_GET_PERFORM_NOTIFICATION 0xAC /* add for DVD-RW */ 323d2bd3ab9SScott Long #define ATAPI_SET_STREAM 0xB6 /* add for DVD-RW */ 3241713e81bSScott Long #define ATAPI_READ_CD_MSF 0xB9 325d2bd3ab9SScott Long #define ATAPI_SCAN 0xBA 326d2bd3ab9SScott Long #define ATAPI_SET_SPEED 0xBB /* no payload */ 3271713e81bSScott Long #define ATAPI_MECHANISM_STATUS 0xBD 3281713e81bSScott Long #define ATAPI_READ_CD 0xBE 329d2bd3ab9SScott Long #define ATAPI_SEND_DVD_STRUCTURE 0xBF 3301713e81bSScott Long #define ATAPI_SET_CDRW_SPEED 0xDA /*WindowsXP need*/ 3311713e81bSScott Long 3321713e81bSScott Long #define MODE_DSP_WRITE_PROTECT 0x80 3331713e81bSScott Long 3341713e81bSScott Long 3351713e81bSScott Long /*************************************************************************** 3361713e81bSScott Long * ATAPI IO Register File 3371713e81bSScott Long ***************************************************************************/ 3381713e81bSScott Long 3391713e81bSScott Long 3401713e81bSScott Long typedef struct _ATAPI_REGISTERS_2 { 3411713e81bSScott Long UCHAR AlternateStatus; 3421713e81bSScott Long } ATAPI_REGISTERS_2, *PATAPI_REGISTERS_2; 3431713e81bSScott Long 3441713e81bSScott Long 3451713e81bSScott Long /*************************************************************************** 3461713e81bSScott Long * ATAPI packets 3471713e81bSScott Long ***************************************************************************/ 3481713e81bSScott Long typedef struct _ATAPI_SENSE_DATA { 3491713e81bSScott Long #ifdef __BIG_ENDIAN_BITFIELD 3501713e81bSScott Long UCHAR Valid:1; 3511713e81bSScott Long UCHAR ErrorCode:7; 3521713e81bSScott Long UCHAR SegmentNumber; 3531713e81bSScott Long UCHAR FileMark:1; 3541713e81bSScott Long UCHAR EndOfMedia:1; 3551713e81bSScott Long UCHAR IncorrectLength:1; 3561713e81bSScott Long UCHAR Reserved:1; 3571713e81bSScott Long UCHAR SenseKey:4; 3581713e81bSScott Long #else 3591713e81bSScott Long UCHAR ErrorCode:7; 3601713e81bSScott Long UCHAR Valid:1; 3611713e81bSScott Long UCHAR SegmentNumber; 3621713e81bSScott Long UCHAR SenseKey:4; 3631713e81bSScott Long UCHAR Reserved:1; 3641713e81bSScott Long UCHAR IncorrectLength:1; 3651713e81bSScott Long UCHAR EndOfMedia:1; 3661713e81bSScott Long UCHAR FileMark:1; 3671713e81bSScott Long #endif 3681713e81bSScott Long UCHAR Information[4]; 3691713e81bSScott Long UCHAR AdditionalSenseLength; 3701713e81bSScott Long UCHAR CommandSpecificInformation[4]; 3711713e81bSScott Long UCHAR AdditionalSenseCode; 3721713e81bSScott Long UCHAR AdditionalSenseCodeQualifier; 3731713e81bSScott Long UCHAR FieldReplaceableUnitCode; 3741713e81bSScott Long UCHAR SenseKeySpecific[3]; 3751713e81bSScott Long } ATAPI_SENSE_DATA, *PATAPI_SENSE_DATA; 3761713e81bSScott Long 3771713e81bSScott Long /* 3781713e81bSScott Long * IDENTIFY data 3791713e81bSScott Long */ 3801713e81bSScott Long typedef struct _IDENTIFY_DATA { 3811713e81bSScott Long USHORT GeneralConfiguration; /* 00 00 */ 3821713e81bSScott Long USHORT NumberOfCylinders; /* 02 1 */ 3831713e81bSScott Long USHORT Reserved1; /* 04 2 */ 3841713e81bSScott Long USHORT NumberOfHeads; /* 06 3 */ 3851713e81bSScott Long USHORT UnformattedBytesPerTrack; /* 08 4 */ 3861713e81bSScott Long USHORT UnformattedBytesPerSector; /* 0A 5 */ 3871713e81bSScott Long USHORT SectorsPerTrack; /* 0C 6 */ 3881713e81bSScott Long USHORT VendorUnique1[3]; /* 0E 7-9 */ 3891713e81bSScott Long USHORT SerialNumber[10]; /* 14 10-19 */ 3901713e81bSScott Long USHORT BufferType; /* 28 20 */ 3911713e81bSScott Long USHORT BufferSectorSize; /* 2A 21 */ 3921713e81bSScott Long USHORT NumberOfEccBytes; /* 2C 22 */ 3931713e81bSScott Long USHORT FirmwareRevision[4]; /* 2E 23-26 */ 3941713e81bSScott Long USHORT ModelNumber[20]; /* 36 27-46 */ 3951713e81bSScott Long UCHAR MaximumBlockTransfer; /* 5E 47 */ 3961713e81bSScott Long UCHAR VendorUnique2; /* 5F */ 3971713e81bSScott Long USHORT DoubleWordIo; /* 60 48 */ 3981713e81bSScott Long USHORT Capabilities; /* 62 49 */ 3991713e81bSScott Long USHORT Reserved2; /* 64 50 */ 4001713e81bSScott Long UCHAR VendorUnique3; /* 66 51 */ 4011713e81bSScott Long UCHAR PioCycleTimingMode; /* 67 */ 4021713e81bSScott Long UCHAR VendorUnique4; /* 68 52 */ 4031713e81bSScott Long UCHAR DmaCycleTimingMode; /* 69 */ 4041713e81bSScott Long USHORT TranslationFieldsValid; /* 6A 53 */ 4051713e81bSScott Long USHORT NumberOfCurrentCylinders; /* 6C 54 */ 4061713e81bSScott Long USHORT NumberOfCurrentHeads; /* 6E 55 */ 4071713e81bSScott Long USHORT CurrentSectorsPerTrack; /* 70 56 */ 4081713e81bSScott Long ULONG CurrentSectorCapacity; /* 72 57-58 */ 4091713e81bSScott Long USHORT CurrentMultiSectorSetting; /* 76 59 */ 4101713e81bSScott Long ULONG UserAddressableSectors; /* 78 60-61 */ 4111713e81bSScott Long UCHAR SingleWordDMASupport; /* 7C 62 */ 4121713e81bSScott Long UCHAR SingleWordDMAActive; /* 7D */ 4131713e81bSScott Long UCHAR MultiWordDMASupport; /* 7E 63 */ 4141713e81bSScott Long UCHAR MultiWordDMAActive; /* 7F */ 4151713e81bSScott Long UCHAR AdvancedPIOModes; /* 80 64 */ 4161713e81bSScott Long UCHAR Reserved4; /* 81 */ 4171713e81bSScott Long USHORT MinimumMWXferCycleTime; /* 82 65 */ 4181713e81bSScott Long USHORT RecommendedMWXferCycleTime; /* 84 66 */ 4191713e81bSScott Long USHORT MinimumPIOCycleTime; /* 86 67 */ 4201713e81bSScott Long USHORT MinimumPIOCycleTimeIORDY; /* 88 68 */ 4211713e81bSScott Long USHORT Reserved5[2]; /* 8A 69-70 */ 4221713e81bSScott Long USHORT ReleaseTimeOverlapped; /* 8E 71 */ 4231713e81bSScott Long USHORT ReleaseTimeServiceCommand; /* 90 72 */ 4241713e81bSScott Long USHORT MajorRevision; /* 92 73 */ 4251713e81bSScott Long USHORT MinorRevision; /* 94 74 */ 4261713e81bSScott Long USHORT MaxQueueDepth; /* 96 75 */ 4271713e81bSScott Long USHORT SataCapability; /* 76 */ 4281713e81bSScott Long USHORT Reserved6[9]; /* 98 77-85 */ 4291713e81bSScott Long USHORT CommandSupport; /* 86 */ 4301713e81bSScott Long USHORT CommandEnable; /* 87 */ 4311713e81bSScott Long USHORT UtralDmaMode; /* 88 */ 4321713e81bSScott Long USHORT Reserved7[11]; /* 89-99 */ 4331713e81bSScott Long ULONG Lba48BitLow; /* 101-100 */ 4341713e81bSScott Long ULONG Lba48BitHigh; /* 103-102 */ 4351713e81bSScott Long USHORT Reserved8[23]; /* 104-126 */ 4361713e81bSScott Long USHORT SpecialFunctionsEnabled; /* 127 */ 4371713e81bSScott Long USHORT Reserved9[128]; /* 128-255 */ 4381713e81bSScott Long 4391713e81bSScott Long } IDENTIFY_DATA, *PIDENTIFY_DATA; 4401713e81bSScott Long 4411713e81bSScott Long typedef struct _CONFIGURATION_IDENTIFY_DATA { 4421713e81bSScott Long USHORT Revision; 4431713e81bSScott Long USHORT MWDMAModeSupported; 4441713e81bSScott Long USHORT UDMAModeSupported; 4451713e81bSScott Long ULONG MaximumLbaLow; 4461713e81bSScott Long ULONG MaximumLbaHigh; 4471713e81bSScott Long USHORT CommandSupport; 4481713e81bSScott Long USHORT Reserved[247]; 4491713e81bSScott Long UCHAR Signature; /* 0xA5 */ 4501713e81bSScott Long UCHAR CheckSum; 4511713e81bSScott Long } 4521713e81bSScott Long CONFIGURATION_IDENTIFY_DATA, *PCONFIGURATION_IDENTIFY_DATA; 4531713e81bSScott Long 4541713e81bSScott Long /* */ 4551713e81bSScott Long /* Identify data without the Reserved4. */ 4561713e81bSScott Long /* */ 4571713e81bSScott Long typedef struct _IDENTIFY_DATA2 { 4581713e81bSScott Long USHORT GeneralConfiguration; /* 00 00 */ 4591713e81bSScott Long USHORT NumberOfCylinders; /* 02 1 */ 4601713e81bSScott Long USHORT Reserved1; /* 04 2 */ 4611713e81bSScott Long USHORT NumberOfHeads; /* 06 3 */ 4621713e81bSScott Long USHORT UnformattedBytesPerTrack; /* 08 4 */ 4631713e81bSScott Long USHORT UnformattedBytesPerSector; /* 0A 5 */ 4641713e81bSScott Long USHORT SectorsPerTrack; /* 0C 6 */ 4651713e81bSScott Long USHORT VendorUnique1[3]; /* 0E 7-9 */ 4661713e81bSScott Long USHORT SerialNumber[10]; /* 14 10-19 */ 4671713e81bSScott Long USHORT BufferType; /* 28 20 */ 4681713e81bSScott Long USHORT BufferSectorSize; /* 2A 21 */ 4691713e81bSScott Long USHORT NumberOfEccBytes; /* 2C 22 */ 4701713e81bSScott Long USHORT FirmwareRevision[4]; /* 2E 23-26 */ 4711713e81bSScott Long USHORT ModelNumber[20]; /* 36 27-46 */ 4721713e81bSScott Long UCHAR MaximumBlockTransfer; /* 5E 47 */ 4731713e81bSScott Long UCHAR VendorUnique2; /* 5F */ 4741713e81bSScott Long USHORT DoubleWordIo; /* 60 48 */ 4751713e81bSScott Long USHORT Capabilities; /* 62 49 */ 4761713e81bSScott Long USHORT Reserved2; /* 64 50 */ 4771713e81bSScott Long UCHAR VendorUnique3; /* 66 51 */ 4781713e81bSScott Long UCHAR PioCycleTimingMode; /* 67 */ 4791713e81bSScott Long UCHAR VendorUnique4; /* 68 52 */ 4801713e81bSScott Long UCHAR DmaCycleTimingMode; /* 69 */ 4811713e81bSScott Long USHORT TranslationFieldsValid; /* 6A 53 */ 4821713e81bSScott Long USHORT NumberOfCurrentCylinders; /* 6C 54 */ 4831713e81bSScott Long USHORT NumberOfCurrentHeads; /* 6E 55 */ 4841713e81bSScott Long USHORT CurrentSectorsPerTrack; /* 70 56 */ 4851713e81bSScott Long ULONG CurrentSectorCapacity; /* 72 57-58 */ 4861713e81bSScott Long USHORT CurrentMultiSectorSetting; /* 59 */ 4871713e81bSScott Long ULONG UserAddressableSectors; /* 60-61 */ 4881713e81bSScott Long UCHAR SingleWordDMASupport; /* 62 */ 4891713e81bSScott Long UCHAR SingleWordDMAActive; 4901713e81bSScott Long UCHAR MultiWordDMASupport; /* 63 */ 4911713e81bSScott Long UCHAR MultiWordDMAActive; 4921713e81bSScott Long UCHAR AdvancedPIOModes; /* 64 */ 4931713e81bSScott Long UCHAR Reserved4; 4941713e81bSScott Long USHORT MinimumMWXferCycleTime; /* 65 */ 4951713e81bSScott Long USHORT RecommendedMWXferCycleTime; /* 66 */ 4961713e81bSScott Long USHORT MinimumPIOCycleTime; /* 67 */ 4971713e81bSScott Long USHORT MinimumPIOCycleTimeIORDY; /* 68 */ 4981713e81bSScott Long USHORT Reserved5[2]; /* 69-70 */ 4991713e81bSScott Long USHORT ReleaseTimeOverlapped; /* 71 */ 5001713e81bSScott Long USHORT ReleaseTimeServiceCommand; /* 72 */ 5011713e81bSScott Long USHORT MajorRevision; /* 73 */ 5021713e81bSScott Long USHORT MinorRevision; /* 74 */ 5031713e81bSScott Long /* USHORT Reserved6[14]; // 75-88 */ 5041713e81bSScott Long } IDENTIFY_DATA2, *PIDENTIFY_DATA2; 5051713e81bSScott Long 5061713e81bSScott Long #define IDENTIFY_DATA_SIZE sizeof(IDENTIFY_DATA2) 5071713e81bSScott Long 5081713e81bSScott Long /* */ 5091713e81bSScott Long /* IDENTIFY DMA timing cycle modes. */ 5101713e81bSScott Long /* */ 5111713e81bSScott Long 5121713e81bSScott Long #define IDENTIFY_DMA_CYCLES_MODE_0 0x00 5131713e81bSScott Long #define IDENTIFY_DMA_CYCLES_MODE_1 0x01 5141713e81bSScott Long #define IDENTIFY_DMA_CYCLES_MODE_2 0x02 5151713e81bSScott Long 5161713e81bSScott Long /* 5171713e81bSScott Long * Mode definitions 5181713e81bSScott Long */ 5191713e81bSScott Long typedef enum _DISK_MODE 5201713e81bSScott Long { 5211713e81bSScott Long IDE_PIO_0 = 0, 5221713e81bSScott Long IDE_PIO_1, 5231713e81bSScott Long IDE_PIO_2, 5241713e81bSScott Long IDE_PIO_3, 5251713e81bSScott Long IDE_PIO_4, 5261713e81bSScott Long IDE_MWDMA_0, 5271713e81bSScott Long IDE_MWDMA_1, 5281713e81bSScott Long IDE_MWDMA_2, 5291713e81bSScott Long IDE_UDMA_0, 5301713e81bSScott Long IDE_UDMA_1, 5311713e81bSScott Long IDE_UDMA_2, 5321713e81bSScott Long IDE_UDMA_3, 5331713e81bSScott Long IDE_UDMA_4, 5341713e81bSScott Long IDE_UDMA_5, 5351713e81bSScott Long IDE_UDMA_6, 5361713e81bSScott Long IDE_UDMA_7, 5371713e81bSScott Long } DISK_MODE; 5381713e81bSScott Long 5391713e81bSScott Long /*************************************************************************** 5401713e81bSScott Long * IDE Macro 5411713e81bSScott Long ***************************************************************************/ 5421713e81bSScott Long #ifndef MAX_LBA_T 5431713e81bSScott Long #define MAX_LBA_T ((LBA_T)-1) 5441713e81bSScott Long #endif 5451713e81bSScott Long 5461713e81bSScott Long #define SECTOR_TO_BYTE_SHIFT 9 5471713e81bSScott Long #define SECTOR_TO_BYTE(x) ((ULONG)(x) << SECTOR_TO_BYTE_SHIFT) 5481713e81bSScott Long 5491713e81bSScott Long #define mGetStatus(IOPort2) (UCHAR)InPort(&IOPort2->AlternateStatus) 5501713e81bSScott Long #define mUnitControl(IOPort2, Value) OutPort(&IOPort2->AlternateStatus,(UCHAR)(Value)) 5511713e81bSScott Long 5521713e81bSScott Long #define mGetErrorCode(IOPort) (UCHAR)InPort((PUCHAR)&IOPort->Data+1) 5531713e81bSScott Long #define mSetFeaturePort(IOPort,x) OutPort((PUCHAR)&IOPort->Data+1, x) 5541713e81bSScott Long #define mSetBlockCount(IOPort,x) OutPort(&IOPort->BlockCount, x) 5551713e81bSScott Long #define mGetBlockCount(IOPort) (UCHAR)InPort(&IOPort->BlockCount) 5561713e81bSScott Long #define mGetInterruptReason(IOPort) (UCHAR)InPort(&IOPort->BlockCount) 5571713e81bSScott Long #define mSetBlockNumber(IOPort,x) OutPort(&IOPort->BlockNumber, x) 5581713e81bSScott Long #define mGetBlockNumber(IOPort) (UCHAR)InPort((PUCHAR)&IOPort->BlockNumber) 5591713e81bSScott Long #define mGetByteLow(IOPort) (UCHAR)InPort(&IOPort->CylinderLow) 5601713e81bSScott Long #define mSetCylinderLow(IOPort,x) OutPort(&IOPort->CylinderLow, x) 5611713e81bSScott Long #define mGetByteHigh(IOPort) (UCHAR)InPort(&IOPort->CylinderHigh) 5621713e81bSScott Long #define mSetCylinderHigh(IOPort,x) OutPort(&IOPort->CylinderHigh, x) 5631713e81bSScott Long #define mGetBaseStatus(IOPort) (UCHAR)InPort(&IOPort->Command) 5641713e81bSScott Long #ifdef SUPPORT_HPT601 5651713e81bSScott Long #define mSelectUnit(IOPort,UnitId) do {\ 5661713e81bSScott Long OutPort(&IOPort->DriveSelect, (UCHAR)(UnitId));\ 5671713e81bSScott Long OutPort(&IOPort->DriveSelect, (UCHAR)(UnitId));\ 5681713e81bSScott Long } while (0) 5691713e81bSScott Long #else 5701713e81bSScott Long #define mSelectUnit(IOPort,UnitId) OutPort(&IOPort->DriveSelect, (UCHAR)(UnitId)) 5711713e81bSScott Long #endif 5721713e81bSScott Long #define mGetUnitNumber(IOPort) InPort(&IOPort->DriveSelect) 5731713e81bSScott Long #define mIssueCommand(IOPort,Cmd) OutPort(&IOPort->Command, (UCHAR)(Cmd)) 5741713e81bSScott Long 5751713e81bSScott Long /* 5761713e81bSScott Long * WDC old disk, don't care right now 5771713e81bSScott Long */ 5781713e81bSScott Long #define WDC_MW1_FIX_FLAG_OFFSET 129 5791713e81bSScott Long #define WDC_MW1_FIX_FLAG_VALUE 0x00005555 5801713e81bSScott Long 5811713e81bSScott Long #pragma pack() 5821713e81bSScott Long #endif 5831713e81bSScott Long 5841713e81bSScott Long 5851713e81bSScott Long 586