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.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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.
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
38 * @(#)systm.h 8.7 (Berkeley) 3/29/95
39 * $FreeBSD: src/sys/sys/systm.h,v 1.111.2.18 2002/12/17 18:04:02 sam Exp $
40 * $DragonFly: src/sys/sys/systm.h,v 1.6 2003/06/25 03:56:10 dillon Exp $
46 #include <machine/atomic.h>
47 #include <machine/cpufunc.h>
48 #include <sys/callout.h>
50 extern int securelevel; /* system security level (see init(8)) */
52 extern int cold; /* nonzero if we are doing a cold boot */
53 extern const char *panicstr; /* panic message */
54 extern int dumping; /* system is dumping */
55 extern int safepri; /* safe ipl when cold or panicing */
56 extern char version[]; /* system version */
57 extern char copyright[]; /* system copyright */
59 extern int nswap; /* size of swap space */
61 extern int selwait; /* select timeout address */
63 extern u_char curpriority; /* priority of current process */
65 extern int physmem; /* physical memory */
67 extern dev_t dumpdev; /* dump device */
68 extern long dumplo; /* offset into dumpdev */
70 extern dev_t rootdev; /* root device */
71 extern dev_t rootdevs[2]; /* possible root devices */
72 extern char *rootdevnames[2]; /* names of possible root devices */
73 extern struct vnode *rootvp; /* vnode equivalent to above */
75 extern int boothowto; /* reboot flags, from console subsystem */
76 extern int bootverbose; /* nonzero to print verbose messages */
78 extern int maxusers; /* system tune hint */
80 #ifdef INVARIANTS /* The option is always available */
81 #define KASSERT(exp,msg) do { if (!(exp)) panic msg; } while (0)
82 #define KKASSERT(exp) if (!(exp)) panic("assertion: " #exp " in " __FUNCTION__)
83 #define SPLASSERT(level, msg) __CONCAT(__CONCAT(spl,level),assert)(msg)
84 #define CONDSPLASSERT(cond, level, msg) do { \
86 SPLASSERT(level, msg); \
89 #define KASSERT(exp,msg)
91 #define SPLASSERT(level, msg)
92 #define CONDSPLASSERT(cond, level, msg)
96 * General function declarations.
109 void Debugger __P((const char *msg));
110 void mi_gdinit __P((struct globaldata *gd, int cpu));
111 int dumpstatus __P((vm_offset_t addr, off_t count));
112 int nullop __P((void));
113 int eopnotsupp __P((void));
114 int einval __P((void));
115 int seltrue __P((dev_t dev, int which, struct thread *td));
116 int ureadc __P((int, struct uio *));
117 void *hashinit __P((int count, struct malloc_type *type, u_long *hashmask));
118 void *phashinit __P((int count, struct malloc_type *type, u_long *nentries));
120 void cpu_boot __P((int));
121 void cpu_rootconf __P((void));
122 extern uint32_t crc32_tab[];
123 uint32_t crc32(const void *buf, size_t size);
124 void init_param1 __P((void));
125 void init_param2 __P((int physpages));
126 void tablefull __P((const char *));
127 int addlog __P((const char *, ...)) __printflike(1, 2);
128 int kvprintf __P((char const *, void (*)(int, void*), void *, int,
129 _BSD_VA_LIST_)) __printflike(1, 0);
130 int log __P((int, const char *, ...)) __printflike(2, 3);
131 void logwakeup __P((void));
132 void log_console __P((struct uio *));
133 int printf __P((const char *, ...)) __printflike(1, 2);
134 int snprintf __P((char *, size_t, const char *, ...)) __printflike(3, 4);
135 int sprintf __P((char *buf, const char *, ...)) __printflike(2, 3);
136 int uprintf __P((const char *, ...)) __printflike(1, 2);
137 int vprintf __P((const char *, _BSD_VA_LIST_)) __printflike(1, 0);
138 int vsnprintf __P((char *, size_t, const char *, _BSD_VA_LIST_)) __printflike(3, 0);
139 int vsprintf __P((char *buf, const char *, _BSD_VA_LIST_)) __printflike(2, 0);
140 int ttyprintf __P((struct tty *, const char *, ...)) __printflike(2, 3);
141 int sscanf __P((const char *, char const *, ...));
142 int vsscanf __P((const char *, char const *, _BSD_VA_LIST_));
143 long strtol __P((const char *, char **, int));
144 u_long strtoul __P((const char *, char **, int));
145 quad_t strtoq __P((const char *, char **, int));
146 u_quad_t strtouq __P((const char *, char **, int));
148 void bcopy __P((const void *from, void *to, size_t len));
149 void ovbcopy __P((const void *from, void *to, size_t len));
152 extern void (*bzero) __P((void *buf, size_t len));
154 void bzero __P((void *buf, size_t len));
157 void *memcpy __P((void *to, const void *from, size_t len));
159 int copystr __P((const void *kfaddr, void *kdaddr, size_t len,
161 int copyinstr __P((const void *udaddr, void *kaddr, size_t len,
163 int copyin __P((const void *udaddr, void *kaddr, size_t len));
164 int copyout __P((const void *kaddr, void *udaddr, size_t len));
166 int fubyte __P((const void *base));
167 int subyte __P((void *base, int byte));
168 int suibyte __P((void *base, int byte));
169 long fuword __P((const void *base));
170 int suword __P((void *base, long word));
171 int fusword __P((void *base));
172 int susword __P((void *base, int word));
174 void realitexpire __P((void *));
176 void hardclock __P((struct clockframe *frame));
177 void softclock __P((void));
178 void statclock __P((struct clockframe *frame));
180 void startprofclock __P((struct proc *));
181 void stopprofclock __P((struct proc *));
182 void setstatclockrate __P((int hzrate));
184 char *getenv __P((const char *name));
185 #define testenv getenv
187 int getenv_int __P((const char *name, int *data));
188 int getenv_string __P((const char *name, char *data, int size));
189 int getenv_quad __P((const char *name, quad_t *data));
190 extern char *kern_envp;
192 #ifdef APM_FIXUP_CALLTODO
193 void adjust_timeout_calltodo __P((struct timeval *time_change));
194 #endif /* APM_FIXUP_CALLTODO */
196 #include <sys/libkern.h>
198 /* Initialize the world */
199 void consinit __P((void));
200 void cpu_initclocks __P((void));
201 void nchinit __P((void));
202 void usrinfoinit __P((void));
203 void vntblinit __P((void));
205 /* Finalize the world. */
206 void shutdown_nice __P((int));
209 * Kernel to clock driver interface.
211 void inittodr __P((time_t base));
212 void resettodr __P((void));
213 void startrtclock __P((void));
216 typedef void timeout_t __P((void *)); /* timeout function type */
217 #define CALLOUT_HANDLE_INITIALIZER(handle) \
220 void callout_handle_init __P((struct callout_handle *));
221 struct callout_handle timeout __P((timeout_t *, void *, int));
222 void untimeout __P((timeout_t *, void *, struct callout_handle));
224 /* Interrupt management */
227 * For the alpha arch, some of these functions are static __inline, and
228 * the others should be.
231 void setdelayed __P((void));
232 void setsoftast __P((void));
233 void setsoftcambio __P((void));
234 void setsoftcamnet __P((void));
235 void setsoftclock __P((void));
236 void setsoftcrypto __P((void));
237 void setsoftnet __P((void));
238 void setsofttty __P((void));
239 void setsoftvm __P((void));
240 void setsofttq __P((void));
241 void schedsoftcamnet __P((void));
242 void schedsoftcambio __P((void));
243 void schedsoftnet __P((void));
244 void schedsofttty __P((void));
245 void schedsoftvm __P((void));
246 void schedsofttq __P((void));
247 intrmask_t softclockpending __P((void));
248 void spl0 __P((void));
249 intrmask_t splbio __P((void));
250 intrmask_t splcam __P((void));
251 intrmask_t splclock __P((void));
252 intrmask_t splcrypto __P((void));
253 intrmask_t splhigh __P((void));
254 intrmask_t splimp __P((void));
255 intrmask_t splnet __P((void));
256 intrmask_t splsoftcam __P((void));
257 intrmask_t splsoftcambio __P((void));
258 intrmask_t splsoftcamnet __P((void));
259 intrmask_t splsoftclock __P((void));
260 intrmask_t splsofttty __P((void));
261 intrmask_t splsoftvm __P((void));
262 intrmask_t splsofttq __P((void));
263 intrmask_t splstatclock __P((void));
264 intrmask_t spltty __P((void));
265 intrmask_t splvm __P((void));
266 void splx __P((intrmask_t ipl));
267 void splz __P((void));
268 #endif /* __i386__ */
271 #include <machine/ipl.h>
274 #ifdef INVARIANT_SUPPORT
275 void splbioassert __P((const char *msg));
276 void splcamassert __P((const char *msg));
277 void splclockassert __P((const char *msg));
278 void splcryptoassert __P((const char *msg));
279 void splhighassert __P((const char *msg));
280 void splimpassert __P((const char *msg));
281 void splnetassert __P((const char *msg));
282 void splsoftcamassert __P((const char *msg));
283 void splsoftcambioassert __P((const char *msg));
284 void splsoftcamnetassert __P((const char *msg));
285 void splsoftclockassert __P((const char *msg));
286 void splsoftttyassert __P((const char *msg));
287 void splsoftvmassert __P((const char *msg));
288 void splsofttqassert __P((const char *msg));
289 void splstatclockassert __P((const char *msg));
290 void splttyassert __P((const char *msg));
291 void splvmassert __P((const char *msg));
292 #endif /* INVARIANT_SUPPORT */
295 * XXX It's not clear how "machine independent" these will be yet, but
296 * they are used all over the place especially in pci drivers. We would
297 * have to modify lots of drivers since <machine/cpufunc.h> no longer
298 * implicitly causes these to be defined when it #included <machine/spl.h>
300 extern intrmask_t bio_imask; /* group of interrupts masked with splbio() */
301 extern intrmask_t cam_imask; /* group of interrupts masked with splcam() */
302 extern intrmask_t net_imask; /* group of interrupts masked with splimp() */
303 extern intrmask_t stat_imask; /* interrupts masked with splstatclock() */
304 extern intrmask_t tty_imask; /* group of interrupts masked with spltty() */
307 extern const intrmask_t soft_imask; /* interrupts masked with splsoft*() */
308 extern const intrmask_t softnet_imask; /* interrupt masked with splnet() */
309 extern const intrmask_t softtty_imask; /* interrupt masked with splsofttty() */
312 * Various callout lists.
315 /* Exit callout list declarations. */
316 typedef void (*exitlist_fn) __P((struct thread *td));
318 int at_exit __P((exitlist_fn function));
319 int rm_at_exit __P((exitlist_fn function));
321 /* Fork callout list declarations. */
322 typedef void (*forklist_fn) __P((struct proc *parent, struct proc *child,
325 int at_fork __P((forklist_fn function));
326 int rm_at_fork __P((forklist_fn function));
329 * Not exactly a callout LIST, but a callout entry.
330 * Allow an external module to define a hardware watchdog tickler.
331 * Normally a process would do this, but there are times when the
332 * kernel needs to be able to hold off the watchdog, when the process
333 * is not active, e.g., when dumping core.
335 typedef void (*watchdog_tickle_fn) __P((void));
337 extern watchdog_tickle_fn wdog_tickler;
340 * Common `proc' functions are declared here so that proc.h can be included
343 int tsleep __P((void *chan, int pri, const char *wmesg, int timo));
344 int xsleep __P((struct xwait *w, int pri, const char *wmesg, int timo, int *gen));
345 void xwakeup __P((struct xwait *w));
346 void xwait_init __P((struct xwait *w));
347 void wakeup __P((void *chan));
348 void wakeup_one __P((void *chan));
351 * Common `dev_t' stuff are declared here to avoid #include poisoning
356 dev_t makedev(int x, int y);
357 udev_t dev2udev(dev_t x);
358 dev_t udev2dev(udev_t x, int b);
359 int uminor(udev_t dev);
360 int umajor(udev_t dev);
361 udev_t makeudev(int x, int y);
362 #endif /* !_SYS_SYSTM_H_ */