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-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 1982, 1988, 1991, 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  * 4. Neither the name of the University nor the names of its contributors
   19  *    may be used to endorse or promote products derived from this software
   20  *    without specific prior written permission.
   21  *
   22  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   32  * SUCH DAMAGE.
   33  *
   34  *      @(#)systm.h     8.7 (Berkeley) 3/29/95
   35  * $FreeBSD$
   36  */
   37 
   38 #ifndef _SYS_SYSTM_H_
   39 #define _SYS_SYSTM_H_
   40 
   41 #include <machine/atomic.h>
   42 #include <machine/cpufunc.h>
   43 #include <sys/callout.h>
   44 #include <sys/cdefs.h>
   45 #include <sys/queue.h>
   46 #include <sys/stdint.h>         /* for people using printf mainly */
   47 
   48 extern int securelevel;         /* system security level (see init(8)) */
   49 extern int suser_enabled;       /* suser() is permitted to return 0 */
   50 
   51 extern int cold;                /* nonzero if we are doing a cold boot */
   52 extern const char *panicstr;    /* panic message */
   53 extern char version[];          /* system version */
   54 extern char copyright[];        /* system copyright */
   55 extern int kstack_pages;        /* number of kernel stack pages */
   56 
   57 extern int nswap;               /* size of swap space */
   58 
   59 extern u_int nselcoll;          /* select collisions since boot */
   60 extern struct mtx sellock;      /* select lock variable */
   61 extern struct cv selwait;       /* select conditional variable */
   62 
   63 extern long physmem;            /* physical memory */
   64 extern long realmem;            /* 'real' memory */
   65 
   66 extern struct cdev *rootdev;            /* root device */
   67 extern char *rootdevnames[2];   /* names of possible root devices */
   68 
   69 extern int boothowto;           /* reboot flags, from console subsystem */
   70 extern int bootverbose;         /* nonzero to print verbose messages */
   71 
   72 extern int maxusers;            /* system tune hint */
   73 
   74 #ifdef  INVARIANTS              /* The option is always available */
   75 #define KASSERT(exp,msg) do {                                           \
   76         if (__predict_false(!(exp)))                                    \
   77                 panic msg;                                              \
   78 } while (0)
   79 #else
   80 #define KASSERT(exp,msg)
   81 #endif
   82 
   83 #ifndef CTASSERT                /* Allow lint to override */
   84 #define CTASSERT(x)             _CTASSERT(x, __LINE__)
   85 #define _CTASSERT(x, y)         __CTASSERT(x, y)
   86 #define __CTASSERT(x, y)        typedef char __assert ## y[(x) ? 1 : -1]
   87 #endif
   88 
   89 /*
   90  * XXX the hints declarations are even more misplaced than most declarations
   91  * in this file, since they are needed in one file (per arch) and only used
   92  * in two files.
   93  * XXX most of these variables should be const.
   94  */
   95 extern int envmode;
   96 extern int hintmode;            /* 0 = off. 1 = config, 2 = fallback */
   97 extern int dynamic_kenv;
   98 extern struct sx kenv_lock;
   99 extern char *kern_envp;
  100 extern char static_env[];
  101 extern char static_hints[];     /* by config for now */
  102 
  103 extern char **kenvp;
  104 
  105 /*
  106  * General function declarations.
  107  */
  108 
  109 struct clockframe;
  110 struct malloc_type;
  111 struct mtx;
  112 struct proc;
  113 struct kse;
  114 struct socket;
  115 struct thread;
  116 struct tty;
  117 struct ucred;
  118 struct uio;
  119 struct _jmp_buf;
  120 
  121 int     setjmp(struct _jmp_buf *);
  122 void    longjmp(struct _jmp_buf *, int) __dead2;
  123 int     dumpstatus(vm_offset_t addr, off_t count);
  124 int     nullop(void);
  125 int     eopnotsupp(void);
  126 int     ureadc(int, struct uio *);
  127 void    hashdestroy(void *, struct malloc_type *, u_long);
  128 void    *hashinit(int count, struct malloc_type *type, u_long *hashmask);
  129 void    *phashinit(int count, struct malloc_type *type, u_long *nentries);
  130 void    g_waitidle(void);
  131 
  132 #ifdef RESTARTABLE_PANICS
  133 void    panic(const char *, ...) __printflike(1, 2);
  134 #else
  135 void    panic(const char *, ...) __dead2 __printflike(1, 2);
  136 #endif
  137 
  138 void    cpu_boot(int);
  139 void    cpu_rootconf(void);
  140 extern uint32_t crc32_tab[];
  141 uint32_t crc32(const void *buf, size_t size);
  142 void    critical_enter(void);
  143 void    critical_exit(void);
  144 void    init_param1(void);
  145 void    init_param2(long physpages);
  146 void    init_param3(long kmempages);
  147 void    tablefull(const char *);
  148 int     kvprintf(char const *, void (*)(int, void*), void *, int,
  149             __va_list) __printflike(1, 0);
  150 void    log(int, const char *, ...) __printflike(2, 3);
  151 void    log_console(struct uio *);
  152 int     printf(const char *, ...) __printflike(1, 2);
  153 int     snprintf(char *, size_t, const char *, ...) __printflike(3, 4);
  154 int     sprintf(char *buf, const char *, ...) __printflike(2, 3);
  155 int     uprintf(const char *, ...) __printflike(1, 2);
  156 int     vprintf(const char *, __va_list) __printflike(1, 0);
  157 int     vsnprintf(char *, size_t, const char *, __va_list) __printflike(3, 0);
  158 int     vsnrprintf(char *, size_t, int, const char *, __va_list) __printflike(4, 0);
  159 int     vsprintf(char *buf, const char *, __va_list) __printflike(2, 0);
  160 int     ttyprintf(struct tty *, const char *, ...) __printflike(2, 3);
  161 int     sscanf(const char *, char const *, ...) __nonnull(1) __nonnull(2);
  162 int     vsscanf(const char *, char const *, __va_list) __nonnull(1) __nonnull(2);
  163 long    strtol(const char *, char **, int) __nonnull(1);
  164 u_long  strtoul(const char *, char **, int) __nonnull(1);
  165 quad_t  strtoq(const char *, char **, int) __nonnull(1);
  166 u_quad_t strtouq(const char *, char **, int) __nonnull(1);
  167 void    tprintf(struct proc *p, int pri, const char *, ...) __printflike(3, 4);
  168 void    hexdump(void *ptr, int length, const char *hdr, int flags);
  169 #define HD_COLUMN_MASK  0xff
  170 #define HD_DELIM_MASK   0xff00
  171 #define HD_OMIT_COUNT   (1 << 16)
  172 #define HD_OMIT_HEX     (1 << 17)
  173 #define HD_OMIT_CHARS   (1 << 18)
  174 
  175 #define ovbcopy(f, t, l) bcopy((f), (t), (l))
  176 void    bcopy(const void *from, void *to, size_t len) __nonnull(1) __nonnull(2);
  177 void    bzero(void *buf, size_t len) __nonnull(1);
  178 
  179 void    *memcpy(void *to, const void *from, size_t len) __nonnull(1) __nonnull(2);
  180 
  181 int     copystr(const void * __restrict kfaddr, void * __restrict kdaddr,
  182             size_t len, size_t * __restrict lencopied)
  183             __nonnull(1) __nonnull(2);
  184 int     copyinstr(const void * __restrict udaddr, void * __restrict kaddr,
  185             size_t len, size_t * __restrict lencopied)
  186             __nonnull(1) __nonnull(2);
  187 int     copyin(const void * __restrict udaddr, void * __restrict kaddr,
  188             size_t len) __nonnull(1) __nonnull(2);
  189 int     copyout(const void * __restrict kaddr, void * __restrict udaddr,
  190             size_t len) __nonnull(1) __nonnull(2);
  191 
  192 int     fubyte(const void *base);
  193 long    fuword(const void *base);
  194 int     fuword16(void *base);
  195 int32_t fuword32(const void *base);
  196 int64_t fuword64(const void *base);
  197 int     subyte(void *base, int byte);
  198 int     suword(void *base, long word);
  199 int     suword16(void *base, int word);
  200 int     suword32(void *base, int32_t word);
  201 int     suword64(void *base, int64_t word);
  202 intptr_t casuptr(intptr_t *p, intptr_t old, intptr_t new);
  203 
  204 void    realitexpire(void *);
  205 
  206 void    hardclock(struct clockframe *frame);
  207 void    hardclock_process(struct clockframe *frame);
  208 void    softclock(void *);
  209 void    statclock(struct clockframe *frame);
  210 void    profclock(struct clockframe *frame);
  211 
  212 void    startprofclock(struct proc *);
  213 void    stopprofclock(struct proc *);
  214 void    cpu_startprofclock(void);
  215 void    cpu_stopprofclock(void);
  216 
  217 /* flags for suser() and suser_cred() */
  218 #define SUSER_ALLOWJAIL 1
  219 #define SUSER_RUID      2
  220 
  221 int     suser(struct thread *td);
  222 int     suser_cred(struct ucred *cred, int flag);
  223 int     cr_cansee(struct ucred *u1, struct ucred *u2);
  224 int     cr_canseesocket(struct ucred *cred, struct socket *so);
  225 
  226 char    *getenv(const char *name);
  227 void    freeenv(char *env);
  228 int     getenv_int(const char *name, int *data);
  229 long    getenv_long(const char *name, long *data);
  230 unsigned long getenv_ulong(const char *name, unsigned long *data);
  231 int     getenv_string(const char *name, char *data, int size);
  232 int     getenv_quad(const char *name, quad_t *data);
  233 int     setenv(const char *name, const char *value);
  234 int     unsetenv(const char *name);
  235 int     testenv(const char *name);
  236 
  237 #ifdef APM_FIXUP_CALLTODO
  238 struct timeval;
  239 void    adjust_timeout_calltodo(struct timeval *time_change);
  240 #endif /* APM_FIXUP_CALLTODO */
  241 
  242 #include <sys/libkern.h>
  243 
  244 /* Initialize the world */
  245 void    consinit(void);
  246 void    cpu_initclocks(void);
  247 void    usrinfoinit(void);
  248 
  249 /* Finalize the world. */
  250 void    shutdown_nice(int);
  251 
  252 /*
  253  * Kernel to clock driver interface.
  254  */
  255 void    inittodr(time_t base);
  256 void    resettodr(void);
  257 void    startrtclock(void);
  258 
  259 /* Timeouts */
  260 typedef void timeout_t(void *); /* timeout function type */
  261 #define CALLOUT_HANDLE_INITIALIZER(handle)      \
  262         { NULL }
  263 
  264 void    callout_handle_init(struct callout_handle *);
  265 struct  callout_handle timeout(timeout_t *, void *, int);
  266 void    untimeout(timeout_t *, void *, struct callout_handle);
  267 caddr_t kern_timeout_callwheel_alloc(caddr_t v);
  268 void    kern_timeout_callwheel_init(void);
  269 
  270 /* Stubs for obsolete functions that used to be for interrupt  management */
  271 static __inline void            spl0(void)              { return; }
  272 static __inline intrmask_t      splbio(void)            { return 0; }
  273 static __inline intrmask_t      splcam(void)            { return 0; }
  274 static __inline intrmask_t      splclock(void)          { return 0; }
  275 static __inline intrmask_t      splhigh(void)           { return 0; }
  276 static __inline intrmask_t      splimp(void)            { return 0; }
  277 static __inline intrmask_t      splnet(void)            { return 0; }
  278 static __inline intrmask_t      splsoftcam(void)        { return 0; }
  279 static __inline intrmask_t      splsoftclock(void)      { return 0; }
  280 static __inline intrmask_t      splsofttty(void)        { return 0; }
  281 static __inline intrmask_t      splsoftvm(void)         { return 0; }
  282 static __inline intrmask_t      splsofttq(void)         { return 0; }
  283 static __inline intrmask_t      splstatclock(void)      { return 0; }
  284 static __inline intrmask_t      spltty(void)            { return 0; }
  285 static __inline intrmask_t      splvm(void)             { return 0; }
  286 static __inline void            splx(intrmask_t ipl __unused)   { return; }
  287 
  288 /*
  289  * Various callout lists.
  290  */
  291 
  292 /*
  293  * Not exactly a callout LIST, but a callout entry.
  294  * Allow an external module to define a hardware watchdog tickler.
  295  * Normally a process would do this, but there are times when the
  296  * kernel needs to be able to hold off the watchdog, when the process
  297  * is not active, e.g., when dumping core.
  298  */
  299 typedef void (*watchdog_tickle_fn)(void);
  300 
  301 extern watchdog_tickle_fn       wdog_tickler;
  302 
  303 /*
  304  * Common `proc' functions are declared here so that proc.h can be included
  305  * less often.
  306  */
  307 int     msleep(void *chan, struct mtx *mtx, int pri, const char *wmesg,
  308             int timo);
  309 #define tsleep(chan, pri, wmesg, timo)  msleep(chan, NULL, pri, wmesg, timo)
  310 void    wakeup(void *chan) __nonnull(1);
  311 void    wakeup_one(void *chan) __nonnull(1);
  312 
  313 /*
  314  * Common `struct cdev *' stuff are declared here to avoid #include poisoning
  315  */
  316 
  317 int major(struct cdev *x);
  318 int minor(struct cdev *x);
  319 dev_t dev2udev(struct cdev *x);
  320 struct cdev *findcdev(dev_t x);
  321 int uminor(dev_t dev);
  322 int umajor(dev_t dev);
  323 
  324 /* XXX: Should be void nanodelay(u_int nsec); */
  325 void    DELAY(int usec);
  326 
  327 /*
  328  * Unit number allocation API. (kern/subr_unit.c)
  329  */
  330 struct unrhdr;
  331 struct unrhdr *new_unrhdr(int low, int high, struct mtx *mutex);
  332 void delete_unrhdr(struct unrhdr *uh);
  333 int alloc_unr(struct unrhdr *uh);
  334 int alloc_unrl(struct unrhdr *uh);
  335 void free_unr(struct unrhdr *uh, u_int item);
  336 
  337 #endif /* !_SYS_SYSTM_H_ */

Cache object: 19fadd0dc1f3037e08ec5a4e3013cadb


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