FreeBSD/Linux Kernel Cross Reference
sys/sys/systm.h
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$
40 */
41
42 #ifndef _SYS_SYSTM_H_
43 #define _SYS_SYSTM_H_
44
45 #include <machine/cpufunc.h>
46 #include <sys/callout.h>
47
48 extern int securelevel; /* system security level (see init(8)) */
49
50 extern int cold; /* nonzero if we are doing a cold boot */
51 extern const char *panicstr; /* panic message */
52 extern int safepri; /* safe ipl when cold or panicing */
53 extern char version[]; /* system version */
54 extern char copyright[]; /* system copyright */
55
56 extern int nblkdev; /* number of entries in bdevsw */
57 extern int nchrdev; /* number of entries in cdevsw */
58 extern int nswap; /* size of swap space */
59
60 extern int selwait; /* select timeout address */
61
62 extern u_char curpriority; /* priority of current process */
63
64 extern int physmem; /* physical memory */
65
66 extern dev_t dumpdev; /* dump device */
67 extern long dumplo; /* offset into dumpdev */
68
69 extern dev_t rootdev; /* root device */
70 extern dev_t rootdevs[2]; /* possible root devices */
71 extern char *rootdevnames[2]; /* names of possible root devices */
72 extern struct vnode *rootvp; /* vnode equivalent to above */
73
74 extern struct vnode *swapdev_vp;/* vnode for swap device */
75
76 extern int boothowto; /* reboot flags, from console subsystem */
77 extern int bootverbose; /* nonzero to print verbose messages */
78
79 #ifdef INVARIANTS /* The option is always available */
80 #define KASSERT(exp,msg) do { if (!(exp)) panic msg; } while (0)
81 #else
82 #define KASSERT(exp,msg)
83 #endif
84
85 /*
86 * General function declarations.
87 */
88
89 struct clockframe;
90 struct malloc_type;
91 struct proc;
92 struct timeval;
93 struct tty;
94 struct uio;
95
96 void Debugger __P((const char *msg));
97 int nullop __P((void));
98 int eopnotsupp __P((void));
99 int einval __P((void));
100 int seltrue __P((dev_t dev, int which, struct proc *p));
101 int ureadc __P((int, struct uio *));
102 void *hashinit __P((int count, struct malloc_type *type, u_long *hashmask));
103 void *phashinit __P((int count, struct malloc_type *type, u_long *nentries));
104
105 void panic __P((const char *, ...)) __dead2 __printflike(1, 2);
106 void cpu_boot __P((int));
107 void cpu_rootconf __P((void));
108 void cpu_dumpconf __P((void));
109 void tablefull __P((const char *));
110 int addlog __P((const char *, ...)) __printflike(1, 2);
111 int kvprintf __P((char const *, void (*)(int, void*), void *, int,
112 _BSD_VA_LIST_)) __printflike(1, 0);
113 void log __P((int, const char *, ...)) __printflike(2, 3);
114 void logwakeup __P((void));
115 int printf __P((const char *, ...)) __printflike(1, 2);
116 int snprintf __P((char *, size_t, const char *, ...)) __printflike(3, 4);
117 int sprintf __P((char *buf, const char *, ...)) __printflike(2, 3);
118 void uprintf __P((const char *, ...)) __printflike(1, 2);
119 void vprintf __P((const char *, _BSD_VA_LIST_)) __printflike(1, 0);
120 int vsnprintf __P((char *, size_t, const char *, _BSD_VA_LIST_)) __printflike(3, 0);
121 int vsprintf __P((char *buf, const char *, _BSD_VA_LIST_)) __printflike(2, 0);
122 void ttyprintf __P((struct tty *, const char *, ...)) __printflike(2, 3);
123 int sscanf __P((const char *, char const *, ...));
124 int vsscanf __P((const char *, char const *, _BSD_VA_LIST_));
125 long strtol __P((const char *, char **, int));
126 u_long strtoul __P((const char *, char **, int));
127 quad_t strtoq __P((const char *, char **, int));
128 u_quad_t strtouq __P((const char *, char **, int));
129
130 void bcopy __P((const void *from, void *to, size_t len));
131 void ovbcopy __P((const void *from, void *to, size_t len));
132 #ifdef __i386__
133 extern void (*bzero) __P((void *buf, size_t len));
134 #else
135 void bzero __P((void *buf, size_t len));
136 #endif
137
138 void *memcpy __P((void *to, const void *from, size_t len));
139
140 int copystr __P((const void *kfaddr, void *kdaddr, size_t len,
141 size_t *lencopied));
142 int copyinstr __P((const void *udaddr, void *kaddr, size_t len,
143 size_t *lencopied));
144 int copyin __P((const void *udaddr, void *kaddr, size_t len));
145 int copyout __P((const void *kaddr, void *udaddr, size_t len));
146
147 int fubyte __P((const void *base));
148 int subyte __P((void *base, int byte));
149 int suibyte __P((void *base, int byte));
150 long fuword __P((const void *base));
151 int suword __P((void *base, long word));
152 long fusword __P((void *base));
153 int susword __P((void *base, long word));
154
155 void realitexpire __P((void *));
156
157 void hardclock __P((struct clockframe *frame));
158 void softclock __P((void));
159 void statclock __P((struct clockframe *frame));
160
161 void startprofclock __P((struct proc *));
162 void stopprofclock __P((struct proc *));
163 void setstatclockrate __P((int hzrate));
164
165 char *getenv __P((char *name));
166 int getenv_int __P((char *name, int *data));
167 quad_t getenv_quad __P((char *name, quad_t *data));
168 extern char *kern_envp;
169
170 #ifdef APM_FIXUP_CALLTODO
171 void adjust_timeout_calltodo __P((struct timeval *time_change));
172 #endif /* APM_FIXUP_CALLTODO */
173
174 #include <sys/libkern.h>
175
176 /* Initialize the world */
177 void consinit __P((void));
178 void cpu_initclocks __P((void));
179 void nchinit __P((void));
180 void usrinfoinit __P((void));
181 void vntblinit __P((void));
182
183 /* Finalize the world. */
184 void shutdown_nice __P((void));
185
186 /*
187 * Kernel to clock driver interface.
188 */
189 void inittodr __P((time_t base));
190 void resettodr __P((void));
191 void startrtclock __P((void));
192
193 /* Timeouts */
194 typedef void timeout_t __P((void *)); /* timeout function type */
195 #define CALLOUT_HANDLE_INITIALIZER(handle) \
196 { NULL }
197
198 void callout_handle_init __P((struct callout_handle *));
199 struct callout_handle timeout __P((timeout_t *, void *, int));
200 void untimeout __P((timeout_t *, void *, struct callout_handle));
201
202 /* Interrupt management */
203
204 #ifdef __i386__
205 void setdelayed __P((void));
206 void setsoftast __P((void));
207 void setsoftcambio __P((void));
208 void setsoftcamnet __P((void));
209 void setsoftclock __P((void));
210 void setsoftnet __P((void));
211 void setsofttty __P((void));
212 void setsoftvm __P((void));
213 void schedsoftcamnet __P((void));
214 void schedsoftcambio __P((void));
215 void schedsoftnet __P((void));
216 void schedsofttty __P((void));
217 void schedsoftvm __P((void));
218 intrmask_t softclockpending __P((void));
219 void spl0 __P((void));
220 intrmask_t splbio __P((void));
221 intrmask_t splcam __P((void));
222 intrmask_t splclock __P((void));
223 intrmask_t splhigh __P((void));
224 intrmask_t splimp __P((void));
225 intrmask_t splnet __P((void));
226 #ifdef SMP
227 intrmask_t splq __P((intrmask_t mask));
228 #endif
229 intrmask_t splsoftcam __P((void));
230 intrmask_t splsoftcambio __P((void));
231 intrmask_t splsoftcamnet __P((void));
232 intrmask_t splsoftclock __P((void));
233 intrmask_t splsofttty __P((void));
234 intrmask_t splsoftvm __P((void));
235 intrmask_t splstatclock __P((void));
236 intrmask_t spltty __P((void));
237 intrmask_t splvm __P((void));
238 void splx __P((intrmask_t ipl));
239 void splz __P((void));
240 #endif /* __i386__ */
241
242 #ifdef __alpha__
243 #include <machine/ipl.h>
244 #endif
245
246 /*
247 * XXX It's not clear how "machine independent" these will be yet, but
248 * they are used all over the place especially in pci drivers. We would
249 * have to modify lots of drivers since <machine/cpufunc.h> no longer
250 * implicitly causes these to be defined when it #included <machine/spl.h>
251 */
252 extern intrmask_t bio_imask; /* group of interrupts masked with splbio() */
253 extern intrmask_t cam_imask; /* group of interrupts masked with splcam() */
254 extern intrmask_t net_imask; /* group of interrupts masked with splimp() */
255 extern intrmask_t stat_imask; /* interrupts masked with splstatclock() */
256 extern intrmask_t tty_imask; /* group of interrupts masked with spltty() */
257
258 /* Read only */
259 extern const intrmask_t soft_imask; /* interrupts masked with splsoft*() */
260 extern const intrmask_t softnet_imask; /* interrupt masked with splnet() */
261 extern const intrmask_t softtty_imask; /* interrupt masked with splsofttty() */
262
263 /*
264 * Various callout lists.
265 */
266
267 /* Exit callout list declarations. */
268 typedef void (*exitlist_fn) __P((struct proc *procp));
269
270 int at_exit __P((exitlist_fn function));
271 int rm_at_exit __P((exitlist_fn function));
272
273 /* Fork callout list declarations. */
274 typedef void (*forklist_fn) __P((struct proc *parent, struct proc *child,
275 int flags));
276
277 int at_fork __P((forklist_fn function));
278 int rm_at_fork __P((forklist_fn function));
279
280 /* Shutdown callout list definitions and declarations. */
281 #define SHUTDOWN_PRE_SYNC 0
282 #define SHUTDOWN_POST_SYNC 1
283 #define SHUTDOWN_FINAL 2
284 #define SHUTDOWN_PRI_FIRST 0
285 #define SHUTDOWN_PRI_DEFAULT 10000
286 #define SHUTDOWN_PRI_LAST 20000
287
288 typedef void (*bootlist_fn) __P((int, void *));
289
290 int at_shutdown __P((bootlist_fn function, void *arg, int position));
291 int at_shutdown_pri __P((bootlist_fn function, void *arg, int position, int pri));
292 int rm_at_shutdown __P((bootlist_fn function, void *arg));
293
294 /*
295 * Not exactly a callout LIST, but a callout entry.
296 * Allow an external module to define a hardware watchdog tickler.
297 * Normally a process would do this, but there are times when the
298 * kernel needs to be able to hold off the watchdog, when the process
299 * is not active, e.g., when dumping core.
300 */
301 typedef void (*watchdog_tickle_fn) __P((void));
302
303 extern watchdog_tickle_fn wdog_tickler;
304
305 /*
306 * Common `proc' functions are declared here so that proc.h can be included
307 * less often.
308 */
309 int tsleep __P((void *chan, int pri, const char *wmesg, int timo));
310 int asleep __P((void *chan, int pri, const char *wmesg, int timo));
311 int await __P((int pri, int timo));
312 void wakeup __P((void *chan));
313
314 #endif /* !_SYS_SYSTM_H_ */
Cache object: 9f78874d15f0342e1a1b0d3f17beb972
|