]> 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 6db98ca4e35268f30df5a39b498d6d7a2cb560a0..c7f27a61ed6dbe7ccc9482d7411fb5923a740aa6 100644 (file)
@@ -2,6 +2,7 @@
 #include "kernel/boot_info.h"
 
 #include "uart_console.h"
+#include "console.h"
 
 extern void kernel_main(const struct boot_info* bi);
 
@@ -9,7 +10,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 441a43227372a6007045a7081abb9d7915a2bb2b..ecab9963b0f95eaba3ed14f7797931238a421a05 100644 (file)
@@ -2,6 +2,7 @@
 #include "kernel/boot_info.h"
 
 #include "uart_console.h"
+#include "console.h"
 
 extern void kernel_main(const struct boot_info* bi);
 
@@ -9,7 +10,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 6db98ca4e35268f30df5a39b498d6d7a2cb560a0..c7f27a61ed6dbe7ccc9482d7411fb5923a740aa6 100644 (file)
@@ -2,6 +2,7 @@
 #include "kernel/boot_info.h"
 
 #include "uart_console.h"
+#include "console.h"
 
 extern void kernel_main(const struct boot_info* bi);
 
@@ -9,7 +10,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 f6704b1ddb2db51f39bcbe981ab97fff4c2fbd4e..e271b77a150074a10d1e96b3ad6882cda73c64b8 100644 (file)
@@ -1,5 +1,5 @@
 #include "arch/x86/acpi.h"
-#include "uart_console.h"
+#include "console.h"
 #include "utils.h"
 #include "vmm.h"
 
@@ -35,7 +35,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;
     }
 
@@ -148,15 +148,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. */
@@ -166,7 +162,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;
@@ -176,12 +172,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;
     }
@@ -211,7 +207,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;
     }
 
@@ -219,7 +215,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;
@@ -228,18 +224,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;
     }
@@ -248,26 +244,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 22a7b7498495b0e1ee13e7e2eff6b89359c75233..e7096470ff9108843be2775712b6813fcc84bf84 100644 (file)
@@ -5,6 +5,7 @@
 #include "arch/x86/gdt.h"
 #include "arch/x86/idt.h"
 #include "uart_console.h"
+#include "console.h"
 
 #include "arch/x86/multiboot2.h"
 
@@ -15,21 +16,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;
@@ -49,7 +50,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 44b3ceca792892fc779911fa72148819963a5463..4532297a916f28bf7d32f312579fafb7e83382af 100644 (file)
@@ -5,7 +5,6 @@
 #include "keyboard.h"
 #include "syscall.h"
 #include "timer.h"
-#include "uart_console.h"
 #include "console.h"
 #include "uaccess.h"
 #include "vga_console.h"
@@ -35,7 +34,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();
@@ -56,18 +55,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 9e3d7f4d8708ef52b17f30893d2dcbafaaefb9b9..371476921d2d80d5c599120dc2ea316a2cb98d52 100644 (file)
@@ -1,5 +1,5 @@
 #include "arch/x86/cpuid.h"
-#include "uart_console.h"
+#include "console.h"
 #include "utils.h"
 
 #include <stddef.h>
@@ -99,49 +99,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 c6972d638c2b87e1b0d12ccdafd3b127c2f6917b..9ad36a9462416aa5ee9219e9885bc997841857c7 100644 (file)
@@ -3,7 +3,7 @@
 #include "fs.h"
 #include "heap.h"
 #include "pmm.h"
-#include "uart_console.h"
+#include "console.h"
 #include "utils.h"
 #include "vmm.h"
 
@@ -150,9 +150,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;
     }
 
@@ -199,9 +197,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;
     }
@@ -231,7 +227,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);
@@ -241,7 +237,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);
@@ -268,9 +264,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;
         }
@@ -288,7 +282,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 6fdb813b29d4718468f4a7c061eaa89d07a0a0e6..6d1153bc83a3f59b7bcbde39359d206bbe9157bf 100644 (file)
@@ -1,6 +1,6 @@
 #include "arch/x86/gdt.h"
 
-#include "uart_console.h"
+#include "console.h"
  #include "utils.h"
 
 struct gdt_entry {
@@ -94,7 +94,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;
@@ -112,5 +112,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 720699f5d1ce713bd609f458345ec02e0e1e2b1b..c677665cd961a35ee98fdb8b752fbc799bedab1c 100644 (file)
@@ -1,7 +1,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"
@@ -210,7 +210,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;
@@ -290,7 +290,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) {
@@ -304,12 +304,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
@@ -372,33 +367,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 f162c42ca920f551301647c4947c3d4ab086bdfa..e4d9a14beadd64e8333bc9b856936e7e3d47cd5e 100644 (file)
@@ -1,7 +1,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>
@@ -26,7 +26,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;
     }
 
