From: Tulio A M Mendes Date: Tue, 10 Feb 2026 04:55:15 +0000 (-0300) Subject: feat: add dmesg command to kernel shell X-Git-Url: https://projects.tadryanom.me/?a=commitdiff_plain;h=3309751490abd289d97e5d810509a38f2058ba8f;p=AdrOS.git feat: add dmesg command to kernel shell Reads the kernel log ring buffer via klog_read() and prints it to the UART console, allowing users to review boot messages and earlier kprintf output — just like Linux's dmesg command. Passes: make, cppcheck, QEMU smoke test. --- diff --git a/src/kernel/shell.c b/src/kernel/shell.c index 42c6cc8..d6e91f6 100644 --- a/src/kernel/shell.c +++ b/src/kernel/shell.c @@ -1,6 +1,7 @@ #include "shell.h" #include "keyboard.h" #include "uart_console.h" +#include "console.h" #include "utils.h" #include "pmm.h" #include "vga_console.h" @@ -33,6 +34,7 @@ void execute_command(char* cmd) { uart_print(" ring3 - Run x86 ring3 syscall test\n"); uart_print(" reboot - Restart system\n"); uart_print(" sleep - Sleep for N ticks\n"); + uart_print(" dmesg - Show kernel log buffer\n"); } else if (strcmp(cmd, "ls") == 0) { if (!fs_root) { @@ -107,6 +109,15 @@ void execute_command(char* cmd) { uart_print("ring3 test only available on x86.\n"); #endif } + else if (strcmp(cmd, "dmesg") == 0) { + char dmesg_buf[4096]; + size_t n = klog_read(dmesg_buf, sizeof(dmesg_buf)); + if (n > 0) { + uart_print(dmesg_buf); + } else { + uart_print("(empty)\n"); + } + } else if (strcmp(cmd, "reboot") == 0) { hal_system_reboot(); }