diff options
author | Marvin Borner | 2020-08-09 18:50:17 +0200 |
---|---|---|
committer | Marvin Borner | 2020-08-09 18:50:17 +0200 |
commit | b933a9955a2a1eb0ab32b232e23d24dc207cba46 (patch) | |
tree | cb5871cb861a1e7eee8900a2ed81a9e33a3ce130 /lib/sys.c | |
parent | 544acef0986977ef9d3a05d87bb9f55163b1280a (diff) |
Added syscall templates
Diffstat (limited to 'lib/sys.c')
-rw-r--r-- | lib/sys.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/lib/sys.c b/lib/sys.c new file mode 100644 index 0000000..d676445 --- /dev/null +++ b/lib/sys.c @@ -0,0 +1,57 @@ +// MIT License, Copyright (c) 2020 Marvin Borner +// Syscall implementation + +#include <sys.h> + +/** + * Definitions + */ + +int sys0(enum sys num) +{ + int a; + __asm__ volatile("int $0x80" : "=a"(a) : "0"(num)); + return a; +} + +int sys1(enum sys num, int d1) +{ + int a; + __asm__ volatile("int $0x80" : "=a"(a) : "0"(num), "b"((int)d1)); + return a; +} + +int sys2(enum sys num, int d1, int d2) +{ + int a; + __asm__ volatile("int $0x80" : "=a"(a) : "0"(num), "b"((int)d1), "c"((int)d2)); + return a; +} + +int sys3(enum sys num, int d1, int d2, int d3) +{ + int a; + __asm__ volatile("int $0x80" + : "=a"(a) + : "0"(num), "b"((int)d1), "c"((int)d2), "d"((int)d3)); + return a; +} + +int sys4(enum sys num, int d1, int d2, int d3, int d4) +{ + int a; + __asm__ volatile("int $0x80" + : "=a"(a) + : "0"(num), "b"((int)d1), "c"((int)d2), "d"((int)d3), "S"((int)d4)); + return a; +} + +int sys5(enum sys num, int d1, int d2, int d3, int d4, int d5) +{ + int a; + __asm__ volatile("int $0x80" + : "=a"(a) + : "0"(num), "b"((int)d1), "c"((int)d2), "d"((int)d3), "S"((int)d4), + "D"((int)d5)); + return a; +} |