systm.h revision 61033
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 3950477Speter * $FreeBSD: head/sys/sys/systm.h 61033 2000-05-28 15:45:30Z dfr $ 401541Srgrimes */ 411541Srgrimes 422165Spaul#ifndef _SYS_SYSTM_H_ 432865Sbde#define _SYS_SYSTM_H_ 442165Spaul 4549043Salc#include <machine/atomic.h> 461549Srgrimes#include <machine/cpufunc.h> 4729683Sgibbs#include <sys/callout.h> 481549Srgrimes 4918883Sbdeextern int securelevel; /* system security level (see init(8)) */ 507090Sbde 517090Sbdeextern int cold; /* nonzero if we are doing a cold boot */ 521541Srgrimesextern const char *panicstr; /* panic message */ 5331337Sbdeextern int safepri; /* safe ipl when cold or panicing */ 541541Srgrimesextern char version[]; /* system version */ 551541Srgrimesextern char copyright[]; /* system copyright */ 561541Srgrimes 571541Srgrimesextern int nswap; /* size of swap space */ 581541Srgrimes 591541Srgrimesextern int selwait; /* select timeout address */ 601541Srgrimes 611541Srgrimesextern u_char curpriority; /* priority of current process */ 621541Srgrimes 631541Srgrimesextern int physmem; /* physical memory */ 641541Srgrimes 651541Srgrimesextern dev_t dumpdev; /* dump device */ 661541Srgrimesextern long dumplo; /* offset into dumpdev */ 671541Srgrimes 681541Srgrimesextern dev_t rootdev; /* root device */ 6936809Sbdeextern dev_t rootdevs[2]; /* possible root devices */ 7036809Sbdeextern char *rootdevnames[2]; /* names of possible root devices */ 711541Srgrimesextern struct vnode *rootvp; /* vnode equivalent to above */ 721541Srgrimes 731541Srgrimesextern int boothowto; /* reboot flags, from console subsystem */ 7415113Sbdeextern int bootverbose; /* nonzero to print verbose messages */ 751541Srgrimes 7642453Seivind#ifdef INVARIANTS /* The option is always available */ 7742453Seivind#define KASSERT(exp,msg) do { if (!(exp)) panic msg; } while (0) 7857294Sbde#define SPLASSERT(level, msg) __CONCAT(__CONCAT(spl,level),assert)(msg) 7958283Sps#define CONDSPLASSERT(cond, level, msg) do { \ 8058283Sps if (cond) \ 8158283Sps SPLASSERT(level, msg); \ 8258283Sps} while (0) 8342408Seivind#else 8442453Seivind#define KASSERT(exp,msg) 8558283Sps#define SPLASSERT(level, msg) 8658283Sps#define CONDSPLASSERT(cond, level, msg) 8742408Seivind#endif 8842408Seivind 891541Srgrimes/* 901541Srgrimes * General function declarations. 911541Srgrimes */ 9230282Sphk 9333777Sbdestruct clockframe; 9430282Sphkstruct malloc_type; 9533777Sbdestruct proc; 9633777Sbdestruct timeval; 9733777Sbdestruct tty; 9833777Sbdestruct uio; 9930282Sphk 10016875Sbdevoid Debugger __P((const char *msg)); 1011541Srgrimesint nullop __P((void)); 1021541Srgrimesint eopnotsupp __P((void)); 10314508Shsuint einval __P((void)); 1041541Srgrimesint seltrue __P((dev_t dev, int which, struct proc *p)); 1053304Sphkint ureadc __P((int, struct uio *)); 10630282Sphkvoid *hashinit __P((int count, struct malloc_type *type, u_long *hashmask)); 10730282Sphkvoid *phashinit __P((int count, struct malloc_type *type, u_long *nentries)); 1081541Srgrimes 10917975Sbdevoid cpu_boot __P((int)); 11029683Sgibbsvoid cpu_rootconf __P((void)); 1111541Srgrimesvoid tablefull __P((const char *)); 11237614Sbdeint addlog __P((const char *, ...)) __printflike(1, 2); 11318556Sbdeint kvprintf __P((char const *, void (*)(int, void*), void *, int, 11437614Sbde _BSD_VA_LIST_)) __printflike(1, 0); 11549047Sdfrint log __P((int, const char *, ...)) __printflike(2, 3); 11629509Sbdevoid logwakeup __P((void)); 11737614Sbdeint printf __P((const char *, ...)) __printflike(1, 2); 11841479Sarchieint snprintf __P((char *, size_t, const char *, ...)) __printflike(3, 4); 11937614Sbdeint sprintf __P((char *buf, const char *, ...)) __printflike(2, 3); 12049047Sdfrint uprintf __P((const char *, ...)) __printflike(1, 2); 12149047Sdfrint vprintf __P((const char *, _BSD_VA_LIST_)) __printflike(1, 0); 12241479Sarchieint vsnprintf __P((char *, size_t, const char *, _BSD_VA_LIST_)) __printflike(3, 0); 12338874Sacheint vsprintf __P((char *buf, const char *, _BSD_VA_LIST_)) __printflike(2, 0); 12449047Sdfrint ttyprintf __P((struct tty *, const char *, ...)) __printflike(2, 3); 12542680Smsmithint sscanf __P((const char *, char const *, ...)); 12642680Smsmithint vsscanf __P((const char *, char const *, _BSD_VA_LIST_)); 12754216Sarchielong strtol __P((const char *, char **, int)); 12854216Sarchieu_long strtoul __P((const char *, char **, int)); 12954216Sarchiequad_t strtoq __P((const char *, char **, int)); 13054216Sarchieu_quad_t strtouq __P((const char *, char **, int)); 1311541Srgrimes 1328215Sdgvoid bcopy __P((const void *from, void *to, size_t len)); 1338215Sdgvoid ovbcopy __P((const void *from, void *to, size_t len)); 13456079Sjmb 13536735Sdfr#ifdef __i386__ 13613414Sphkextern void (*bzero) __P((void *buf, size_t len)); 13736735Sdfr#else 13836735Sdfrvoid bzero __P((void *buf, size_t len)); 13936735Sdfr#endif 1401541Srgrimes 1418215Sdgvoid *memcpy __P((void *to, const void *from, size_t len)); 1428215Sdg 14313456Sbdeint copystr __P((const void *kfaddr, void *kdaddr, size_t len, 14413456Sbde size_t *lencopied)); 14513456Sbdeint copyinstr __P((const void *udaddr, void *kaddr, size_t len, 14613456Sbde size_t *lencopied)); 14713456Sbdeint copyin __P((const void *udaddr, void *kaddr, size_t len)); 14813456Sbdeint copyout __P((const void *kaddr, void *udaddr, size_t len)); 1491541Srgrimes 15013456Sbdeint fubyte __P((const void *base)); 1511541Srgrimesint subyte __P((void *base, int byte)); 1521541Srgrimesint suibyte __P((void *base, int byte)); 15336735Sdfrlong fuword __P((const void *base)); 15436735Sdfrint suword __P((void *base, long word)); 15544495Sbdeint fusword __P((void *base)); 15644495Sbdeint susword __P((void *base, int word)); 1571541Srgrimes 1581541Srgrimesvoid realitexpire __P((void *)); 1591541Srgrimes 1601541Srgrimesvoid hardclock __P((struct clockframe *frame)); 16132390Sphkvoid softclock __P((void)); 1621541Srgrimesvoid statclock __P((struct clockframe *frame)); 1631541Srgrimes 1641541Srgrimesvoid startprofclock __P((struct proc *)); 1651541Srgrimesvoid stopprofclock __P((struct proc *)); 1661541Srgrimesvoid setstatclockrate __P((int hzrate)); 1671541Srgrimes 16840096Smsmithchar *getenv __P((char *name)); 16942706Smsmithint getenv_int __P((char *name, int *data)); 17052946Smjacobquad_t getenv_quad __P((char *name, quad_t *data)); 17140096Smsmithextern char *kern_envp; 17240096Smsmith 17331960Snate#ifdef APM_FIXUP_CALLTODO 17431960Snatevoid adjust_timeout_calltodo __P((struct timeval *time_change)); 17531960Snate#endif /* APM_FIXUP_CALLTODO */ 17631960Snate 1777109Sphk#include <sys/libkern.h> 1782112Swollman 1792112Swollman/* Initialize the world */ 18029509Sbdevoid consinit __P((void)); 18129509Sbdevoid cpu_initclocks __P((void)); 18229509Sbdevoid nchinit __P((void)); 18329509Sbdevoid usrinfoinit __P((void)); 18429509Sbdevoid vntblinit __P((void)); 1852112Swollman 1867090Sbde/* Finalize the world. */ 1877090Sbdevoid shutdown_nice __P((void)); 1887090Sbde 1897090Sbde/* 1907090Sbde * Kernel to clock driver interface. 1917090Sbde */ 1927090Sbdevoid inittodr __P((time_t base)); 1937090Sbdevoid resettodr __P((void)); 1947090Sbdevoid startrtclock __P((void)); 1957090Sbde 1962112Swollman/* Timeouts */ 19729509Sbdetypedef void timeout_t __P((void *)); /* timeout function type */ 19829683Sgibbs#define CALLOUT_HANDLE_INITIALIZER(handle) \ 19929683Sgibbs { NULL } 2002112Swollman 20129683Sgibbsvoid callout_handle_init __P((struct callout_handle *)); 20229683Sgibbsstruct callout_handle timeout __P((timeout_t *, void *, int)); 20329683Sgibbsvoid untimeout __P((timeout_t *, void *, struct callout_handle)); 2042165Spaul 20538130Sbde/* Interrupt management */ 20638130Sbde 20757294Sbde/* 20857294Sbde * For the alpha arch, some of these functions are static __inline, and 20957294Sbde * the others should be. 21057294Sbde */ 21136735Sdfr#ifdef __i386__ 21238130Sbdevoid setdelayed __P((void)); 21338130Sbdevoid setsoftast __P((void)); 21438130Sbdevoid setsoftcambio __P((void)); 21538130Sbdevoid setsoftcamnet __P((void)); 21638130Sbdevoid setsoftclock __P((void)); 21738130Sbdevoid setsoftnet __P((void)); 21838130Sbdevoid setsofttty __P((void)); 21938130Sbdevoid setsoftvm __P((void)); 22061033Sdfrvoid setsofttq __P((void)); 22138130Sbdevoid schedsoftcamnet __P((void)); 22238130Sbdevoid schedsoftcambio __P((void)); 22338130Sbdevoid schedsoftnet __P((void)); 22438130Sbdevoid schedsofttty __P((void)); 22538130Sbdevoid schedsoftvm __P((void)); 22661033Sdfrvoid schedsofttq __P((void)); 22738130Sbdeintrmask_t softclockpending __P((void)); 22838130Sbdevoid spl0 __P((void)); 22938130Sbdeintrmask_t splbio __P((void)); 23038130Sbdeintrmask_t splcam __P((void)); 23138130Sbdeintrmask_t splclock __P((void)); 23238130Sbdeintrmask_t splhigh __P((void)); 23338130Sbdeintrmask_t splimp __P((void)); 23438130Sbdeintrmask_t splnet __P((void)); 23538130Sbdeintrmask_t splsoftcam __P((void)); 23638130Sbdeintrmask_t splsoftcambio __P((void)); 23738130Sbdeintrmask_t splsoftcamnet __P((void)); 23838130Sbdeintrmask_t splsoftclock __P((void)); 23938130Sbdeintrmask_t splsofttty __P((void)); 24038130Sbdeintrmask_t splsoftvm __P((void)); 24161033Sdfrintrmask_t splsofttq __P((void)); 24238130Sbdeintrmask_t splstatclock __P((void)); 24338130Sbdeintrmask_t spltty __P((void)); 24438130Sbdeintrmask_t splvm __P((void)); 24538130Sbdevoid splx __P((intrmask_t ipl)); 24638130Sbdevoid splz __P((void)); 24738130Sbde#endif /* __i386__ */ 24826312Speter 24936735Sdfr#ifdef __alpha__ 25036735Sdfr#include <machine/ipl.h> 25136735Sdfr#endif 25236735Sdfr 25357294Sbde#ifdef INVARIANT_SUPPORT 25457294Sbdevoid splbioassert __P((const char *msg)); 25557294Sbdevoid splcamassert __P((const char *msg)); 25657294Sbdevoid splclockassert __P((const char *msg)); 25757294Sbdevoid splhighassert __P((const char *msg)); 25857294Sbdevoid splimpassert __P((const char *msg)); 25957294Sbdevoid splnetassert __P((const char *msg)); 26057294Sbdevoid splsoftcamassert __P((const char *msg)); 26157294Sbdevoid splsoftcambioassert __P((const char *msg)); 26257294Sbdevoid splsoftcamnetassert __P((const char *msg)); 26357294Sbdevoid splsoftclockassert __P((const char *msg)); 26457294Sbdevoid splsoftttyassert __P((const char *msg)); 26557294Sbdevoid splsoftvmassert __P((const char *msg)); 26657294Sbdevoid splstatclockassert __P((const char *msg)); 26757294Sbdevoid splttyassert __P((const char *msg)); 26857294Sbdevoid splvmassert __P((const char *msg)); 26957294Sbde#endif /* INVARIANT_SUPPORT */ 27057294Sbde 27126312Speter/* 27226312Speter * XXX It's not clear how "machine independent" these will be yet, but 27326312Speter * they are used all over the place especially in pci drivers. We would 27426312Speter * have to modify lots of drivers since <machine/cpufunc.h> no longer 27526312Speter * implicitly causes these to be defined when it #included <machine/spl.h> 27626312Speter */ 27726312Speterextern intrmask_t bio_imask; /* group of interrupts masked with splbio() */ 27829683Sgibbsextern intrmask_t cam_imask; /* group of interrupts masked with splcam() */ 27926312Speterextern intrmask_t net_imask; /* group of interrupts masked with splimp() */ 28026312Speterextern intrmask_t stat_imask; /* interrupts masked with splstatclock() */ 28126312Speterextern intrmask_t tty_imask; /* group of interrupts masked with spltty() */ 28226312Speter 28326312Speter/* Read only */ 28427585Sbdeextern const intrmask_t soft_imask; /* interrupts masked with splsoft*() */ 28526312Speterextern const intrmask_t softnet_imask; /* interrupt masked with splnet() */ 28626312Speterextern const intrmask_t softtty_imask; /* interrupt masked with splsofttty() */ 28726312Speter 28829509Sbde/* 28929509Sbde * Various callout lists. 29029509Sbde */ 29117658Sjulian 29229509Sbde/* Exit callout list declarations. */ 29329509Sbdetypedef void (*exitlist_fn) __P((struct proc *procp)); 29417658Sjulian 29529509Sbdeint at_exit __P((exitlist_fn function)); 29629509Sbdeint rm_at_exit __P((exitlist_fn function)); 29717658Sjulian 29829509Sbde/* Fork callout list declarations. */ 29929509Sbdetypedef void (*forklist_fn) __P((struct proc *parent, struct proc *child, 30029509Sbde int flags)); 30127997Sjulian 30229509Sbdeint at_fork __P((forklist_fn function)); 30329509Sbdeint rm_at_fork __P((forklist_fn function)); 30427997Sjulian 30529509Sbde/* 30629509Sbde * Not exactly a callout LIST, but a callout entry. 30729509Sbde * Allow an external module to define a hardware watchdog tickler. 30829509Sbde * Normally a process would do this, but there are times when the 30929509Sbde * kernel needs to be able to hold off the watchdog, when the process 31029509Sbde * is not active, e.g., when dumping core. 31129509Sbde */ 31229509Sbdetypedef void (*watchdog_tickle_fn) __P((void)); 31329509Sbde 31429509Sbdeextern watchdog_tickle_fn wdog_tickler; 31529509Sbde 31618884Sbde/* 31718884Sbde * Common `proc' functions are declared here so that proc.h can be included 31818884Sbde * less often. 31918884Sbde */ 32031333Sbdeint tsleep __P((void *chan, int pri, const char *wmesg, int timo)); 32141971Sdillonint asleep __P((void *chan, int pri, const char *wmesg, int timo)); 32241971Sdillonint await __P((int pri, int timo)); 32318884Sbdevoid wakeup __P((void *chan)); 32454471Sgreenvoid wakeup_one __P((void *chan)); 32518884Sbde 32647028Sphk/* 32747028Sphk * Common `dev_t' stuff are declared here to avoid #include poisoning 32847028Sphk */ 32947028Sphk 33047028Sphkint major(dev_t x); 33147028Sphkint minor(dev_t x); 33247028Sphkdev_t makedev(int x, int y); 33347028Sphkudev_t dev2udev(dev_t x); 33447028Sphkdev_t udev2dev(udev_t x, int b); 33547028Sphkint uminor(udev_t dev); 33647028Sphkint umajor(udev_t dev); 33748859Sphkudev_t makeudev(int x, int y); 3382865Sbde#endif /* !_SYS_SYSTM_H_ */ 339