Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdint.h>
- #include <kernel/idt.h>
- #include <kernel/isr.h>
- #include <stdio.h>
- extern void isr0(); // All our ISRs
- extern void isr1();
- extern void isr2();
- extern void isr3();
- extern void isr4();
- extern void isr5();
- extern void isr6();
- extern void isr7();
- extern void isr8();
- extern void isr9();
- extern void isr10();
- extern void isr11();
- extern void isr12();
- extern void isr13();
- extern void isr14();
- extern void isr15();
- extern void isr16();
- extern void isr17();
- extern void isr18();
- extern void isr19();
- extern void isr20();
- extern void isr21();
- extern void isr22();
- extern void isr23();
- extern void isr24();
- extern void isr25();
- extern void isr26();
- extern void isr27();
- extern void isr28();
- extern void isr29();
- extern void isr30();
- extern void isr31();
- void loadisr (void) {
- idt_setgate(0, (uint32_t)isr0, 0x08, 0x8e); // Populate the IDT with addresses of ISR to call, with appropriate segment and flags
- idt_setgate(1, (uint32_t)isr1, 0x08, 0x8e);
- idt_setgate(2, (uint32_t)isr2, 0x08, 0x8e);
- idt_setgate(3, (uint32_t)isr3, 0x08, 0x8e);
- idt_setgate(4, (uint32_t)isr4, 0x08, 0x8e);
- idt_setgate(5, (uint32_t)isr5, 0x08, 0x8e);
- idt_setgate(6, (uint32_t)isr6, 0x08, 0x8e);
- idt_setgate(7, (uint32_t)isr7, 0x08, 0x8e);
- idt_setgate(8, (uint32_t)isr8, 0x08, 0x8e);
- idt_setgate(9, (uint32_t)isr9, 0x08, 0x8e);
- idt_setgate(10, (uint32_t)isr10, 0x08, 0x8e);
- idt_setgate(11, (uint32_t)isr11, 0x08, 0x8e);
- idt_setgate(12, (uint32_t)isr12, 0x08, 0x8e);
- idt_setgate(13, (uint32_t)isr13, 0x08, 0x8e);
- idt_setgate(14, (uint32_t)isr14, 0x08, 0x8e);
- idt_setgate(15, (uint32_t)isr15, 0x08, 0x8e);
- idt_setgate(16, (uint32_t)isr16, 0x08, 0x8e);
- idt_setgate(17, (uint32_t)isr17, 0x08, 0x8e);
- idt_setgate(18, (uint32_t)isr18, 0x08, 0x8e);
- idt_setgate(19, (uint32_t)isr19, 0x08, 0x8e);
- idt_setgate(20, (uint32_t)isr20, 0x08, 0x8e);
- idt_setgate(21, (uint32_t)isr21, 0x08, 0x8e);
- idt_setgate(22, (uint32_t)isr22, 0x08, 0x8e);
- idt_setgate(23, (uint32_t)isr23, 0x08, 0x8e);
- idt_setgate(24, (uint32_t)isr24, 0x08, 0x8e);
- idt_setgate(25, (uint32_t)isr25, 0x08, 0x8e);
- idt_setgate(26, (uint32_t)isr26, 0x08, 0x8e);
- idt_setgate(27, (uint32_t)isr27, 0x08, 0x8e);
- idt_setgate(28, (uint32_t)isr28, 0x08, 0x8e);
- idt_setgate(29, (uint32_t)isr29, 0x08, 0x8e);
- idt_setgate(30, (uint32_t)isr30, 0x08, 0x8e);
- idt_setgate(31, (uint32_t)isr31, 0x08, 0x8e);
- }
- char *exceptionmsgs[] = { // Messages to print in case of specific exception.
- "divide exception.",
- "debug error.",
- "non-maskable interrupt.",
- "breakpoint exception.",
- "overflow exception.",
- "BOUND range exceeded.",
- "invalid opcode.",
- "no Maths Coprocessor.",
- "double fault.",
- "coprocessor segment overun.",
- "invalid TSS exception.",
- "segment not present exception.",
- "stack segment fault.",
- "general protection fault.",
- "page fault.",
- "reserved exception.",
- "floating-point error.",
- "alignment check exception.",
- "machine check exception.",
- "SIMD floating point exeption.",
- "virtualisation exception.",
- "reserved exception.",
- "reserved exception.",
- "reserved exception.",
- "reserved exception.",
- "reserved exception.",
- "reserved exception.",
- "reserved exception.",
- "reserved exception.",
- "reserved exception.",
- "reserved exception.",
- "reserved exception."
- };
- void isr_handle (struct regs *r) { // Function called from assembly (boot.S) to print out messages detailing exception and to halt.
- if (r->int_no < 32) {
- puts(exceptionmsgs[r->int_no]);
- puts("The system has been halted.");
- for(;;);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment