xref: /dragonfly/sys/sys/conf.h (revision 76b1f6231f5abc8d0793b5318f51b7619cf52f77)
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  */
37 
38 #ifndef _SYS_CONF_H_
39 #define   _SYS_CONF_H_
40 
41 #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
42 
43 #ifndef _SYS_QUEUE_H_
44 #include <sys/queue.h>
45 #endif
46 #ifndef _SYS_TIME_H_
47 #include <sys/time.h>
48 #endif
49 #ifndef _SYS_BIOTRACK_H_
50 #include <sys/biotrack.h>
51 #endif
52 #ifndef _SYS_SYSREF_H_
53 #include <sys/sysref.h>
54 #endif
55 #ifndef _SYS_EVENT_H_
56 #include <sys/event.h>
57 #endif
58 #include <libprop/proplib.h>
59 #include <sys/param.h>
60 
61 struct tty;
62 struct disk;
63 struct vnode;
64 struct dev_ops;
65 struct vm_object;
66 
67 struct cdev {
68           u_int               si_flags;
69           __uint64_t          si_inode;
70           uid_t               si_uid;
71           gid_t               si_gid;
72           int                 si_perms;
73           TAILQ_ENTRY(cdev) link;
74           int                 si_uminor;
75           int                 si_umajor;
76           struct cdev         *si_parent;
77           LIST_ENTRY(cdev)    si_hash;
78           SLIST_HEAD(, vnode) si_hlist;
79           char                si_name[SPECNAMELEN + 1];
80           void                *si_drv1;
81           void                *si_drv2;
82           struct dev_ops      *si_ops;  /* device operations vector */
83           struct dev_ops      *si_bops; /* backing devops vector */
84           int                 si_iosize_max;      /* maximum I/O size (for physio &al) */
85           struct sysref       si_sysref;
86           union {
87                     struct {
88                               struct tty *__sit_tty;
89                     } __si_tty;
90                     struct {
91                               struct disk *__sid_disk;
92                               struct mount *__sid_mountpoint;
93                               int __sid_bsize_phys; /* min physical block size */
94                               int __sid_bsize_best; /* optimal block size */
95                     } __si_disk;
96           } __si_u;
97           struct bio_track si_track_read;
98           struct bio_track si_track_write;
99           time_t              si_lastread;        /* time_uptime */
100           time_t              si_lastwrite;       /* time_uptime */
101           struct vm_object *si_object;  /* vm_pager support */
102           prop_dictionary_t si_dict;
103           struct kqinfo       si_kqinfo;          /* degenerate delegated knotes */
104 };
105 
106 #define SI_UNUSED01 0x0001
107 #define SI_HASHED   0x0002    /* in (maj,min) hash table */
108 #define SI_OVERRIDE 0x0004    /* override uid, gid, and perms */
109 #define SI_INTERCEPTED        0x0008    /* device ops was intercepted */
110 #define SI_DEVFS_LINKED       0x0010
111 #define   SI_REPROBE_TEST     0x0020
112 #define SI_CANFREE  0x0040    /* basically just a propagated D_CANFREE */
113 
114 #define si_tty                __si_u.__si_tty.__sit_tty
115 #define si_disk               __si_u.__si_disk.__sid_disk
116 #define si_mountpoint         __si_u.__si_disk.__sid_mountpoint
117 #define si_bsize_phys         __si_u.__si_disk.__sid_bsize_phys
118 #define si_bsize_best         __si_u.__si_disk.__sid_bsize_best
119 
120 #define CDEVSW_ALL_MINORS     0         /* mask of 0 always matches 0 */
121 
122 /*
123  * Special device management
124  */
125 #define   SPECHSZ   64
126 #define   SPECHASH(rdev)      (((unsigned)(minor(rdev)))%SPECHSZ)
127 
128 /*
129  * Definitions of device driver entry switches
130  */
131 
132 struct buf;
133 struct bio;
134 struct proc;
135 struct uio;
136 struct knote;
137 struct ucred;
138 
139 struct thread;
140 
141 typedef int l_open_t (struct cdev *dev, struct tty *tp);
142 typedef int l_close_t (struct tty *tp, int flag);
143 typedef int l_read_t (struct tty *tp, struct uio *uio, int flag);
144 typedef int l_write_t (struct tty *tp, struct uio *uio, int flag);
145 typedef int l_ioctl_t (struct tty *tp, u_long cmd, caddr_t data, int flag,
146                               struct ucred *cred);
147 typedef int l_rint_t (int c, struct tty *tp);
148 typedef int l_start_t (struct tty *tp);
149 typedef int l_modem_t (struct tty *tp, int flag);
150 
151 /*
152  * Line discipline switch table
153  */
154 struct linesw {
155           l_open_t  *l_open;
156           l_close_t *l_close;
157           l_read_t  *l_read;
158           l_write_t *l_write;
159           l_ioctl_t *l_ioctl;
160           l_rint_t  *l_rint;
161           l_start_t *l_start;
162           l_modem_t *l_modem;
163           u_char              l_hotchar;
164 };
165 
166 #ifdef _KERNEL
167 extern struct linesw linesw[];
168 extern int nlinesw;
169 
170 int ldisc_register (int , struct linesw *);
171 void ldisc_deregister (int);
172 #define LDISC_LOAD  -1                  /* Loadable line discipline */
173 #endif
174 
175 /*
176  * Swap device table
177  */
178 struct swdevt {
179           dev_t     sw_dev;                       /* For quasibogus swapdev reporting */
180           int       sw_flags;
181           int       sw_nblks;           /* Number of swap blocks on device */
182           int       sw_nused;           /* swap blocks used on device */
183           struct    vnode *sw_vp;
184           struct cdev *sw_device;
185 };
186 
187 #define   SW_FREED  0x01
188 #define   SW_SEQUENTIAL       0x02
189 #define SW_CLOSING  0x04
190 #define   sw_freed  sw_flags  /* XXX compat */
191 
192 #ifdef _KERNEL
193 
194 l_ioctl_t l_nullioctl;
195 l_read_t  l_noread;
196 l_write_t l_nowrite;
197 
198 struct module;
199 
200 struct devsw_module_data {
201           int       (*chainevh)(struct module *, int, void *); /* next handler */
202           void      *chainarg;          /* arg for next event handler */
203           /* Do not initialize fields hereafter */
204 };
205 
206 #define DEV_MODULE(name, evh, arg)                                              \
207 static moduledata_t name##_mod = {                                              \
208     #name,                                                                                \
209     evh,                                                                        \
210     arg                                                                                   \
211 };                                                                                        \
212 DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE)
213 
214 #define dev2unit(x) ((minor(x) & 0xff) | (minor(x) >> 8))
215 
216 int       count_dev (cdev_t dev);
217 void      destroy_dev (cdev_t dev);
218 void      release_dev (cdev_t dev);
219 cdev_t    reference_dev (cdev_t dev);
220 const char *devtoname (cdev_t dev);
221 int       iszerodev (cdev_t dev);
222 
223 int       lminor (cdev_t dev);
224 cdev_t    kgetdiskbyname(const char *name);
225 int       dev_is_good(cdev_t dev);
226 
227 /*
228  * XXX: This included for when DEVFS resurfaces
229  */
230 
231 #define             UID_ROOT  0
232 #define             UID_BIN             3
233 #define             UID_UUCP  66
234 
235 #define             GID_WHEEL 0
236 #define             GID_KMEM  2
237 #define             GID_TTY             4
238 #define             GID_OPERATOR        5
239 #define             GID_BIN             7
240 #define             GID_GAMES 13
241 #define             GID_VIDEO 44
242 #define             GID_DIALER          68
243 #define             GID_NVMM  90
244 
245 #endif /* _KERNEL */
246 #endif /* _KERNEL || _KERNEL_STRUCTURES */
247 
248 #endif /* !_SYS_CONF_H_ */
249