feature: a lot of stuff and got to a working command line ish
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include <drivers/ports.h>
|
||||
#include <drivers/vgascreen.h>
|
||||
#include <libc/libc.h>
|
||||
#include <libc/stdbool.h>
|
||||
#include <cpu/isr.h>
|
||||
#include <cpu/timer.h>
|
||||
#include <drivers/keyboard.h>
|
||||
@@ -8,9 +9,12 @@
|
||||
#include <multiboot.h>
|
||||
#include <drivers/serial.h>
|
||||
#include <kprint.h>
|
||||
#include <libc/readline.h>
|
||||
#include <libc/string.h>
|
||||
|
||||
char *msg_booted = "Booted Successfully!\n";
|
||||
|
||||
void main_loop();
|
||||
|
||||
void kmain(multiboot_info_t *multiboot_info) {
|
||||
isr_install();
|
||||
@@ -37,9 +41,39 @@ void kmain(multiboot_info_t *multiboot_info) {
|
||||
init_timer(50);
|
||||
init_keyboard();
|
||||
|
||||
print_mmap_info();
|
||||
// print_mmap_info();
|
||||
while (true) {
|
||||
main_loop();
|
||||
}
|
||||
|
||||
// vga_set_raw(pos * 2, 'X');
|
||||
// vga_set_raw(pos * 2 + 1, 0xf);
|
||||
do {} while (1);
|
||||
}
|
||||
|
||||
const char* newline = "\n";
|
||||
const char* msg_unknown_command = "Unknown command: ";
|
||||
|
||||
const char* cmd_echo = "echo";
|
||||
const char* cmd_print_mmap = "print_mmap";
|
||||
|
||||
void main_loop() {
|
||||
char* msg = readline(NULL);
|
||||
char* args = strchr(msg, ' ') + 1;
|
||||
args[-1] = 0;
|
||||
if (strcmp(cmd_echo, msg) == 0) {
|
||||
kprint(args);
|
||||
kprint(newline);
|
||||
goto _main_loop_end;
|
||||
}
|
||||
if (strcmp(cmd_print_mmap, msg) == 0) {
|
||||
print_mmap_info();
|
||||
goto _main_loop_end;
|
||||
}
|
||||
|
||||
kprint(msg_unknown_command);
|
||||
kprint(msg);
|
||||
kprint(newline);
|
||||
_main_loop_end:
|
||||
free(msg);
|
||||
}
|
||||
Reference in New Issue
Block a user