Syscall tracing improvements
[akaros.git] / kern / include / syscall.h
1 #ifndef ROS_KERN_SYSCALL_H
2 #define ROS_KERN_SYSCALL_H
3 #ifndef ROS_KERNEL
4 # error "This is ROS kernel header; user programs should not #include it"
5 #endif
6
7 #include <ros/common.h>
8 #include <process.h>
9
10 #define SYSTRACE_ON                                     0x01
11 #define SYSTRACE_LOUD                           0x02
12 #define SYSTRACE_ALLPROC                        0x04
13
14 #define MAX_NUM_TRACED                          10
15 #define MAX_SYSTRACES                           1024
16
17 #define MAX_ASRC_BATCH                          10
18
19 /* Consider cache aligning this */
20 struct systrace_record {
21         uint64_t                timestamp;
22         uintreg_t               syscallno;
23         uintreg_t               arg1;
24         uintreg_t               arg2;
25         uintreg_t               arg3;
26         uintreg_t               arg4;
27         uintreg_t               arg5;
28         int                             pid;
29         uint32_t                coreid;
30         uint32_t                vcoreid;
31 };
32
33 struct sys_return {
34         uint32_t *returnloc;
35         uint32_t *errno_loc;
36 };
37
38 /* Syscall table */
39 typedef intreg_t (*syscall_t)(struct proc *, uintreg_t, uintreg_t, uintreg_t,
40                               uintreg_t, uintreg_t);
41 struct sys_table_entry {
42         syscall_t call;
43         char *name;
44 };
45 const static struct sys_table_entry syscall_table[];
46 /* Syscall invocation */
47 intreg_t syscall(struct proc *p, uintreg_t num, uintreg_t a1, uintreg_t a2,
48                  uintreg_t a3, uintreg_t a4, uintreg_t a5);
49
50 /* Tracing functions */
51 void systrace_start(bool silent);
52 void systrace_stop(void);
53 int systrace_reg(bool all, struct proc *p);
54 int systrace_dereg(bool all, struct proc *p);
55 void systrace_print(bool all, struct proc *p);
56 void systrace_clear_buffer(void);
57
58 /* direct returnval and errno handling */
59 void set_errno(uint32_t errno);
60 void set_retval(uint32_t retval);
61 #endif /* !ROS_KERN_SYSCALL_H */