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