systm.h revision 31960
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
3931960Snate * $Id: systm.h,v 1.64 1997/11/21 18:27:15 bde Exp $
401541Srgrimes */
411541Srgrimes
422165Spaul#ifndef _SYS_SYSTM_H_
432865Sbde#define	_SYS_SYSTM_H_
442165Spaul
451549Srgrimes#include <machine/cpufunc.h>
4629683Sgibbs#include <sys/callout.h>
471549Srgrimes
4818883Sbdeextern int securelevel;		/* system security level (see init(8)) */
497090Sbde
507090Sbdeextern int cold;		/* nonzero if we are doing a cold boot */
511541Srgrimesextern const char *panicstr;	/* panic message */
5231337Sbdeextern int safepri;		/* safe ipl when cold or panicing */
531541Srgrimesextern char version[];		/* system version */
541541Srgrimesextern char copyright[];	/* system copyright */
551541Srgrimes
561541Srgrimesextern int nblkdev;		/* number of entries in bdevsw */
571541Srgrimesextern int nchrdev;		/* number of entries in cdevsw */
581541Srgrimesextern int nswap;		/* size of swap space */
591541Srgrimes
601541Srgrimesextern int selwait;		/* select timeout address */
611541Srgrimes
621541Srgrimesextern u_char curpriority;	/* priority of current process */
631541Srgrimes
641541Srgrimesextern int physmem;		/* physical memory */
651541Srgrimes
661541Srgrimesextern dev_t dumpdev;		/* dump device */
671541Srgrimesextern long dumplo;		/* offset into dumpdev */
681541Srgrimes
691541Srgrimesextern dev_t rootdev;		/* root device */
701541Srgrimesextern struct vnode *rootvp;	/* vnode equivalent to above */
711541Srgrimes
7229208Sbdeextern struct vnode *swapdev_vp;/* vnode for swap device */
731541Srgrimes
741541Srgrimesextern int boothowto;		/* reboot flags, from console subsystem */
7515113Sbdeextern int bootverbose;		/* nonzero to print verbose messages */
761541Srgrimes
771541Srgrimes/*
781541Srgrimes * General function declarations.
791541Srgrimes */
8030282Sphk
8130282Sphkstruct malloc_type;
8230282Sphk
8316875Sbdevoid	Debugger __P((const char *msg));
841541Srgrimesint	nullop __P((void));
851541Srgrimesint	eopnotsupp __P((void));
8614508Shsuint	einval __P((void));
871541Srgrimesint	seltrue __P((dev_t dev, int which, struct proc *p));
883304Sphkint	ureadc __P((int, struct uio *));
8930282Sphkvoid	*hashinit __P((int count, struct malloc_type *type, u_long *hashmask));
9030282Sphkvoid	*phashinit __P((int count, struct malloc_type *type, u_long *nentries));
911541Srgrimes
9218277Sbdevoid	panic __P((const char *, ...)) __dead2;
9317975Sbdevoid	cpu_boot __P((int));
9429683Sgibbsvoid	cpu_rootconf __P((void));
9529683Sgibbsvoid	cpu_dumpconf __P((void));
961541Srgrimesvoid	tablefull __P((const char *));
9715680Sgpalmerint	addlog __P((const char *, ...));
9818556Sbdeint	kvprintf __P((char const *, void (*)(int, void*), void *, int,
9918556Sbde		      _BSD_VA_LIST_));
1001541Srgrimesvoid	log __P((int, const char *, ...));
10129509Sbdevoid	logwakeup __P((void));
10213697Sgibbsint	printf __P((const char *, ...));
10313446Sphkint	sprintf __P((char *buf, const char *, ...));
1042112Swollmanvoid	uprintf __P((const char *, ...));
10518556Sbdevoid	vprintf __P((const char *, _BSD_VA_LIST_));
1061541Srgrimesvoid	ttyprintf __P((struct tty *, const char *, ...));
1071541Srgrimes
1088215Sdgvoid	bcopy __P((const void *from, void *to, size_t len));
1098215Sdgvoid	ovbcopy __P((const void *from, void *to, size_t len));
11013414Sphkextern void	(*bzero) __P((void *buf, size_t len));
1111541Srgrimes
1128215Sdgvoid	*memcpy __P((void *to, const void *from, size_t len));
1138215Sdg
11413456Sbdeint	copystr __P((const void *kfaddr, void *kdaddr, size_t len,
11513456Sbde		size_t *lencopied));
11613456Sbdeint	copyinstr __P((const void *udaddr, void *kaddr, size_t len,
11713456Sbde		size_t *lencopied));
11813456Sbdeint	copyin __P((const void *udaddr, void *kaddr, size_t len));
11913456Sbdeint	copyout __P((const void *kaddr, void *udaddr, size_t len));
1201541Srgrimes
12113456Sbdeint	fubyte __P((const void *base));
1221541Srgrimesint	subyte __P((void *base, int byte));
1231541Srgrimesint	suibyte __P((void *base, int byte));
12413456Sbdeint	fuword __P((const void *base));
1251541Srgrimesint	suword __P((void *base, int word));
12627993Sdysonint	fusword __P((void *base));
1276358Sphkint	susword __P((void *base, int word));
1281541Srgrimes
12926259Speterstruct timeval;
1301541Srgrimesint	hzto __P((struct timeval *tv));
1311541Srgrimesvoid	realitexpire __P((void *));
1321541Srgrimes
1331541Srgrimesstruct clockframe;
1341541Srgrimesvoid	hardclock __P((struct clockframe *frame));
1351541Srgrimesvoid	softclock __P((void));
1361541Srgrimesvoid	statclock __P((struct clockframe *frame));
1371541Srgrimes
1381541Srgrimesvoid	startprofclock __P((struct proc *));
1391541Srgrimesvoid	stopprofclock __P((struct proc *));
1401541Srgrimesvoid	setstatclockrate __P((int hzrate));
1411541Srgrimes
1423484Sphkvoid	hardupdate __P((long));
14321101Sjhayvoid	hardpps __P((struct timeval *tvp, long usec));
14421101Sjhay
14531960Snate#ifdef APM_FIXUP_CALLTODO
14631960Snatevoid	adjust_timeout_calltodo __P((struct timeval *time_change));
14731960Snate#endif /* APM_FIXUP_CALLTODO */
14831960Snate
1497109Sphk#include <sys/libkern.h>
1502112Swollman
1512112Swollman/* Initialize the world */
15229509Sbdevoid	consinit __P((void));
15329509Sbdevoid	cpu_initclocks __P((void));
15429509Sbdevoid	nchinit __P((void));
15529509Sbdevoid	usrinfoinit __P((void));
15629509Sbdevoid	vntblinit __P((void));
1572112Swollman
1587090Sbde/* Finalize the world. */
1597090Sbdevoid	shutdown_nice __P((void));
1607090Sbde
1617090Sbde/*
1627090Sbde * Kernel to clock driver interface.
1637090Sbde */
1647090Sbdevoid	inittodr __P((time_t base));
1657090Sbdevoid	resettodr __P((void));
1667090Sbdevoid	startrtclock __P((void));
1677090Sbde
1682112Swollman/* Timeouts */
16929509Sbdetypedef void timeout_t __P((void *));	/* timeout function type */
17029683Sgibbs#define CALLOUT_HANDLE_INITIALIZER(handle)	\
17129683Sgibbs	{ NULL }
1722112Swollman
17329683Sgibbsvoid	callout_handle_init __P((struct callout_handle *));
17429683Sgibbsstruct	callout_handle timeout __P((timeout_t *, void *, int));
17529683Sgibbsvoid	untimeout __P((timeout_t *, void *, struct callout_handle));
1762165Spaul
17726312Speter/* Interrupt management */
17826312Spetervoid		setdelayed(void);
17926312Spetervoid		setsoftast(void);
18026312Spetervoid		setsoftclock(void);
18126312Spetervoid		setsoftnet(void);
18229683Sgibbsvoid		setsoftcambio(void);
18329683Sgibbsvoid		setsoftcamnet(void);
18426312Spetervoid		setsofttty(void);
18526312Spetervoid		schedsoftnet(void);
18626312Spetervoid		schedsofttty(void);
18729683Sgibbsvoid		schedsoftcamnet(void);
18829683Sgibbsvoid		schedsoftcambio(void);
18926312Spetervoid		spl0(void);
19026312Speterintrmask_t	softclockpending(void);
19126312Speterintrmask_t	splbio(void);
19226312Speterintrmask_t	splclock(void);
19326312Speterintrmask_t	splhigh(void);
19426312Speterintrmask_t	splimp(void);
19526312Speterintrmask_t	splnet(void);
19628440Sfsmp#ifdef SMP
19728440Sfsmpintrmask_t	splq(intrmask_t mask);
19828440Sfsmp#endif
19929683Sgibbsintrmask_t	splcam(void);
20029683Sgibbsintrmask_t	splsoftcam(void);
20129683Sgibbsintrmask_t	splsoftcambio(void);
20229683Sgibbsintrmask_t	splsoftcamnet(void);
20326312Speterintrmask_t	splsoftclock(void);
20426312Speterintrmask_t	splsofttty(void);
20526312Speterintrmask_t	splstatclock(void);
20626312Speterintrmask_t	spltty(void);
20726312Speterintrmask_t	splvm(void);
20826312Spetervoid		splx(intrmask_t ipl);
20926312Spetervoid		splz(void);
21026312Speter
21126312Speter/*
21226312Speter * XXX It's not clear how "machine independent" these will be yet, but
21326312Speter * they are used all over the place especially in pci drivers.  We would
21426312Speter * have to modify lots of drivers since <machine/cpufunc.h> no longer
21526312Speter * implicitly causes these to be defined when it #included <machine/spl.h>
21626312Speter */
21726312Speterextern intrmask_t bio_imask;	/* group of interrupts masked with splbio() */
21829683Sgibbsextern intrmask_t cam_imask;	/* group of interrupts masked with splcam() */
21926312Speterextern intrmask_t net_imask;	/* group of interrupts masked with splimp() */
22026312Speterextern intrmask_t stat_imask;	/* interrupts masked with splstatclock() */
22126312Speterextern intrmask_t tty_imask;	/* group of interrupts masked with spltty() */
22226312Speter
22326312Speter/* Read only */
22427585Sbdeextern const intrmask_t soft_imask;    /* interrupts masked with splsoft*() */
22526312Speterextern const intrmask_t softnet_imask; /* interrupt masked with splnet() */
22626312Speterextern const intrmask_t softtty_imask; /* interrupt masked with splsofttty() */
22726312Speter
22829509Sbde/*
22929509Sbde * Various callout lists.
23029509Sbde */
23117658Sjulian
23229509Sbde/* Exit callout list declarations. */
23329509Sbdetypedef void (*exitlist_fn) __P((struct proc *procp));
23417658Sjulian
23529509Sbdeint	at_exit __P((exitlist_fn function));
23629509Sbdeint	rm_at_exit __P((exitlist_fn function));
23717658Sjulian
23829509Sbde/* Fork callout list declarations. */
23929509Sbdetypedef void (*forklist_fn) __P((struct proc *parent, struct proc *child,
24029509Sbde				 int flags));
24127997Sjulian
24229509Sbdeint	at_fork __P((forklist_fn function));
24329509Sbdeint	rm_at_fork __P((forklist_fn function));
24427997Sjulian
24529509Sbde/* Shutdown callout list definitions and declarations. */
24629509Sbde#define	SHUTDOWN_PRE_SYNC	0
24729509Sbde#define	SHUTDOWN_POST_SYNC	1
24829509Sbde
24929509Sbdetypedef void (*bootlist_fn) __P((int, void *));
25029509Sbde
25129509Sbdeint	at_shutdown __P((bootlist_fn function, void *arg, int position));
25229509Sbdeint	rm_at_shutdown __P((bootlist_fn function, void *arg));
25329509Sbde
25429509Sbde/*
25529509Sbde * Not exactly a callout LIST, but a callout entry.
25629509Sbde * Allow an external module to define a hardware watchdog tickler.
25729509Sbde * Normally a process would do this, but there are times when the
25829509Sbde * kernel needs to be able to hold off the watchdog, when the process
25929509Sbde * is not active, e.g., when dumping core.
26029509Sbde */
26129509Sbdetypedef void (*watchdog_tickle_fn) __P((void));
26229509Sbde
26329509Sbdeextern watchdog_tickle_fn	wdog_tickler;
26429509Sbde
26518884Sbde/*
26618884Sbde * Common `proc' functions are declared here so that proc.h can be included
26718884Sbde * less often.
26818884Sbde */
26931333Sbdeint	tsleep __P((void *chan, int pri, const char *wmesg, int timo));
27018884Sbdevoid	wakeup __P((void *chan));
27118884Sbde
2722865Sbde#endif /* !_SYS_SYSTM_H_ */
273