diff --git a/sys/amd64/debug.c b/sys/amd64/debug.c index c605bf3..4aeded0 100644 --- a/sys/amd64/debug.c +++ b/sys/amd64/debug.c @@ -56,3 +56,13 @@ Debug_Registers(int argc, const char *argv[]) tf->r13, tf->r14, tf->r15); } +void +Debug_Reboot(int argc, const char *argv[]) +{ + /* + * Triple fault the core by loading a non-canonical address into CR3. We + * should use ACPI, or even the keyboard controller if it exists. + */ + write_cr3(0x8000000000000000ULL); +} + diff --git a/sys/include/kdebug.h b/sys/include/kdebug.h index dec6d93..bebe5ec 100644 --- a/sys/include/kdebug.h +++ b/sys/include/kdebug.h @@ -4,6 +4,7 @@ // Platform Functions void Debug_Registers(int argc, const char *argv[]); +void Debug_Reboot(int argc, const char *argv[]); uintptr_t db_disasm(uintptr_t loc, bool altfmt); // Generic Functions diff --git a/sys/kern/debug.c b/sys/kern/debug.c index f44fb28..3f76945 100644 --- a/sys/kern/debug.c +++ b/sys/kern/debug.c @@ -170,6 +170,7 @@ Debug_Help(int argc, const char *argv[]) { PHELP("disasm", "Disassemble"); PHELP("dump", "Dump a region of memory"); + PHELP("reboot", "Reboot computer"); PHELP("registers", "Show CPU registers"); PHELP("help", "Display the list of commands"); } @@ -262,6 +263,8 @@ Debug_Prompt() Debug_Registers(argc, (const char **)argv); } else if (strcmp(argv[0], "disasm") == 0) { Debug_Disasm(argc, (const char **)argv); + } else if (strcmp(argv[0], "reboot") == 0) { + Debug_Reboot(argc, (const char **)argv); } else if (strcmp(argv[0], "echo") == 0) { Debug_Echo(argc, (const char **)argv); } else if (strcmp(argv[0], "") != 0) {