]> git.saurik.com Git - apple/xnu.git/blob - bsd/sys/disk.h
xnu-2422.100.13.tar.gz
[apple/xnu.git] / bsd / sys / disk.h
1 /*
2 * Copyright (c) 1998-2006 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28
29 #ifndef _SYS_DISK_H_
30 #define _SYS_DISK_H_
31
32 #include <stdint.h>
33 #include <sys/ioctl.h>
34
35 #ifdef XNU_KERNEL_PRIVATE
36 #include <mach/boolean.h>
37 #endif /* XNU_KERNEL_PRIVATE */
38
39 /*
40 * Definitions
41 *
42 * ioctl description
43 * ------------------------------------- ---------------------------------------
44 * DKIOCEJECT eject media
45 * DKIOCSYNCHRONIZECACHE flush media
46 *
47 * DKIOCFORMAT format media
48 * DKIOCGETFORMATCAPACITIES get media's formattable capacities
49 *
50 * DKIOCGETBLOCKSIZE get media's block size
51 * DKIOCGETBLOCKCOUNT get media's block count
52 * DKIOCGETFIRMWAREPATH get media's firmware path
53 *
54 * DKIOCISFORMATTED is media formatted?
55 * DKIOCISWRITABLE is media writable?
56 *
57 * DKIOCREQUESTIDLE idle media
58 * DKIOCUNMAP delete unused data
59 *
60 * DKIOCGETMAXBLOCKCOUNTREAD get maximum block count for reads
61 * DKIOCGETMAXBLOCKCOUNTWRITE get maximum block count for writes
62 * DKIOCGETMAXBYTECOUNTREAD get maximum byte count for reads
63 * DKIOCGETMAXBYTECOUNTWRITE get maximum byte count for writes
64 *
65 * DKIOCGETMAXSEGMENTCOUNTREAD get maximum segment count for reads
66 * DKIOCGETMAXSEGMENTCOUNTWRITE get maximum segment count for writes
67 * DKIOCGETMAXSEGMENTBYTECOUNTREAD get maximum segment byte count for reads
68 * DKIOCGETMAXSEGMENTBYTECOUNTWRITE get maximum segment byte count for writes
69 *
70 * DKIOCGETMINSEGMENTALIGNMENTBYTECOUNT get minimum segment alignment in bytes
71 * DKIOCGETMAXSEGMENTADDRESSABLEBITCOUNT get maximum segment width in bits
72 *
73 * DKIOCGETFEATURES get device's feature set
74 * DKIOCGETPHYSICALBLOCKSIZE get device's block size
75 * DKIOCGETCOMMANDPOOLSIZE get device's queue depth
76 */
77
78 #define DK_FEATURE_UNMAP 0x00000010
79
80 typedef struct
81 {
82 uint64_t offset;
83 uint64_t length;
84 } dk_extent_t;
85
86 typedef struct
87 {
88 char path[128];
89 } dk_firmware_path_t;
90
91 typedef struct
92 {
93 uint64_t blockCount;
94 uint32_t blockSize;
95
96 uint8_t reserved0096[4]; /* reserved, clear to zero */
97 } dk_format_capacity_t;
98
99 typedef struct
100 {
101 dk_format_capacity_t * capacities;
102 uint32_t capacitiesCount; /* use zero to probe count */
103
104 #ifdef __LP64__
105 uint8_t reserved0096[4]; /* reserved, clear to zero */
106 #else /* !__LP64__ */
107 uint8_t reserved0064[8]; /* reserved, clear to zero */
108 #endif /* !__LP64__ */
109 } dk_format_capacities_t;
110
111 typedef struct
112 {
113 dk_extent_t * extents;
114 uint32_t extentsCount;
115
116 #ifdef __LP64__
117 uint8_t reserved0096[4]; /* reserved, clear to zero */
118 #else /* !__LP64__ */
119 uint8_t reserved0064[8]; /* reserved, clear to zero */
120 #endif /* !__LP64__ */
121 } dk_unmap_t;
122
123 #define DKIOCEJECT _IO('d', 21)
124 #define DKIOCSYNCHRONIZECACHE _IO('d', 22)
125
126 #define DKIOCFORMAT _IOW('d', 26, dk_format_capacity_t)
127 #define DKIOCGETFORMATCAPACITIES _IOWR('d', 26, dk_format_capacities_t)
128
129 #define DKIOCGETBLOCKSIZE _IOR('d', 24, uint32_t)
130 #define DKIOCGETBLOCKCOUNT _IOR('d', 25, uint64_t)
131 #define DKIOCGETFIRMWAREPATH _IOR('d', 28, dk_firmware_path_t)
132
133 #define DKIOCISFORMATTED _IOR('d', 23, uint32_t)
134 #define DKIOCISWRITABLE _IOR('d', 29, uint32_t)
135
136 #define DKIOCREQUESTIDLE _IO('d', 30)
137 #define DKIOCUNMAP _IOW('d', 31, dk_unmap_t)
138
139 #define DKIOCGETMAXBLOCKCOUNTREAD _IOR('d', 64, uint64_t)
140 #define DKIOCGETMAXBLOCKCOUNTWRITE _IOR('d', 65, uint64_t)
141 #define DKIOCGETMAXBYTECOUNTREAD _IOR('d', 70, uint64_t)
142 #define DKIOCGETMAXBYTECOUNTWRITE _IOR('d', 71, uint64_t)
143
144 #define DKIOCGETMAXSEGMENTCOUNTREAD _IOR('d', 66, uint64_t)
145 #define DKIOCGETMAXSEGMENTCOUNTWRITE _IOR('d', 67, uint64_t)
146 #define DKIOCGETMAXSEGMENTBYTECOUNTREAD _IOR('d', 68, uint64_t)
147 #define DKIOCGETMAXSEGMENTBYTECOUNTWRITE _IOR('d', 69, uint64_t)
148
149 #define DKIOCGETMINSEGMENTALIGNMENTBYTECOUNT _IOR('d', 74, uint64_t)
150 #define DKIOCGETMAXSEGMENTADDRESSABLEBITCOUNT _IOR('d', 75, uint64_t)
151
152 #define DKIOCGETFEATURES _IOR('d', 76, uint32_t)
153 #define DKIOCGETPHYSICALBLOCKSIZE _IOR('d', 77, uint32_t)
154 #define DKIOCGETCOMMANDPOOLSIZE _IOR('d', 78, uint32_t)
155
156 #ifdef KERNEL
157 #define DK_FEATURE_FORCE_UNIT_ACCESS 0x00000001
158
159 typedef struct
160 {
161 uint64_t offset;
162 uint64_t length;
163
164 uint8_t reserved0128[12]; /* reserved, clear to zero */
165
166 dev_t dev;
167 } dk_physical_extent_t;
168
169 #define DKIOCGETBLOCKCOUNT32 _IOR('d', 25, uint32_t)
170 #define DKIOCSETBLOCKSIZE _IOW('d', 24, uint32_t)
171 #define DKIOCGETBSDUNIT _IOR('d', 27, uint32_t)
172 #define DKIOCISSOLIDSTATE _IOR('d', 79, uint32_t)
173 #define DKIOCISVIRTUAL _IOR('d', 72, uint32_t)
174 #define DKIOCGETBASE _IOR('d', 73, uint64_t)
175 #define DKIOCGETTHROTTLEMASK _IOR('d', 80, uint64_t)
176 #define DKIOCLOCKPHYSICALEXTENTS _IO('d', 81)
177 #define DKIOCGETPHYSICALEXTENT _IOWR('d', 82, dk_physical_extent_t)
178 #define DKIOCUNLOCKPHYSICALEXTENTS _IO('d', 83)
179 #define DKIOCGETMAXPRIORITYCOUNT _IOR('d', 84, uint32_t)
180
181 #ifdef XNU_KERNEL_PRIVATE
182 typedef struct
183 {
184 boolean_t mi_mdev; /* Is this a memdev device? */
185 boolean_t mi_phys; /* Physical memory? */
186 uint32_t mi_base; /* Base page number of the device? */
187 uint64_t mi_size; /* Size of the device (in ) */
188 } dk_memdev_info_t;
189
190 typedef dk_memdev_info_t memdev_info_t;
191
192 #define DKIOCGETMEMDEVINFO _IOR('d', 90, dk_memdev_info_t)
193 #endif /* XNU_KERNEL_PRIVATE */
194 #ifdef PRIVATE
195 typedef struct _dk_cs_pin {
196 dk_extent_t cp_extent;
197 int64_t cp_flags;
198 } _dk_cs_pin_t;
199 #define _DKIOCSPINDISCARDDATA (1 << 0)
200 #define _DKIOCCSPINEXTENT _IOW('d', 199, _dk_cs_pin_t)
201 #define _DKIOCCSUNPINEXTENT _IOW('d', 200, _dk_cs_pin_t)
202 #define _DKIOCGETMIGRATIONUNITBYTESIZE _IOR('d', 201, uint32_t)
203 typedef struct _dk_cs_map {
204 dk_extent_t cm_extent;
205 uint64_t cm_bytes_mapped;
206 } _dk_cs_map_t;
207 #define _DKIOCCSMAP _IOWR('d', 202, _dk_cs_map_t)
208 #define _DKIOCCSSETFSVNODE _IOW('d', 203, vnode_t)
209 #define _DKIOCCSGETFREEBYTES _IOR('d', 204, uint64_t)
210 #endif /* PRIVATE */
211 #endif /* KERNEL */
212
213 #ifdef PRIVATE
214 #ifdef TARGET_OS_EMBEDDED
215 #define _DKIOCSETSTATIC _IO('d', 84)
216 #endif /* TARGET_OS_EMBEDDED */
217 #endif /* PRIVATE */
218
219 #endif /* _SYS_DISK_H_ */