systm.h revision 36735
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
3936735Sdfr * $Id: systm.h,v 1.70 1998/02/24 02:01:11 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
8133777Sbdestruct clockframe;
8230282Sphkstruct malloc_type;
8333777Sbdestruct proc;
8433777Sbdestruct timeval;
8533777Sbdestruct tty;
8633777Sbdestruct uio;
8730282Sphk
8816875Sbdevoid	Debugger __P((const char *msg));
891541Srgrimesint	nullop __P((void));
901541Srgrimesint	eopnotsupp __P((void));
9114508Shsuint	einval __P((void));
921541Srgrimesint	seltrue __P((dev_t dev, int which, struct proc *p));
933304Sphkint	ureadc __P((int, struct uio *));
9430282Sphkvoid	*hashinit __P((int count, struct malloc_type *type, u_long *hashmask));
9530282Sphkvoid	*phashinit __P((int count, struct malloc_type *type, u_long *nentries));
961541Srgrimes
9718277Sbdevoid	panic __P((const char *, ...)) __dead2;
9817975Sbdevoid	cpu_boot __P((int));
9929683Sgibbsvoid	cpu_rootconf __P((void));
10029683Sgibbsvoid	cpu_dumpconf __P((void));
1011541Srgrimesvoid	tablefull __P((const char *));
10215680Sgpalmerint	addlog __P((const char *, ...));
10318556Sbdeint	kvprintf __P((char const *, void (*)(int, void*), void *, int,
10418556Sbde		      _BSD_VA_LIST_));
1051541Srgrimesvoid	log __P((int, const char *, ...));
10629509Sbdevoid	logwakeup __P((void));
10713697Sgibbsint	printf __P((const char *, ...));
10813446Sphkint	sprintf __P((char *buf, const char *, ...));
1092112Swollmanvoid	uprintf __P((const char *, ...));
11018556Sbdevoid	vprintf __P((const char *, _BSD_VA_LIST_));
1111541Srgrimesvoid	ttyprintf __P((struct tty *, const char *, ...));
1121541Srgrimes
1138215Sdgvoid	bcopy __P((const void *from, void *to, size_t len));
1148215Sdgvoid	ovbcopy __P((const void *from, void *to, size_t len));
11536735Sdfr#ifdef __i386__
11613414Sphkextern void	(*bzero) __P((void *buf, size_t len));
11736735Sdfr#else
11836735Sdfrvoid	bzero __P((void *buf, size_t len));
11936735Sdfr#endif
1201541Srgrimes
1218215Sdgvoid	*memcpy __P((void *to, const void *from, size_t len));
1228215Sdg
12313456Sbdeint	copystr __P((const void *kfaddr, void *kdaddr, size_t len,
12413456Sbde		size_t *lencopied));
12513456Sbdeint	copyinstr __P((const void *udaddr, void *kaddr, size_t len,
12613456Sbde		size_t *lencopied));
12713456Sbdeint	copyin __P((const void *udaddr, void *kaddr, size_t len));
12813456Sbdeint	copyout __P((const void *kaddr, void *udaddr, size_t len));
1291541Srgrimes
13013456Sbdeint	fubyte __P((const void *base));
1311541Srgrimesint	subyte __P((void *base, int byte));
1321541Srgrimesint	suibyte __P((void *base, int byte));
13336735Sdfrlong	fuword __P((const void *base));
13436735Sdfrint	suword __P((void *base, long word));
13536735Sdfrlong	fusword __P((void *base));
13636735Sdfrint	susword __P((void *base, long word));
1371541Srgrimes
1381541Srgrimesint	hzto __P((struct timeval *tv));
1391541Srgrimesvoid	realitexpire __P((void *));
1401541Srgrimes
1411541Srgrimesvoid	hardclock __P((struct clockframe *frame));
14232390Sphkvoid	softclock __P((void));
1431541Srgrimesvoid	statclock __P((struct clockframe *frame));
1441541Srgrimes
1451541Srgrimesvoid	startprofclock __P((struct proc *));
1461541Srgrimesvoid	stopprofclock __P((struct proc *));
1471541Srgrimesvoid	setstatclockrate __P((int hzrate));
1481541Srgrimes
14921101Sjhayvoid	hardpps __P((struct timeval *tvp, long usec));
15021101Sjhay
15131960Snate#ifdef APM_FIXUP_CALLTODO
15231960Snatevoid	adjust_timeout_calltodo __P((struct timeval *time_change));
15331960Snate#endif /* APM_FIXUP_CALLTODO */
15431960Snate
1557109Sphk#include <sys/libkern.h>
1562112Swollman
1572112Swollman/* Initialize the world */
15829509Sbdevoid	consinit __P((void));
15929509Sbdevoid	cpu_initclocks __P((void));
16029509Sbdevoid	nchinit __P((void));
16129509Sbdevoid	usrinfoinit __P((void));
16229509Sbdevoid	vntblinit __P((void));
1632112Swollman
1647090Sbde/* Finalize the world. */
1657090Sbdevoid	shutdown_nice __P((void));
1667090Sbde
1677090Sbde/*
1687090Sbde * Kernel to clock driver interface.
1697090Sbde */
1707090Sbdevoid	inittodr __P((time_t base));
1717090Sbdevoid	resettodr __P((void));
1727090Sbdevoid	startrtclock __P((void));
1737090Sbde
1742112Swollman/* Timeouts */
17529509Sbdetypedef void timeout_t __P((void *));	/* timeout function type */
17629683Sgibbs#define CALLOUT_HANDLE_INITIALIZER(handle)	\
17729683Sgibbs	{ NULL }
1782112Swollman
17929683Sgibbsvoid	callout_handle_init __P((struct callout_handle *));
18029683Sgibbsstruct	callout_handle timeout __P((timeout_t *, void *, int));
18129683Sgibbsvoid	untimeout __P((timeout_t *, void *, struct callout_handle));
1822165Spaul
18336735Sdfr#ifdef __i386__
18436735Sdfr
18526312Speter/* Interrupt management */
18626312Spetervoid		setdelayed(void);
18726312Spetervoid		setsoftast(void);
18826312Spetervoid		setsoftclock(void);
18926312Spetervoid		setsoftnet(void);
19029683Sgibbsvoid		setsoftcambio(void);
19129683Sgibbsvoid		setsoftcamnet(void);
19232677Sgibbsvoid		setsoftvm(void);
19326312Spetervoid		setsofttty(void);
19426312Spetervoid		schedsoftnet(void);
19526312Spetervoid		schedsofttty(void);
19629683Sgibbsvoid		schedsoftcamnet(void);
19729683Sgibbsvoid		schedsoftcambio(void);
19832677Sgibbsvoid		schedsoftvm(void);
19926312Spetervoid		spl0(void);
20026312Speterintrmask_t	softclockpending(void);
20126312Speterintrmask_t	splbio(void);
20226312Speterintrmask_t	splclock(void);
20326312Speterintrmask_t	splhigh(void);
20426312Speterintrmask_t	splimp(void);
20526312Speterintrmask_t	splnet(void);
20628440Sfsmp#ifdef SMP
20728440Sfsmpintrmask_t	splq(intrmask_t mask);
20828440Sfsmp#endif
20929683Sgibbsintrmask_t	splcam(void);
21029683Sgibbsintrmask_t	splsoftcam(void);
21129683Sgibbsintrmask_t	splsoftcambio(void);
21229683Sgibbsintrmask_t	splsoftcamnet(void);
21326312Speterintrmask_t	splsoftclock(void);
21426312Speterintrmask_t	splsofttty(void);
21532677Sgibbsintrmask_t	splsoftvm(void);
21626312Speterintrmask_t	splstatclock(void);
21726312Speterintrmask_t	spltty(void);
21826312Speterintrmask_t	splvm(void);
21926312Spetervoid		splx(intrmask_t ipl);
22026312Spetervoid		splz(void);
22126312Speter
22236735Sdfr#endif
22336735Sdfr
22436735Sdfr#ifdef __alpha__
22536735Sdfr#include <machine/ipl.h>
22636735Sdfr#endif
22736735Sdfr
22826312Speter/*
22926312Speter * XXX It's not clear how "machine independent" these will be yet, but
23026312Speter * they are used all over the place especially in pci drivers.  We would
23126312Speter * have to modify lots of drivers since <machine/cpufunc.h> no longer
23226312Speter * implicitly causes these to be defined when it #included <machine/spl.h>
23326312Speter */
23426312Speterextern intrmask_t bio_imask;	/* group of interrupts masked with splbio() */
23529683Sgibbsextern intrmask_t cam_imask;	/* group of interrupts masked with splcam() */
23626312Speterextern intrmask_t net_imask;	/* group of interrupts masked with splimp() */
23726312Speterextern intrmask_t stat_imask;	/* interrupts masked with splstatclock() */
23826312Speterextern intrmask_t tty_imask;	/* group of interrupts masked with spltty() */
23926312Speter
24026312Speter/* Read only */
24127585Sbdeextern const intrmask_t soft_imask;    /* interrupts masked with splsoft*() */
24226312Speterextern const intrmask_t softnet_imask; /* interrupt masked with splnet() */
24326312Speterextern const intrmask_t softtty_imask; /* interrupt masked with splsofttty() */
24426312Speter
24529509Sbde/*
24629509Sbde * Various callout lists.
24729509Sbde */
24817658Sjulian
24929509Sbde/* Exit callout list declarations. */
25029509Sbdetypedef void (*exitlist_fn) __P((struct proc *procp));
25117658Sjulian
25229509Sbdeint	at_exit __P((exitlist_fn function));
25329509Sbdeint	rm_at_exit __P((exitlist_fn function));
25417658Sjulian
25529509Sbde/* Fork callout list declarations. */
25629509Sbdetypedef void (*forklist_fn) __P((struct proc *parent, struct proc *child,
25729509Sbde				 int flags));
25827997Sjulian
25929509Sbdeint	at_fork __P((forklist_fn function));
26029509Sbdeint	rm_at_fork __P((forklist_fn function));
26127997Sjulian
26229509Sbde/* Shutdown callout list definitions and declarations. */
26329509Sbde#define	SHUTDOWN_PRE_SYNC	0
26429509Sbde#define	SHUTDOWN_POST_SYNC	1
26529509Sbde
26629509Sbdetypedef void (*bootlist_fn) __P((int, void *));
26729509Sbde
26829509Sbdeint	at_shutdown __P((bootlist_fn function, void *arg, int position));
26929509Sbdeint	rm_at_shutdown __P((bootlist_fn function, void *arg));
27029509Sbde
27129509Sbde/*
27229509Sbde * Not exactly a callout LIST, but a callout entry.
27329509Sbde * Allow an external module to define a hardware watchdog tickler.
27429509Sbde * Normally a process would do this, but there are times when the
27529509Sbde * kernel needs to be able to hold off the watchdog, when the process
27629509Sbde * is not active, e.g., when dumping core.
27729509Sbde */
27829509Sbdetypedef void (*watchdog_tickle_fn) __P((void));
27929509Sbde
28029509Sbdeextern watchdog_tickle_fn	wdog_tickler;
28129509Sbde
28218884Sbde/*
28318884Sbde * Common `proc' functions are declared here so that proc.h can be included
28418884Sbde * less often.
28518884Sbde */
28631333Sbdeint	tsleep __P((void *chan, int pri, const char *wmesg, int timo));
28718884Sbdevoid	wakeup __P((void *chan));
28818884Sbde
2892865Sbde#endif /* !_SYS_SYSTM_H_ */
290