systm.h revision 54471
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
3950477Speter * $FreeBSD: head/sys/sys/systm.h 54471 1999-12-12 04:21:27Z green $
401541Srgrimes */
411541Srgrimes
422165Spaul#ifndef _SYS_SYSTM_H_
432865Sbde#define	_SYS_SYSTM_H_
442165Spaul
4549043Salc#include <machine/atomic.h>
461549Srgrimes#include <machine/cpufunc.h>
4729683Sgibbs#include <sys/callout.h>
481549Srgrimes
4918883Sbdeextern int securelevel;		/* system security level (see init(8)) */
507090Sbde
517090Sbdeextern int cold;		/* nonzero if we are doing a cold boot */
521541Srgrimesextern const char *panicstr;	/* panic message */
5331337Sbdeextern int safepri;		/* safe ipl when cold or panicing */
541541Srgrimesextern char version[];		/* system version */
551541Srgrimesextern char copyright[];	/* system copyright */
561541Srgrimes
571541Srgrimesextern int nswap;		/* size of swap space */
581541Srgrimes
591541Srgrimesextern int selwait;		/* select timeout address */
601541Srgrimes
611541Srgrimesextern u_char curpriority;	/* priority of current process */
621541Srgrimes
631541Srgrimesextern int physmem;		/* physical memory */
641541Srgrimes
651541Srgrimesextern dev_t dumpdev;		/* dump device */
661541Srgrimesextern long dumplo;		/* offset into dumpdev */
671541Srgrimes
681541Srgrimesextern dev_t rootdev;		/* root device */
6936809Sbdeextern dev_t rootdevs[2];	/* possible root devices */
7036809Sbdeextern char *rootdevnames[2];	/* names of possible root devices */
711541Srgrimesextern struct vnode *rootvp;	/* vnode equivalent to above */
721541Srgrimes
731541Srgrimesextern int boothowto;		/* reboot flags, from console subsystem */
7415113Sbdeextern int bootverbose;		/* nonzero to print verbose messages */
751541Srgrimes
7642453Seivind#ifdef	INVARIANTS		/* The option is always available */
7742453Seivind#define	KASSERT(exp,msg)	do { if (!(exp)) panic msg; } while (0)
7842408Seivind#else
7942453Seivind#define	KASSERT(exp,msg)
8042408Seivind#endif
8142408Seivind
821541Srgrimes/*
831541Srgrimes * General function declarations.
841541Srgrimes */
8530282Sphk
8633777Sbdestruct clockframe;
8730282Sphkstruct malloc_type;
8833777Sbdestruct proc;
8933777Sbdestruct timeval;
9033777Sbdestruct tty;
9133777Sbdestruct uio;
9230282Sphk
9316875Sbdevoid	Debugger __P((const char *msg));
941541Srgrimesint	nullop __P((void));
951541Srgrimesint	eopnotsupp __P((void));
9614508Shsuint	einval __P((void));
971541Srgrimesint	seltrue __P((dev_t dev, int which, struct proc *p));
983304Sphkint	ureadc __P((int, struct uio *));
9930282Sphkvoid	*hashinit __P((int count, struct malloc_type *type, u_long *hashmask));
10030282Sphkvoid	*phashinit __P((int count, struct malloc_type *type, u_long *nentries));
1011541Srgrimes
10217975Sbdevoid	cpu_boot __P((int));
10329683Sgibbsvoid	cpu_rootconf __P((void));
1041541Srgrimesvoid	tablefull __P((const char *));
10537614Sbdeint	addlog __P((const char *, ...)) __printflike(1, 2);
10618556Sbdeint	kvprintf __P((char const *, void (*)(int, void*), void *, int,
10737614Sbde		      _BSD_VA_LIST_)) __printflike(1, 0);
10849047Sdfrint	log __P((int, const char *, ...)) __printflike(2, 3);
10929509Sbdevoid	logwakeup __P((void));
11037614Sbdeint	printf __P((const char *, ...)) __printflike(1, 2);
11141479Sarchieint	snprintf __P((char *, size_t, const char *, ...)) __printflike(3, 4);
11237614Sbdeint	sprintf __P((char *buf, const char *, ...)) __printflike(2, 3);
11349047Sdfrint	uprintf __P((const char *, ...)) __printflike(1, 2);
11449047Sdfrint	vprintf __P((const char *, _BSD_VA_LIST_)) __printflike(1, 0);
11541479Sarchieint	vsnprintf __P((char *, size_t, const char *, _BSD_VA_LIST_)) __printflike(3, 0);
11638874Sacheint     vsprintf __P((char *buf, const char *, _BSD_VA_LIST_)) __printflike(2, 0);
11749047Sdfrint	ttyprintf __P((struct tty *, const char *, ...)) __printflike(2, 3);
11842680Smsmithint	sscanf __P((const char *, char const *, ...));
11942680Smsmithint	vsscanf __P((const char *, char const *, _BSD_VA_LIST_));
12054216Sarchielong	strtol __P((const char *, char **, int));
12154216Sarchieu_long	strtoul __P((const char *, char **, int));
12254216Sarchiequad_t	strtoq __P((const char *, char **, int));
12354216Sarchieu_quad_t strtouq __P((const char *, char **, int));
1241541Srgrimes
1258215Sdgvoid	bcopy __P((const void *from, void *to, size_t len));
1268215Sdgvoid	ovbcopy __P((const void *from, void *to, size_t len));
12736735Sdfr#ifdef __i386__
12813414Sphkextern void	(*bzero) __P((void *buf, size_t len));
12936735Sdfr#else
13036735Sdfrvoid	bzero __P((void *buf, size_t len));
13136735Sdfr#endif
1321541Srgrimes
1338215Sdgvoid	*memcpy __P((void *to, const void *from, size_t len));
1348215Sdg
13513456Sbdeint	copystr __P((const void *kfaddr, void *kdaddr, size_t len,
13613456Sbde		size_t *lencopied));
13713456Sbdeint	copyinstr __P((const void *udaddr, void *kaddr, size_t len,
13813456Sbde		size_t *lencopied));
13913456Sbdeint	copyin __P((const void *udaddr, void *kaddr, size_t len));
14013456Sbdeint	copyout __P((const void *kaddr, void *udaddr, size_t len));
1411541Srgrimes
14213456Sbdeint	fubyte __P((const void *base));
1431541Srgrimesint	subyte __P((void *base, int byte));
1441541Srgrimesint	suibyte __P((void *base, int byte));
14536735Sdfrlong	fuword __P((const void *base));
14636735Sdfrint	suword __P((void *base, long word));
14744495Sbdeint	fusword __P((void *base));
14844495Sbdeint	susword __P((void *base, int word));
1491541Srgrimes
1501541Srgrimesvoid	realitexpire __P((void *));
1511541Srgrimes
1521541Srgrimesvoid	hardclock __P((struct clockframe *frame));
15332390Sphkvoid	softclock __P((void));
1541541Srgrimesvoid	statclock __P((struct clockframe *frame));
1551541Srgrimes
1561541Srgrimesvoid	startprofclock __P((struct proc *));
1571541Srgrimesvoid	stopprofclock __P((struct proc *));
1581541Srgrimesvoid	setstatclockrate __P((int hzrate));
1591541Srgrimes
16040096Smsmithchar	*getenv __P((char *name));
16142706Smsmithint	getenv_int __P((char *name, int *data));
16252946Smjacobquad_t	getenv_quad __P((char *name, quad_t *data));
16340096Smsmithextern char *kern_envp;
16440096Smsmith
16531960Snate#ifdef APM_FIXUP_CALLTODO
16631960Snatevoid	adjust_timeout_calltodo __P((struct timeval *time_change));
16731960Snate#endif /* APM_FIXUP_CALLTODO */
16831960Snate
1697109Sphk#include <sys/libkern.h>
1702112Swollman
1712112Swollman/* Initialize the world */
17229509Sbdevoid	consinit __P((void));
17329509Sbdevoid	cpu_initclocks __P((void));
17429509Sbdevoid	nchinit __P((void));
17529509Sbdevoid	usrinfoinit __P((void));
17629509Sbdevoid	vntblinit __P((void));
1772112Swollman
1787090Sbde/* Finalize the world. */
1797090Sbdevoid	shutdown_nice __P((void));
1807090Sbde
1817090Sbde/*
1827090Sbde * Kernel to clock driver interface.
1837090Sbde */
1847090Sbdevoid	inittodr __P((time_t base));
1857090Sbdevoid	resettodr __P((void));
1867090Sbdevoid	startrtclock __P((void));
1877090Sbde
1882112Swollman/* Timeouts */
18929509Sbdetypedef void timeout_t __P((void *));	/* timeout function type */
19029683Sgibbs#define CALLOUT_HANDLE_INITIALIZER(handle)	\
19129683Sgibbs	{ NULL }
1922112Swollman
19329683Sgibbsvoid	callout_handle_init __P((struct callout_handle *));
19429683Sgibbsstruct	callout_handle timeout __P((timeout_t *, void *, int));
19529683Sgibbsvoid	untimeout __P((timeout_t *, void *, struct callout_handle));
1962165Spaul
19738130Sbde/* Interrupt management */
19838130Sbde
19936735Sdfr#ifdef __i386__
20038130Sbdevoid		setdelayed __P((void));
20138130Sbdevoid		setsoftast __P((void));
20238130Sbdevoid		setsoftcambio __P((void));
20338130Sbdevoid		setsoftcamnet __P((void));
20438130Sbdevoid		setsoftclock __P((void));
20538130Sbdevoid		setsoftnet __P((void));
20638130Sbdevoid		setsofttty __P((void));
20738130Sbdevoid		setsoftvm __P((void));
20838130Sbdevoid		schedsoftcamnet __P((void));
20938130Sbdevoid		schedsoftcambio __P((void));
21038130Sbdevoid		schedsoftnet __P((void));
21138130Sbdevoid		schedsofttty __P((void));
21238130Sbdevoid		schedsoftvm __P((void));
21338130Sbdeintrmask_t	softclockpending __P((void));
21438130Sbdevoid		spl0 __P((void));
21538130Sbdeintrmask_t	splbio __P((void));
21638130Sbdeintrmask_t	splcam __P((void));
21738130Sbdeintrmask_t	splclock __P((void));
21838130Sbdeintrmask_t	splhigh __P((void));
21938130Sbdeintrmask_t	splimp __P((void));
22038130Sbdeintrmask_t	splnet __P((void));
22138130Sbdeintrmask_t	splsoftcam __P((void));
22238130Sbdeintrmask_t	splsoftcambio __P((void));
22338130Sbdeintrmask_t	splsoftcamnet __P((void));
22438130Sbdeintrmask_t	splsoftclock __P((void));
22538130Sbdeintrmask_t	splsofttty __P((void));
22638130Sbdeintrmask_t	splsoftvm __P((void));
22738130Sbdeintrmask_t	splstatclock __P((void));
22838130Sbdeintrmask_t	spltty __P((void));
22938130Sbdeintrmask_t	splvm __P((void));
23038130Sbdevoid		splx __P((intrmask_t ipl));
23138130Sbdevoid		splz __P((void));
23238130Sbde#endif /* __i386__ */
23326312Speter
23436735Sdfr#ifdef __alpha__
23536735Sdfr#include <machine/ipl.h>
23636735Sdfr#endif
23736735Sdfr
23826312Speter/*
23926312Speter * XXX It's not clear how "machine independent" these will be yet, but
24026312Speter * they are used all over the place especially in pci drivers.  We would
24126312Speter * have to modify lots of drivers since <machine/cpufunc.h> no longer
24226312Speter * implicitly causes these to be defined when it #included <machine/spl.h>
24326312Speter */
24426312Speterextern intrmask_t bio_imask;	/* group of interrupts masked with splbio() */
24529683Sgibbsextern intrmask_t cam_imask;	/* group of interrupts masked with splcam() */
24626312Speterextern intrmask_t net_imask;	/* group of interrupts masked with splimp() */
24726312Speterextern intrmask_t stat_imask;	/* interrupts masked with splstatclock() */
24826312Speterextern intrmask_t tty_imask;	/* group of interrupts masked with spltty() */
24926312Speter
25026312Speter/* Read only */
25127585Sbdeextern const intrmask_t soft_imask;    /* interrupts masked with splsoft*() */
25226312Speterextern const intrmask_t softnet_imask; /* interrupt masked with splnet() */
25326312Speterextern const intrmask_t softtty_imask; /* interrupt masked with splsofttty() */
25426312Speter
25529509Sbde/*
25629509Sbde * Various callout lists.
25729509Sbde */
25817658Sjulian
25929509Sbde/* Exit callout list declarations. */
26029509Sbdetypedef void (*exitlist_fn) __P((struct proc *procp));
26117658Sjulian
26229509Sbdeint	at_exit __P((exitlist_fn function));
26329509Sbdeint	rm_at_exit __P((exitlist_fn function));
26417658Sjulian
26529509Sbde/* Fork callout list declarations. */
26629509Sbdetypedef void (*forklist_fn) __P((struct proc *parent, struct proc *child,
26729509Sbde				 int flags));
26827997Sjulian
26929509Sbdeint	at_fork __P((forklist_fn function));
27029509Sbdeint	rm_at_fork __P((forklist_fn function));
27127997Sjulian
27229509Sbde/*
27329509Sbde * Not exactly a callout LIST, but a callout entry.
27429509Sbde * Allow an external module to define a hardware watchdog tickler.
27529509Sbde * Normally a process would do this, but there are times when the
27629509Sbde * kernel needs to be able to hold off the watchdog, when the process
27729509Sbde * is not active, e.g., when dumping core.
27829509Sbde */
27929509Sbdetypedef void (*watchdog_tickle_fn) __P((void));
28029509Sbde
28129509Sbdeextern watchdog_tickle_fn	wdog_tickler;
28229509Sbde
28318884Sbde/*
28418884Sbde * Common `proc' functions are declared here so that proc.h can be included
28518884Sbde * less often.
28618884Sbde */
28731333Sbdeint	tsleep __P((void *chan, int pri, const char *wmesg, int timo));
28841971Sdillonint	asleep __P((void *chan, int pri, const char *wmesg, int timo));
28941971Sdillonint	await  __P((int pri, int timo));
29018884Sbdevoid	wakeup __P((void *chan));
29154471Sgreenvoid	wakeup_one __P((void *chan));
29218884Sbde
29347028Sphk/*
29447028Sphk * Common `dev_t' stuff are declared here to avoid #include poisoning
29547028Sphk */
29647028Sphk
29747028Sphkint major(dev_t x);
29847028Sphkint minor(dev_t x);
29947028Sphkdev_t makedev(int x, int y);
30047028Sphkudev_t dev2udev(dev_t x);
30147028Sphkdev_t udev2dev(udev_t x, int b);
30247028Sphkint uminor(udev_t dev);
30347028Sphkint umajor(udev_t dev);
30448859Sphkudev_t makeudev(int x, int y);
3052865Sbde#endif /* !_SYS_SYSTM_H_ */
306