xref: /dragonfly/sys/sys/conf.h (revision 277350a0)
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. Neither the name of the University nor the names of its contributors
19  *    may be used to endorse or promote products derived from this software
20  *    without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  *
34  *	@(#)conf.h	8.5 (Berkeley) 1/9/95
35  * $FreeBSD: src/sys/sys/conf.h,v 1.103.2.6 2002/03/11 01:14:55 dd Exp $
36  * $DragonFly: src/sys/sys/conf.h,v 1.18 2007/05/09 00:53:35 dillon Exp $
37  */
38 
39 #ifndef _SYS_CONF_H_
40 #define	_SYS_CONF_H_
41 
42 #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
43 
44 #ifndef _SYS_QUEUE_H_
45 #include <sys/queue.h>
46 #endif
47 #ifndef _SYS_TIME_H_
48 #include <sys/time.h>
49 #endif
50 #ifndef _SYS_BIOTRACK_H_
51 #include <sys/biotrack.h>
52 #endif
53 #ifndef _SYS_SYSREF_H_
54 #include <sys/sysref.h>
55 #endif
56 #ifndef _SYS_EVENT_H_
57 #include <sys/event.h>
58 #endif
59 #include <libprop/proplib.h>
60 
61 #define SPECNAMELEN	63
62 
63 struct tty;
64 struct disk;
65 struct vnode;
66 struct dev_ops;
67 struct vm_object;
68 
69 struct cdev {
70 	u_int		si_flags;
71 	__uint64_t	si_inode;
72 	uid_t		si_uid;
73 	gid_t		si_gid;
74 	int		si_perms;
75 	TAILQ_ENTRY(cdev) link;
76 	int		si_uminor;
77 	int		si_umajor;
78 	struct cdev	*si_parent;
79 	LIST_ENTRY(cdev)	si_hash;
80 	SLIST_HEAD(, vnode) si_hlist;
81 	char		si_name[SPECNAMELEN + 1];
82 	void		*si_drv1;
83 	void		*si_drv2;
84 	struct dev_ops	*si_ops;	/* device operations vector */
85 	struct dev_ops	*si_bops;	/* backing devops vector */
86 	int		si_iosize_max;	/* maximum I/O size (for physio &al) */
87 	struct sysref	si_sysref;
88 	union {
89 		struct {
90 			struct tty *__sit_tty;
91 		} __si_tty;
92 		struct {
93 			struct disk *__sid_disk;
94 			struct mount *__sid_mountpoint;
95 			int __sid_bsize_phys; /* min physical block size */
96 			int __sid_bsize_best; /* optimal block size */
97 		} __si_disk;
98 	} __si_u;
99 	struct bio_track si_track_read;
100 	struct bio_track si_track_write;
101 	time_t		si_lastread;	/* time_uptime */
102 	time_t		si_lastwrite;	/* time_uptime */
103 	struct vm_object *si_object;	/* vm_pager support */
104 	prop_dictionary_t si_dict;
105 	struct kqinfo	si_kqinfo;	/* degenerate delegated knotes */
106 };
107 
108 #define SI_UNUSED01	0x0001
109 #define SI_HASHED	0x0002	/* in (maj,min) hash table */
110 #define SI_OVERRIDE	0x0004	/* override uid, gid, and perms */
111 #define SI_INTERCEPTED	0x0008	/* device ops was intercepted */
112 #define SI_DEVFS_LINKED	0x0010
113 #define	SI_REPROBE_TEST	0x0020
114 #define SI_CANFREE	0x0040	/* basically just a propagated D_CANFREE */
115 
116 #define si_tty		__si_u.__si_tty.__sit_tty
117 #define si_disk		__si_u.__si_disk.__sid_disk
118 #define si_mountpoint	__si_u.__si_disk.__sid_mountpoint
119 #define si_bsize_phys	__si_u.__si_disk.__sid_bsize_phys
120 #define si_bsize_best	__si_u.__si_disk.__sid_bsize_best
121 
122 #define CDEVSW_ALL_MINORS	0	/* mask of 0 always matches 0 */
123 
124 /*
125  * Special device management
126  */
127 #define	SPECHSZ	64
128 #define	SPECHASH(rdev)	(((unsigned)(minor(rdev)))%SPECHSZ)
129 
130 /*
131  * Definitions of device driver entry switches
132  */
133 
134 struct buf;
135 struct bio;
136 struct proc;
137 struct uio;
138 struct knote;
139 struct ucred;
140 
141 struct thread;
142 
143 typedef int l_open_t (struct cdev *dev, struct tty *tp);
144 typedef int l_close_t (struct tty *tp, int flag);
145 typedef int l_read_t (struct tty *tp, struct uio *uio, int flag);
146 typedef int l_write_t (struct tty *tp, struct uio *uio, int flag);
147 typedef int l_ioctl_t (struct tty *tp, u_long cmd, caddr_t data, int flag,
148 			struct ucred *cred);
149 typedef int l_rint_t (int c, struct tty *tp);
150 typedef int l_start_t (struct tty *tp);
151 typedef int l_modem_t (struct tty *tp, int flag);
152 
153 /*
154  * Line discipline switch table
155  */
156 struct linesw {
157 	l_open_t	*l_open;
158 	l_close_t	*l_close;
159 	l_read_t	*l_read;
160 	l_write_t	*l_write;
161 	l_ioctl_t	*l_ioctl;
162 	l_rint_t	*l_rint;
163 	l_start_t	*l_start;
164 	l_modem_t	*l_modem;
165 	u_char		l_hotchar;
166 };
167 
168 #ifdef _KERNEL
169 extern struct linesw linesw[];
170 extern int nlinesw;
171 
172 int ldisc_register (int , struct linesw *);
173 void ldisc_deregister (int);
174 #define LDISC_LOAD 	-1		/* Loadable line discipline */
175 #endif
176 
177 /*
178  * Swap device table
179  */
180 struct swdevt {
181 	udev_t	sw_dev;			/* For quasibogus swapdev reporting */
182 	int	sw_flags;
183 	int	sw_nblks;		/* Number of swap blocks on device */
184 	int	sw_nused;		/* swap blocks used on device */
185 	struct	vnode *sw_vp;
186 	struct cdev *sw_device;
187 };
188 
189 #define	SW_FREED	0x01
190 #define	SW_SEQUENTIAL	0x02
191 #define SW_CLOSING	0x04
192 #define	sw_freed	sw_flags	/* XXX compat */
193 
194 #ifdef _KERNEL
195 
196 l_ioctl_t	l_nullioctl;
197 l_read_t	l_noread;
198 l_write_t	l_nowrite;
199 
200 struct module;
201 
202 struct devsw_module_data {
203 	int	(*chainevh)(struct module *, int, void *); /* next handler */
204 	void	*chainarg;	/* arg for next event handler */
205 	/* Do not initialize fields hereafter */
206 };
207 
208 #define DEV_MODULE(name, evh, arg)					\
209 static moduledata_t name##_mod = {					\
210     #name,								\
211     evh,								\
212     arg									\
213 };									\
214 DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE)
215 
216 #define dev2unit(x)	((minor(x) & 0xff) | (minor(x) >> 8))
217 
218 int	count_dev (cdev_t dev);
219 void	destroy_dev (cdev_t dev);
220 void	release_dev (cdev_t dev);
221 cdev_t	get_dev (int x, int y);
222 cdev_t	reference_dev (cdev_t dev);
223 struct dev_ops *devsw (cdev_t dev);
224 const char *devtoname (cdev_t dev);
225 void	freedev (cdev_t dev);
226 int	iszerodev (cdev_t dev);
227 
228 int	lminor (cdev_t dev);
229 void	setconf (void);
230 cdev_t	kgetdiskbyname(const char *name);
231 int	dev_is_good(cdev_t dev);
232 
233 /*
234  * XXX: This included for when DEVFS resurfaces
235  */
236 
237 #define		UID_ROOT	0
238 #define		UID_BIN		3
239 #define		UID_UUCP	66
240 
241 #define		GID_WHEEL	0
242 #define		GID_KMEM	2
243 #define		GID_TTY		4
244 #define		GID_OPERATOR	5
245 #define		GID_BIN		7
246 #define		GID_GAMES	13
247 #define		GID_DIALER	68
248 
249 #endif /* _KERNEL */
250 #endif /* _KERNEL || _KERNEL_STRUCTURES */
251 
252 #endif /* !_SYS_CONF_H_ */
253