atapi.h revision 136849
1136849Sscottl/*
2136849Sscottl * Copyright (c) 2003-2004 HighPoint Technologies, Inc.
3136849Sscottl * All rights reserved.
4136849Sscottl *
5136849Sscottl * Redistribution and use in source and binary forms, with or without
6136849Sscottl * modification, are permitted provided that the following conditions
7136849Sscottl * are met:
8136849Sscottl * 1. Redistributions of source code must retain the above copyright
9136849Sscottl *    notice, this list of conditions and the following disclaimer.
10136849Sscottl * 2. Redistributions in binary form must reproduce the above copyright
11136849Sscottl *    notice, this list of conditions and the following disclaimer in the
12136849Sscottl *    documentation and/or other materials provided with the distribution.
13136849Sscottl *
14136849Sscottl * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15136849Sscottl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16136849Sscottl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17136849Sscottl * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18136849Sscottl * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19136849Sscottl * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20136849Sscottl * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21136849Sscottl * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22136849Sscottl * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23136849Sscottl * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24136849Sscottl * SUCH DAMAGE.
25136849Sscottl */
26136849Sscottl
27136849Sscottl#ifndef _ATAPI_H_
28136849Sscottl#define _ATAPI_H_
29136849Sscottl
30136849Sscottl#pragma pack(1)
31136849Sscottl
32136849Sscottl/***************************************************************************
33136849Sscottl *            IDE IO Register File
34136849Sscottl ***************************************************************************/
35136849Sscottl
36136849Sscottl/*
37136849Sscottl * IDE IO Port definition
38136849Sscottl */
39136849Sscottltypedef struct _IDE_REGISTERS_1 {
40136849Sscottl    USHORT Data;               /* RW: Data port feature register      */
41136849Sscottl    UCHAR BlockCount;          /* RW: Sector count               */
42136849Sscottl    UCHAR BlockNumber;         /* RW: Sector number & LBA 0-7    */
43136849Sscottl    UCHAR CylinderLow;         /* RW: Cylinder low & LBA 8-15    */
44136849Sscottl    UCHAR CylinderHigh;        /* RW: Cylinder hign & LBA 16-23  */
45136849Sscottl    UCHAR DriveSelect;         /* RW: Drive/head & LBA 24-27     */
46136849Sscottl    UCHAR Command;             /* RO: Status WR:Command          */
47136849Sscottl} IDE_REGISTERS_1, *PIDE_REGISTERS_1;
48136849Sscottl
49136849Sscottl
50136849Sscottl/*
51136849Sscottl * IDE status definitions
52136849Sscottl */
53136849Sscottl#define IDE_STATUS_ERROR             0x01 /* Error Occurred in Execution    */
54136849Sscottl#define IDE_STATUS_INDEX             0x02 /* is vendor specific             */
55136849Sscottl#define IDE_STATUS_CORRECTED_ERROR   0x04 /* Corrected Data                 */
56136849Sscottl#define IDE_STATUS_DRQ               0x08 /* Ready to transfer data         */
57136849Sscottl#define IDE_STATUS_DSC               0x10 /* not defined in ATA-2           */
58136849Sscottl#define IDE_STATUS_DWF               0x20 /* Device Fault has been detected */
59136849Sscottl#define IDE_STATUS_DRDY              0x40 /* Device Ready to accept command */
60136849Sscottl#define IDE_STATUS_IDLE              0x50 /* Device is OK                   */
61136849Sscottl#define IDE_STATUS_BUSY              0x80 /* Device Busy, must wait         */
62136849Sscottl
63136849Sscottl
64136849Sscottl#define IDE_ERROR_BAD_BLOCK          0x80 /* Reserved now                   */
65136849Sscottl#define IDE_ERROR_DATA_ERROR         0x40 /* Uncorreectable  Data Error     */
66136849Sscottl#define IDE_ERROR_MEDIA_CHANGE       0x20 /* Media Changed                  */
67136849Sscottl#define IDE_ERROR_ID_NOT_FOUND       0x10 /* ID Not Found                   */
68136849Sscottl#define IDE_ERROR_MEDIA_CHANGE_REQ   0x08 /* Media Change Requested         */
69136849Sscottl#define IDE_ERROR_COMMAND_ABORTED    0x04 /* Aborted Command                */
70136849Sscottl#define IDE_ERROR_TRACK0_NOT_FOUND   0x02 /* Track 0 Not Found              */
71136849Sscottl#define IDE_ERROR_ADDRESS_NOT_FOUND  0x01 /* Address Mark Not Found         */
72136849Sscottl
73136849Sscottl
74136849Sscottl#define LBA_MODE                     0x40
75136849Sscottl
76136849Sscottl/*
77136849Sscottl * IDE command definitions
78136849Sscottl */
79136849Sscottl
80136849Sscottl#define IDE_COMMAND_RECALIBRATE      0x10 /* Recalibrate                    */
81136849Sscottl#define IDE_COMMAND_READ             0x20 /* Read Sectors with retry        */
82136849Sscottl#define IDE_COMMAND_WRITE            0x30 /* Write Sectors with retry       */
83136849Sscottl#define IDE_COMMAND_VERIFY           0x40 /* Read Verify Sectors with Retry */
84136849Sscottl#define IDE_COMMAND_SEEK             0x70 /* Seek                           */
85136849Sscottl#define IDE_COMMAND_SET_DRIVE_PARAMETER   0x91 /* Initialize Device Parmeters */
86136849Sscottl#define IDE_COMMAND_GET_MEDIA_STATUS 0xDA
87136849Sscottl#define IDE_COMMAND_DOOR_LOCK        0xDE /* Door Lock                      */
88136849Sscottl#define IDE_COMMAND_DOOR_UNLOCK      0xDF /* Door Unlock                          */
89136849Sscottl#define IDE_COMMAND_ENABLE_MEDIA_STATUS   0xEF /* Set Features              */
90136849Sscottl#define IDE_COMMAND_IDENTIFY         0xEC /* Identify Device                */
91136849Sscottl#define IDE_COMMAND_MEDIA_EJECT      0xED
92136849Sscottl#define IDE_COMMAND_SET_FEATURES     0xEF /* IDE set features command       */
93136849Sscottl
94136849Sscottl#define IDE_COMMAND_FLUSH_CACHE      0xE7
95136849Sscottl#define IDE_COMMAND_STANDBY_IMMEDIATE 0xE0
96136849Sscottl
97136849Sscottl#ifndef NOT_SUPPORT_MULTIPLE
98136849Sscottl#define IDE_COMMAND_READ_MULTIPLE    0xC4 /* Read Multiple                  */
99136849Sscottl#define IDE_COMMAND_WRITE_MULTIPLE   0xC5 /* Write Multiple                 */
100136849Sscottl#define IDE_COMMAND_SET_MULTIPLE     0xC6 /* Set Multiple Mode              */
101136849Sscottl#endif
102136849Sscottl
103136849Sscottl#ifndef NOT_SUPPORT_DMA
104136849Sscottl#define IDE_COMMAND_DMA_READ        0xc8  /* IDE DMA read command           */
105136849Sscottl#define IDE_COMMAND_DMA_WRITE       0xca  /* IDE DMA write command          */
106136849Sscottl#endif
107136849Sscottl
108136849Sscottl#define IDE_COMMAND_READ_DMA_QUEUE   0xc7 /* IDE read DMA queue command     */
109136849Sscottl#define IDE_COMMAND_WRITE_DMA_QUEUE  0xcc /* IDE write DMA queue command    */
110136849Sscottl#define IDE_COMMAND_SERVICE          0xA2 /* IDE service command command    */
111136849Sscottl#define IDE_COMMAND_NOP              0x00 /* IDE NOP command                */
112136849Sscottl#define IDE_STATUS_SRV               0x10
113136849Sscottl#define IDE_RELEASE_BUS              4
114136849Sscottl
115136849Sscottl/*#define IDE_COMMAND_FLUSH_CACHE_EXT */
116136849Sscottl#define IDE_COMMAND_READ_DMA_EXT       	0x25
117136849Sscottl#define IDE_COMMAND_READ_QUEUE_EXT		0x26
118136849Sscottl#define IDE_COMMAND_READ_MULTIPLE_EXT	0x29
119136849Sscottl#define IDE_COMMAND_READ_MAX_ADDR		0x27
120136849Sscottl#define IDE_COMMAND_READ_EXT			0x24
121136849Sscottl#define IDE_COMMAND_VERIFY_EXT			0x42
122136849Sscottl#define IDE_COMMAND_SET_MULTIPLE_EXT	0x37
123136849Sscottl#define IDE_COMMAND_WRITE_DMA_EXT		0x35
124136849Sscottl#define IDE_COMMAND_WRITE_QUEUE_EXT		0x36
125136849Sscottl#define IDE_COMMAND_WRITE_EXT			0x34
126136849Sscottl#define IDE_COMMAND_WRITE_MULTIPLE_EXT	0x39
127136849Sscottl
128136849Sscottl/*
129136849Sscottl * IDE_COMMAND_SET_FEATURES
130136849Sscottl */
131136849Sscottl#define FT_USE_ULTRA        0x40    /* Set feature for Ultra DMA           */
132136849Sscottl#define FT_USE_MWDMA        0x20    /* Set feature for MW DMA              */
133136849Sscottl#define FT_USE_SWDMA        0x10    /* Set feature for SW DMA              */
134136849Sscottl#define FT_USE_PIO          0x8     /* Set feature for PIO                 */
135136849Sscottl#define FT_DISABLE_IORDY    0x10    /* Set feature for disabling IORDY     */
136136849Sscottl
137136849Sscottl/*
138136849Sscottl * S.M.A.R.T. commands
139136849Sscottl */
140136849Sscottl#define IDE_COMMAND_SMART       0xB0
141136849Sscottl#define SMART_READ_VALUES       0xd0
142136849Sscottl#define SMART_READ_THRESHOLDS   0xd1
143136849Sscottl#define SMART_AUTOSAVE          0xd2
144136849Sscottl#define SMART_SAVE              0xd3
145136849Sscottl#define SMART_IMMEDIATE_OFFLINE 0xd4
146136849Sscottl#define SMART_READ_LOG_SECTOR   0xd5
147136849Sscottl#define SMART_WRITE_LOG_SECTOR  0xd6
148136849Sscottl#define SMART_ENABLE            0xd8
149136849Sscottl#define SMART_DISABLE           0xd9
150136849Sscottl#define SMART_STATUS            0xda
151136849Sscottl#define SMART_AUTO_OFFLINE      0xdb
152136849Sscottl
153136849Sscottl /***************************************************************************
154136849Sscottl *            IDE Control Register File
155136849Sscottl ***************************************************************************/
156136849Sscottl
157136849Sscottltypedef struct _IDE_REGISTERS_2 {
158136849Sscottl    UCHAR AlternateStatus;     /* RW: device control port        */
159136849Sscottl} IDE_REGISTERS_2, *PIDE_REGISTERS_2;
160136849Sscottl
161136849Sscottl
162136849Sscottl/*
163136849Sscottl * IDE drive control definitions
164136849Sscottl */
165136849Sscottl#define IDE_DC_DISABLE_INTERRUPTS    0x02
166136849Sscottl#define IDE_DC_RESET_CONTROLLER      0x04
167136849Sscottl#define IDE_DC_REENABLE_CONTROLLER   0x00
168136849Sscottl
169136849Sscottl/***************************************************************************
170136849Sscottl *   MSNS:   Removable device
171136849Sscottl ***************************************************************************/
172136849Sscottl/*
173136849Sscottl * Media syatus
174136849Sscottl */
175136849Sscottl#define MSNS_NO_MEDIA             2
176136849Sscottl#define MSNS_MEDIA_CHANGE_REQUEST 8
177136849Sscottl#define MSNS_MIDIA_CHANGE         0x20
178136849Sscottl#define MSNS_WRITE_PROTECT        0x40
179136849Sscottl#define MSNS_READ_PROTECT         0x80
180136849Sscottl
181136849Sscottl/***************************************************************************
182136849Sscottl *            ATAPI IO Register File
183136849Sscottl ***************************************************************************/
184136849Sscottl
185136849Sscottl/*
186136849Sscottl * ATAPI register definition
187136849Sscottl */
188136849Sscottl
189136849Sscottltypedef struct _ATAPI_REGISTERS_1 {
190136849Sscottl    USHORT Data;
191136849Sscottl    UCHAR InterruptReason;         	/* Atapi Phase Port               */
192136849Sscottl    UCHAR Unused1;
193136849Sscottl    UCHAR ByteCountLow;        		/* Byte Count LSB                 */
194136849Sscottl    UCHAR ByteCountHigh;         	/* Byte Count MSB                 */
195136849Sscottl    UCHAR DriveSelect;
196136849Sscottl    UCHAR Command;
197136849Sscottl} ATAPI_REGISTERS_1, *PATAPI_REGISTERS_1;
198136849Sscottl
199136849Sscottl/*
200136849Sscottl *    Atapi Error Status
201136849Sscottl */
202136849Sscottl#define IDE_ERROR_END_OF_MEDIA       IDE_ERROR_TRACK0_NOT_FOUND
203136849Sscottl#define IDE_ERROR_ILLEGAL_LENGTH     IDE_ERROR_ADDRESS_NOT_FOUND
204136849Sscottl
205136849Sscottl/*
206136849Sscottl * ATAPI interrupt reasons
207136849Sscottl */
208136849Sscottl#define ATAPI_IR_COD 0x01
209136849Sscottl#define ATAPI_IR_IO  0x02
210136849Sscottl
211136849Sscottl/* sense key */
212136849Sscottl#define ATAPI_SENSE_NO_SENSE         0x00
213136849Sscottl#define ATAPI_SENSE_RECOVERED_ERROR  0x01
214136849Sscottl#define ATAPI_SENSE_NOT_READY        0x02
215136849Sscottl#define ATAPI_SENSE_MEDIUM_ERROR     0x03
216136849Sscottl#define ATAPI_SENSE_HARDWARE_ERROR   0x04
217136849Sscottl#define ATAPI_SENSE_ILLEGAL_REQUEST  0x05
218136849Sscottl#define ATAPI_SENSE_UNIT_ATTENTION   0x06
219136849Sscottl#define ATAPI_SENSE_DATA_PROTECT     0x07
220136849Sscottl#define ATAPI_SENSE_BLANK_CHECK      0x08
221136849Sscottl#define ATAPI_SENSE_UNIQUE           0x09
222136849Sscottl#define ATAPI_SENSE_COPY_ABORTED     0x0A
223136849Sscottl#define ATAPI_SENSE_ABORTED_COMMAND  0x0B
224136849Sscottl#define ATAPI_SENSE_EQUAL            0x0C
225136849Sscottl#define ATAPI_SENSE_VOL_OVERFLOW     0x0D
226136849Sscottl#define ATAPI_SENSE_MISCOMPARE       0x0E
227136849Sscottl#define ATAPI_SENSE_RESERVED         0x0F
228136849Sscottl
229136849Sscottl/* Additional Sense codes */
230136849Sscottl#define ATAPI_ASC_NO_SENSE           0x00
231136849Sscottl#define ATAPI_ASC_LUN_NOT_READY      0x04
232136849Sscottl#define ATAPI_ASC_TRACK_ERROR        0x14
233136849Sscottl#define ATAPI_ASC_SEEK_ERROR         0x15
234136849Sscottl#define ATAPI_ASC_REC_DATA_NOECC     0x17
235136849Sscottl#define ATAPI_ASC_REC_DATA_ECC       0x18
236136849Sscottl#define ATAPI_ASC_ILLEGAL_COMMAND    0x20
237136849Sscottl#define ATAPI_ASC_ILLEGAL_BLOCK      0x21
238136849Sscottl#define ATAPI_ASC_INVALID_CDB        0x24
239136849Sscottl#define ATAPI_ASC_INVALID_LUN        0x25
240136849Sscottl#define ATAPI_ASC_PROTECT            0x27
241136849Sscottl#define ATAPI_ASC_MEDIUM_CHANGED     0x28
242136849Sscottl#define ATAPI_ASC_BUS_RESET          0x29
243136849Sscottl#define ATAPI_ASC_NO_MEDIA_IN_DEVICE 0x3a
244136849Sscottl#define ATAPI_ASC_MUSIC_AREA         0xA0
245136849Sscottl#define ATAPI_ASC_DATA_AREA          0xA1
246136849Sscottl#define ATAPI_ASC_VOLUME_OVERFLOW    0xA7
247136849Sscottl
248136849Sscottl/*
249136849Sscottl * IDE command definitions ( for ATAPI )
250136849Sscottl */
251136849Sscottl
252136849Sscottl#define IDE_COMMAND_ATAPI_RESET      0x08 /* Atapi Software Reset command   */
253136849Sscottl#define IDE_COMMAND_ATAPI_PACKET     0xA0    /* Atapi Identify command         */
254136849Sscottl#define IDE_COMMAND_ATAPI_IDENTIFY   0xA1    /* Atapi Packet Command           */
255136849Sscottl
256136849Sscottl
257136849Sscottl/*
258136849Sscottl * ATAPI command definitions
259136849Sscottl */
260136849Sscottl
261136849Sscottl#define ATAPI_TEST_UNIT_READY     0x00
262136849Sscottl#define ATAPI_REZERO_UNIT         0x01
263136849Sscottl#define ATAPI_REQUEST_SENSE       0x03
264136849Sscottl#define ATAPI_FORMAT_UNIT6        0x04
265136849Sscottl#define ATAPI_FORMAT_UNIT         0x24
266136849Sscottl#define ATAPI_INQUIRY             0x12
267136849Sscottl#define ATAPI_MODE_SELECT         0x15
268136849Sscottl#define ATAPI_MODE_SENSE          0x1A
269136849Sscottl#define ATAPI_START_STOP_UNIT     0x1B
270136849Sscottl#define ATAPI_LOAD_UNLOAD         0x1B
271136849Sscottl#define ATAPI_MEDIUM_REMOVAL      0x1E
272136849Sscottl#define ATAPI_READ_CAPACITY       0x25
273136849Sscottl#define ATAPI_READ                0x28
274136849Sscottl#define ATAPI_WRITE               0x2A
275136849Sscottl#define ATAPI_SEEK                0x2B
276136849Sscottl#define ATAPI_VERIFY              0x2F
277136849Sscottl#define ATAPI_READ_DATA_BUFF      0x3C
278136849Sscottl#define ATAPI_READ_SUB_CHANNEL    0x42
279136849Sscottl#define ATAPI_READ_TOC            0x43
280136849Sscottl#define ATAPI_READ_HEADER         0x44
281136849Sscottl#define ATAPI_GET_CONFIGURATION   0x46
282136849Sscottl#define ATAPI_PLAY_AUDIO_MSF      0x47
283136849Sscottl#define ATAPI_GET_EVENT_STATUS_NOTIFICATION 0x4A
284136849Sscottl#define ATAPI_PAUSE_RESUME        0x4B
285136849Sscottl#define ATAPI_STOP_PLAY_SCAN      0x4E
286136849Sscottl#define ATAPI_READ_DISK_INFORMATION  0x51
287136849Sscottl#define ATAPI_READ_TRACK_INFORMATION 0x52
288136849Sscottl#define ATAPI_MODE_SELECT10       0x55
289136849Sscottl#define ATAPI_MODE_SENSE10        0x5A
290136849Sscottl#define ATAPI_CLOSE_TRACK_SESSION 0x5B
291136849Sscottl#define ATAPI_READ_BUFFER_CAPACITY   0x5C
292136849Sscottl#define ATAPI_BLANK_COMMAND       0xA1 /*Provide the ability to erase any part of a CD-RW disc.*/
293136849Sscottl#define ATAPI_REPORT_KEY          0xA4
294136849Sscottl#define ATAPI_PLAY_AUDIO          0xA5
295136849Sscottl#define ATAPI_READ12              0xA8
296136849Sscottl#define ATAPI_READ_DVD_STRUCTURE  0xAD
297136849Sscottl#define ATAPI_READ_CD_MSF         0xB9
298136849Sscottl#define ATAPI_SET_CD_SPEED        0xBB
299136849Sscottl#define ATAPI_MECHANISM_STATUS    0xBD
300136849Sscottl#define ATAPI_READ_CD             0xBE
301136849Sscottl#define ATAPI_SET_CDRW_SPEED      0xDA /*WindowsXP need*/
302136849Sscottl
303136849Sscottl#define MODE_DSP_WRITE_PROTECT  0x80
304136849Sscottl
305136849Sscottl
306136849Sscottl/***************************************************************************
307136849Sscottl *            ATAPI IO Register File
308136849Sscottl ***************************************************************************/
309136849Sscottl
310136849Sscottl
311136849Sscottltypedef struct _ATAPI_REGISTERS_2 {
312136849Sscottl    UCHAR AlternateStatus;
313136849Sscottl} ATAPI_REGISTERS_2, *PATAPI_REGISTERS_2;
314136849Sscottl
315136849Sscottl
316136849Sscottl/***************************************************************************
317136849Sscottl *            ATAPI packets
318136849Sscottl ***************************************************************************/
319136849Sscottltypedef struct _ATAPI_SENSE_DATA {
320136849Sscottl#ifdef __BIG_ENDIAN_BITFIELD
321136849Sscottl    UCHAR Valid:1;
322136849Sscottl    UCHAR ErrorCode:7;
323136849Sscottl    UCHAR SegmentNumber;
324136849Sscottl    UCHAR FileMark:1;
325136849Sscottl    UCHAR EndOfMedia:1;
326136849Sscottl    UCHAR IncorrectLength:1;
327136849Sscottl    UCHAR Reserved:1;
328136849Sscottl    UCHAR SenseKey:4;
329136849Sscottl#else
330136849Sscottl    UCHAR ErrorCode:7;
331136849Sscottl    UCHAR Valid:1;
332136849Sscottl    UCHAR SegmentNumber;
333136849Sscottl    UCHAR SenseKey:4;
334136849Sscottl    UCHAR Reserved:1;
335136849Sscottl    UCHAR IncorrectLength:1;
336136849Sscottl    UCHAR EndOfMedia:1;
337136849Sscottl    UCHAR FileMark:1;
338136849Sscottl#endif
339136849Sscottl    UCHAR Information[4];
340136849Sscottl    UCHAR AdditionalSenseLength;
341136849Sscottl    UCHAR CommandSpecificInformation[4];
342136849Sscottl    UCHAR AdditionalSenseCode;
343136849Sscottl    UCHAR AdditionalSenseCodeQualifier;
344136849Sscottl    UCHAR FieldReplaceableUnitCode;
345136849Sscottl    UCHAR SenseKeySpecific[3];
346136849Sscottl} ATAPI_SENSE_DATA, *PATAPI_SENSE_DATA;
347136849Sscottl
348136849Sscottl/*
349136849Sscottl * IDENTIFY data
350136849Sscottl */
351136849Sscottltypedef struct _IDENTIFY_DATA {
352136849Sscottl    USHORT GeneralConfiguration;            /* 00 00 */
353136849Sscottl    USHORT NumberOfCylinders;               /* 02  1 */
354136849Sscottl    USHORT Reserved1;                       /* 04  2 */
355136849Sscottl    USHORT NumberOfHeads;                   /* 06  3 */
356136849Sscottl    USHORT UnformattedBytesPerTrack;        /* 08  4 */
357136849Sscottl    USHORT UnformattedBytesPerSector;       /* 0A  5 */
358136849Sscottl    USHORT SectorsPerTrack;                 /* 0C  6 */
359136849Sscottl    USHORT VendorUnique1[3];                /* 0E  7-9 */
360136849Sscottl    USHORT SerialNumber[10];                /* 14  10-19 */
361136849Sscottl    USHORT BufferType;                      /* 28  20 */
362136849Sscottl    USHORT BufferSectorSize;                /* 2A  21 */
363136849Sscottl    USHORT NumberOfEccBytes;                /* 2C  22 */
364136849Sscottl    USHORT FirmwareRevision[4];             /* 2E  23-26 */
365136849Sscottl    USHORT ModelNumber[20];                 /* 36  27-46 */
366136849Sscottl    UCHAR  MaximumBlockTransfer;            /* 5E  47 */
367136849Sscottl    UCHAR  VendorUnique2;                   /* 5F */
368136849Sscottl    USHORT DoubleWordIo;                    /* 60  48 */
369136849Sscottl    USHORT Capabilities;                    /* 62  49 */
370136849Sscottl    USHORT Reserved2;                       /* 64  50 */
371136849Sscottl    UCHAR  VendorUnique3;                   /* 66  51 */
372136849Sscottl    UCHAR  PioCycleTimingMode;              /* 67 */
373136849Sscottl    UCHAR  VendorUnique4;                   /* 68  52 */
374136849Sscottl    UCHAR  DmaCycleTimingMode;              /* 69 */
375136849Sscottl    USHORT TranslationFieldsValid;          /* 6A  53 */
376136849Sscottl    USHORT NumberOfCurrentCylinders;        /* 6C  54 */
377136849Sscottl    USHORT NumberOfCurrentHeads;            /* 6E  55 */
378136849Sscottl    USHORT CurrentSectorsPerTrack;          /* 70  56 */
379136849Sscottl    ULONG  CurrentSectorCapacity;           /* 72  57-58 */
380136849Sscottl    USHORT CurrentMultiSectorSetting;       /* 76  59 */
381136849Sscottl    ULONG  UserAddressableSectors;          /* 78  60-61 */
382136849Sscottl    UCHAR  SingleWordDMASupport;            /* 7C  62 */
383136849Sscottl    UCHAR  SingleWordDMAActive;             /* 7D */
384136849Sscottl    UCHAR  MultiWordDMASupport;         	/* 7E  63 */
385136849Sscottl    UCHAR  MultiWordDMAActive;              /* 7F */
386136849Sscottl    UCHAR  AdvancedPIOModes;                /* 80  64 */
387136849Sscottl    UCHAR  Reserved4;                       /* 81 */
388136849Sscottl    USHORT MinimumMWXferCycleTime;          /* 82  65 */
389136849Sscottl    USHORT RecommendedMWXferCycleTime;      /* 84  66 */
390136849Sscottl    USHORT MinimumPIOCycleTime;             /* 86  67 */
391136849Sscottl    USHORT MinimumPIOCycleTimeIORDY;        /* 88  68 */
392136849Sscottl    USHORT Reserved5[2];                    /* 8A  69-70 */
393136849Sscottl    USHORT ReleaseTimeOverlapped;           /* 8E  71 */
394136849Sscottl    USHORT ReleaseTimeServiceCommand;       /* 90  72 */
395136849Sscottl    USHORT MajorRevision;                   /* 92  73 */
396136849Sscottl    USHORT MinorRevision;                   /* 94  74 */
397136849Sscottl    USHORT MaxQueueDepth;                   /* 96  75 */
398136849Sscottl	USHORT SataCapability;                  /*     76 */
399136849Sscottl    USHORT Reserved6[9];                    /* 98   77-85 */
400136849Sscottl    USHORT CommandSupport;                  /*     86 */
401136849Sscottl    USHORT CommandEnable;                   /*     87 */
402136849Sscottl    USHORT UtralDmaMode;                    /*     88 */
403136849Sscottl    USHORT Reserved7[11];                   /*     89-99 */
404136849Sscottl    ULONG  Lba48BitLow;						/*     101-100 */
405136849Sscottl    ULONG  Lba48BitHigh;					/*     103-102 */
406136849Sscottl    USHORT Reserved8[23];                   /*     104-126 */
407136849Sscottl    USHORT SpecialFunctionsEnabled;         /*     127 */
408136849Sscottl    USHORT Reserved9[128];                  /*     128-255 */
409136849Sscottl
410136849Sscottl} IDENTIFY_DATA, *PIDENTIFY_DATA;
411136849Sscottl
412136849Sscottltypedef struct _CONFIGURATION_IDENTIFY_DATA {
413136849Sscottl	USHORT Revision;
414136849Sscottl	USHORT MWDMAModeSupported;
415136849Sscottl	USHORT UDMAModeSupported;
416136849Sscottl	ULONG  MaximumLbaLow;
417136849Sscottl	ULONG  MaximumLbaHigh;
418136849Sscottl	USHORT CommandSupport;
419136849Sscottl	USHORT Reserved[247];
420136849Sscottl	UCHAR  Signature; /* 0xA5 */
421136849Sscottl	UCHAR  CheckSum;
422136849Sscottl}
423136849SscottlCONFIGURATION_IDENTIFY_DATA, *PCONFIGURATION_IDENTIFY_DATA;
424136849Sscottl
425136849Sscottl/* */
426136849Sscottl/* Identify data without the Reserved4. */
427136849Sscottl/* */
428136849Sscottltypedef struct _IDENTIFY_DATA2 {
429136849Sscottl    USHORT GeneralConfiguration;            /* 00 00 */
430136849Sscottl    USHORT NumberOfCylinders;               /* 02  1 */
431136849Sscottl    USHORT Reserved1;                       /* 04  2 */
432136849Sscottl    USHORT NumberOfHeads;                   /* 06  3 */
433136849Sscottl    USHORT UnformattedBytesPerTrack;        /* 08  4 */
434136849Sscottl    USHORT UnformattedBytesPerSector;       /* 0A  5 */
435136849Sscottl    USHORT SectorsPerTrack;                 /* 0C  6 */
436136849Sscottl    USHORT VendorUnique1[3];                /* 0E  7-9 */
437136849Sscottl    USHORT SerialNumber[10];                /* 14  10-19 */
438136849Sscottl    USHORT BufferType;                      /* 28  20 */
439136849Sscottl    USHORT BufferSectorSize;                /* 2A  21 */
440136849Sscottl    USHORT NumberOfEccBytes;                /* 2C  22 */
441136849Sscottl    USHORT FirmwareRevision[4];             /* 2E  23-26 */
442136849Sscottl    USHORT ModelNumber[20];                 /* 36  27-46 */
443136849Sscottl    UCHAR  MaximumBlockTransfer;            /* 5E  47 */
444136849Sscottl    UCHAR  VendorUnique2;                   /* 5F */
445136849Sscottl    USHORT DoubleWordIo;                    /* 60  48 */
446136849Sscottl    USHORT Capabilities;                    /* 62  49 */
447136849Sscottl    USHORT Reserved2;                       /* 64  50 */
448136849Sscottl    UCHAR  VendorUnique3;                   /* 66  51 */
449136849Sscottl    UCHAR  PioCycleTimingMode;              /* 67 */
450136849Sscottl    UCHAR  VendorUnique4;                   /* 68  52 */
451136849Sscottl    UCHAR  DmaCycleTimingMode;              /* 69 */
452136849Sscottl    USHORT TranslationFieldsValid;         	/* 6A  53 */
453136849Sscottl    USHORT NumberOfCurrentCylinders;        /* 6C  54 */
454136849Sscottl    USHORT NumberOfCurrentHeads;            /* 6E  55 */
455136849Sscottl    USHORT CurrentSectorsPerTrack;          /* 70  56 */
456136849Sscottl    ULONG  CurrentSectorCapacity;           /* 72  57-58 */
457136849Sscottl    USHORT CurrentMultiSectorSetting;       /*     59 */
458136849Sscottl    ULONG  UserAddressableSectors;          /*     60-61 */
459136849Sscottl    UCHAR  SingleWordDMASupport;        	/*     62 */
460136849Sscottl    UCHAR  SingleWordDMAActive;
461136849Sscottl    UCHAR  MultiWordDMASupport;         	/*     63 */
462136849Sscottl    UCHAR  MultiWordDMAActive;
463136849Sscottl    UCHAR  AdvancedPIOModes;            	/*     64 */
464136849Sscottl    UCHAR  Reserved4;
465136849Sscottl    USHORT MinimumMWXferCycleTime;          /*     65 */
466136849Sscottl    USHORT RecommendedMWXferCycleTime;      /*     66 */
467136849Sscottl    USHORT MinimumPIOCycleTime;             /*     67 */
468136849Sscottl    USHORT MinimumPIOCycleTimeIORDY;        /*     68 */
469136849Sscottl    USHORT Reserved5[2];                    /*     69-70 */
470136849Sscottl    USHORT ReleaseTimeOverlapped;           /*     71 */
471136849Sscottl    USHORT ReleaseTimeServiceCommand;       /*     72 */
472136849Sscottl    USHORT MajorRevision;                   /*     73 */
473136849Sscottl    USHORT MinorRevision;                   /*     74 */
474136849Sscottl/*    USHORT Reserved6[14];                 //     75-88 */
475136849Sscottl} IDENTIFY_DATA2, *PIDENTIFY_DATA2;
476136849Sscottl
477136849Sscottl#define IDENTIFY_DATA_SIZE sizeof(IDENTIFY_DATA2)
478136849Sscottl
479136849Sscottl/* */
480136849Sscottl/* IDENTIFY DMA timing cycle modes. */
481136849Sscottl/* */
482136849Sscottl
483136849Sscottl#define IDENTIFY_DMA_CYCLES_MODE_0 0x00
484136849Sscottl#define IDENTIFY_DMA_CYCLES_MODE_1 0x01
485136849Sscottl#define IDENTIFY_DMA_CYCLES_MODE_2 0x02
486136849Sscottl
487136849Sscottl/*
488136849Sscottl * Mode definitions
489136849Sscottl */
490136849Sscottltypedef enum _DISK_MODE
491136849Sscottl{
492136849Sscottl	IDE_PIO_0 = 0,
493136849Sscottl	IDE_PIO_1,
494136849Sscottl	IDE_PIO_2,
495136849Sscottl	IDE_PIO_3,
496136849Sscottl	IDE_PIO_4,
497136849Sscottl	IDE_MWDMA_0,
498136849Sscottl	IDE_MWDMA_1,
499136849Sscottl	IDE_MWDMA_2,
500136849Sscottl	IDE_UDMA_0,
501136849Sscottl	IDE_UDMA_1,
502136849Sscottl	IDE_UDMA_2,
503136849Sscottl	IDE_UDMA_3,
504136849Sscottl	IDE_UDMA_4,
505136849Sscottl	IDE_UDMA_5,
506136849Sscottl	IDE_UDMA_6,
507136849Sscottl	IDE_UDMA_7,
508136849Sscottl} DISK_MODE;
509136849Sscottl
510136849Sscottl/***************************************************************************
511136849Sscottl *            IDE Macro
512136849Sscottl ***************************************************************************/
513136849Sscottl#ifndef MAX_LBA_T
514136849Sscottl#define MAX_LBA_T ((LBA_T)-1)
515136849Sscottl#endif
516136849Sscottl
517136849Sscottl#define SECTOR_TO_BYTE_SHIFT 9
518136849Sscottl#define SECTOR_TO_BYTE(x)  ((ULONG)(x) << SECTOR_TO_BYTE_SHIFT)
519136849Sscottl
520136849Sscottl#define mGetStatus(IOPort2)           (UCHAR)InPort(&IOPort2->AlternateStatus)
521136849Sscottl#define mUnitControl(IOPort2, Value)  OutPort(&IOPort2->AlternateStatus,(UCHAR)(Value))
522136849Sscottl
523136849Sscottl#define mGetErrorCode(IOPort)         (UCHAR)InPort((PUCHAR)&IOPort->Data+1)
524136849Sscottl#define mSetFeaturePort(IOPort,x)     OutPort((PUCHAR)&IOPort->Data+1, x)
525136849Sscottl#define mSetBlockCount(IOPort,x)      OutPort(&IOPort->BlockCount, x)
526136849Sscottl#define mGetBlockCount(IOPort)	      (UCHAR)InPort(&IOPort->BlockCount)
527136849Sscottl#define mGetInterruptReason(IOPort)   (UCHAR)InPort(&IOPort->BlockCount)
528136849Sscottl#define mSetBlockNumber(IOPort,x)     OutPort(&IOPort->BlockNumber, x)
529136849Sscottl#define mGetBlockNumber(IOPort)       (UCHAR)InPort((PUCHAR)&IOPort->BlockNumber)
530136849Sscottl#define mGetByteLow(IOPort)           (UCHAR)InPort(&IOPort->CylinderLow)
531136849Sscottl#define mSetCylinderLow(IOPort,x)         OutPort(&IOPort->CylinderLow, x)
532136849Sscottl#define mGetByteHigh(IOPort)          (UCHAR)InPort(&IOPort->CylinderHigh)
533136849Sscottl#define mSetCylinderHigh(IOPort,x)    OutPort(&IOPort->CylinderHigh, x)
534136849Sscottl#define mGetBaseStatus(IOPort)        (UCHAR)InPort(&IOPort->Command)
535136849Sscottl#ifdef SUPPORT_HPT601
536136849Sscottl#define mSelectUnit(IOPort,UnitId)  do {\
537136849Sscottl		OutPort(&IOPort->DriveSelect, (UCHAR)(UnitId));\
538136849Sscottl		OutPort(&IOPort->DriveSelect, (UCHAR)(UnitId));\
539136849Sscottl		} while (0)
540136849Sscottl#else
541136849Sscottl#define mSelectUnit(IOPort,UnitId)    OutPort(&IOPort->DriveSelect, (UCHAR)(UnitId))
542136849Sscottl#endif
543136849Sscottl#define mGetUnitNumber(IOPort)        InPort(&IOPort->DriveSelect)
544136849Sscottl#define mIssueCommand(IOPort,Cmd)     OutPort(&IOPort->Command, (UCHAR)(Cmd))
545136849Sscottl
546136849Sscottl/*
547136849Sscottl * WDC old disk, don't care right now
548136849Sscottl */
549136849Sscottl#define WDC_MW1_FIX_FLAG_OFFSET        129
550136849Sscottl#define WDC_MW1_FIX_FLAG_VALUE        0x00005555
551136849Sscottl
552136849Sscottl#pragma pack()
553136849Sscottl#endif
554136849Sscottl
555136849Sscottl
556136849Sscottl
557