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.301 2021/06/16 11:55:10 rin 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 #ifndef _SYS_SYSTM_H_
   40 #define _SYS_SYSTM_H_
   41 
   42 #if defined(_KERNEL_OPT)
   43 #include "opt_ddb.h"
   44 #include "opt_multiprocessor.h"
   45 #include "opt_gprof.h"
   46 #include "opt_kasan.h"
   47 #include "opt_kcsan.h"
   48 #include "opt_kmsan.h"
   49 #include "opt_modular.h"
   50 #include "opt_wsdisplay_compat.h"
   51 #endif
   52 #if !defined(_KERNEL) && !defined(_STANDALONE)
   53 #include <stdbool.h>
   54 #endif
   55 
   56 #include <machine/endian.h>
   57 
   58 #include <sys/types.h>
   59 #include <sys/stdarg.h>
   60 
   61 #include <sys/device_if.h>
   62 
   63 struct clockframe;
   64 struct lwp;
   65 struct proc;
   66 struct sysent;
   67 struct timeval;
   68 struct tty;
   69 struct uio;
   70 struct vnode;
   71 struct vmspace;
   72 
   73 extern const char *panicstr;    /* panic message */
   74 extern int doing_shutdown;      /* shutting down */
   75 
   76 extern const char copyright[];  /* system copyright */
   77 extern char machine[];          /* machine type */
   78 extern char machine_arch[];     /* machine architecture */
   79 extern const char osrelease[];  /* short system version */
   80 extern const char ostype[];     /* system type */
   81 extern const char kernel_ident[];/* kernel configuration ID */
   82 extern const char version[];    /* system version */
   83 extern const char buildinfo[];  /* information from build environment */
   84 
   85 extern int autonicetime;        /* time (in seconds) before autoniceval */
   86 extern int autoniceval;         /* proc priority after autonicetime */
   87 
   88 extern int selwait;             /* select timeout address */
   89 
   90 extern int maxmem;              /* max memory per process */
   91 extern psize_t physmem;         /* physical memory */
   92 
   93 extern dev_t dumpdev;           /* dump device */
   94 extern dev_t dumpcdev;          /* dump device (character equivalent) */
   95 extern long dumplo;             /* offset into dumpdev */
   96 extern int dumpsize;            /* size of dump in pages */
   97 extern const char *dumpspec;    /* how dump device was specified */
   98 
   99 extern dev_t rootdev;           /* root device */
  100 extern struct vnode *rootvp;    /* vnode equivalent to above */
  101 extern device_t root_device; /* device equivalent to above */
  102 extern const char *rootspec;    /* how root device was specified */
  103 
  104 extern int ncpu;                /* number of CPUs configured */
  105 extern int ncpuonline;          /* number of CPUs online */
  106 #if defined(_KERNEL)
  107 extern bool mp_online;          /* secondary processors are started */
  108 #endif /* defined(_KERNEL) */
  109 
  110 extern const char hexdigits[];  /* "0123456789abcdef" in subr_prf.c */
  111 extern const char HEXDIGITS[];  /* "0123456789ABCDEF" in subr_prf.c */
  112 
  113 /*
  114  * These represent the swap pseudo-device (`sw').  This device
  115  * is used by the swap pager to indirect through the routines
  116  * in sys/vm/vm_swap.c.
  117  */
  118 extern const dev_t swapdev;     /* swapping device */
  119 extern struct vnode *swapdev_vp;/* vnode equivalent to above */
  120 
  121 extern const dev_t zerodev;     /* /dev/zero */
  122 
  123 #if defined(_KERNEL)
  124 typedef int     sy_call_t(struct lwp *, const void *, register_t *);
  125 
  126 extern struct sysent {          /* system call table */
  127         short   sy_narg;        /* number of args */
  128         short   sy_argsize;     /* total size of arguments */
  129         int     sy_flags;       /* flags. see below */
  130         sy_call_t *sy_call;     /* implementing function */
  131         uint32_t sy_entry;      /* DTrace entry ID for systrace. */
  132         uint32_t sy_return;     /* DTrace return ID for systrace. */
  133 } sysent[];
  134 extern int nsysent;
  135 extern const uint32_t sysent_nomodbits[];
  136 #endif
  137 
  138 #if     BYTE_ORDER == BIG_ENDIAN
  139 #define SCARG(p,k)      ((p)->k.be.datum)       /* get arg from args pointer */
  140 #elif   BYTE_ORDER == LITTLE_ENDIAN
  141 #define SCARG(p,k)      ((p)->k.le.datum)       /* get arg from args pointer */
  142 #else
  143 #error  "what byte order is this machine?"
  144 #endif
  145 
  146 #define SYCALL_INDIRECT 0x0000002 /* indirect (ie syscall() or __syscall()) */
  147 #define SYCALL_NARGS64_MASK     0x000f000 /* count of 64bit args */
  148 #define SYCALL_RET_64   0x0010000 /* retval is a 64bit integer value */
  149 #define SYCALL_ARG0_64  0x0020000
  150 #define SYCALL_ARG1_64  0x0040000
  151 #define SYCALL_ARG2_64  0x0080000
  152 #define SYCALL_ARG3_64  0x0100000
  153 #define SYCALL_ARG4_64  0x0200000
  154 #define SYCALL_ARG5_64  0x0400000
  155 #define SYCALL_ARG6_64  0x0800000
  156 #define SYCALL_ARG7_64  0x1000000
  157 #define SYCALL_NOSYS    0x2000000 /* permanent nosys in sysent[] */
  158 #define SYCALL_ARG_PTR  0x4000000 /* at least one argument is a pointer */
  159 #define SYCALL_RET_64_P(sy)     ((sy)->sy_flags & SYCALL_RET_64)
  160 #define SYCALL_ARG_64_P(sy, n)  ((sy)->sy_flags & (SYCALL_ARG0_64 << (n)))
  161 #define SYCALL_ARG_64_MASK(sy)  (((sy)->sy_flags >> 17) & 0xff)
  162 #define SYCALL_ARG_PTR_P(sy)    ((sy)->sy_flags & SYCALL_ARG_PTR)
  163 #define SYCALL_NARGS64(sy)      (((sy)->sy_flags >> 12) & 0x0f)
  164 #define SYCALL_NARGS64_VAL(n)   ((n) << 12)
  165 
  166 extern int boothowto;           /* reboot flags, from console subsystem */
  167 #define bootverbose     (boothowto & AB_VERBOSE)
  168 #define bootquiet       (boothowto & AB_QUIET)
  169 
  170 extern const char *get_booted_kernel(void);
  171 
  172 extern void (*v_putc)(int); /* Virtual console putc routine */
  173 
  174 /*
  175  * General function declarations.
  176  */
  177 void    voidop(void);
  178 int     nullop(void *);
  179 void*   nullret(void);
  180 int     enodev(void);
  181 int     enosys(void);
  182 int     enoioctl(void);
  183 int     enxio(void);
  184 int     eopnotsupp(void);
  185 
  186 enum hashtype {
  187         HASH_LIST,
  188         HASH_SLIST,
  189         HASH_TAILQ,
  190         HASH_PSLIST
  191 };
  192 
  193 #ifdef _KERNEL
  194 #define COND_SET_STRUCT(dst, src, allow) \
  195         do { \
  196                 /* \
  197                  * Make sure we don't end up hashing/assigning large \
  198                  * structure for performance. Upper-bound is arbitrary, \
  199                  * but consider before bumping. \
  200                  */ \
  201                 CTASSERT(sizeof(src) < 32); \
  202                 if (allow) \
  203                         dst = src; \
  204                 else \
  205                         hash_value(&dst, sizeof(dst), &src, sizeof(src)); \
  206         } while (/*CONSTCOND*/0)
  207 
  208 #define COND_SET_CPTR(dst, src, allow) \
  209         do { \
  210                 if (allow) \
  211                         dst = src; \
  212                 else { \
  213                         void *__v; \
  214                         hash_value(&__v, sizeof(__v), &src, sizeof(src)); \
  215                         dst = __v; \
  216                 } \
  217         } while (/*CONSTCOND*/0)
  218 
  219 #define COND_SET_PTR(dst, src, allow) \
  220         do { \
  221                 if (allow) \
  222                         dst = src; \
  223                 else \
  224                         hash_value(&dst, sizeof(dst), &src, sizeof(src)); \
  225         } while (/*CONSTCOND*/0)
  226 
  227 #define COND_SET_VALUE(dst, src, allow) \
  228         do { \
  229                 if (allow) \
  230                         dst = src; \
  231                 else { \
  232                         uint64_t __v = src; \
  233                         hash_value(&dst, sizeof(dst), &__v, sizeof(__v)); \
  234                 } \
  235         } while (/*CONSTCOND*/0)
  236 
  237 void    hash_value(void *, size_t, const void *, size_t);
  238 bool    get_expose_address(struct proc *);
  239 void    *hashinit(u_int, enum hashtype, bool, u_long *);
  240 void    hashdone(void *, enum hashtype, u_long);
  241 int     seltrue(dev_t, int, struct lwp *);
  242 int     sys_nosys(struct lwp *, const void *, register_t *);
  243 int     sys_nomodule(struct lwp *, const void *, register_t *);
  244 
  245 void    aprint_normal(const char *, ...) __printflike(1, 2);
  246 void    aprint_error(const char *, ...) __printflike(1, 2);
  247 void    aprint_naive(const char *, ...) __printflike(1, 2);
  248 void    aprint_verbose(const char *, ...) __printflike(1, 2);
  249 void    aprint_debug(const char *, ...) __printflike(1, 2);
  250 
  251 void    aprint_normal_dev(device_t, const char *, ...) __printflike(2, 3);
  252 void    aprint_error_dev(device_t, const char *, ...) __printflike(2, 3);
  253 void    aprint_naive_dev(device_t, const char *, ...) __printflike(2, 3);
  254 void    aprint_verbose_dev(device_t, const char *, ...) __printflike(2, 3);
  255 void    aprint_debug_dev(device_t, const char *, ...) __printflike(2, 3);
  256 
  257 void    device_printf(device_t, const char *fmt, ...) __printflike(2, 3);
  258 
  259 struct ifnet;
  260 
  261 void    aprint_normal_ifnet(struct ifnet *, const char *, ...)
  262     __printflike(2, 3);
  263 void    aprint_error_ifnet(struct ifnet *, const char *, ...)
  264     __printflike(2, 3);
  265 void    aprint_naive_ifnet(struct ifnet *, const char *, ...)
  266     __printflike(2, 3);
  267 void    aprint_verbose_ifnet(struct ifnet *, const char *, ...)
  268     __printflike(2, 3);
  269 void    aprint_debug_ifnet(struct ifnet *, const char *, ...)
  270     __printflike(2, 3);
  271 
  272 int     aprint_get_error_count(void);
  273 
  274 void    printf_tolog(const char *, ...) __printflike(1, 2);
  275 
  276 void    printf_nolog(const char *, ...) __printflike(1, 2);
  277 
  278 void    printf_nostamp(const char *, ...) __printflike(1, 2);
  279 
  280 void    printf(const char *, ...) __printflike(1, 2);
  281 
  282 int     snprintf(char *, size_t, const char *, ...) __printflike(3, 4);
  283 
  284 int     vasprintf(char **, const char *, va_list) __printflike(2, 0);
  285 
  286 void    vprintf(const char *, va_list) __printflike(1, 0);
  287 
  288 int     vsnprintf(char *, size_t, const char *, va_list) __printflike(3, 0);
  289 
  290 void    vprintf_flags(int, const char *, va_list) __printflike(2, 0);
  291 
  292 void    printf_flags(int, const char *, ...) __printflike(2, 3);
  293 
  294 int     humanize_number(char *, size_t, uint64_t, const char *, int);
  295 
  296 void    twiddle(void);
  297 void    banner(void);
  298 #endif /* _KERNEL */
  299 
  300 void    panic(const char *, ...) __dead __printflike(1, 2);
  301 void    vpanic(const char *, va_list) __dead __printflike(1, 0);
  302 void    uprintf(const char *, ...) __printflike(1, 2);
  303 void    uprintf_locked(const char *, ...) __printflike(1, 2);
  304 void    ttyprintf(struct tty *, const char *, ...) __printflike(2, 3);
  305 
  306 int     format_bytes(char *, size_t, uint64_t);
  307 
  308 void    tablefull(const char *, const char *);
  309 
  310 #if defined(_KERNEL) && defined(KASAN)
  311 int     kasan_kcopy(const void *, void *, size_t);
  312 #define kcopy           kasan_kcopy
  313 #elif defined(_KERNEL) && defined(KCSAN)
  314 int     kcsan_kcopy(const void *, void *, size_t);
  315 #define kcopy           kcsan_kcopy
  316 #elif defined(_KERNEL) && defined(KMSAN)
  317 int     kmsan_kcopy(const void *, void *, size_t);
  318 #define kcopy           kmsan_kcopy
  319 #else
  320 int     kcopy(const void *, void *, size_t);
  321 #endif
  322 
  323 #ifdef _KERNEL
  324 #define bcopy(src, dst, len)    memcpy((dst), (src), (len))
  325 #define bzero(src, len)         memset((src), 0, (len))
  326 #define bcmp(a, b, len)         memcmp((a), (b), (len))
  327 #endif /* KERNEL */
  328 
  329 int     copystr(const void *, void *, size_t, size_t *);
  330 #if defined(_KERNEL) && defined(KASAN)
  331 int     kasan_copyinstr(const void *, void *, size_t, size_t *);
  332 int     kasan_copyoutstr(const void *, void *, size_t, size_t *);
  333 int     kasan_copyin(const void *, void *, size_t);
  334 int     copyout(const void *, void *, size_t);
  335 #define copyinstr       kasan_copyinstr
  336 #define copyoutstr      kasan_copyoutstr
  337 #define copyin          kasan_copyin
  338 #elif defined(_KERNEL) && defined(KCSAN)
  339 int     kcsan_copyinstr(const void *, void *, size_t, size_t *);
  340 int     kcsan_copyoutstr(const void *, void *, size_t, size_t *);
  341 int     kcsan_copyin(const void *, void *, size_t);
  342 int     kcsan_copyout(const void *, void *, size_t);
  343 #define copyinstr       kcsan_copyinstr
  344 #define copyoutstr      kcsan_copyoutstr
  345 #define copyin          kcsan_copyin
  346 #define copyout         kcsan_copyout
  347 #elif defined(_KERNEL) && defined(KMSAN)
  348 int     kmsan_copyinstr(const void *, void *, size_t, size_t *);
  349 int     kmsan_copyoutstr(const void *, void *, size_t, size_t *);
  350 int     kmsan_copyin(const void *, void *, size_t);
  351 int     kmsan_copyout(const void *, void *, size_t);
  352 #define copyinstr       kmsan_copyinstr
  353 #define copyoutstr      kmsan_copyoutstr
  354 #define copyin          kmsan_copyin
  355 #define copyout         kmsan_copyout
  356 #else
  357 int     copyinstr(const void *, void *, size_t, size_t *);
  358 int     copyoutstr(const void *, void *, size_t, size_t *);
  359 int     copyin(const void *, void *, size_t);
  360 int     copyout(const void *, void *, size_t);
  361 #endif
  362 
  363 #ifdef _KERNEL
  364 typedef int     (*copyin_t)(const void *, void *, size_t);
  365 typedef int     (*copyout_t)(const void *, void *, size_t);
  366 #endif
  367 
  368 int     copyin_proc(struct proc *, const void *, void *, size_t);
  369 int     copyout_proc(struct proc *, const void *, void *, size_t);
  370 int     copyin_pid(pid_t, const void *, void *, size_t);
  371 int     copyin_vmspace(struct vmspace *, const void *, void *, size_t);
  372 int     copyout_vmspace(struct vmspace *, const void *, void *, size_t);
  373 
  374 int     ioctl_copyin(int ioctlflags, const void *src, void *dst, size_t len);
  375 int     ioctl_copyout(int ioctlflags, const void *src, void *dst, size_t len);
  376 
  377 int     ucas_32(volatile uint32_t *, uint32_t, uint32_t, uint32_t *);
  378 #ifdef _LP64
  379 int     ucas_64(volatile uint64_t *, uint64_t, uint64_t, uint64_t *);
  380 #endif
  381 int     ucas_ptr(volatile void *, void *, void *, void *);
  382 int     ucas_int(volatile unsigned int *, unsigned int, unsigned int,
  383                  unsigned int *);
  384 int     ufetch_8(const uint8_t *, uint8_t *);
  385 int     ufetch_16(const uint16_t *, uint16_t *);
  386 int     ufetch_32(const uint32_t *, uint32_t *);
  387 #ifdef _LP64
  388 int     ufetch_64(const uint64_t *, uint64_t *);
  389 #endif
  390 int     ufetch_char(const unsigned char *, unsigned char *);
  391 int     ufetch_short(const unsigned short *, unsigned short *);
  392 int     ufetch_int(const unsigned int *, unsigned int *);
  393 int     ufetch_long(const unsigned long *, unsigned long *);
  394 int     ufetch_ptr(const void **, void **);
  395 int     ustore_8(uint8_t *, uint8_t);
  396 int     ustore_16(uint16_t *, uint16_t);
  397 int     ustore_32(uint32_t *, uint32_t);
  398 #ifdef _LP64
  399 int     ustore_64(uint64_t *, uint64_t);
  400 #endif
  401 int     ustore_char(unsigned char *, unsigned char);
  402 int     ustore_short(unsigned short *, unsigned short);
  403 int     ustore_int(unsigned int *, unsigned int);
  404 int     ustore_long(unsigned long *, unsigned long);
  405 int     ustore_ptr(void **, void *);
  406 
  407 #ifdef __UCAS_PRIVATE
  408 
  409 #if defined(__HAVE_UCAS_FULL) && defined(KASAN)
  410 int     kasan__ucas_32(volatile uint32_t *, uint32_t, uint32_t, uint32_t *);
  411 #ifdef __HAVE_UCAS_MP
  412 int     kasan__ucas_32_mp(volatile uint32_t *, uint32_t, uint32_t, uint32_t *);
  413 #endif /* __HAVE_UCAS_MP */
  414 #ifdef _LP64
  415 int     kasan__ucas_64(volatile uint64_t *, uint64_t, uint64_t, uint64_t *);
  416 #ifdef __HAVE_UCAS_MP
  417 int     kasan__ucas_64_mp(volatile uint64_t *, uint64_t, uint64_t, uint64_t *);
  418 #endif /* __HAVE_UCAS_MP */
  419 #endif /* _LP64 */
  420 #define _ucas_32        kasan__ucas_32
  421 #define _ucas_32_mp     kasan__ucas_32_mp
  422 #define _ucas_64        kasan__ucas_64
  423 #define _ucas_64_mp     kasan__ucas_64_mp
  424 #elif defined(__HAVE_UCAS_FULL) && defined(KMSAN)
  425 int     kmsan__ucas_32(volatile uint32_t *, uint32_t, uint32_t, uint32_t *);
  426 #ifdef __HAVE_UCAS_MP
  427 int     kmsan__ucas_32_mp(volatile uint32_t *, uint32_t, uint32_t, uint32_t *);
  428 #endif /* __HAVE_UCAS_MP */
  429 #ifdef _LP64
  430 int     kmsan__ucas_64(volatile uint64_t *, uint64_t, uint64_t, uint64_t *);
  431 #ifdef __HAVE_UCAS_MP
  432 int     kmsan__ucas_64_mp(volatile uint64_t *, uint64_t, uint64_t, uint64_t *);
  433 #endif /* __HAVE_UCAS_MP */
  434 #endif /* _LP64 */
  435 #define _ucas_32        kmsan__ucas_32
  436 #define _ucas_32_mp     kmsan__ucas_32_mp
  437 #define _ucas_64        kmsan__ucas_64
  438 #define _ucas_64_mp     kmsan__ucas_64_mp
  439 #else
  440 int     _ucas_32(volatile uint32_t *, uint32_t, uint32_t, uint32_t *);
  441 #ifdef __HAVE_UCAS_MP
  442 int     _ucas_32_mp(volatile uint32_t *, uint32_t, uint32_t, uint32_t *);
  443 #endif /* __HAVE_UCAS_MP */
  444 #ifdef _LP64
  445 int     _ucas_64(volatile uint64_t *, uint64_t, uint64_t, uint64_t *);
  446 #ifdef __HAVE_UCAS_MP
  447 int     _ucas_64_mp(volatile uint64_t *, uint64_t, uint64_t, uint64_t *);
  448 #endif /* __HAVE_UCAS_MP */
  449 #endif /* _LP64 */
  450 #endif
  451 
  452 #endif /* __UCAS_PRIVATE */
  453 
  454 #ifdef __UFETCHSTORE_PRIVATE
  455 
  456 #if defined(KASAN)
  457 int     kasan__ufetch_8(const uint8_t *, uint8_t *);
  458 int     kasan__ufetch_16(const uint16_t *, uint16_t *);
  459 int     kasan__ufetch_32(const uint32_t *, uint32_t *);
  460 #ifdef _LP64
  461 int     kasan__ufetch_64(const uint64_t *, uint64_t *);
  462 #endif
  463 int     _ustore_8(uint8_t *, uint8_t);
  464 int     _ustore_16(uint16_t *, uint16_t);
  465 int     _ustore_32(uint32_t *, uint32_t);
  466 #ifdef _LP64
  467 int     _ustore_64(uint64_t *, uint64_t);
  468 #endif
  469 #define _ufetch_8       kasan__ufetch_8
  470 #define _ufetch_16      kasan__ufetch_16
  471 #define _ufetch_32      kasan__ufetch_32
  472 #define _ufetch_64      kasan__ufetch_64
  473 #elif defined(KMSAN)
  474 int     kmsan__ufetch_8(const uint8_t *, uint8_t *);
  475 int     kmsan__ufetch_16(const uint16_t *, uint16_t *);
  476 int     kmsan__ufetch_32(const uint32_t *, uint32_t *);
  477 #ifdef _LP64
  478 int     kmsan__ufetch_64(const uint64_t *, uint64_t *);
  479 #endif
  480 int     kmsan__ustore_8(uint8_t *, uint8_t);
  481 int     kmsan__ustore_16(uint16_t *, uint16_t);
  482 int     kmsan__ustore_32(uint32_t *, uint32_t);
  483 #ifdef _LP64
  484 int     kmsan__ustore_64(uint64_t *, uint64_t);
  485 #endif
  486 #define _ufetch_8       kmsan__ufetch_8
  487 #define _ufetch_16      kmsan__ufetch_16
  488 #define _ufetch_32      kmsan__ufetch_32
  489 #define _ufetch_64      kmsan__ufetch_64
  490 #define _ustore_8       kmsan__ustore_8
  491 #define _ustore_16      kmsan__ustore_16
  492 #define _ustore_32      kmsan__ustore_32
  493 #define _ustore_64      kmsan__ustore_64
  494 #else
  495 int     _ufetch_8(const uint8_t *, uint8_t *);
  496 int     _ufetch_16(const uint16_t *, uint16_t *);
  497 int     _ufetch_32(const uint32_t *, uint32_t *);
  498 #ifdef _LP64
  499 int     _ufetch_64(const uint64_t *, uint64_t *);
  500 #endif
  501 int     _ustore_8(uint8_t *, uint8_t);
  502 int     _ustore_16(uint16_t *, uint16_t);
  503 int     _ustore_32(uint32_t *, uint32_t);
  504 #ifdef _LP64
  505 int     _ustore_64(uint64_t *, uint64_t);
  506 #endif
  507 #endif
  508 
  509 #endif /* __UFETCHSTORE_PRIVATE */
  510 
  511 void    hardclock(struct clockframe *);
  512 void    softclock(void *);
  513 void    statclock(struct clockframe *);
  514 
  515 #ifdef NTP
  516 void    ntp_init(void);
  517 #ifdef PPS_SYNC
  518 struct timespec;
  519 void    hardpps(struct timespec *, long);
  520 #endif /* PPS_SYNC */
  521 #else
  522 void    ntp_init(void); /* also provides adjtime() functionality */
  523 #endif /* NTP */
  524 
  525 void    ssp_init(void);
  526 
  527 void    initclocks(void);
  528 void    inittodr(time_t);
  529 void    resettodr(void);
  530 void    cpu_initclocks(void);
  531 void    setrootfstime(time_t);
  532 
  533 void    startprofclock(struct proc *);
  534 void    stopprofclock(struct proc *);
  535 void    proftick(struct clockframe *);
  536 void    setstatclockrate(int);
  537 
  538 /*
  539  * Critical polling hooks.  Functions to be run while the kernel stays
  540  * elevated IPL for a "long" time.  (watchdogs).
  541  */
  542 void    *critpollhook_establish(void (*)(void *), void *);
  543 void    critpollhook_disestablish(void *);
  544 void    docritpollhooks(void);
  545 
  546 /*
  547  * Shutdown hooks.  Functions to be run with all interrupts disabled
  548  * immediately before the system is halted or rebooted.
  549  */
  550 void    *shutdownhook_establish(void (*)(void *), void *);
  551 void    shutdownhook_disestablish(void *);
  552 void    doshutdownhooks(void);
  553 
  554 /*
  555  * Power management hooks.
  556  */
  557 void    *powerhook_establish(const char *, void (*)(int, void *), void *);
  558 void    powerhook_disestablish(void *);
  559 void    dopowerhooks(int);
  560 #define PWR_RESUME      0
  561 #define PWR_SUSPEND     1
  562 #define PWR_STANDBY     2
  563 #define PWR_SOFTRESUME  3
  564 #define PWR_SOFTSUSPEND 4
  565 #define PWR_SOFTSTANDBY 5
  566 #define PWR_NAMES \
  567         "resume",       /* 0 */ \
  568         "suspend",      /* 1 */ \
  569         "standby",      /* 2 */ \
  570         "softresume",   /* 3 */ \
  571         "softsuspend",  /* 4 */ \
  572         "softstandby"   /* 5 */
  573 
  574 /*
  575  * Mountroot hooks (and mountroot declaration).  Device drivers establish
  576  * these to be executed just before (*mountroot)() if the passed device is
  577  * selected as the root device.
  578  */
  579 
  580 #define ROOT_FSTYPE_ANY "?"
  581 
  582 extern const char *rootfstype;
  583 void    *mountroothook_establish(void (*)(device_t), device_t);
  584 void    mountroothook_disestablish(void *);
  585 void    mountroothook_destroy(void);
  586 void    domountroothook(device_t);
  587 
  588 /*
  589  * Exec hooks. Subsystems may want to do cleanup when a process
  590  * execs.
  591  */
  592 void    *exechook_establish(void (*)(struct proc *, void *), void *);
  593 void    exechook_disestablish(void *);
  594 void    doexechooks(struct proc *);
  595 
  596 /*
  597  * Exit hooks. Subsystems may want to do cleanup when a process exits.
  598  */
  599 void    *exithook_establish(void (*)(struct proc *, void *), void *);
  600 void    exithook_disestablish(void *);
  601 void    doexithooks(struct proc *);
  602 
  603 /*
  604  * Fork hooks.  Subsystems may want to do special processing when a process
  605  * forks.
  606  */
  607 void    *forkhook_establish(void (*)(struct proc *, struct proc *));
  608 void    forkhook_disestablish(void *);
  609 void    doforkhooks(struct proc *, struct proc *);
  610 
  611 /*
  612  * kernel syscall tracing/debugging hooks.
  613  */
  614 #ifdef _KERNEL
  615 bool    trace_is_enabled(struct proc *);
  616 int     trace_enter(register_t, const struct sysent *, const void *);
  617 void    trace_exit(register_t, const struct sysent *, const void *,
  618     register_t [], int);
  619 #endif
  620 
  621 int     uiomove(void *, size_t, struct uio *);
  622 int     uiomove_frombuf(void *, size_t, struct uio *);
  623 
  624 #ifdef _KERNEL
  625 int     setjmp(label_t *) __returns_twice;
  626 void    longjmp(label_t *) __dead;
  627 #endif
  628 
  629 void    consinit(void);
  630 
  631 void    cpu_startup(void);
  632 void    cpu_configure(void);
  633 void    cpu_bootconf(void);
  634 void    cpu_rootconf(void);
  635 void    cpu_dumpconf(void);
  636 
  637 #ifdef GPROF
  638 void    kmstartup(void);
  639 #endif
  640 
  641 void    machdep_init(void);
  642 
  643 #ifdef _KERNEL
  644 #include <lib/libkern/libkern.h>
  645 
  646 /*
  647  * Stuff to handle debugger magic key sequences.
  648  */
  649 #define CNS_LEN                 128
  650 #define CNS_MAGIC_VAL(x)        ((x)&0x1ff)
  651 #define CNS_MAGIC_NEXT(x)       (((x)>>9)&0x7f)
  652 #define CNS_TERM                0x7f    /* End of sequence */
  653 
  654 typedef struct cnm_state {
  655         int     cnm_state;
  656         u_short *cnm_magic;
  657 } cnm_state_t;
  658 
  659 /* Override db_console() in MD headers */
  660 #ifndef cn_trap
  661 #define cn_trap()       console_debugger()
  662 #endif
  663 #ifndef cn_isconsole
  664 #ifndef WSDISPLAY_MULTICONS
  665 #define cn_isconsole(d) (cn_tab != NULL && (d) == cn_tab->cn_dev)
  666 #else
  667 bool wsdisplay_cn_isconsole(dev_t);
  668 #define cn_isconsole(d) wsdisplay_cn_isconsole(d)
  669 #endif
  670 #endif
  671 
  672 void cn_init_magic(cnm_state_t *);
  673 void cn_destroy_magic(cnm_state_t *);
  674 int cn_set_magic(const char *);
  675 int cn_get_magic(char *, size_t);
  676 /* This should be called for each byte read */
  677 #ifndef cn_check_magic
  678 #define cn_check_magic(d, k, s)                                         \
  679         do {                                                            \
  680                 if (cn_isconsole(d)) {                                  \
  681                         int _v = (s).cnm_magic[(s).cnm_state];          \
  682                         if ((k) == CNS_MAGIC_VAL(_v)) {                 \
  683                                 (s).cnm_state = CNS_MAGIC_NEXT(_v);     \
  684                                 if ((s).cnm_state == CNS_TERM) {        \
  685                                         cn_trap();                      \
  686                                         (s).cnm_state = 0;              \
  687                                 }                                       \
  688                         } else {                                        \
  689                                 (s).cnm_state = 0;                      \
  690                         }                                               \
  691                 }                                                       \
  692         } while (/* CONSTCOND */ 0)
  693 #endif
  694 
  695 /* Encode out-of-band events this way when passing to cn_check_magic() */
  696 #define CNC_BREAK               0x100
  697 
  698 #if defined(DDB) || defined(sun3) || defined(sun2)
  699 /* note that cpu_Debugger() is always available on sun[23] */
  700 void    cpu_Debugger(void);
  701 #define Debugger        cpu_Debugger
  702 #endif
  703 
  704 #ifdef DDB
  705 /*
  706  * Enter debugger(s) from console attention if enabled
  707  */
  708 extern int db_fromconsole; /* XXX ddb/ddbvar.h */
  709 #define console_debugger() if (db_fromconsole) Debugger()
  710 #elif defined(Debugger)
  711 #define console_debugger() Debugger()
  712 #else
  713 #define console_debugger() do {} while (/* CONSTCOND */ 0) /* NOP */
  714 #endif
  715 
  716 /* For SYSCALL_DEBUG */
  717 void scdebug_init(void);
  718 void scdebug_call(register_t, const register_t[]);
  719 void scdebug_ret(register_t, int, const register_t[]);
  720 
  721 void    kernel_lock_init(void);
  722 void    _kernel_lock(int);
  723 void    _kernel_unlock(int, int *);
  724 bool    _kernel_locked_p(void);
  725 
  726 void    kernconfig_lock_init(void);
  727 void    kernconfig_lock(void);
  728 void    kernconfig_unlock(void);
  729 bool    kernconfig_is_held(void);
  730 #endif
  731 
  732 #if defined(MULTIPROCESSOR) || defined(MODULAR) || defined(_MODULE)
  733 #define KERNEL_LOCK(count, lwp)                 \
  734 do {                                            \
  735         if ((count) != 0)                       \
  736                 _kernel_lock((count));  \
  737 } while (/* CONSTCOND */ 0)
  738 #define KERNEL_UNLOCK(all, lwp, p)      _kernel_unlock((all), (p))
  739 #define KERNEL_LOCKED_P()               _kernel_locked_p()
  740 #else
  741 #define KERNEL_LOCK(count, lwp)         do {(void)(count); (void)(lwp);} while (/* CONSTCOND */ 0) /*NOP*/
  742 #define KERNEL_UNLOCK(all, lwp, ptr)    do {(void)(all); (void)(lwp); (void)(ptr);} while (/* CONSTCOND */ 0) /*NOP*/
  743 #define KERNEL_LOCKED_P()               (true)
  744 #endif
  745 
  746 #define KERNEL_UNLOCK_LAST(l)           KERNEL_UNLOCK(-1, (l), NULL)
  747 #define KERNEL_UNLOCK_ALL(l, p)         KERNEL_UNLOCK(0, (l), (p))
  748 #define KERNEL_UNLOCK_ONE(l)            KERNEL_UNLOCK(1, (l), NULL)
  749 
  750 #ifdef _KERNEL
  751 /* Preemption control. */
  752 void    kpreempt_disable(void);
  753 void    kpreempt_enable(void);
  754 bool    kpreempt_disabled(void);
  755 
  756 vaddr_t calc_cache_size(vsize_t , int, int);
  757 #endif
  758 
  759 void assert_sleepable(void);
  760 #if defined(DEBUG)
  761 #define ASSERT_SLEEPABLE()      assert_sleepable()
  762 #else /* defined(DEBUG) */
  763 #define ASSERT_SLEEPABLE()      do {} while (0)
  764 #endif /* defined(DEBUG) */
  765 
  766 
  767 #endif  /* !_SYS_SYSTM_H_ */

Cache object: 66873133a597f565a267394811bee362


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