diff options
author | Ian Moffett <ian@osmora.org> | 2025-10-12 13:44:11 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-10-12 13:44:11 -0400 |
commit | 423731942e321c9cd387669ff8c86c76867866ac (patch) | |
tree | 438ccf209c08e25e4a834f71f92e4746efd2f4bf /src | |
parent | da685f3cd675954abc03d675affa42a1db40de3e (diff) |
kern: reboot: Add reboot system call
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libc/src/l5/reboot.c | 38 | ||||
-rw-r--r-- | src/sys/include/compat/unix/syscall.h | 4 | ||||
-rw-r--r-- | src/sys/include/os/reboot.h | 37 | ||||
-rw-r--r-- | src/sys/include/sys/syscall.h | 1 |
4 files changed, 79 insertions, 1 deletions
diff --git a/src/lib/libc/src/l5/reboot.c b/src/lib/libc/src/l5/reboot.c new file mode 100644 index 0000000..6e77f48 --- /dev/null +++ b/src/lib/libc/src/l5/reboot.c @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Ian Marco Moffett and L5 engineers + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/syscall.h> +#include <sys/reboot.h> + +void +reboot(int method) +{ + syscall(SYS_reboot, method); + __builtin_unreachable(); +} diff --git a/src/sys/include/compat/unix/syscall.h b/src/sys/include/compat/unix/syscall.h index 2cca0bc..7a612c3 100644 --- a/src/sys/include/compat/unix/syscall.h +++ b/src/sys/include/compat/unix/syscall.h @@ -35,6 +35,7 @@ #include <sys/mount.h> #include <sys/syscall.h> #include <os/iotap.h> +#include <os/reboot.h> /* * Exit the current process - exit(2) syscall @@ -72,7 +73,8 @@ scret_t(*g_unix_sctab[])(struct syscall_args *) = { [SYS_mount] = sys_mount, [SYS_open] = sys_open, [SYS_muxtap] = sys_muxtap, - [SYS_getargv] = sys_getargv + [SYS_getargv] = sys_getargv, + [SYS_reboot] = sys_reboot }; #endif /* !_NEED_UNIX_SCTAB */ diff --git a/src/sys/include/os/reboot.h b/src/sys/include/os/reboot.h new file mode 100644 index 0000000..f0f967e --- /dev/null +++ b/src/sys/include/os/reboot.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Ian Marco Moffett and L5 engineers + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _OS_REBOOT_H_ +#define _OS_REBOOT_H_ + +#include <sys/syscall.h> + +scret_t sys_reboot(struct syscall_args *scargs); + +#endif /* !_OS_REBOOT_H_ */ diff --git a/src/sys/include/sys/syscall.h b/src/sys/include/sys/syscall.h index 8353eda..9616aed 100644 --- a/src/sys/include/sys/syscall.h +++ b/src/sys/include/sys/syscall.h @@ -53,6 +53,7 @@ #define SYS_open 0x08 /* open a file */ #define SYS_muxtap 0x09 /* mux an I/O tap */ #define SYS_getargv 0x0A /* get process argv */ +#define SYS_reboot 0x0B /* reboot the system */ typedef __ssize_t scret_t; typedef __ssize_t scarg_t; |