source: trunk/src/os2ahci/ioctl.h@ 205

Last change on this file since 205 was 205, checked in by David Azarewicz, 5 years ago

Fixed ADD RM id.

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