root / lab4 / .minix-src / include / minix / sysutil.h @ 14
History | View | Annotate | Download (3.7 KB)
1 |
#ifndef _MINIX_SYSUTIL_H
|
---|---|
2 |
#define _MINIX_SYSUTIL_H 1 |
3 |
|
4 |
#include <minix/ipc.h> |
5 |
#include <sys/cdefs.h> |
6 |
|
7 |
/* Extra system library definitions to support device drivers and servers.
|
8 |
*
|
9 |
* Created:
|
10 |
* Mar 15, 2004 by Jorrit N. Herder
|
11 |
*
|
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_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
|
20 |
*/
|
21 |
|
22 |
/*==========================================================================*
|
23 |
* Miscellaneous helper functions.
|
24 |
*==========================================================================*/
|
25 |
|
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 ... */ |
33 |
|
34 |
extern int env_argc; |
35 |
extern char **env_argv; |
36 |
|
37 |
void env_setargs(int argc, char *argv[]); |
38 |
int env_get_param(const char *key, char *value, int max_size); |
39 |
void __dead env_panic(const char *key); |
40 |
int env_parse(const char *env, const char *fmt, int field, |
41 |
long *param, long min, long max); |
42 |
|
43 |
#define fkey_map(fkeys, sfkeys) fkey_ctl(FKEY_MAP, (fkeys), (sfkeys))
|
44 |
#define fkey_unmap(fkeys, sfkeys) fkey_ctl(FKEY_UNMAP, (fkeys), (sfkeys))
|
45 |
#define fkey_events(fkeys, sfkeys) fkey_ctl(FKEY_EVENTS, (fkeys), (sfkeys))
|
46 |
int fkey_ctl(int req, int *fkeys, int *sfkeys); |
47 |
|
48 |
struct timespec;
|
49 |
|
50 |
int printf(const char *fmt, ...); |
51 |
void kputc(int c); |
52 |
__dead void panic(const char *fmt, ...) |
53 |
__attribute__((__format__(__printf__,1,2))); |
54 |
void panic_hook(void); |
55 |
void __panic_hook(void); |
56 |
int getuptime(clock_t *ticks, clock_t *realtime, time_t *boottime);
|
57 |
clock_t getticks(void);
|
58 |
int tickdelay(clock_t ticks);
|
59 |
int tsc_calibrate(void); |
60 |
u32_t sys_hz(void);
|
61 |
double getidle(void); |
62 |
void util_stacktrace(void); |
63 |
int micro_delay(u32_t micros);
|
64 |
u32_t tsc_64_to_micros(u64_t tsc); |
65 |
u32_t tsc_to_micros(u32_t low, u32_t high); |
66 |
u32_t tsc_get_khz(void);
|
67 |
u32_t micros_to_ticks(u32_t micros); |
68 |
time_t clock_time(struct timespec *tv);
|
69 |
#if defined(__arm__)
|
70 |
void read_frclock(u32_t *frclk);
|
71 |
u32_t delta_frclock(u32_t base, u32_t cur); |
72 |
#endif
|
73 |
void read_frclock_64(u64_t *frclk);
|
74 |
u64_t delta_frclock_64(u64_t base, u64_t cur); |
75 |
u32_t frclock_64_to_micros(u64_t tsc); |
76 |
void ser_putc(char c); |
77 |
void get_randomness(struct k_randomness *, int); |
78 |
u32_t sqrt_approx(u32_t); |
79 |
|
80 |
int stime(time_t *_top);
|
81 |
|
82 |
void cpuavg_init(struct cpuavg *); |
83 |
void cpuavg_increment(struct cpuavg *, clock_t, clock_t); |
84 |
uint32_t cpuavg_getstats(const struct cpuavg *, uint32_t *, uint32_t *, |
85 |
clock_t, clock_t); |
86 |
uint32_t cpuavg_getccpu(void);
|
87 |
|
88 |
#define asynsend(ep, msg) asynsend3(ep, msg, 0) |
89 |
int asynsend3(endpoint_t ep, message *msg, int flags); |
90 |
int asyn_geterror(endpoint_t *dst, message *msg, int *err); |
91 |
int senda_reload(void); |
92 |
|
93 |
#define ASSERT(c) if(!(c)) { panic("%s:%d: assert %s failed", __FILE__, __LINE__, #c); } |
94 |
|
95 |
/* timing library */
|
96 |
#define TIMING_CATEGORIES 20 |
97 |
|
98 |
#define TIMING_POINTS 20 /* timing resolution */ |
99 |
#define TIMING_CATEGORIES 20 |
100 |
#define TIMING_NAME 10 |
101 |
|
102 |
struct util_timingdata {
|
103 |
char names[TIMING_NAME];
|
104 |
unsigned long lock_timings[TIMING_POINTS]; |
105 |
unsigned long lock_timings_range[2]; |
106 |
unsigned long binsize, resets, misses, measurements; |
107 |
unsigned long starttimes[2]; /* nonzero if running */ |
108 |
}; |
109 |
|
110 |
typedef struct util_timingdata util_timingdata_t; |
111 |
|
112 |
/* GCOV support (not always compiled in) */
|
113 |
int gcov_flush(endpoint_t endpt, cp_grant_id_t grant, size_t bufsize);
|
114 |
|
115 |
#endif /* _MINIX_SYSUTIL_H */ |
116 |
|