]>
git.saurik.com Git - apple/xnu.git/blob - bsd/sys/systm.h
   2  * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved. 
   4  * @APPLE_LICENSE_HEADER_START@ 
   6  * The contents of this file constitute Original Code as defined in and 
   7  * are subject to the Apple Public Source License Version 1.1 (the 
   8  * "License").  You may not use this file except in compliance with the 
   9  * License.  Please obtain a copy of the License at 
  10  * http://www.apple.com/publicsource and read it before using this file. 
  12  * This Original Code and all software distributed under the License are 
  13  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER 
  14  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 
  15  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 
  16  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the 
  17  * License for the specific language governing rights and limitations 
  20  * @APPLE_LICENSE_HEADER_END@ 
  22 /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */ 
  24  * Copyright (c) 1982, 1988, 1991, 1993 
  25  *      The Regents of the University of California.  All rights reserved. 
  26  * (c) UNIX System Laboratories, Inc. 
  27  * All or some portions of this file are derived from material licensed 
  28  * to the University of California by American Telephone and Telegraph 
  29  * Co. or Unix System Laboratories, Inc. and are reproduced herein with 
  30  * the permission of UNIX System Laboratories, Inc. 
  32  * Redistribution and use in source and binary forms, with or without 
  33  * modification, are permitted provided that the following conditions 
  35  * 1. Redistributions of source code must retain the above copyright 
  36  *    notice, this list of conditions and the following disclaimer. 
  37  * 2. Redistributions in binary form must reproduce the above copyright 
  38  *    notice, this list of conditions and the following disclaimer in the 
  39  *    documentation and/or other materials provided with the distribution. 
  40  * 3. All advertising materials mentioning features or use of this software 
  41  *    must display the following acknowledgement: 
  42  *      This product includes software developed by the University of 
  43  *      California, Berkeley and its contributors. 
  44  * 4. Neither the name of the University nor the names of its contributors 
  45  *    may be used to endorse or promote products derived from this software 
  46  *    without specific prior written permission. 
  48  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 
  49  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
  50  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
  51  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 
  52  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
  53  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
  54  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
  55  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
  56  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
  57  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
  60  *      @(#)systm.h     8.7 (Berkeley) 3/29/95 
  64  * The `securelevel' variable controls the security level of the system. 
  65  * It can only be decreased by process 1 (/sbin/init). 
  67  * Security levels are as follows: 
  68  *   -1 permannently insecure mode - always run system in level 0 mode. 
  69  *    0 insecure mode - immutable and append-only flags make be turned off. 
  70  *      All devices may be read or written subject to permission modes. 
  71  *    1 secure mode - immutable and append-only flags may not be changed; 
  72  *      raw disks of mounted filesystems, /dev/mem, and /dev/kmem are 
  74  *    2 highly secure mode - same as (1) plus raw disks are always 
  75  *      read-only whether mounted or not. This level precludes tampering  
  76  *      with filesystems by unmounting them, but also inhibits running 
  77  *      newfs while the system is secured. 
  79  * In normal operation, the system runs in level 0 mode while single user 
  80  * and in level 1 mode while multiuser. If level 2 mode is desired while 
  81  * running multiuser, it can be set in the multiuser startup script 
  82  * (/etc/rc.local) using sysctl(1). If it is desired to run the system 
  83  * in level 0 mode while multiuser, initialize the variable securelevel 
  84  * in /sys/kern/kern_sysctl.c to -1. Note that it is NOT initialized to 
  85  * zero as that would allow the vmunix binary to be patched to -1. 
  86  * Without initialization, securelevel loads in the BSS area which only 
  87  * comes into existence when the kernel is loaded and hence cannot be 
  88  * patched by a stalking hacker. 
  94 #include <sys/appleapiopts.h> 
  95 #include <sys/cdefs.h> 
  96 #include <sys/types.h> 
 100 #include <sys/proc.h> 
 101 #include <sys/linker_set.h> 
 103 #include <kern/thread.h> 
 106 #ifdef __APPLE_API_PRIVATE 
 107 extern int securelevel
;         /* system security level */ 
 108 extern const char *panicstr
;    /* panic message */ 
 109 extern char version
[];          /* system version */ 
 110 extern char copyright
[];        /* system copyright */ 
 113 extern struct sysent 
{          /* system call table */ 
 114         int16_t         sy_narg
;        /* number of args */ 
 115         int8_t          sy_parallel
;/* can execute in parallel */ 
 116         int8_t          sy_funnel
;      /* funnel type */ 
 117         int32_t         (*sy_call
)();   /* implementing function */ 
 121 extern int      boothowto
;      /* reboot flags, from console subsystem */ 
 122 extern int      show_space
; 
 124 extern int nblkdev
;             /* number of entries in bdevsw */ 
 125 extern int nchrdev
;             /* number of entries in cdevsw */ 
 126 extern dev_t rootdev
;           /* root device */ 
 127 extern struct vnode 
*rootvp
;    /* vnode equivalent to above */ 
 128 #endif /* __APPLE_API_PRIVATE */ 
 130 #ifdef __APPLE_API_UNSTABLE 
 132 #define KERNEL_FUNNEL 1 
 133 #define NETWORK_FUNNEL 2 
 135 extern funnel_t 
* kernel_flock
; 
 136 extern funnel_t 
* network_flock
; 
 137 #endif /* __APPLE_API_UNSTABLE */ 
 139 #define SYSINIT(a,b,c,d,e) 
 140 #define MALLOC_DEFINE(a,b,c) 
 142 #define getenv_int(a,b) (*b = 0) 
 143 #define KASSERT(exp,msg) 
 146  * General function declarations. 
 149 int     nullop 
__P((void)); 
 150 int     enodev ();              /* avoid actual prototype for multiple use */ 
 153 int     enoioctl 
__P((void)); 
 154 int     enxio 
__P((void)); 
 155 int     eopnotsupp 
__P((void)); 
 156 int     einval 
__P((void)); 
 158 #ifdef __APPLE_API_UNSTABLE 
 159 int     seltrue 
__P((dev_t dev
, int which
, struct proc 
*p
)); 
 160 #endif /* __APPLE_API_UNSTABLE */ 
 162 void    *hashinit 
__P((int count
, int type
, u_long 
*hashmask
)); 
 163 int     nosys 
__P((struct proc 
*, void *, register_t 
*)); 
 166 volatile void   panic 
__P((const char *, ...)); 
 168 void    panic 
__P((const char *, ...)); 
 170 void    tablefull 
__P((const char *)); 
 171 void    log 
__P((int, const char *, ...)); 
 172 void    kprintf 
__P((const char *, ...)); 
 173 void    ttyprintf 
__P((struct tty 
*, const char *, ...)); 
 175 int     kvprintf 
__P((char const *, void (*)(int, void*), void *, int, 
 178 int     snprintf 
__P((char *, size_t, const char *, ...)); 
 179 int     sprintf 
__P((char *buf
, const char *, ...)); 
 180 void    uprintf 
__P((const char *, ...)); 
 181 void    vprintf 
__P((const char *, _BSD_VA_LIST_
)); 
 182 int     vsnprintf 
__P((char *, size_t, const char *, _BSD_VA_LIST_
)); 
 183 int     vsprintf 
__P((char *buf
, const char *, _BSD_VA_LIST_
)); 
 185 void    bcopy 
__P((const void *from
, void *to
, size_t len
)); 
 186 void    ovbcopy 
__P((const void *from
, void *to
, size_t len
)); 
 187 void    bzero 
__P((void *buf
, size_t len
)); 
 189 int     copystr 
__P((void *kfaddr
, void *kdaddr
, size_t len
, size_t *done
)); 
 190 int     copyinstr 
__P((void *udaddr
, void *kaddr
, size_t len
, size_t *done
)); 
 191 int     copyoutstr 
__P((void *kaddr
, void *udaddr
, size_t len
, size_t *done
)); 
 192 int     copyin 
__P((void *udaddr
, void *kaddr
, size_t len
)); 
 193 int     copyout 
__P((void *kaddr
, void *udaddr
, size_t len
)); 
 194 int     copywithin 
__P((void *saddr
, void *daddr
, size_t len
)); 
 196 int     fubyte 
__P((void *base
)); 
 198 int     fuibyte 
__P((void *base
)); 
 200 int     subyte 
__P((void *base
, int byte
)); 
 201 int     suibyte 
__P((void *base
, int byte
)); 
 202 long    fuword 
__P((void *base
)); 
 203 long    fuiword 
__P((void *base
)); 
 204 int     suword 
__P((void *base
, long word
)); 
 205 int     suiword 
__P((void *base
, long word
)); 
 207 #ifdef __APPLE_API_UNSTABLE 
 208 int     hzto 
__P((struct timeval 
*tv
)); 
 209 typedef void (*timeout_fcn_t
)(void *); 
 210 void    timeout 
__P((void (*)(void *), void *arg
, int ticks
)); 
 211 void    untimeout 
__P((void (*)(void *), void *arg
)); 
 212 void    realitexpire 
__P((void *)); 
 213 #endif /* __APPLE_API_UNSTABLE */ 
 215 #ifdef __APPLE_API_PRIVATE 
 216 void    bsd_hardclock 
__P((boolean_t usermode
, caddr_t pc
, int numticks
)); 
 217 void    gatherstats 
__P((boolean_t usermode
, caddr_t pc
)); 
 219 void    initclocks 
__P((void)); 
 221 void    startprofclock 
__P((struct proc 
*)); 
 222 void    stopprofclock 
__P((struct proc 
*)); 
 223 void    setstatclockrate 
__P((int hzrate
)); 
 225 /* debugger entry points */ 
 226 int     Debugger 
__P((void));   /* in DDB only */ 
 229 void    set_fsblocksize 
__P((struct vnode 
*)); 
 230 #endif /* __APPLE_API_PRIVATE */ 
 232 void addlog 
__P((const char *, ...)); 
 233 void printf 
__P((const char *, ...)); 
 235 extern boolean_t    
thread_funnel_switch(int oldfnl
, int newfnl
); 
 237 #include <libkern/libkern.h> 
 241 #endif /* !_SYS_SYSTM_H_ */