]> git.saurik.com Git - apple/xnu.git/blob - bsd/dev/disk.h
8d672d97c3ccf9cd83367fd126fbac6232c31a4f
[apple/xnu.git] / bsd / dev / disk.h
1 /*
2 * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /* @(#)disk.h 1.0 08/29/87 (c) 1987 NeXT */
26
27 #ifndef _BSD_DEV_DISK_
28 #define _BSD_DEV_DISK_
29 #ifndef _SYS_DISK_H_
30 #define _SYS_DISK_H_
31
32 #include <sys/appleapiopts.h>
33 #include <mach/machine/vm_types.h>
34 #include <mach/machine/boolean.h>
35 #include <sys/types.h>
36 #include <sys/ioctl.h>
37 #include <sys/time.h>
38 #include <dev/disk_label.h>
39
40 /*
41 * USE <sys/disk.h> INSTEAD (NOTE: DKIOCGETBLOCKCOUNT -> DKIOCGETBLOCKCOUNT32)
42 */
43
44 #ifdef __APPLE_API_OBSOLETE
45
46 #define DR_CMDSIZE 32
47 #define DR_ERRSIZE 32
48
49 struct disk_req {
50 int dr_bcount; /* byte count for data transfers */
51 caddr_t dr_addr; /* memory addr for data transfers */
52 struct timeval dr_exec_time; /* execution time of operation */
53
54 /*
55 * interpretation of cmdblk and errblk is driver specific.
56 */
57 char dr_cmdblk[DR_CMDSIZE];
58 char dr_errblk[DR_ERRSIZE];
59 };
60
61 struct sdc_wire {
62 vm_offset_t start, end;
63 boolean_t new_pageable;
64 };
65
66
67 #define BAD_BLK_OFF 4 /* offset of bad blk tbl from label */
68 #define NBAD_BLK (12 * 1024 / sizeof (int))
69
70 struct bad_block { /* bad block table, sized to be 12KB */
71 int bad_blk[NBAD_BLK];
72 };
73
74 /*
75 * sector bitmap states (2 bits per sector)
76 */
77 #define SB_UNTESTED 0 /* must be zero */
78 #define SB_BAD 1
79 #define SB_WRITTEN 2
80 #define SB_ERASED 3
81
82 struct drive_info { /* info about drive hardware */
83 char di_name[MAXDNMLEN]; /* drive type name */
84 int di_label_blkno[NLABELS];/* label loc'ns in DEVICE SECTORS */
85 int di_devblklen; /* device sector size */
86 int di_maxbcount; /* max bytes per transfer request */
87 };
88
89 #define DS_STATSIZE 32
90
91 struct disk_stats {
92 int s_ecccnt; /* avg ECC corrections per sector */
93 int s_maxecc; /* max ECC corrections observed */
94
95 /*
96 * interpretation of s_stats is driver specific
97 */
98 char s_stats[DS_STATSIZE];
99 };
100
101 struct drive_location {
102 char location[ 128 ];
103 };
104
105 #define DKIOCGLABEL _IOR('d', 0,struct disk_label) /* read label */
106 #define DKIOCSLABEL _IOW('d', 1,struct disk_label) /* write label */
107 #define DKIOCGBITMAP _IO('d', 2) /* read bitmap */
108 #define DKIOCSBITMAP _IO('d', 3) /* write bitmap */
109 #define DKIOCREQ _IOWR('d', 4, struct disk_req) /* cmd request */
110 #define DKIOCINFO _IOR('d', 5, struct drive_info) /* get drive info */
111 #define DKIOCZSTATS _IO('d',7) /* zero statistics */
112 #define DKIOCGSTATS _IO('d', 8) /* get statistics */
113 #define DKIOCRESET _IO('d', 9) /* reset disk */
114 #define DKIOCGFLAGS _IOR('d', 11, int) /* get driver flags */
115 #define DKIOCSFLAGS _IOW('d', 12, int) /* set driver flags */
116 #define DKIOCSDCWIRE _IOW('d', 14, struct sdc_wire) /* sdc wire memory */
117 #define DKIOCSDCLOCK _IO('d', 15) /* sdc lock */
118 #define DKIOCSDCUNLOCK _IO('d', 16) /* sdc unlock */
119 #define DKIOCGFREEVOL _IOR('d', 17, int) /* get free volume # */
120 #define DKIOCGBBT _IO('d', 18) /* read bad blk tbl */
121 #define DKIOCSBBT _IO('d', 19) /* write bad blk tbl */
122 #define DKIOCMNOTIFY _IOW('d', 20, int) /* message on insert */
123 #define DKIOCEJECT _IO('d', 21) /* eject disk */
124 #define DKIOCPANELPRT _IOW('d', 22, int) /* register Panel */
125 /* Request port */
126 #define DKIOCSFORMAT _IOW('d', 23, int) /* set 'Formatted' flag */
127 #define DKIOCGFORMAT _IOR('d', 23, int) /* get 'Formatted' flag */
128 #define DKIOCBLKSIZE _IOR('d', 24, int) /* device sector size */
129 #define DKIOCNUMBLKS _IOR('d', 25, int) /* number of sectors */
130 #define DKIOCCHECKINSERT _IO('d',26) /* manually poll removable */
131 /* media drive */
132 #define DKIOCCANCELAUTOMOUNT _IOW('d',27, dev_t) /* cancel automount request */
133 #define DKIOCGLOCATION _IOR('d',28, struct drive_location) /* arch dependent location descrip */
134 #define DKIOCSETBLOCKSIZE _IOW('d', 24, int) /* set media's preferred sector size */
135 #define DKIOCGETBLOCKSIZE DKIOCBLKSIZE /* get media's preferred sector size */
136 #define DKIOCGETBLOCKCOUNT32 DKIOCNUMBLKS /* get media's sector count */
137 #define DKIOCGETBLOCKCOUNT64 _IOR('d', 25, u_int64_t) /* get media's sector count */
138 #define DKIOCGETLOCATION DKIOCGLOCATION /* get media's location description */
139 #define DKIOCISFORMATTED DKIOCGFORMAT /* is media formatted? */
140 #define DKIOCISWRITABLE _IOR('d', 29, int) /* is media writable? */
141
142 #define DKIOCGETMAXBLOCKCOUNTREAD _IOR('d', 64, u_int64_t) /* get device's maximum block count for read requests */
143 #define DKIOCGETMAXBLOCKCOUNTWRITE _IOR('d', 65, u_int64_t) /* get device's maximum block count for write requests */
144 #define DKIOCGETMAXSEGMENTCOUNTREAD _IOR('d', 66, u_int64_t) /* get device's maximum physical segment count for read buffers */
145 #define DKIOCGETMAXSEGMENTCOUNTWRITE _IOR('d', 67, u_int64_t) /* get device's maximum physical segment count for write buffers */
146
147 #endif /* __APPLE_API_OBSOLETE */
148
149 #endif /* _SYS_DISK_H_ */
150 #endif /* _BSD_DEV_DISK_ */