Efficient DEBUG logging system with __FILE__ and fctprintf

This commit is contained in:
2025-12-28 12:15:32 +01:00
parent ead0ed6ae1
commit 3853a1ace3
9 changed files with 55 additions and 40 deletions

View File

@@ -3,6 +3,7 @@
#include <stddef.h>
#include "../io/serial/serial.h"
#include "../io/kbd/ps2.h"
#include <kernel.h>
struct interrupt_descriptor idt[256];
struct idtr idt_reg;
@@ -49,7 +50,7 @@ void idt_init()
idt_set_entry(i, vector_0_handler + (i*16), 0);
}
idt_load(&idt);
serial_kputs("kernel: idt: Initialized IDT!\n");
DEBUG("IDT initialized");
}
struct cpu_status_t* interrupt_dispatch(struct cpu_status_t* context)
@@ -57,74 +58,74 @@ struct cpu_status_t* interrupt_dispatch(struct cpu_status_t* context)
switch(context->vector_number)
{
case 0:
serial_kputs("kernel: idt: Divide Error!\n");
DEBUG("Divide Error!");
break;
case 1:
serial_kputs("kernel: idt: Debug Exception!\n");
DEBUG("Debug Exception!");
break;
case 2:
serial_kputs("kernel: idt: NMI Interrupt!\n");
DEBUG("NMI Interrupt!");
break;
case 3:
serial_kputs("kernel: idt: Breakpoint Interrupt!\n");
DEBUG("Breakpoint Interrupt!");
break;
case 4:
serial_kputs("kernel: idt: Overflow Trap!\n");
DEBUG("Overflow Trap!");
break;
case 5:
serial_kputs("kernel: idt: BOUND Range Exceeded!\n");
DEBUG("BOUND Range Exceeded!");
break;
case 6:
serial_kputs("kernel: idt: Invalid Opcode!\n");
DEBUG("Invalid Opcode!");
break;
case 7:
serial_kputs("kernel: idt: Device Not Available!\n");
DEBUG("Device Not Available!");
break;
case 8:
serial_kputs("kernel: idt: Double Fault!\n");
DEBUG("Double Fault!");
break;
case 9:
serial_kputs("kernel: idt: Coprocessor Segment Overrun!\n");
DEBUG("Coprocessor Segment Overrun!");
break;
case 10:
serial_kputs("kernel: idt: Invalid TSS!\n");
DEBUG("Invalid TSS!");
break;
case 11:
serial_kputs("kernel: idt: Segment Not Present!\n");
DEBUG("Segment Not Present!");
break;
case 12:
serial_kputs("kernel: idt: Stack-Segment Fault!\n");
DEBUG("Stack-Segment Fault!");
break;
case 13:
serial_kputs("kernel: idt: General Protection Fault!\n");
DEBUG("General Protection Fault!");
break;
case 14:
serial_kputs("kernel: idt: Page Fault!\n");
DEBUG("Page Fault!");
break;
case 15:
serial_kputs("kernel: idt: Intel Reserved Interrupt! (Achievement unlocked: How Did We Get Here?)\n");
DEBUG("Intel Reserved Interrupt! (Achievement unlocked: How Did We Get Here?)");
break;
case 16:
serial_kputs("kernel: idt: x87 Floating-Point Error!\n");
DEBUG("x87 Floating-Point Error!");
break;
case 17:
serial_kputs("kernel: idt: Alignment Check Fault!\n");
DEBUG("Alignment Check Fault!");
break;
case 18:
serial_kputs("kernel: idt: Machine Check!\n");
DEBUG("Machine Check!");
break;
case 19:
serial_kputs("kernel: idt: SIMD Floating-Point Exception!\n");
DEBUG("SIMD Floating-Point Exception!");
break;
case 20:
serial_kputs("kernel: idt: Virtualization Exception!\n");
DEBUG("Virtualization Exception!");
break;
case 21:
serial_kputs("kernel: idt: Control Protection Exception!\n");
DEBUG("Control Protection Exception!");
break;
case 32:
//serial_kputs("Tick!");
DEBUG("Tick!");
ticks++;
// Send an EOI so that we can continue having interrupts
outb(0x20, 0x20);
@@ -135,7 +136,7 @@ struct cpu_status_t* interrupt_dispatch(struct cpu_status_t* context)
break;
default:
serial_kputs("kernel: idt: Unexpected interrupt\n");
DEBUG("Unexpected interrupt");
break;
}