#include #include #include void (*irq_handlers[256])(isr_stack_t *r) = { 0 }; void register_interrupt_handler(uint8_t n, void (*handler)(isr_stack_t *)) { irq_handlers[n] = handler; } void isr_handler(isr_stack_t *r) { if (irq_handlers[r->int_no]) { irq_handlers[r->int_no](r); } else { printf("Unhandled interrupt: %d\n", r->int_no); } /* Send EOI to PIC */ if (r->int_no >= 40) { outb(0xA0, 0x20); } if (r->int_no >= 32) { outb(0x20, 0x20); } } void syscall_handler(regs_t *r) { switch (r->eax) { case 0: printf("Syscall: Hello world\n"); break; case 1: printf("Syscall: value = %d\n", r->ebx); break; default: printf("Unknown syscall %d\n", r->eax); } }