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