From a717296a2036cede5fccfff544513043a984d614 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Thu, 15 Sep 2022 19:21:14 +0300 Subject: change syscalls to take 5 params and return 6 + In total, a syscall is built up of 6 values, with the first being the syscall number. Symmetrically, the first value is now a status and the following five values return "values". This allows us to cram in more info into the ipc_* functions. The performance difference is absolutely minimal, at least from my testing in qemu. --- arch/riscv64/conf/init.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'arch/riscv64/conf/init.c') diff --git a/arch/riscv64/conf/init.c b/arch/riscv64/conf/init.c index 4bd6a4e..feb5177 100644 --- a/arch/riscv64/conf/init.c +++ b/arch/riscv64/conf/init.c @@ -9,30 +9,33 @@ #include #include "../../../include/apos/syscalls.h" +#define ecall() do { asm ("ecall" : : : "a0", "a1", "a2", "a3", "a4", "a5"); \ +} while (0) static void sys_noop() { long register a0 asm ("a0") = SYS_NOOP; - asm ("ecall" : : : "a0", "a1"); + ecall(); } static void sys_putch(char c) { long register a0 asm ("a0") = SYS_PUTCH; long register a1 asm ("a1") = c; - asm ("ecall" : : : "a0", "a1"); + ecall(); } static uint64_t sys_timebase() { long register a0 asm ("a0") = SYS_TIMEBASE; long register a1 asm ("a1") = 0; - asm ("ecall" : : : "a0", "a1"); + long register a2 asm ("a2") = 0; + ecall(); #if defined(_LP64) return a1; #else - uint64_t t = a0; + uint64_t t = a1; t <<= 32; - return t + a1; + return t + a2; #endif } @@ -40,13 +43,14 @@ static uint64_t sys_ticks() { long register a0 asm ("a0") = SYS_TICKS; long register a1 asm ("a1") = 0; - asm ("ecall" : : : "a0", "a1"); + long register a2 asm ("a2") = 0; + ecall(); #if defined(_LP64) return a1; #else - uint64_t t = a0; + uint64_t t = a1; t <<= 32; - return t + a1; + return t + a2; #endif } -- cgit v1.3