Index: kernel/arch/ia64/include/drivers/kbd.h
===================================================================
--- kernel/arch/ia64/include/drivers/kbd.h	(revision 323a5aaf36674c20719d102e0508c32ef466bfa3)
+++ kernel/arch/ia64/include/drivers/kbd.h	(revision 323a5aaf36674c20719d102e0508c32ef466bfa3)
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2006 Jakub Jermar, Jakub Vana
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup ia6464	
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_ia64_KBD_H_
+#define KERN_ia64_KBD_H_
+
+
+typedef enum {
+	KBD_UNKNOWN,
+	KBD_SKI,
+	KBD_LEGACY,
+	KBD_NS16550
+} kbd_type_t;
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/ia64/include/interrupt.h
===================================================================
--- kernel/arch/ia64/include/interrupt.h	(revision 8d2760fe0365099552ec91e6cee8c5bbd55ed273)
+++ kernel/arch/ia64/include/interrupt.h	(revision 323a5aaf36674c20719d102e0508c32ef466bfa3)
@@ -57,4 +57,5 @@
 #define IRQ_MOUSE		252
 #define INTERRUPT_SPURIOUS	15
+#define LAGACY_INTERRUPT_BASE	0x20
 
 /** General Exception codes. */
@@ -153,4 +154,5 @@
 extern void disabled_fp_register(uint64_t vector, istate_t *istate);
 
+
 #endif
 
Index: kernel/arch/ia64/src/drivers/ega.c
===================================================================
--- kernel/arch/ia64/src/drivers/ega.c	(revision 8d2760fe0365099552ec91e6cee8c5bbd55ed273)
+++ kernel/arch/ia64/src/drivers/ega.c	(revision 323a5aaf36674c20719d102e0508c32ef466bfa3)
@@ -95,4 +95,5 @@
 	sysinfo_set_item_val("fb.width", NULL, ROW);
 	sysinfo_set_item_val("fb.height", NULL, ROWS);
+	sysinfo_set_item_val("fb.blinking", NULL, true);
 	sysinfo_set_item_val("fb.address.physical", NULL, VIDEORAM & 0xffffffff);
 	
Index: kernel/arch/ia64/src/ia64.c
===================================================================
--- kernel/arch/ia64/src/ia64.c	(revision 8d2760fe0365099552ec91e6cee8c5bbd55ed273)
+++ kernel/arch/ia64/src/ia64.c	(revision 323a5aaf36674c20719d102e0508c32ef466bfa3)
@@ -64,8 +64,10 @@
 
 /*NS16550 as a COM 1*/
-#define NS16550_IRQ 4
+#define NS16550_IRQ (4+LAGACY_INTERRUPT_BASE)
 #define NS16550_PORT 0x3f8
 
 bootinfo_t *bootinfo;
+
+static uint64_t iosapic_base=0xfec00000;
 
 void arch_pre_main(void)
@@ -112,8 +114,34 @@
 }
 
+static void iosapic_init(void)
+{
+
+	uint64_t IOSAPIC = PA2KA((unative_t)(iosapic_base))|FW_OFFSET;
+	int i;
+	
+	
+	for(i=0;i<16;i++)
+	{
+	
+		if(i==2) continue;	 //Disable Cascade interrupt
+		((uint32_t*)(IOSAPIC+0x00))[0]=0x10+2*i;
+		srlz_d();
+		((uint32_t*)(IOSAPIC+0x10))[0]=LAGACY_INTERRUPT_BASE+i;
+		srlz_d();
+		((uint32_t*)(IOSAPIC+0x00))[0]=0x10+2*i+1;
+		srlz_d();
+		((uint32_t*)(IOSAPIC+0x10))[0]=1<<(56-32);
+		srlz_d();
+	}
+
+}
+
+
 void arch_post_mm_init(void)
 {
 	if(config.cpu_active==1)
 	{
+		iosapic_init();
+	
 		irq_init(INR_COUNT, INR_COUNT);
 #ifdef SKI
@@ -123,5 +151,6 @@
 #endif	
 	}
-	it_init();	
+	it_init();
+		
 }
 
@@ -143,5 +172,7 @@
 		i8042_poll();
 #ifdef CONFIG_NS16550
+	#ifndef CONFIG_NS16550_INTERRUPT_DRIVEN
 		ns16550_poll();
