akaros/kern/include/syscall.h
<<
>>
Prefs
   1#pragma once
   2#ifndef ROS_KERNEL
   3# error "This is ROS kernel header; user programs should not #include it"
   4#endif
   5
   6#include <ros/common.h>
   7#include <ros/syscall.h>
   8#include <process.h>
   9#include <kref.h>
  10#include <ns.h>
  11#include <bitmap.h>
  12
  13#define SYSTRACE_ON             0x01
  14#define SYSTRACE_LOUD           0x02
  15#define SYSTRACE_ALLPROC        0x04
  16
  17#define MAX_SYSTRACES           1024
  18
  19#define SYSCALL_STRLEN          128
  20
  21#define MAX_ASRC_BATCH          10
  22
  23#define SYSTR_RECORD_SZ         256
  24#define SYSTR_PRETTY_BUF_SZ     (SYSTR_BUF_SZ - sizeof(struct systrace_record))
  25struct systrace_record {
  26        struct systrace_record_anon {
  27                uint64_t                start_timestamp, end_timestamp;
  28                uintreg_t               syscallno;
  29                uintreg_t               arg0;
  30                uintreg_t               arg1;
  31                uintreg_t               arg2;
  32                uintreg_t               arg3;
  33                uintreg_t               arg4;
  34                uintreg_t               arg5;
  35                uintreg_t               retval;
  36                int                     pid;
  37                uint32_t                coreid;
  38                uint32_t                vcoreid;
  39                char                    *pretty_buf;
  40                uint8_t                 datalen;
  41                int                     errno;
  42        };
  43        uint8_t data[SYSTR_RECORD_SZ - sizeof(struct systrace_record_anon)];
  44};
  45
  46struct strace {
  47        bool tracing;
  48        bool inherit;
  49        bool drop_overflow;
  50        atomic_t nr_drops;
  51        unsigned long appx_nr_sysc;
  52        struct kref procs; /* when procs goes to zero, q is hung up. */
  53        struct kref users; /* when users goes to zero, q and struct are freed.*/
  54        struct queue *q;
  55        spinlock_t lock;
  56        DECLARE_BITMAP(trace_set, MAX_SYSCALL_NR);
  57};
  58
  59extern bool systrace_loud;
  60
  61/* Syscall table */
  62typedef intreg_t (*syscall_t)(struct proc *, uintreg_t, uintreg_t, uintreg_t,
  63                              uintreg_t, uintreg_t, uintreg_t);
  64struct sys_table_entry {
  65        syscall_t call;
  66        char *name;
  67};
  68extern const struct sys_table_entry syscall_table[];
  69extern const int max_syscall;
  70/* Syscall invocation */
  71void prep_syscalls(struct proc *p, struct syscall *sysc, unsigned int nr_calls);
  72void run_local_syscall(struct syscall *sysc);
  73intreg_t syscall(struct proc *p, uintreg_t sc_num, uintreg_t a0, uintreg_t a1,
  74                 uintreg_t a2, uintreg_t a3, uintreg_t a4, uintreg_t a5);
  75void set_errno(int errno);
  76int get_errno(void);
  77void unset_errno(void);
  78void vset_errstr(const char *fmt, va_list ap);
  79void set_errstr(const char *errstr, ...);
  80char *current_errstr(void);
  81void set_error(int error, const char *fmt, ...);
  82struct errbuf *get_cur_errbuf(void);
  83void set_cur_errbuf(struct errbuf *ebuf);
  84char *get_cur_genbuf(void);
  85void __signal_syscall(struct syscall *sysc, struct proc *p);
  86
  87/* Utility */
  88bool syscall_uses_fd(struct syscall *sysc, int fd);
  89void print_sysc(struct proc *p, struct syscall *sysc);
  90void kth_panic_sysc(struct kthread *kth);
  91