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

Last change on this file since 84 was 84, checked in by chris, 14 years ago
  • Added ioctl.c, ioctl.h and apm.c to repository
File size: 4.8 KB
Line 
1/******************************************************************************
2 * ioctl.h - IOCTL structures and constants for os2ahci driver
3 *
4 * Copyright (c) 2010 Christian Mueller. Parts copied from/inspired by the
5 * Linux AHCI driver; those parts are (c) Linux AHCI/ATA maintainers
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22/* -------------------------- macros and constants ------------------------- */
23
24/* IOCTL categories and functions */
25#define OS2AHCI_IOCTL_CATEGORY 0x80
26#define OS2AHCI_IOCTL_GET_DEVLIST 0x01
27#define OS2AHCI_IOCTL_PASSTHROUGH 0x02
28
29/* device flags */
30#define DF_LBA48 0x0001U
31#define DF_ATAPI 0x0002U
32#define DF_ATAPI_16 0x0004U
33#define DF_REMOVABLE 0x0008U
34
35/* passthrough flags */
36#define PT_WRITE 0x0001U /* transfer direction host -> device */
37#define PT_ATAPI 0x0002U /* ATAPI command (ATA if not set) */
38
39/* ------------------------ typedefs and structures ------------------------ */
40
41#ifndef VMDHL_WRITE
42typedef void *LIN;
43#endif
44
45#pragma pack(1)
46
47/******************************************************************************
48 * Generic ATA-8 command structure. This is loosely based on ATA-8, i.e. we
49 * don't have to deal with shadow registers and map them to the low bytes of
50 * adjecent words, etc. but there are still some oddities which need to be
51 * taken into consideration. For example, ATA-8 says LBA-28 sector addresses
52 * are simply the lower 28 bits in the LBA field. However, the underlying
53 * transport (SATA in our case) only looks at the three lower bytes of the
54 * LBA field, much like an IDE device would do. This means that only 3 bytes
55 * of the LBA field are processed and this yields only 24 bits. The remaining
56 * 4 bits need to be stored in the "device" register....
57 *
58 * Everything else seems to behave normally, as far as this term can be
59 * applied to IDE/ATA. Further details can be found in section 7.1.5.1 of the
60 * ATA-8 spec (Inputs for 28-bit Read/Write Commands).
61 */
62typedef struct {
63 USHORT features; /* feature bits */
64 USHORT count; /* count register (e.g. number of sectors) */
65 ULONG lba_l; /* low 24 bits of LBA-28 (32 bits for 48-bit devices) */
66 USHORT lba_h; /* high 16 bits of LBA for 48-bit devices */
67 UCHAR cmd; /* ATA command field */
68 UCHAR device; /* ATA device field and upper 4 bits of LBA-28 */
69} ATACMD;
70
71/******************************************************************************
72 * Data structure for OS2AHCI_IOCTL_GET_DEVLIST; the parameter for this IOCTL
73 * is a USHORT with the number of entries in 'devs'.
74 */
75typedef struct {
76 USHORT cnt; /* number of entries in 'devs' */
77 struct {
78 USHORT adapter; /* adapter */
79 USHORT port; /* port */
80 USHORT device; /* device (port multiplier) */
81 USHORT type; /* device type; see UIB_TYPE_* in iorb.h */
82 USHORT ncq_max; /* maximum number of queued commands */
83 USHORT flags; /* device flags; see DF_* above */
84 } devs[1];
85} OS2AHCI_DEVLIST;
86
87/******************************************************************************
88 * Parameter structure for OS2AHCI_IOCTL_PASSTHROUGH; the data structure for
89 * this IOCTL is a buffer for sense data in case of errors.
90 */
91typedef struct {
92 USHORT adapter; /* adapter */
93 USHORT port; /* port */
94 USHORT device; /* device (port multiplier) */
95 USHORT flags; /* request flags; see PT_* above */
96 ULONG timeout; /* timeout in seconds (0 = default of 30s) */
97
98 USHORT cmdlen; /* length of ATA or ATAPI command */
99 union {
100 ATACMD ata; /* ATA command */
101 UCHAR cdb[20]; /* ATAPI command */
102 } cmd;
103
104 ULONG buflen; /* length of buffer for data transfers */
105 LIN buf; /* buffer for data transfers (32-bit linear address) */
106 USHORT sense_len; /* length of sense data in IOCTL DataPacket */
107} OS2AHCI_PASSTHROUGH;
108
109#pragma pack()
110
Note: See TracBrowser for help on using the repository browser.