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/kernel.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 /*-
    2  * Copyright (c) 1995 Terrence R. Lambert
    3  * All rights reserved.
    4  *
    5  * Copyright (c) 1990, 1993
    6  *      The Regents of the University of California.  All rights reserved.
    7  * (c) UNIX System Laboratories, Inc.
    8  * All or some portions of this file are derived from material licensed
    9  * to the University of California by American Telephone and Telegraph
   10  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
   11  * the permission of UNIX System Laboratories, Inc.
   12  *
   13  * Redistribution and use in source and binary forms, with or without
   14  * modification, are permitted provided that the following conditions
   15  * are met:
   16  * 1. Redistributions of source code must retain the above copyright
   17  *    notice, this list of conditions and the following disclaimer.
   18  * 2. Redistributions in binary form must reproduce the above copyright
   19  *    notice, this list of conditions and the following disclaimer in the
   20  *    documentation and/or other materials provided with the distribution.
   21  * 3. All advertising materials mentioning features or use of this software
   22  *    must display the following acknowledgement:
   23  *      This product includes software developed by the University of
   24  *      California, Berkeley and its contributors.
   25  * 4. Neither the name of the University nor the names of its contributors
   26  *    may be used to endorse or promote products derived from this software
   27  *    without specific prior written permission.
   28  *
   29  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   30  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   31  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   32  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   33  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   34  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   35  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   36  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   37  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   38  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   39  * SUCH DAMAGE.
   40  *
   41  *      @(#)kernel.h    8.3 (Berkeley) 1/21/94
   42  * $FreeBSD: src/sys/sys/kernel.h,v 1.22.2.3 1999/09/05 08:22:30 peter Exp $
   43  */
   44 
   45 #ifndef _SYS_KERNEL_H_
   46 #define _SYS_KERNEL_H_
   47 
   48 /* Global variables for the kernel. */
   49 
   50 /* 1.1 */
   51 extern long hostid;
   52 extern char hostname[MAXHOSTNAMELEN];
   53 extern int hostnamelen;
   54 extern char domainname[MAXHOSTNAMELEN];
   55 extern int domainnamelen;
   56 extern char kernelname[MAXPATHLEN];
   57 
   58 /* 1.2 */
   59 extern volatile struct timeval mono_time;
   60 extern struct timeval boottime;
   61 extern struct timeval runtime;
   62 extern volatile struct timeval time;
   63 extern struct timezone tz;                      /* XXX */
   64 
   65 extern int tick;                        /* usec per tick (1000000 / hz) */
   66 extern int hz;                          /* system clock's frequency */
   67 extern int psratio;                     /* ratio: prof / stat */
   68 extern int stathz;                      /* statistics clock's frequency */
   69 extern int profhz;                      /* profiling clock's frequency */
   70 extern int ticks;
   71 extern int lbolt;                       /* once a second sleep address */
   72 extern int tickdelta;
   73 extern long timedelta;
   74 
   75 /*
   76  * The following macros are used to declare global sets of objects, which
   77  * are collected by the linker into a `struct linker_set' as defined below.
   78  *
   79  * NB: the constants defined below must match those defined in
   80  * ld/ld.h.  Since their calculation requires arithmetic, we
   81  * can't name them symbolically (e.g., 23 is N_SETT | N_EXT).
   82  */
   83 #define MAKE_SET(set, sym, type) \
   84         static void const * const __set_##set##_sym_##sym = &sym; \
   85         __asm(".stabs \"_" #set "\", " #type ", 0, 0, _" #sym)
   86 #define TEXT_SET(set, sym) MAKE_SET(set, sym, 23)
   87 #define DATA_SET(set, sym) MAKE_SET(set, sym, 25)
   88 #define BSS_SET(set, sym)  MAKE_SET(set, sym, 27)
   89 #define ABS_SET(set, sym)  MAKE_SET(set, sym, 21)
   90 
   91 
   92 /*
   93  * Enumerated types for known system startup interfaces.
   94  *
   95  * Startup occurs in ascending numeric order; the list entries are
   96  * sorted prior to attempting startup to guarantee order.  Items
   97  * of the same level are arbitrated for order based on the 'order'
   98  * element.
   99  *
  100  * These numbers are arbitrary and are chosen ONLY for ordering; the
  101  * enumeration values are explicit rather than implicit to provide
  102  * for binary compatibility with inserted elements.
  103  *
  104  * The SI_SUB_RUN_SCHEDULER value must have the highest lexical value.
  105  *
  106  * The SI_SUB_CONSOLE and SI_SUB_SWAP values represent values used by
  107  * the BSD 4.4Lite but not by FreeBSD; they are maintained in dependent
  108  * order to support porting.
  109  *
  110  * The SI_SUB_PROTO_BEGIN and SI_SUB_PROTO_END bracket a range of
  111  * initializations to take place at splimp().  This is a historical
  112  * wart that should be removed -- probably running everything at
  113  * splimp() until the first init that doesn't want it is the correct
  114  * fix.  They are currently present to ensure historical behavior.
  115  */
  116 enum sysinit_sub_id {
  117         SI_SUB_DUMMY            = 0x00000000,   /* not executed; for linker*/
  118         SI_SUB_CONSOLE          = 0x08000000,   /* console*/
  119         SI_SUB_COPYRIGHT        = 0x08000001,   /* first use of console*/
  120         SI_SUB_VM               = 0x10000000,   /* virtual memory system init*/
  121         SI_SUB_KMEM             = 0x18000000,   /* kernel memory*/
  122         SI_SUB_CPU              = 0x20000000,   /* CPU resource(s)*/
  123         SI_SUB_DEVFS            = 0x22000000,   /* get DEVFS ready */
  124         SI_SUB_DRIVERS          = 0x23000000,   /* Let Drivers initialize */
  125         SI_SUB_CONFIGURE        = 0x24000000,   /* Configure devices */
  126         SI_SUB_INTRINSIC        = 0x28000000,   /* proc 0*/
  127         SI_SUB_RUN_QUEUE        = 0x30000000,   /* the run queue*/
  128         SI_SUB_VM_CONF          = 0x38000000,   /* config VM, set limits*/
  129         SI_SUB_VFS              = 0x40000000,   /* virtual file system*/
  130         SI_SUB_CLOCKS           = 0x48000000,   /* real time and stat clocks*/
  131         SI_SUB_MBUF             = 0x50000000,   /* mbufs*/
  132         SI_SUB_CLIST            = 0x58000000,   /* clists*/
  133         SI_SUB_SYSV_SHM         = 0x64000000,   /* System V shared memory*/
  134         SI_SUB_SYSV_SEM         = 0x68000000,   /* System V semaphores*/
  135         SI_SUB_SYSV_MSG         = 0x6C000000,   /* System V message queues*/
  136         SI_SUB_PSEUDO           = 0x70000000,   /* pseudo devices*/
  137         SI_SUB_PROTO_BEGIN      = 0x80000000,   /* XXX: set splimp (kludge)*/
  138         SI_SUB_PROTO_IF         = 0x84000000,   /* interfaces*/
  139         SI_SUB_PROTO_DOMAIN     = 0x88000000,   /* domains (address families?)*/
  140         SI_SUB_PROTO_END        = 0x8fffffff,   /* XXX: set splx (kludge)*/
  141         SI_SUB_KPROF            = 0x90000000,   /* kernel profiling*/
  142         SI_SUB_KICK_SCHEDULER   = 0xa0000000,   /* start the timeout events*/
  143         SI_SUB_INT_CONFIG_HOOKS = 0xa8000000,   /* Interrupts enabled config */
  144         SI_SUB_ROOT_CONF        = 0xb0000000,   /* Find root devices */
  145         SI_SUB_DUMP_CONF        = 0xb2000000,   /* Find dump devices */
  146         SI_SUB_MOUNT_ROOT       = 0xb4000000,   /* root mount*/
  147         SI_SUB_ROOT_FDTAB       = 0xb8000000,   /* root vnode in fd table...*/
  148         SI_SUB_SWAP             = 0xc0000000,   /* swap*/
  149         SI_SUB_INTRINSIC_POST   = 0xd0000000,   /* proc 0 cleanup*/
  150         SI_SUB_KTHREAD_INIT     = 0xe0000000,   /* init process*/
  151         SI_SUB_KTHREAD_PAGE     = 0xe4000000,   /* pageout daemon*/
  152         SI_SUB_KTHREAD_VM       = 0xe8000000,   /* vm daemon*/
  153         SI_SUB_KTHREAD_UPDATE   = 0xec000000,   /* update daemon*/
  154         SI_SUB_RUN_SCHEDULER    = 0xffffffff    /* scheduler: no return*/
  155 };
  156 
  157 
  158 /*
  159  * Some enumerated orders; "ANY" sorts last.
  160  */
  161 enum sysinit_elem_order {
  162         SI_ORDER_FIRST          = 0x00000000,   /* first*/
  163         SI_ORDER_SECOND         = 0x00000001,   /* second*/
  164         SI_ORDER_THIRD          = 0x00000002,   /* third*/
  165         SI_ORDER_MIDDLE         = 0x10000000,   /* somewhere in the middle */
  166         SI_ORDER_ANY            = 0xffffffff    /* last*/
  167 };
  168 
  169 
  170 /*
  171  * System initialization call types; currently two are supported... one
  172  * to do a simple function call and one to cause a process to be started
  173  * by the kernel on the callers behalf.
  174  */
  175 typedef enum sysinit_elem_type {
  176         SI_TYPE_DEFAULT         = 0x00000000,   /* No special processing*/
  177         SI_TYPE_KTHREAD         = 0x00000001    /* start kernel thread*/
  178 } si_elem_t;
  179 
  180 
  181 /*
  182  * A system initialization call instance
  183  *
  184  * The subsystem
  185  */
  186 struct sysinit {
  187         unsigned int    subsystem;              /* subsystem identifier*/
  188         unsigned int    order;                  /* init order within subsystem*/
  189         void            (*func) __P((void *));  /* init function*/
  190         void            *udata;                 /* multiplexer/argument */
  191         si_elem_t       type;                   /* sysinit_elem_type*/
  192 };
  193 
  194 
  195 /*
  196  * Default: no special processing
  197  */
  198 #define SYSINIT(uniquifier, subsystem, order, func, ident)      \
  199         static struct sysinit uniquifier ## _sys_init = {       \
  200                 subsystem,                                      \
  201                 order,                                          \
  202                 func,                                           \
  203                 ident,                                          \
  204                 SI_TYPE_DEFAULT                                 \
  205         };                                                      \
  206         DATA_SET(sysinit_set,uniquifier ## _sys_init);
  207 
  208 /*
  209  * Call 'fork()' before calling '(*func)(ident)';
  210  * for making a kernel 'thread' (or builtin process.)
  211  */
  212 #define SYSINIT_KT(uniquifier, subsystem, order, func, ident)   \
  213         static struct sysinit uniquifier ## _sys_init = {       \
  214                 subsystem,                                      \
  215                 order,                                          \
  216                 func,                                           \
  217                 ident,                                          \
  218                 SI_TYPE_KTHREAD                                 \
  219         };                                                      \
  220         DATA_SET(sysinit_set,uniquifier ## _sys_init);
  221 
  222 
  223 /*
  224  * A kernel process descriptor; used to start "internal" daemons
  225  *
  226  * Note: global_procpp may be NULL for no global save area
  227  */
  228 struct kproc_desc {
  229         char            *arg0;                  /* arg 0 (for 'ps' listing)*/
  230         void            (*func) __P((void));    /* "main" for kernel process*/
  231         struct proc     **global_procpp;        /* ptr to proc ptr save area*/
  232 };
  233 
  234 void    kproc_start __P((void *udata));
  235 
  236 #ifdef PSEUDO_LKM
  237 #include <sys/conf.h>
  238 #include <sys/exec.h>
  239 #include <sys/sysent.h>
  240 #include <sys/lkm.h>
  241 
  242 #define PSEUDO_SET(init, name) \
  243         extern struct linker_set MODVNOPS; \
  244         MOD_MISC(name); \
  245         static int \
  246         name ## _load(struct lkm_table *lkmtp, int cmd) \
  247                 { init((void *)NULL /* XXX unused (?) */); return 0; } \
  248         static int \
  249         name ## _unload(struct lkm_table *lkmtp, int cmd) \
  250                 { return EINVAL; } \
  251         int \
  252         name ## _mod(struct lkm_table *lkmtp, int cmd, int ver) { \
  253                 DISPATCH(lkmtp, cmd, ver, name ## _load, name ## _unload, \
  254                          lkm_nullcmd); }
  255 #else /* PSEUDO_LKM */
  256 
  257 /*
  258  * Compatibility.  To be deprecated after LKM is updated.
  259  */
  260 #define PSEUDO_SET(sym, name)   SYSINIT(ps, SI_SUB_PSEUDO, SI_ORDER_ANY, sym, 0)
  261 
  262 #endif /* PSEUDO_LKM */
  263 
  264 struct linker_set {
  265         int             ls_length;
  266         const void      *ls_items[1];           /* really ls_length of them,
  267                                                  * trailing NULL */
  268 };
  269 
  270 extern struct linker_set execsw_set;
  271 
  272 #endif /* !_SYS_KERNEL_H_*/

Cache object: be4af5b7ed25100b5b383306eafbe52a


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