@@ -53,14 +53,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 608d9f302e6e446d2b655839dd0cac4d99c7c621..e45944306edd5afd00187cb8d597b86e29e1bdf0 100644 (file)
@@ -2,7 +2,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>
@@ -71,11 +71,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;
     }
 
@@ -123,14 +123,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;
 }
@@ -179,14 +173,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 093915109c627e5c327840184758f7a62e18913e..566da8bceae542ac26d3335e5e22d9349badcc7c 100644 (file)
@@ -1,5 +1,5 @@
 #include "mtrr.h"
-#include "uart_console.h"
+#include "console.h"
 
 #define IA32_MTRRCAP       0xFE
 #define IA32_MTRR_DEF_TYPE 0x2FF
@@ -25,26 +25,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 7b395e3ee2e24e1bf48c08a608de8eca9f59d885..7a18138bb1ac392662b573932067c384a2a16782 100644 (file)
@@ -1,7 +1,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>
@@ -40,11 +40,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 bef7f195ce0b6d2935939c20d288ec7b98853126..050d1d064c806bd29e971d522f837f3d72343d42 100644 (file)
@@ -1,6 +1,6 @@
 #include "pmm.h"
 #include "arch/x86/multiboot2.h"
-#include "uart_console.h"
+#include "console.h"
 #include "utils.h"
 #include "hal/mm.h"
 
@@ -16,7 +16,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;
     }
 
@@ -27,7 +27,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);
@@ -111,18 +111,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 e09637e7b7063e89094eab29e574bc38bb74f624..fbc15f4299528a9a71dc964ecbe38e835b304702 100644 (file)
@@ -4,7 +4,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"
@@ -90,7 +90,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;
     }
 
@@ -104,11 +104,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;
 }
@@ -155,11 +151,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);
 
@@ -193,15 +185,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);
         }
     }
 
@@ -210,10 +196,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 b5cccac25c381a4d3fee113c635872fc5b8fdf81..942c261cc168b8b1473493c438e0735e4c3a9b1e 100644 (file)
@@ -1,5 +1,5 @@
 #include "hal/cpu_features.h"
-#include "uart_console.h"
+#include "console.h"
 
 #include <stdint.h>
 
@@ -32,7 +32,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;
     }
 
@@ -48,7 +48,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 376255ffb5a741d071297200b7c55ed505124a1d..d5a10cf2c9d19da23fd1b60087bdbd43aa612fc8 100644 (file)
@@ -3,7 +3,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"
@@ -72,14 +72,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"
@@ -144,7 +138,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;
@@ -152,7 +146,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 8ba36536255172cb034bf1d6f7c7f355781c7f83..8065c7903eae45168d15cc550d26cda160d972b8 100644 (file)
@@ -1,7 +1,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>
@@ -126,7 +126,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;
         }
 
@@ -436,11 +436,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 de3872502dd46fca39d5fe3e3ae6b395183ba6d1..346f876ed18e95e3e54ad802bb49126cc770e084 100644 (file)
@@ -3,7 +3,7 @@
 #include "vmm.h"
 #include "pmm.h"
 #include "interrupts.h"
-#include "uart_console.h"
+#include "console.h"
 #include "utils.h"
 #include "io.h"
 
@@ -215,7 +215,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;
     }
 
@@ -226,7 +226,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;
@@ -261,24 +261,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;
     }
 
@@ -294,14 +288,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 2148eb5c79b50389d755452e5affa1bcc639d932..bd9ecc5bcb0f7dd1165b0b2f8669bf347238e321 100644 (file)
@@ -1,7 +1,7 @@
 #include "initrd.h"
 #include "utils.h"
 #include "heap.h"
-#include "uart_console.h"
+#include "console.h"
 #include "errno.h"
 
 #define TAR_BLOCK 512
@@ -294,10 +294,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 51be178796edc8bda00e89fafbc1fe61f818e4c5..dad757f8fa7dec2998981cd162c02f6ec4037e7a 100644 (file)
@@ -1,6 +1,6 @@
 #include "keyboard.h"
 #include "devfs.h"
