Finish ISR code for CPU faults (ISRs 0-31)

This commit is contained in:
Justin C. Miller
2018-04-15 18:40:21 -07:00
parent 2388a92085
commit bce281606e
3 changed files with 33 additions and 11 deletions

View File

@@ -109,9 +109,6 @@ interrupts_init()
{
uint8_t *p;
gdt_load();
gdt_dump(g_gdtr);
p = reinterpret_cast<uint8_t *>(&g_gdt_table);
for (int i = 0; i < sizeof(g_gdt_table); ++i) p[i] = 0;
@@ -127,9 +124,6 @@ interrupts_init()
set_gdt_entry(7, 0, 0xfffff, true, gdt_flags::rw | gdt_flags::ex);
gdt_write();
gdt_load();
gdt_dump(g_gdtr);
p = reinterpret_cast<uint8_t *>(&g_idt_table);
for (int i = 0; i < sizeof(g_idt_table); ++i) p[i] = 0;
@@ -154,10 +148,35 @@ struct registers
void
isr_handler(registers regs)
{
console::get()->puts("received interrupt: ");
console::get()->put_dec(regs.interrupt);
console *cons = console::get();
cons->puts("received interrupt:\n");
#define print_reg(name, value) \
cons->puts(" " name ": "); \
cons->put_hex((value)); \
cons->puts("\n");
print_reg("ISR", regs.interrupt);
print_reg("ERR", regs.errorcode);
console::get()->puts("\n");
while(1);
print_reg(" ds", regs.ds);
print_reg("rdi", regs.rdi);
print_reg("rsi", regs.rsi);
print_reg("rbp", regs.rbp);
print_reg("rsp", regs.rsp);
print_reg("rbx", regs.rbx);
print_reg("rdx", regs.rdx);
print_reg("rcx", regs.rcx);
print_reg("rax", regs.rax);
console::get()->puts("\n");
print_reg("rip", regs.rip);
print_reg(" cs", regs.cs);
print_reg(" ef", regs.eflags);
print_reg("esp", regs.user_esp);
print_reg(" ss", regs.ss);
}

View File

@@ -78,6 +78,7 @@ isr_handler_prelude:
push rcx
push rdx
push rbx
push rsp
push rbp
push rsi
push rdi
@@ -102,11 +103,12 @@ isr_handler_prelude:
pop rdi
pop rsi
pop rbp
pop rsp
pop rbx
pop rdx
pop rcx
pop rax
add rsp, 8 ; because the ISRs added err/num
add rsp, 16 ; because the ISRs added err/num
sti
iretq

View File

@@ -45,8 +45,9 @@ kernel_main(popcorn_data *header)
cons.puts("Interrupts initialized.\n");
// int x = 1 / 0;
// isr31();
__asm__ __volatile__("int $31");
__asm__ __volatile__("int $15");
cons.puts("boogity!");
do_the_set_registers(header);