Index: kernel/arch/ia32/src/interrupt.c
===================================================================
--- kernel/arch/ia32/src/interrupt.c	(revision 95b355086cd805dc6f9cc96f44fa2ef92cecd8b5)
+++ kernel/arch/ia32/src/interrupt.c	(revision 16d71f41c615fdf91941d1ca9fee163d4e90d351)
@@ -52,4 +52,5 @@
 #include <ipc/sysipc.h>
 #include <interrupt.h>
+#include <ddi/irq.h>
 
 /*
@@ -61,5 +62,5 @@
 void (* eoi_function)(void) = NULL;
 
-void PRINT_INFO_ERRCODE(istate_t *istate)
+void decode_istate(istate_t *istate)
 {
 	char *symbol = get_symtab_entry(istate->eip);
@@ -84,14 +85,23 @@
 }
 
-void null_interrupt(int n, istate_t *istate)
+static void trap_virtual_eoi(void)
+{
+	if (eoi_function)
+		eoi_function();
+	else
+		panic("no eoi_function\n");
+
+}
+
+static void null_interrupt(int n, istate_t *istate)
 {
 	fault_if_from_uspace(istate, "unserviced interrupt: %d", n);
 
-	PRINT_INFO_ERRCODE(istate);
+	decode_istate(istate);
 	panic("unserviced interrupt: %d\n", n);
 }
 
 /** General Protection Fault. */
-void gp_fault(int n, istate_t *istate)
+static void gp_fault(int n, istate_t *istate)
 {
 	if (TASK) {
@@ -116,17 +126,17 @@
 	}
 
-	PRINT_INFO_ERRCODE(istate);
+	decode_istate(istate);
 	panic("general protection fault\n");
 }
 
-void ss_fault(int n, istate_t *istate)
+static void ss_fault(int n, istate_t *istate)
 {
 	fault_if_from_uspace(istate, "stack fault");
 
-	PRINT_INFO_ERRCODE(istate);
+	decode_istate(istate);
 	panic("stack fault\n");
 }
 
-void simd_fp_exception(int n, istate_t *istate)
+static void simd_fp_exception(int n, istate_t *istate)
 {
 	uint32_t mxcsr;
@@ -139,10 +149,10 @@
 			     (unative_t)mxcsr);
 
-	PRINT_INFO_ERRCODE(istate);
+	decode_istate(istate);
 	printf("MXCSR: %#zx\n",(unative_t)(mxcsr));
 	panic("SIMD FP exception(19)\n");
 }
 
-void nm_fault(int n, istate_t *istate)
+static void nm_fault(int n, istate_t *istate)
 {
 #ifdef CONFIG_FPU_LAZY     
@@ -154,14 +164,60 @@
 }
 
-void syscall(int n, istate_t *istate)
-{
-	panic("Obsolete syscall handler.");
-}
-
-void tlb_shootdown_ipi(int n, istate_t *istate)
+#ifdef CONFIG_SMP
+static void tlb_shootdown_ipi(int n, istate_t *istate)
 {
 	trap_virtual_eoi();
 	tlb_shootdown_ipi_recv();
 }
+#endif
+
+/** Handler of IRQ exceptions */
+static void irq_interrupt(int n, istate_t *istate)
+{
+	ASSERT(n >= IVT_IRQBASE);
+	
+	int inum = n - IVT_IRQBASE;
+	ASSERT(inum < IRQ_COUNT);
+	ASSERT((inum != IRQ_PIC_SPUR) && (inum != IRQ_PIC1));
+
+	irq_t *irq = irq_dispatch_and_lock(inum);
+	if (irq) {
+		/*
+		 * The IRQ handler was found.
+		 */
+		irq->handler(irq, irq->arg);
+		spinlock_unlock(&irq->lock);
+	} else {
+		/*
+		 * Spurious interrupt.
+		 */
+#ifdef CONFIG_DEBUG
+		printf("cpu%d: spurious interrupt (inum=%d)\n", CPU->id, inum);
+#endif
+	}
+	trap_virtual_eoi();
+}
+
+void interrupt_init(void)
+{
+	int i;
+	
+	for (i = 0; i < IVT_ITEMS; i++)
+		exc_register(i, "null", (iroutine) null_interrupt);
+	
+	for (i = 0; i < IRQ_COUNT; i++) {
+		if ((i != IRQ_PIC_SPUR) && (i != IRQ_PIC1))
+			exc_register(IVT_IRQBASE + i, "irq", (iroutine) irq_interrupt);
+	}
+	
+	exc_register(7, "nm_fault", (iroutine) nm_fault);
+	exc_register(12, "ss_fault", (iroutine) ss_fault);
+	exc_register(13, "gp_fault", (iroutine) gp_fault);
+	exc_register(19, "simd_fp", (iroutine) simd_fp_exception);
+	
+#ifdef CONFIG_SMP
+	exc_register(VECTOR_TLB_SHOOTDOWN_IPI, "tlb_shootdown", (iroutine) tlb_shootdown_ipi);
+#endif
+}
 
 void trap_virtual_enable_irqs(uint16_t irqmask)
@@ -181,13 +237,4 @@
 }
 
-void trap_virtual_eoi(void)
-{
-	if (eoi_function)
-		eoi_function();
-	else
-		panic("no eoi_function\n");
-
-}
-
 /** @}
  */
