rk/idt.c

22 lines
839 B
C
Raw Normal View History

2024-05-21 22:07:04 -04:00
#include <idt.h>
#include <vga.h>
#include <printf.h>
2024-05-21 22:07:04 -04:00
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);
}