From 44f9642bfc9ce9f740d508670befb569e06621a2 Mon Sep 17 00:00:00 2001 From: Jon Santmyer Date: Mon, 19 Oct 2026 11:06:32 -0400 Subject: add debug console. start work on userland pagedir manipulation tools --- arch/x86_64/debug/console.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 arch/x86_64/debug/console.c (limited to 'arch/x86_64/debug/console.c') diff --git a/arch/x86_64/debug/console.c b/arch/x86_64/debug/console.c new file mode 100644 index 0000000..b73e980 --- /dev/null +++ b/arch/x86_64/debug/console.c @@ -0,0 +1,39 @@ +#ifdef DEBUG_CONSOLE +#include "debug/console.h" +#include "lib/printf.h" +#include "../hal/serial_com.h" + +static char +s_console_getc(void) +{ +#ifdef DEBUG_SERIAL + char c = serial_com_getc(SERIAL_COM1); +#endif + serial_com_putc(SERIAL_COM1, c); + return c; +} + +int +debug_console_readinput(char *buf, size_t len) +{ + serial_com_putc(SERIAL_COM1, '>'); + char readc; + int readw = 0; + while((readc = s_console_getc()) != 0xD) { + if(readw > len) break; + buf[readw++] = readc; + } + buf[readw] = 0; + return readw; +} + +void debug_console_start(void) +{ + char input_buffer[128]; + while(1) { + debug_console_readinput(input_buffer, 128); + debug_console_parsecmd(input_buffer); + } +} + +#endif -- cgit v1.2.3