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