systm.h revision 7612
11541Srgrimes/*- 21541Srgrimes * Copyright (c) 1982, 1988, 1991, 1993 31541Srgrimes * The Regents of the University of California. All rights reserved. 41541Srgrimes * (c) UNIX System Laboratories, Inc. 51541Srgrimes * All or some portions of this file are derived from material licensed 61541Srgrimes * to the University of California by American Telephone and Telegraph 71541Srgrimes * Co. or Unix System Laboratories, Inc. and are reproduced herein with 81541Srgrimes * the permission of UNIX System Laboratories, Inc. 91541Srgrimes * 101541Srgrimes * Redistribution and use in source and binary forms, with or without 111541Srgrimes * modification, are permitted provided that the following conditions 121541Srgrimes * are met: 131541Srgrimes * 1. Redistributions of source code must retain the above copyright 141541Srgrimes * notice, this list of conditions and the following disclaimer. 151541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 161541Srgrimes * notice, this list of conditions and the following disclaimer in the 171541Srgrimes * documentation and/or other materials provided with the distribution. 181541Srgrimes * 3. All advertising materials mentioning features or use of this software 191541Srgrimes * must display the following acknowledgement: 201541Srgrimes * This product includes software developed by the University of 211541Srgrimes * California, Berkeley and its contributors. 221541Srgrimes * 4. Neither the name of the University nor the names of its contributors 231541Srgrimes * may be used to endorse or promote products derived from this software 241541Srgrimes * without specific prior written permission. 251541Srgrimes * 261541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 271541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 281541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 291541Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 301541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 311541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 321541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 331541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 341541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 351541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 361541Srgrimes * SUCH DAMAGE. 371541Srgrimes * 381541Srgrimes * @(#)systm.h 8.4 (Berkeley) 2/23/94 397612Sdg * $Id: systm.h,v 1.18 1995/04/01 20:19:00 joerg Exp $ 401541Srgrimes */ 411541Srgrimes 422165Spaul#ifndef _SYS_SYSTM_H_ 432865Sbde#define _SYS_SYSTM_H_ 442165Spaul 451549Srgrimes#include <machine/cpufunc.h> 467566Sjoerg#include <machine/stdarg.h> 471549Srgrimes 481541Srgrimes/* 491541Srgrimes * The `securelevel' variable controls the security level of the system. 501541Srgrimes * It can only be decreased by process 1 (/sbin/init). 511541Srgrimes * 521541Srgrimes * Security levels are as follows: 531541Srgrimes * -1 permannently insecure mode - always run system in level 0 mode. 541541Srgrimes * 0 insecure mode - immutable and append-only flags make be turned off. 551541Srgrimes * All devices may be read or written subject to permission modes. 561541Srgrimes * 1 secure mode - immutable and append-only flags may not be changed; 571541Srgrimes * raw disks of mounted filesystems, /dev/mem, and /dev/kmem are 581541Srgrimes * read-only. 591541Srgrimes * 2 highly secure mode - same as (1) plus raw disks are always 601541Srgrimes * read-only whether mounted or not. This level precludes tampering 611541Srgrimes * with filesystems by unmounting them, but also inhibits running 621541Srgrimes * newfs while the system is secured. 631541Srgrimes * 641541Srgrimes * In normal operation, the system runs in level 0 mode while single user 651541Srgrimes * and in level 1 mode while multiuser. If level 2 mode is desired while 661541Srgrimes * running multiuser, it can be set in the multiuser startup script 671541Srgrimes * (/etc/rc.local) using sysctl(1). If it is desired to run the system 681541Srgrimes * in level 0 mode while multiuser, initialize the variable securelevel 691541Srgrimes * in /sys/kern/kern_sysctl.c to -1. Note that it is NOT initialized to 701858Sdg * zero as that would allow the kernel binary to be patched to -1. 711541Srgrimes * Without initialization, securelevel loads in the BSS area which only 721541Srgrimes * comes into existence when the kernel is loaded and hence cannot be 731541Srgrimes * patched by a stalking hacker. 741541Srgrimes */ 751541Srgrimesextern int securelevel; /* system security level */ 767090Sbde 777090Sbdeextern int cold; /* nonzero if we are doing a cold boot */ 781541Srgrimesextern const char *panicstr; /* panic message */ 791541Srgrimesextern char version[]; /* system version */ 801541Srgrimesextern char copyright[]; /* system copyright */ 811541Srgrimes 821541Srgrimesextern int nblkdev; /* number of entries in bdevsw */ 831541Srgrimesextern int nchrdev; /* number of entries in cdevsw */ 841541Srgrimesextern int nswdev; /* number of swap devices */ 851541Srgrimesextern int nswap; /* size of swap space */ 861541Srgrimes 871541Srgrimesextern int selwait; /* select timeout address */ 881541Srgrimes 891541Srgrimesextern u_char curpriority; /* priority of current process */ 901541Srgrimes 911541Srgrimesextern int maxmem; /* max memory per process */ 921541Srgrimesextern int physmem; /* physical memory */ 931541Srgrimes 941541Srgrimesextern dev_t dumpdev; /* dump device */ 951541Srgrimesextern long dumplo; /* offset into dumpdev */ 961541Srgrimes 971541Srgrimesextern dev_t rootdev; /* root device */ 981541Srgrimesextern struct vnode *rootvp; /* vnode equivalent to above */ 991541Srgrimes 1001541Srgrimesextern dev_t swapdev; /* swapping device */ 1011541Srgrimesextern struct vnode *swapdev_vp;/* vnode equivalent to above */ 1021541Srgrimes 1031541Srgrimesextern int boothowto; /* reboot flags, from console subsystem */ 1041541Srgrimes 1051541Srgrimes/* 1061541Srgrimes * General function declarations. 1071541Srgrimes */ 1081541Srgrimesint nullop __P((void)); 1091541Srgrimesint enodev __P((void)); 1101541Srgrimesint enoioctl __P((void)); 1111541Srgrimesint enxio __P((void)); 1121541Srgrimesint eopnotsupp __P((void)); 1131541Srgrimesint seltrue __P((dev_t dev, int which, struct proc *p)); 1143304Sphkint ureadc __P((int, struct uio *)); 1151541Srgrimesvoid *hashinit __P((int count, int type, u_long *hashmask)); 1167612Sdgvoid *phashinit __P((int count, int type, u_long *nentries)); 1171541Srgrimes 1182059Sdg__dead void panic __P((const char *, ...)) __dead2; 1192059Sdg__dead void boot __P((int)) __dead2; 1201541Srgrimesvoid tablefull __P((const char *)); 1211541Srgrimesvoid addlog __P((const char *, ...)); 1221541Srgrimesvoid log __P((int, const char *, ...)); 1231541Srgrimesvoid printf __P((const char *, ...)); 1242112Swollmanvoid uprintf __P((const char *, ...)); 1251541Srgrimesint sprintf __P((char *buf, const char *, ...)); 1261541Srgrimesvoid ttyprintf __P((struct tty *, const char *, ...)); 1277566Sjoergvoid kprintf __P((const char *fmt, int flags, struct tty *tp, va_list ap)); 1281541Srgrimes 1291541Srgrimesvoid bcopy __P((const void *from, void *to, u_int len)); 1301541Srgrimesvoid ovbcopy __P((const void *from, void *to, u_int len)); 1312811Sbdevoid blkclr __P((void *buf, u_int len)); 1321541Srgrimesvoid bzero __P((void *buf, u_int len)); 1331541Srgrimes 1341541Srgrimesint copystr __P((void *kfaddr, void *kdaddr, u_int len, u_int *done)); 1351541Srgrimesint copyinstr __P((void *udaddr, void *kaddr, u_int len, u_int *done)); 1361541Srgrimesint copyoutstr __P((void *kaddr, void *udaddr, u_int len, u_int *done)); 1371541Srgrimesint copyin __P((void *udaddr, void *kaddr, u_int len)); 1381541Srgrimesint copyout __P((void *kaddr, void *udaddr, u_int len)); 1391541Srgrimes 1401541Srgrimesint fubyte __P((void *base)); 1411541Srgrimesint fuibyte __P((void *base)); 1421541Srgrimesint subyte __P((void *base, int byte)); 1431541Srgrimesint suibyte __P((void *base, int byte)); 1441541Srgrimesint fuword __P((void *base)); 1451541Srgrimesint fuiword __P((void *base)); 1461541Srgrimesint suword __P((void *base, int word)); 1476358Sphkint susword __P((void *base, int word)); 1481541Srgrimesint suiword __P((void *base, int word)); 1491541Srgrimes 1501541Srgrimesint hzto __P((struct timeval *tv)); 1511541Srgrimesvoid realitexpire __P((void *)); 1521541Srgrimes 1531541Srgrimesstruct clockframe; 1541541Srgrimesvoid hardclock __P((struct clockframe *frame)); 1551541Srgrimesvoid softclock __P((void)); 1561541Srgrimesvoid statclock __P((struct clockframe *frame)); 1571541Srgrimes 1581541Srgrimesvoid initclocks __P((void)); 1591541Srgrimes 1601541Srgrimesvoid startprofclock __P((struct proc *)); 1611541Srgrimesvoid stopprofclock __P((struct proc *)); 1621541Srgrimesvoid setstatclockrate __P((int hzrate)); 1631541Srgrimes 1643484Sphkvoid hardupdate __P((long)); 1657109Sphk#include <sys/libkern.h> 1662112Swollman 1672112Swollman/* Initialize the world */ 1682112Swollmanextern void consinit(void); 1692112Swollmanextern void kmeminit(void); 1702112Swollmanextern void cpu_startup(void); 1712112Swollmanextern void usrinfoinit(void); 1722112Swollmanextern void rqinit(void); 1732112Swollmanextern void vfsinit(void); 1742112Swollmanextern void mbinit(void); 1752112Swollmanextern void clist_init(void); 1762112Swollmanextern void ifinit(void); 1772112Swollmanextern void domaininit(void); 1782112Swollmanextern void cpu_initclocks(void); 1792112Swollmanextern void vntblinit(void); 1802112Swollmanextern void nchinit(void); 1812112Swollman 1827090Sbde/* Finalize the world. */ 1837090Sbdevoid shutdown_nice __P((void)); 1847090Sbde 1852112Swollmanextern __dead void vm_pageout(void) __dead2; /* pagedaemon, called in proc 2 */ 1862112Swollmanextern __dead void vfs_update(void) __dead2; /* update, called in proc 3 */ 1872112Swollmanextern __dead void scheduler(void) __dead2; /* sched, called in process 0 */ 1882112Swollman 1897090Sbde/* 1907090Sbde * Kernel to clock driver interface. 1917090Sbde */ 1927090Sbdevoid inittodr __P((time_t base)); 1937090Sbdevoid resettodr __P((void)); 1947090Sbdevoid startrtclock __P((void)); 1957090Sbde 1962112Swollman/* Timeouts */ 1972112Swollmantypedef void (timeout_t)(void *); /* actual timeout function type */ 1982112Swollmantypedef timeout_t *timeout_func_t; /* a pointer to this type */ 1992112Swollman 2002112Swollmanvoid timeout(timeout_func_t, void *, int); 2012112Swollmanvoid untimeout(timeout_func_t, void *); 2023484Sphkvoid logwakeup __P((void)); 2032165Spaul 2047090Sbde/* Syscalls that are called internally. */ 2057430Sbdestruct close_args { 2067430Sbde int fd; 2077430Sbde}; 2087430Sbdeint close __P((struct proc *, struct close_args *uap, int *retval)); 2097090Sbdestruct execve_args { 2107090Sbde char *fname; 2117090Sbde char **argv; 2127090Sbde char **envv; 2137090Sbde}; 2147090Sbdeint execve __P((struct proc *, struct execve_args *, int *retval)); 2157090Sbdestruct fork_args { 2167090Sbde int dummy; 2177090Sbde}; 2187090Sbdeint fork __P((struct proc *, struct fork_args *, int retval[])); 2197090Sbdestruct sync_args { 2207090Sbde int dummy; 2217090Sbde}; 2227090Sbdeint sync __P((struct proc *, struct sync_args *, int *retval)); 2237090Sbdestruct wait_args { 2247090Sbde int pid; 2257090Sbde int *status; 2267090Sbde int options; 2277090Sbde struct rusage *rusage; 2287090Sbde#if defined(COMPAT_43) || defined(COMPAT_IBCS2) 2297090Sbde int compat; /* pseudo */ 2307090Sbde#endif 2317090Sbde}; 2327090Sbdeint wait1 __P((struct proc *, struct wait_args *, int retval[])); 2337090Sbde 2342865Sbde#endif /* !_SYS_SYSTM_H_ */ 235