Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void isr_handler(int_reg_t *r) {
- interrupt_lock();
- /* If the int number is in range */
- if (r->int_num < IDT_ENTRIES) {
- if (r->int_num < 32) {
- /* Exception */
- uint64_t cr2;
- asm volatile("movq %%cr2, %0;" : "=r"(cr2));
- /* Ensure the display is not locked when we crash */
- unlock(&base_tty.tty_lock);
- unlock(&vesa_lock);
- clear_buffer();
- tty_seek(0, 0, &base_tty);
- sprintf("\nException!");
- sprintf("\nRAX: %lx RBX: %lx RCX: %lx \nRDX: %lx RBP: %lx RDI: %lx \nRSI: %lx R08: %lx R09: %lx \nR10: %lx R11: %lx R12: %lx \nR13: %lx R14: %lx R15: %lx \nRSP: %lx ERR: %lx INT: %lx \nRIP: %lx CR2: %lx", r->rax, r->rbx, r->rcx, r->rdx, r->rbp, r->rdi, r->rsi, r->r8, r->r9, r->r10, r->r11, r->r12, r->r13, r->r14, r->r15, r->rsp, r->int_err, r->int_num, r->rip, cr2);
- while (1) { asm volatile("hlt"); }
- }
- /* If the entry is present */
- if (handlers[r->int_num]) {
- /* Call the handler */
- handlers[r->int_num](r);
- }
- } else {
- uint64_t cr2;
- asm volatile("movq %%cr2, %0;" : "=r"(cr2));
- sprintf("\nBad int no %lu", r->int_num);
- sprintf("\nRAX: %lx RBX: %lx RCX: %lx \nRDX: %lx RBP: %lx RDI: %lx \nRSI: %lx R08: %lx R09: %lx \nR10: %lx R11: %lx R12: %lx \nR13: %lx R14: %lx R15: %lx \nRSP: %lx ERR: %lx INT: %lx \nRIP: %lx CR2: %lx", r->rax, r->rbx, r->rcx, r->rdx, r->rbp, r->rdi, r->rsi, r->r8, r->r9, r->r10, r->r11, r->r12, r->r13, r->r14, r->r15, r->rsp, r->int_err, r->int_num, r->rip, cr2);
- while (1) { asm volatile("hlt"); }
- }
- interrupt_unlock();
- // If we make it here, send an EOI to our LAPIC
- write_lapic(0xB0, 0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement