diff --git a/headers/shell.h b/headers/shell.h index 47f4f72..c26e965 100644 --- a/headers/shell.h +++ b/headers/shell.h @@ -43,7 +43,17 @@ static const char *POOP = " \\_ \\___\"\"\"/\"\" / `\"\"/\"\" " "\n"; -typedef enum { HELP, REBOOT, POWEROFF, ECHO, COLOR, MERDELLA, ERROR } CMD_TOK; +typedef enum { + HELP, + REBOOT, + POWEROFF, + HALT, + ECHO, + COLOR, + MERDELLA, + ERROR +} CMD_TOK; void reboot(void); +void halt(void); void shell_init(void); diff --git a/src/shell/exec.c b/src/shell/exec.c index 5f891f7..b992d9b 100644 --- a/src/shell/exec.c +++ b/src/shell/exec.c @@ -27,6 +27,8 @@ static CMD_TOK find_command(char *line) command = REBOOT; else if (!strcmp(line, "poweroff")) command = POWEROFF; + else if (!strcmp(line, "halt")) + command = HALT; else if (!strcmp(line, "echo")) command = ECHO; else if (!strcmp(line, "color")) @@ -85,12 +87,14 @@ void shell_init(void) "poweroff, echo, color, merdella\n"); break; case REBOOT: - kprintf(0, "rebooting...\n"); reboot(); break; case POWEROFF: kprintf(0, "powering off\n"); break; + case HALT: + halt(); + break; case ECHO: kprintf(0, "echoing\n"); break; diff --git a/src/shell/reboot.c b/src/shell/power.c similarity index 95% rename from src/shell/reboot.c rename to src/shell/power.c index d97b836..427d84e 100644 --- a/src/shell/reboot.c +++ b/src/shell/power.c @@ -30,3 +30,8 @@ loop: asm volatile("hlt"); /* if that didn't work, halt the CPU */ goto loop; /* if a NMI is received, halt again */ } + +void halt(void) +{ + asm volatile("hlt"); +}