1 | /******************************************************************************
|
---|
2 | * ioctl.h - IOCTL structures and constants for os2ahci driver
|
---|
3 | *
|
---|
4 | * Copyright (c) 2011 thi.guten Software Development
|
---|
5 | * Copyright (c) 2011 Mensys B.V.
|
---|
6 | *
|
---|
7 | * Authors: Christian Mueller, Markus Thielen
|
---|
8 | *
|
---|
9 | * Parts copied from/inspired by the Linux AHCI driver;
|
---|
10 | * those parts are (c) Linux AHCI/ATA maintainers
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or modify
|
---|
13 | * it under the terms of the GNU General Public License as published by
|
---|
14 | * the Free Software Foundation; either version 2 of the License, or
|
---|
15 | * (at your option) any later version.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful,
|
---|
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
20 | * GNU General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, write to the Free Software
|
---|
24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
25 | */
|
---|
26 |
|
---|
27 | /* -------------------------- macros and constants ------------------------- */
|
---|
28 |
|
---|
29 | /* IOCTL categories and functions */
|
---|
30 | #define OS2AHCI_IOCTL_CATEGORY 0x87
|
---|
31 | #define OS2AHCI_IOCTL_GET_DEVLIST 0x01
|
---|
32 | #define OS2AHCI_IOCTL_PASSTHROUGH 0x02
|
---|
33 |
|
---|
34 | /* IOCTL definitions from s506oem.h (primarily required for SMART calls) */
|
---|
35 | #define DSKSP_CAT_SMART 0x80 /* SMART IOCTL category */
|
---|
36 | #define DSKSP_SMART_ONOFF 0x20 /* turn SMART on or off */
|
---|
37 | #define DSKSP_SMART_AUTOSAVE_ONOFF 0x21 /* turn SMART autosave on or off */
|
---|
38 | #define DSKSP_SMART_SAVE 0x22 /* force save of SMART data */
|
---|
39 | #define DSKSP_SMART_GETSTATUS 0x23 /* get SMART status (pass/fail) */
|
---|
40 | #define DSKSP_SMART_GET_ATTRIBUTES 0x24 /* get SMART attributes table */
|
---|
41 | #define DSKSP_SMART_GET_THRESHOLDS 0x25 /* get SMART thresholds table */
|
---|
42 | #define DSKSP_SMART_GET_LOG 0x26 /* get SMART log table */
|
---|
43 | #define DSKSP_SMART_AUTO_OFFLINE 0x27 /* set SMART offline autosave timer */
|
---|
44 | #define DSKSP_SMART_EXEC_OFFLINE 0x28 /* execute SMART immediate offline */
|
---|
45 |
|
---|
46 | #define SMART_CMD_ON 1 /* on value for related SMART functions */
|
---|
47 | #define SMART_CMD_OFF 0 /* off value for related SMART functions */
|
---|
48 |
|
---|
49 | #define DSKSP_CAT_GENERIC 0x90 /* generic IOCTL category */
|
---|
50 | #define DSKSP_GEN_GET_COUNTERS 0x40 /* get general counter values table */
|
---|
51 | #define DSKSP_GET_UNIT_INFORMATION 0x41 /* get unit configuration and BM DMA counters */
|
---|
52 | #define DSKSP_GET_INQUIRY_DATA 0x42 /* get ATA/ATAPI inquiry data */
|
---|
53 |
|
---|
54 | /* unit information structure flags from s506oem.h */
|
---|
55 | #define UIF_VALID 0x8000U /* unit information valid */
|
---|
56 | #define UIF_TIMINGS_VALID 0x4000U /* timing information valid */
|
---|
57 | #define UIF_RUNNING_BMDMA 0x2000U /* running Bus Master DMA on unit */
|
---|
58 | #define UIF_RUNNING_DMA 0x1000U /* running slave DMA on unit */
|
---|
59 | #define UIF_SATA 0x0004U /* SATA */
|
---|
60 | #define UIF_SLAVE 0x0002U /* slave on channel */
|
---|
61 | #define UIF_ATAPI 0x0001U /* ATAPI device if 1, ATA otherwise */
|
---|
62 |
|
---|
63 | /* device flags */
|
---|
64 | #define DF_LBA48 0x0001U
|
---|
65 | #define DF_ATAPI 0x0002U
|
---|
66 | #define DF_ATAPI_16 0x0004U
|
---|
67 | #define DF_REMOVABLE 0x0008U
|
---|
68 |
|
---|
69 | /* passthrough flags */
|
---|
70 | #define PT_WRITE 0x0001U /* transfer direction host -> device */
|
---|
71 | #define PT_ATAPI 0x0002U /* ATAPI command (ATA if not set) */
|
---|
72 |
|
---|
73 | /* ------------------------ typedefs and structures ------------------------ */
|
---|
74 |
|
---|
75 | #ifndef VMDHL_WRITE
|
---|
76 | typedef void *LIN;
|
---|
77 | #endif
|
---|
78 |
|
---|
79 | #pragma pack(1)
|
---|
80 |
|
---|
81 | /******************************************************************************
|
---|
82 | * Generic ATA-8 command structure. This is loosely based on ATA-8, i.e. we
|
---|
83 | * don't have to deal with shadow registers and map them to the low bytes of
|
---|
84 | * adjecent words, etc. but there are still some oddities which need to be
|
---|
85 | * taken into consideration. For example, ATA-8 says LBA-28 sector addresses
|
---|
86 | * are simply the lower 28 bits in the LBA field. However, the underlying
|
---|
87 | * transport (SATA in our case) only looks at the three lower bytes of the
|
---|
88 | * LBA field, much like an IDE device would do. This means that only 3 bytes
|
---|
89 | * of the LBA field are processed and this yields only 24 bits. The remaining
|
---|
90 | * 4 bits need to be stored in the "device" register....
|
---|
91 | *
|
---|
92 | * Everything else seems to behave normally, as far as this term can be
|
---|
93 | * applied to IDE/ATA. Further details can be found in section 7.1.5.1 of the
|
---|
94 | * ATA-8 spec (Inputs for 28-bit Read/Write Commands).
|
---|
95 | */
|
---|
96 | typedef struct {
|
---|
97 | USHORT features; /* feature bits */
|
---|
98 | USHORT count; /* count register (e.g. number of sectors) */
|
---|
99 | ULONG lba_l; /* low 24 bits of LBA-28 (32 bits for 48-bit devices) */
|
---|
100 | USHORT lba_h; /* high 16 bits of LBA for 48-bit devices */
|
---|
101 | UCHAR cmd; /* ATA command field */
|
---|
102 | UCHAR device; /* ATA device field and upper 4 bits of LBA-28 */
|
---|
103 | } ATACMD;
|
---|
104 |
|
---|
105 | /******************************************************************************
|
---|
106 | * Data structure for OS2AHCI_IOCTL_GET_DEVLIST; the parameter for this IOCTL
|
---|
107 | * is a USHORT with the number of entries in 'devs'.
|
---|
108 | */
|
---|
109 | typedef struct {
|
---|
110 | USHORT cnt; /* number of entries in 'devs' */
|
---|
111 | struct {
|
---|
112 | USHORT adapter; /* adapter */
|
---|
113 | USHORT port; /* port */
|
---|
114 | USHORT device; /* device (port multiplier) */
|
---|
115 | USHORT type; /* device type; see UIB_TYPE_* in iorb.h */
|
---|
116 | USHORT ncq_max; /* maximum number of queued commands */
|
---|
117 | USHORT flags; /* device flags; see DF_* above */
|
---|
118 | } devs[1];
|
---|
119 | } OS2AHCI_DEVLIST;
|
---|
120 |
|
---|
121 | /******************************************************************************
|
---|
122 | * Parameter structure for OS2AHCI_IOCTL_PASSTHROUGH; the data structure for
|
---|
123 | * this IOCTL is a buffer for sense data in case of errors.
|
---|
124 | */
|
---|
125 | typedef struct {
|
---|
126 | USHORT adapter; /* adapter */
|
---|
127 | USHORT port; /* port */
|
---|
128 | USHORT device; /* device (port multiplier) */
|
---|
129 | USHORT flags; /* request flags; see PT_* above */
|
---|
130 | ULONG timeout; /* timeout in seconds (0 = default of 30s) */
|
---|
131 |
|
---|
132 | USHORT cmdlen; /* length of ATA or ATAPI command */
|
---|
133 | union {
|
---|
134 | ATACMD ata; /* ATA command */
|
---|
135 | UCHAR cdb[20]; /* ATAPI command */
|
---|
136 | } cmd;
|
---|
137 |
|
---|
138 | ULONG buflen; /* length of buffer for data transfers */
|
---|
139 | LIN buf; /* buffer for data transfers (32-bit linear address) */
|
---|
140 | USHORT sense_len; /* length of sense data in IOCTL DataPacket */
|
---|
141 | } OS2AHCI_PASSTHROUGH;
|
---|
142 |
|
---|
143 | /******************************************************************************
|
---|
144 | * DSKSP command parameters; copied from s506oem.h
|
---|
145 | */
|
---|
146 | typedef struct _DSKSP_CommandParameters
|
---|
147 | {
|
---|
148 | BYTE byPhysicalUnit; /* physical unit number 0-n */
|
---|
149 | /* 0 = Pri/Mas, 1=Pri/Sla, 2=Sec/Mas, etc. */
|
---|
150 | } DSKSP_CommandParameters;
|
---|
151 |
|
---|
152 | /******************************************************************************
|
---|
153 | * DSKSP device counters data; copied from s506oem.h
|
---|
154 | */
|
---|
155 | typedef struct _DeviceCountersData
|
---|
156 | {
|
---|
157 | USHORT wRevisionNumber; /* counter structure revision */
|
---|
158 | ULONG TotalReadOperations; /* total read operations performed */
|
---|
159 | ULONG TotalWriteOperations; /* total write operations performed */
|
---|
160 | ULONG TotalWriteErrors; /* total write errors encountered */
|
---|
161 | ULONG TotalReadErrors; /* total read errors encountered */
|
---|
162 | ULONG TotalSeekErrors; /* total seek errors encountered */
|
---|
163 | ULONG TotalSectorsRead; /* total number of sectors read */
|
---|
164 | ULONG TotalSectorsWritten; /* total number of sectors written */
|
---|
165 |
|
---|
166 | ULONG TotalBMReadOperations; /* total bus master DMA read operations */
|
---|
167 | ULONG TotalBMWriteOperations; /* total bus master DMA write operations */
|
---|
168 | ULONG ByteMisalignedBuffers; /* total buffers on odd byte boundary */
|
---|
169 | ULONG TransfersAcross64K; /* total buffers crossing a 64K page boundary */
|
---|
170 | USHORT TotalBMStatus; /* total bad busmaster status */
|
---|
171 | USHORT TotalBMErrors; /* total bad busmaster error */
|
---|
172 | ULONG TotalIRQsLost; /* total lost interrupts */
|
---|
173 | USHORT TotalDRQsLost; /* total lost data transfer requests */
|
---|
174 | USHORT TotalBusyErrors; /* total device busy timeouts */
|
---|
175 | USHORT TotalBMStatus2; /* total bad busmaster status */
|
---|
176 | USHORT TotalChipStatus; /* total bad chip status */
|
---|
177 | USHORT ReadErrors[4];
|
---|
178 | USHORT WriteErrors[2];
|
---|
179 | USHORT SeekErrors[2];
|
---|
180 | USHORT SATAErrors;
|
---|
181 | } DeviceCountersData;
|
---|
182 |
|
---|
183 | /******************************************************************************
|
---|
184 | * DSKSP unit information data; copied from s506oem.h
|
---|
185 | */
|
---|
186 | typedef struct _UnitInformationData
|
---|
187 | {
|
---|
188 | USHORT wRevisionNumber; /* structure revision number */
|
---|
189 | union {
|
---|
190 | struct {
|
---|
191 | USHORT wTFBase; /* task file register base addr */
|
---|
192 | USHORT wDevCtl; /* device control register addr */
|
---|
193 | } rev0;
|
---|
194 | ULONG dTFBase; /* task file register base addr */
|
---|
195 | };
|
---|
196 | USHORT wIRQ; /* interrupt request level */
|
---|
197 | USHORT wFlags; /* flags */
|
---|
198 | UCHAR byPIO_Mode; /* PIO transfer mode programmed */
|
---|
199 | UCHAR byDMA_Mode; /* DMA transfer mode programmed */
|
---|
200 | ULONG UnitFlags1;
|
---|
201 | USHORT UnitFlags2;
|
---|
202 | } UnitInformationData;
|
---|
203 |
|
---|
204 |
|
---|
205 | #pragma pack()
|
---|
206 |
|
---|