core: move reboot.c to a general power.c file
feature: halt added
This commit is contained in:
parent
e7a8d39ad7
commit
963bf46b62
@ -43,7 +43,17 @@ static const char *POOP =
|
|||||||
" \\_ \\___\"\"\"/\"\" / `\"\"/\"\" "
|
" \\_ \\___\"\"\"/\"\" / `\"\"/\"\" "
|
||||||
"\n";
|
"\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 reboot(void);
|
||||||
|
void halt(void);
|
||||||
void shell_init(void);
|
void shell_init(void);
|
||||||
|
@ -27,6 +27,8 @@ static CMD_TOK find_command(char *line)
|
|||||||
command = REBOOT;
|
command = REBOOT;
|
||||||
else if (!strcmp(line, "poweroff"))
|
else if (!strcmp(line, "poweroff"))
|
||||||
command = POWEROFF;
|
command = POWEROFF;
|
||||||
|
else if (!strcmp(line, "halt"))
|
||||||
|
command = HALT;
|
||||||
else if (!strcmp(line, "echo"))
|
else if (!strcmp(line, "echo"))
|
||||||
command = ECHO;
|
command = ECHO;
|
||||||
else if (!strcmp(line, "color"))
|
else if (!strcmp(line, "color"))
|
||||||
@ -85,12 +87,14 @@ void shell_init(void)
|
|||||||
"poweroff, echo, color, merdella\n");
|
"poweroff, echo, color, merdella\n");
|
||||||
break;
|
break;
|
||||||
case REBOOT:
|
case REBOOT:
|
||||||
kprintf(0, "rebooting...\n");
|
|
||||||
reboot();
|
reboot();
|
||||||
break;
|
break;
|
||||||
case POWEROFF:
|
case POWEROFF:
|
||||||
kprintf(0, "powering off\n");
|
kprintf(0, "powering off\n");
|
||||||
break;
|
break;
|
||||||
|
case HALT:
|
||||||
|
halt();
|
||||||
|
break;
|
||||||
case ECHO:
|
case ECHO:
|
||||||
kprintf(0, "echoing\n");
|
kprintf(0, "echoing\n");
|
||||||
break;
|
break;
|
||||||
|
@ -30,3 +30,8 @@ loop:
|
|||||||
asm volatile("hlt"); /* if that didn't work, halt the CPU */
|
asm volatile("hlt"); /* if that didn't work, halt the CPU */
|
||||||
goto loop; /* if a NMI is received, halt again */
|
goto loop; /* if a NMI is received, halt again */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void halt(void)
|
||||||
|
{
|
||||||
|
asm volatile("hlt");
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user