Index: arch/amd64/include/drivers/i8042.h
===================================================================
--- arch/amd64/include/drivers/i8042.h	(revision d87c3f3d6ecce3cef508faa5142aa822aa7ad387)
+++ arch/amd64/include/drivers/i8042.h	(revision d87c3f3d6ecce3cef508faa5142aa822aa7ad387)
@@ -0,0 +1,1 @@
+../../../ia32/include/drivers/i8042.h
Index: arch/amd64/include/i8042.h
===================================================================
--- arch/amd64/include/i8042.h	(revision 02f441c01218d2e5f05985b7f7d8eb6487119248)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../../ia32/include/i8042.h
Index: arch/sparc64/Makefile.inc
===================================================================
--- arch/sparc64/Makefile.inc	(revision 02f441c01218d2e5f05985b7f7d8eb6487119248)
+++ arch/sparc64/Makefile.inc	(revision d87c3f3d6ecce3cef508faa5142aa822aa7ad387)
@@ -58,5 +58,13 @@
 CONFIG_ASID_FIFO = y
 
+## Compile with support for framebuffer.
+#
+
 CONFIG_FB = y
+
+## Compile with support for i8042 controller.
+#
+
+CONFIG_I8042 = y
 
 ARCH_SOURCES = \
Index: arch/sparc64/include/console.h
===================================================================
--- arch/sparc64/include/console.h	(revision 02f441c01218d2e5f05985b7f7d8eb6487119248)
+++ arch/sparc64/include/console.h	(revision d87c3f3d6ecce3cef508faa5142aa822aa7ad387)
@@ -31,4 +31,5 @@
 
 extern void kofwinput(void *arg);
+extern void kkbdpoll(void *arg);
 extern void ofw_sparc64_console_init(void);
 extern void standalone_sparc64_console_init(void);
Index: arch/sparc64/include/drivers/i8042.h
===================================================================
--- arch/sparc64/include/drivers/i8042.h	(revision d87c3f3d6ecce3cef508faa5142aa822aa7ad387)
+++ arch/sparc64/include/drivers/i8042.h	(revision d87c3f3d6ecce3cef508faa5142aa822aa7ad387)
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2006 Jakub Jermar
+ * 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.
+ */
+
+#ifndef __sparc64_I8042_H__
+#define __sparc64_I8042_H__
+
+#include <arch/types.h>
+
+#define KBD_PHYS_ADDRESS	0x1fff8904000ULL
+#define KBD_VIRT_ADDRESS	0x00000d00000ULL
+
+#define STATUS_REG	4
+#define COMMAND_REG	4
+#define DATA_REG	6
+
+static inline void i8042_data_write(__u8 data)
+{
+	((__u8 *)(KBD_VIRT_ADDRESS))[DATA_REG] = data;
+}
+
+static inline __u8 i8042_data_read(void)
+{
+	return ((volatile __u8 *)(KBD_VIRT_ADDRESS))[DATA_REG];
+}
+
+static inline __u8 i8042_status_read(void)
+{
+	return ((volatile __u8 *)(KBD_VIRT_ADDRESS))[STATUS_REG];
+}
+
+static inline void i8042_command_write(__u8 command)
+{
+	((__u8 *)(KBD_VIRT_ADDRESS))[COMMAND_REG] = command;
+}
+
+#endif
Index: arch/sparc64/include/drivers/keyboard.h
===================================================================
--- arch/sparc64/include/drivers/keyboard.h	(revision 02f441c01218d2e5f05985b7f7d8eb6487119248)
+++ 	(revision )
@@ -1,35 +1,0 @@
-/*
- * Copyright (C) 2006 Jakub Jermar
- * 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.
- */
-
-#ifndef __sparc64_KEYBOARD_H__
-#define __sparc64_KEYBOARD_H__
-
-#define KBD_PHYS_ADDRESS	0x1fff8904000ULL
-#define KBD_VIRT_ADDRESS	0x00000d00000ULL
-
-#endif
Index: arch/sparc64/include/interrupt.h
===================================================================
--- arch/sparc64/include/interrupt.h	(revision 02f441c01218d2e5f05985b7f7d8eb6487119248)
+++ arch/sparc64/include/interrupt.h	(revision d87c3f3d6ecce3cef508faa5142aa822aa7ad387)
@@ -35,4 +35,11 @@
 #define IVT_FIRST	1
 