-#include "uart_console.h"
+#include "console.h"
 #include "utils.h"
 #include <stddef.h>
 
@@ -88,7 +88,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 41ad5568531958d5b2d5598c3390065b4606541a..3c33fe70b7feabe7a046ba84f56fe4da953a379a 100644 (file)
@@ -1,5 +1,5 @@
 #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) {
@@ -14,7 +14,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 d6bd59b4d3852fbb9e5818b9b780e3df552a6259..d830139c954e4ff8eb6c16351425e81c4e2442a5 100644 (file)
@@ -1,5 +1,5 @@
 #include "timer.h"
-#include "uart_console.h"
+#include "console.h"
 #include "process.h" 
 #include "vdso.h"
 
@@ -19,6 +19,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 3d18076e67683d7bcb6aa24278d7447152ab20c3..38d8ceaca9a66f81a820820c2cd828cc57633282 100644 (file)
@@ -4,7 +4,7 @@
 #include "devfs.h"
 #include "fb.h"
 #include "uaccess.h"
-#include "uart_console.h"
+#include "console.h"
 #include "utils.h"
 
 #include <stddef.h>
@@ -15,7 +15,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;
     }
 
@@ -38,18 +38,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;
 }
@@ -199,5 +191,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 aeb8ce0aaef6fd2a52b85c46a536526b7a5e3b54..d6933a185f27895c484a3b2e923066aeef7f9377 100644 (file)
@@ -5,7 +5,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"
 
@@ -104,20 +104,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;
     }
 
@@ -130,7 +130,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;
@@ -146,7 +146,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;
     }
@@ -170,11 +170,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;
 }
@@ -241,7 +237,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;
         }
 
@@ -249,7 +245,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;
         }
 
@@ -269,7 +265,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 1115dd0140dbcc87a04a0a6102679390fc2d07b1..70799ef32b5dfae9d0993fc183520636b25c25c5 100644 (file)
@@ -4,7 +4,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. */
@@ -97,9 +97,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 662df62aa25bb6f0834e4c28b8e037b19283a99e..2d5762c9453588cf4f2c53c48b4efa0074e1b780 100644 (file)
@@ -1,6 +1,6 @@
 #include "hal/cpu_features.h"
 #include "arch/x86/cpuid.h"
-#include "uart_console.h"
+#include "console.h"
 
 #include <stddef.h>
 
@@ -56,7 +56,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 face81a19d19eff661cf81bb5bb168e9d95c11c6..08b86a79cdfdbcd37122b5943264075497b495b8 100644 (file)
@@ -1,5 +1,5 @@
 #include "pci.h"
-#include "uart_console.h"
+#include "console.h"
 #include "utils.h"
 #include "io.h"
 
@@ -99,24 +99,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 99ee816b4dc36d6c7f481675a5e3abc9de3433d2..9a77215f1c89a44bb39b2d7dc3b6c947fe08b992 100644 (file)
@@ -4,7 +4,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 c50a7cd6739479f8ffe7077e72c153ffc24bac5e..167d95bfa5b1e95f85b903652de616f1b5d76c58 100644 (file)
@@ -1,5 +1,5 @@
 #include "hal/cpu_features.h"
-#include "uart_console.h"
+#include "console.h"
 
 #include <stddef.h>
 
@@ -9,7 +9,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))
@@ -19,5 +19,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 8c26d5ded8bb19dfe55e1cbcb8c88f5656698d8a..6b8f6d06b74fcdf0c1b988cee432adaf4b30d9fd 100644 (file)
@@ -2,7 +2,7 @@
 #include "ata_pio.h"
 #include "heap.h"
 #include "utils.h"
-#include "uart_console.h"
+#include "console.h"
 #include "errno.h"
 
 #include <stddef.h>
@@ -160,18 +160,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;
     }
 
@@ -193,19 +193,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 8302e5d61836e5d3a9af7d867d0b0df3948b4f9f..4f34320ad094536e45120ec1feb9f378d8efb38e 100644 (file)
@@ -18,7 +18,7 @@
 #include "socket.h"
 #include "vbe.h"
 #include "keyboard.h"
-#include "uart_console.h"
+#include "console.h"
 
 #include "hal/mm.h"
 
@@ -51,7 +51,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 04153568e0286319c26ce04ac6c9e6cdbd57267c..2b68bf4628d33c3a729812b8b24bd642201ecf05 100644 (file)
@@ -1,6 +1,6 @@
 #include "kaslr.h"
 #include "hal/cpu.h"
