]> git.saurik.com Git - apple/xnu.git/blame - bsd/sys/disk.h
xnu-2422.100.13.tar.gz
[apple/xnu.git] / bsd / sys / disk.h
CommitLineData
9bccf70c 1/*
2d21ac55 2 * Copyright (c) 1998-2006 Apple Computer, Inc. All rights reserved.
9bccf70c 3 *
2d21ac55 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
9bccf70c 5 *
2d21ac55
A
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.
8f6c56a5 14 *
2d21ac55
A
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
8f6c56a5
A
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2d21ac55
A
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.
8f6c56a5 25 *
2d21ac55 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
9bccf70c
A
27 */
28
29#ifndef _SYS_DISK_H_
30#define _SYS_DISK_H_
31
2d21ac55 32#include <stdint.h>
9bccf70c 33#include <sys/ioctl.h>
9bccf70c 34
39236c6e
A
35#ifdef XNU_KERNEL_PRIVATE
36#include <mach/boolean.h>
37#endif /* XNU_KERNEL_PRIVATE */
38
55e303ae
A
39/*
40 * Definitions
41 *
0c530ab8
A
42 * ioctl description
43 * ------------------------------------- ---------------------------------------
44 * DKIOCEJECT eject media
45 * DKIOCSYNCHRONIZECACHE flush media
5d5c5d0d 46 *
0c530ab8
A
47 * DKIOCFORMAT format media
48 * DKIOCGETFORMATCAPACITIES get media's formattable capacities
5d5c5d0d 49 *
0c530ab8
A
50 * DKIOCGETBLOCKSIZE get media's block size
51 * DKIOCGETBLOCKCOUNT get media's block count
52 * DKIOCGETFIRMWAREPATH get media's firmware path
4452a7af 53 *
0c530ab8
A
54 * DKIOCISFORMATTED is media formatted?
55 * DKIOCISWRITABLE is media writable?
4452a7af 56 *
c910b4d9 57 * DKIOCREQUESTIDLE idle media
060df5ea 58 * DKIOCUNMAP delete unused data
593a1d5f 59 *
0c530ab8
A
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
593a1d5f 72 *
060df5ea 73 * DKIOCGETFEATURES get device's feature set
593a1d5f 74 * DKIOCGETPHYSICALBLOCKSIZE get device's block size
b0d623f7 75 * DKIOCGETCOMMANDPOOLSIZE get device's queue depth
55e303ae
A
76 */
77
060df5ea
A
78#define DK_FEATURE_UNMAP 0x00000010
79
9bccf70c
A
80typedef struct
81{
593a1d5f
A
82 uint64_t offset;
83 uint64_t length;
060df5ea 84} dk_extent_t;
593a1d5f
A
85
86typedef struct
87{
88 char path[128];
9bccf70c
A
89} dk_firmware_path_t;
90
55e303ae
A
91typedef struct
92{
2d21ac55
A
93 uint64_t blockCount;
94 uint32_t blockSize;
55e303ae 95
2d21ac55 96 uint8_t reserved0096[4]; /* reserved, clear to zero */
55e303ae
A
97} dk_format_capacity_t;
98
99typedef struct
100{
101 dk_format_capacity_t * capacities;
2d21ac55 102 uint32_t capacitiesCount; /* use zero to probe count */
55e303ae 103
2d21ac55
A
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__ */
55e303ae
A
109} dk_format_capacities_t;
110
060df5ea
A
111typedef 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
0c530ab8
A
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)
91447636 128
2d21ac55
A
129#define DKIOCGETBLOCKSIZE _IOR('d', 24, uint32_t)
130#define DKIOCGETBLOCKCOUNT _IOR('d', 25, uint64_t)
0c530ab8 131#define DKIOCGETFIRMWAREPATH _IOR('d', 28, dk_firmware_path_t)
55e303ae 132
2d21ac55
A
133#define DKIOCISFORMATTED _IOR('d', 23, uint32_t)
134#define DKIOCISWRITABLE _IOR('d', 29, uint32_t)
9bccf70c 135
c910b4d9 136#define DKIOCREQUESTIDLE _IO('d', 30)
060df5ea 137#define DKIOCUNMAP _IOW('d', 31, dk_unmap_t)
593a1d5f 138
2d21ac55
A
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)
9bccf70c 143
2d21ac55
A
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)
9bccf70c 148
2d21ac55
A
149#define DKIOCGETMINSEGMENTALIGNMENTBYTECOUNT _IOR('d', 74, uint64_t)
150#define DKIOCGETMAXSEGMENTADDRESSABLEBITCOUNT _IOR('d', 75, uint64_t)
9bccf70c 151
060df5ea 152#define DKIOCGETFEATURES _IOR('d', 76, uint32_t)
593a1d5f 153#define DKIOCGETPHYSICALBLOCKSIZE _IOR('d', 77, uint32_t)
b0d623f7 154#define DKIOCGETCOMMANDPOOLSIZE _IOR('d', 78, uint32_t)
593a1d5f 155
9bccf70c 156#ifdef KERNEL
2d21ac55 157#define DK_FEATURE_FORCE_UNIT_ACCESS 0x00000001
6d2010ae
A
158
159typedef 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
2d21ac55
A
169#define DKIOCGETBLOCKCOUNT32 _IOR('d', 25, uint32_t)
170#define DKIOCSETBLOCKSIZE _IOW('d', 24, uint32_t)
171#define DKIOCGETBSDUNIT _IOR('d', 27, uint32_t)
6d2010ae 172#define DKIOCISSOLIDSTATE _IOR('d', 79, uint32_t)
2d21ac55
A
173#define DKIOCISVIRTUAL _IOR('d', 72, uint32_t)
174#define DKIOCGETBASE _IOR('d', 73, uint64_t)
6d2010ae
A
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)
39236c6e
A
179#define DKIOCGETMAXPRIORITYCOUNT _IOR('d', 84, uint32_t)
180
181#ifdef XNU_KERNEL_PRIVATE
182typedef 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
190typedef dk_memdev_info_t memdev_info_t;
191
192#define DKIOCGETMEMDEVINFO _IOR('d', 90, dk_memdev_info_t)
193#endif /* XNU_KERNEL_PRIVATE */
7ddcb079 194#ifdef PRIVATE
316670eb
A
195typedef 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)
39236c6e
A
203typedef 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)
7ddcb079 210#endif /* PRIVATE */
9bccf70c
A
211#endif /* KERNEL */
212
316670eb
A
213#ifdef PRIVATE
214#ifdef TARGET_OS_EMBEDDED
215#define _DKIOCSETSTATIC _IO('d', 84)
216#endif /* TARGET_OS_EMBEDDED */
217#endif /* PRIVATE */
218
9bccf70c 219#endif /* _SYS_DISK_H_ */