mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 00:14:32 -08:00
Finish ISR code for CPU faults (ISRs 0-31)
This commit is contained in:
@@ -109,9 +109,6 @@ interrupts_init()
|
|||||||
{
|
{
|
||||||
uint8_t *p;
|
uint8_t *p;
|
||||||
|
|
||||||
gdt_load();
|
|
||||||
gdt_dump(g_gdtr);
|
|
||||||
|
|
||||||
p = reinterpret_cast<uint8_t *>(&g_gdt_table);
|
p = reinterpret_cast<uint8_t *>(&g_gdt_table);
|
||||||
for (int i = 0; i < sizeof(g_gdt_table); ++i) p[i] = 0;
|
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);
|
set_gdt_entry(7, 0, 0xfffff, true, gdt_flags::rw | gdt_flags::ex);
|
||||||
|
|
||||||
gdt_write();
|
gdt_write();
|
||||||
gdt_load();
|
|
||||||
gdt_dump(g_gdtr);
|
|
||||||
|
|
||||||
p = reinterpret_cast<uint8_t *>(&g_idt_table);
|
p = reinterpret_cast<uint8_t *>(&g_idt_table);
|
||||||
for (int i = 0; i < sizeof(g_idt_table); ++i) p[i] = 0;
|
for (int i = 0; i < sizeof(g_idt_table); ++i) p[i] = 0;
|
||||||
|
|
||||||
@@ -154,10 +148,35 @@ struct registers
|
|||||||
void
|
void
|
||||||
isr_handler(registers regs)
|
isr_handler(registers regs)
|
||||||
{
|
{
|
||||||
console::get()->puts("received interrupt: ");
|
console *cons = console::get();
|
||||||
console::get()->put_dec(regs.interrupt);
|
|
||||||
|
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");
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ isr_handler_prelude:
|
|||||||
push rcx
|
push rcx
|
||||||
push rdx
|
push rdx
|
||||||
push rbx
|
push rbx
|
||||||
|
push rsp
|
||||||
push rbp
|
push rbp
|
||||||
push rsi
|
push rsi
|
||||||
push rdi
|
push rdi
|
||||||
@@ -102,11 +103,12 @@ isr_handler_prelude:
|
|||||||
pop rdi
|
pop rdi
|
||||||
pop rsi
|
pop rsi
|
||||||
pop rbp
|
pop rbp
|
||||||
|
pop rsp
|
||||||
pop rbx
|
pop rbx
|
||||||
pop rdx
|
pop rdx
|
||||||
pop rcx
|
pop rcx
|
||||||
pop rax
|
pop rax
|
||||||
|
|
||||||
add rsp, 8 ; because the ISRs added err/num
|
add rsp, 16 ; because the ISRs added err/num
|
||||||
sti
|
sti
|
||||||
iretq
|
iretq
|
||||||
|
|||||||
@@ -45,8 +45,9 @@ kernel_main(popcorn_data *header)
|
|||||||
|
|
||||||
cons.puts("Interrupts initialized.\n");
|
cons.puts("Interrupts initialized.\n");
|
||||||
|
|
||||||
|
// int x = 1 / 0;
|
||||||
// isr31();
|
// isr31();
|
||||||
__asm__ __volatile__("int $31");
|
__asm__ __volatile__("int $15");
|
||||||
|
|
||||||
cons.puts("boogity!");
|
cons.puts("boogity!");
|
||||||
do_the_set_registers(header);
|
do_the_set_registers(header);
|
||||||
|
|||||||
Reference in New Issue
Block a user