systm.h revision 29509
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
3929509Sbde * $Id: systm.h,v 1.58 1997/09/07 16:20:55 bde Exp $
401541Srgrimes */
411541Srgrimes
422165Spaul#ifndef _SYS_SYSTM_H_
432865Sbde#define	_SYS_SYSTM_H_
442165Spaul
451549Srgrimes#include <machine/cpufunc.h>
461549Srgrimes
4718883Sbdeextern int securelevel;		/* system security level (see init(8)) */
487090Sbde
497090Sbdeextern int cold;		/* nonzero if we are doing a cold boot */
501541Srgrimesextern const char *panicstr;	/* panic message */
511541Srgrimesextern char version[];		/* system version */
521541Srgrimesextern char copyright[];	/* system copyright */
531541Srgrimes
541541Srgrimesextern int nblkdev;		/* number of entries in bdevsw */
551541Srgrimesextern int nchrdev;		/* number of entries in cdevsw */
561541Srgrimesextern int nswap;		/* size of swap space */
571541Srgrimes
581541Srgrimesextern int selwait;		/* select timeout address */
591541Srgrimes
601541Srgrimesextern u_char curpriority;	/* priority of current process */
611541Srgrimes
621541Srgrimesextern int physmem;		/* physical memory */
631541Srgrimes
641541Srgrimesextern dev_t dumpdev;		/* dump device */
651541Srgrimesextern long dumplo;		/* offset into dumpdev */
661541Srgrimes
671541Srgrimesextern dev_t rootdev;		/* root device */
681541Srgrimesextern struct vnode *rootvp;	/* vnode equivalent to above */
691541Srgrimes
7029208Sbdeextern struct vnode *swapdev_vp;/* vnode for swap device */
711541Srgrimes
721541Srgrimesextern int boothowto;		/* reboot flags, from console subsystem */
7315113Sbdeextern int bootverbose;		/* nonzero to print verbose messages */
741541Srgrimes
751541Srgrimes/*
761541Srgrimes * General function declarations.
771541Srgrimes */
7816875Sbdevoid	Debugger __P((const char *msg));
791541Srgrimesint	nullop __P((void));
801541Srgrimesint	eopnotsupp __P((void));
8114508Shsuint	einval __P((void));
821541Srgrimesint	seltrue __P((dev_t dev, int which, struct proc *p));
833304Sphkint	ureadc __P((int, struct uio *));
841541Srgrimesvoid	*hashinit __P((int count, int type, u_long *hashmask));
857612Sdgvoid	*phashinit __P((int count, int type, u_long *nentries));
861541Srgrimes
8718277Sbdevoid	panic __P((const char *, ...)) __dead2;
8818277Sbdevoid	boot __P((int)) __dead2;
8917975Sbdevoid	cpu_boot __P((int));
901541Srgrimesvoid	tablefull __P((const char *));
9115680Sgpalmerint	addlog __P((const char *, ...));
9218556Sbdeint	kvprintf __P((char const *, void (*)(int, void*), void *, int,
9318556Sbde		      _BSD_VA_LIST_));
941541Srgrimesvoid	log __P((int, const char *, ...));
9529509Sbdevoid	logwakeup __P((void));
9613697Sgibbsint	printf __P((const char *, ...));
9713446Sphkint	sprintf __P((char *buf, const char *, ...));
982112Swollmanvoid	uprintf __P((const char *, ...));
9918556Sbdevoid	vprintf __P((const char *, _BSD_VA_LIST_));
1001541Srgrimesvoid	ttyprintf __P((struct tty *, const char *, ...));
1011541Srgrimes
1028215Sdgvoid	bcopy __P((const void *from, void *to, size_t len));
1038215Sdgvoid	ovbcopy __P((const void *from, void *to, size_t len));
10413414Sphkextern void	(*bzero) __P((void *buf, size_t len));
1051541Srgrimes
1068215Sdgvoid	*memcpy __P((void *to, const void *from, size_t len));
1078215Sdg
10813456Sbdeint	copystr __P((const void *kfaddr, void *kdaddr, size_t len,
10913456Sbde		size_t *lencopied));
11013456Sbdeint	copyinstr __P((const void *udaddr, void *kaddr, size_t len,
11113456Sbde		size_t *lencopied));
11213456Sbdeint	copyin __P((const void *udaddr, void *kaddr, size_t len));
11313456Sbdeint	copyout __P((const void *kaddr, void *udaddr, size_t len));
1141541Srgrimes
11513456Sbdeint	fubyte __P((const void *base));
1161541Srgrimesint	subyte __P((void *base, int byte));
1171541Srgrimesint	suibyte __P((void *base, int byte));
11813456Sbdeint	fuword __P((const void *base));
1191541Srgrimesint	suword __P((void *base, int word));
12027993Sdysonint	fusword __P((void *base));
1216358Sphkint	susword __P((void *base, int word));
1221541Srgrimes
12326259Speterstruct timeval;
1241541Srgrimesint	hzto __P((struct timeval *tv));
1251541Srgrimesvoid	realitexpire __P((void *));
1261541Srgrimes
1271541Srgrimesstruct clockframe;
1281541Srgrimesvoid	hardclock __P((struct clockframe *frame));
1291541Srgrimesvoid	softclock __P((void));
1301541Srgrimesvoid	statclock __P((struct clockframe *frame));
1311541Srgrimes
1321541Srgrimesvoid	startprofclock __P((struct proc *));
1331541Srgrimesvoid	stopprofclock __P((struct proc *));
1341541Srgrimesvoid	setstatclockrate __P((int hzrate));
1351541Srgrimes
1363484Sphkvoid	hardupdate __P((long));
13721101Sjhayvoid	hardpps __P((struct timeval *tvp, long usec));
13821101Sjhay
1397109Sphk#include <sys/libkern.h>
1402112Swollman
1412112Swollman/* Initialize the world */
14229509Sbdevoid	consinit __P((void));
14329509Sbdevoid	cpu_initclocks __P((void));
14429509Sbdevoid	nchinit __P((void));
14529509Sbdevoid	usrinfoinit __P((void));
14629509Sbdevoid	vntblinit __P((void));
1472112Swollman
1487090Sbde/* Finalize the world. */
1497090Sbdevoid	shutdown_nice __P((void));
1507090Sbde
1517090Sbde/*
1527090Sbde * Kernel to clock driver interface.
1537090Sbde */
1547090Sbdevoid	inittodr __P((time_t base));
1557090Sbdevoid	resettodr __P((void));
1567090Sbdevoid	startrtclock __P((void));
1577090Sbde
1582112Swollman/* Timeouts */
15929509Sbdetypedef void timeout_t __P((void *));	/* timeout function type */
1602112Swollman
16129509Sbdevoid	timeout __P((timeout_t *, void *, int));
16229509Sbdevoid	untimeout __P((timeout_t *, void *));
1632165Spaul
16426312Speter/* Interrupt management */
16526312Spetervoid		setdelayed(void);
16626312Spetervoid		setsoftast(void);
16726312Spetervoid		setsoftclock(void);
16826312Spetervoid		setsoftnet(void);
16926312Spetervoid		setsofttty(void);
17026312Spetervoid		schedsoftnet(void);
17126312Spetervoid		schedsofttty(void);
17226312Spetervoid		spl0(void);
17326312Speterintrmask_t	softclockpending(void);
17426312Speterintrmask_t	splbio(void);
17526312Speterintrmask_t	splclock(void);
17626312Speterintrmask_t	splhigh(void);
17726312Speterintrmask_t	splimp(void);
17826312Speterintrmask_t	splnet(void);
17928440Sfsmp#ifdef SMP
18028440Sfsmpintrmask_t	splq(intrmask_t mask);
18128440Sfsmp#endif
18226312Speterintrmask_t	splsoftclock(void);
18326312Speterintrmask_t	splsofttty(void);
18426312Speterintrmask_t	splstatclock(void);
18526312Speterintrmask_t	spltty(void);
18626312Speterintrmask_t	splvm(void);
18726312Spetervoid		splx(intrmask_t ipl);
18826312Spetervoid		splz(void);
18926312Speter
19026312Speter/*
19126312Speter * XXX It's not clear how "machine independent" these will be yet, but
19226312Speter * they are used all over the place especially in pci drivers.  We would
19326312Speter * have to modify lots of drivers since <machine/cpufunc.h> no longer
19426312Speter * implicitly causes these to be defined when it #included <machine/spl.h>
19526312Speter */
19626312Speterextern intrmask_t bio_imask;	/* group of interrupts masked with splbio() */
19726312Speterextern intrmask_t net_imask;	/* group of interrupts masked with splimp() */
19826312Speterextern intrmask_t stat_imask;	/* interrupts masked with splstatclock() */
19926312Speterextern intrmask_t tty_imask;	/* group of interrupts masked with spltty() */
20026312Speter
20126312Speter/* Read only */
20227585Sbdeextern const intrmask_t soft_imask;    /* interrupts masked with splsoft*() */
20326312Speterextern const intrmask_t softnet_imask; /* interrupt masked with splnet() */
20426312Speterextern const intrmask_t softtty_imask; /* interrupt masked with splsofttty() */
20526312Speter
20629509Sbde/*
20729509Sbde * Various callout lists.
20829509Sbde */
20917658Sjulian
21029509Sbde/* Exit callout list declarations. */
21129509Sbdetypedef void (*exitlist_fn) __P((struct proc *procp));
21217658Sjulian
21329509Sbdeint	at_exit __P((exitlist_fn function));
21429509Sbdeint	rm_at_exit __P((exitlist_fn function));
21517658Sjulian
21629509Sbde/* Fork callout list declarations. */
21729509Sbdetypedef void (*forklist_fn) __P((struct proc *parent, struct proc *child,
21829509Sbde				 int flags));
21927997Sjulian
22029509Sbdeint	at_fork __P((forklist_fn function));
22129509Sbdeint	rm_at_fork __P((forklist_fn function));
22227997Sjulian
22329509Sbde/* Shutdown callout list definitions and declarations. */
22429509Sbde#define	SHUTDOWN_PRE_SYNC	0
22529509Sbde#define	SHUTDOWN_POST_SYNC	1
22629509Sbde
22729509Sbdetypedef void (*bootlist_fn) __P((int, void *));
22829509Sbde
22929509Sbdeint	at_shutdown __P((bootlist_fn function, void *arg, int position));
23029509Sbdeint	rm_at_shutdown __P((bootlist_fn function, void *arg));
23129509Sbde
23229509Sbde/*
23329509Sbde * Not exactly a callout LIST, but a callout entry.
23429509Sbde * Allow an external module to define a hardware watchdog tickler.
23529509Sbde * Normally a process would do this, but there are times when the
23629509Sbde * kernel needs to be able to hold off the watchdog, when the process
23729509Sbde * is not active, e.g., when dumping core.
23829509Sbde */
23929509Sbdetypedef void (*watchdog_tickle_fn) __P((void));
24029509Sbde
24129509Sbdeextern watchdog_tickle_fn	wdog_tickler;
24229509Sbde
24318884Sbde/*
24418884Sbde * Common `proc' functions are declared here so that proc.h can be included
24518884Sbde * less often.
24618884Sbde */
24718884Sbdeint	tsleep __P((void *chan, int pri, char *wmesg, int timo));
24818884Sbdevoid	wakeup __P((void *chan));
24918884Sbde
2502865Sbde#endif /* !_SYS_SYSTM_H_ */
251