1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 #ifndef __SYSTM_H__
41 #define __SYSTM_H__
42
43 #include <sys/queue.h>
44 #include <sys/stdarg.h>
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73 extern int securelevel;
74 extern const char *panicstr;
75 extern const char version[];
76 extern const char copyright[];
77 extern const char ostype[];
78 extern const char osversion[];
79 extern const char osrelease[];
80 extern int cold;
81
82 extern int ncpus;
83 extern int nblkdev;
84 extern int nchrdev;
85
86 extern int selwait;
87
88 #ifdef MULTIPROCESSOR
89 #define curpriority (curcpu()->ci_schedstate.spc_curpriority)
90 #else
91 extern u_char curpriority;
92 #endif
93
94 extern int maxmem;
95 extern int physmem;
96
97 extern dev_t dumpdev;
98 extern long dumplo;
99
100 extern dev_t rootdev;
101 extern struct vnode *rootvp;
102
103 extern dev_t swapdev;
104 extern struct vnode *swapdev_vp;
105
106 struct proc;
107
108 typedef int sy_call_t(struct proc *, void *, register_t *);
109
110 extern struct sysent {
111 short sy_narg;
112 short sy_argsize;
113 sy_call_t *sy_call;
114 } sysent[];
115 #if _BYTE_ORDER == _BIG_ENDIAN
116 #define SCARG(p, k) ((p)->k.be.datum)
117 #elif _BYTE_ORDER == _LITTLE_ENDIAN
118 #define SCARG(p, k) ((p)->k.le.datum)
119 #else
120 #error "what byte order is this machine?"
121 #endif
122
123 #if defined(_KERNEL) && defined(SYSCALL_DEBUG)
124 void scdebug_call(struct proc *p, register_t code, register_t retval[]);
125 void scdebug_ret(struct proc *p, register_t code, int error, register_t retval[]);
126 #endif
127
128 extern int boothowto;
129
130 extern void (*v_putc)(int);
131
132
133
134
135 int nullop(void *);
136 int enodev(void);
137 int enosys(void);
138 int enoioctl(void);
139 int enxio(void);
140 int eopnotsupp(void *);
141
142 int lkmenodev(void);
143
144 struct vnodeopv_desc;
145 void vfs_opv_init(void);
146 void vfs_opv_init_explicit(struct vnodeopv_desc *);
147 void vfs_opv_init_default(struct vnodeopv_desc *);
148 void vfs_op_init(void);
149
150 int seltrue(dev_t dev, int which, struct proc *);
151 void *hashinit(int, int, int, u_long *);
152 int sys_nosys(struct proc *, void *, register_t *);
153
154 void panic(const char *, ...)
155 __attribute__((__noreturn__,__format__(__kprintf__,1,2)));
156 void __assert(const char *, const char *, int, const char *)
157 __attribute__((__noreturn__));
158 int printf(const char *, ...)
159 __attribute__((__format__(__kprintf__,1,2)));
160 void uprintf(const char *, ...)
161 __attribute__((__format__(__kprintf__,1,2)));
162 int vprintf(const char *, va_list);
163 int vsnprintf(char *, size_t, const char *, va_list);
164 int snprintf(char *buf, size_t, const char *, ...)
165 __attribute__((__format__(__kprintf__,3,4)));
166 struct tty;
167 void ttyprintf(struct tty *, const char *, ...)
168 __attribute__((__format__(__kprintf__,2,3)));
169
170 void splassert_fail(int, int, const char *);
171 extern int splassert_ctl;
172
173 void tablefull(const char *);
174
175 int kcopy(const void *, void *, size_t)
176 __attribute__ ((__bounded__(__buffer__,1,3)))
177 __attribute__ ((__bounded__(__buffer__,2,3)));
178
179 void bcopy(const void *, void *, size_t)
180 __attribute__ ((__bounded__(__buffer__,1,3)))
181 __attribute__ ((__bounded__(__buffer__,2,3)));
182 void ovbcopy(const void *, void *, size_t)
183 __attribute__ ((__bounded__(__buffer__,1,3)))
184 __attribute__ ((__bounded__(__buffer__,2,3)));
185 void bzero(void *, size_t)
186 __attribute__ ((__bounded__(__buffer__,1,2)));
187 int bcmp(const void *, const void *, size_t);
188 void *memcpy(void *, const void *, size_t)
189 __attribute__ ((__bounded__(__buffer__,1,3)))
190 __attribute__ ((__bounded__(__buffer__,2,3)));
191 void *memmove(void *, const void *, size_t)
192 __attribute__ ((__bounded__(__buffer__,1,3)))
193 __attribute__ ((__bounded__(__buffer__,2,3)));
194 void *memset(void *, int, size_t)
195 __attribute__ ((__bounded__(__buffer__,1,3)));
196
197 int copystr(const void *, void *, size_t, size_t *)
198 __attribute__ ((__bounded__(__string__,2,3)));
199 int copyinstr(const void *, void *, size_t, size_t *)
200 __attribute__ ((__bounded__(__string__,2,3)));
201 int copyoutstr(const void *, void *, size_t, size_t *);
202 int copyin(const void *, void *, size_t)
203 __attribute__ ((__bounded__(__buffer__,2,3)));
204 int copyout(const void *, void *, size_t);
205
206 struct timeval;
207 int hzto(struct timeval *);
208 int tvtohz(struct timeval *);
209 void realitexpire(void *);
210
211 struct clockframe;
212 void hardclock(struct clockframe *);
213 void softclock(void);
214 void statclock(struct clockframe *);
215
216 void initclocks(void);
217 void inittodr(time_t);
218 void resettodr(void);
219 void cpu_initclocks(void);
220
221 void startprofclock(struct proc *);
222 void stopprofclock(struct proc *);
223 void setstatclockrate(int);
224
225 void wdog_register(void *, int (*)(void *, int));
226
227
228
229
230
231
232
233
234
235 struct hook_desc {
236 TAILQ_ENTRY(hook_desc) hd_list;
237 void (*hd_fn)(void *);
238 void *hd_arg;
239 };
240 TAILQ_HEAD(hook_desc_head, hook_desc);
241
242 extern struct hook_desc_head shutdownhook_list, startuphook_list,
243 mountroothook_list;
244
245 void *hook_establish(struct hook_desc_head *, int, void (*)(void *), void *);
246 void hook_disestablish(struct hook_desc_head *, void *);
247 void dohooks(struct hook_desc_head *, int);
248
249 #define HOOK_REMOVE 0x01
250 #define HOOK_FREE 0x02
251
252 #define startuphook_establish(fn, arg) \
253 hook_establish(&startuphook_list, 1, (fn), (arg))
254 #define startuphook_disestablish(vhook) \
255 hook_disestablish(&startuphook_list, (vhook))
256 #define dostartuphooks() dohooks(&startuphook_list, HOOK_REMOVE|HOOK_FREE)
257
258 #define shutdownhook_establish(fn, arg) \
259 hook_establish(&shutdownhook_list, 0, (fn), (arg))
260 #define shutdownhook_disestablish(vhook) \
261 hook_disestablish(&shutdownhook_list, (vhook))
262 #define doshutdownhooks() dohooks(&shutdownhook_list, HOOK_REMOVE)
263
264 #define mountroothook_establish(fn, arg) \
265 hook_establish(&mountroothook_list, 0, (fn), (arg))
266 #define mountroothook_disestablish(vhook) \
267 hook_disestablish(&mountroothook_list, (vhook))
268 #define domountroothooks() dohooks(&mountroothook_list, HOOK_REMOVE|HOOK_FREE)
269
270
271
272
273 void *powerhook_establish(void (*)(int, void *), void *);
274 void powerhook_disestablish(void *);
275 void dopowerhooks(int);
276 #define PWR_RESUME 0
277 #define PWR_SUSPEND 1
278 #define PWR_STANDBY 2
279
280 struct uio;
281 int uiomove(void *, int, struct uio *);
282
283 #if defined(_KERNEL)
284 int setjmp(label_t *);
285 void longjmp(label_t *);
286 #endif
287
288 void consinit(void);
289
290 void cpu_startup(void);
291 void cpu_configure(void);
292 void diskconf(void);
293
294 #ifdef GPROF
295 void kmstartup(void);
296 #endif
297
298 int nfs_mountroot(void);
299 int dk_mountroot(void);
300 extern int (*mountroot)(void);
301
302 #include <lib/libkern/libkern.h>
303
304 #if defined(DDB) || defined(KGDB)
305
306 void Debugger(void);
307 int read_symtab_from_file(struct proc *,struct vnode *,const char *);
308 #endif
309
310 #ifdef BOOT_CONFIG
311 void user_config(void);
312 #endif
313
314 #if defined(MULTIPROCESSOR)
315 void _kernel_lock_init(void);
316 void _kernel_lock(void);
317 void _kernel_unlock(void);
318 void _kernel_proc_lock(struct proc *);
319 void _kernel_proc_unlock(struct proc *);
320
321 #define KERNEL_LOCK_INIT() _kernel_lock_init()
322 #define KERNEL_LOCK() _kernel_lock()
323 #define KERNEL_UNLOCK() _kernel_unlock()
324 #define KERNEL_PROC_LOCK(p) _kernel_proc_lock((p))
325 #define KERNEL_PROC_UNLOCK(p) _kernel_proc_unlock((p))
326
327 #else
328
329 #define KERNEL_LOCK_INIT()
330 #define KERNEL_LOCK()
331 #define KERNEL_UNLOCK()
332 #define KERNEL_PROC_LOCK(p)
333 #define KERNEL_PROC_UNLOCK(p)
334
335 #endif
336
337 #endif