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/systm.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: systm.h,v 1.170 2004/01/23 05:01:19 simonb Exp $       */
    2 
    3 /*-
    4  * Copyright (c) 1982, 1988, 1991, 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  *      @(#)systm.h     8.7 (Berkeley) 3/29/95
   37  */
   38 
   39 /*
   40  * The `securelevel' variable controls the security level of the system.
   41  * It can only be decreased by process 1 (/sbin/init).
   42  *
   43  * Security levels are as follows:
   44  *   -1 permanently insecure mode - always run system in level 0 mode.
   45  *    0 insecure mode - immutable and append-only flags may be turned off.
   46  *      All devices may be read or written subject to permission modes.
   47  *    1 secure mode - immutable and append-only flags may not be changed;
   48  *      raw disks of mounted filesystems, /dev/mem, and /dev/kmem are
   49  *      read-only.
   50  *    2 highly secure mode - same as (1) plus raw disks are always
   51  *      read-only whether mounted or not. This level precludes tampering
   52  *      with filesystems by unmounting them, but also inhibits running
   53  *      newfs while the system is secured.
   54  *
   55  * In normal operation, the system runs in level 0 mode while single user
   56  * and in level 1 mode while multiuser. If level 2 mode is desired while
   57  * running multiuser, it can be set in the multiuser startup script
   58  * (/etc/rc.local) using sysctl(8). If it is desired to run the system
   59  * in level 0 mode while multiuser, initialize the variable securelevel
   60  * in /sys/kern/kern_sysctl.c to -1. Note that it is NOT initialized to
   61  * zero as that would allow the vmunix binary to be patched to -1.
   62  * Without initialization, securelevel loads in the BSS area which only
   63  * comes into existence when the kernel is loaded and hence cannot be
   64  * patched by a stalking hacker.
   65  */
   66 
   67 #ifndef _SYS_SYSTM_H_
   68 #define _SYS_SYSTM_H_
   69 
   70 #if defined(_KERNEL_OPT)
   71 #include "opt_ddb.h"
   72 #include "opt_multiprocessor.h"
   73 #include "opt_syscall_debug.h"
   74 #endif
   75 
   76 #include <machine/endian.h>
   77 
   78 struct clockframe;
   79 struct device;
   80 struct lwp;
   81 struct proc;
   82 struct timeval;
   83 struct tty;
   84 struct uio;
   85 struct vnode;
   86 
   87 extern int securelevel;         /* system security level */
   88 extern const char *panicstr;    /* panic message */
   89 extern int doing_shutdown;      /* shutting down */
   90 
   91 extern const char copyright[];  /* system copyright */
   92 extern char cpu_model[];        /* machine/cpu model name */
   93 extern char machine[];          /* machine type */
   94 extern char machine_arch[];     /* machine architecture */
   95 extern const char osrelease[];  /* short system version */
   96 extern const char ostype[];     /* system type */
   97 extern const char version[];    /* system version */
   98 
   99 extern int autonicetime;        /* time (in seconds) before autoniceval */
  100 extern int autoniceval;         /* proc priority after autonicetime */
  101 
  102 extern int selwait;             /* select timeout address */
  103 
  104 extern int maxmem;              /* max memory per process */
  105 extern int physmem;             /* physical memory */
  106 
  107 extern dev_t dumpdev;           /* dump device */
  108 extern long dumplo;             /* offset into dumpdev */
  109 extern int dumpsize;            /* size of dump in pages */
  110 extern const char *dumpspec;    /* how dump device was specified */
  111 
  112 extern dev_t rootdev;           /* root device */
  113 extern struct vnode *rootvp;    /* vnode equivalent to above */
  114 extern struct device *root_device; /* device equivalent to above */
  115 extern const char *rootspec;    /* how root device was specified */
  116 
  117 /*
  118  * These represent the swap pseudo-device (`sw').  This device
  119  * is used by the swap pager to indirect through the routines
  120  * in sys/vm/vm_swap.c.
  121  */
  122 extern const dev_t swapdev;     /* swapping device */
  123 extern struct vnode *swapdev_vp;/* vnode equivalent to above */
  124 
  125 extern const dev_t zerodev;     /* /dev/zero */
  126 
  127 typedef int     sy_call_t(struct lwp *, void *, register_t *);
  128 
  129 extern struct sysent {          /* system call table */
  130         short   sy_narg;        /* number of args */
  131         short   sy_argsize;     /* total size of arguments */
  132         int     sy_flags;       /* flags. see below */
  133         sy_call_t *sy_call;     /* implementing function */
  134 } sysent[];
  135 extern int nsysent;
  136 #if     BYTE_ORDER == BIG_ENDIAN
  137 #define SCARG(p,k)      ((p)->k.be.datum)       /* get arg from args pointer */
  138 #elif   BYTE_ORDER == LITTLE_ENDIAN
  139 #define SCARG(p,k)      ((p)->k.le.datum)       /* get arg from args pointer */
  140 #else
  141 #error  "what byte order is this machine?"
  142 #endif
  143 
  144 #define SYCALL_MPSAFE   0x0001  /* syscall is MP-safe */
  145 
  146 extern int boothowto;           /* reboot flags, from console subsystem */
  147 #define bootverbose     (boothowto & AB_VERBOSE)
  148 #define bootquiet       (boothowto & AB_QUIET)
  149 
  150 extern void (*v_putc) __P((int)); /* Virtual console putc routine */
  151 
  152 extern  void    _insque __P((void *, void *));
  153 extern  void    _remque __P((void *));
  154 
  155 /* casts to keep lint happy, but it should be happy with void * */
  156 #define insque(q,p)     _insque(q, p)
  157 #define remque(q)       _remque(q)
  158 
  159 /*
  160  * General function declarations.
  161  */
  162 int     nullop __P((void *));
  163 int     enodev __P((void));
  164 int     enosys __P((void));
  165 int     enoioctl __P((void));
  166 int     enxio __P((void));
  167 int     eopnotsupp __P((void));
  168 
  169 enum hashtype {
  170         HASH_LIST,
  171         HASH_TAILQ
  172 };
  173 
  174 struct malloc_type;
  175 void    *hashinit __P((u_int, enum hashtype, struct malloc_type *,
  176             int, u_long *));
  177 void    hashdone __P((void *, struct malloc_type *));
  178 int     seltrue __P((dev_t, int, struct proc *));
  179 int     sys_nosys __P((struct lwp *, void *, register_t *));
  180 
  181 
  182 #ifdef _KERNEL
  183 void    aprint_normal __P((const char *, ...))
  184     __attribute__((__format__(__printf__,1,2)));
  185 void    aprint_error __P((const char *, ...))
  186     __attribute__((__format__(__printf__,1,2)));
  187 void    aprint_naive __P((const char *, ...))
  188     __attribute__((__format__(__printf__,1,2)));
  189 void    aprint_verbose __P((const char *, ...))
  190     __attribute__((__format__(__printf__,1,2)));
  191 void    aprint_debug __P((const char *, ...))
  192     __attribute__((__format__(__printf__,1,2)));
  193 
  194 int     aprint_get_error_count __P((void));
  195 
  196 void    printf_nolog __P((const char *, ...))
  197     __attribute__((__format__(__printf__,1,2)));
  198 
  199 void    printf __P((const char *, ...))
  200     __attribute__((__format__(__printf__,1,2)));
  201 int     sprintf __P((char *, const char *, ...))
  202     __attribute__((__format__(__printf__,2,3)));
  203 int     snprintf __P((char *, size_t, const char *, ...))
  204     __attribute__((__format__(__printf__,3,4)));
  205 void    vprintf __P((const char *, _BSD_VA_LIST_));
  206 int     vsprintf __P((char *, const char *, _BSD_VA_LIST_));
  207 int     vsnprintf __P((char *, size_t, const char *, _BSD_VA_LIST_));
  208 int     humanize_number __P((char *, size_t, u_int64_t, const char *, int));
  209 
  210 void    twiddle __P((void));
  211 #endif /* _KERNEL */
  212 
  213 void    panic __P((const char *, ...))
  214     __attribute__((__noreturn__,__format__(__printf__,1,2)));
  215 void    uprintf __P((const char *, ...))
  216     __attribute__((__format__(__printf__,1,2)));
  217 void    ttyprintf __P((struct tty *, const char *, ...))
  218     __attribute__((__format__(__printf__,2,3)));
  219 
  220 char    *bitmask_snprintf __P((u_quad_t, const char *, char *, size_t));
  221 
  222 int     format_bytes __P((char *, size_t, u_int64_t));
  223 
  224 void    tablefull __P((const char *, const char *));
  225 
  226 int     kcopy __P((const void *, void *, size_t));
  227 
  228 #ifdef _KERNEL
  229 #define bcopy(src, dst, len)    memcpy((dst), (src), (len))
  230 #define bzero(src, len)         memset((src), 0, (len))
  231 #define bcmp(a, b, len)         memcmp((a), (b), (len))
  232 #endif /* KERNEL */
  233 
  234 int     copystr __P((const void *, void *, size_t, size_t *));
  235 int     copyinstr __P((const void *, void *, size_t, size_t *));
  236 int     copyoutstr __P((const void *, void *, size_t, size_t *));
  237 int     copyin __P((const void *, void *, size_t));
  238 int     copyout __P((const void *, void *, size_t));
  239 
  240 int     copyin_proc __P((struct proc *, const void *, void *, size_t));
  241 int     copyout_proc __P((struct proc *, const void *, void *, size_t));
  242 
  243 int     subyte __P((void *, int));
  244 int     suibyte __P((void *, int));
  245 int     susword __P((void *, short));
  246 int     suisword __P((void *, short));
  247 int     suswintr __P((void *, short));
  248 int     suword __P((void *, long));
  249 int     suiword __P((void *, long));
  250 
  251 int     fubyte __P((const void *));
  252 int     fuibyte __P((const void *));
  253 int     fusword __P((const void *));
  254 int     fuisword __P((const void *));
  255 int     fuswintr __P((const void *));
  256 long    fuword __P((const void *));
  257 long    fuiword __P((const void *));
  258 
  259 int     hzto __P((struct timeval *));
  260 
  261 void    hardclock __P((struct clockframe *));
  262 void    softclock __P((void *));
  263 void    statclock __P((struct clockframe *));
  264 #ifdef NTP
  265 void    hardupdate __P((long offset));
  266 #ifdef PPS_SYNC
  267 void    hardpps __P((struct timeval *, long));
  268 extern  void *pps_kc_hardpps_source;
  269 extern  int pps_kc_hardpps_mode;
  270 #endif
  271 #endif
  272 
  273 void    initclocks __P((void));
  274 void    inittodr __P((time_t));
  275 void    resettodr __P((void));
  276 void    cpu_initclocks __P((void));
  277 
  278 void    startprofclock __P((struct proc *));
  279 void    stopprofclock __P((struct proc *));
  280 void    proftick __P((struct clockframe *));
  281 void    setstatclockrate __P((int));
  282 
  283 /*
  284  * Shutdown hooks.  Functions to be run with all interrupts disabled
  285  * immediately before the system is halted or rebooted.
  286  */
  287 void    *shutdownhook_establish __P((void (*)(void *), void *));
  288 void    shutdownhook_disestablish __P((void *));
  289 void    doshutdownhooks __P((void));
  290 
  291 /*
  292  * Power management hooks.
  293  */
  294 void    *powerhook_establish __P((void (*)(int, void *), void *));
  295 void    powerhook_disestablish __P((void *));
  296 void    dopowerhooks __P((int));
  297 #define PWR_RESUME      0
  298 #define PWR_SUSPEND     1
  299 #define PWR_STANDBY     2
  300 #define PWR_SOFTRESUME  3
  301 #define PWR_SOFTSUSPEND 4
  302 #define PWR_SOFTSTANDBY 5
  303 
  304 /*
  305  * Mountroot hooks (and mountroot declaration).  Device drivers establish
  306  * these to be executed just before (*mountroot)() if the passed device is
  307  * selected as the root device.
  308  */
  309 extern int (*mountroot)(void);
  310 void    *mountroothook_establish __P((void (*)(struct device *),
  311             struct device *));
  312 void    mountroothook_disestablish __P((void *));
  313 void    mountroothook_destroy __P((void));
  314 void    domountroothook __P((void));
  315 
  316 /*
  317  * Exec hooks. Subsystems may want to do cleanup when a process
  318  * execs.
  319  */
  320 void    *exechook_establish __P((void (*)(struct proc *, void *), void *));
  321 void    exechook_disestablish __P((void *));
  322 void    doexechooks __P((struct proc *));
  323 
  324 /*
  325  * Exit hooks. Subsystems may want to do cleanup when a process exits.
  326  */
  327 void    *exithook_establish __P((void (*)(struct proc *, void *), void *));
  328 void    exithook_disestablish __P((void *));
  329 void    doexithooks __P((struct proc *));
  330 
  331 /*
  332  * Fork hooks.  Subsystems may want to do special processing when a process
  333  * forks.
  334  */
  335 void    *forkhook_establish __P((void (*)(struct proc *, struct proc *)));
  336 void    forkhook_disestablish __P((void *));
  337 void    doforkhooks __P((struct proc *, struct proc *));
  338 
  339 /*
  340  * kernel syscall tracing/debugging hooks.
  341  */
  342 int     trace_enter __P((struct lwp *, register_t, register_t,
  343             const struct sysent *, void *));
  344 void    trace_exit __P((struct lwp *, register_t, void *, register_t [], int));
  345 
  346 int     uiomove __P((void *, size_t, struct uio *));
  347 
  348 #ifdef _KERNEL
  349 int     setjmp  __P((label_t *));
  350 void    longjmp __P((label_t *));
  351 #endif
  352 
  353 void    consinit __P((void));
  354 
  355 void    cpu_startup __P((void));
  356 void    cpu_configure __P((void));
  357 void    cpu_rootconf __P((void));
  358 void    cpu_dumpconf __P((void));
  359 
  360 #ifdef GPROF
  361 void    kmstartup __P((void));
  362 #endif
  363 
  364 #ifdef _KERNEL
  365 #include <lib/libkern/libkern.h>
  366 
  367 /*
  368  * Stuff to handle debugger magic key sequences.
  369  */
  370 #define CNS_LEN                 128
  371 #define CNS_MAGIC_VAL(x)        ((x)&0x1ff)
  372 #define CNS_MAGIC_NEXT(x)       (((x)>>9)&0x7f)
  373 #define CNS_TERM                0x7f    /* End of sequence */
  374 
  375 typedef struct cnm_state {
  376         int     cnm_state;
  377         u_short *cnm_magic;
  378 } cnm_state_t;
  379 
  380 /* Override db_console() in MD headers */
  381 #ifndef cn_trap
  382 #define cn_trap()       console_debugger()
  383 #endif
  384 #ifndef cn_isconsole
  385 #define cn_isconsole(d) (cn_tab != NULL && (d) == cn_tab->cn_dev)
  386 #endif
  387 
  388 void cn_init_magic __P((cnm_state_t *));
  389 void cn_destroy_magic __P((cnm_state_t *));
  390 int cn_set_magic __P((char *));
  391 int cn_get_magic __P((char *, int));
  392 /* This should be called for each byte read */
  393 #ifndef cn_check_magic
  394 #define cn_check_magic(d, k, s)                                         \
  395         do {                                                            \
  396                 if (cn_isconsole(d)) {                                  \
  397                         int v = (s).cnm_magic[(s).cnm_state];           \
  398                         if ((k) == CNS_MAGIC_VAL(v)) {                  \
  399                                 (s).cnm_state = CNS_MAGIC_NEXT(v);      \
  400                                 if ((s).cnm_state == CNS_TERM) {        \
  401                                         cn_trap();                      \
  402                                         (s).cnm_state = 0;              \
  403                                 }                                       \
  404                         } else {                                        \
  405                                 (s).cnm_state = 0;                      \
  406                         }                                               \
  407                 }                                                       \
  408         } while (/* CONSTCOND */ 0)
  409 #endif
  410 
  411 /* Encode out-of-band events this way when passing to cn_check_magic() */
  412 #define CNC_BREAK               0x100
  413 
  414 #if defined(DDB) || defined(sun3) || defined(sun2)
  415 /* note that cpu_Debugger() is always available on sun[23] */
  416 void    cpu_Debugger __P((void));
  417 #define Debugger        cpu_Debugger
  418 #endif
  419 
  420 #ifdef DDB
  421 /*
  422  * Enter debugger(s) from console attention if enabled
  423  */
  424 extern int db_fromconsole; /* XXX ddb/ddbvar.h */
  425 #define console_debugger() if (db_fromconsole) Debugger()
  426 #elif defined(Debugger)
  427 #define console_debugger() Debugger()
  428 #else
  429 #define console_debugger() do {} while (/* CONSTCOND */ 0) /* NOP */
  430 #endif
  431 #endif /* _KERNEL */
  432 
  433 #ifdef SYSCALL_DEBUG
  434 void scdebug_call __P((struct lwp *, register_t, register_t[]));
  435 void scdebug_ret __P((struct lwp *, register_t, int, register_t[]));
  436 #endif /* SYSCALL_DEBUG */
  437 
  438 #if defined(MULTIPROCESSOR)
  439 void    _kernel_lock_init(void);
  440 void    _kernel_lock(int);
  441 void    _kernel_unlock(void);
  442 void    _kernel_proc_lock(struct lwp *);
  443 void    _kernel_proc_unlock(struct lwp *);
  444 
  445 #define KERNEL_LOCK_INIT()              _kernel_lock_init()
  446 #define KERNEL_LOCK(flag)               _kernel_lock((flag))
  447 #define KERNEL_UNLOCK()                 _kernel_unlock()
  448 #define KERNEL_PROC_LOCK(l)             _kernel_proc_lock((l))
  449 #define KERNEL_PROC_UNLOCK(l)           _kernel_proc_unlock((l))
  450 
  451 #else /* ! MULTIPROCESSOR */
  452 
  453 #define KERNEL_LOCK_INIT()              /* nothing */
  454 #define KERNEL_LOCK(flag)               /* nothing */
  455 #define KERNEL_UNLOCK()                 /* nothing */
  456 #define KERNEL_PROC_LOCK(l)             /* nothing */
  457 #define KERNEL_PROC_UNLOCK(l)           /* nothing */
  458 
  459 #endif /* MULTIPROCESSOR */
  460 
  461 #endif  /* !_SYS_SYSTM_H_ */

Cache object: 26d2933960233164ed4f35ae4c10c93d


[ 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.