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 0x80
|
---|
31 | #define OS2AHCI_IOCTL_GET_DEVLIST 0x01
|
---|
32 | #define OS2AHCI_IOCTL_PASSTHROUGH 0x02
|
---|
33 |
|
---|
34 | /* device flags */
|
---|
35 | #define DF_LBA48 0x0001U
|
---|
36 | #define DF_ATAPI 0x0002U
|
---|
37 | #define DF_ATAPI_16 0x0004U
|
---|
38 | #define DF_REMOVABLE 0x0008U
|
---|
39 |
|
---|
40 | /* passthrough flags */
|
---|
41 | #define PT_WRITE 0x0001U /* transfer direction host -> device */
|
---|
42 | #define PT_ATAPI 0x0002U /* ATAPI command (ATA if not set) */
|
---|
43 |
|
---|
44 | /* ------------------------ typedefs and structures ------------------------ */
|
---|
45 |
|
---|
46 | #ifndef VMDHL_WRITE
|
---|
47 | typedef void *LIN;
|
---|
48 | #endif
|
---|
49 |
|
---|
50 | #pragma pack(1)
|
---|
51 |
|
---|
52 | /******************************************************************************
|
---|
53 | * Generic ATA-8 command structure. This is loosely based on ATA-8, i.e. we
|
---|
54 | * don't have to deal with shadow registers and map them to the low bytes of
|
---|
55 | * adjecent words, etc. but there are still some oddities which need to be
|
---|
56 | * taken into consideration. For example, ATA-8 says LBA-28 sector addresses
|
---|
57 | * are simply the lower 28 bits in the LBA field. However, the underlying
|
---|
58 | * transport (SATA in our case) only looks at the three lower bytes of the
|
---|
59 | * LBA field, much like an IDE device would do. This means that only 3 bytes
|
---|
60 | * of the LBA field are processed and this yields only 24 bits. The remaining
|
---|
61 | * 4 bits need to be stored in the "device" register....
|
---|
62 | *
|
---|
63 | * Everything else seems to behave normally, as far as this term can be
|
---|
64 | * applied to IDE/ATA. Further details can be found in section 7.1.5.1 of the
|
---|
65 | * ATA-8 spec (Inputs for 28-bit Read/Write Commands).
|
---|
66 | */
|
---|
67 | typedef struct {
|
---|
68 | USHORT features; /* feature bits */
|
---|
69 | USHORT count; /* count register (e.g. number of sectors) */
|
---|
70 | ULONG lba_l; /* low 24 bits of LBA-28 (32 bits for 48-bit devices) */
|
---|
71 | USHORT lba_h; /* high 16 bits of LBA for 48-bit devices */
|
---|
72 | UCHAR cmd; /* ATA command field */
|
---|
73 | UCHAR device; /* ATA device field and upper 4 bits of LBA-28 */
|
---|
74 | } ATACMD;
|
---|
75 |
|
---|
76 | /******************************************************************************
|
---|
77 | * Data structure for OS2AHCI_IOCTL_GET_DEVLIST; the parameter for this IOCTL
|
---|
78 | * is a USHORT with the number of entries in 'devs'.
|
---|
79 | */
|
---|
80 | typedef struct {
|
---|
81 | USHORT cnt; /* number of entries in 'devs' */
|
---|
82 | struct {
|
---|
83 | USHORT adapter; /* adapter */
|
---|
84 | USHORT port; /* port */
|
---|
85 | USHORT device; /* device (port multiplier) */
|
---|
86 | USHORT type; /* device type; see UIB_TYPE_* in iorb.h */
|
---|
87 | USHORT ncq_max; /* maximum number of queued commands */
|
---|
88 | USHORT flags; /* device flags; see DF_* above */
|
---|
89 | } devs[1];
|
---|
90 | } OS2AHCI_DEVLIST;
|
---|
91 |
|
---|
92 | /******************************************************************************
|
---|
93 | * Parameter structure for OS2AHCI_IOCTL_PASSTHROUGH; the data structure for
|
---|
94 | * this IOCTL is a buffer for sense data in case of errors.
|
---|
95 | */
|
---|
96 | typedef struct {
|
---|
97 | USHORT adapter; /* adapter */
|
---|
98 | USHORT port; /* port */
|
---|
99 | USHORT device; /* device (port multiplier) */
|
---|
100 | USHORT flags; /* request flags; see PT_* above */
|
---|
101 | ULONG timeout; /* timeout in seconds (0 = default of 30s) */
|
---|
102 |
|
---|
103 | USHORT cmdlen; /* length of ATA or ATAPI command */
|
---|
104 | union {
|
---|
105 | ATACMD ata; /* ATA command */
|
---|
106 | UCHAR cdb[20]; /* ATAPI command */
|
---|
107 | } cmd;
|
---|
108 |
|
---|
109 | ULONG buflen; /* length of buffer for data transfers */
|
---|
110 | LIN buf; /* buffer for data transfers (32-bit linear address) */
|
---|
111 | USHORT sense_len; /* length of sense data in IOCTL DataPacket */
|
---|
112 | } OS2AHCI_PASSTHROUGH;
|
---|
113 |
|
---|
114 | #pragma pack()
|
---|
115 |
|
---|