+/* Dummy macros. */
+#define IRQ_KBD		2
+#define VECTOR_KBD	IRQ_KBD
+
+#define trap_virtual_enable_irqs(x)
+#define trap_virtual_eoi()
+
 extern void interrupt_register(int n, const char *name, iroutine f);
 
Index: arch/sparc64/src/console.c
===================================================================
--- arch/sparc64/src/console.c	(revision 02f441c01218d2e5f05985b7f7d8eb6487119248)
+++ arch/sparc64/src/console.c	(revision d87c3f3d6ecce3cef508faa5142aa822aa7ad387)
@@ -32,5 +32,6 @@
 #include <genarch/fb/fb.h>
 #include <arch/drivers/fb.h>
-#include <arch/drivers/keyboard.h>
+#include <arch/drivers/i8042.h>
+#include <genarch/i8042/i8042.h>
 #include <genarch/ofw/ofw.h>
 #include <console/chardev.h>
@@ -40,4 +41,6 @@
 #include <proc/thread.h>
 #include <synch/mutex.h>
+
+#define KEYBOARD_POLL_PAUSE	50000	/* 50ms */
 
 static void ofw_sparc64_putchar(chardev_t *d, const char ch);
@@ -74,4 +77,5 @@
 	stdin = NULL;
 	fb_init(FB_VIRT_ADDRESS, FB_X_RES, FB_Y_RES, FB_COLOR_DEPTH/8);
+	i8042_init();
 }
 
@@ -156,5 +160,17 @@
 			chardev_push_character(&ofw_sparc64_console, ch);
 		}
-		thread_usleep(25000);
+		thread_usleep(KEYBOARD_POLL_PAUSE);
 	}
 }
+
+/** Kernel thread for polling keyboard.
+ *
+ * @param arg Ignored.
+ */
+void kkbdpoll(void *arg)
+{
+	while (1) {
+		i8042_poll();		
+		thread_usleep(KEYBOARD_POLL_PAUSE);
+	}
+}
Index: arch/sparc64/src/mm/tlb.c
===================================================================
--- arch/sparc64/src/mm/tlb.c	(revision 02f441c01218d2e5f05985b7f7d8eb6487119248)
+++ arch/sparc64/src/mm/tlb.c	(revision d87c3f3d6ecce3cef508faa5142aa822aa7ad387)
@@ -43,5 +43,5 @@
 
 #include <arch/drivers/fb.h>
-#include <arch/drivers/keyboard.h>
+#include <arch/drivers/i8042.h>
 
 char *context_encoding[] = {
Index: arch/sparc64/src/sparc64.c
===================================================================
--- arch/sparc64/src/sparc64.c	(revision 02f441c01218d2e5f05985b7f7d8eb6487119248)
+++ arch/sparc64/src/sparc64.c	(revision d87c3f3d6ecce3cef508faa5142aa822aa7ad387)
@@ -62,4 +62,12 @@
 		panic("cannot create kofwinput\n");
 	thread_ready(t);
+
+	/*
+         * Create thread that polls keyboard.
+         */
+	t = thread_create(kkbdpoll, NULL, TASK, 0);
+	if (!t)
+		panic("cannot create kkbdpoll\n");
+	thread_ready(t);
 }
 
Index: arch/sparc64/src/start.S
===================================================================
--- arch/sparc64/src/start.S	(revision 02f441c01218d2e5f05985b7f7d8eb6487119248)
+++ arch/sparc64/src/start.S	(revision d87c3f3d6ecce3cef508faa5142aa822aa7ad387)
@@ -102,4 +102,6 @@
 	nop
 
+	wrpr %r0, 0, %pil
+
 	call main_bsp
 	nop
