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. Neither the name of the University nor the names of its contributors |
---|
19 | * may be used to endorse or promote products derived from this software |
---|
20 | * without specific prior written permission. |
---|
21 | * |
---|
22 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
---|
23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
---|
26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
---|
27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
---|
28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
---|
29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
---|
30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
---|
31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
---|
32 | * SUCH DAMAGE. |
---|
33 | * |
---|
34 | * @(#)systm.h 8.7 (Berkeley) 3/29/95 |
---|
35 | * $FreeBSD$ |
---|
36 | */ |
---|
37 | |
---|
38 | #ifndef _SYS_SYSTM_H_ |
---|
39 | #define _SYS_SYSTM_H_ |
---|
40 | |
---|
41 | #include <machine/atomic.h> |
---|
42 | #include <machine/cpufunc.h> |
---|
43 | #include <sys/callout.h> |
---|
44 | #include <sys/cdefs.h> |
---|
45 | #include <sys/queue.h> |
---|
46 | #include <sys/stdint.h> /* for people using printf mainly */ |
---|
47 | #ifdef __rtems__ |
---|
48 | #include <string.h> |
---|
49 | #endif /* __rtems__ */ |
---|
50 | |
---|
51 | __NULLABILITY_PRAGMA_PUSH |
---|
52 | |
---|
53 | #ifndef __rtems__ |
---|
54 | extern int cold; /* nonzero if we are doing a cold boot */ |
---|
55 | extern int suspend_blocked; /* block suspend due to pending shutdown */ |
---|
56 | extern int rebooting; /* kern_reboot() has been called. */ |
---|
57 | #else /* __rtems__ */ |
---|
58 | /* In RTEMS there is no cold boot and reboot */ |
---|
59 | #define cold 0 |
---|
60 | #define rebooting 0 |
---|
61 | #endif /* __rtems__ */ |
---|
62 | #ifndef __rtems__ |
---|
63 | extern const char *panicstr; /* panic message */ |
---|
64 | #else /* __rtems__ */ |
---|
65 | #define panicstr NULL |
---|
66 | #endif /* __rtems__ */ |
---|
67 | extern char version[]; /* system version */ |
---|
68 | extern char compiler_version[]; /* compiler version */ |
---|
69 | extern char copyright[]; /* system copyright */ |
---|
70 | extern int kstack_pages; /* number of kernel stack pages */ |
---|
71 | |
---|
72 | extern u_long pagesizes[]; /* supported page sizes */ |
---|
73 | extern long physmem; /* physical memory */ |
---|
74 | extern long realmem; /* 'real' memory */ |
---|
75 | |
---|
76 | extern char *rootdevnames[2]; /* names of possible root devices */ |
---|
77 | |
---|
78 | extern int boothowto; /* reboot flags, from console subsystem */ |
---|
79 | #ifndef __rtems__ |
---|
80 | extern int bootverbose; /* nonzero to print verbose messages */ |
---|
81 | #else /* __rtems__ */ |
---|
82 | #ifdef BOOTVERBOSE |
---|
83 | extern int bootverbose; /* nonzero to print verbose messages */ |
---|
84 | #else |
---|
85 | #define bootverbose 0 /* Remove all verbose code for the standard RTEMS build */ |
---|
86 | #endif /* BOOTVERBOSE */ |
---|
87 | #endif /* __rtems__ */ |
---|
88 | |
---|
89 | |
---|
90 | extern int maxusers; /* system tune hint */ |
---|
91 | extern int ngroups_max; /* max # of supplemental groups */ |
---|
92 | #ifndef __rtems__ |
---|
93 | extern int vm_guest; /* Running as virtual machine guest? */ |
---|
94 | #else /* __rtems__ */ |
---|
95 | #define vm_guest VM_GUEST_NO |
---|
96 | #endif /* __rtems__ */ |
---|
97 | |
---|
98 | /* |
---|
99 | * Detected virtual machine guest types. The intention is to expand |
---|
100 | * and/or add to the VM_GUEST_VM type if specific VM functionality is |
---|
101 | * ever implemented (e.g. vendor-specific paravirtualization features). |
---|
102 | * Keep in sync with vm_guest_sysctl_names[]. |
---|
103 | */ |
---|
104 | enum VM_GUEST { VM_GUEST_NO = 0, VM_GUEST_VM, VM_GUEST_XEN, VM_GUEST_HV, |
---|
105 | VM_GUEST_VMWARE, VM_GUEST_KVM, VM_LAST }; |
---|
106 | |
---|
107 | #if defined(WITNESS) || defined(INVARIANT_SUPPORT) |
---|
108 | void kassert_panic(const char *fmt, ...) __printflike(1, 2); |
---|
109 | #endif |
---|
110 | |
---|
111 | #ifdef INVARIANTS /* The option is always available */ |
---|
112 | #define KASSERT(exp,msg) do { \ |
---|
113 | if (__predict_false(!(exp))) \ |
---|
114 | kassert_panic msg; \ |
---|
115 | } while (0) |
---|
116 | #define VNASSERT(exp, vp, msg) do { \ |
---|
117 | if (__predict_false(!(exp))) { \ |
---|
118 | vn_printf(vp, "VNASSERT failed\n"); \ |
---|
119 | kassert_panic msg; \ |
---|
120 | } \ |
---|
121 | } while (0) |
---|
122 | #else |
---|
123 | #define KASSERT(exp,msg) do { \ |
---|
124 | } while (0) |
---|
125 | |
---|
126 | #define VNASSERT(exp, vp, msg) do { \ |
---|
127 | } while (0) |
---|
128 | #endif |
---|
129 | |
---|
130 | #ifndef CTASSERT /* Allow lint to override */ |
---|
131 | #define CTASSERT(x) _Static_assert(x, "compile-time assertion failed") |
---|
132 | #endif |
---|
133 | |
---|
134 | /* |
---|
135 | * Assert that a pointer can be loaded from memory atomically. |
---|
136 | * |
---|
137 | * This assertion enforces stronger alignment than necessary. For example, |
---|
138 | * on some architectures, atomicity for unaligned loads will depend on |
---|
139 | * whether or not the load spans multiple cache lines. |
---|
140 | */ |
---|
141 | #define ASSERT_ATOMIC_LOAD_PTR(var, msg) \ |
---|
142 | KASSERT(sizeof(var) == sizeof(void *) && \ |
---|
143 | ((uintptr_t)&(var) & (sizeof(void *) - 1)) == 0, msg) |
---|
144 | |
---|
145 | /* |
---|
146 | * Assert that a thread is in critical(9) section. |
---|
147 | */ |
---|
148 | #define CRITICAL_ASSERT(td) \ |
---|
149 | KASSERT((td)->td_critnest >= 1, ("Not in critical section")); |
---|
150 | |
---|
151 | /* |
---|
152 | * If we have already panic'd and this is the thread that called |
---|
153 | * panic(), then don't block on any mutexes but silently succeed. |
---|
154 | * Otherwise, the kernel will deadlock since the scheduler isn't |
---|
155 | * going to run the thread that holds any lock we need. |
---|
156 | */ |
---|
157 | #ifndef __rtems__ |
---|
158 | #define SCHEDULER_STOPPED_TD(td) ({ \ |
---|
159 | MPASS((td) == curthread); \ |
---|
160 | __predict_false((td)->td_stopsched); \ |
---|
161 | }) |
---|
162 | #else /* __rtems__ */ |
---|
163 | #define SCHEDULER_STOPPED_TD(td) 0 |
---|
164 | #endif /* __rtems__ */ |
---|
165 | #define SCHEDULER_STOPPED() SCHEDULER_STOPPED_TD(curthread) |
---|
166 | |
---|
167 | /* |
---|
168 | * Align variables. |
---|
169 | */ |
---|
170 | #define __read_mostly __section(".data.read_mostly") |
---|
171 | #define __exclusive_cache_line __aligned(CACHE_LINE_SIZE) \ |
---|
172 | __section(".data.exclusive_cache_line") |
---|
173 | /* |
---|
174 | * XXX the hints declarations are even more misplaced than most declarations |
---|
175 | * in this file, since they are needed in one file (per arch) and only used |
---|
176 | * in two files. |
---|
177 | * XXX most of these variables should be const. |
---|
178 | */ |
---|
179 | extern int osreldate; |
---|
180 | extern int envmode; |
---|
181 | extern int hintmode; /* 0 = off. 1 = config, 2 = fallback */ |
---|
182 | extern int dynamic_kenv; |
---|
183 | extern struct mtx kenv_lock; |
---|
184 | extern char *kern_envp; |
---|
185 | extern char static_env[]; |
---|
186 | extern char static_hints[]; /* by config for now */ |
---|
187 | |
---|
188 | extern char **kenvp; |
---|
189 | |
---|
190 | extern const void *zero_region; /* address space maps to a zeroed page */ |
---|
191 | |
---|
192 | extern int unmapped_buf_allowed; |
---|
193 | |
---|
194 | #ifdef __LP64__ |
---|
195 | #define IOSIZE_MAX iosize_max() |
---|
196 | #define DEVFS_IOSIZE_MAX devfs_iosize_max() |
---|
197 | #else |
---|
198 | #define IOSIZE_MAX SSIZE_MAX |
---|
199 | #define DEVFS_IOSIZE_MAX SSIZE_MAX |
---|
200 | #endif |
---|
201 | |
---|
202 | /* |
---|
203 | * General function declarations. |
---|
204 | */ |
---|
205 | |
---|
206 | struct inpcb; |
---|
207 | struct lock_object; |
---|
208 | struct malloc_type; |
---|
209 | struct mtx; |
---|
210 | struct proc; |
---|
211 | struct socket; |
---|
212 | struct thread; |
---|
213 | struct tty; |
---|
214 | struct ucred; |
---|
215 | struct uio; |
---|
216 | struct _jmp_buf; |
---|
217 | struct trapframe; |
---|
218 | struct eventtimer; |
---|
219 | |
---|
220 | #ifndef __rtems__ |
---|
221 | int setjmp(struct _jmp_buf *) __returns_twice; |
---|
222 | void longjmp(struct _jmp_buf *, int) __dead2; |
---|
223 | #endif /* __rtems__ */ |
---|
224 | int dumpstatus(vm_offset_t addr, off_t count); |
---|
225 | int nullop(void); |
---|
226 | int eopnotsupp(void); |
---|
227 | int ureadc(int, struct uio *); |
---|
228 | void hashdestroy(void *, struct malloc_type *, u_long); |
---|
229 | void *hashinit(int count, struct malloc_type *type, u_long *hashmask); |
---|
230 | void *hashinit_flags(int count, struct malloc_type *type, |
---|
231 | u_long *hashmask, int flags); |
---|
232 | #define HASH_NOWAIT 0x00000001 |
---|
233 | #define HASH_WAITOK 0x00000002 |
---|
234 | |
---|
235 | void *phashinit(int count, struct malloc_type *type, u_long *nentries); |
---|
236 | void *phashinit_flags(int count, struct malloc_type *type, u_long *nentries, |
---|
237 | int flags); |
---|
238 | void g_waitidle(void); |
---|
239 | |
---|
240 | void panic(const char *, ...) __dead2 __printflike(1, 2); |
---|
241 | void vpanic(const char *, __va_list) __dead2 __printflike(1, 0); |
---|
242 | |
---|
243 | void cpu_boot(int); |
---|
244 | void cpu_flush_dcache(void *, size_t); |
---|
245 | void cpu_rootconf(void); |
---|
246 | #ifndef __rtems__ |
---|
247 | void critical_enter(void); |
---|
248 | void critical_exit(void); |
---|
249 | #else /* __rtems__ */ |
---|
250 | #include <rtems/score/threaddispatch.h> |
---|
251 | |
---|
252 | static __inline void |
---|
253 | critical_enter(void) |
---|
254 | { |
---|
255 | _Thread_Dispatch_disable(); |
---|
256 | } |
---|
257 | |
---|
258 | static __inline void |
---|
259 | critical_exit(void) |
---|
260 | { |
---|
261 | _Thread_Dispatch_enable(_Per_CPU_Get()); |
---|
262 | } |
---|
263 | #endif /* __rtems__ */ |
---|
264 | void init_param1(void); |
---|
265 | void init_param2(long physpages); |
---|
266 | void init_static_kenv(char *, size_t); |
---|
267 | void tablefull(const char *); |
---|
268 | #ifdef EARLY_PRINTF |
---|
269 | typedef void early_putc_t(int ch); |
---|
270 | extern early_putc_t *early_putc; |
---|
271 | #endif |
---|
272 | int kvprintf(char const *, void (*)(int, void*), void *, int, |
---|
273 | __va_list) __printflike(1, 0); |
---|
274 | void log(int, const char *, ...) __printflike(2, 3); |
---|
275 | void log_console(struct uio *); |
---|
276 | void vlog(int, const char *, __va_list) __printflike(2, 0); |
---|
277 | int asprintf(char **ret, struct malloc_type *mtp, const char *format, |
---|
278 | ...) __printflike(3, 4); |
---|
279 | int printf(const char *, ...) __printflike(1, 2); |
---|
280 | int snprintf(char *, size_t, const char *, ...) __printflike(3, 4); |
---|
281 | int sprintf(char *buf, const char *, ...) __printflike(2, 3); |
---|
282 | int uprintf(const char *, ...) __printflike(1, 2); |
---|
283 | int vprintf(const char *, __va_list) __printflike(1, 0); |
---|
284 | int vasprintf(char **ret, struct malloc_type *mtp, const char *format, |
---|
285 | __va_list ap) __printflike(3, 0); |
---|
286 | int vsnprintf(char *, size_t, const char *, __va_list) __printflike(3, 0); |
---|
287 | int vsnrprintf(char *, size_t, int, const char *, __va_list) __printflike(4, 0); |
---|
288 | int vsprintf(char *buf, const char *, __va_list) __printflike(2, 0); |
---|
289 | int ttyprintf(struct tty *, const char *, ...) __printflike(2, 3); |
---|
290 | int sscanf(const char *, char const * _Nonnull, ...) __scanflike(2, 3); |
---|
291 | int vsscanf(const char * _Nonnull, char const * _Nonnull, __va_list) __scanflike(2, 0); |
---|
292 | long strtol(const char *, char **, int); |
---|
293 | u_long strtoul(const char *, char **, int); |
---|
294 | #ifndef __rtems__ |
---|
295 | quad_t strtoq(const char *, char **, int); |
---|
296 | u_quad_t strtouq(const char *, char **, int); |
---|
297 | #else /* __rtems__ */ |
---|
298 | long long strtoll(const char *, char **, int); |
---|
299 | unsigned long long strtoull(const char *, char **, int); |
---|
300 | |
---|
301 | static inline quad_t |
---|
302 | strtoq(const char *nptr, char **endptr, int base) |
---|
303 | { |
---|
304 | |
---|
305 | return (strtoll(nptr, endptr, base)); |
---|
306 | } |
---|
307 | |
---|
308 | static inline u_quad_t |
---|
309 | strtouq(const char *nptr, char **endptr, int base) |
---|
310 | { |
---|
311 | |
---|
312 | return (strtoull(nptr, endptr, base)); |
---|
313 | } |
---|
314 | #endif /* __rtems__ */ |
---|
315 | void tprintf(struct proc *p, int pri, const char *, ...) __printflike(3, 4); |
---|
316 | void vtprintf(struct proc *, int, const char *, __va_list) __printflike(3, 0); |
---|
317 | void hexdump(const void *ptr, int length, const char *hdr, int flags); |
---|
318 | #define HD_COLUMN_MASK 0xff |
---|
319 | #define HD_DELIM_MASK 0xff00 |
---|
320 | #define HD_OMIT_COUNT (1 << 16) |
---|
321 | #define HD_OMIT_HEX (1 << 17) |
---|
322 | #define HD_OMIT_CHARS (1 << 18) |
---|
323 | |
---|
324 | #define ovbcopy(f, t, l) bcopy((f), (t), (l)) |
---|
325 | #ifndef __rtems__ |
---|
326 | void bcopy(const void * _Nonnull from, void * _Nonnull to, size_t len); |
---|
327 | void bzero(void * _Nonnull buf, size_t len); |
---|
328 | #else /* __rtems__ */ |
---|
329 | #define bcopy(src, dst, len) memmove((dst), (src), (len)) |
---|
330 | #define bzero(buf, size) memset((buf), 0, (size)) |
---|
331 | #endif /* __rtems__ */ |
---|
332 | void explicit_bzero(void * _Nonnull, size_t); |
---|
333 | |
---|
334 | void *memcpy(void * _Nonnull to, const void * _Nonnull from, size_t len); |
---|
335 | void *memmove(void * _Nonnull dest, const void * _Nonnull src, size_t n); |
---|
336 | |
---|
337 | #ifndef __rtems__ |
---|
338 | int copystr(const void * _Nonnull __restrict kfaddr, |
---|
339 | void * _Nonnull __restrict kdaddr, size_t len, |
---|
340 | size_t * __restrict lencopied); |
---|
341 | int copyinstr(const void * __restrict udaddr, |
---|
342 | void * _Nonnull __restrict kaddr, size_t len, |
---|
343 | size_t * __restrict lencopied); |
---|
344 | int copyin(const void * _Nonnull __restrict udaddr, |
---|
345 | void * _Nonnull __restrict kaddr, size_t len); |
---|
346 | int copyin_nofault(const void * _Nonnull __restrict udaddr, |
---|
347 | void * _Nonnull __restrict kaddr, size_t len); |
---|
348 | int copyout(const void * _Nonnull __restrict kaddr, |
---|
349 | void * _Nonnull __restrict udaddr, size_t len); |
---|
350 | int copyout_nofault(const void * _Nonnull __restrict kaddr, |
---|
351 | void * _Nonnull __restrict udaddr, size_t len); |
---|
352 | #else /* __rtems__ */ |
---|
353 | static inline int |
---|
354 | copyinstr(const void * __restrict udaddr, void * __restrict kaddr, |
---|
355 | size_t len, size_t * __restrict lencopied) |
---|
356 | { |
---|
357 | if (lencopied != NULL) { |
---|
358 | *lencopied = len; |
---|
359 | } |
---|
360 | |
---|
361 | memcpy(kaddr, udaddr, len); |
---|
362 | |
---|
363 | return (0); |
---|
364 | } |
---|
365 | |
---|
366 | static inline int |
---|
367 | copyin(const void * __restrict udaddr, void * __restrict kaddr, |
---|
368 | size_t len) |
---|
369 | { |
---|
370 | memcpy(kaddr, udaddr, len); |
---|
371 | |
---|
372 | return (0); |
---|
373 | } |
---|
374 | |
---|
375 | static inline int |
---|
376 | copyin_nofault(const void * __restrict udaddr, void * __restrict kaddr, |
---|
377 | size_t len) |
---|
378 | { |
---|
379 | return copyin(udaddr, kaddr, len); |
---|
380 | } |
---|
381 | |
---|
382 | static inline int |
---|
383 | copyout(const void * __restrict kaddr, void * __restrict udaddr, |
---|
384 | size_t len) |
---|
385 | { |
---|
386 | memcpy(udaddr, kaddr, len); |
---|
387 | |
---|
388 | return (0); |
---|
389 | } |
---|
390 | |
---|
391 | static inline int |
---|
392 | copyout_nofault(const void * __restrict kaddr, void * __restrict udaddr, |
---|
393 | size_t len) |
---|
394 | { |
---|
395 | return copyout(kaddr, udaddr, len); |
---|
396 | } |
---|
397 | #endif /* __rtems__ */ |
---|
398 | |
---|
399 | #ifndef __rtems__ |
---|
400 | int fubyte(volatile const void *base); |
---|
401 | #else /* __rtems__ */ |
---|
402 | static inline int |
---|
403 | fubyte(const void *base) |
---|
404 | { |
---|
405 | const unsigned char *byte_base = (const unsigned char *)base; |
---|
406 | |
---|
407 | return byte_base[0]; |
---|
408 | } |
---|
409 | #endif /* __rtems__ */ |
---|
410 | long fuword(volatile const void *base); |
---|
411 | int fuword16(volatile const void *base); |
---|
412 | int32_t fuword32(volatile const void *base); |
---|
413 | int64_t fuword64(volatile const void *base); |
---|
414 | int fueword(volatile const void *base, long *val); |
---|
415 | int fueword32(volatile const void *base, int32_t *val); |
---|
416 | int fueword64(volatile const void *base, int64_t *val); |
---|
417 | int subyte(volatile void *base, int byte); |
---|
418 | int suword(volatile void *base, long word); |
---|
419 | int suword16(volatile void *base, int word); |
---|
420 | int suword32(volatile void *base, int32_t word); |
---|
421 | int suword64(volatile void *base, int64_t word); |
---|
422 | uint32_t casuword32(volatile uint32_t *base, uint32_t oldval, uint32_t newval); |
---|
423 | u_long casuword(volatile u_long *p, u_long oldval, u_long newval); |
---|
424 | int casueword32(volatile uint32_t *base, uint32_t oldval, uint32_t *oldvalp, |
---|
425 | uint32_t newval); |
---|
426 | int casueword(volatile u_long *p, u_long oldval, u_long *oldvalp, |
---|
427 | u_long newval); |
---|
428 | |
---|
429 | void realitexpire(void *); |
---|
430 | |
---|
431 | int sysbeep(int hertz, int period); |
---|
432 | |
---|
433 | void hardclock(int usermode, uintfptr_t pc); |
---|
434 | void hardclock_cnt(int cnt, int usermode); |
---|
435 | void hardclock_cpu(int usermode); |
---|
436 | void hardclock_sync(int cpu); |
---|
437 | #ifndef __rtems__ |
---|
438 | void softclock(void *); |
---|
439 | #endif /* __rtems__ */ |
---|
440 | void statclock(int usermode); |
---|
441 | void statclock_cnt(int cnt, int usermode); |
---|
442 | void profclock(int usermode, uintfptr_t pc); |
---|
443 | void profclock_cnt(int cnt, int usermode, uintfptr_t pc); |
---|
444 | |
---|
445 | int hardclockintr(void); |
---|
446 | |
---|
447 | void startprofclock(struct proc *); |
---|
448 | void stopprofclock(struct proc *); |
---|
449 | void cpu_startprofclock(void); |
---|
450 | void cpu_stopprofclock(void); |
---|
451 | sbintime_t cpu_idleclock(void); |
---|
452 | void cpu_activeclock(void); |
---|
453 | void cpu_new_callout(int cpu, sbintime_t bt, sbintime_t bt_opt); |
---|
454 | void cpu_et_frequency(struct eventtimer *et, uint64_t newfreq); |
---|
455 | extern int cpu_disable_c2_sleep; |
---|
456 | extern int cpu_disable_c3_sleep; |
---|
457 | |
---|
458 | char *kern_getenv(const char *name); |
---|
459 | void freeenv(char *env); |
---|
460 | int getenv_int(const char *name, int *data); |
---|
461 | int getenv_uint(const char *name, unsigned int *data); |
---|
462 | int getenv_long(const char *name, long *data); |
---|
463 | int getenv_ulong(const char *name, unsigned long *data); |
---|
464 | int getenv_string(const char *name, char *data, int size); |
---|
465 | int getenv_int64(const char *name, int64_t *data); |
---|
466 | int getenv_uint64(const char *name, uint64_t *data); |
---|
467 | int getenv_quad(const char *name, quad_t *data); |
---|
468 | int kern_setenv(const char *name, const char *value); |
---|
469 | int kern_unsetenv(const char *name); |
---|
470 | int testenv(const char *name); |
---|
471 | |
---|
472 | typedef uint64_t (cpu_tick_f)(void); |
---|
473 | void set_cputicker(cpu_tick_f *func, uint64_t freq, unsigned var); |
---|
474 | extern cpu_tick_f *cpu_ticks; |
---|
475 | uint64_t cpu_tickrate(void); |
---|
476 | uint64_t cputick2usec(uint64_t tick); |
---|
477 | |
---|
478 | #ifdef APM_FIXUP_CALLTODO |
---|
479 | struct timeval; |
---|
480 | void adjust_timeout_calltodo(struct timeval *time_change); |
---|
481 | #endif /* APM_FIXUP_CALLTODO */ |
---|
482 | |
---|
483 | #include <sys/libkern.h> |
---|
484 | |
---|
485 | /* Initialize the world */ |
---|
486 | void consinit(void); |
---|
487 | void cpu_initclocks(void); |
---|
488 | void cpu_initclocks_bsp(void); |
---|
489 | void cpu_initclocks_ap(void); |
---|
490 | void usrinfoinit(void); |
---|
491 | |
---|
492 | /* Finalize the world */ |
---|
493 | void kern_reboot(int) __dead2; |
---|
494 | void shutdown_nice(int); |
---|
495 | |
---|
496 | /* Timeouts */ |
---|
497 | typedef void timeout_t(void *); /* timeout function type */ |
---|
498 | #define CALLOUT_HANDLE_INITIALIZER(handle) \ |
---|
499 | { NULL } |
---|
500 | |
---|
501 | void callout_handle_init(struct callout_handle *); |
---|
502 | struct callout_handle timeout(timeout_t *, void *, int); |
---|
503 | void untimeout(timeout_t *, void *, struct callout_handle); |
---|
504 | |
---|
505 | /* Stubs for obsolete functions that used to be for interrupt management */ |
---|
506 | #ifdef __rtems__ |
---|
507 | typedef int intrmask_t; |
---|
508 | #endif /* __rtems__ */ |
---|
509 | static __inline intrmask_t splbio(void) { return 0; } |
---|
510 | static __inline intrmask_t splcam(void) { return 0; } |
---|
511 | static __inline intrmask_t splclock(void) { return 0; } |
---|
512 | static __inline intrmask_t splhigh(void) { return 0; } |
---|
513 | static __inline intrmask_t splimp(void) { return 0; } |
---|
514 | static __inline intrmask_t splnet(void) { return 0; } |
---|
515 | static __inline intrmask_t spltty(void) { return 0; } |
---|
516 | static __inline void splx(intrmask_t ipl __unused) { return; } |
---|
517 | |
---|
518 | /* |
---|
519 | * Common `proc' functions are declared here so that proc.h can be included |
---|
520 | * less often. |
---|
521 | */ |
---|
522 | int _sleep(void * _Nonnull chan, struct lock_object *lock, int pri, |
---|
523 | const char *wmesg, sbintime_t sbt, sbintime_t pr, int flags); |
---|
524 | #define msleep(chan, mtx, pri, wmesg, timo) \ |
---|
525 | _sleep((chan), &(mtx)->lock_object, (pri), (wmesg), \ |
---|
526 | tick_sbt * (timo), 0, C_HARDCLOCK) |
---|
527 | #define msleep_sbt(chan, mtx, pri, wmesg, bt, pr, flags) \ |
---|
528 | _sleep((chan), &(mtx)->lock_object, (pri), (wmesg), (bt), (pr), \ |
---|
529 | (flags)) |
---|
530 | #ifndef __rtems__ |
---|
531 | int msleep_spin_sbt(void * _Nonnull chan, struct mtx *mtx, |
---|
532 | const char *wmesg, sbintime_t sbt, sbintime_t pr, int flags); |
---|
533 | #else /* __rtems__ */ |
---|
534 | #define msleep_spin_sbt(chan, mtx, wmesg, sbt, pr, flags) \ |
---|
535 | msleep_sbt(chan, mtx, 0, wmesg, sbt, pr, flags) |
---|
536 | #endif /* __rtems__ */ |
---|
537 | #define msleep_spin(chan, mtx, wmesg, timo) \ |
---|
538 | msleep_spin_sbt((chan), (mtx), (wmesg), tick_sbt * (timo), \ |
---|
539 | 0, C_HARDCLOCK) |
---|
540 | int pause_sbt(const char *wmesg, sbintime_t sbt, sbintime_t pr, |
---|
541 | int flags); |
---|
542 | #ifdef __rtems__ |
---|
543 | #include <unistd.h> |
---|
544 | #endif /* __rtems__ */ |
---|
545 | #define pause(wmesg, timo) \ |
---|
546 | pause_sbt((wmesg), tick_sbt * (timo), 0, C_HARDCLOCK) |
---|
547 | #define tsleep(chan, pri, wmesg, timo) \ |
---|
548 | _sleep((chan), NULL, (pri), (wmesg), tick_sbt * (timo), \ |
---|
549 | 0, C_HARDCLOCK) |
---|
550 | #define tsleep_sbt(chan, pri, wmesg, bt, pr, flags) \ |
---|
551 | _sleep((chan), NULL, (pri), (wmesg), (bt), (pr), (flags)) |
---|
552 | void wakeup(void * chan); |
---|
553 | void wakeup_one(void * chan); |
---|
554 | |
---|
555 | /* |
---|
556 | * Common `struct cdev *' stuff are declared here to avoid #include poisoning |
---|
557 | */ |
---|
558 | |
---|
559 | struct cdev; |
---|
560 | dev_t dev2udev(struct cdev *x); |
---|
561 | const char *devtoname(struct cdev *cdev); |
---|
562 | |
---|
563 | #ifdef __LP64__ |
---|
564 | size_t devfs_iosize_max(void); |
---|
565 | size_t iosize_max(void); |
---|
566 | #endif |
---|
567 | |
---|
568 | int poll_no_poll(int events); |
---|
569 | |
---|
570 | /* XXX: Should be void nanodelay(u_int nsec); */ |
---|
571 | void DELAY(int usec); |
---|
572 | |
---|
573 | /* Root mount holdback API */ |
---|
574 | struct root_hold_token; |
---|
575 | |
---|
576 | struct root_hold_token *root_mount_hold(const char *identifier); |
---|
577 | void root_mount_rel(struct root_hold_token *h); |
---|
578 | int root_mounted(void); |
---|
579 | |
---|
580 | |
---|
581 | /* |
---|
582 | * Unit number allocation API. (kern/subr_unit.c) |
---|
583 | */ |
---|
584 | struct unrhdr; |
---|
585 | struct unrhdr *new_unrhdr(int low, int high, struct mtx *mutex); |
---|
586 | void init_unrhdr(struct unrhdr *uh, int low, int high, struct mtx *mutex); |
---|
587 | void delete_unrhdr(struct unrhdr *uh); |
---|
588 | void clean_unrhdr(struct unrhdr *uh); |
---|
589 | void clean_unrhdrl(struct unrhdr *uh); |
---|
590 | int alloc_unr(struct unrhdr *uh); |
---|
591 | int alloc_unr_specific(struct unrhdr *uh, u_int item); |
---|
592 | int alloc_unrl(struct unrhdr *uh); |
---|
593 | void free_unr(struct unrhdr *uh, u_int item); |
---|
594 | |
---|
595 | void intr_prof_stack_use(struct thread *td, struct trapframe *frame); |
---|
596 | |
---|
597 | void counted_warning(unsigned *counter, const char *msg); |
---|
598 | |
---|
599 | __NULLABILITY_PRAGMA_POP |
---|
600 | |
---|
601 | #endif /* !_SYS_SYSTM_H_ */ |
---|