]>
Commit | Line | Data |
---|---|---|
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 | /* 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 | ||
69 | #include <sys/appleapiopts.h> | |
70 | ||
71 | /* | |
72 | * Definitions of device driver entry switches | |
73 | */ | |
74 | ||
75 | struct buf; | |
76 | struct proc; | |
77 | struct tty; | |
78 | struct uio; | |
79 | struct vnode; | |
80 | ||
81 | #ifdef __APPLE_API_UNSTABLE | |
82 | /* | |
83 | * Device switch function types. | |
84 | */ | |
85 | typedef int open_close_fcn_t __P((dev_t dev, int flags, int devtype, | |
86 | struct proc *p)); | |
87 | ||
88 | typedef struct tty *d_devtotty_t __P((dev_t dev)); | |
89 | ||
90 | typedef void strategy_fcn_t __P((struct buf *bp)); | |
91 | typedef int ioctl_fcn_t __P((dev_t dev, u_long cmd, caddr_t data, | |
92 | int fflag, struct proc *p)); | |
93 | typedef int dump_fcn_t (); /* parameters vary by architecture */ | |
94 | typedef int psize_fcn_t __P((dev_t dev)); | |
95 | typedef int read_write_fcn_t __P((dev_t dev, struct uio *uio, int ioflag)); | |
96 | typedef int stop_fcn_t __P((struct tty *tp, int rw)); | |
97 | typedef int reset_fcn_t __P((int uban)); | |
98 | typedef int select_fcn_t __P((dev_t dev, int which, void * wql, struct proc *p)); | |
99 | typedef int mmap_fcn_t __P(()); | |
100 | typedef int getc_fcn_t __P((dev_t dev)); | |
101 | typedef int putc_fcn_t __P((dev_t dev, char c)); | |
102 | typedef int d_poll_t __P((dev_t dev, int events, struct proc *p)); | |
103 | ||
104 | #define d_open_t open_close_fcn_t | |
105 | #define d_close_t open_close_fcn_t | |
106 | #define d_read_t read_write_fcn_t | |
107 | #define d_write_t read_write_fcn_t | |
108 | #define d_ioctl_t ioctl_fcn_t | |
109 | ||
110 | __BEGIN_DECLS | |
111 | int enodev (); /* avoid actual prototype for multiple use */ | |
112 | void enodev_strat(); | |
113 | __END_DECLS | |
114 | ||
115 | /* | |
116 | * Versions of enodev() pointer, cast to appropriate function type. For use | |
117 | * in empty devsw slots. | |
118 | */ | |
119 | #define eno_opcl ((open_close_fcn_t *)&enodev) | |
120 | #define eno_strat ((strategy_fcn_t *)&enodev_strat) | |
121 | #define eno_ioctl ((ioctl_fcn_t *)&enodev) | |
122 | #define eno_dump ((dump_fcn_t *)&enodev) | |
123 | #define eno_psize ((psize_fcn_t *)&enodev) | |
124 | #define eno_rdwrt ((read_write_fcn_t *)&enodev) | |
125 | #define eno_stop ((stop_fcn_t *)&enodev) | |
126 | #define eno_reset ((reset_fcn_t *)&enodev) | |
127 | #define eno_mmap ((mmap_fcn_t *)&enodev) | |
128 | #define eno_getc ((getc_fcn_t *)&enodev) | |
129 | #define eno_putc ((putc_fcn_t *)&enodev) | |
130 | #define eno_select ((select_fcn_t *)&enodev) | |
131 | ||
132 | /* | |
133 | * Types for d_type. | |
134 | */ | |
135 | #define D_TAPE 1 | |
136 | #define D_DISK 2 | |
137 | #define D_TTY 3 | |
138 | ||
139 | /* | |
140 | * Block device switch table | |
141 | */ | |
142 | struct bdevsw { | |
143 | open_close_fcn_t *d_open; | |
144 | open_close_fcn_t *d_close; | |
145 | strategy_fcn_t *d_strategy; | |
146 | ioctl_fcn_t *d_ioctl; | |
147 | dump_fcn_t *d_dump; | |
148 | psize_fcn_t *d_psize; | |
149 | int d_type; | |
150 | }; | |
151 | ||
152 | #ifdef KERNEL | |
153 | ||
154 | d_devtotty_t nodevtotty; | |
155 | d_write_t nowrite; | |
156 | ||
157 | #ifdef __APPLE_API_PRIVATE | |
158 | extern struct bdevsw bdevsw[]; | |
159 | #endif /* __APPLE_API_PRIVATE */ | |
160 | ||
161 | /* | |
162 | * Contents of empty bdevsw slot. | |
163 | */ | |
164 | #define NO_BDEVICE \ | |
165 | { eno_opcl, eno_opcl, eno_strat, eno_ioctl, \ | |
166 | eno_dump, eno_psize, 0 } | |
167 | ||
168 | #endif /* KERNEL */ | |
169 | ||
170 | /* | |
171 | * Character device switch table | |
172 | */ | |
173 | struct cdevsw { | |
174 | open_close_fcn_t *d_open; | |
175 | open_close_fcn_t *d_close; | |
176 | read_write_fcn_t *d_read; | |
177 | read_write_fcn_t *d_write; | |
178 | ioctl_fcn_t *d_ioctl; | |
179 | stop_fcn_t *d_stop; | |
180 | reset_fcn_t *d_reset; | |
181 | struct tty **d_ttys; | |
182 | select_fcn_t *d_select; | |
183 | mmap_fcn_t *d_mmap; | |
184 | strategy_fcn_t *d_strategy; | |
185 | getc_fcn_t *d_getc; | |
186 | putc_fcn_t *d_putc; | |
187 | int d_type; | |
188 | }; | |
189 | ||
190 | #ifdef KERNEL | |
191 | ||
192 | #ifdef __APPLE_API_PRIVATE | |
193 | extern struct cdevsw cdevsw[]; | |
194 | #endif /* __APPLE_API_PRIVATE */ | |
195 | ||
196 | /* | |
197 | * Contents of empty cdevsw slot. | |
198 | */ | |
199 | ||
200 | #define NO_CDEVICE \ | |
201 | { \ | |
202 | eno_opcl, eno_opcl, eno_rdwrt, eno_rdwrt, \ | |
203 | eno_ioctl, eno_stop, eno_reset, 0, \ | |
204 | seltrue, eno_mmap, eno_strat, eno_getc, \ | |
205 | eno_putc, 0 \ | |
206 | } | |
207 | #endif /* KERNEL */ | |
208 | ||
209 | /* | |
210 | * Line discipline switch table | |
211 | */ | |
212 | struct linesw { | |
213 | int (*l_open) __P((dev_t dev, struct tty *tp)); | |
214 | int (*l_close) __P((struct tty *tp, int flags)); | |
215 | int (*l_read) __P((struct tty *tp, struct uio *uio, | |
216 | int flag)); | |
217 | int (*l_write) __P((struct tty *tp, struct uio *uio, | |
218 | int flag)); | |
219 | int (*l_ioctl) __P((struct tty *tp, u_long cmd, caddr_t data, | |
220 | int flag, struct proc *p)); | |
221 | int (*l_rint) __P((int c, struct tty *tp)); | |
222 | int (*l_start) __P((struct tty *tp)); | |
223 | int (*l_modem) __P((struct tty *tp, int flag)); | |
224 | }; | |
225 | ||
226 | #ifdef KERNEL | |
227 | ||
228 | #ifdef __APPLE_API_PRIVATE | |
229 | extern struct linesw linesw[]; | |
230 | extern int nlinesw; | |
231 | #endif /* __APPLE_API_PRIVATE */ | |
232 | ||
233 | int ldisc_register __P((int , struct linesw *)); | |
234 | void ldisc_deregister __P((int)); | |
235 | #define LDISC_LOAD -1 /* Loadable line discipline */ | |
236 | ||
237 | #endif /* KERNEL */ | |
238 | ||
239 | #ifdef __APPLE_API_OBSOLETE | |
240 | /* | |
241 | * Swap device table | |
242 | */ | |
243 | struct swdevt { | |
244 | dev_t sw_dev; | |
245 | int sw_flags; | |
246 | int sw_nblks; | |
247 | struct vnode *sw_vp; | |
248 | }; | |
249 | #define SW_FREED 0x01 | |
250 | #define SW_SEQUENTIAL 0x02 | |
251 | #define sw_freed sw_flags /* XXX compat */ | |
252 | ||
253 | #ifdef KERNEL | |
254 | extern struct swdevt swdevt[]; | |
255 | #endif /* KERNEL */ | |
256 | ||
257 | #endif /* __APPLE_API_OBSOLETE */ | |
258 | ||
259 | ||
260 | #ifdef KERNEL | |
261 | /* | |
262 | * ***_free finds free slot; | |
263 | * ***_add adds entries to the devsw table | |
264 | * If int arg is -1; finds a free slot | |
265 | * Returns the major number if successful | |
266 | * else -1 | |
267 | */ | |
268 | __BEGIN_DECLS | |
269 | int bdevsw_isfree __P((int)); | |
270 | int bdevsw_add __P((int, struct bdevsw *)); | |
271 | int bdevsw_remove __P((int, struct bdevsw *)); | |
272 | int cdevsw_isfree __P((int)); | |
273 | int cdevsw_add __P((int, struct cdevsw *)); | |
274 | int cdevsw_remove __P((int, struct cdevsw *)); | |
275 | __END_DECLS | |
276 | #endif /* KERNEL */ | |
277 | ||
278 | #endif /* __APPLE_API_UNSTABLE */ | |
279 | ||
280 | #endif /* _SYS_CONF_H_ */ |