The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/conf.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: conf.h,v 1.161 2022/03/28 12:39:18 riastradh Exp $     */
    2 
    3 /*-
    4  * Copyright (c) 1990, 1993
    5  *      The Regents of the University of California.  All rights reserved.
    6  * (c) UNIX System Laboratories, Inc.
    7  * All or some portions of this file are derived from material licensed
    8  * to the University of California by American Telephone and Telegraph
    9  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
   10  * the permission of UNIX System Laboratories, Inc.
   11  *
   12  * Redistribution and use in source and binary forms, with or without
   13  * modification, are permitted provided that the following conditions
   14  * are met:
   15  * 1. Redistributions of source code must retain the above copyright
   16  *    notice, this list of conditions and the following disclaimer.
   17  * 2. Redistributions in binary form must reproduce the above copyright
   18  *    notice, this list of conditions and the following disclaimer in the
   19  *    documentation and/or other materials provided with the distribution.
   20  * 3. Neither the name of the University nor the names of its contributors
   21  *    may be used to endorse or promote products derived from this software
   22  *    without specific prior written permission.
   23  *
   24  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   34  * SUCH DAMAGE.
   35  *
   36  *      @(#)conf.h      8.5 (Berkeley) 1/9/95
   37  */
   38 
   39 #ifndef _SYS_CONF_H_
   40 #define _SYS_CONF_H_
   41 
   42 /*
   43  * Definitions of device driver entry switches
   44  */
   45 
   46 #include <sys/queue.h>
   47 #include <sys/device_if.h>
   48 
   49 struct buf;
   50 struct knote;
   51 struct lwp;
   52 struct tty;
   53 struct uio;
   54 struct vnode;
   55 
   56 /*
   57  * Types for d_flag
   58  */
   59 #define D_OTHER         0x0000
   60 #define D_TAPE          0x0001
   61 #define D_DISK          0x0002
   62 #define D_TTY           0x0003
   63 #define D_TYPEMASK      0x00ff
   64 #define D_MPSAFE        0x0100
   65 #define D_NEGOFFSAFE    0x0200
   66 #define D_UNUSED0       0x0400  /* was D_MCLOSE */
   67 
   68 /*
   69  * Block device switch table
   70  */
   71 struct bdevsw {
   72         int             (*d_open)(dev_t, int, int, struct lwp *);
   73         int             (*d_cancel)(dev_t, int, int, struct lwp *);
   74         int             (*d_close)(dev_t, int, int, struct lwp *);
   75         void            (*d_strategy)(struct buf *);
   76         int             (*d_ioctl)(dev_t, u_long, void *, int, struct lwp *);
   77         int             (*d_dump)(dev_t, daddr_t, void *, size_t);
   78         int             (*d_psize)(dev_t);
   79         int             (*d_discard)(dev_t, off_t, off_t);
   80         int             (*d_devtounit)(dev_t);
   81         struct cfdriver *d_cfdriver;
   82         int             d_flag;
   83 };
   84 
   85 /*
   86  * Character device switch table
   87  */
   88 struct cdevsw {
   89         int             (*d_open)(dev_t, int, int, struct lwp *);
   90         int             (*d_cancel)(dev_t, int, int, struct lwp *);
   91         int             (*d_close)(dev_t, int, int, struct lwp *);
   92         int             (*d_read)(dev_t, struct uio *, int);
   93         int             (*d_write)(dev_t, struct uio *, int);
   94         int             (*d_ioctl)(dev_t, u_long, void *, int, struct lwp *);
   95         void            (*d_stop)(struct tty *, int);
   96         struct tty *    (*d_tty)(dev_t);
   97         int             (*d_poll)(dev_t, int, struct lwp *);
   98         paddr_t         (*d_mmap)(dev_t, off_t, int);
   99         int             (*d_kqfilter)(dev_t, struct knote *);
  100         int             (*d_discard)(dev_t, off_t, off_t);
  101         int             (*d_devtounit)(dev_t);
  102         struct cfdriver *d_cfdriver;
  103         int             d_flag;
  104 };
  105 
  106 #ifdef _KERNEL
  107 
  108 #include <sys/mutex.h>
  109 extern kmutex_t device_lock;
  110 
  111 int devsw_attach(const char *, const struct bdevsw *, devmajor_t *,
  112                  const struct cdevsw *, devmajor_t *);
  113 void devsw_detach(const struct bdevsw *, const struct cdevsw *);
  114 const struct bdevsw *bdevsw_lookup(dev_t);
  115 const struct cdevsw *cdevsw_lookup(dev_t);
  116 devmajor_t bdevsw_lookup_major(const struct bdevsw *);
  117 devmajor_t cdevsw_lookup_major(const struct cdevsw *);
  118 
  119 typedef int dev_open_t(dev_t, int, int, struct lwp *);
  120 typedef int dev_cancel_t(dev_t, int, int, struct lwp *);
  121 typedef int dev_close_t(dev_t, int, int, struct lwp *);
  122 typedef int dev_read_t(dev_t, struct uio *, int);
  123 typedef int dev_write_t(dev_t, struct uio *, int);
  124 typedef int dev_ioctl_t(dev_t, u_long, void *, int, struct lwp *);
  125 typedef void dev_stop_t(struct tty *, int);
  126 typedef struct tty *dev_tty_t(dev_t);
  127 typedef int dev_poll_t(dev_t, int, struct lwp *);
  128 typedef paddr_t dev_mmap_t(dev_t, off_t, int);
  129 typedef void dev_strategy_t(struct buf *);
  130 typedef int dev_dump_t(dev_t, daddr_t, void *, size_t);
  131 typedef int dev_size_t(dev_t);
  132 typedef int dev_kqfilter_t(dev_t, struct knote *);
  133 typedef int dev_discard_t(dev_t, off_t, off_t);
  134 
  135 #define dev_type_open(n)        dev_open_t n
  136 #define dev_type_cancel(n)      dev_cancel_t n
  137 #define dev_type_close(n)       dev_close_t n
  138 #define dev_type_read(n)        dev_read_t n
  139 #define dev_type_write(n)       dev_write_t n
  140 #define dev_type_ioctl(n)       dev_ioctl_t n
  141 #define dev_type_stop(n)        dev_stop_t n
  142 #define dev_type_tty(n)         dev_tty_t n
  143 #define dev_type_poll(n)        dev_poll_t n
  144 #define dev_type_mmap(n)        dev_mmap_t n
  145 #define dev_type_strategy(n)    dev_strategy_t n
  146 #define dev_type_dump(n)        dev_dump_t n
  147 #define dev_type_size(n)        dev_size_t n
  148 #define dev_type_kqfilter(n)    dev_kqfilter_t n
  149 #define dev_type_discard(n)     dev_discard_t n
  150 
  151 int devenodev(dev_t, ...);
  152 int deveopnotsupp(dev_t, ...);
  153 int devnullop(dev_t, ...);
  154 int ttyenodev(struct tty *, ...);
  155 void ttyvenodev(struct tty *, ...);
  156 void ttyvnullop(struct tty *, ...);
  157 
  158 #define noopen          ((dev_open_t *)devenodev)
  159 #define noclose         ((dev_close_t *)devenodev)
  160 #define noread          ((dev_read_t *)devenodev)
  161 #define nowrite         ((dev_write_t *)devenodev)
  162 #define noioctl         ((dev_ioctl_t *)devenodev)
  163 #define nostop          ((dev_stop_t *)ttyvenodev)
  164 #define notty           NULL
  165 #define nopoll          seltrue
  166 paddr_t nommap(dev_t, off_t, int);
  167 #define nodump          ((dev_dump_t *)devenodev)
  168 #define nosize          NULL
  169 #define nokqfilter      seltrue_kqfilter
  170 #define nodiscard       ((dev_discard_t *)devenodev)
  171 
  172 #define nullopen        ((dev_open_t *)devnullop)
  173 #define nullclose       ((dev_close_t *)devnullop)
  174 #define nullread        ((dev_read_t *)devnullop)
  175 #define nullwrite       ((dev_write_t *)devnullop)
  176 #define nullioctl       ((dev_ioctl_t *)devnullop)
  177 #define nullstop        ((dev_stop_t *)ttyvnullop)
  178 #define nullpoll        ((dev_poll_t *)devnullop)
  179 #define nulldump        ((dev_dump_t *)devnullop)
  180 #define nullkqfilter    ((dev_kqfilter_t *)deveopnotsupp)
  181 #define nulldiscard     ((dev_discard_t *)devnullop)
  182 
  183 /* device access wrappers. */
  184 
  185 dev_type_open(bdev_open);
  186 dev_type_cancel(bdev_cancel);
  187 dev_type_close(bdev_close);
  188 dev_type_strategy(bdev_strategy);
  189 dev_type_ioctl(bdev_ioctl);
  190 dev_type_dump(bdev_dump);
  191 dev_type_size(bdev_size);
  192 dev_type_discard(bdev_discard);
  193 
  194 void    bdev_detached(dev_t);
  195 
  196 dev_type_open(cdev_open);
  197 dev_type_cancel(cdev_cancel);
  198 dev_type_close(cdev_close);
  199 dev_type_read(cdev_read);
  200 dev_type_write(cdev_write);
  201 dev_type_ioctl(cdev_ioctl);
  202 dev_type_stop(cdev_stop);
  203 dev_type_tty(cdev_tty);
  204 dev_type_poll(cdev_poll);
  205 dev_type_mmap(cdev_mmap);
  206 dev_type_kqfilter(cdev_kqfilter);
  207 dev_type_discard(cdev_discard);
  208 
  209 void    cdev_detached(dev_t);
  210 
  211 int     cdev_type(dev_t);
  212 int     cdev_flags(dev_t);
  213 int     bdev_type(dev_t);
  214 int     bdev_flags(dev_t);
  215 
  216 /* symbolic sleep message strings */
  217 extern  const char devopn[], devio[], devwait[], devin[], devout[];
  218 extern  const char devioc[], devcls[];
  219 
  220 #endif /* _KERNEL */
  221 
  222 /*
  223  * Line discipline switch table
  224  */
  225 struct linesw {
  226         const char *l_name;     /* Linesw name */
  227 
  228         LIST_ENTRY(linesw) l_list;
  229         u_int   l_refcnt;       /* locked by ttyldisc_list_slock */
  230         int     l_no;           /* legacy discipline number (for TIOCGETD) */
  231 
  232         int     (*l_open)       (dev_t, struct tty *);
  233         int     (*l_close)      (struct tty *, int);
  234         int     (*l_read)       (struct tty *, struct uio *, int);
  235         int     (*l_write)      (struct tty *, struct uio *, int);
  236         int     (*l_ioctl)      (struct tty *, u_long, void *, int,
  237                                     struct lwp *);
  238         int     (*l_rint)       (int, struct tty *);
  239         int     (*l_start)      (struct tty *);
  240         int     (*l_modem)      (struct tty *, int);
  241         int     (*l_poll)       (struct tty *, int, struct lwp *);
  242 };
  243 
  244 #ifdef _KERNEL
  245 void           ttyldisc_init(void);
  246 int            ttyldisc_attach(struct linesw *);
  247 int            ttyldisc_detach(struct linesw *);
  248 struct linesw *ttyldisc_lookup(const char *);
  249 struct linesw *ttyldisc_lookup_bynum(int);
  250 struct linesw *ttyldisc_default(void);
  251 void           ttyldisc_release(struct linesw *);
  252 
  253 /* For those defining their own line disciplines: */
  254 #define ttynodisc ((int (*)(dev_t, struct tty *))devenodev)
  255 #define ttyerrclose ((int (*)(struct tty *, int))ttyenodev)
  256 #define ttyerrio ((int (*)(struct tty *, struct uio *, int))ttyenodev)
  257 #define ttyerrstart ((int (*)(struct tty *))ttyenodev)
  258 
  259 int     ttyerrpoll (struct tty *, int, struct lwp *);
  260 int     ttynullioctl(struct tty *, u_long, void *, int, struct lwp *);
  261 
  262 int     iskmemdev(dev_t);
  263 int     seltrue_kqfilter(dev_t, struct knote *);
  264 #endif
  265 
  266 #ifdef _KERNEL
  267 
  268 #define DEV_MEM         0       /* minor device 0 is physical memory */
  269 #define DEV_KMEM        1       /* minor device 1 is kernel memory */
  270 #define DEV_NULL        2       /* minor device 2 is EOF/rathole */
  271 #ifdef COMPAT_16
  272 #define _DEV_ZERO_oARM  3       /* reserved: old ARM /dev/zero minor */
  273 #endif
  274 #define DEV_FULL        11      /* minor device 11 is '\0'/ENOSPC */
  275 #define DEV_ZERO        12      /* minor device 12 is '\0'/rathole */
  276 
  277 enum devnode_class {
  278         DEVNODE_DONTBOTHER,
  279         DEVNODE_SINGLE,
  280         DEVNODE_VECTOR,
  281 };
  282 #define DEVNODE_FLAG_LINKZERO   0x01    /* create name -> name0 link */
  283 #define DEVNODE_FLAG_ISMINOR0   0x02    /* vector[0] specifies minor */
  284 #ifdef notyet
  285 #define DEVNODE_FLAG_ISMINOR1   0x04    /* vector[1] specifies starting minor */
  286 #endif
  287 
  288 struct devsw_conv {
  289         const char *d_name;
  290         devmajor_t d_bmajor;
  291         devmajor_t d_cmajor;
  292 
  293         /* information about /dev nodes related to the device */
  294         enum devnode_class d_class;
  295         int d_flags;
  296         int d_vectdim[2];
  297 };
  298 
  299 void devsw_init(void);
  300 const char *devsw_blk2name(devmajor_t);
  301 const char *cdevsw_getname(devmajor_t);
  302 const char *bdevsw_getname(devmajor_t);
  303 devmajor_t devsw_name2blk(const char *, char *, size_t);
  304 devmajor_t devsw_name2chr(const char *, char *, size_t);
  305 dev_t devsw_chr2blk(dev_t);
  306 dev_t devsw_blk2chr(dev_t);
  307 int dev_minor_unit(dev_t);
  308 
  309 void mm_init(void);
  310 #endif /* _KERNEL */
  311 
  312 #ifdef _KERNEL
  313 void    setroot(device_t, int);
  314 void    rootconf(void);
  315 void    swapconf(void);
  316 #endif /* _KERNEL */
  317 
  318 #endif /* !_SYS_CONF_H_ */

Cache object: feb788605e730a854e71195d44e474c7


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.