Initial import from FreeBSD RELENG_4:
[dragonfly.git] / sys / sys / systm.h
CommitLineData
984263bc
MD
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: src/sys/sys/systm.h,v 1.111.2.18 2002/12/17 18:04:02 sam Exp $
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 int safepri; /* safe ipl when cold or panicing */
55extern char version[]; /* system version */
56extern char copyright[]; /* system copyright */
57
58extern int nswap; /* size of swap space */
59
60extern int selwait; /* select timeout address */
61
62extern u_char curpriority; /* priority of current process */
63
64extern int physmem; /* physical memory */
65
66extern dev_t dumpdev; /* dump device */
67extern long dumplo; /* offset into dumpdev */
68
69extern dev_t rootdev; /* root device */
70extern dev_t rootdevs[2]; /* possible root devices */
71extern char *rootdevnames[2]; /* names of possible root devices */
72extern struct vnode *rootvp; /* vnode equivalent to above */
73
74extern int boothowto; /* reboot flags, from console subsystem */
75extern int bootverbose; /* nonzero to print verbose messages */
76
77extern int maxusers; /* system tune hint */
78
79#ifdef INVARIANTS /* The option is always available */
80#define KASSERT(exp,msg) do { if (!(exp)) panic msg; } while (0)
81#define SPLASSERT(level, msg) __CONCAT(__CONCAT(spl,level),assert)(msg)
82#define CONDSPLASSERT(cond, level, msg) do { \
83 if (cond) \
84 SPLASSERT(level, msg); \
85} while (0)
86#else
87#define KASSERT(exp,msg)
88#define SPLASSERT(level, msg)
89#define CONDSPLASSERT(cond, level, msg)
90#endif
91
92/*
93 * General function declarations.
94 */
95
96struct clockframe;
97struct malloc_type;
98struct proc;
99struct timeval;
100struct tty;
101struct uio;
102
103void Debugger __P((const char *msg));
104int dumpstatus __P((vm_offset_t addr, off_t count));
105int nullop __P((void));
106int eopnotsupp __P((void));
107int einval __P((void));
108int seltrue __P((dev_t dev, int which, struct proc *p));
109int ureadc __P((int, struct uio *));
110void *hashinit __P((int count, struct malloc_type *type, u_long *hashmask));
111void *phashinit __P((int count, struct malloc_type *type, u_long *nentries));
112
113void cpu_boot __P((int));
114void cpu_rootconf __P((void));
115extern uint32_t crc32_tab[];
116uint32_t crc32(const void *buf, size_t size);
117void init_param1 __P((void));
118void init_param2 __P((int physpages));
119void tablefull __P((const char *));
120int addlog __P((const char *, ...)) __printflike(1, 2);
121int kvprintf __P((char const *, void (*)(int, void*), void *, int,
122 _BSD_VA_LIST_)) __printflike(1, 0);
123int log __P((int, const char *, ...)) __printflike(2, 3);
124void logwakeup __P((void));
125void log_console __P((struct uio *));
126int printf __P((const char *, ...)) __printflike(1, 2);
127int snprintf __P((char *, size_t, const char *, ...)) __printflike(3, 4);
128int sprintf __P((char *buf, const char *, ...)) __printflike(2, 3);
129int uprintf __P((const char *, ...)) __printflike(1, 2);
130int vprintf __P((const char *, _BSD_VA_LIST_)) __printflike(1, 0);
131int vsnprintf __P((char *, size_t, const char *, _BSD_VA_LIST_)) __printflike(3, 0);
132int vsprintf __P((char *buf, const char *, _BSD_VA_LIST_)) __printflike(2, 0);
133int ttyprintf __P((struct tty *, const char *, ...)) __printflike(2, 3);
134int sscanf __P((const char *, char const *, ...));
135int vsscanf __P((const char *, char const *, _BSD_VA_LIST_));
136long strtol __P((const char *, char **, int));
137u_long strtoul __P((const char *, char **, int));
138quad_t strtoq __P((const char *, char **, int));
139u_quad_t strtouq __P((const char *, char **, int));
140
141void bcopy __P((const void *from, void *to, size_t len));
142void ovbcopy __P((const void *from, void *to, size_t len));
143
144#ifdef __i386__
145extern void (*bzero) __P((void *buf, size_t len));
146#else
147void bzero __P((void *buf, size_t len));
148#endif
149
150void *memcpy __P((void *to, const void *from, size_t len));
151
152int copystr __P((const void *kfaddr, void *kdaddr, size_t len,
153 size_t *lencopied));
154int copyinstr __P((const void *udaddr, void *kaddr, size_t len,
155 size_t *lencopied));
156int copyin __P((const void *udaddr, void *kaddr, size_t len));
157int copyout __P((const void *kaddr, void *udaddr, size_t len));
158
159int fubyte __P((const void *base));
160int subyte __P((void *base, int byte));
161int suibyte __P((void *base, int byte));
162long fuword __P((const void *base));
163int suword __P((void *base, long word));
164int fusword __P((void *base));
165int susword __P((void *base, int word));
166
167void realitexpire __P((void *));
168
169void hardclock __P((struct clockframe *frame));
170void softclock __P((void));
171void statclock __P((struct clockframe *frame));
172
173void startprofclock __P((struct proc *));
174void stopprofclock __P((struct proc *));
175void setstatclockrate __P((int hzrate));
176
177char *getenv __P((const char *name));
178#define testenv getenv
179#define freeenv
180int getenv_int __P((const char *name, int *data));
181int getenv_string __P((const char *name, char *data, int size));
182int getenv_quad __P((const char *name, quad_t *data));
183extern char *kern_envp;
184
185#ifdef APM_FIXUP_CALLTODO
186void adjust_timeout_calltodo __P((struct timeval *time_change));
187#endif /* APM_FIXUP_CALLTODO */
188
189#include <sys/libkern.h>
190
191/* Initialize the world */
192void consinit __P((void));
193void cpu_initclocks __P((void));
194void nchinit __P((void));
195void usrinfoinit __P((void));
196void vntblinit __P((void));
197
198/* Finalize the world. */
199void shutdown_nice __P((int));
200
201/*
202 * Kernel to clock driver interface.
203 */
204void inittodr __P((time_t base));
205void resettodr __P((void));
206void startrtclock __P((void));
207
208/* Timeouts */
209typedef void timeout_t __P((void *)); /* timeout function type */
210#define CALLOUT_HANDLE_INITIALIZER(handle) \
211 { NULL }
212
213void callout_handle_init __P((struct callout_handle *));
214struct callout_handle timeout __P((timeout_t *, void *, int));
215void untimeout __P((timeout_t *, void *, struct callout_handle));
216
217/* Interrupt management */
218
219/*
220 * For the alpha arch, some of these functions are static __inline, and
221 * the others should be.
222 */
223#ifdef __i386__
224void setdelayed __P((void));
225void setsoftast __P((void));
226void setsoftcambio __P((void));
227void setsoftcamnet __P((void));
228void setsoftclock __P((void));
229void setsoftcrypto __P((void));
230void setsoftnet __P((void));
231void setsofttty __P((void));
232void setsoftvm __P((void));
233void setsofttq __P((void));
234void schedsoftcamnet __P((void));
235void schedsoftcambio __P((void));
236void schedsoftnet __P((void));
237void schedsofttty __P((void));
238void schedsoftvm __P((void));
239void schedsofttq __P((void));
240intrmask_t softclockpending __P((void));
241void spl0 __P((void));
242intrmask_t splbio __P((void));
243intrmask_t splcam __P((void));
244intrmask_t splclock __P((void));
245intrmask_t splcrypto __P((void));
246intrmask_t splhigh __P((void));
247intrmask_t splimp __P((void));
248intrmask_t splnet __P((void));
249intrmask_t splsoftcam __P((void));
250intrmask_t splsoftcambio __P((void));
251intrmask_t splsoftcamnet __P((void));
252intrmask_t splsoftclock __P((void));
253intrmask_t splsofttty __P((void));
254intrmask_t splsoftvm __P((void));
255intrmask_t splsofttq __P((void));
256intrmask_t splstatclock __P((void));
257intrmask_t spltty __P((void));
258intrmask_t splvm __P((void));
259void splx __P((intrmask_t ipl));
260void splz __P((void));
261#endif /* __i386__ */
262
263#ifdef __alpha__
264#include <machine/ipl.h>
265#endif
266
267#ifdef INVARIANT_SUPPORT
268void splbioassert __P((const char *msg));
269void splcamassert __P((const char *msg));
270void splclockassert __P((const char *msg));
271void splcryptoassert __P((const char *msg));
272void splhighassert __P((const char *msg));
273void splimpassert __P((const char *msg));
274void splnetassert __P((const char *msg));
275void splsoftcamassert __P((const char *msg));
276void splsoftcambioassert __P((const char *msg));
277void splsoftcamnetassert __P((const char *msg));
278void splsoftclockassert __P((const char *msg));
279void splsoftttyassert __P((const char *msg));
280void splsoftvmassert __P((const char *msg));
281void splsofttqassert __P((const char *msg));
282void splstatclockassert __P((const char *msg));
283void splttyassert __P((const char *msg));
284void splvmassert __P((const char *msg));
285#endif /* INVARIANT_SUPPORT */
286
287/*
288 * XXX It's not clear how "machine independent" these will be yet, but
289 * they are used all over the place especially in pci drivers. We would
290 * have to modify lots of drivers since <machine/cpufunc.h> no longer
291 * implicitly causes these to be defined when it #included <machine/spl.h>
292 */
293extern intrmask_t bio_imask; /* group of interrupts masked with splbio() */
294extern intrmask_t cam_imask; /* group of interrupts masked with splcam() */
295extern intrmask_t net_imask; /* group of interrupts masked with splimp() */
296extern intrmask_t stat_imask; /* interrupts masked with splstatclock() */
297extern intrmask_t tty_imask; /* group of interrupts masked with spltty() */
298
299/* Read only */
300extern const intrmask_t soft_imask; /* interrupts masked with splsoft*() */
301extern const intrmask_t softnet_imask; /* interrupt masked with splnet() */
302extern const intrmask_t softtty_imask; /* interrupt masked with splsofttty() */
303
304/*
305 * Various callout lists.
306 */
307
308/* Exit callout list declarations. */
309typedef void (*exitlist_fn) __P((struct proc *procp));
310
311int at_exit __P((exitlist_fn function));
312int rm_at_exit __P((exitlist_fn function));
313
314/* Fork callout list declarations. */
315typedef void (*forklist_fn) __P((struct proc *parent, struct proc *child,
316 int flags));
317
318int at_fork __P((forklist_fn function));
319int rm_at_fork __P((forklist_fn function));
320
321/*
322 * Not exactly a callout LIST, but a callout entry.
323 * Allow an external module to define a hardware watchdog tickler.
324 * Normally a process would do this, but there are times when the
325 * kernel needs to be able to hold off the watchdog, when the process
326 * is not active, e.g., when dumping core.
327 */
328typedef void (*watchdog_tickle_fn) __P((void));
329
330extern watchdog_tickle_fn wdog_tickler;
331
332/*
333 * Common `proc' functions are declared here so that proc.h can be included
334 * less often.
335 */
336int tsleep __P((void *chan, int pri, const char *wmesg, int timo));
337int asleep __P((void *chan, int pri, const char *wmesg, int timo));
338int await __P((int pri, int timo));
339void wakeup __P((void *chan));
340void wakeup_one __P((void *chan));
341
342/*
343 * Common `dev_t' stuff are declared here to avoid #include poisoning
344 */
345
346int major(dev_t x);
347int minor(dev_t x);
348dev_t makedev(int x, int y);
349udev_t dev2udev(dev_t x);
350dev_t udev2dev(udev_t x, int b);
351int uminor(udev_t dev);
352int umajor(udev_t dev);
353udev_t makeudev(int x, int y);
354#endif /* !_SYS_SYSTM_H_ */