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