@@ -442,6 +442,19 @@ uint64_t sys_sbrk(struct pt_regs *regs)
return retval;
}
+/**
+ * @brief 重启计算机
+ *
+ * @return
+ */
+uint64_t sys_reboot(struct pt_regs *regs)
+{
+ // 重启计算机
+ io_out8(0x64, 0xfe);
+
+ return 0;
+}
ul sys_ahci_end_req(struct pt_regs *regs)
{
ahci_end_request();
@@ -469,5 +482,6 @@ system_call_t system_call_table[MAX_SYSTEM_CALL_NUM] =
[8] = sys_vfork,
[9] = sys_brk,
[10] = sys_sbrk,
- [11 ... 254] = system_call_not_exists,
+ [11] = sys_reboot,
+ [12 ... 254] = system_call_not_exists,
[255] = sys_ahci_end_req};
@@ -20,5 +20,6 @@
#define SYS_VFORK 8
#define SYS_BRK 9
#define SYS_SBRK 10
+#define SYS_REBOOT 11 // 重启
#define SYS_AHCI_END_REQ 255 // AHCI DMA请求结束end_request的系统调用
@@ -2,6 +2,7 @@
#include <libc/string.h>
#include <libc/stdio.h>
#include <libc/stddef.h>
+#include <libsystem/syscall.h>
// 当前工作目录(在main_loop中初始化)
char *shell_current_path = NULL;
@@ -163,4 +164,7 @@ int shell_cmd_exec(int argc, char **argv) {}
* @return int
*/
// todo:
-int shell_cmd_reboot(int argc, char **argv) {}
+int shell_cmd_reboot(int argc, char **argv)
+ return syscall_invoke(SYS_REBOOT, 0, 0, 0, 0, 0, 0, 0, 0);
@@ -14,6 +14,7 @@
+#define SYS_REBOOT 11
/**
* @brief 用户态系统调用函数