]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commitdiff
kprintf: migrate all uart_print() calls to kprintf() (Route A)
authorTulio A M Mendes <[email protected]>
Fri, 13 Feb 2026 04:31:04 +0000 (01:31 -0300)
committerTulio A M Mendes <[email protected]>
Fri, 13 Feb 2026 04:31:04 +0000 (01:31 -0300)
Replace 270 direct uart_print() calls across 42 files with kprintf(),
routing all kernel messages through the klog ring buffer and multi-backend
console infrastructure (UART + VGA).

Key changes:
- All kernel log/debug messages now go through kprintf() -> klog_append()
  -> console_write(), ensuring they appear in dmesg and on all enabled
  output devices.
- Consolidated multi-call patterns (uart_print+itoa_hex) into single
  kprintf() calls with format specifiers (%x, %u, %s, %d, %c).
- Removed manual itoa/itoa_hex + uart_print concatenation throughout.
- Cleaned up stale #include uart_console.h from files that no longer
  need it (main.c, socket.c, syscall.c, slab.c, timer.c).
- uart_print() now only remains in 2 places:
  * uart_console.c (the implementation)
  * console.c (the UART backend in console_write)
- uart_put_char() retained in tty.c for direct terminal I/O (not logging).
- arch_early_setup files keep uart_console.h for uart_init() call.

Build: clean, cppcheck: clean, smoke: 19/19 pass.

45 files changed:
src/arch/arm/arch_early_setup.c
src/arch/mips/arch_early_setup.c
src/arch/riscv/arch_early_setup.c
src/arch/x86/acpi.c
src/arch/x86/arch_early_setup.c
src/arch/x86/arch_platform.c
src/arch/x86/cpuid.c
src/arch/x86/elf.c
src/arch/x86/gdt.c
src/arch/x86/idt.c
src/arch/x86/ioapic.c
src/arch/x86/lapic.c
src/arch/x86/mtrr.c
src/arch/x86/percpu.c
src/arch/x86/pmm_boot.c
src/arch/x86/smp.c
src/arch/x86/sysenter_init.c
src/arch/x86/usermode.c
src/arch/x86/vmm.c
src/drivers/e1000.c
src/drivers/initrd.c
src/drivers/keyboard.c
src/drivers/pci.c
src/drivers/timer.c
src/drivers/vbe.c
src/hal/x86/ata_dma.c
src/hal/x86/ata_pio.c
src/hal/x86/cpu_features.c
src/hal/x86/pci.c
src/hal/x86/timer.c
src/kernel/cpu_features.c
src/kernel/fat16.c
src/kernel/init.c
src/kernel/kaslr.c
src/kernel/main.c
src/kernel/scheduler.c
src/kernel/socket.c
src/kernel/syscall.c
src/kernel/tty.c
src/kernel/vdso.c
src/mm/heap.c
src/mm/pmm.c
src/mm/slab.c
src/net/dns.c
src/net/e1000_netif.c

index 2e64e9ee9393ce7b913c1e54d5de0631f9de5d00..0fe75a6f1a4e49982216edcdaa5926c0809f553d 100644 (file)
@@ -11,6 +11,7 @@
 #include "kernel/boot_info.h"
 
 #include "uart_console.h"
+#include "console.h"
 
 extern void kernel_main(const struct boot_info* bi);
 
@@ -18,7 +19,7 @@ extern void kernel_main(const struct boot_info* bi);
     (void)args;
 
     uart_init();
-    uart_print("\n[AdrOS] Booting...\n");
+    kprintf("\n[AdrOS] Booting...\n");
 
     struct boot_info bi;
     bi.arch_magic = 0;
index 6518b31930d0fd89e2839b1957507507e1110dfb..d5f6ce1ca85db11acb57780286f72b3d501ea558 100644 (file)
@@ -11,6 +11,7 @@
 #include "kernel/boot_info.h"
 
 #include "uart_console.h"
+#include "console.h"
 
 extern void kernel_main(const struct boot_info* bi);
 
@@ -18,7 +19,7 @@ extern void kernel_main(const struct boot_info* bi);
     (void)args;
 
     uart_init();
-    uart_print("\n[AdrOS] Booting...\n");
+    kprintf("\n[AdrOS] Booting...\n");
 
     struct boot_info bi;
     bi.arch_magic = 0;
index 2e64e9ee9393ce7b913c1e54d5de0631f9de5d00..0fe75a6f1a4e49982216edcdaa5926c0809f553d 100644 (file)
@@ -11,6 +11,7 @@
 #include "kernel/boot_info.h"
 
 #include "uart_console.h"
+#include "console.h"
 
 extern void kernel_main(const struct boot_info* bi);
 
@@ -18,7 +19,7 @@ extern void kernel_main(const struct boot_info* bi);
     (void)args;
 
     uart_init();
-    uart_print("\n[AdrOS] Booting...\n");
+    kprintf("\n[AdrOS] Booting...\n");
 
     struct boot_info bi;
     bi.arch_magic = 0;
index 83909c434bbde76b3f37ccaa23031796f5e909db..e28232cafb4d543fe63e978660ee5fb9df7d1724 100644 (file)
@@ -8,7 +8,7 @@
  */
 
 #include "arch/x86/acpi.h"
-#include "uart_console.h"
+#include "console.h"
 #include "utils.h"
 #include "vmm.h"
 
