systm.h revision 27997
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 3927997Sjulian * $Id: systm.h,v 1.54 1997/08/09 00:04:06 dyson 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)); 12327993Sdysonint fusword __P((void *base)); 1246358Sphkint susword __P((void *base, int word)); 1251541Srgrimes 12626259Speterstruct timeval; 1271541Srgrimesint hzto __P((struct timeval *tv)); 1281541Srgrimesvoid realitexpire __P((void *)); 1291541Srgrimes 1301541Srgrimesstruct clockframe; 1311541Srgrimesvoid hardclock __P((struct clockframe *frame)); 1321541Srgrimesvoid softclock __P((void)); 1331541Srgrimesvoid statclock __P((struct clockframe *frame)); 1341541Srgrimes 1351541Srgrimesvoid startprofclock __P((struct proc *)); 1361541Srgrimesvoid stopprofclock __P((struct proc *)); 1371541Srgrimesvoid setstatclockrate __P((int hzrate)); 1381541Srgrimes 1393484Sphkvoid hardupdate __P((long)); 14021101Sjhayvoid hardpps __P((struct timeval *tvp, long usec)); 14121101Sjhay 1427109Sphk#include <sys/libkern.h> 1432112Swollman 1442112Swollman/* Initialize the world */ 1452112Swollmanextern void consinit(void); 1462112Swollmanextern void usrinfoinit(void); 1472112Swollmanextern void cpu_initclocks(void); 1482112Swollmanextern void vntblinit(void); 1492112Swollmanextern void nchinit(void); 1502112Swollman 1517090Sbde/* Finalize the world. */ 1527090Sbdevoid shutdown_nice __P((void)); 1537090Sbde 1547090Sbde/* 1557090Sbde * Kernel to clock driver interface. 1567090Sbde */ 1577090Sbdevoid inittodr __P((time_t base)); 1587090Sbdevoid resettodr __P((void)); 1597090Sbdevoid startrtclock __P((void)); 1607090Sbde 1612112Swollman/* Timeouts */ 1622112Swollmantypedef void (timeout_t)(void *); /* actual timeout function type */ 1632112Swollmantypedef timeout_t *timeout_func_t; /* a pointer to this type */ 1642112Swollman 1652112Swollmanvoid timeout(timeout_func_t, void *, int); 1662112Swollmanvoid untimeout(timeout_func_t, void *); 1673484Sphkvoid logwakeup __P((void)); 1682165Spaul 16926312Speter/* Interrupt management */ 17026312Spetervoid setdelayed(void); 17126312Spetervoid setsoftast(void); 17226312Spetervoid setsoftclock(void); 17326312Spetervoid setsoftnet(void); 17426312Spetervoid setsofttty(void); 17526312Spetervoid schedsoftnet(void); 17626312Spetervoid schedsofttty(void); 17726312Spetervoid spl0(void); 17826312Speterintrmask_t softclockpending(void); 17926312Speterintrmask_t splbio(void); 18026312Speterintrmask_t splclock(void); 18126312Speterintrmask_t splhigh(void); 18226312Speterintrmask_t splimp(void); 18326312Speterintrmask_t splnet(void); 18426312Speterintrmask_t splsoftclock(void); 18526312Speterintrmask_t splsofttty(void); 18626312Speterintrmask_t splstatclock(void); 18726312Speterintrmask_t spltty(void); 18826312Speterintrmask_t splvm(void); 18926312Spetervoid splx(intrmask_t ipl); 19026312Spetervoid splz(void); 19126312Speter 19226312Speter/* 19326312Speter * XXX It's not clear how "machine independent" these will be yet, but 19426312Speter * they are used all over the place especially in pci drivers. We would 19526312Speter * have to modify lots of drivers since <machine/cpufunc.h> no longer 19626312Speter * implicitly causes these to be defined when it #included <machine/spl.h> 19726312Speter */ 19826312Speterextern intrmask_t bio_imask; /* group of interrupts masked with splbio() */ 19926312Speterextern intrmask_t net_imask; /* group of interrupts masked with splimp() */ 20026312Speterextern intrmask_t stat_imask; /* interrupts masked with splstatclock() */ 20126312Speterextern intrmask_t tty_imask; /* group of interrupts masked with spltty() */ 20226312Speter 20326312Speter/* Read only */ 20427585Sbdeextern const intrmask_t soft_imask; /* interrupts masked with splsoft*() */ 20526312Speterextern const intrmask_t softnet_imask; /* interrupt masked with splnet() */ 20626312Speterextern const intrmask_t softtty_imask; /* interrupt masked with splsofttty() */ 20726312Speter 20817658Sjulian/* Various other callout lists that modules might want to know about */ 20917768Sjulian/* shutdown callout list definitions */ 21017658Sjuliantypedef void (*bootlist_fn)(int,void *); 21117768Sjulianint at_shutdown(bootlist_fn function, void *arg, int); 21217658Sjulianint rm_at_shutdown(bootlist_fn function, void *arg); 21317768Sjulian#define SHUTDOWN_PRE_SYNC 0 21417768Sjulian#define SHUTDOWN_POST_SYNC 1 21517658Sjulian 21617658Sjulian/* forking */ /* XXX not yet */ 21717658Sjuliantypedef void (*forklist_fn)(struct proc *parent,struct proc *child,int flags); 21817658Sjulianint at_fork(forklist_fn function); 21917658Sjulianint rm_at_fork(forklist_fn function); 22017658Sjulian 22117658Sjulian/* exiting */ 22217658Sjuliantypedef void (*exitlist_fn)(struct proc *procp); 22317658Sjulianint at_exit(exitlist_fn function); 22417658Sjulianint rm_at_exit(exitlist_fn function); 22517658Sjulian 22627997Sjulian/* Not exactly a callout LIST, but a callout entry.. */ 22727997Sjulian/* Allow an external module to define a hardware watchdog tickler */ 22827997Sjulian/* Normally a process would do this, but there are times when the */ 22927997Sjulian/* kernel needs to be able to hold off the watchdog, when the process */ 23027997Sjulian/* is not active, e.g. when dumping core. Costs us a whole 4 bytes to */ 23127997Sjulian/* make this generic. the variable is in kern_shutdown.c */ 23227997Sjuliantypedef void (*watchdog_tickle_fn)(void); 23327997Sjulianextern watchdog_tickle_fn wdog_tickler; 23427997Sjulian 23527997Sjulian 23618884Sbde/* 23718884Sbde * Common `proc' functions are declared here so that proc.h can be included 23818884Sbde * less often. 23918884Sbde */ 24018884Sbdeint tsleep __P((void *chan, int pri, char *wmesg, int timo)); 24118884Sbdevoid wakeup __P((void *chan)); 24218884Sbde 2432865Sbde#endif /* !_SYS_SYSTM_H_ */ 244