VM: munmap used by VM for itself is no longer used
[minix.git] / include / minix / sysutil.h
blobcd32e953c3a570c2fdeea9b7bbee5896a7e2470c
1 #ifndef _MINIX_SYSUTIL_H
2 #define _MINIX_SYSUTIL_H 1
4 #include <minix/ipc.h>
5 #include <sys/cdefs.h>
7 /* Extra system library definitions to support device drivers and servers.
9 * Created:
10 * Mar 15, 2004 by Jorrit N. Herder
12 * Changes:
13 * May 31, 2005: added printf, kputc (relocated from syslib)
14 * May 31, 2005: added getuptime
15 * Mar 18, 2005: added tickdelay
16 * Oct 01, 2004: added env_parse, env_prefix, env_panic
17 * Jul 13, 2004: added fkey_ctl
18 * Apr 28, 2004: added report, panic
19 * Mar 31, 2004: setup like other libraries, such as syslib
22 /*==========================================================================*
23 * Miscellaneous helper functions.
24 *==========================================================================*/
26 /* Environment parsing return values. */
27 #define EP_BUF_SIZE 128 /* local buffer for env value */
28 #define EP_UNSET 0 /* variable not set */
29 #define EP_OFF 1 /* var = off */
30 #define EP_ON 2 /* var = on (or field left blank) */
31 #define EP_SET 3 /* var = 1:2:3 (nonblank field) */
32 #define EP_EGETKENV 4 /* sys_getkenv() failed ... */
34 extern int env_argc;
35 extern char **env_argv;
37 void env_setargs(int argc, char *argv[]);
38 int env_get_param(char *key, char *value, int max_size);
39 int env_prefix(char *env, char *prefix);
40 void env_panic(char *key);
41 int env_parse(char *env, char *fmt, int field, long *param, long min,
42 long max);
44 #define fkey_map(fkeys, sfkeys) fkey_ctl(FKEY_MAP, (fkeys), (sfkeys))
45 #define fkey_unmap(fkeys, sfkeys) fkey_ctl(FKEY_UNMAP, (fkeys), (sfkeys))
46 #define fkey_events(fkeys, sfkeys) fkey_ctl(FKEY_EVENTS, (fkeys), (sfkeys))
47 int fkey_ctl(int req, int *fkeys, int *sfkeys);
49 int printf(const char *fmt, ...);
50 void kputc(int c);
51 __dead void panic(const char *fmt, ...);
52 int getuptime(clock_t *ticks);
53 int getuptime2(clock_t *ticks, time_t *boottime);
54 int tickdelay(clock_t ticks);
55 int tsc_calibrate(void);
56 u32_t sys_hz(void);
57 double getidle(void);
58 void util_stacktrace(void);
59 int micro_delay(u32_t micros);
60 u32_t tsc_64_to_micros(u64_t tsc);
61 u32_t tsc_to_micros(u32_t low, u32_t high);
62 u32_t tsc_get_khz(void);
63 u32_t micros_to_ticks(u32_t micros);
64 void ser_putc(char c);
65 void get_randomness(struct k_randomness *, int);
66 u32_t sqrt_approx(u32_t);
68 #define asynsend(ep, msg) asynsend3(ep, msg, 0)
69 int asynsend3(endpoint_t ep, message *msg, int flags);
70 int asyn_geterror(endpoint_t *dst, message *msg, int *err);
72 #define ASSERT(c) if(!(c)) { panic("%s:%d: assert %s failed", __FILE__, __LINE__, #c); }
74 /* timing library */
75 #define TIMING_CATEGORIES 20
77 #define TIMING_POINTS 20 /* timing resolution */
78 #define TIMING_CATEGORIES 20
79 #define TIMING_NAME 10
81 struct util_timingdata {
82 char names[TIMING_NAME];
83 unsigned long lock_timings[TIMING_POINTS];
84 unsigned long lock_timings_range[2];
85 unsigned long binsize, resets, misses, measurements;
86 unsigned long starttimes[2]; /* nonzero if running */
89 typedef struct util_timingdata util_timingdata_t;
91 #endif /* _MINIX_SYSUTIL_H */