-#include "uart_console.h"
+#include "console.h"
 
 static uint32_t prng_state;
 
@@ -8,7 +8,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 2950c40ab0e73335fb7fafba3f318f7edf44a2f0..83bb740c80b451c9ed3a1dfcce07dfd9d32037b9 100644 (file)
@@ -2,7 +2,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 0b1a3852786e6c245c84809c562c7722ab0a995c..6e6925cf2110a7a5162f9b95f8ffd5777b7e2c71 100644 (file)
@@ -2,7 +2,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"
@@ -619,7 +619,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);
 
@@ -627,7 +627,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();
     }
@@ -671,7 +671,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 ec7baf57bfda0c8c055cee366e821368e1e091f2..2fd3a56037181ffeeea306f662a4b1f29dae318b 100644 (file)
@@ -3,7 +3,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 9edf0222c787eb2590383b2e63a1c7e84761cea2..efe4f73b221f29e7d371e05aab8f0562547482f1 100644 (file)
@@ -4,7 +4,7 @@
 #include "process.h"
 #include "spinlock.h"
 #include "uaccess.h"
-#include "uart_console.h"
+#include "console.h"
 #include "utils.h"
 
 #include "heap.h"
index 5f7403961c76bef196ebfc8987d9a987a66bea2d..4eff563eea0bfe45188ff7305d662dca7d35040f 100644 (file)
@@ -5,6 +5,7 @@
 #include "process.h"
 #include "waitqueue.h"
 #include "spinlock.h"
+#include "console.h"
 #include "uart_console.h"
 #include "uaccess.h"
 #include "errno.h"
@@ -276,7 +277,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);
@@ -287,7 +288,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);
@@ -298,7 +299,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);
@@ -309,7 +310,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]);
@@ -335,7 +336,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 5c09a3374a358fee96bbea06c5e570f2a156a9e0..74a9ae1e725015aeb617e1619ed111f398bc3795 100644 (file)
@@ -2,7 +2,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;
@@ -10,7 +10,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;
@@ -25,16 +25,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 32f68c5a1f808ce7a81d4ad5a521dee93294dd88..68d686406e49dbaecd61c1df514cdccedbf52bae 100644 (file)
@@ -1,5 +1,5 @@
 #include "heap.h"
-#include "uart_console.h"
+#include "console.h"
 #include "pmm.h"
 #include "vmm.h"
 #include "spinlock.h"
@@ -91,7 +91,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);
 
@@ -105,7 +105,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,
@@ -122,7 +122,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) {
@@ -142,7 +142,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;
     }
 
@@ -152,7 +152,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();
     }
 
@@ -185,19 +185,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 71456bd2d3d8aa13e2bb5c15d3c6a2132fb89bc1..e9e5615a26c2a983b8adfd8a87958158555fc806 100644 (file)
@@ -1,6 +1,6 @@
 #include "pmm.h"
 #include "utils.h"
-#include "uart_console.h"
+#include "console.h"
 #include "hal/cpu.h"
 #include "hal/mm.h"
 #include "spinlock.h"
@@ -84,7 +84,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);
 }
 
@@ -126,7 +126,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 911ceaee4ea12ad109ecad5ce3f95a0dc347fe32..fc07f9086d22cf9be5777a9b896e4b4ebe5cc423 100644 (file)
@@ -2,7 +2,7 @@
 #include "pmm.h"
 #include "heap.h"
 #include "hal/mm.h"
-#include "uart_console.h"
+#include "console.h"
 
 #include <stddef.h>
 
index c24e8cd56b12309af0ee7d68bfb8586ed3448480..f276e009600c4bd1fdb28e059bc77e111b346500 100644 (file)
@@ -1,5 +1,5 @@
 #include "dns.h"
-#include "uart_console.h"
+#include "console.h"
 
 #include "lwip/dns.h"
 #include "lwip/ip_addr.h"
@@ -12,7 +12,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 df6ab477a366441488b1bad7dee3f4719f419343..0d5d8d45830f31ef44af37e254a7b90b677c7e34 100644 (file)
@@ -14,7 +14,7 @@
 #include "netif/ethernet.h"
 
 #include "e1000.h"
-#include "uart_console.h"
+#include "console.h"
 #include "utils.h"
 
 #define E1000_NETIF_MTU  1500
@@ -109,7 +109,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;
     }
 
@@ -131,7 +131,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) {