1libsyscall: A system call handling framework
2============================================
3
4libsyscall provides a table based framework for handling system calls. A
5user of this library just provides a file named syscall_table.h with a
6table of function pointers defined using the DEF_SYSCALL macro:
7
8DEF_SYSCALL(nr, fn, rtype, nargs, ...)
9
10nr : system call number to use. Should not be zero or negative
11fn : name of the system call. E.g, "read", "write" etc.
12rtype: type of return value for this syscall
13nargs: number of arguments accepted by this system call. System calls
14supported by this library can take upto 4 arguments.
15
16These parameters are followed by types (and optionally names) names of
17arguments to the system call. This information is useful for
18auto-generating C function prototypes for userspace (see below).
19
20An example system call table:
21
22DEF_SYSCALL(0x3, read, long, 3, uint32_t fd, void* msg, uint32_t size)
23DEF_SYSCALL(0x4, write, long, 3, uint32_t fd, void* msg, uint32_t size)
24DEF_SYSCALL(0x5, open, long, 0)
25DEF_SYSCALL(0x2d, brk, long, 1, uint32_t brk)
26DEF_SYSCALL(0x36, ioctl, long, 3, uint32_t d, uint32_t req, void *msg)
27DEF_SYSCALL(0x4e, gettimeofday, long, 0)
28DEF_SYSCALL(0x5b, munmap, long, 2, addr_t addr, uint32_t size)
29DEF_SYSCALL(0x7d, mprotect, long, 0)
30DEF_SYSCALL(0xa2, usleep, long, 1, struct timespec *ts)
31DEF_SYSCALL(0xc0, mmap2, long, 4, addr_t addr, uint32_t length, uint32_t prot, uint32_t flags)
32DEF_SYSCALL(0xc5, fstat, long, 0)
33DEF_SYSCALL(0xdc, madvise, long, 0)
34DEF_SYSCALL(0xe0, gettid, long, 0)
35DEF_SYSCALL(0xf8, exit_group, long, 0)
36DEF_SYSCALL(0x107, clock_gettime, long, 0)
37
38Function names get expanded to sys_{fn_name} by the macro in the kernel.
39In the table above, syscall 0x3 "read" causes sys_read() to be called,
40and syscall 0x4 causes sys_write() to be called by the syscall hander.
41
42Syscall vector handler and ABI
43==============================
44
45The system call vector handler provided as part of this library simply
46jumps to the right function in the table based on system call number
47provided in a register.
48
49The system call ABI for a given architecture is documented in
50arch/$(ARCH)/syscall.S
51
52System calls are executed with interrupts turned on.
53
54Stub and C prototype autogeneration
55===================================
56
57This library also provides a python script to generate system call stub
58functions for userspace in GNU assembler syntax and a C header file with
59macros defining syscall numbers and C function prototypes for all
60functions. For more info:
61
62python stubgen.py --help
63