@@ -44,7 +44,7 @@ static const void* acpi_map_phys(uintptr_t phys, size_t len) {
     uint32_t num_pages = (uint32_t)((page_end - page_start) >> 12);
 
     if (num_pages > ACPI_TMP_VA_PAGES) {
-        uart_print("[ACPI] Table too large to map.\n");
+        kprintf("[ACPI] Table too large to map.\n");
         return NULL;
     }
 
@@ -157,15 +157,11 @@ int acpi_init(void) {
 
     const struct acpi_rsdp* rsdp = find_rsdp();
     if (!rsdp) {
-        uart_print("[ACPI] RSDP not found.\n");
+        kprintf("[ACPI] RSDP not found.\n");
         return -1;
     }
 
-    uart_print("[ACPI] RSDP found, revision=");
-    char tmp[12];
-    itoa(rsdp->revision, tmp, 10);
-    uart_print(tmp);
-    uart_print("\n");
+    kprintf("[ACPI] RSDP found, revision=%d\n", (int)rsdp->revision);
 
     /* Get RSDT (ACPI 1.0 — 32-bit pointers).
      * The RSDT may be above the 16MB identity-mapped range, so use acpi_map_phys. */
@@ -175,7 +171,7 @@ int acpi_init(void) {
     const struct acpi_sdt_header* rsdt_hdr =
         (const struct acpi_sdt_header*)acpi_map_phys(rsdt_phys, sizeof(struct acpi_sdt_header));
     if (!rsdt_hdr) {
-        uart_print("[ACPI] Cannot map RSDT header.\n");
+        kprintf("[ACPI] Cannot map RSDT header.\n");
         return -1;
     }
     uint32_t rsdt_len = rsdt_hdr->length;
@@ -185,12 +181,12 @@ int acpi_init(void) {
     const struct acpi_rsdt* rsdt =
         (const struct acpi_rsdt*)acpi_map_phys(rsdt_phys, rsdt_len);
     if (!rsdt) {
-        uart_print("[ACPI] Cannot map full RSDT.\n");
+        kprintf("[ACPI] Cannot map full RSDT.\n");
         return -1;
     }
 
     if (!acpi_checksum(rsdt, rsdt_len)) {
-        uart_print("[ACPI] RSDT checksum failed.\n");
+        kprintf("[ACPI] RSDT checksum failed.\n");
         acpi_unmap_all();
         return -1;
     }
@@ -220,7 +216,7 @@ int acpi_init(void) {
     acpi_unmap_all();
 
     if (!madt_phys) {
-        uart_print("[ACPI] MADT not found.\n");
+        kprintf("[ACPI] MADT not found.\n");
         return -1;
     }
 
@@ -228,7 +224,7 @@ int acpi_init(void) {
     const struct acpi_sdt_header* madt_hdr =
         (const struct acpi_sdt_header*)acpi_map_phys(madt_phys, sizeof(struct acpi_sdt_header));
     if (!madt_hdr) {
-        uart_print("[ACPI] Cannot map MADT header.\n");
+        kprintf("[ACPI] Cannot map MADT header.\n");
         return -1;
     }
     uint32_t madt_len = madt_hdr->length;
@@ -237,18 +233,18 @@ int acpi_init(void) {
     const struct acpi_madt* madt =
         (const struct acpi_madt*)acpi_map_phys(madt_phys, madt_len);
     if (!madt) {
-        uart_print("[ACPI] Cannot map full MADT.\n");
+        kprintf("[ACPI] Cannot map full MADT.\n");
         return -1;
     }
 
     if (!acpi_checksum(madt, madt_len)) {
-        uart_print("[ACPI] MADT checksum failed.\n");
+        kprintf("[ACPI] MADT checksum failed.\n");
         acpi_unmap_all();
         return -1;
     }
 
     if (parse_madt(madt) < 0) {
-        uart_print("[ACPI] MADT parse failed.\n");
+        kprintf("[ACPI] MADT parse failed.\n");
         acpi_unmap_all();
         return -1;
     }
@@ -257,26 +253,15 @@ int acpi_init(void) {
     g_acpi_valid = 1;
 
     /* Print summary */
-    uart_print("[ACPI] MADT: ");
-    itoa(g_acpi_info.num_cpus, tmp, 10);
-    uart_print(tmp);
-    uart_print(" CPU(s), LAPIC=");
-    itoa_hex(g_acpi_info.lapic_address, tmp);
-    uart_print(tmp);
-    uart_print(", IOAPIC=");
-    itoa_hex(g_acpi_info.ioapic_address, tmp);
-    uart_print(tmp);
-    uart_print("\n");
+    kprintf("[ACPI] MADT: %u CPU(s), LAPIC=0x%x, IOAPIC=0x%x\n",
+            (unsigned)g_acpi_info.num_cpus,
+            (unsigned)g_acpi_info.lapic_address,
+            (unsigned)g_acpi_info.ioapic_address);
 
     for (uint8_t i = 0; i < g_acpi_info.num_cpus; i++) {
-        uart_print("[ACPI]   CPU ");
-        itoa(i, tmp, 10);
-        uart_print(tmp);
-        uart_print(": LAPIC ID=");
-        itoa(g_acpi_info.cpu_lapic_ids[i], tmp, 10);
-        uart_print(tmp);
-        uart_print(g_acpi_info.cpu_enabled[i] ? " (enabled)" : " (disabled)");
-        uart_print("\n");
+        kprintf("[ACPI]   CPU %u: LAPIC ID=%u%s\n",
+                (unsigned)i, (unsigned)g_acpi_info.cpu_lapic_ids[i],
+                g_acpi_info.cpu_enabled[i] ? " (enabled)" : " (disabled)");
     }
 
     return 0;
index 2fff8d1cff69fb2396327334c2c901d82b5de7ff..cd47c152fcbddef4d841639711223f395902abcf 100644 (file)
@@ -14,6 +14,7 @@
 #include "arch/x86/gdt.h"
 #include "arch/x86/idt.h"
 #include "uart_console.h"
+#include "console.h"
 
 #include "arch/x86/multiboot2.h"
 
@@ -24,21 +25,21 @@ static uint32_t multiboot_copy_size;
 
  void arch_early_setup(const struct arch_boot_args* args) {
     uart_init();
-    uart_print("\n[AdrOS] Booting...\n");
+    kprintf("\n[AdrOS] Booting...\n");
 
     uint32_t magic = (uint32_t)(args ? args->a0 : 0);
     uintptr_t mbi_phys = (uintptr_t)(args ? args->a1 : 0);
 
     if (magic != 0x36d76289) {
-        uart_print("[ERR] Invalid Multiboot2 Magic!\n");
+        kprintf("[ERR] Invalid Multiboot2 Magic!\n");
     } else {
-        uart_print("[OK] Multiboot2 Magic Confirmed.\n");
+        kprintf("[OK] Multiboot2 Magic Confirmed.\n");
     }
 
-    uart_print("[AdrOS] Initializing GDT/TSS...\n");
+    kprintf("[AdrOS] Initializing GDT/TSS...\n");
     gdt_init();
 
-    uart_print("[AdrOS] Initializing IDT...\n");
+    kprintf("[AdrOS] Initializing IDT...\n");
     idt_init();
 
     struct boot_info bi;
@@ -58,7 +59,7 @@ static uint32_t multiboot_copy_size;
         if (total_size >= 8) {
             multiboot_copy_size = total_size;
             if (multiboot_copy_size > sizeof(multiboot_copy)) {
-                uart_print("[WARN] Multiboot2 info too large, truncating copy.\n");
+                kprintf("[WARN] Multiboot2 info too large, truncating copy.\n");
                 multiboot_copy_size = sizeof(multiboot_copy);
             }
 
index 5c940ed9fdaf95234c614fb7a5af97fecd477f45..0f459c43d0dcd4ec29dd758d6aa5fc679736646c 100644 (file)
@@ -14,7 +14,6 @@
 #include "keyboard.h"
 #include "syscall.h"
 #include "timer.h"
-#include "uart_console.h"
 #include "console.h"
 #include "uaccess.h"
 #include "vga_console.h"
@@ -44,7 +43,7 @@ static uint8_t ring0_trap_stack[16384] __attribute__((aligned(16)));
 #if defined(__i386__)
 static void userspace_init_thread(void) {
     if (!fs_root) {
-        uart_print("[ELF] fs_root missing\n");
+        kprintf("[ELF] fs_root missing\n");
         process_exit_notify(1);
         schedule();
         for (;;) hal_cpu_idle();
@@ -65,18 +64,16 @@ static void userspace_init_thread(void) {
     current_process->heap_break = heap_brk;
     vmm_as_activate(user_as);
 
-    uart_print("[ELF] starting /bin/init.elf\n");
+    kprintf("[ELF] starting /bin/init.elf\n");
 
-    uart_print("[ELF] user_range_ok(entry)=");
-    uart_put_char(user_range_ok((const void*)entry, 1) ? '1' : '0');
-    uart_print(" user_range_ok(stack)=");
-    uart_put_char(user_range_ok((const void*)(user_sp - 16), 16) ? '1' : '0');
-    uart_print("\n");
+    kprintf("[ELF] user_range_ok(entry)=%c user_range_ok(stack)=%c\n",
+            user_range_ok((const void*)entry, 1) ? '1' : '0',
+            user_range_ok((const void*)(user_sp - 16), 16) ? '1' : '0');
 
     hal_cpu_set_kernel_stack((uintptr_t)&ring0_trap_stack[sizeof(ring0_trap_stack)]);
 
     if (hal_usermode_enter(entry, user_sp) < 0) {
-        uart_print("[USER] usermode enter not supported on this architecture.\n");
+        kprintf("[USER] usermode enter not supported on this architecture.\n");
         process_exit_notify(1);
         schedule();
         for (;;) hal_cpu_idle();
index cde78cc008adc28c41287162d3652530974367d8..75ceac346d673260bf52307f4ca0232237e88aad 100644 (file)
@@ -8,7 +8,7 @@
  */
 
 #include "arch/x86/cpuid.h"
-#include "uart_console.h"
+#include "console.h"
 #include "utils.h"
 
 #include <stddef.h>
@@ -108,49 +108,39 @@ void x86_cpuid_detect(struct x86_cpu_features* out) {
 }
 
 void x86_cpuid_print(const struct x86_cpu_features* f) {
-    uart_print("[CPUID] Vendor: ");
-    uart_print(f->vendor);
-    uart_print("\n");
+    kprintf("[CPUID] Vendor: %s\n", f->vendor);
 
     if (f->brand[0]) {
-        uart_print("[CPUID] Brand:  ");
-        uart_print(f->brand);
-        uart_print("\n");
+        kprintf("[CPUID] Brand:  %s\n", f->brand);
     }
 
-    uart_print("[CPUID] Features:");
-    if (f->fpu)   uart_print(" FPU");
-    if (f->tsc)   uart_print(" TSC");
-    if (f->msr)   uart_print(" MSR");
-    if (f->pae)   uart_print(" PAE");
-    if (f->apic)  uart_print(" APIC");
-    if (f->sep)   uart_print(" SEP");
-    if (f->pge)   uart_print(" PGE");
-    if (f->mmx)   uart_print(" MMX");
-    if (f->fxsr)  uart_print(" FXSR");
-    if (f->sse)   uart_print(" SSE");
-    if (f->sse2)  uart_print(" SSE2");
-    if (f->sse3)  uart_print(" SSE3");
-    if (f->ssse3) uart_print(" SSSE3");
-    if (f->sse41) uart_print(" SSE4.1");
-    if (f->sse42) uart_print(" SSE4.2");
-    if (f->avx)   uart_print(" AVX");
-    if (f->htt)   uart_print(" HTT");
-    if (f->nx)    uart_print(" NX");
-    if (f->lm)    uart_print(" LM");
-    if (f->x2apic) uart_print(" x2APIC");
-    if (f->hypervisor) uart_print(" HYPERVISOR");
-    if (f->syscall) uart_print(" SYSCALL");
-    if (f->smep) uart_print(" SMEP");
-    if (f->smap) uart_print(" SMAP");
-    uart_print("\n");
-
-    uart_print("[CPUID] APIC ID: ");
-    char tmp[12];
-    itoa(f->initial_apic_id, tmp, 10);
-    uart_print(tmp);
-    uart_print(", Logical CPUs: ");
-    itoa(f->logical_cpus, tmp, 10);
-    uart_print(tmp);
-    uart_print("\n");
+    kprintf("[CPUID] Features:");
+    if (f->fpu)   kprintf(" FPU");
+    if (f->tsc)   kprintf(" TSC");
+    if (f->msr)   kprintf(" MSR");
+    if (f->pae)   kprintf(" PAE");
+    if (f->apic)  kprintf(" APIC");
+    if (f->sep)   kprintf(" SEP");
+    if (f->pge)   kprintf(" PGE");
+    if (f->mmx)   kprintf(" MMX");
+    if (f->fxsr)  kprintf(" FXSR");
+    if (f->sse)   kprintf(" SSE");
+    if (f->sse2)  kprintf(" SSE2");
+    if (f->sse3)  kprintf(" SSE3");
+    if (f->ssse3) kprintf(" SSSE3");
+    if (f->sse41) kprintf(" SSE4.1");
+    if (f->sse42) kprintf(" SSE4.2");
+    if (f->avx)   kprintf(" AVX");
+    if (f->htt)   kprintf(" HTT");
+    if (f->nx)    kprintf(" NX");
+    if (f->lm)    kprintf(" LM");
+    if (f->x2apic) kprintf(" x2APIC");
+    if (f->hypervisor) kprintf(" HYPERVISOR");
+    if (f->syscall) kprintf(" SYSCALL");
+    if (f->smep) kprintf(" SMEP");
+    if (f->smap) kprintf(" SMAP");
+    kprintf("\n");
+
+    kprintf("[CPUID] APIC ID: %u, Logical CPUs: %u\n",
+            (unsigned)f->initial_apic_id, (unsigned)f->logical_cpus);
 }
index e830680b4ac2a7a392790a570dbdcb9c877e3af8..8b0ba9dfaa04bc8a1455a0063ad36da4dd680a02 100644 (file)
@@ -12,7 +12,7 @@
 #include "fs.h"
 #include "heap.h"
 #include "pmm.h"
-#include "uart_console.h"
+#include "console.h"
 #include "utils.h"
 #include "vmm.h"
 
@@ -159,9 +159,7 @@ static int elf32_load_interp(const char* interp_path, uintptr_t as,
 
     fs_node_t* node = vfs_lookup(interp_path);
     if (!node) {
-        uart_print("[ELF] interp not found: ");
-        uart_print(interp_path);
-        uart_print("\n");
+        kprintf("[ELF] interp not found: %s\n", interp_path);
         return -ENOENT;
     }
 
@@ -208,9 +206,7 @@ int elf32_load_user_from_initrd(const char* filename, uintptr_t* entry_out, uint
 
     fs_node_t* node = vfs_lookup(filename);
     if (!node) {
-        uart_print("[ELF] file not found: ");
-        uart_print(filename);
-        uart_print("\n");
+        kprintf("[ELF] file not found: %s\n", filename);
         vmm_as_destroy(new_as);
         return -ENOENT;
     }
@@ -240,7 +236,7 @@ int elf32_load_user_from_initrd(const char* filename, uintptr_t* entry_out, uint
     const elf32_ehdr_t* eh = (const elf32_ehdr_t*)file;
     int vrc = elf32_validate(eh, file_len);
     if (vrc < 0) {
-        uart_print("[ELF] invalid ELF header\n");
+        kprintf("[ELF] invalid ELF header\n");
         kfree(file);
         vmm_as_activate(old_as);
         vmm_as_destroy(new_as);
@@ -250,7 +246,7 @@ int elf32_load_user_from_initrd(const char* filename, uintptr_t* entry_out, uint
     uintptr_t highest_seg_end = 0;
     int lrc = elf32_load_segments(file, file_len, new_as, 0, &highest_seg_end);
     if (lrc < 0) {
-        uart_print("[ELF] segment load failed\n");
+        kprintf("[ELF] segment load failed\n");
         kfree(file);
         vmm_as_activate(old_as);
         vmm_as_destroy(new_as);
@@ -277,9 +273,7 @@ int elf32_load_user_from_initrd(const char* filename, uintptr_t* entry_out, uint
             if (irc == 0) {
                 real_entry = interp_entry;
                 has_interp = 1;
-                uart_print("[ELF] loaded interp: ");
-                uart_print(interp_path);
-                uart_print("\n");
+                kprintf("[ELF] loaded interp: %s\n", interp_path);
             }
             break;
         }
@@ -297,7 +291,7 @@ int elf32_load_user_from_initrd(const char* filename, uintptr_t* entry_out, uint
 
     int src2 = elf32_map_user_range(new_as, user_stack_base, user_stack_size, VMM_FLAG_RW);
     if (src2 < 0) {
-        uart_print("[ELF] OOM mapping user stack\n");
+        kprintf("[ELF] OOM mapping user stack\n");
         kfree(file);
         vmm_as_activate(old_as);
         vmm_as_destroy(new_as);
index 3dc2b4ce55007f484e1be9c72b9cf615efde42a1..b6f0bf030768f76e29c47d44a0b26753f3bea239 100644 (file)
@@ -9,7 +9,7 @@
 
 #include "arch/x86/gdt.h"
 
-#include "uart_console.h"
+#include "console.h"
  #include "utils.h"
 
 struct gdt_entry {
@@ -103,7 +103,7 @@ void tss_set_kernel_stack(uintptr_t esp0) {
 }
 
 void gdt_init(void) {
-    uart_print("[GDT] Initializing GDT/TSS...\n");
+    kprintf("[GDT] Initializing GDT/TSS...\n");
 
     gp.limit = (uint16_t)(sizeof(struct gdt_entry) * GDT_MAX_ENTRIES - 1);
     gp.base = (uint32_t)(uintptr_t)&gdt;
@@ -121,5 +121,5 @@ void gdt_init(void) {
     gdt_flush((uint32_t)(uintptr_t)&gp);
     tss_flush(0x28);
 
-    uart_print("[GDT] Loaded.\n");
+    kprintf("[GDT] Loaded.\n");
 }
index e0971e15597ee6a3d8e9b4c2bc41bb46b612fed6..07ae547304f76145ba2eb3cb312c53f38de4fd33 100644 (file)
@@ -10,7 +10,7 @@
 #include "arch/x86/idt.h"
 #include "arch/x86/lapic.h"
 #include "io.h"
-#include "uart_console.h"
+#include "console.h"
 #include "process.h"
 #include "spinlock.h"
 #include "uaccess.h"
@@ -219,7 +219,7 @@ void pic_remap(void) {
 }
 
 void idt_init(void) {
-    uart_print("[IDT] Initializing Interrupts...\n");
+    kprintf("[IDT] Initializing Interrupts...\n");
     
     idtp.limit = (sizeof(struct idt_entry) * IDT_ENTRIES) - 1;
     idtp.base  = (uint32_t)&idt;
@@ -299,7 +299,7 @@ void idt_init(void) {
     // Load IDT
     __asm__ volatile("lidt %0" : : "m"(idtp));
 
-    uart_print("[IDT] Loaded.\n");
+    kprintf("[IDT] Loaded.\n");
 }
 
 void register_interrupt_handler(uint8_t n, isr_handler_t handler) {
@@ -313,12 +313,7 @@ void register_interrupt_handler(uint8_t n, isr_handler_t handler) {
 // ... imports ...
 
 void print_reg(const char* name, uint32_t val) {
-    char buf[16];
-    uart_print(name);
-    uart_print(": ");
-    itoa_hex(val, buf);
-    uart_print(buf);
-    uart_print("  ");
+    kprintf("%s: %x  ", name, val);
 }
 
 // The Main Handler called by assembly
@@ -381,33 +376,25 @@ void isr_handler(struct registers* regs) {
 
             __asm__ volatile("cli"); // Stop everything
             
-            uart_print("\n\n!!! KERNEL PANIC !!!\n");
-            uart_print("Exception Number: ");
-            char num_buf[16];
-            itoa(regs->int_no, num_buf, 10);
-            uart_print(num_buf);
-            uart_print("\n");
+            kprintf("\n\n!!! KERNEL PANIC !!!\n");
+            kprintf("Exception Number: %u\n", (unsigned)regs->int_no);
             
-            uart_print("registers:\n");
+            kprintf("registers:\n");
             print_reg("EAX", regs->eax); print_reg("EBX", regs->ebx); print_reg("ECX", regs->ecx); print_reg("EDX", regs->edx);
-            uart_print("\n");
+            kprintf("\n");
             print_reg("ESI", regs->esi); print_reg("EDI", regs->edi); print_reg("EBP", regs->ebp); print_reg("ESP", regs->esp);
-            uart_print("\n");
+            kprintf("\n");
             print_reg("EIP", regs->eip); print_reg("CS ", regs->cs);  print_reg("EFLAGS", regs->eflags);
-            uart_print("\n");
+            kprintf("\n");
 
             // Print Page Fault specifics
             if (regs->int_no == 14) {
                 uint32_t cr2;
                 __asm__ volatile("mov %%cr2, %0" : "=r"(cr2));
-                uart_print("\nPAGE FAULT at address: ");
-                char cr2_buf[16];
-                itoa_hex(cr2, cr2_buf);
-                uart_print(cr2_buf);
-                uart_print("\n");
+                kprintf("\nPAGE FAULT at address: 0x%x\n", cr2);
             }
             
-            uart_print("\nSystem Halted.\n");
+            kprintf("\nSystem Halted.\n");
             for(;;) __asm__("hlt");
         }
     }
index 750771ca1ca6e90b98e40e8c05a38c0c545b2d58..f3c94ef89e54b7642610f7986942bfe60332f267 100644 (file)
@@ -10,7 +10,7 @@
 #include "arch/x86/ioapic.h"
 #include "arch/x86/lapic.h"
 #include "vmm.h"
-#include "uart_console.h"
+#include "console.h"
 #include "utils.h"
 
 #include <stdint.h>
@@ -35,7 +35,7 @@ int ioapic_is_enabled(void) {
 
 int ioapic_init(void) {
     if (!lapic_is_enabled()) {
-        uart_print("[IOAPIC] LAPIC not enabled, skipping IOAPIC.\n");
+        kprintf("[IOAPIC] LAPIC not enabled, skipping IOAPIC.\n");
         return 0;
     }
 
@@ -62,14 +62,8 @@ int ioapic_init(void) {
 
     ioapic_active = 1;
 
-    uart_print("[IOAPIC] Enabled at phys=");
-    char tmp[12];
-    itoa_hex((uint32_t)phys_base, tmp);
-    uart_print(tmp);
-    uart_print(", max IRQs=");
-    itoa(ioapic_max_irqs, tmp, 10);
-    uart_print(tmp);
-    uart_print("\n");
+    kprintf("[IOAPIC] Enabled at phys=0x%x, max IRQs=%u\n",
+            (unsigned)phys_base, (unsigned)ioapic_max_irqs);
 
     return 1;
 }
index 0dead06aa6ad1f536989b1fe568ad4ba6f0d39b5..228bb49834c2fe8dce7c22a69104c0930e585668 100644 (file)
@@ -11,7 +11,7 @@
 #include "hal/cpu_features.h"
 #include "vmm.h"
 #include "io.h"
-#include "uart_console.h"
+#include "console.h"
 #include "utils.h"
 
 #include <stdint.h>
@@ -80,11 +80,11 @@ void pic_disable(void) {
 int lapic_init(void) {
     const struct cpu_features* f = hal_cpu_get_features();
     if (!f->has_apic) {
-        uart_print("[LAPIC] CPU does not support APIC.\n");
+        kprintf("[LAPIC] CPU does not support APIC.\n");
         return 0;
     }
     if (!f->has_msr) {
-        uart_print("[LAPIC] CPU does not support MSR.\n");
+        kprintf("[LAPIC] CPU does not support MSR.\n");
         return 0;
     }
 
@@ -132,14 +132,8 @@ int lapic_init(void) {
 
     lapic_active = 1;
 
-    uart_print("[LAPIC] Enabled at phys=");
-    char tmp[12];
-    itoa_hex((uint32_t)phys_base, tmp);
-    uart_print(tmp);
-    uart_print(", ID=");
-    itoa(lapic_get_id(), tmp, 10);
-    uart_print(tmp);
-    uart_print("\n");
+    kprintf("[LAPIC] Enabled at phys=0x%x, ID=%u\n",
+            (unsigned)phys_base, (unsigned)lapic_get_id());
 
     return 1;
 }
@@ -188,14 +182,8 @@ void lapic_timer_start(uint32_t frequency_hz) {
     lapic_write(LAPIC_TIMER_DCR, LAPIC_TIMER_DIV_16);
     lapic_write(LAPIC_TIMER_ICR, ticks_per_interrupt);
 
-    uart_print("[LAPIC] Timer started at ");
-    char tmp[12];
-    itoa((int)frequency_hz, tmp, 10);
-    uart_print(tmp);
-    uart_print("Hz (ticks=");
-    itoa_hex(ticks_per_interrupt, tmp);
-    uart_print(tmp);
-    uart_print(")\n");
+    kprintf("[LAPIC] Timer started at %uHz (ticks=0x%x)\n",
+            (unsigned)frequency_hz, ticks_per_interrupt);
 }
 
 void lapic_timer_stop(void) {
index c4b0f0908303eaefd3c4a29573451eda28bcc7bf..8ed9de0f50b24113e2ad861b6a434c96144b8e98 100644 (file)
@@ -8,7 +8,7 @@
  */
 
 #include "mtrr.h"
-#include "uart_console.h"
+#include "console.h"
 
 #define IA32_MTRRCAP       0xFE
 #define IA32_MTRR_DEF_TYPE 0x2FF
@@ -34,26 +34,20 @@ void mtrr_init(void) {
     /* Check MTRR support: CPUID.1:EDX bit 12 */
     __asm__ volatile("cpuid" : "=a"(eax), "=d"(edx) : "a"(1) : "ebx", "ecx");
     if (!(edx & (1U << 12))) {
-        uart_print("[MTRR] Not supported by CPU\n");
+        kprintf("[MTRR] Not supported by CPU\n");
         return;
     }
 
     uint64_t cap = rdmsr(IA32_MTRRCAP);
     mtrr_count = (uint8_t)(cap & 0xFF);
     if (mtrr_count == 0) {
-        uart_print("[MTRR] No variable-range MTRRs available\n");
+        kprintf("[MTRR] No variable-range MTRRs available\n");
         return;
     }
 
     mtrr_enabled = 1;
-    uart_print("[MTRR] Initialized, ");
-    /* Simple decimal print for count */
-    char buf[4];
-    buf[0] = (char)('0' + mtrr_count / 10);
-    buf[1] = (char)('0' + mtrr_count % 10);
-    buf[2] = '\0';
-    uart_print(buf);
-    uart_print(" variable-range registers\n");
+    kprintf("[MTRR] Initialized, %u variable-range registers\n",
+            (unsigned)mtrr_count);
 }
 
 int mtrr_set_range(uint64_t base, uint64_t size, uint8_t type) {
index c4bfc61bdbc0f19e2ba7becff00bba81a22744f8..61a46650033a72a6dc079ac2627ca766fa78bc91 100644 (file)
@@ -10,7 +10,7 @@
 #include "arch/x86/percpu.h"
 #include "arch/x86/smp.h"
 #include "arch/x86/gdt.h"
-#include "uart_console.h"
+#include "console.h"
 #include "utils.h"
 
 #include <stdint.h>
@@ -49,11 +49,7 @@ void percpu_init(void) {
         set_percpu_gdt_entry(PERCPU_GDT_BASE + i, (uint32_t)(uintptr_t)&g_percpu[i]);
     }
 
-    char tmp[12];
-    uart_print("[PERCPU] Initialized for ");
-    itoa(ncpus, tmp, 10);
-    uart_print(tmp);
-    uart_print(" CPU(s).\n");
+    kprintf("[PERCPU] Initialized for %u CPU(s).\n", (unsigned)ncpus);
 }
 
 void percpu_setup_gs(uint32_t cpu_index) {
index 458d3eaca9cb865b8bffdbce9f3082341e7acfab..706db7148ebefe0af889d4f917e7d65e92e8cf9a 100644 (file)
@@ -9,7 +9,7 @@
 
 #include "pmm.h"
 #include "arch/x86/multiboot2.h"
-#include "uart_console.h"
+#include "console.h"
 #include "utils.h"
 #include "hal/mm.h"
 
@@ -25,7 +25,7 @@ static uint64_t align_down_local(uint64_t value, uint64_t align) {
 
 void pmm_arch_init(void* boot_info) {
     if (!boot_info) {
-        uart_print("[PMM] Error: boot_info is NULL!\n");
+        kprintf("[PMM] Error: boot_info is NULL!\n");
         return;
     }
 
@@ -36,7 +36,7 @@ void pmm_arch_init(void* boot_info) {
     int saw_mmap = 0;
     uint64_t freed_frames = 0;
 
-    uart_print("[PMM] Parsing Multiboot2 info...\n");
+    kprintf("[PMM] Parsing Multiboot2 info...\n");
 
     // First pass: determine total memory size
     for (tag = (struct multiboot_tag *)((uint8_t *)boot_info + 8);
@@ -120,18 +120,11 @@ void pmm_arch_init(void* boot_info) {
     // Reserve low memory and frame 0
     pmm_mark_region(0, 0x00100000, 1);
 
-    uart_print("[PMM] total_memory bytes: ");
-    char tmp[11];
-    itoa_hex((uint32_t)total_memory, tmp);
-    uart_print(tmp);
-    uart_print("\n");
-    uart_print("[PMM] freed_frames: ");
-    itoa_hex((uint32_t)freed_frames, tmp);
-    uart_print(tmp);
-    uart_print("\n");
+    kprintf("[PMM] total_memory bytes: 0x%x\n", (unsigned)total_memory);
+    kprintf("[PMM] freed_frames: 0x%x\n", (unsigned)freed_frames);
 
     if (freed_frames == 0) {
-        uart_print("[PMM] WARN: no free frames detected (MMAP missing or parse failed).\n");
+        kprintf("[PMM] WARN: no free frames detected (MMAP missing or parse failed).\n");
     }
 
     // Protect Multiboot2 modules (e.g. initrd)
index 27a0f67ddddc611c80776052ff404e011e10ca32..d10acb4f9079455e5abdd341220f27605ebdf907 100644 (file)
@@ -13,7 +13,7 @@
 #include "arch/x86/percpu.h"
 #include "arch/x86/idt.h"
 #include "arch/x86/gdt.h"
-#include "uart_console.h"
+#include "console.h"
 #include "utils.h"
 #include "io.h"
 #include "hal/cpu.h"
@@ -99,7 +99,7 @@ int smp_enumerate(void) {
         g_cpus[0].cpu_index = 0;
         g_cpus[0].started = 1;
         g_cpus[0].kernel_stack = 0;
-        uart_print("[SMP] Single CPU enumerated.\n");
+        kprintf("[SMP] Single CPU enumerated.\n");
         return 1;
     }
 
@@ -113,11 +113,7 @@ int smp_enumerate(void) {
         g_cpus[i].kernel_stack = (uint32_t)(uintptr_t)&ap_stacks[i][AP_STACK_SIZE];
     }
 
-    char tmp[12];
-    uart_print("[SMP] Enumerated ");
-    itoa(g_cpu_count, tmp, 10);
-    uart_print(tmp);
-    uart_print(" CPU(s).\n");
+    kprintf("[SMP] Enumerated %u CPU(s).\n", (unsigned)g_cpu_count);
 
     return (int)g_cpu_count;
 }
@@ -164,11 +160,7 @@ int smp_start_aps(void) {
     *cr3_ptr = cr3_val;
     *entry_ptr = (uint32_t)(uintptr_t)ap_entry;
 
-    uart_print("[SMP] Starting ");
-    char tmp[12];
-    itoa(g_cpu_count - 1, tmp, 10);
-    uart_print(tmp);
-    uart_print(" AP(s)...\n");
+    kprintf("[SMP] Starting %u AP(s)...\n", (unsigned)(g_cpu_count - 1));
 
     uint8_t sipi_vector = (uint8_t)(AP_TRAMPOLINE_PHYS >> 12);
 
@@ -202,15 +194,9 @@ int smp_start_aps(void) {
         }
 
         if (g_cpus[i].started) {
-            uart_print("[SMP] CPU ");
-            itoa(g_cpus[i].lapic_id, tmp, 10);
-            uart_print(tmp);
-            uart_print(" started.\n");
+            kprintf("[SMP] CPU %u started.\n", (unsigned)g_cpus[i].lapic_id);
         } else {
-            uart_print("[SMP] CPU ");
-            itoa(g_cpus[i].lapic_id, tmp, 10);
-            uart_print(tmp);
-            uart_print(" failed to start!\n");
+            kprintf("[SMP] CPU %u failed to start!\n", (unsigned)g_cpus[i].lapic_id);
         }
     }
 
@@ -219,10 +205,7 @@ int smp_start_aps(void) {
         if (g_cpus[i].started) started++;
     }
 
-    uart_print("[SMP] ");
-    itoa(started, tmp, 10);
-    uart_print(tmp);
-    uart_print(" CPU(s) active.\n");
+    kprintf("[SMP] %u CPU(s) active.\n", (unsigned)started);
 
     return (int)started;
 }
index 165d44e98217704a5e733b391617b358c6808714..265e1bd79e57b422e4ece086f9d1c35ea0b4635c 100644 (file)
@@ -8,7 +8,7 @@
  */
 
 #include "hal/cpu_features.h"
-#include "uart_console.h"
+#include "console.h"
 
 #include <stdint.h>
 
@@ -41,7 +41,7 @@ static int sysenter_enabled = 0;
 void x86_sysenter_init(void) {
     const struct cpu_features* f = hal_cpu_get_features();
     if (!f->has_sysenter) {
-        uart_print("[SYSENTER] CPU does not support SYSENTER/SYSEXIT.\n");
+        kprintf("[SYSENTER] CPU does not support SYSENTER/SYSEXIT.\n");
         return;
     }
 
@@ -57,7 +57,7 @@ void x86_sysenter_init(void) {
     wrmsr(IA32_SYSENTER_EIP, (uintptr_t)sysenter_entry);
 
     sysenter_enabled = 1;
-    uart_print("[SYSENTER] Fast syscall enabled.\n");
+    kprintf("[SYSENTER] Fast syscall enabled.\n");
 }
 
 void x86_sysenter_set_kernel_stack(uintptr_t esp0) {
index dc3a2e3d5560a34e19376943146e8fc18f5877ab..c2c732bd941f148d01ad61f30d156708f32cf94d 100644 (file)
@@ -12,7 +12,7 @@
 
 #include "pmm.h"
 #include "vmm.h"
-#include "uart_console.h"
+#include "console.h"
 #include "utils.h"
  #include "arch/x86/usermode.h"
 #include "arch/x86/idt.h"
@@ -81,14 +81,8 @@ static void* pmm_alloc_page_low_16mb(void) {
 }
 
 __attribute__((noreturn)) void x86_enter_usermode(uintptr_t user_eip, uintptr_t user_esp) {
-    uart_print("[USER] enter ring3 eip=");
-    char tmp[16];
-    itoa_hex((uint32_t)user_eip, tmp);
-    uart_print(tmp);
-    uart_print(" esp=");
-    itoa_hex((uint32_t)user_esp, tmp);
-    uart_print(tmp);
-    uart_print("\n");
+    kprintf("[USER] enter ring3 eip=0x%x esp=0x%x\n",
+            (unsigned)user_eip, (unsigned)user_esp);
 
     __asm__ volatile(
         "cli\n"
@@ -153,7 +147,7 @@ __attribute__((noreturn)) void x86_enter_usermode_regs(const struct registers* r
 }
 
 void x86_usermode_test_start(void) {
-    uart_print("[USER] Starting ring3 test...\n");
+    kprintf("[USER] Starting ring3 test...\n");
 
     const uintptr_t user_code_vaddr = 0x00400000U;
     const uintptr_t user_stack_vaddr = 0x00800000U;
@@ -161,7 +155,7 @@ void x86_usermode_test_start(void) {
     void* code_phys = pmm_alloc_page_low_16mb();
     void* stack_phys = pmm_alloc_page_low_16mb();
     if (!code_phys || !stack_phys) {
-        uart_print("[USER] OOM allocating user pages.\n");
+        kprintf("[USER] OOM allocating user pages.\n");
         return;
     }
 
index 274fbcffe59b4da5e93ce6d180522fbc328faa3b..d540789377e23be7bc3dbdd3b37a2a8bda2943de 100644 (file)
@@ -10,7 +10,7 @@
 #include "vmm.h"
 #include "pmm.h"
 #include "heap.h"
-#include "uart_console.h"
+#include "console.h"
 #include "utils.h"
 #include "hal/cpu.h"
 #include <stddef.h>
@@ -135,7 +135,7 @@ void vmm_map_page(uint64_t phys, uint64_t virt, uint32_t flags) {
     if ((pd[di] & X86_PTE_PRESENT) == 0) {
         uint32_t pt_phys = (uint32_t)(uintptr_t)pmm_alloc_page_low();
         if (!pt_phys) {
-            uart_print("[VMM] OOM allocating page table.\n");
+            kprintf("[VMM] OOM allocating page table.\n");
             return;
         }
 
@@ -445,11 +445,11 @@ int vmm_handle_cow_fault(uintptr_t fault_addr) {
 }
 
 void vmm_init(void) {
-    uart_print("[VMM] PAE paging active.\n");
+    kprintf("[VMM] PAE paging active.\n");
 
     g_kernel_as = hal_cpu_get_address_space();
 
     /* Test mapping */
     vmm_map_page(0xB8000, 0xC00B8000, VMM_FLAG_PRESENT | VMM_FLAG_RW);
-    uart_print("[VMM] Mapped VGA to 0xC00B8000.\n");
+    kprintf("[VMM] Mapped VGA to 0xC00B8000.\n");
 }
index 651444860eb77547c91de81ca2921e1e42b59ba4..61dc936a0e230dc103689059b81838d4853a4ef4 100644 (file)
@@ -12,7 +12,7 @@
 #include "vmm.h"
 #include "pmm.h"
 #include "interrupts.h"
-#include "uart_console.h"
+#include "console.h"
 #include "utils.h"
 #include "io.h"
 
@@ -224,7 +224,7 @@ static void e1000_irq_handler(struct registers* regs) {
 int e1000_init(void) {
     const struct pci_device* dev = pci_find_device(E1000_VENDOR_ID, E1000_DEVICE_ID);
     if (!dev) {
-        uart_print("[E1000] Device not found.\n");
+        kprintf("[E1000] Device not found.\n");
         return -1;
     }
 
@@ -235,7 +235,7 @@ int e1000_init(void) {
     /* Read BAR0 (MMIO base) */
     uint32_t bar0 = dev->bar[0];
     if (bar0 & 1) {
-        uart_print("[E1000] BAR0 is I/O (unsupported).\n");
+        kprintf("[E1000] BAR0 is I/O (unsupported).\n");
         return -1;
     }
     uint32_t mmio_phys = bar0 & 0xFFFFFFF0U;
@@ -270,24 +270,18 @@ int e1000_init(void) {
     /* Read MAC address from EEPROM */
     e1000_read_mac();
 
-    uart_print("[E1000] MAC: ");
-    char hex[4];
-    for (int i = 0; i < 6; i++) {
-        if (i) uart_print(":");
-        hex[0] = "0123456789ABCDEF"[(e1000_mac[i] >> 4) & 0xF];
-        hex[1] = "0123456789ABCDEF"[e1000_mac[i] & 0xF];
-        hex[2] = '\0';
-        uart_print(hex);
-    }
-    uart_print("\n");
+    kprintf("[E1000] MAC: %x:%x:%x:%x:%x:%x\n",
+            (unsigned)e1000_mac[0], (unsigned)e1000_mac[1],
+            (unsigned)e1000_mac[2], (unsigned)e1000_mac[3],
+            (unsigned)e1000_mac[4], (unsigned)e1000_mac[5]);
 
     /* Init TX and RX rings */
     if (e1000_init_tx() < 0) {
-        uart_print("[E1000] Failed to init TX ring.\n");
+        kprintf("[E1000] Failed to init TX ring.\n");
         return -1;
     }
     if (e1000_init_rx() < 0) {
-        uart_print("[E1000] Failed to init RX ring.\n");
+        kprintf("[E1000] Failed to init RX ring.\n");
         return -1;
     }
 
@@ -303,14 +297,8 @@ int e1000_init(void) {
 
     e1000_ready = 1;
 
-    char buf[12];
-    uart_print("[E1000] Initialized, IRQ=");
-    itoa(irq, buf, 10);
-    uart_print(buf);
-    uart_print(", MMIO=");
-    itoa_hex(mmio_phys, buf);
-    uart_print(buf);
-    uart_print("\n");
+    kprintf("[E1000] Initialized, IRQ=%u, MMIO=0x%x\n",
+            (unsigned)irq, (unsigned)mmio_phys);
 
     return 0;
 }
index 0e884e1ac74f1c08f10278d93b55e9d4711e9e5e..0bf51d138df9e2bbc801955058d84a5bc5fce9c5 100644 (file)
@@ -10,7 +10,7 @@
 #include "initrd.h"
 #include "utils.h"
 #include "heap.h"
-#include "uart_console.h"
+#include "console.h"
 #include "errno.h"
 
 #define TAR_BLOCK 512
@@ -303,10 +303,7 @@ fs_node_t* initrd_init(uint32_t location) {
 
     initrd_finalize_nodes();
 
-    uart_print("[INITRD] Found ");
-    char buf[16]; itoa(files, buf, 10);
-    uart_print(buf);
-    uart_print(" files.\n");
+    kprintf("[INITRD] Found %d files.\n", files);
 
     return &nodes[root];
 }
index 553f9f255e13ea957f45aa67cb3ac7af1adae819..7b31431fa52a236f115812de493348f1af388c72 100644 (file)
@@ -9,7 +9,7 @@
 
 #include "keyboard.h"
 #include "devfs.h"
-#include "uart_console.h"
+#include "console.h"
 #include "utils.h"
 #include <stddef.h>
 
@@ -97,7 +97,7 @@ static uint32_t kbd_dev_read(fs_node_t* node, uint32_t offset, uint32_t size, ui
 static fs_node_t g_dev_kbd_node;
 
 void keyboard_init(void) {
-    uart_print("[KBD] Initializing Keyboard Driver...\n");
+    kprintf("[KBD] Initializing Keyboard Driver...\n");
     spinlock_init(&kbd_lock);
     spinlock_init(&scan_lock);
     kbd_head = 0;
index a8cf8f1d899218adba4876b0e09756d8bc443067..ce0896541493d16edce8624a4d5e33554ddc43d7 100644 (file)
@@ -8,7 +8,7 @@
  */
 
 #include "pci.h"
-#include "uart_console.h"
+#include "console.h"
 
 __attribute__((weak))
 uint32_t pci_config_read(uint8_t bus, uint8_t slot, uint8_t func, uint8_t offset) {
@@ -23,7 +23,7 @@ void pci_config_write(uint8_t bus, uint8_t slot, uint8_t func, uint8_t offset, u
 
 __attribute__((weak))
 void pci_init(void) {
-    uart_print("[PCI] Not supported on this architecture.\n");
+    kprintf("[PCI] Not supported on this architecture.\n");
 }
 
 __attribute__((weak))
index f789de1ab5661b7df3812b094b079f9b64c34e7c..ab5899784e86dec0b10f923ec7dbf3cccbf0599e 100644 (file)
@@ -8,7 +8,7 @@
  */
 
 #include "timer.h"
-#include "uart_console.h"
+#include "console.h"
 #include "process.h" 
 #include "vdso.h"
 
@@ -28,6 +28,6 @@ static void hal_tick_bridge(void) {
 }
 
 void timer_init(uint32_t frequency) {
-    uart_print("[TIMER] Initializing...\n");
+    kprintf("[TIMER] Initializing...\n");
     hal_timer_init(frequency, hal_tick_bridge);
 }
index 8205f63714ce73b7d3899253d4b855b0548d9460..d751dbb703e53c41b05c8d78aaf9a0fa4daa593a 100644 (file)
@@ -13,7 +13,7 @@
 #include "devfs.h"
 #include "fb.h"
 #include "uaccess.h"
-#include "uart_console.h"
+#include "console.h"
 #include "utils.h"
 
 #include <stddef.h>
@@ -24,7 +24,7 @@ static fs_node_t g_dev_fb0_node;
 
 int vbe_init(const struct boot_info* bi) {
     if (!bi || bi->fb_addr == 0 || bi->fb_width == 0 || bi->fb_height == 0 || bi->fb_bpp == 0) {
-        uart_print("[VBE] No framebuffer provided by bootloader.\n");
+        kprintf("[VBE] No framebuffer provided by bootloader.\n");
         return -1;
     }
 
@@ -47,18 +47,10 @@ int vbe_init(const struct boot_info* bi) {
     g_vbe.virt_addr = (volatile uint8_t*)virt_base;
     g_vbe_ready = 1;
 
-    uart_print("[VBE] Framebuffer ");
-    char buf[16];
-    itoa(g_vbe.width, buf, 10); uart_print(buf);
-    uart_print("x");
-    itoa(g_vbe.height, buf, 10); uart_print(buf);
-    uart_print("x");
-    itoa(g_vbe.bpp, buf, 10); uart_print(buf);
-    uart_print(" @ 0x");
-    itoa_hex(g_vbe.phys_addr, buf); uart_print(buf);
-    uart_print(" mapped to 0x");
-    itoa_hex(virt_base, buf); uart_print(buf);
-    uart_print("\n");
+    kprintf("[VBE] Framebuffer %ux%ux%u @ 0x%x mapped to 0x%x\n",
+            (unsigned)g_vbe.width, (unsigned)g_vbe.height,
+            (unsigned)g_vbe.bpp, (unsigned)g_vbe.phys_addr,
+            (unsigned)virt_base);
 
     return 0;
 }
@@ -208,5 +200,5 @@ void vbe_register_devfs(void) {
     g_dev_fb0_node.mmap = &fb0_mmap;
     devfs_register_device(&g_dev_fb0_node);
 
-    uart_print("[VBE] Registered /dev/fb0\n");
+    kprintf("[VBE] Registered /dev/fb0\n");
 }
index 8ef5e855ff1f64231fb721a5763b73968360030e..d8dbab1c0ef8f5309adbe23875937ec1fdcb970d 100644 (file)
@@ -14,7 +14,7 @@
 #include "vmm.h"
 #include "arch/x86/idt.h"
 #include "spinlock.h"
-#include "uart_console.h"
+#include "console.h"
 #include "utils.h"
 #include "errno.h"
 
@@ -113,20 +113,20 @@ int ata_dma_init(void) {
     /* Find IDE controller: PCI class 0x01 (Mass Storage), subclass 0x01 (IDE) */
     const struct pci_device* ide = pci_find_class(0x01, 0x01);
     if (!ide) {
-        uart_print("[ATA-DMA] No PCI IDE controller found.\n");
+        kprintf("[ATA-DMA] No PCI IDE controller found.\n");
         return -ENODEV;
     }
 
     /* BAR4 contains the Bus Master IDE I/O base */
     uint32_t bar4 = ide->bar[4];
     if ((bar4 & 1) == 0) {
-        uart_print("[ATA-DMA] BAR4 is not I/O space.\n");
+        kprintf("[ATA-DMA] BAR4 is not I/O space.\n");
         return -ENODEV;
     }
     bm_base = (uint16_t)(bar4 & 0xFFFC);
 
     if (bm_base == 0) {
-        uart_print("[ATA-DMA] BAR4 I/O base is zero.\n");
+        kprintf("[ATA-DMA] BAR4 I/O base is zero.\n");
         return -ENODEV;
     }
 
@@ -139,7 +139,7 @@ int ata_dma_init(void) {
      * We only need 1 PRD entry (8 bytes) but allocate a full page. */
     void* prdt_page = pmm_alloc_page();
     if (!prdt_page) {
-        uart_print("[ATA-DMA] Failed to allocate PRDT page.\n");
+        kprintf("[ATA-DMA] Failed to allocate PRDT page.\n");
         return -ENOMEM;
     }
     prdt_phys = (uint32_t)(uintptr_t)prdt_page;
@@ -155,7 +155,7 @@ int ata_dma_init(void) {
     /* Allocate DMA bounce buffer: one page for sector transfers */
     void* buf_page = pmm_alloc_page();
     if (!buf_page) {
-        uart_print("[ATA-DMA] Failed to allocate DMA buffer page.\n");
+        kprintf("[ATA-DMA] Failed to allocate DMA buffer page.\n");
         pmm_free_page(prdt_page);
         return -ENOMEM;
     }
@@ -179,11 +179,7 @@ int ata_dma_init(void) {
 
     dma_available = 1;
 
-    char tmp[12];
-    uart_print("[ATA-DMA] Initialized, BM I/O base=");
-    itoa_hex(bm_base, tmp);
-    uart_print(tmp);
-    uart_print("\n");
+    kprintf("[ATA-DMA] Initialized, BM I/O base=0x%x\n", (unsigned)bm_base);
 
     return 0;
 }
@@ -250,7 +246,7 @@ static int ata_dma_transfer(uint32_t lba, int is_write) {
         if (bm_stat & BM_STATUS_ERR) {
             outb((uint16_t)(bm_base + BM_CMD), 0);
             outb((uint16_t)(bm_base + BM_STATUS), BM_STATUS_IRQ | BM_STATUS_ERR);
-            uart_print("[ATA-DMA] Bus master error!\n");
+            kprintf("[ATA-DMA] Bus master error!\n");
             return -EIO;
         }
 
@@ -258,7 +254,7 @@ static int ata_dma_transfer(uint32_t lba, int is_write) {
         if (ata_stat & ATA_SR_ERR) {
             outb((uint16_t)(bm_base + BM_CMD), 0);
             outb((uint16_t)(bm_base + BM_STATUS), BM_STATUS_IRQ | BM_STATUS_ERR);
-            uart_print("[ATA-DMA] ATA error during DMA!\n");
+            kprintf("[ATA-DMA] ATA error during DMA!\n");
             return -EIO;
         }
 
@@ -278,7 +274,7 @@ static int ata_dma_transfer(uint32_t lba, int is_write) {
     __atomic_store_n(&dma_active, 0, __ATOMIC_SEQ_CST);
 
     if (!completed) {
-        uart_print("[ATA-DMA] Transfer timeout!\n");
+        kprintf("[ATA-DMA] Transfer timeout!\n");
         return -EIO;
     }
 
index a8c21deae64a2058a2855d7ba5179d22162675c5..0dd3a388a7e7cffa2a04be69ebc43ab76186f319 100644 (file)
@@ -13,7 +13,7 @@
 #include "errno.h"
 #include "io.h"
 #include "arch/x86/idt.h"
-#include "uart_console.h"
+#include "console.h"
 
 /* Basic IRQ 14 handler: read ATA status to deassert INTRQ.
  * Registered early so PIO IDENTIFY doesn't cause an IRQ storm. */
@@ -106,9 +106,9 @@ int ata_pio_init_primary_master(void) {
 
     // Try to upgrade to DMA mode
     if (ata_dma_init() == 0) {
-        uart_print("[ATA] Using DMA mode.\n");
+        kprintf("[ATA] Using DMA mode.\n");
     } else {
-        uart_print("[ATA] Using PIO mode (DMA unavailable).\n");
+        kprintf("[ATA] Using PIO mode (DMA unavailable).\n");
     }
 
     return 0;
index ff8e64b4a4e158c39573f5ffaa59e3e02ef0091c..9411c7ad59abd4ed38e0132a9f3e17c498baa15b 100644 (file)
@@ -9,7 +9,7 @@
 
 #include "hal/cpu_features.h"
 #include "arch/x86/cpuid.h"
-#include "uart_console.h"
+#include "console.h"
 
 #include <stddef.h>
 
@@ -65,7 +65,7 @@ void hal_cpu_detect_features(void) {
         uint32_t cr4 = read_cr4();
         cr4 |= CR4_SMEP;
         write_cr4(cr4);
-        uart_print("[CPU] SMEP enabled.\n");
+        kprintf("[CPU] SMEP enabled.\n");
     }
 
     /* SMAP (Supervisor Mode Access Prevention) is NOT enabled yet because
index 7cba2b9f54b9b2d5f7df3ce636f00d3045bfe0cb..55a16c36bd1b9f6ae06f2ce98fc2b9d966c53da9 100644 (file)
@@ -8,7 +8,7 @@
  */
 
 #include "pci.h"
-#include "uart_console.h"
+#include "console.h"
 #include "utils.h"
 #include "io.h"
 
@@ -108,24 +108,13 @@ void pci_init(void) {
         pci_scan_bus(0);
     }
 
-    uart_print("[PCI] Enumerated ");
-    char buf[8];
-    itoa(pci_device_count, buf, 10);
-    uart_print(buf);
-    uart_print(" device(s)\n");
+    kprintf("[PCI] Enumerated %d device(s)\n", pci_device_count);
 
     for (int i = 0; i < pci_device_count; i++) {
         struct pci_device* d = &pci_devices[i];
-        uart_print("  ");
-        char hex[12];
-        itoa_hex(d->vendor_id, hex); uart_print(hex);
-        uart_print(":");
-        itoa_hex(d->device_id, hex); uart_print(hex);
-        uart_print(" class=");
-        itoa_hex(d->class_code, hex); uart_print(hex);
-        uart_print(":");
-        itoa_hex(d->subclass, hex); uart_print(hex);
-        uart_print("\n");
+        kprintf("  %x:%x class=%x:%x\n",
+                (unsigned)d->vendor_id, (unsigned)d->device_id,
+                (unsigned)d->class_code, (unsigned)d->subclass);
     }
 }
 
index 8ffb9eae22a6d4f9f532151bd21495f5fdf0cc47..3736060638efc76970f3e5e99e85e6c03eaf87d5 100644 (file)
@@ -13,7 +13,7 @@
 #include "arch/x86/idt.h"
 #include "arch/x86/lapic.h"
 #include "io.h"
-#include "uart_console.h"
+#include "console.h"
 
 static hal_timer_tick_cb_t g_tick_cb = 0;
 
index ef72c070a3fac4044a25f802fd1c4fe652163ced..bd2558bbf7169c34237aebd2f82c19a706cb9360 100644 (file)
@@ -8,7 +8,7 @@
  */
 
 #include "hal/cpu_features.h"
-#include "uart_console.h"
+#include "console.h"
 
 #include <stddef.h>
 
@@ -18,7 +18,7 @@ __attribute__((weak))
 void hal_cpu_detect_features(void) {
     for (size_t i = 0; i < sizeof(g_default_features); i++)
         ((uint8_t*)&g_default_features)[i] = 0;
-    uart_print("[CPU] No arch-specific feature detection.\n");
+    kprintf("[CPU] No arch-specific feature detection.\n");
 }
 
 __attribute__((weak))
@@ -28,5 +28,5 @@ const struct cpu_features* hal_cpu_get_features(void) {
 
 __attribute__((weak))
 void hal_cpu_print_features(void) {
-    uart_print("[CPU] Feature detection not available.\n");
+    kprintf("[CPU] Feature detection not available.\n");
 }
index a06bcf30afd9944041d7360b20e4a7ec6fd3039f..cb46b2c5f1eef844b640bdab2b542bdd2d75eea9 100644 (file)
@@ -11,7 +11,7 @@
 #include "ata_pio.h"
 #include "heap.h"
 #include "utils.h"
-#include "uart_console.h"
+#include "console.h"
 #include "errno.h"
 
 #include <stddef.h>
@@ -169,18 +169,18 @@ static fs_node_t* fat16_finddir(fs_node_t* node, const char* name) {
 
 fs_node_t* fat16_mount(uint32_t partition_lba) {
     if (fat16_read_sector(partition_lba, g_sector_buf) < 0) {
-        uart_print("[FAT16] Failed to read BPB\n");
+        kprintf("[FAT16] Failed to read BPB\n");
         return NULL;
     }
 
     struct fat16_bpb* bpb = (struct fat16_bpb*)g_sector_buf;
 
     if (bpb->bytes_per_sector != 512) {
-        uart_print("[FAT16] Unsupported sector size\n");
+        kprintf("[FAT16] Unsupported sector size\n");
         return NULL;
     }
     if (bpb->fat_size_16 == 0 || bpb->num_fats == 0) {
-        uart_print("[FAT16] Invalid BPB\n");
+        kprintf("[FAT16] Invalid BPB\n");
         return NULL;
     }
 
@@ -202,19 +202,7 @@ fs_node_t* fat16_mount(uint32_t partition_lba) {
     g_fat_root.flags = FS_DIRECTORY;
     g_fat_root.finddir = fat16_finddir;
 
-    uart_print("[FAT16] Mounted at LBA ");
-    char buf[12];
-    int bi = 0;
-    uint32_t v = partition_lba;
-    if (v == 0) { buf[bi++] = '0'; }
-    else {
-        char tmp[12]; int ti = 0;
-        while (v) { tmp[ti++] = (char)('0' + v % 10); v /= 10; }
-        while (ti--) buf[bi++] = tmp[ti];
-    }
-    buf[bi] = '\0';
-    uart_print(buf);
-    uart_print("\n");
+    kprintf("[FAT16] Mounted at LBA %u\n", partition_lba);
 
     return &g_fat_root;
 }
index 613ed1f306c75f0b320752ee2e3d009dcaf3838a..f9beb49cacb20b5eab0095fa47c8b1373f1bdb01 100644 (file)
@@ -27,7 +27,7 @@
 #include "socket.h"
 #include "vbe.h"
 #include "keyboard.h"
-#include "uart_console.h"
+#include "console.h"
 
 #include "hal/mm.h"
 
@@ -60,7 +60,7 @@ int init_start(const struct boot_info* bi) {
                                       HAL_MM_MAP_RW, &initrd_virt) == 0) {
             fs_root = initrd_init((uint32_t)initrd_virt);
         } else {
-            uart_print("[INITRD] Failed to map initrd physical range.\n");
+            kprintf("[INITRD] Failed to map initrd physical range.\n");
         }
     }
 
index e3404ca2aaf3c65c1376370c99509b428ae9a85c..a7ff77d795fa0925f9a5cdd9ab62f8219607870e 100644 (file)
@@ -9,7 +9,7 @@
 
 #include "kaslr.h"
 #include "hal/cpu.h"
-#include "uart_console.h"
+#include "console.h"
 
 static uint32_t prng_state;
 
@@ -17,7 +17,7 @@ void kaslr_init(void) {
     uint64_t tsc = hal_cpu_read_timestamp();
     prng_state = (uint32_t)(tsc ^ (tsc >> 32));
     if (prng_state == 0) prng_state = 0xDEADBEEF;
-    uart_print("[KASLR] PRNG seeded from TSC\n");
+    kprintf("[KASLR] PRNG seeded from TSC\n");
 }
 
 uint32_t kaslr_rand(void) {
index 5a6cb97c5ec036e38b413289ccdc059ad38b8f4e..cb61c7c83dbf785c06228769c6b970f777da9a81 100644 (file)
@@ -11,7 +11,6 @@
 #include <stddef.h>
 #include "console.h"
 #include "vga_console.h"
-#include "uart_console.h"
 #include "pmm.h"
 #include "vmm.h"
 #include "process.h"
index 036aef9a0e91ba1e7740da20c63a93f01c81377a..13c33477b1383686e28dceee811a32c60660538e 100644 (file)
@@ -11,7 +11,7 @@
 #include "pmm.h"
 #include "vmm.h"
 #include "heap.h"
-#include "uart_console.h"
+#include "console.h"
 #include "timer.h" // Need access to current tick usually, but we pass it in wake_check
 #include "spinlock.h"
 #include "utils.h"
@@ -628,7 +628,7 @@ struct process* process_find_by_pid(uint32_t pid) {
 }
 
 void process_init(void) {
-    uart_print("[SCHED] Initializing Multitasking...\n");
+    kprintf("[SCHED] Initializing Multitasking...\n");
 
     uintptr_t flags = spin_lock_irqsave(&sched_lock);
 
@@ -636,7 +636,7 @@ void process_init(void) {
     struct process* kernel_proc = (struct process*)kmalloc(sizeof(*kernel_proc));
     if (!kernel_proc) {
         spin_unlock_irqrestore(&sched_lock, flags);
-        uart_print("[SCHED] OOM allocating kernel process struct.\n");
+        kprintf("[SCHED] OOM allocating kernel process struct.\n");
         for(;;) hal_cpu_idle();
         __builtin_unreachable();
     }
@@ -680,7 +680,7 @@ void process_init(void) {
     void* kstack0 = kstack_alloc();
     if (!kstack0) {
         spin_unlock_irqrestore(&sched_lock, flags);
-        uart_print("[SCHED] OOM allocating PID 0 kernel stack.\n");
+        kprintf("[SCHED] OOM allocating PID 0 kernel stack.\n");
         for (;;) hal_cpu_idle();
         __builtin_unreachable();
     }
index e63f715e772925985ca176d95094a07d78a1fd31..01bc1e626f6295e399d1e010b95734bfca040d2b 100644 (file)
@@ -12,7 +12,7 @@
 #include "errno.h"
 #include "process.h"
 #include "waitqueue.h"
-#include "uart_console.h"
+#include "console.h"
 #include "utils.h"
 
 #include "lwip/tcp.h"
index 4c958e0852a3f298f68026e5e4091d1b6eee4018..b1e25bd5c70f37f231bca656786e96a8cdfa42e5 100644 (file)
@@ -13,7 +13,7 @@
 #include "process.h"
 #include "spinlock.h"
 #include "uaccess.h"
-#include "uart_console.h"
+#include "console.h"
 #include "utils.h"
 
 #include "heap.h"
index 237a3c64505153c2512b4dc292e775cee10f02ac..2fdf424c1f5c05e481dd1dcaae573d86e245c4a2 100644 (file)
@@ -14,6 +14,7 @@
 #include "process.h"
 #include "waitqueue.h"
 #include "spinlock.h"
+#include "console.h"
 #include "uart_console.h"
 #include "uaccess.h"
 #include "errno.h"
@@ -285,7 +286,7 @@ void tty_input_char(char c) {
         if (c == 0x03) {
             spin_unlock_irqrestore(&tty_lock, flags);
             if (lflag & TTY_ECHO) {
-                uart_print("^C\n");
+                kprintf("^C\n");
             }
             if (tty_fg_pgrp != 0) {
                 process_kill_pgrp(tty_fg_pgrp, SIGINT_NUM);
@@ -296,7 +297,7 @@ void tty_input_char(char c) {
         if (c == 0x1C) {
             spin_unlock_irqrestore(&tty_lock, flags);
             if (lflag & TTY_ECHO) {
-                uart_print("^\\\n");
+                kprintf("^\\\n");
             }
             if (tty_fg_pgrp != 0) {
                 process_kill_pgrp(tty_fg_pgrp, SIGQUIT_NUM);
@@ -307,7 +308,7 @@ void tty_input_char(char c) {
         if (c == 0x1A) {
             spin_unlock_irqrestore(&tty_lock, flags);
             if (lflag & TTY_ECHO) {
-                uart_print("^Z\n");
+                kprintf("^Z\n");
             }
             if (tty_fg_pgrp != 0) {
                 process_kill_pgrp(tty_fg_pgrp, SIGTSTP_NUM);
@@ -318,7 +319,7 @@ void tty_input_char(char c) {
 
     if (c == 0x04 && (lflag & TTY_ICANON)) {
         if (lflag & TTY_ECHO) {
-            uart_print("^D");
+            kprintf("^D");
         }
         for (uint32_t i = 0; i < line_len; i++) {
             canon_push(line_buf[i]);
@@ -344,7 +345,7 @@ void tty_input_char(char c) {
         if (line_len > 0) {
             line_len--;
             if (lflag & TTY_ECHO) {
-                uart_print("\b \b");
+                kprintf("\b \b");
             }
         }
         spin_unlock_irqrestore(&tty_lock, flags);
index ec41b1c9e5a316ec16f9f2e558c204202d2c19f5..12bc12b18977125ca167911eb5cf52465937c13c 100644 (file)
@@ -11,7 +11,7 @@
 #include "pmm.h"
 #include "vmm.h"
 #include "utils.h"
-#include "uart_console.h"
+#include "console.h"
 
 static uintptr_t vdso_phys = 0;
 static volatile struct vdso_data* vdso_kptr = 0;
@@ -19,7 +19,7 @@ static volatile struct vdso_data* vdso_kptr = 0;
 void vdso_init(void) {
     void* page = pmm_alloc_page();
     if (!page) {
-        uart_print("[VDSO] OOM\n");
+        kprintf("[VDSO] OOM\n");
         return;
     }
     vdso_phys = (uintptr_t)page;
@@ -34,16 +34,7 @@ void vdso_init(void) {
     memset((void*)vdso_kptr, 0, PAGE_SIZE);
     vdso_kptr->tick_hz = 50;
 
-    uart_print("[VDSO] Initialized at phys=0x");
-    /* Simple hex print */
-    char hex[9];
-    for (int i = 7; i >= 0; i--) {
-        uint8_t nib = (uint8_t)((vdso_phys >> (i * 4)) & 0xF);
-        hex[7 - i] = (char)(nib < 10 ? '0' + nib : 'a' + nib - 10);
-    }
-    hex[8] = '\0';
-    uart_print(hex);
-    uart_print("\n");
+    kprintf("[VDSO] Initialized at phys=0x%x\n", (unsigned)vdso_phys);
 }
 
 void vdso_update_tick(uint32_t tick) {
index 7a30d92dd17f76a60898a8f27c04b1509367491e..2821b3c756d99120287546c9c04021d280224f26 100644 (file)
@@ -8,7 +8,7 @@
  */
 
 #include "heap.h"
-#include "uart_console.h"
+#include "console.h"
 #include "pmm.h"
 #include "vmm.h"
 #include "spinlock.h"
@@ -100,7 +100,7 @@ static inline int size_to_order(size_t size) {
 /* ---- Public API ---- */
 
 void kheap_init(void) {
-    uart_print("[HEAP] Initializing Buddy Allocator...\n");
+    kprintf("[HEAP] Initializing Buddy Allocator...\n");
 
     uintptr_t flags = spin_lock_irqsave(&heap_lock);
 
@@ -114,7 +114,7 @@ void kheap_init(void) {
         void* phys = pmm_alloc_page();
         if (!phys) {
             spin_unlock_irqrestore(&heap_lock, flags);
-            uart_print("[HEAP] OOM during init!\n");
+            kprintf("[HEAP] OOM during init!\n");
             return;
         }
         vmm_map_page((uint64_t)(uintptr_t)phys, (uint64_t)va,
@@ -131,7 +131,7 @@ void kheap_init(void) {
     fl_add(&free_lists[BUDDY_MAX_ORDER - BUDDY_MIN_ORDER], blk_to_fn(root));
 
     spin_unlock_irqrestore(&heap_lock, flags);
-    uart_print("[HEAP] 8MB Buddy Allocator Ready.\n");
+    kprintf("[HEAP] 8MB Buddy Allocator Ready.\n");
 }
 
 void* kmalloc(size_t size) {
@@ -151,7 +151,7 @@ void* kmalloc(size_t size) {
 
     if (k > BUDDY_MAX_ORDER) {
         spin_unlock_irqrestore(&heap_lock, flags);
-        uart_print("[HEAP] OOM: kmalloc failed.\n");
+        kprintf("[HEAP] OOM: kmalloc failed.\n");
         return NULL;
     }
 
@@ -161,7 +161,7 @@ void* kmalloc(size_t size) {
 
     if (blk->magic != BUDDY_MAGIC || !blk->is_free) {
         spin_unlock_irqrestore(&heap_lock, flags);
-        uart_print("[HEAP] Corruption in kmalloc!\n");
+        kprintf("[HEAP] Corruption in kmalloc!\n");
         for (;;) hal_cpu_idle();
     }
 
@@ -194,19 +194,15 @@ void kfree(void* ptr) {
 
     if (blk->magic != BUDDY_MAGIC) {
         spin_unlock_irqrestore(&heap_lock, flags);
-        uart_print("[HEAP] Corruption in kfree! (bad magic)\n");
-        char a[11], m[11];
-        itoa_hex((uint32_t)(uintptr_t)blk, a);
-        itoa_hex(blk->magic, m);
-        uart_print("[HEAP] hdr="); uart_print(a);
-        uart_print(" magic=");    uart_print(m);
-        uart_print("\n");
+        kprintf("[HEAP] Corruption in kfree! (bad magic)\n");
+        kprintf("[HEAP] hdr=0x%x magic=0x%x\n",
+                (unsigned)(uintptr_t)blk, (unsigned)blk->magic);
         for (;;) hal_cpu_idle();
     }
 
     if (blk->is_free) {
         spin_unlock_irqrestore(&heap_lock, flags);
-        uart_print("[HEAP] Double free!\n");
+        kprintf("[HEAP] Double free!\n");
         for (;;) hal_cpu_idle();
     }
 
index 351bc3ba7f2e73109135cdeed74698a6085617aa..f655c1262cdf4eb63ccf70e2870817d4885d19b3 100644 (file)
@@ -9,7 +9,7 @@
 
 #include "pmm.h"
 #include "utils.h"
-#include "uart_console.h"
+#include "console.h"
 #include "hal/cpu.h"
 #include "hal/mm.h"
 #include "spinlock.h"
@@ -93,7 +93,7 @@ void pmm_set_limits(uint64_t total_mem, uint64_t max_fr) {
 __attribute__((weak))
 void pmm_arch_init(void* boot_info) {
     (void)boot_info;
-    uart_print("[PMM] No arch-specific memory init. Assuming 16MB.\n");
+    kprintf("[PMM] No arch-specific memory init. Assuming 16MB.\n");
     pmm_set_limits(16 * 1024 * 1024, 0);
 }
 
@@ -135,7 +135,7 @@ void pmm_init(void* boot_info) {
 
     pmm_mark_region(phys_start_aligned, kernel_size, 1);
 
-    uart_print("[PMM] Initialized.\n");
+    kprintf("[PMM] Initialized.\n");
 }
 
 void* pmm_alloc_page(void) {
index 7254e1e7bed32ba6240c480ec721eaaea63ce8ef..85ff18ab09c23a8bfab93e50f7f5299d4684b4e1 100644 (file)
@@ -11,7 +11,7 @@
 #include "pmm.h"
 #include "heap.h"
 #include "hal/mm.h"
-#include "uart_console.h"
+#include "console.h"
 
 #include <stddef.h>
 
index b9f96e597a1e4308b66680e3b2c4daba55027bff..a6bd27ba8438ea2d5c63dd6772ceb354f9217e4e 100644 (file)
@@ -8,7 +8,7 @@
  */
 
 #include "dns.h"
-#include "uart_console.h"
+#include "console.h"
 
 #include "lwip/dns.h"
 #include "lwip/ip_addr.h"
@@ -21,7 +21,7 @@ void dns_resolver_init(uint32_t server_ip) {
                           (server_ip >> 8) & 0xFF,
                           server_ip & 0xFF);
     dns_setserver(0, &dns_server);
-    uart_print("[DNS] Resolver initialized\n");
+    kprintf("[DNS] Resolver initialized\n");
 }
 
 static volatile int dns_done;
index 2dfbb83e38cf78e8fbf0b08c92a6ae08f0c96689..a3a732e8911ae155fba1bbf6296f74f76df65742 100644 (file)
@@ -23,7 +23,7 @@
 #include "netif/ethernet.h"
 
 #include "e1000.h"
-#include "uart_console.h"
+#include "console.h"
 #include "utils.h"
 
 #define E1000_NETIF_MTU  1500
@@ -118,7 +118,7 @@ static void net_init_done(void* arg) {
 
 void net_init(void) {
     if (!e1000_link_up()) {
-        uart_print("[NET] E1000 link down, skipping lwIP init.\n");
+        kprintf("[NET] E1000 link down, skipping lwIP init.\n");
         return;
     }
 
@@ -140,7 +140,7 @@ void net_init(void) {
 
     net_initialized = 1;
 
-    uart_print("[NET] lwIP initialized (threaded), IP=10.0.2.15\n");
+    kprintf("[NET] lwIP initialized (threaded), IP=10.0.2.15\n");
 }
 
 void net_poll(void) {