systm.h revision 18556
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 *
3814508Shsu *	@(#)systm.h	8.7 (Berkeley) 3/29/95
3918556Sbde * $Id: systm.h,v 1.44 1996/09/13 09:20:15 bde Exp $
401541Srgrimes */
411541Srgrimes
422165Spaul#ifndef _SYS_SYSTM_H_
432865Sbde#define	_SYS_SYSTM_H_
442165Spaul
451549Srgrimes#include <machine/cpufunc.h>
461549Srgrimes
471541Srgrimes/*
481541Srgrimes * The `securelevel' variable controls the security level of the system.
491541Srgrimes * It can only be decreased by process 1 (/sbin/init).
501541Srgrimes *
511541Srgrimes * Security levels are as follows:
5213765Smpp *   -1	permanently insecure mode - always run system in level 0 mode.
531541Srgrimes *    0	insecure mode - immutable and append-only flags make be turned off.
541541Srgrimes *	All devices may be read or written subject to permission modes.
551541Srgrimes *    1	secure mode - immutable and append-only flags may not be changed;
561541Srgrimes *	raw disks of mounted filesystems, /dev/mem, and /dev/kmem are
571541Srgrimes *	read-only.
581541Srgrimes *    2	highly secure mode - same as (1) plus raw disks are always
598876Srgrimes *	read-only whether mounted or not. This level precludes tampering
601541Srgrimes *	with filesystems by unmounting them, but also inhibits running
611541Srgrimes *	newfs while the system is secured.
621541Srgrimes *
631541Srgrimes * In normal operation, the system runs in level 0 mode while single user
641541Srgrimes * and in level 1 mode while multiuser. If level 2 mode is desired while
651541Srgrimes * running multiuser, it can be set in the multiuser startup script
661541Srgrimes * (/etc/rc.local) using sysctl(1). If it is desired to run the system
671541Srgrimes * in level 0 mode while multiuser, initialize the variable securelevel
681541Srgrimes * in /sys/kern/kern_sysctl.c to -1. Note that it is NOT initialized to
691858Sdg * zero as that would allow the kernel binary to be patched to -1.
701541Srgrimes * Without initialization, securelevel loads in the BSS area which only
711541Srgrimes * comes into existence when the kernel is loaded and hence cannot be
721541Srgrimes * patched by a stalking hacker.
731541Srgrimes */
741541Srgrimesextern int securelevel;		/* system security level */
757090Sbde
767090Sbdeextern int cold;		/* nonzero if we are doing a cold boot */
771541Srgrimesextern const char *panicstr;	/* panic message */
781541Srgrimesextern char version[];		/* system version */
791541Srgrimesextern char copyright[];	/* system copyright */
801541Srgrimes
811541Srgrimesextern int nblkdev;		/* number of entries in bdevsw */
821541Srgrimesextern int nchrdev;		/* number of entries in cdevsw */
838504Sdgextern struct swdevt *swdevt;	/* swap-device information */
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 physmem;		/* physical memory */
921541Srgrimes
931541Srgrimesextern dev_t dumpdev;		/* dump device */
941541Srgrimesextern long dumplo;		/* offset into dumpdev */
951541Srgrimes
961541Srgrimesextern dev_t rootdev;		/* root device */
971541Srgrimesextern struct vnode *rootvp;	/* vnode equivalent to above */
981541Srgrimes
991541Srgrimesextern dev_t swapdev;		/* swapping device */
1001541Srgrimesextern struct vnode *swapdev_vp;/* vnode equivalent to above */
1011541Srgrimes
1021541Srgrimesextern int boothowto;		/* reboot flags, from console subsystem */
10315113Sbdeextern int bootverbose;		/* nonzero to print verbose messages */
1041541Srgrimes
1051541Srgrimes/*
1061541Srgrimes * General function declarations.
1071541Srgrimes */
10816875Sbdevoid	Debugger __P((const char *msg));
1091541Srgrimesint	nullop __P((void));
1101541Srgrimesint	eopnotsupp __P((void));
11114508Shsuint	einval __P((void));
1121541Srgrimesint	seltrue __P((dev_t dev, int which, struct proc *p));
1133304Sphkint	ureadc __P((int, struct uio *));
1141541Srgrimesvoid	*hashinit __P((int count, int type, u_long *hashmask));
1157612Sdgvoid	*phashinit __P((int count, int type, u_long *nentries));
1161541Srgrimes
11718277Sbdevoid	panic __P((const char *, ...)) __dead2;
11818277Sbdevoid	boot __P((int)) __dead2;
11917975Sbdevoid	cpu_boot __P((int));
1201541Srgrimesvoid	tablefull __P((const char *));
12115680Sgpalmerint	addlog __P((const char *, ...));
12218556Sbdeint	kvprintf __P((char const *, void (*)(int, void*), void *, int,
12318556Sbde		      _BSD_VA_LIST_));
1241541Srgrimesvoid	log __P((int, const char *, ...));
12513697Sgibbsint	printf __P((const char *, ...));
12613446Sphkint	sprintf __P((char *buf, const char *, ...));
1272112Swollmanvoid	uprintf __P((const char *, ...));
12818556Sbdevoid	vprintf __P((const char *, _BSD_VA_LIST_));
1291541Srgrimesvoid	ttyprintf __P((struct tty *, const char *, ...));
1301541Srgrimes
1318215Sdgvoid	bcopy __P((const void *from, void *to, size_t len));
1328215Sdgvoid	ovbcopy __P((const void *from, void *to, size_t len));
13313414Sphkextern void	(*bzero) __P((void *buf, size_t len));
1341541Srgrimes
1358215Sdgvoid	*memcpy __P((void *to, const void *from, size_t len));
1368215Sdg
13713456Sbdeint	copystr __P((const void *kfaddr, void *kdaddr, size_t len,
13813456Sbde		size_t *lencopied));
13913456Sbdeint	copyinstr __P((const void *udaddr, void *kaddr, size_t len,
14013456Sbde		size_t *lencopied));
14113456Sbdeint	copyin __P((const void *udaddr, void *kaddr, size_t len));
14213456Sbdeint	copyout __P((const void *kaddr, void *udaddr, size_t len));
1431541Srgrimes
14413456Sbdeint	fubyte __P((const void *base));
14513456Sbdeint	fuibyte __P((const void *base));
1461541Srgrimesint	subyte __P((void *base, int byte));
1471541Srgrimesint	suibyte __P((void *base, int byte));
14813456Sbdeint	fuword __P((const void *base));
1491541Srgrimesint	suword __P((void *base, int word));
1506358Sphkint	susword __P((void *base, int word));
1511541Srgrimes
1521541Srgrimesint	hzto __P((struct timeval *tv));
1531541Srgrimesvoid	realitexpire __P((void *));
1541541Srgrimes
1551541Srgrimesstruct clockframe;
1561541Srgrimesvoid	hardclock __P((struct clockframe *frame));
1571541Srgrimesvoid	softclock __P((void));
1581541Srgrimesvoid	statclock __P((struct clockframe *frame));
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 usrinfoinit(void);
1702112Swollmanextern void cpu_initclocks(void);
1712112Swollmanextern void vntblinit(void);
1722112Swollmanextern void nchinit(void);
1732112Swollman
1747090Sbde/* Finalize the world. */
1757090Sbdevoid	shutdown_nice __P((void));
1767090Sbde
1777090Sbde/*
1787090Sbde * Kernel to clock driver interface.
1797090Sbde */
1807090Sbdevoid	inittodr __P((time_t base));
1817090Sbdevoid	resettodr __P((void));
1827090Sbdevoid	startrtclock __P((void));
1837090Sbde
1842112Swollman/* Timeouts */
1852112Swollmantypedef void (timeout_t)(void *); /* actual timeout function type */
1862112Swollmantypedef timeout_t *timeout_func_t; /* a pointer to this type */
1872112Swollman
1882112Swollmanvoid timeout(timeout_func_t, void *, int);
1892112Swollmanvoid untimeout(timeout_func_t, void *);
1903484Sphkvoid	logwakeup __P((void));
1912165Spaul
19217658Sjulian/* Various other callout lists that modules might want to know about */
19317768Sjulian/* shutdown callout list definitions */
19417658Sjuliantypedef void (*bootlist_fn)(int,void *);
19517768Sjulianint at_shutdown(bootlist_fn function, void *arg, int);
19617658Sjulianint rm_at_shutdown(bootlist_fn function, void *arg);
19717768Sjulian#define SHUTDOWN_PRE_SYNC 0
19817768Sjulian#define SHUTDOWN_POST_SYNC 1
19917658Sjulian
20017658Sjulian/* forking */ /* XXX not yet */
20117658Sjuliantypedef void (*forklist_fn)(struct proc *parent,struct proc *child,int flags);
20217658Sjulianint at_fork(forklist_fn function);
20317658Sjulianint rm_at_fork(forklist_fn function);
20417658Sjulian
20517658Sjulian/* exiting */
20617658Sjuliantypedef void (*exitlist_fn)(struct proc *procp);
20717658Sjulianint at_exit(exitlist_fn function);
20817658Sjulianint rm_at_exit(exitlist_fn function);
20917658Sjulian
2102865Sbde#endif /* !_SYS_SYSTM_H_ */
211