rk/kernel/idt.c
2024-05-26 01:33:18 -05:00

22 lines
860 B
C

#include <kernel/idt.h>
#include <kernel/vga.h>
#include <kernel/printf.h>
void encode_idt_entry(struct idt_entry idt[], int i, uint32_t offset, uint16_t segment_selector, uint8_t attributes) {
idt[i].offset_lo = (uint16_t)(offset & 0xFFFF);
idt[i].seg_select = segment_selector;
idt[i].reserved = 0;
idt[i].attributes = attributes;
idt[i].offset_hi = (uint16_t)(offset >> 16);
}
void exception_handler(struct registers regs) {
clear_screen();
printf("Exception 0x%X (0x%X) has occurred\nEAX: 0x%08X\nECX: 0x%08X\nEDX: 0x%08X\nEBX: 0x%08X\nESI: 0x%08X\nEDI: 0x%08X\nEBP: 0x%08X\nESP: 0x%08X\n",
regs.int_no, regs.err_code, regs.eax, regs.ecx, regs.edx, regs.ebx, regs.esi, regs.edi, regs.ebp, regs.esp+24);
printf("\nEIP: 0x%08X\nCS: 0x%08X\nEFLAGS: 0x%08X",
regs.eip, regs.cs, regs.eflags);
}