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