]> git.saurik.com Git - apple/xnu.git/blame - bsd/sys/conf.h
xnu-6153.81.5.tar.gz
[apple/xnu.git] / bsd / sys / conf.h
CommitLineData
1c79356b 1/*
316670eb 2 * Copyright (c) 2000-2012 Apple Computer, Inc. All rights reserved.
5d5c5d0d 3 *
2d21ac55 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
0a7de745 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.
0a7de745 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.
0a7de745 17 *
2d21ac55
A
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.
0a7de745 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
81struct buf;
82struct proc;
83struct tty;
84struct uio;
85struct vnode;
86
91447636
A
87/*
88 * Types for d_type.
89 * These are returned by ioctl FIODTYPE
90 */
0a7de745
A
91#define D_TAPE 1
92#define D_DISK 2
93#define D_TTY 3
91447636
A
94
95#ifdef KERNEL
0a7de745 96/*
1c79356b
A
97 * Device switch function types.
98 */
91447636 99typedef int open_close_fcn_t(dev_t dev, int flags, int devtype,
0a7de745 100 struct proc *p);
91447636
A
101
102typedef struct tty *d_devtotty_t(dev_t dev);
103
0a7de745 104typedef void strategy_fcn_t(struct buf *bp);
91447636 105typedef int ioctl_fcn_t(dev_t dev, u_long cmd, caddr_t data,
0a7de745 106 int fflag, struct proc *p);
91447636 107typedef int dump_fcn_t(void); /* parameters vary by architecture */
0a7de745 108typedef int psize_fcn_t(dev_t dev);
91447636 109typedef int read_write_fcn_t(dev_t dev, struct uio *uio, int ioflag);
0a7de745
A
110typedef int stop_fcn_t(struct tty *tp, int rw);
111typedef int reset_fcn_t(int uban);
112typedef int select_fcn_t(dev_t dev, int which, void * wql, struct proc *p);
113typedef int mmap_fcn_t(void);
114
115#define d_open_t open_close_fcn_t
116#define d_close_t open_close_fcn_t
117#define d_read_t read_write_fcn_t
118#define d_write_t read_write_fcn_t
119#define d_ioctl_t ioctl_fcn_t
120#define d_stop_t stop_fcn_t
121#define d_reset_t reset_fcn_t
122#define d_select_t select_fcn_t
123#define d_mmap_t mmap_fcn_t
124#define d_strategy_t strategy_fcn_t
1c79356b
A
125
126__BEGIN_DECLS
0a7de745
A
127int enodev(void);
128void enodev_strat(void);
1c79356b
A
129__END_DECLS
130
131/*
132 * Versions of enodev() pointer, cast to appropriate function type. For use
133 * in empty devsw slots.
134 */
0a7de745
A
135#define eno_opcl ((open_close_fcn_t *)&enodev)
136#define eno_strat ((strategy_fcn_t *)&enodev_strat)
137#define eno_ioctl ((ioctl_fcn_t *)&enodev)
138#define eno_dump ((dump_fcn_t *)&enodev)
139#define eno_psize ((psize_fcn_t *)&enodev)
140#define eno_rdwrt ((read_write_fcn_t *)&enodev)
141#define eno_stop ((stop_fcn_t *)&enodev)
142#define eno_reset ((reset_fcn_t *)&enodev)
143#define eno_mmap ((mmap_fcn_t *)&enodev)
144#define eno_select ((select_fcn_t *)&enodev)
1c79356b 145
b0d623f7 146/* For source backward compatibility only! */
0a7de745
A
147#define eno_getc ((void *)&enodev)
148#define eno_putc ((void *)&enodev)
1c79356b
A
149
150/*
151 * Block device switch table
152 */
153struct bdevsw {
0a7de745
A
154 open_close_fcn_t *d_open;
155 open_close_fcn_t *d_close;
156 strategy_fcn_t *d_strategy;
157 ioctl_fcn_t *d_ioctl;
158 dump_fcn_t *d_dump;
159 psize_fcn_t *d_psize;
160 int d_type;
1c79356b
A
161};
162
1c79356b
A
163
164d_devtotty_t nodevtotty;
0a7de745 165d_write_t nowrite;
1c79356b 166
91447636 167#ifdef KERNEL_PRIVATE
1c79356b 168extern struct bdevsw bdevsw[];
316670eb 169extern int (*bootcache_contains_block)(dev_t device, u_int64_t blkno);
91447636 170#endif /* KERNEL_PRIVATE */
1c79356b
A
171
172/*
173 * Contents of empty bdevsw slot.
174 */
0a7de745
A
175#define NO_BDEVICE \
176 { eno_opcl, eno_opcl, eno_strat, eno_ioctl, \
177 eno_dump, eno_psize, 0 }
178
1c79356b
A
179
180/*
181 * Character device switch table
182 */
183struct cdevsw {
0a7de745
A
184 open_close_fcn_t *d_open;
185 open_close_fcn_t *d_close;
186 read_write_fcn_t *d_read;
187 read_write_fcn_t *d_write;
188 ioctl_fcn_t *d_ioctl;
189 stop_fcn_t *d_stop;
190 reset_fcn_t *d_reset;
191 struct tty **d_ttys;
192 select_fcn_t *d_select;
193 mmap_fcn_t *d_mmap;
194 strategy_fcn_t *d_strategy;
195 void *d_reserved_1;
196 void *d_reserved_2;
197 int d_type;
1c79356b
A
198};
199
6d2010ae 200#ifdef BSD_KERNEL_PRIVATE
6d2010ae
A
201
202extern uint64_t cdevsw_flags[];
5ba3f43e
A
203#define CDEVSW_SELECT_KQUEUE 0x01
204#define CDEVSW_USE_OFFSET 0x02
205#define CDEVSW_IS_PTC 0x04
206#define CDEVSW_IS_PTS 0x08
6d2010ae
A
207
208struct thread;
209
210typedef struct devsw_lock {
0a7de745
A
211 TAILQ_ENTRY(devsw_lock) dl_list;
212 struct thread *dl_thread;
213 dev_t dl_dev;
214 int dl_mode;
6d2010ae
A
215} *devsw_lock_t;
216
217#endif /* BSD_KERNEL_PRIVATE */
1c79356b 218
1c79356b
A
219
220/*
221 * Contents of empty cdevsw slot.
222 */
223
0a7de745
A
224#define NO_CDEVICE \
225 { \
226 eno_opcl, eno_opcl, eno_rdwrt, eno_rdwrt, \
227 eno_ioctl, eno_stop, eno_reset, 0, \
228 (select_fcn_t *)seltrue, eno_mmap, eno_strat, eno_getc, \
229 eno_putc, 0 \
1c79356b 230 }
0a7de745 231
9bccf70c 232#endif /* KERNEL */
0a7de745 233
91447636
A
234#ifdef KERNEL_PRIVATE
235typedef int l_open_t (dev_t dev, struct tty *tp);
236typedef int l_close_t(struct tty *tp, int flags);
237typedef int l_read_t (struct tty *tp, struct uio *uio, int flag);
238typedef int l_write_t(struct tty *tp, struct uio *uio, int flag);
239typedef int l_ioctl_t(struct tty *tp, u_long cmd, caddr_t data, int flag,
0a7de745 240 struct proc *p);
91447636
A
241typedef int l_rint_t (int c, struct tty *tp);
242typedef void l_start_t(struct tty *tp);
243typedef int l_modem_t(struct tty *tp, int flag);
244
1c79356b
A
245/*
246 * Line discipline switch table
247 */
248struct linesw {
0a7de745
A
249 l_open_t *l_open;
250 l_close_t *l_close;
251 l_read_t *l_read;
252 l_write_t *l_write;
253 l_ioctl_t *l_ioctl;
254 l_rint_t *l_rint;
255 l_start_t *l_start;
256 l_modem_t *l_modem;
1c79356b
A
257};
258
9bccf70c 259
1c79356b 260extern struct linesw linesw[];
fe8ab488 261extern const int nlinesw;
0a7de745
A
262
263int ldisc_register(int, struct linesw *);
91447636 264void ldisc_deregister(int);
1c79356b 265#define LDISC_LOAD -1 /* Loadable line discipline */
1c79356b 266
91447636 267#endif /* KERNEL_PRIVATE */
9bccf70c 268
91447636 269#ifdef BSD_KERNEL_PRIVATE
1c79356b
A
270/*
271 * Swap device table
272 */
273struct swdevt {
0a7de745
A
274 dev_t sw_dev;
275 int sw_flags;
276 int sw_nblks;
277 struct vnode *sw_vp;
1c79356b 278};
0a7de745
A
279#define SW_FREED 0x01
280#define SW_SEQUENTIAL 0x02
281#define sw_freed sw_flags /* XXX compat */
1c79356b 282
1c79356b 283extern struct swdevt swdevt[];
9bccf70c 284
91447636 285#endif /* BSD_KERNEL_PRIVATE */
9bccf70c 286
1c79356b
A
287
288#ifdef KERNEL
289/*
290 * ***_free finds free slot;
291 * ***_add adds entries to the devsw table
292 * If int arg is -1; finds a free slot
293 * Returns the major number if successful
294 * else -1
295 */
296__BEGIN_DECLS
6d2010ae 297#ifdef KERNEL_PRIVATE
39037602 298void devsw_init(void);
6d2010ae
A
299extern struct cdevsw cdevsw[];
300extern int cdevsw_setkqueueok(int, struct cdevsw*, int);
301#endif /* KERNEL_PRIVATE */
302
303#ifdef BSD_KERNEL_PRIVATE
304extern void devsw_lock(dev_t, int);
305extern void devsw_unlock(dev_t, int);
306#endif /* BSD_KERNEL_PRIVATE */
307
91447636
A
308int bdevsw_isfree(int);
309int bdevsw_add(int, struct bdevsw *);
310int bdevsw_remove(int, struct bdevsw *);
311int cdevsw_isfree(int);
312int cdevsw_add(int, struct cdevsw *);
313int cdevsw_add_with_bdev(int index, struct cdevsw * csw, int bdev);
314int cdevsw_remove(int, struct cdevsw *);
b0d623f7 315int isdisk(dev_t, int);
1c79356b 316__END_DECLS
9bccf70c
A
317#endif /* KERNEL */
318
1c79356b 319#endif /* _SYS_CONF_H_ */