forked from pepper-org/pepperOS
Kernel debug shell
This commit is contained in:
+37
-1
@@ -5,6 +5,11 @@
|
||||
*/
|
||||
|
||||
#include <io/term/term.h>
|
||||
#include <config.h>
|
||||
#include <io/kbd/ps2.h>
|
||||
#include <string/string.h>
|
||||
#include <stdint.h>
|
||||
#include <kernel.h>
|
||||
|
||||
/*
|
||||
* pedicel_main - Kernel shell main function
|
||||
@@ -13,8 +18,39 @@
|
||||
* This is the entry point for the kernel shell process.
|
||||
* It is used to start programs and to test different things
|
||||
* on different real hardware easily.
|
||||
*
|
||||
* Named after the root part of the pepper.
|
||||
*/
|
||||
void pedicel_main(void* arg)
|
||||
{
|
||||
printf("Entering the kernel shell...\r\n");
|
||||
printf("Welcome to the kernel shell!\r\nType 'help' for a list of commands.\r\n");
|
||||
|
||||
for (;;) {
|
||||
char input_buf[PEDICEL_INPUT_SIZE] = {0};
|
||||
printf(PEDICEL_PROMPT);
|
||||
keyboard_getline(input_buf, PEDICEL_INPUT_SIZE);
|
||||
|
||||
if (strncmp(input_buf, "help", 4) == 0) {
|
||||
printf("\r\npanic - trigger a test panic\r\n"
|
||||
"syscall - trigger int 0x80\r\n"
|
||||
"pf - trigger a page fault\r\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strncmp(input_buf, "panic", 5) == 0) {
|
||||
panic(NULL, "test panic");
|
||||
}
|
||||
|
||||
if (strncmp(input_buf, "syscall", 7) == 0) {
|
||||
__asm__ volatile("int $0x80");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strncmp(input_buf, "pf", 2) == 0) {
|
||||
volatile uint64_t* fault = (uint64_t*)0xdeadbeef;
|
||||
fault[0] = 1;
|
||||
}
|
||||
|
||||
printf("%s: command not found\r\n", input_buf);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user