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