From 7a1c7ed1b1c30ba4c668194a955fb414e471bade Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sat, 1 Jun 2024 16:42:55 +0300 Subject: add sleep syscall + Sets the current core to sleep --- src/uapi/conf.c | 10 +++++++++- src/uapi/dispatch.c | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/uapi/conf.c b/src/uapi/conf.c index 894b98a..497aef0 100644 --- a/src/uapi/conf.c +++ b/src/uapi/conf.c @@ -108,8 +108,16 @@ SYSCALL_DEFINE1(poweroff)(struct tcb *t, sys_arg_t type) case SHUTDOWN: case COLD_REBOOT: case WARM_REBOOT: - return_args2(t, OK, poweroff(type)); + return_args1(t, poweroff(type)); }; return_args1(t, ERR_INVAL); } + +SYSCALL_DEFINE0(sleep)(struct tcb *t) +{ + if (!(has_cap(t->caps, CAP_POWER))) + return_args1(t, ERR_PERM); + + return_args1(t, sleep()); +} diff --git a/src/uapi/dispatch.c b/src/uapi/dispatch.c index 5b523cc..f160091 100644 --- a/src/uapi/dispatch.c +++ b/src/uapi/dispatch.c @@ -76,6 +76,7 @@ void handle_syscall(sys_arg_t syscall, sys_arg_t a, sys_arg_t b, case SYS_GET_CAP: sys_get_cap(t, a, b, c, d, e); break; case SYS_CLEAR_CAP: sys_clear_cap(t, a, b, c, d, e); break; case SYS_POWEROFF: sys_poweroff(t, a, b, c, d, e); break; + case SYS_SLEEP: sys_sleep(t, a, b, c, d, e); break; case SYS_IRQ_REQ: sys_irq_req(t, a, b, c, d, e); break; default: error("Syscall %zu outside allowed range [0 - %i]\n", syscall, -- cgit v1.3