+	#endif	
 #endif
 		thread_usleep(POLL_INTERVAL);
@@ -149,4 +180,11 @@
 }
 #endif
+
+
+static void end_of_irq_void(void *cir_arg __attribute__((unused)),inr_t inr __attribute__((unused)))
+{
+	return;
+}
+
 
 void arch_post_smp_init(void)
@@ -172,5 +210,5 @@
 
 #ifdef CONFIG_NS16550
-		ns16550_init(kbd, NS16550_IRQ, NS16550_PORT); // as a COM 1
+		ns16550_init(kbd, NS16550_IRQ, NS16550_PORT,end_of_irq_void,NULL); // as a COM 1
 #else
 #endif
@@ -188,4 +226,8 @@
 	sysinfo_set_item_val("ia64_iospace.address", NULL, true);
 	sysinfo_set_item_val("ia64_iospace.address.virtual", NULL, IO_OFFSET);
+
+
+
+
 
 }
@@ -238,4 +280,10 @@
 #ifdef SKI
 	ski_kbd_grab();
+#else
+	i8042_grab();
+	#ifdef CONFIG_NS16550
+		ns16550_grab();
+	#endif	
+		
 #endif	
 }
@@ -247,4 +295,10 @@
 #ifdef SKI
 	ski_kbd_release();
+	i8042_release();
+#else	
+	#ifdef CONFIG_NS16550
+		ns16550_release();
+	#endif	
+
 #endif
 }
Index: kernel/arch/ia64/src/interrupt.c
===================================================================
--- kernel/arch/ia64/src/interrupt.c	(revision 8d2760fe0365099552ec91e6cee8c5bbd55ed273)
+++ kernel/arch/ia64/src/interrupt.c	(revision 323a5aaf36674c20719d102e0508c32ef466bfa3)
@@ -236,5 +236,5 @@
 }
 
-static void end_of_local_irq()
+static void end_of_local_irq(void)
 {
 	asm volatile ("mov cr.eoi=r0;;");
@@ -244,5 +244,4 @@
 void external_interrupt(uint64_t vector, istate_t *istate)
 {
-	irq_t *irq;
 	cr_ivr_t ivr;
 	
@@ -250,9 +249,4 @@
 	srlz_d();
 
-	irq = irq_dispatch_and_lock(ivr.vector);
-	if (irq) {
-		irq->handler(irq, irq->arg);
-		spinlock_unlock(&irq->lock);
-	} else {
 		switch (ivr.vector) {
 		case INTERRUPT_SPURIOUS:
@@ -271,9 +265,37 @@
 
 		default:
-			panic("\nUnhandled External Interrupt Vector %d\n",
-			    ivr.vector);
+			{
+
+				int ack=false;
+				irq_t *irq = irq_dispatch_and_lock(ivr.vector);
+				if (irq) {
+					/*
+					 * The IRQ handler was found.
+					 */
+		 
+					if (irq->preack) {
+						/* Send EOI before processing the interrupt */
+						end_of_local_irq();
+						ack=true;
+					}
+					irq->handler(irq, irq->arg);
+					spinlock_unlock(&irq->lock);
+				} else {
+					/*
+					 * Unhandled interrupt.
+					 */
+					end_of_local_irq();
+					ack=true;
+#ifdef CONFIG_DEBUG
+					printf("\nUnhandled External Interrupt Vector %d\n",ivr.vector);
+#endif
+				}
+				if(!ack) end_of_local_irq();
+
+			}	
+
+
 			break;
 		}
-	}
 }
 
Index: kernel/arch/ia64/src/ski/ski.c
===================================================================
--- kernel/arch/ia64/src/ski/ski.c	(revision 8d2760fe0365099552ec91e6cee8c5bbd55ed273)
+++ kernel/arch/ia64/src/ski/ski.c	(revision 323a5aaf36674c20719d102e0508c32ef466bfa3)
@@ -45,4 +45,5 @@
 #include <synch/spinlock.h>
 #include <arch/asm.h>
+#include <drivers/kbd.h>
 
 #define SKI_KBD_INR	0
@@ -228,4 +229,5 @@
 	sysinfo_set_item_val("kbd.inr", NULL, SKI_KBD_INR);
 	sysinfo_set_item_val("kbd.devno", NULL, ski_kbd_devno);
+	sysinfo_set_item_val("kbd.type", NULL, KBD_SKI);
 }
 
