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