systm.h revision 79418
1/*- 2 * Copyright (c) 1982, 1988, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by the University of 21 * California, Berkeley and its contributors. 22 * 4. Neither the name of the University nor the names of its contributors 23 * may be used to endorse or promote products derived from this software 24 * without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)systm.h 8.7 (Berkeley) 3/29/95 39 * $FreeBSD: head/sys/sys/systm.h 79418 2001-07-08 04:56:07Z julian $ 40 */ 41 42#ifndef _SYS_SYSTM_H_ 43#define _SYS_SYSTM_H_ 44 45#include <machine/atomic.h> 46#include <machine/cpufunc.h> 47#include <sys/callout.h> 48 49extern int securelevel; /* system security level (see init(8)) */ 50 51extern int cold; /* nonzero if we are doing a cold boot */ 52extern const char *panicstr; /* panic message */ 53extern int dumping; /* system is dumping */ 54extern char version[]; /* system version */ 55extern char copyright[]; /* system copyright */ 56 57extern int nswap; /* size of swap space */ 58 59extern struct cv selwait; /* select conditional variable */ 60 61extern int physmem; /* physical memory */ 62 63extern dev_t dumpdev; /* dump device */ 64extern long dumplo; /* offset into dumpdev */ 65 66extern dev_t rootdev; /* root device */ 67extern dev_t rootdevs[2]; /* possible root devices */ 68extern char *rootdevnames[2]; /* names of possible root devices */ 69extern struct vnode *rootvp; /* vnode equivalent to above */ 70 71extern int boothowto; /* reboot flags, from console subsystem */ 72extern int bootverbose; /* nonzero to print verbose messages */ 73 74#ifdef INVARIANTS /* The option is always available */ 75#define KASSERT(exp,msg) do { if (!(exp)) panic msg; } while (0) 76#else 77#define KASSERT(exp,msg) 78#endif 79 80/* 81 * General function declarations. 82 */ 83 84struct clockframe; 85struct malloc_type; 86struct mtx; 87struct proc; 88struct timeval; 89struct tty; 90struct ucred; 91struct uio; 92struct _jmp_buf; 93 94int setjmp __P((struct _jmp_buf *)); 95void longjmp __P((struct _jmp_buf *, int)) __dead2; 96void Debugger __P((const char *msg)); 97int dumpstatus __P((vm_offset_t addr, long count)); 98int nullop __P((void)); 99int eopnotsupp __P((void)); 100int einval __P((void)); 101int seltrue __P((dev_t dev, int which, struct proc *p)); 102int ureadc __P((int, struct uio *)); 103void *hashinit __P((int count, struct malloc_type *type, u_long *hashmask)); 104void *phashinit __P((int count, struct malloc_type *type, u_long *nentries)); 105 106void cpu_boot __P((int)); 107void cpu_rootconf __P((void)); 108void tablefull __P((const char *)); 109int kvprintf __P((char const *, void (*)(int, void*), void *, int, 110 _BSD_VA_LIST_)) __printflike(1, 0); 111void log __P((int, const char *, ...)) __printflike(2, 3); 112void log_console __P((struct uio *)); 113int printf __P((const char *, ...)) __printflike(1, 2); 114int snprintf __P((char *, size_t, const char *, ...)) __printflike(3, 4); 115int sprintf __P((char *buf, const char *, ...)) __printflike(2, 3); 116int uprintf __P((const char *, ...)) __printflike(1, 2); 117int vprintf __P((const char *, _BSD_VA_LIST_)) __printflike(1, 0); 118int vsnprintf __P((char *, size_t, const char *, _BSD_VA_LIST_)) __printflike(3, 0); 119int vsprintf __P((char *buf, const char *, _BSD_VA_LIST_)) __printflike(2, 0); 120int ttyprintf __P((struct tty *, const char *, ...)) __printflike(2, 3); 121int sscanf __P((const char *, char const *, ...)); 122int vsscanf __P((const char *, char const *, _BSD_VA_LIST_)); 123long strtol __P((const char *, char **, int)); 124u_long strtoul __P((const char *, char **, int)); 125quad_t strtoq __P((const char *, char **, int)); 126u_quad_t strtouq __P((const char *, char **, int)); 127void tprintf __P((struct proc *p, int pri, const char *, ...)) __printflike(3, 4); 128 129void bcopy __P((const void *from, void *to, size_t len)); 130void ovbcopy __P((const void *from, void *to, size_t len)); 131 132#ifdef __i386__ 133extern void (*bzero) __P((void *buf, size_t len)); 134#else 135void bzero __P((void *buf, size_t len)); 136#endif 137 138void *memcpy __P((void *to, const void *from, size_t len)); 139 140int copystr __P((const void *kfaddr, void *kdaddr, size_t len, 141 size_t *lencopied)); 142int copyinstr __P((const void *udaddr, void *kaddr, size_t len, 143 size_t *lencopied)); 144int copyin __P((const void *udaddr, void *kaddr, size_t len)); 145int copyout __P((const void *kaddr, void *udaddr, size_t len)); 146 147int fubyte __P((const void *base)); 148int subyte __P((void *base, int byte)); 149int suibyte __P((void *base, int byte)); 150long fuword __P((const void *base)); 151int suword __P((void *base, long word)); 152int fusword __P((void *base)); 153int susword __P((void *base, int word)); 154 155void realitexpire __P((void *)); 156 157void hardclock __P((struct clockframe *frame)); 158void hardclock_process __P((struct proc *p, int user)); 159void softclock __P((void *)); 160void statclock __P((struct clockframe *frame)); 161void statclock_process __P((struct proc *p, register_t pc, int user)); 162 163void startprofclock __P((struct proc *)); 164void stopprofclock __P((struct proc *)); 165void setstatclockrate __P((int hzrate)); 166 167/* flags for suser_xxx() */ 168#define PRISON_ROOT 1 169 170int suser __P((struct proc *)); 171int suser_xxx __P((struct ucred *cred, struct proc *proc, int flag)); 172int u_cansee __P((struct ucred *u1, struct ucred *u2)); 173 174char *getenv __P((const char *name)); 175int getenv_int __P((const char *name, int *data)); 176quad_t getenv_quad __P((const char *name, quad_t *data)); 177extern char *kern_envp; 178 179#ifdef APM_FIXUP_CALLTODO 180void adjust_timeout_calltodo __P((struct timeval *time_change)); 181#endif /* APM_FIXUP_CALLTODO */ 182 183#include <sys/libkern.h> 184 185/* Initialize the world */ 186void consinit __P((void)); 187void cpu_initclocks __P((void)); 188void usrinfoinit __P((void)); 189 190/* Finalize the world. */ 191void shutdown_nice __P((int)); 192 193/* 194 * Kernel to clock driver interface. 195 */ 196void inittodr __P((time_t base)); 197void resettodr __P((void)); 198void startrtclock __P((void)); 199 200/* Timeouts */ 201typedef void timeout_t __P((void *)); /* timeout function type */ 202#define CALLOUT_HANDLE_INITIALIZER(handle) \ 203 { NULL } 204 205void callout_handle_init __P((struct callout_handle *)); 206struct callout_handle timeout __P((timeout_t *, void *, int)); 207void untimeout __P((timeout_t *, void *, struct callout_handle)); 208 209/* Stubs for obsolete functions that used to be for interrupt management */ 210static __inline void spl0(void) { return; } 211static __inline intrmask_t splbio(void) { return 0; } 212static __inline intrmask_t splcam(void) { return 0; } 213static __inline intrmask_t splclock(void) { return 0; } 214static __inline intrmask_t splhigh(void) { return 0; } 215static __inline intrmask_t splimp(void) { return 0; } 216static __inline intrmask_t splnet(void) { return 0; } 217static __inline intrmask_t splsoftcam(void) { return 0; } 218static __inline intrmask_t splsoftclock(void) { return 0; } 219static __inline intrmask_t splsofttty(void) { return 0; } 220static __inline intrmask_t splsoftvm(void) { return 0; } 221static __inline intrmask_t splsofttq(void) { return 0; } 222static __inline intrmask_t splstatclock(void) { return 0; } 223static __inline intrmask_t spltty(void) { return 0; } 224static __inline intrmask_t splvm(void) { return 0; } 225static __inline void splx(intrmask_t ipl) { return; } 226 227/* 228 * Various callout lists. 229 */ 230 231/* Exit callout list declarations. */ 232typedef void (*exitlist_fn) __P((struct proc *procp)); 233 234int at_exit __P((exitlist_fn function)); 235int rm_at_exit __P((exitlist_fn function)); 236 237/* Fork callout list declarations. */ 238typedef void (*forklist_fn) __P((struct proc *parent, struct proc *child, 239 int flags)); 240 241int at_fork __P((forklist_fn function)); 242int rm_at_fork __P((forklist_fn function)); 243 244/* 245 * Not exactly a callout LIST, but a callout entry. 246 * Allow an external module to define a hardware watchdog tickler. 247 * Normally a process would do this, but there are times when the 248 * kernel needs to be able to hold off the watchdog, when the process 249 * is not active, e.g., when dumping core. 250 */ 251typedef void (*watchdog_tickle_fn) __P((void)); 252 253extern watchdog_tickle_fn wdog_tickler; 254 255/* 256 * Common `proc' functions are declared here so that proc.h can be included 257 * less often. 258 */ 259int msleep __P((void *chan, struct mtx *mtx, int pri, const char *wmesg, 260 int timo)); 261#define tsleep(chan, pri, wmesg, timo) msleep(chan, NULL, pri, wmesg, timo) 262int asleep __P((void *chan, int pri, const char *wmesg, int timo)); 263#define await(pri, timo) mawait(NULL, pri, timo) 264int mawait __P((struct mtx *mtx, int pri, int timo)); 265void wakeup __P((void *chan)); 266void wakeup_one __P((void *chan)); 267 268/* 269 * Common `dev_t' stuff are declared here to avoid #include poisoning 270 */ 271 272int major(dev_t x); 273int minor(dev_t x); 274dev_t makedev(int x, int y); 275udev_t dev2udev(dev_t x); 276dev_t udev2dev(udev_t x, int b); 277int uminor(udev_t dev); 278int umajor(udev_t dev); 279udev_t makeudev(int x, int y); 280 281/* XXX: Should be void nanodelay(u_int nsec); */ 282void DELAY __P((int usec)); 283 284#endif /* !_SYS_SYSTM_H_ */ 285