systm.h revision 27585
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
3927585Sbde * $Id: systm.h,v 1.52 1997/05/31 09:43:22 peter 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 */
568504Sdgextern struct swdevt *swdevt;	/* swap-device information */
571541Srgrimesextern int nswdev;		/* number of swap devices */
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
721541Srgrimesextern dev_t swapdev;		/* swapping device */
731541Srgrimesextern struct vnode *swapdev_vp;/* vnode equivalent to above */
741541Srgrimes
751541Srgrimesextern int boothowto;		/* reboot flags, from console subsystem */
7615113Sbdeextern int bootverbose;		/* nonzero to print verbose messages */
771541Srgrimes
781541Srgrimes/*
791541Srgrimes * General function declarations.
801541Srgrimes */
8116875Sbdevoid	Debugger __P((const char *msg));
821541Srgrimesint	nullop __P((void));
831541Srgrimesint	eopnotsupp __P((void));
8414508Shsuint	einval __P((void));
851541Srgrimesint	seltrue __P((dev_t dev, int which, struct proc *p));
863304Sphkint	ureadc __P((int, struct uio *));
871541Srgrimesvoid	*hashinit __P((int count, int type, u_long *hashmask));
887612Sdgvoid	*phashinit __P((int count, int type, u_long *nentries));
891541Srgrimes
9018277Sbdevoid	panic __P((const char *, ...)) __dead2;
9118277Sbdevoid	boot __P((int)) __dead2;
9217975Sbdevoid	cpu_boot __P((int));
931541Srgrimesvoid	tablefull __P((const char *));
9415680Sgpalmerint	addlog __P((const char *, ...));
9518556Sbdeint	kvprintf __P((char const *, void (*)(int, void*), void *, int,
9618556Sbde		      _BSD_VA_LIST_));
971541Srgrimesvoid	log __P((int, const char *, ...));
9813697Sgibbsint	printf __P((const char *, ...));
9913446Sphkint	sprintf __P((char *buf, const char *, ...));
1002112Swollmanvoid	uprintf __P((const char *, ...));
10118556Sbdevoid	vprintf __P((const char *, _BSD_VA_LIST_));
1021541Srgrimesvoid	ttyprintf __P((struct tty *, const char *, ...));
1031541Srgrimes
1048215Sdgvoid	bcopy __P((const void *from, void *to, size_t len));
1058215Sdgvoid	ovbcopy __P((const void *from, void *to, size_t len));
10613414Sphkextern void	(*bzero) __P((void *buf, size_t len));
1071541Srgrimes
1088215Sdgvoid	*memcpy __P((void *to, const void *from, size_t len));
1098215Sdg
11013456Sbdeint	copystr __P((const void *kfaddr, void *kdaddr, size_t len,
11113456Sbde		size_t *lencopied));
11213456Sbdeint	copyinstr __P((const void *udaddr, void *kaddr, size_t len,
11313456Sbde		size_t *lencopied));
11413456Sbdeint	copyin __P((const void *udaddr, void *kaddr, size_t len));
11513456Sbdeint	copyout __P((const void *kaddr, void *udaddr, size_t len));
1161541Srgrimes
11713456Sbdeint	fubyte __P((const void *base));
11813456Sbdeint	fuibyte __P((const void *base));
1191541Srgrimesint	subyte __P((void *base, int byte));
1201541Srgrimesint	suibyte __P((void *base, int byte));
12113456Sbdeint	fuword __P((const void *base));
1221541Srgrimesint	suword __P((void *base, int word));
1236358Sphkint	susword __P((void *base, int word));
1241541Srgrimes
12526259Speterstruct timeval;
1261541Srgrimesint	hzto __P((struct timeval *tv));
1271541Srgrimesvoid	realitexpire __P((void *));
1281541Srgrimes
1291541Srgrimesstruct clockframe;
1301541Srgrimesvoid	hardclock __P((struct clockframe *frame));
1311541Srgrimesvoid	softclock __P((void));
1321541Srgrimesvoid	statclock __P((struct clockframe *frame));
1331541Srgrimes
1341541Srgrimesvoid	startprofclock __P((struct proc *));
1351541Srgrimesvoid	stopprofclock __P((struct proc *));
1361541Srgrimesvoid	setstatclockrate __P((int hzrate));
1371541Srgrimes
1383484Sphkvoid	hardupdate __P((long));
13921101Sjhayvoid	hardpps __P((struct timeval *tvp, long usec));
14021101Sjhay
1417109Sphk#include <sys/libkern.h>
1422112Swollman
1432112Swollman/* Initialize the world */
1442112Swollmanextern void consinit(void);
1452112Swollmanextern void usrinfoinit(void);
1462112Swollmanextern void cpu_initclocks(void);
1472112Swollmanextern void vntblinit(void);
1482112Swollmanextern void nchinit(void);
1492112Swollman
1507090Sbde/* Finalize the world. */
1517090Sbdevoid	shutdown_nice __P((void));
1527090Sbde
1537090Sbde/*
1547090Sbde * Kernel to clock driver interface.
1557090Sbde */
1567090Sbdevoid	inittodr __P((time_t base));
1577090Sbdevoid	resettodr __P((void));
1587090Sbdevoid	startrtclock __P((void));
1597090Sbde
1602112Swollman/* Timeouts */
1612112Swollmantypedef void (timeout_t)(void *); /* actual timeout function type */
1622112Swollmantypedef timeout_t *timeout_func_t; /* a pointer to this type */
1632112Swollman
1642112Swollmanvoid timeout(timeout_func_t, void *, int);
1652112Swollmanvoid untimeout(timeout_func_t, void *);
1663484Sphkvoid	logwakeup __P((void));
1672165Spaul
16826312Speter/* Interrupt management */
16926312Spetervoid		setdelayed(void);
17026312Spetervoid		setsoftast(void);
17126312Spetervoid		setsoftclock(void);
17226312Spetervoid		setsoftnet(void);
17326312Spetervoid		setsofttty(void);
17426312Spetervoid		schedsoftnet(void);
17526312Spetervoid		schedsofttty(void);
17626312Spetervoid		spl0(void);
17726312Speterintrmask_t	softclockpending(void);
17826312Speterintrmask_t	splbio(void);
17926312Speterintrmask_t	splclock(void);
18026312Speterintrmask_t	splhigh(void);
18126312Speterintrmask_t	splimp(void);
18226312Speterintrmask_t	splnet(void);
18326312Speterintrmask_t	splsoftclock(void);
18426312Speterintrmask_t	splsofttty(void);
18526312Speterintrmask_t	splstatclock(void);
18626312Speterintrmask_t	spltty(void);
18726312Speterintrmask_t	splvm(void);
18826312Spetervoid		splx(intrmask_t ipl);
18926312Spetervoid		splz(void);
19026312Speter
19126312Speter/*
19226312Speter * XXX It's not clear how "machine independent" these will be yet, but
19326312Speter * they are used all over the place especially in pci drivers.  We would
19426312Speter * have to modify lots of drivers since <machine/cpufunc.h> no longer
19526312Speter * implicitly causes these to be defined when it #included <machine/spl.h>
19626312Speter */
19726312Speterextern intrmask_t bio_imask;	/* group of interrupts masked with splbio() */
19826312Speterextern intrmask_t net_imask;	/* group of interrupts masked with splimp() */
19926312Speterextern intrmask_t stat_imask;	/* interrupts masked with splstatclock() */
20026312Speterextern intrmask_t tty_imask;	/* group of interrupts masked with spltty() */
20126312Speter
20226312Speter/* Read only */
20327585Sbdeextern const intrmask_t soft_imask;    /* interrupts masked with splsoft*() */
20426312Speterextern const intrmask_t softnet_imask; /* interrupt masked with splnet() */
20526312Speterextern const intrmask_t softtty_imask; /* interrupt masked with splsofttty() */
20626312Speter
20717658Sjulian/* Various other callout lists that modules might want to know about */
20817768Sjulian/* shutdown callout list definitions */
20917658Sjuliantypedef void (*bootlist_fn)(int,void *);
21017768Sjulianint at_shutdown(bootlist_fn function, void *arg, int);
21117658Sjulianint rm_at_shutdown(bootlist_fn function, void *arg);
21217768Sjulian#define SHUTDOWN_PRE_SYNC 0
21317768Sjulian#define SHUTDOWN_POST_SYNC 1
21417658Sjulian
21517658Sjulian/* forking */ /* XXX not yet */
21617658Sjuliantypedef void (*forklist_fn)(struct proc *parent,struct proc *child,int flags);
21717658Sjulianint at_fork(forklist_fn function);
21817658Sjulianint rm_at_fork(forklist_fn function);
21917658Sjulian
22017658Sjulian/* exiting */
22117658Sjuliantypedef void (*exitlist_fn)(struct proc *procp);
22217658Sjulianint at_exit(exitlist_fn function);
22317658Sjulianint rm_at_exit(exitlist_fn function);
22417658Sjulian
22518884Sbde/*
22618884Sbde * Common `proc' functions are declared here so that proc.h can be included
22718884Sbde * less often.
22818884Sbde */
22918884Sbdeint	tsleep __P((void *chan, int pri, char *wmesg, int timo));
23018884Sbdevoid	wakeup __P((void *chan));
23118884Sbde
2322865Sbde#endif /* !_SYS_SYSTM_H_ */
233