]> git.saurik.com Git - apple/xnu.git/blob - bsd/sys/conf.h
8b45c062dcb17eca88335c7528bf7d496356519e
[apple/xnu.git] / bsd / sys / conf.h
1 /*
2 * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_OSREFERENCE_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
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
29 */
30 /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
31 /*-
32 * Copyright (c) 1990, 1993
33 * The Regents of the University of California. All rights reserved.
34 * (c) UNIX System Laboratories, Inc.
35 * All or some portions of this file are derived from material licensed
36 * to the University of California by American Telephone and Telegraph
37 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
38 * the permission of UNIX System Laboratories, Inc.
39 *
40 * Redistribution and use in source and binary forms, with or without
41 * modification, are permitted provided that the following conditions
42 * are met:
43 * 1. Redistributions of source code must retain the above copyright
44 * notice, this list of conditions and the following disclaimer.
45 * 2. Redistributions in binary form must reproduce the above copyright
46 * notice, this list of conditions and the following disclaimer in the
47 * documentation and/or other materials provided with the distribution.
48 * 3. All advertising materials mentioning features or use of this software
49 * must display the following acknowledgement:
50 * This product includes software developed by the University of
51 * California, Berkeley and its contributors.
52 * 4. Neither the name of the University nor the names of its contributors
53 * may be used to endorse or promote products derived from this software
54 * without specific prior written permission.
55 *
56 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
57 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
59 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
60 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
61 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
62 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
64 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
65 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
66 * SUCH DAMAGE.
67 *
68 * @(#)conf.h 8.5 (Berkeley) 1/9/95
69 */
70
71 #ifndef _SYS_CONF_H_
72 #define _SYS_CONF_H_ 1
73
74 #include <sys/appleapiopts.h>
75 #include <sys/cdefs.h>
76
77 /*
78 * Definitions of device driver entry switches
79 */
80
81 struct buf;
82 struct proc;
83 struct tty;
84 struct uio;
85 struct vnode;
86
87 /*
88 * Types for d_type.
89 * These are returned by ioctl FIODTYPE
90 */
91 #define D_TAPE 1
92 #define D_DISK 2
93 #define D_TTY 3
94
95 #ifdef KERNEL
96 /*
97 * Device switch function types.
98 */
99 typedef int open_close_fcn_t(dev_t dev, int flags, int devtype,
100 struct proc *p);
101
102 typedef struct tty *d_devtotty_t(dev_t dev);
103
104 typedef void strategy_fcn_t(struct buf *bp);
105 typedef int ioctl_fcn_t(dev_t dev, u_long cmd, caddr_t data,
106 int fflag, struct proc *p);
107 typedef int dump_fcn_t(void); /* parameters vary by architecture */
108 typedef int psize_fcn_t(dev_t dev);
109 typedef int read_write_fcn_t(dev_t dev, struct uio *uio, int ioflag);
110 typedef int stop_fcn_t(struct tty *tp, int rw);
111 typedef int reset_fcn_t(int uban);
112 typedef int select_fcn_t(dev_t dev, int which, void * wql, struct proc *p);
113 typedef int mmap_fcn_t(void);
114 typedef int getc_fcn_t(dev_t dev);
115 typedef int putc_fcn_t(dev_t dev, char c);
116 typedef int d_poll_t(dev_t dev, int events, struct proc *p);
117
118 #define d_open_t open_close_fcn_t
119 #define d_close_t open_close_fcn_t
120 #define d_read_t read_write_fcn_t
121 #define d_write_t read_write_fcn_t
122 #define d_ioctl_t ioctl_fcn_t
123 #define d_stop_t stop_fcn_t
124 #define d_reset_t reset_fcn_t
125 #define d_select_t select_fcn_t
126 #define d_mmap_t mmap_fcn_t
127 #define d_strategy_t strategy_fcn_t
128 #define d_getc_t getc_fcn_t
129 #define d_putc_t putc_fcn_t
130
131 __BEGIN_DECLS
132 int enodev(void);
133 void enodev_strat(void);
134 __END_DECLS
135
136 /*
137 * Versions of enodev() pointer, cast to appropriate function type. For use
138 * in empty devsw slots.
139 */
140 #define eno_opcl ((open_close_fcn_t *)&enodev)
141 #define eno_strat ((strategy_fcn_t *)&enodev_strat)
142 #define eno_ioctl ((ioctl_fcn_t *)&enodev)
143 #define eno_dump ((dump_fcn_t *)&enodev)
144 #define eno_psize ((psize_fcn_t *)&enodev)
145 #define eno_rdwrt ((read_write_fcn_t *)&enodev)
146 #define eno_stop ((stop_fcn_t *)&enodev)
147 #define eno_reset ((reset_fcn_t *)&enodev)
148 #define eno_mmap ((mmap_fcn_t *)&enodev)
149 #define eno_getc ((getc_fcn_t *)&enodev)
150 #define eno_putc ((putc_fcn_t *)&enodev)
151 #define eno_select ((select_fcn_t *)&enodev)
152
153
154 /*
155 * Block device switch table
156 */
157 struct bdevsw {
158 open_close_fcn_t *d_open;
159 open_close_fcn_t *d_close;
160 strategy_fcn_t *d_strategy;
161 ioctl_fcn_t *d_ioctl;
162 dump_fcn_t *d_dump;
163 psize_fcn_t *d_psize;
164 int d_type;
165 };
166
167
168 d_devtotty_t nodevtotty;
169 d_write_t nowrite;
170
171 #ifdef KERNEL_PRIVATE
172 extern struct bdevsw bdevsw[];
173 #endif /* KERNEL_PRIVATE */
174
175 /*
176 * Contents of empty bdevsw slot.
177 */
178 #define NO_BDEVICE \
179 { eno_opcl, eno_opcl, eno_strat, eno_ioctl, \
180 eno_dump, eno_psize, 0 }
181
182
183 /*
184 * Character device switch table
185 */
186 struct cdevsw {
187 open_close_fcn_t *d_open;
188 open_close_fcn_t *d_close;
189 read_write_fcn_t *d_read;
190 read_write_fcn_t *d_write;
191 ioctl_fcn_t *d_ioctl;
192 stop_fcn_t *d_stop;
193 reset_fcn_t *d_reset;
194 struct tty **d_ttys;
195 select_fcn_t *d_select;
196 mmap_fcn_t *d_mmap;
197 strategy_fcn_t *d_strategy;
198 getc_fcn_t *d_getc;
199 putc_fcn_t *d_putc;
200 int d_type;
201 };
202
203
204 #ifdef KERNEL_PRIVATE
205 extern struct cdevsw cdevsw[];
206 #endif /* KERNEL_PRIVATE */
207
208 /*
209 * Contents of empty cdevsw slot.
210 */
211
212 #define NO_CDEVICE \
213 { \
214 eno_opcl, eno_opcl, eno_rdwrt, eno_rdwrt, \
215 eno_ioctl, eno_stop, eno_reset, 0, \
216 (select_fcn_t *)seltrue, eno_mmap, eno_strat, eno_getc, \
217 eno_putc, 0 \
218 }
219
220 #endif /* KERNEL */
221
222 #ifdef KERNEL_PRIVATE
223 typedef int l_open_t (dev_t dev, struct tty *tp);
224 typedef int l_close_t(struct tty *tp, int flags);
225 typedef int l_read_t (struct tty *tp, struct uio *uio, int flag);
226 typedef int l_write_t(struct tty *tp, struct uio *uio, int flag);
227 typedef int l_ioctl_t(struct tty *tp, u_long cmd, caddr_t data, int flag,
228 struct proc *p);
229 typedef int l_rint_t (int c, struct tty *tp);
230 typedef void l_start_t(struct tty *tp);
231 typedef int l_modem_t(struct tty *tp, int flag);
232
233 /*
234 * Line discipline switch table
235 */
236 struct linesw {
237 l_open_t *l_open;
238 l_close_t *l_close;
239 l_read_t *l_read;
240 l_write_t *l_write;
241 l_ioctl_t *l_ioctl;
242 l_rint_t *l_rint;
243 l_start_t *l_start;
244 l_modem_t *l_modem;
245 };
246
247
248 extern struct linesw linesw[];
249 extern int nlinesw;
250
251 int ldisc_register(int , struct linesw *);
252 void ldisc_deregister(int);
253 #define LDISC_LOAD -1 /* Loadable line discipline */
254
255 #endif /* KERNEL_PRIVATE */
256
257 #ifdef BSD_KERNEL_PRIVATE
258 /*
259 * Swap device table
260 */
261 struct swdevt {
262 dev_t sw_dev;
263 int sw_flags;
264 int sw_nblks;
265 struct vnode *sw_vp;
266 };
267 #define SW_FREED 0x01
268 #define SW_SEQUENTIAL 0x02
269 #define sw_freed sw_flags /* XXX compat */
270
271 extern struct swdevt swdevt[];
272
273 #endif /* BSD_KERNEL_PRIVATE */
274
275
276 #ifdef KERNEL
277 /*
278 * ***_free finds free slot;
279 * ***_add adds entries to the devsw table
280 * If int arg is -1; finds a free slot
281 * Returns the major number if successful
282 * else -1
283 */
284 __BEGIN_DECLS
285 int bdevsw_isfree(int);
286 int bdevsw_add(int, struct bdevsw *);
287 int bdevsw_remove(int, struct bdevsw *);
288 int cdevsw_isfree(int);
289 int cdevsw_add(int, struct cdevsw *);
290 int cdevsw_add_with_bdev(int index, struct cdevsw * csw, int bdev);
291 int cdevsw_remove(int, struct cdevsw *);
292 __END_DECLS
293 #endif /* KERNEL */
294
295 #endif /* _SYS_CONF_H_ */