conf.h revision 52965
11590Srgrimes/*- 21590Srgrimes * Copyright (c) 1990, 1993 31590Srgrimes * The Regents of the University of California. All rights reserved. 41590Srgrimes * (c) UNIX System Laboratories, Inc. 51590Srgrimes * All or some portions of this file are derived from material licensed 61590Srgrimes * to the University of California by American Telephone and Telegraph 71590Srgrimes * Co. or Unix System Laboratories, Inc. and are reproduced herein with 81590Srgrimes * the permission of UNIX System Laboratories, Inc. 91590Srgrimes * 101590Srgrimes * Redistribution and use in source and binary forms, with or without 111590Srgrimes * modification, are permitted provided that the following conditions 121590Srgrimes * are met: 131590Srgrimes * 1. Redistributions of source code must retain the above copyright 141590Srgrimes * notice, this list of conditions and the following disclaimer. 151590Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 161590Srgrimes * notice, this list of conditions and the following disclaimer in the 171590Srgrimes * documentation and/or other materials provided with the distribution. 181590Srgrimes * 3. All advertising materials mentioning features or use of this software 191590Srgrimes * must display the following acknowledgement: 201590Srgrimes * This product includes software developed by the University of 211590Srgrimes * California, Berkeley and its contributors. 221590Srgrimes * 4. Neither the name of the University nor the names of its contributors 231590Srgrimes * may be used to endorse or promote products derived from this software 241590Srgrimes * without specific prior written permission. 251590Srgrimes * 261590Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 271590Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 281590Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 291590Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 3087628Sdwmalone * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 311590Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 321590Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3328625Ssteve * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3487628Sdwmalone * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 351590Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3687628Sdwmalone * SUCH DAMAGE. 3787628Sdwmalone * 3887628Sdwmalone * @(#)conf.h 8.5 (Berkeley) 1/9/95 391590Srgrimes * $FreeBSD: head/sys/sys/conf.h 52965 1999-11-07 10:01:17Z phk $ 401590Srgrimes */ 4191382Sdwmalone 421590Srgrimes#ifndef _SYS_CONF_H_ 431590Srgrimes#define _SYS_CONF_H_ 441590Srgrimes 4592920Simp#include <sys/queue.h> 4692920Simp 4792920Simp#define SPECNAMELEN 15 4892920Simp 491590Srgrimesstruct tty; 501590Srgrimesstruct disk; 511590Srgrimesstruct vnode; 521590Srgrimes 531590Srgrimesstruct specinfo { 541590Srgrimes u_int si_flags; 55100822Sdwmalone#define SI_STASHED 0x0001 /* created in stashed storage */ 561590Srgrimes udev_t si_udev; 571590Srgrimes LIST_ENTRY(specinfo) si_hash; 581590Srgrimes SLIST_HEAD(, vnode) si_hlist; 591590Srgrimes char si_name[SPECNAMELEN + 1]; 601590Srgrimes void *si_drv1, *si_drv2; 611590Srgrimes struct cdevsw *si_devsw; 621590Srgrimes void *si_devfs; /* save cookie for devfs operations */ 631590Srgrimes void *si_bdevfs; /* XXX block device (should go away) */ 641590Srgrimes int si_iosize_max; /* maximum I/O size (for physio &al) */ 651590Srgrimes union { 661590Srgrimes struct { 671590Srgrimes struct tty *__sit_tty; 681590Srgrimes } __si_tty; 691590Srgrimes struct { 701590Srgrimes struct disk *__sid_disk; 711590Srgrimes struct mount *__sid_mountpoint; 721590Srgrimes int __sid_bsize_phys; /* min physical block size */ 731590Srgrimes int __sid_bsize_best; /* optimal block size */ 741590Srgrimes } __si_disk; 751590Srgrimes } __si_u; 761590Srgrimes}; 771590Srgrimes 781590Srgrimes#define si_tty __si_u.__si_tty.__sit_tty 791590Srgrimes#define si_disk __si_u.__si_disk.__sid_disk 801590Srgrimes#define si_mountpoint __si_u.__si_disk.__sid_mountpoint 811590Srgrimes#define si_bsize_phys __si_u.__si_disk.__sid_bsize_phys 821590Srgrimes#define si_bsize_best __si_u.__si_disk.__sid_bsize_best 831590Srgrimes 841590Srgrimes/* 851590Srgrimes * Exported shorthand 861590Srgrimes */ 871590Srgrimes#define v_hashchain v_rdev->si_hlist 881590Srgrimes#define v_specmountpoint v_rdev->si_mountpoint 891590Srgrimes 901590Srgrimes/* 911590Srgrimes * Special device management 921590Srgrimes */ 931590Srgrimes#define SPECHSZ 64 941590Srgrimes#define SPECHASH(rdev) (((unsigned)(minor(rdev)))%SPECHSZ) 951590Srgrimes 961590Srgrimes/* 971590Srgrimes * Definitions of device driver entry switches 981590Srgrimes */ 991590Srgrimes 1001590Srgrimesstruct buf; 1011590Srgrimesstruct proc; 1021590Srgrimesstruct uio; 1031590Srgrimes 1041590Srgrimestypedef int d_open_t __P((dev_t dev, int oflags, int devtype, struct proc *p)); 1051590Srgrimestypedef int d_close_t __P((dev_t dev, int fflag, int devtype, struct proc *p)); 1061590Srgrimestypedef void d_strategy_t __P((struct buf *bp)); 1071590Srgrimestypedef int d_parms_t __P((dev_t dev, struct specinfo *sinfo, int ctl)); 1081590Srgrimestypedef int d_ioctl_t __P((dev_t dev, u_long cmd, caddr_t data, 1091590Srgrimes int fflag, struct proc *p)); 1101590Srgrimestypedef int d_dump_t __P((dev_t dev)); 1111590Srgrimestypedef int d_psize_t __P((dev_t dev)); 1121590Srgrimes 113166503Srsetypedef int d_read_t __P((dev_t dev, struct uio *uio, int ioflag)); 1141590Srgrimestypedef int d_write_t __P((dev_t dev, struct uio *uio, int ioflag)); 1151590Srgrimestypedef int d_poll_t __P((dev_t dev, int events, struct proc *p)); 1161590Srgrimestypedef int d_mmap_t __P((dev_t dev, vm_offset_t offset, int nprot)); 1171590Srgrimes 1181590Srgrimestypedef int l_open_t __P((dev_t dev, struct tty *tp)); 1191590Srgrimestypedef int l_close_t __P((struct tty *tp, int flag)); 1201590Srgrimestypedef int l_read_t __P((struct tty *tp, struct uio *uio, int flag)); 1211590Srgrimestypedef int l_write_t __P((struct tty *tp, struct uio *uio, int flag)); 12291189Sgshapirotypedef int l_ioctl_t __P((struct tty *tp, u_long cmd, caddr_t data, 12391189Sgshapiro int flag, struct proc *p)); 1241590Srgrimestypedef int l_rint_t __P((int c, struct tty *tp)); 1251590Srgrimestypedef int l_start_t __P((struct tty *tp)); 1261590Srgrimestypedef int l_modem_t __P((struct tty *tp, int flag)); 1271590Srgrimes 1281590Srgrimes/* This is type of the function DEVFS uses to hook into the kernel with */ 1291590Srgrimestypedef void devfs_create_t __P((dev_t dev, uid_t uid, gid_t gid, int perms)); 1301590Srgrimestypedef void devfs_remove_t __P((dev_t dev)); 1311590Srgrimes 1321590Srgrimes/* 1331590Srgrimes * XXX: The dummy argument can be used to do what strategy1() never 1341590Srgrimes * did anywhere: Create a per device flag to lock the device during 1351590Srgrimes * label/slice surgery, all calls with a dummy == 0 gets stalled on 1361590Srgrimes * a queue somewhere, whereas dummy == 1 are let through. Once out 1371590Srgrimes * of surgery, reset the flag and restart all the stuff on the stall 1381590Srgrimes * queue. 1391590Srgrimes */ 1401590Srgrimes#define BUF_STRATEGY(bp, dummy) (*devsw((bp)->b_dev)->d_strategy)(bp) 1411590Srgrimes/* 1421590Srgrimes * Types for d_flags. 1431590Srgrimes */ 1441590Srgrimes#define D_TAPE 0x0001 1451590Srgrimes#define D_DISK 0x0002 1461590Srgrimes#define D_TTY 0x0004 1471590Srgrimes#define D_MEM 0x0008 1481590Srgrimes 1491590Srgrimes#define D_TYPEMASK 0xffff 1501590Srgrimes 1511590Srgrimes/* 1521590Srgrimes * Flags for d_flags. 1531590Srgrimes */ 1541590Srgrimes#define D_NAGGED 0x20000 /* nagged about missing make_dev() */ 1551590Srgrimes#define D_CANFREE 0x40000 /* can free blocks */ 1561590Srgrimes#define D_TRACKCLOSE 0x80000 /* track all closes */ 1571590Srgrimes 1581590Srgrimes/* 1591590Srgrimes * Character device switch table 1601590Srgrimes */ 1611590Srgrimesstruct cdevsw { 1621590Srgrimes d_open_t *d_open; 1631590Srgrimes d_close_t *d_close; 1641590Srgrimes d_read_t *d_read; 1651590Srgrimes d_write_t *d_write; 1661590Srgrimes d_ioctl_t *d_ioctl; 1671590Srgrimes d_poll_t *d_poll; 1681590Srgrimes d_mmap_t *d_mmap; 1691590Srgrimes d_strategy_t *d_strategy; 1701590Srgrimes const char *d_name; /* base device name, e.g. 'vn' */ 1711590Srgrimes int d_maj; 1721590Srgrimes d_dump_t *d_dump; 1731590Srgrimes d_psize_t *d_psize; 1741590Srgrimes u_int d_flags; 1751590Srgrimes int d_bmaj; 1761590Srgrimes}; 1771590Srgrimes 1781590Srgrimes/* 1791590Srgrimes * Line discipline switch table 1801590Srgrimes */ 1811590Srgrimesstruct linesw { 1821590Srgrimes l_open_t *l_open; 1831590Srgrimes l_close_t *l_close; 1841590Srgrimes l_read_t *l_read; 1851590Srgrimes l_write_t *l_write; 1861590Srgrimes l_ioctl_t *l_ioctl; 1871590Srgrimes l_rint_t *l_rint; 1881590Srgrimes l_start_t *l_start; 1891590Srgrimes l_modem_t *l_modem; 1901590Srgrimes u_char l_hotchar; 1911590Srgrimes}; 1921590Srgrimes 1931590Srgrimes#ifdef KERNEL 1941590Srgrimesextern struct linesw linesw[]; 1951590Srgrimesextern int nlinesw; 1961590Srgrimes 19728625Ssteveint ldisc_register __P((int , struct linesw *)); 19828625Sstevevoid ldisc_deregister __P((int)); 19928625Ssteve#define LDISC_LOAD -1 /* Loadable line discipline */ 20028625Ssteve#endif 20128625Ssteve 20228625Ssteve/* 20328625Ssteve * Swap device table 20428625Ssteve */ 20528625Sstevestruct swdevt { 20628625Ssteve udev_t sw_dev; /* For quasibogus swapdev reporting */ 2071590Srgrimes int sw_flags; 2081590Srgrimes int sw_nblks; 2091590Srgrimes struct vnode *sw_vp; 2101590Srgrimes dev_t sw_device; 2111590Srgrimes}; 2121590Srgrimes#define SW_FREED 0x01 2131590Srgrimes#define SW_SEQUENTIAL 0x02 2141590Srgrimes#define sw_freed sw_flags /* XXX compat */ 2151590Srgrimes 2161590Srgrimes#ifdef KERNEL 2171590Srgrimesd_open_t noopen; 2181590Srgrimesd_close_t noclose; 2191590Srgrimesd_read_t noread; 2201590Srgrimesd_write_t nowrite; 2211590Srgrimesd_ioctl_t noioctl; 2221590Srgrimesd_mmap_t nommap; 2231590Srgrimes#define nostrategy ((d_strategy_t *)NULL) 2241590Srgrimes#define nopoll seltrue 2251590Srgrimes 2261590Srgrimesd_dump_t nodump; 2271590Srgrimes 2281590Srgrimes#define NUMCDEVSW 256 2291590Srgrimes 2301590Srgrimes/* 2311590Srgrimes * nopsize is little used, so not worth having dummy functions for. 2321590Srgrimes */ 2331590Srgrimes#define nopsize ((d_psize_t *)NULL) 2341590Srgrimes 2351590Srgrimesd_open_t nullopen; 2361590Srgrimesd_close_t nullclose; 2371590Srgrimes 23897574Stjrl_read_t l_noread; 23997574Stjrl_write_t l_nowrite; 24097574Stjr 24197574Stjrstruct module; 24297574Stjr 2431590Srgrimesstruct devsw_module_data { 2441590Srgrimes int (*chainevh)(struct module *, int, void *); /* next handler */ 2451590Srgrimes void *chainarg; /* arg for next event handler */ 2461590Srgrimes /* Do not initialize fields hereafter */ 2471590Srgrimes}; 2481590Srgrimes 2491590Srgrimes#define DEV_MODULE(name, evh, arg) \ 2501590Srgrimesstatic struct devsw_module_data name##_devsw_mod = { \ 2511590Srgrimes evh, arg, \ 2521590Srgrimes}; \ 2531590Srgrimes \ 2541590Srgrimesstatic moduledata_t name##_mod = { \ 2551590Srgrimes #name, \ 2561590Srgrimes devsw_module_handler, \ 2571590Srgrimes &name##_devsw_mod \ 258100822Sdwmalone}; \ 2591590SrgrimesDECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE) 2601590Srgrimes 2611590Srgrimes 2621590Srgrimesint cdevsw_add __P((struct cdevsw *new)); 2631590Srgrimesint cdevsw_remove __P((struct cdevsw *old)); 2641590Srgrimesdev_t chrtoblk __P((dev_t dev)); 2651590Srgrimesstruct cdevsw *devsw __P((dev_t dev)); 2661590Srgrimesint devsw_module_handler __P((struct module *mod, int what, void *arg)); 2671590Srgrimesconst char *devtoname __P((dev_t dev)); 2681590Srgrimesvoid freedev __P((dev_t dev)); 2691590Srgrimesint iskmemdev __P((dev_t dev)); 2701590Srgrimesint iszerodev __P((dev_t dev)); 2711590Srgrimesdev_t makebdev __P((int maj, int min)); 2721590Srgrimesdev_t make_dev __P((struct cdevsw *devsw, int minor, uid_t uid, gid_t gid, int perms, char *fmt, ...)) __printflike(6, 7); 2731590Srgrimesint lminor __P((dev_t dev)); 2741590Srgrimesvoid remove_dev __P((dev_t dev)); 2751590Srgrimesvoid setconf __P((void)); 2761590Srgrimes 27791189Sgshapiroextern devfs_create_t *devfs_create_hook; 27891189Sgshapiro 2791590Srgrimes/* 2801590Srgrimes * XXX: This included for when DEVFS resurfaces 2811590Srgrimes */ 2821590Srgrimes 2831590Srgrimes#define UID_ROOT 0 2841590Srgrimes#define UID_BIN 3 2851590Srgrimes#define UID_UUCP 66 2861590Srgrimes 2871590Srgrimes#define GID_WHEEL 0 2881590Srgrimes#define GID_KMEM 2 2891590Srgrimes#define GID_OPERATOR 5 2901590Srgrimes#define GID_BIN 7 2911590Srgrimes#define GID_GAMES 13 2921590Srgrimes#define GID_DIALER 68 2931590Srgrimes 2941590Srgrimes#endif /* KERNEL */ 2951590Srgrimes 2961590Srgrimes#endif /* !_SYS_CONF_H_ */ 2971590Srgrimes