conf.h revision 49678
1/*-
2 * Copyright (c) 1990, 1993
3 *	The Regents of the University of California.  All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 *    notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 *    notice, this list of conditions and the following disclaimer in the
17 *    documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 *    must display the following acknowledgement:
20 *	This product includes software developed by the University of
21 *	California, Berkeley and its contributors.
22 * 4. Neither the name of the University nor the names of its contributors
23 *    may be used to endorse or promote products derived from this software
24 *    without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 *	@(#)conf.h	8.5 (Berkeley) 1/9/95
39 * $Id: conf.h,v 1.69 1999/08/09 18:45:20 jdp Exp $
40 */
41
42#ifndef _SYS_CONF_H_
43#define	_SYS_CONF_H_
44
45#include <sys/queue.h>
46
47#define SPECNAMELEN	15
48
49struct tty;
50struct vnode;
51
52struct specinfo {
53	struct	mount *si_mountpoint;
54	int		si_bsize_phys;	/* minimum physical block size */
55	int		si_bsize_best;	/* optimal block size / VBLK */
56	int		si_bsize_max;	/* maximum block size */
57
58	udev_t		si_udev;
59	SLIST_ENTRY(specinfo)	si_hash;
60	struct vnode	*si_hlist;
61	char		si_name[SPECNAMELEN + 1];
62	void		*si_drv1, *si_drv2;
63	struct cdevsw	*si_devsw;
64	union {
65		struct {
66			struct tty *__sit_tty;
67		} __si_tty;
68	} __si_u;
69};
70
71#define si_tty_tty	__si_u.__si_tty.__sit_tty
72
73/*
74 * Exported shorthand
75 */
76#define v_hashchain v_rdev->si_hlist
77#define v_specmountpoint v_rdev->si_mountpoint
78
79/*
80 * Special device management
81 */
82#define	SPECHSZ	64
83#define	SPECHASH(rdev)	(((unsigned)(minor(rdev)))%SPECHSZ)
84
85/*
86 * Definitions of device driver entry switches
87 */
88
89struct buf;
90struct proc;
91struct uio;
92
93typedef int d_open_t __P((dev_t dev, int oflags, int devtype, struct proc *p));
94typedef int d_close_t __P((dev_t dev, int fflag, int devtype, struct proc *p));
95typedef void d_strategy_t __P((struct buf *bp));
96typedef int d_parms_t __P((dev_t dev, struct specinfo *sinfo, int ctl));
97typedef int d_ioctl_t __P((dev_t dev, u_long cmd, caddr_t data,
98			   int fflag, struct proc *p));
99typedef int d_dump_t __P((dev_t dev));
100typedef int d_psize_t __P((dev_t dev));
101
102typedef int d_read_t __P((dev_t dev, struct uio *uio, int ioflag));
103typedef int d_write_t __P((dev_t dev, struct uio *uio, int ioflag));
104typedef void d_stop_t __P((struct tty *tp, int rw));
105typedef int d_reset_t __P((dev_t dev));
106typedef struct tty *d_devtotty_t __P((dev_t dev));
107typedef int d_poll_t __P((dev_t dev, int events, struct proc *p));
108typedef int d_mmap_t __P((dev_t dev, vm_offset_t offset, int nprot));
109
110typedef int l_open_t __P((dev_t dev, struct tty *tp));
111typedef int l_close_t __P((struct tty *tp, int flag));
112typedef int l_read_t __P((struct tty *tp, struct uio *uio, int flag));
113typedef int l_write_t __P((struct tty *tp, struct uio *uio, int flag));
114typedef int l_ioctl_t __P((struct tty *tp, u_long cmd, caddr_t data,
115			   int flag, struct proc *p));
116typedef int l_rint_t __P((int c, struct tty *tp));
117typedef int l_start_t __P((struct tty *tp));
118typedef int l_modem_t __P((struct tty *tp, int flag));
119
120/*
121 * Types for d_type.
122 */
123#define	D_TAPE	1
124#define	D_DISK	2
125#define	D_TTY	3
126
127#define	D_TYPEMASK	0xffff
128
129/*
130 * Flags for d_flags.
131 */
132#define	D_NOCLUSTERR	0x10000		/* disables cluter read */
133#define	D_NOCLUSTERW	0x20000		/* disables cluster write */
134#define	D_NOCLUSTERRW	(D_NOCLUSTERR | D_NOCLUSTERW)
135#define	D_CANFREE	0x40000		/* can free blocks */
136
137/*
138 * Character device switch table
139 */
140struct cdevsw {
141	d_open_t	*d_open;
142	d_close_t	*d_close;
143	d_read_t	*d_read;
144	d_write_t	*d_write;
145	d_ioctl_t	*d_ioctl;
146	d_stop_t	*d_stop;
147	d_reset_t	*d_bogoreset;	/* XXX not used */
148	d_devtotty_t	*d_devtotty;
149	d_poll_t	*d_poll;
150	d_mmap_t	*d_mmap;
151	d_strategy_t	*d_strategy;
152	char		*d_name;	/* base device name, e.g. 'vn' */
153	d_parms_t	*d_bogoparms;	/* XXX not used */
154	int		d_maj;
155	d_dump_t	*d_dump;
156	d_psize_t	*d_psize;
157	u_int		d_flags;
158	int		d_maxio;
159	int		d_bmaj;
160};
161
162/*
163 * Line discipline switch table
164 */
165struct linesw {
166	l_open_t	*l_open;
167	l_close_t	*l_close;
168	l_read_t	*l_read;
169	l_write_t	*l_write;
170	l_ioctl_t	*l_ioctl;
171	l_rint_t	*l_rint;
172	l_start_t	*l_start;
173	l_modem_t	*l_modem;
174	u_char		l_hotchar;
175};
176
177#ifdef KERNEL
178extern struct linesw linesw[];
179extern int nlinesw;
180
181int ldisc_register __P((int , struct linesw *));
182void ldisc_deregister __P((int));
183#define LDISC_LOAD 	-1		/* Loadable line discipline */
184#endif
185
186/*
187 * Swap device table
188 */
189struct swdevt {
190	udev_t	sw_dev;			/* For quasibogus swapdev reporting */
191	int	sw_flags;
192	int	sw_nblks;
193	struct	vnode *sw_vp;
194	dev_t	sw_device;
195};
196#define	SW_FREED	0x01
197#define	SW_SEQUENTIAL	0x02
198#define	sw_freed	sw_flags	/* XXX compat */
199
200#ifdef KERNEL
201d_open_t	noopen;
202d_close_t	noclose;
203d_read_t	noread;
204d_write_t	nowrite;
205d_ioctl_t	noioctl;
206d_stop_t	nostop;
207d_reset_t	noreset;
208d_devtotty_t	nodevtotty;
209d_mmap_t	nommap;
210#define	nostrategy	((d_strategy_t *)NULL)
211#define	noparms	((d_parms_t *)NULL)
212#define	nopoll	seltrue
213
214d_dump_t	nodump;
215
216#define NUMCDEVSW 256
217
218/*
219 * nopsize is little used, so not worth having dummy functions for.
220 */
221#define	nopsize	((d_psize_t *)NULL)
222
223d_open_t	nullopen;
224d_close_t	nullclose;
225
226l_read_t	l_noread;
227l_write_t	l_nowrite;
228
229struct module;
230
231struct devsw_module_data {
232	int	(*chainevh)(struct module *, int, void *); /* next handler */
233	void	*chainarg;	/* arg for next event handler */
234	struct	cdevsw *cdevsw;	/* device functions */
235	/* Do not initialize fields hereafter */
236};
237
238#define DEV_MODULE(name, cmaj, bmaj, devsw, evh, arg)			\
239static struct devsw_module_data name##_devsw_mod = {			\
240    evh, arg, &devsw							\
241};									\
242									\
243static moduledata_t name##_mod = {					\
244    #name,								\
245    devsw_module_handler,						\
246    &name##_devsw_mod							\
247};									\
248DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE+cmaj*256+bmaj)
249
250
251struct cdevsw *bdevsw __P((dev_t dev));
252int	cdevsw_add __P((struct cdevsw *new));
253int	cdevsw_remove __P((struct cdevsw *old));
254dev_t	chrtoblk __P((dev_t dev));
255struct cdevsw *devsw __P((dev_t dev));
256int	devsw_module_handler __P((struct module *mod, int what, void *arg));
257int	iskmemdev __P((dev_t dev));
258int	iszerodev __P((dev_t dev));
259dev_t	makebdev __P((int maj, int min));
260dev_t	make_dev __P((struct cdevsw *devsw, int minor, uid_t uid, gid_t gid, int perms, char *fmt, ...)) __printflike(6, 7);
261void	setconf __P((void));
262
263/*
264 * XXX: This gunk included in case DEVFS resurfaces
265 */
266
267#define		UID_ROOT	0
268#define		UID_BIN		3
269#define		UID_UUCP	66
270
271#define		GID_WHEEL	0
272#define		GID_KMEM	2
273#define		GID_OPERATOR	5
274#define		GID_BIN		7
275#define		GID_GAMES	13
276#define		GID_DIALER	68
277
278#endif /* KERNEL */
279
280#endif /* !_SYS_CONF_H_ */
281