+}
+
+void
+intr_set_fallback_handler(int_subscriber subscribers)
+{
+ fallback = subscribers;
+}
+
+extern x86_page_table* __kernel_ptd;
+
+void
+intr_handler(isr_param* param)
+{
+ __current->intr_ctx = *param;
+
+#ifdef USE_KERNEL_PT
+ cpu_lcr3(__kernel_ptd);
+
+ vmm_mount_pd(PD_MOUNT_1, __current->page_table);
+#endif
+
+ isr_param* lparam = &__current->intr_ctx;
+
+ if (lparam->vector <= 255) {
+ int_subscriber subscriber = subscribers[lparam->vector];
+ if (subscriber) {
+ subscriber(param);
+ goto done;
+ }
+ }
+
+ if (fallback) {
+ fallback(lparam);
+ goto done;
+ }
+
+ kprint_panic("INT %u: (%x) [%p: %p] Unknown",
+ lparam->vector,
+ lparam->err_code,
+ lparam->cs,
+ lparam->eip);
+
+done:
+ // for all external interrupts except the spurious interrupt
+ // this is required by Intel Manual Vol.3A, section 10.8.1 & 10.8.5
+ if (lparam->vector >= EX_INTERRUPT_BEGIN &&
+ lparam->vector != APIC_SPIV_IV) {
+ apic_done_servicing();
+ }
+
+#ifdef USE_KERNEL_PT
+ cpu_lcr3(__current->page_table);
+#endif
+ return;