conf.h revision 50830
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: head/sys/sys/conf.h 50830 1999-09-03 05:16:59Z julian $ 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 disk; 51struct vnode; 52 53struct specinfo { 54 u_int si_flags; 55#define SI_STASHED 0x0001 /* created in stashed storage */ 56 udev_t si_udev; 57 LIST_ENTRY(specinfo) si_hash; 58 SLIST_HEAD(, vnode) si_hlist; 59 char si_name[SPECNAMELEN + 1]; 60 void *si_drv1, *si_drv2; 61 struct cdevsw *si_devsw; 62 void *si_devfs; /* save cookie for devfs operations */ 63 void *si_bdevfs; /* XXX block device (should go away) */ 64 union { 65 struct { 66 struct tty *__sit_tty; 67 } __si_tty; 68 struct { 69 struct disk *__sid_disk; 70 struct mount *__sid_mountpoint; 71 int __sid_bsize_phys; /* min physical block size */ 72 int __sid_bsize_best; /* optimal block size */ 73 int __sid_bsize_max; /* maximum block size */ 74 } __si_disk; 75 } __si_u; 76}; 77 78#define si_tty __si_u.__si_tty.__sit_tty 79#define si_disk __si_u.__si_disk.__sid_disk 80#define si_mountpoint __si_u.__si_disk.__sid_mountpoint 81#define si_bsize_phys __si_u.__si_disk.__sid_bsize_phys 82#define si_bsize_best __si_u.__si_disk.__sid_bsize_best 83#define si_bsize_max __si_u.__si_disk.__sid_bsize_max 84 85/* 86 * Exported shorthand 87 */ 88#define v_hashchain v_rdev->si_hlist 89#define v_specmountpoint v_rdev->si_mountpoint 90 91/* 92 * Special device management 93 */ 94#define SPECHSZ 64 95#define SPECHASH(rdev) (((unsigned)(minor(rdev)))%SPECHSZ) 96 97/* 98 * Definitions of device driver entry switches 99 */ 100 101struct buf; 102struct proc; 103struct uio; 104 105typedef int d_open_t __P((dev_t dev, int oflags, int devtype, struct proc *p)); 106typedef int d_close_t __P((dev_t dev, int fflag, int devtype, struct proc *p)); 107typedef void d_strategy_t __P((struct buf *bp)); 108typedef int d_parms_t __P((dev_t dev, struct specinfo *sinfo, int ctl)); 109typedef int d_ioctl_t __P((dev_t dev, u_long cmd, caddr_t data, 110 int fflag, struct proc *p)); 111typedef int d_dump_t __P((dev_t dev)); 112typedef int d_psize_t __P((dev_t dev)); 113 114typedef int d_read_t __P((dev_t dev, struct uio *uio, int ioflag)); 115typedef int d_write_t __P((dev_t dev, struct uio *uio, int ioflag)); 116typedef void d_stop_t __P((struct tty *tp, int rw)); 117typedef int d_reset_t __P((dev_t dev)); 118typedef struct tty *d_devtotty_t __P((dev_t dev)); 119typedef int d_poll_t __P((dev_t dev, int events, struct proc *p)); 120typedef int d_mmap_t __P((dev_t dev, vm_offset_t offset, int nprot)); 121 122typedef int l_open_t __P((dev_t dev, struct tty *tp)); 123typedef int l_close_t __P((struct tty *tp, int flag)); 124typedef int l_read_t __P((struct tty *tp, struct uio *uio, int flag)); 125typedef int l_write_t __P((struct tty *tp, struct uio *uio, int flag)); 126typedef int l_ioctl_t __P((struct tty *tp, u_long cmd, caddr_t data, 127 int flag, struct proc *p)); 128typedef int l_rint_t __P((int c, struct tty *tp)); 129typedef int l_start_t __P((struct tty *tp)); 130typedef int l_modem_t __P((struct tty *tp, int flag)); 131 132/* This is type of the function DEVFS uses to hook into the kernel with */ 133typedef void devfs_create_t __P((dev_t dev, uid_t uid, gid_t gid, int perms)); 134typedef void devfs_remove_t __P((dev_t dev)); 135 136/* 137 * XXX: The dummy argument can be used to do what strategy1() never 138 * did anywhere: Create a per device flag to lock the device during 139 * label/slice surgery, all calls with a dummy == 0 gets stalled on 140 * a queue somewhere, whereas dummy == 1 are let through. Once out 141 * of surgery, reset the flag and restart all the stuff on the stall 142 * queue. 143 */ 144#define BUF_STRATEGY(bp, dummy) (*devsw((bp)->b_dev)->d_strategy)(bp) 145/* 146 * Types for d_type. 147 */ 148#define D_TAPE 1 149#define D_DISK 2 150#define D_TTY 4 151 152#define D_TYPEMASK 0xffff 153 154/* 155 * Flags for d_flags. 156 */ 157#define D_NOCLUSTERR 0x10000 /* disables cluter read */ 158#define D_NOCLUSTERW 0x20000 /* disables cluster write */ 159#define D_NOCLUSTERRW (D_NOCLUSTERR | D_NOCLUSTERW) 160#define D_CANFREE 0x40000 /* can free blocks */ 161#define D_TRACKCLOSE 0x80000 /* track all closes */ 162 163/* 164 * Character device switch table 165 */ 166struct cdevsw { 167 d_open_t *d_open; 168 d_close_t *d_close; 169 d_read_t *d_read; 170 d_write_t *d_write; 171 d_ioctl_t *d_ioctl; 172 d_stop_t *d_stop; 173 d_reset_t *d_bogoreset; /* XXX not used */ 174 d_devtotty_t *d_devtotty; 175 d_poll_t *d_poll; 176 d_mmap_t *d_mmap; 177 d_strategy_t *d_strategy; 178 char *d_name; /* base device name, e.g. 'vn' */ 179 d_parms_t *d_bogoparms; /* XXX not used */ 180 int d_maj; 181 d_dump_t *d_dump; 182 d_psize_t *d_psize; 183 u_int d_flags; 184 int d_maxio; 185 int d_bmaj; 186}; 187 188/* 189 * Line discipline switch table 190 */ 191struct linesw { 192 l_open_t *l_open; 193 l_close_t *l_close; 194 l_read_t *l_read; 195 l_write_t *l_write; 196 l_ioctl_t *l_ioctl; 197 l_rint_t *l_rint; 198 l_start_t *l_start; 199 l_modem_t *l_modem; 200 u_char l_hotchar; 201}; 202 203#ifdef KERNEL 204extern struct linesw linesw[]; 205extern int nlinesw; 206 207int ldisc_register __P((int , struct linesw *)); 208void ldisc_deregister __P((int)); 209#define LDISC_LOAD -1 /* Loadable line discipline */ 210#endif 211 212/* 213 * Swap device table 214 */ 215struct swdevt { 216 udev_t sw_dev; /* For quasibogus swapdev reporting */ 217 int sw_flags; 218 int sw_nblks; 219 struct vnode *sw_vp; 220 dev_t sw_device; 221}; 222#define SW_FREED 0x01 223#define SW_SEQUENTIAL 0x02 224#define sw_freed sw_flags /* XXX compat */ 225 226#ifdef KERNEL 227d_open_t noopen; 228d_close_t noclose; 229d_read_t noread; 230d_write_t nowrite; 231d_ioctl_t noioctl; 232d_stop_t nostop; 233d_reset_t noreset; 234d_devtotty_t nodevtotty; 235d_mmap_t nommap; 236#define nostrategy ((d_strategy_t *)NULL) 237#define noparms ((d_parms_t *)NULL) 238#define nopoll seltrue 239 240d_dump_t nodump; 241 242#define NUMCDEVSW 256 243 244/* 245 * nopsize is little used, so not worth having dummy functions for. 246 */ 247#define nopsize ((d_psize_t *)NULL) 248 249d_open_t nullopen; 250d_close_t nullclose; 251 252l_read_t l_noread; 253l_write_t l_nowrite; 254 255struct module; 256 257struct devsw_module_data { 258 int (*chainevh)(struct module *, int, void *); /* next handler */ 259 void *chainarg; /* arg for next event handler */ 260 struct cdevsw *cdevsw; /* device functions */ 261 /* Do not initialize fields hereafter */ 262}; 263 264#define DEV_MODULE(name, cmaj, bmaj, devsw, evh, arg) \ 265static struct devsw_module_data name##_devsw_mod = { \ 266 evh, arg, &devsw \ 267}; \ 268 \ 269static moduledata_t name##_mod = { \ 270 #name, \ 271 devsw_module_handler, \ 272 &name##_devsw_mod \ 273}; \ 274DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE+cmaj*256+bmaj) 275 276 277int cdevsw_add __P((struct cdevsw *new)); 278int cdevsw_remove __P((struct cdevsw *old)); 279dev_t chrtoblk __P((dev_t dev)); 280struct cdevsw *devsw __P((dev_t dev)); 281int devsw_module_handler __P((struct module *mod, int what, void *arg)); 282char *devtoname __P((dev_t dev)); 283void freedev __P((dev_t dev)); 284int iskmemdev __P((dev_t dev)); 285int iszerodev __P((dev_t dev)); 286dev_t makebdev __P((int maj, int min)); 287dev_t make_dev __P((struct cdevsw *devsw, int minor, uid_t uid, gid_t gid, int perms, char *fmt, ...)) __printflike(6, 7); 288int lminor __P((dev_t dev)); 289void remove_dev __P((dev_t dev)); 290void setconf __P((void)); 291 292extern devfs_create_t *devfs_create_hook; 293 294/* 295 * XXX: This included for when DEVFS resurfaces 296 */ 297 298#define UID_ROOT 0 299#define UID_BIN 3 300#define UID_UUCP 66 301 302#define GID_WHEEL 0 303#define GID_KMEM 2 304#define GID_OPERATOR 5 305#define GID_BIN 7 306#define GID_GAMES 13 307#define GID_DIALER 68 308 309#endif /* KERNEL */ 310 311#endif /* !_SYS_CONF_H_ */ 312