Index: kernel/arch/amd64/src/amd64.c
===================================================================
--- kernel/arch/amd64/src/amd64.c	(revision e06da7efc998285c1aa3d8a9ceb29e2a5aea6fdb)
+++ kernel/arch/amd64/src/amd64.c	(revision 411b6a6f0339f865eaac5f492f2277fdfbbd5fcc)
@@ -44,5 +44,6 @@
 #include <genarch/drivers/ega/ega.h>
 #include <arch/drivers/vesa.h>
-#include <genarch/kbd/i8042.h>
+#include <genarch/drivers/i8042/i8042.h>
+#include <genarch/kbrd/kbrd.h>
 #include <arch/drivers/i8254.h>
 #include <arch/drivers/i8259.h>
@@ -190,6 +191,13 @@
 {
 	devno_t devno = device_assign_devno();
-	/* keyboard controller */
-	(void) i8042_init((i8042_t *) I8042_BASE, devno, IRQ_KBD);
+
+        /*
+	 * Initialize the keyboard module and conect it to stdin. Then
+	 * initialize the i8042 controller and connect it to kbrdin. Enable
+	 * keyboard interrupts.
+         */
+	kbrd_init(stdin);
+	(void) i8042_init((i8042_t *) I8042_BASE, devno, IRQ_KBD, &kbrdin);
+	trap_virtual_enable_irqs(1 << IRQ_KBD);
 
 	/*
Index: kernel/arch/ia32/src/ia32.c
===================================================================
--- kernel/arch/ia32/src/ia32.c	(revision e06da7efc998285c1aa3d8a9ceb29e2a5aea6fdb)
+++ kernel/arch/ia32/src/ia32.c	(revision 411b6a6f0339f865eaac5f492f2277fdfbbd5fcc)
@@ -45,5 +45,6 @@
 #include <genarch/drivers/ega/ega.h>
 #include <arch/drivers/vesa.h>
-#include <genarch/kbd/i8042.h>
+#include <genarch/drivers/i8042/i8042.h>
+#include <genarch/kbrd/kbrd.h>
 #include <arch/drivers/i8254.h>
 #include <arch/drivers/i8259.h>
@@ -148,6 +149,13 @@
 {
 	devno_t devno = device_assign_devno();
-	/* keyboard controller */
-	(void) i8042_init((i8042_t *) I8042_BASE, devno, IRQ_KBD);
+
+	/*
+	 * Initialize the keyboard module and conect it to stdin. Then
+	 * initialize the i8042 controller and connect it to kbrdin. Enable
+	 * keyboard interrupts.
+	 */
+	kbrd_init(stdin);
+	(void) i8042_init((i8042_t *) I8042_BASE, devno, IRQ_KBD, &kbrdin);
+	trap_virtual_enable_irqs(1 << IRQ_KBD);
 
 	/*
Index: kernel/arch/ia64/src/ia64.c
===================================================================
--- kernel/arch/ia64/src/ia64.c	(revision e06da7efc998285c1aa3d8a9ceb29e2a5aea6fdb)
+++ kernel/arch/ia64/src/ia64.c	(revision 411b6a6f0339f865eaac5f492f2277fdfbbd5fcc)
@@ -55,5 +55,6 @@
 #include <genarch/drivers/legacy/ia32/io.h>
 #include <genarch/drivers/ega/ega.h>
-#include <genarch/kbd/i8042.h>
+#include <genarch/kbrd/kbrd.h>
+#include <genarch/drivers/i8042/i8042.h>
 #include <genarch/kbd/ns16550.h>
 #include <smp/smp.h>
@@ -178,5 +179,7 @@
 #else
 	inr = IRQ_KBD;
-	(void) i8042_init((i8042_t *)I8042_BASE, devno, inr);
+	kbrd_init(stdin);
+	(void) i8042_init((i8042_t *)I8042_BASE, devno, inr, &kbrdin);
+	trap_virtual_enable_irqs(1 << inr);
 	sysinfo_set_item_val("kbd.type", NULL, KBD_LEGACY);
 	sysinfo_set_item_val("kbd.address.physical", NULL,
Index: kernel/arch/ia64/src/smp/smp.c
===================================================================
--- kernel/arch/ia64/src/smp/smp.c	(revision e06da7efc998285c1aa3d8a9ceb29e2a5aea6fdb)
+++ kernel/arch/ia64/src/smp/smp.c	(revision 411b6a6f0339f865eaac5f492f2277fdfbbd5fcc)
@@ -53,6 +53,4 @@
 #include <ddi/device.h>
 #include <arch/bootinfo.h>
-#include <genarch/kbd/i8042.h>
-#include <genarch/kbd/ns16550.h>
 #include <smp/smp.h>
 #include <smp/ipi.h>
Index: kernel/arch/sparc64/src/console.c
===================================================================
--- kernel/arch/sparc64/src/console.c	(revision e06da7efc998285c1aa3d8a9ceb29e2a5aea6fdb)
+++ kernel/arch/sparc64/src/console.c	(revision 411b6a6f0339f865eaac5f492f2277fdfbbd5fcc)
@@ -41,11 +41,4 @@
 #include <arch/drivers/sgcn.h>
 
-#ifdef CONFIG_Z8530
-#include <genarch/kbd/z8530.h>
-#endif
-#ifdef CONFIG_NS16550
-#include <genarch/kbd/ns16550.h>
-#endif
-
 #include <console/chardev.h>
 #include <console/console.h>
@@ -71,6 +64,4 @@
 {
 #ifdef CONFIG_FB
-	stdin = NULL;
-
 	ofw_tree_property_t *prop;
 	ofw_tree_node_t *screen;
Index: kernel/arch/sparc64/src/drivers/kbd.c
===================================================================
--- kernel/arch/sparc64/src/drivers/kbd.c	(revision e06da7efc998285c1aa3d8a9ceb29e2a5aea6fdb)
+++ kernel/arch/sparc64/src/drivers/kbd.c	(revision 411b6a6f0339f865eaac5f492f2277fdfbbd5fcc)
@@ -35,10 +35,16 @@
 #include <arch/drivers/kbd.h>
 #include <genarch/ofw/ofw_tree.h>
+
+#ifdef CONFIG_SUN_KBD
+#include <genarch/kbrd/kbrd.h>
+#endif
 #ifdef CONFIG_Z8530
-#include <genarch/kbd/z8530.h>
+#include <genarch/drivers/z8530/z8530.h>
 #endif
 #ifdef CONFIG_NS16550
-#include <genarch/kbd/ns16550.h>
-#endif
+#include <genarch/drivers/ns16550/ns16550.h>
+#endif
+
+#include <console/console.h>
 #include <ddi/device.h>
 #include <ddi/irq.h>
@@ -160,5 +166,6 @@
 		z8530 = (z8530_t *) hw_map(aligned_addr, offset + size) +
 		    offset;
-		(void) z8530_init(z8530, devno, inr, cir, cir_arg);
+		kbrd_init(stdin);
+		(void) z8530_init(z8530, devno, inr, cir, cir_arg, &kbrdin);
 		
 		/*
@@ -180,5 +187,6 @@
 		ns16550 = (ns16550_t *) hw_map(aligned_addr, offset + size) +
 		    offset;
-		(void) ns16550_init(ns16550, devno, inr, cir, cir_arg);
+		kbrd_init(stdin);
+		(void) ns16550_init(ns16550, devno, inr, cir, cir_arg, &kbrdin);
 		
 		/*
Index: kernel/arch/sparc64/src/sparc64.c
===================================================================
--- kernel/arch/sparc64/src/sparc64.c	(revision e06da7efc998285c1aa3d8a9ceb29e2a5aea6fdb)
+++ kernel/arch/sparc64/src/sparc64.c	(revision 411b6a6f0339f865eaac5f492f2277fdfbbd5fcc)
@@ -90,6 +90,4 @@
 		 */
 		irq_init(1 << 11, 128);
-
-		standalone_sparc64_console_init();
 	}
 }
@@ -105,11 +103,12 @@
 void arch_post_smp_init(void)
 {
-	static thread_t *t = NULL;
+	if (config.cpu_active == 1) {
+		standalone_sparc64_console_init();
 
-	if (!t) {
-		/*
-	         * Create thread that polls keyboard.
-	         */
-		t = thread_create(kkbdpoll, NULL, TASK, 0, "kkbdpoll", true);
+		/* Create thread that polls keyboard.
+		 * XXX: this is only used by sgcn now
+		 */
+		thread_t *t = thread_create(kkbdpoll, NULL, TASK, 0, "kkbdpoll",
+		    true);
 		if (!t)
 			panic("Cannot create kkbdpoll.");
Index: kernel/genarch/Makefile.inc
===================================================================
--- kernel/genarch/Makefile.inc	(revision e06da7efc998285c1aa3d8a9ceb29e2a5aea6fdb)
+++ kernel/genarch/Makefile.inc	(revision 411b6a6f0339f865eaac5f492f2277fdfbbd5fcc)
@@ -71,26 +71,30 @@
 ifeq ($(CONFIG_I8042),y)
 	GENARCH_SOURCES += \
-		genarch/src/kbd/i8042.c \
-		genarch/src/kbd/key.c \
-		genarch/src/kbd/scanc_pc.c
+		genarch/src/drivers/i8042/i8042.c
+endif
+
+ifeq ($(CONFIG_NS16550),y)
+	GENARCH_SOURCES += \
+		genarch/src/drivers/ns16550/ns16550.c
+endif
+
+ifeq ($(CONFIG_Z8530),y)
+	GENARCH_SOURCES += \
+		genarch/src/drivers/z8530/z8530.c
+endif
+
+ifeq ($(CONFIG_PC_KBD),y)
+	GENARCH_SOURCES += \
+		genarch/src/kbrd/kbrd.c \
+		genarch/src/kbrd/scanc_pc.c
 endif
 
 ifeq ($(CONFIG_SUN_KBD),y)
 	GENARCH_SOURCES += \
-		genarch/src/kbd/key.c \
-		genarch/src/kbd/scanc_sun.c
+		genarch/src/kbrd/kbrd.c \
+		genarch/src/kbrd/scanc_sun.c
 endif
 
-ifeq ($(CONFIG_Z8530),y)
-	GENARCH_SOURCES += \
-		genarch/src/kbd/z8530.c
-endif
-
-ifeq ($(CONFIG_NS16550),y)
-	GENARCH_SOURCES += \
-		genarch/src/kbd/ns16550.c
-endif
-
-ifeq ($(CONFIG_OFW_TREE), y)
+ifeq ($(CONFIG_OFW_TREE),y)
 	GENARCH_SOURCES += \
 		genarch/src/ofw/ofw_tree.c \
Index: kernel/genarch/include/drivers/i8042/i8042.h
===================================================================
--- kernel/genarch/include/drivers/i8042/i8042.h	(revision 411b6a6f0339f865eaac5f492f2277fdfbbd5fcc)
+++ kernel/genarch/include/drivers/i8042/i8042.h	(revision 411b6a6f0339f865eaac5f492f2277fdfbbd5fcc)
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2001-2004 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.
+ */
+
+/** @addtogroup genarch	
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_I8042_H_
+#define KERN_I8042_H_
+
+#include <ddi/irq.h>
+#include <arch/types.h>
+#include <console/chardev.h>
+#include <typedefs.h>
+
+struct i8042 {
+	ioport8_t data;
+	uint8_t pad[3];
+	ioport8_t status;
+} __attribute__ ((packed));
+typedef struct i8042 i8042_t;
+
+typedef struct i8042_instance {
+	devno_t devno;
+	irq_t irq;
+	i8042_t *i8042;
+	chardev_t *devout;
+} i8042_instance_t;
+
+extern bool i8042_init(i8042_t *, devno_t, inr_t, chardev_t *);
+
+#endif
+
+/** @}
+ */
Index: kernel/genarch/include/drivers/ns16550/ns16550.h
===================================================================
--- kernel/genarch/include/drivers/ns16550/ns16550.h	(revision 411b6a6f0339f865eaac5f492f2277fdfbbd5fcc)
+++ kernel/genarch/include/drivers/ns16550/ns16550.h	(revision 411b6a6f0339f865eaac5f492f2277fdfbbd5fcc)
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2001-2004 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.
+ */
+
+/** @addtogroup genarch	
+ * @{
+ */
+/**
+ * @file
+ * @brief	Headers for NS 16550 serial controller.
+ */
+
+#ifndef KERN_NS16550_H_
+#define KERN_NS16550_H_
+
+#include <ddi/irq.h>
+#include <arch/types.h>
+#include <console/chardev.h>
+
+#define IER_ERBFI	0x01	/** Enable Receive Buffer Full Interrupt. */
+
+#define LCR_DLAB	0x80	/** Divisor Latch Access bit. */
+
+#define MCR_OUT2	0x08	/** OUT2. */
+
+/** NS16550 registers. */
+struct ns16550 {
+	ioport8_t rbr;	/**< Receiver Buffer Register. */
+	ioport8_t ier;	/**< Interrupt Enable Register. */
+	union {
+		ioport8_t iir;	/**< Interrupt Ident Register (read). */
+		ioport8_t fcr;	/**< FIFO control register (write). */
+	} __attribute__ ((packed));
+	ioport8_t lcr;	/**< Line Control register. */
+	ioport8_t mcr;	/**< Modem Control Register. */
+	ioport8_t lsr;	/**< Line Status Register. */
+} __attribute__ ((packed));
+typedef struct ns16550 ns16550_t;
+
+/** Structure representing the ns16550 device. */
+typedef struct ns16550_instance {
+	devno_t devno;
+	ns16550_t *ns16550;
+	irq_t irq;
+	chardev_t *devout;
+} ns16550_instance_t;
+
+extern bool ns16550_init(ns16550_t *, devno_t, inr_t, cir_t, void *,
+    chardev_t *);
+extern irq_ownership_t ns16550_claim(irq_t *);
+extern void ns16550_irq_handler(irq_t *);
+
+#endif
+
+/** @}
+ */
Index: kernel/genarch/include/drivers/z8530/z8530.h
===================================================================
--- kernel/genarch/include/drivers/z8530/z8530.h	(revision 411b6a6f0339f865eaac5f492f2277fdfbbd5fcc)
+++ kernel/genarch/include/drivers/z8530/z8530.h	(revision 411b6a6f0339f865eaac5f492f2277fdfbbd5fcc)
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2009 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.
+ */
+
+/** @addtogroup genarch	
+ * @{
+ */
+/**
+ * @file
+ * @brief	Headers for Zilog 8530 serial controller.
+ */
+
+#ifndef KERN_Z8530_H_
+#define KERN_Z8530_H_
+
+#include <ddi/irq.h>
+#include <arch/types.h>
+#include <console/chardev.h>
+
+#define WR0	0
+#define WR1	1
+#define WR2	2
+#define WR3	3
+#define WR4	4
+#define WR5	5
+#define WR6	6
+#define WR7	7
+#define WR8	8
+#define WR9	9
+#define WR10	10
+#define WR11	11
+#define WR12	12
+#define WR13	13
+#define WR14	14
+#define WR15	15
+
+#define RR0	0
+#define RR1	1
+#define RR2	2
+#define RR3	3
+#define RR8	8
+#define RR10	10
+#define RR12	12
+#define RR13	13
+#define RR14	14
+#define RR15	15
+
+/** Reset pending TX interrupt. */
+#define WR0_TX_IP_RST	(0x5 << 3)
+#define WR0_ERR_RST	(0x6 << 3)
+
+/** Receive Interrupts Disabled. */
+#define WR1_RID		(0x0 << 3)
+/** Receive Interrupt on First Character or Special Condition. */
+#define WR1_RIFCSC	(0x1 << 3)
+/** Interrupt on All Receive Characters or Special Conditions. */
+#define WR1_IARCSC	(0x2 << 3)
+/** Receive Interrupt on Special Condition. */
+#define WR1_RISC	(0x3 << 3)
+/** Parity Is Special Condition. */
+#define WR1_PISC	(0x1 << 2)
+
+/** Rx Enable. */
+#define WR3_RX_ENABLE	(0x1 << 0)
+/** 8-bits per character. */
+#define WR3_RX8BITSCH	(0x3 << 6)
+
+/** Master Interrupt Enable. */
+#define WR9_MIE		(0x1 << 3)
+
+/** Receive Character Available. */
+#define RR0_RCA		(0x1 << 0)
+
+/** z8530's registers. */
+struct z8530 {
+	union {
+		ioport8_t ctl_b;
+		ioport8_t status_b;
+	} __attribute__ ((packed));
+	uint8_t pad1;
+	ioport8_t data_b;
+	uint8_t pad2;
+	union {
+		ioport8_t ctl_a;
+		ioport8_t status_a;
+	} __attribute__ ((packed));
+	uint8_t pad3;
+	ioport8_t data_a;
+} __attribute__ ((packed));
+typedef struct z8530 z8530_t;
+
+/** Structure representing the z8530 device. */
+typedef struct {
+	devno_t devno;
+	irq_t irq;
+	z8530_t *z8530;
+	chardev_t *devout;
+} z8530_instance_t;
+
+extern bool z8530_init(z8530_t *, devno_t, inr_t, cir_t, void *, chardev_t *);
+extern irq_ownership_t z8530_claim(irq_t *);
+extern void z8530_irq_handler(irq_t *);
+
+#endif
+
+/** @}
+ */
Index: kernel/genarch/include/kbd/i8042.h
===================================================================
--- kernel/genarch/include/kbd/i8042.h	(revision e06da7efc998285c1aa3d8a9ceb29e2a5aea6fdb)
+++ 	(revision )
@@ -1,60 +1,0 @@
-/*
- * Copyright (c) 2001-2004 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.
- */
-
-/** @addtogroup genarch	
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_I8042_H_
-#define KERN_I8042_H_
-
-#include <ddi/irq.h>
-#include <arch/types.h>
-#include <typedefs.h>
-
-struct i8042 {
-	ioport8_t data;
-	uint8_t pad[3];
-	ioport8_t status;
-} __attribute__ ((packed));
-typedef struct i8042 i8042_t;
-
-typedef struct i8042_instance {
-	devno_t devno;
-	irq_t irq;
-	i8042_t *i8042;
-} i8042_instance_t;
-
-extern bool i8042_init(i8042_t *, devno_t, inr_t);
-
-#endif
-
-/** @}
- */
Index: kernel/genarch/include/kbd/key.h
===================================================================
--- kernel/genarch/include/kbd/key.h	(revision e06da7efc998285c1aa3d8a9ceb29e2a5aea6fdb)
+++ 	(revision )
@@ -1,55 +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.
- */
-
-/** @addtogroup genarch	
- * @{
- */
-/**
- * @file
- */
-
-#ifndef KERN_KEY_H_
-#define KERN_KEY_H_
-
-#include <arch/types.h>
-#include <console/chardev.h>
-
-#define KEY_RELEASE     0x80
-
-extern chardev_t kbrd;
-
-extern void key_released(uint8_t sc);
-extern void key_pressed(uint8_t sc);
-extern uint8_t active_read_buff_read(void);
-extern void active_read_buff_write(uint8_t ch);
-extern void active_read_key_pressed(uint8_t sc);
-
-#endif
-
-/** @}
- */
Index: kernel/genarch/include/kbd/ns16550.h
===================================================================
--- kernel/genarch/include/kbd/ns16550.h	(revision e06da7efc998285c1aa3d8a9ceb29e2a5aea6fdb)
+++ 	(revision )
@@ -1,78 +1,0 @@
-/*
- * Copyright (c) 2001-2004 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.
- */
-
-/** @addtogroup genarch	
- * @{
- */
-/**
- * @file
- * @brief	Headers for NS 16550 serial port / keyboard driver.
- */
-
-#ifndef KERN_NS16550_H_
-#define KERN_NS16550_H_
-
-#include <ddi/irq.h>
-#include <arch/types.h>
-#include <arch/drivers/kbd.h>
-
-#define IER_ERBFI	0x01	/** Enable Receive Buffer Full Interrupt. */
-
-#define LCR_DLAB	0x80	/** Divisor Latch Access bit. */
-
-#define MCR_OUT2	0x08	/** OUT2. */
-
-/** NS16550 registers. */
-struct ns16550 {
-	ioport8_t rbr;	/**< Receiver Buffer Register. */
-	ioport8_t ier;	/**< Interrupt Enable Register. */
-	union {
-		ioport8_t iir;	/**< Interrupt Ident Register (read). */
-		ioport8_t fcr;	/**< FIFO control register (write). */
-	} __attribute__ ((packed));
-	ioport8_t lcr;	/**< Line Control register. */
-	ioport8_t mcr;	/**< Modem Control Register. */
-	ioport8_t lsr;	/**< Line Status Register. */
-} __attribute__ ((packed));
-typedef struct ns16550 ns16550_t;
-
-/** Structure representing the ns16550 device. */
-typedef struct ns16550_instance {
-	devno_t devno;
-	ns16550_t *ns16550;
-	irq_t irq;
-} ns16550_instance_t;
-
-extern bool ns16550_init(ns16550_t *, devno_t, inr_t, cir_t, void *);
-extern irq_ownership_t ns16550_claim(irq_t *);
-extern void ns16550_irq_handler(irq_t *);
-
-#endif
-
-/** @}
- */
Index: kernel/genarch/include/kbd/scanc.h
===================================================================
--- kernel/genarch/include/kbd/scanc.h	(revision e06da7efc998285c1aa3d8a9ceb29e2a5aea6fdb)
+++ 	(revision )
@@ -1,47 +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.
- */
-
-/** @addtogroup genarch	
- * @{
- */
-/**
- * @file
- */
-
-#ifndef KERN_SCANC_H_
-#define KERN_SCANC_H_
-
-#define SPECIAL         '?'
-
-extern char sc_primary_map[];
-extern char sc_secondary_map[];
-
-#endif
-
-/** @}
- */
Index: kernel/genarch/include/kbd/scanc_pc.h
===================================================================
--- kernel/genarch/include/kbd/scanc_pc.h	(revision e06da7efc998285c1aa3d8a9ceb29e2a5aea6fdb)
+++ 	(revision )
@@ -1,57 +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.
- */
-
-/** @addtogroup genarch	
- * @{
- */
-/**
- * @file
- * @brief	Scan codes for pc keyboards.
- */
-
-#ifndef KERN_SCANC_PC_H_
-#define KERN_SCANC_PC_H_
-
-#define SC_ESC		0x01
-#define SC_BACKSPACE	0x0e
-#define SC_LSHIFT       0x2a
-#define SC_RSHIFT       0x36
-#define SC_CAPSLOCK     0x3a
-#define SC_SPEC_ESCAPE  0xe0
-#define SC_LEFTARR      0x4b
-#define SC_RIGHTARR     0x4d
-#define SC_UPARR        0x48
-#define SC_DOWNARR      0x50
-#define SC_DELETE       0x53
-#define SC_HOME         0x47
-#define SC_END          0x4f
-
-#endif
-
-/** @}
- */
Index: kernel/genarch/include/kbd/scanc_sun.h
===================================================================
--- kernel/genarch/include/kbd/scanc_sun.h	(revision e06da7efc998285c1aa3d8a9ceb29e2a5aea6fdb)
+++ 	(revision )
@@ -1,57 +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.
- */
-
-/** @addtogroup genarch	
- * @{
- */
-/**
- * @file
- * @brief	Scan codes for sun keyboards.
- */
-
-#ifndef KERN_SCANC_SUN_H_
-#define KERN_SCANC_SUN_H_
-
-#define SC_ESC		0x1d
-#define SC_BACKSPACE	0x2b
-#define SC_LSHIFT       0x63
-#define SC_RSHIFT       0x6e
-#define SC_CAPSLOCK     0x77
-#define SC_SPEC_ESCAPE  0xe0	/* ??? */
-#define SC_LEFTARR      0x18
-#define SC_RIGHTARR     0x1c
-#define SC_UPARR        0x14
-#define SC_DOWNARR      0x1b
-#define SC_DELETE       0x42
-#define SC_HOME         0x34
-#define SC_END          0x4a
-
-#endif
-
-/** @}
- */
Index: kernel/genarch/include/kbd/z8530.h
===================================================================
--- kernel/genarch/include/kbd/z8530.h	(revision e06da7efc998285c1aa3d8a9ceb29e2a5aea6fdb)
+++ 	(revision )
@@ -1,129 +1,0 @@
-/*
- * Copyright (c) 2001-2004 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.
- */
-
-/** @addtogroup genarch	
- * @{
- */
-/**
- * @file
- * @brief	Headers for Zilog 8530 serial port / keyboard driver.
- */
-
-#ifndef KERN_Z8530_H_
-#define KERN_Z8530_H_
-
-#include <ddi/irq.h>
-#include <arch/types.h>
-
-#define WR0	0
-#define WR1	1
-#define WR2	2
-#define WR3	3
-#define WR4	4
-#define WR5	5
-#define WR6	6
-#define WR7	7
-#define WR8	8
-#define WR9	9
-#define WR10	10
-#define WR11	11
-#define WR12	12
-#define WR13	13
-#define WR14	14
-#define WR15	15
-
-#define RR0	0
-#define RR1	1
-#define RR2	2
-#define RR3	3
-#define RR8	8
-#define RR10	10
-#define RR12	12
-#define RR13	13
-#define RR14	14
-#define RR15	15
-
-/** Reset pending TX interrupt. */
-#define WR0_TX_IP_RST	(0x5 << 3)
-#define WR0_ERR_RST	(0x6 << 3)
-
-/** Receive Interrupts Disabled. */
-#define WR1_RID		(0x0 << 3)
-/** Receive Interrupt on First Character or Special Condition. */
-#define WR1_RIFCSC	(0x1 << 3)
-/** Interrupt on All Receive Characters or Special Conditions. */
-#define WR1_IARCSC	(0x2 << 3)
-/** Receive Interrupt on Special Condition. */
-#define WR1_RISC	(0x3 << 3)
-/** Parity Is Special Condition. */
-#define WR1_PISC	(0x1 << 2)
-
-/** Rx Enable. */
-#define WR3_RX_ENABLE	(0x1 << 0)
-/** 8-bits per character. */
-#define WR3_RX8BITSCH	(0x3 << 6)
-
-/** Master Interrupt Enable. */
-#define WR9_MIE		(0x1 << 3)
-
-/** Receive Character Available. */
-#define RR0_RCA		(0x1 << 0)
-
-/** z8530's registers. */
-struct z8530 {
-	union {
-		ioport8_t ctl_b;
-		ioport8_t status_b;
-	} __attribute__ ((packed));
-	uint8_t pad1;
-	ioport8_t data_b;
-	uint8_t pad2;
-	union {
-		ioport8_t ctl_a;
-		ioport8_t status_a;
-	} __attribute__ ((packed));
-	uint8_t pad3;
-	ioport8_t data_a;
-} __attribute__ ((packed));
-typedef struct z8530 z8530_t;
-
-/** Structure representing the z8530 device. */
-typedef struct {
-	devno_t devno;
-	irq_t irq;
-	z8530_t *z8530;
-} z8530_instance_t;
-
-extern bool z8530_init(z8530_t *, devno_t, inr_t, cir_t, void *);
-extern irq_ownership_t z8530_claim(irq_t *);
-extern void z8530_irq_handler(irq_t *);
-
-#endif
-
-/** @}
- */
Index: kernel/genarch/include/kbrd/kbrd.h
===================================================================
--- kernel/genarch/include/kbrd/kbrd.h	(revision 411b6a6f0339f865eaac5f492f2277fdfbbd5fcc)
+++ kernel/genarch/include/kbrd/kbrd.h	(revision 411b6a6f0339f865eaac5f492f2277fdfbbd5fcc)
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup genarch	
+ * @{
+ */
+/**
+ * @file
+ */
+
+#ifndef KERN_KBD_H_
+#define KERN_KBD_H_
+
+#include <console/chardev.h>
+
+extern chardev_t kbrdin;
+
+extern void kbrd_init(chardev_t *);
+
+#endif
+
+/** @}
+ */
Index: kernel/genarch/include/kbrd/scanc.h
===================================================================
--- kernel/genarch/include/kbrd/scanc.h	(revision 411b6a6f0339f865eaac5f492f2277fdfbbd5fcc)
+++ kernel/genarch/include/kbrd/scanc.h	(revision 411b6a6f0339f865eaac5f492f2277fdfbbd5fcc)
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup genarch	
+ * @{
+ */
+/**
+ * @file
+ */
+
+#ifndef KERN_SCANC_H_
+#define KERN_SCANC_H_
+
+#define SPECIAL         '?'
+
+extern char sc_primary_map[];
+extern char sc_secondary_map[];
+
+#endif
+
+/** @}
+ */
Index: kernel/genarch/include/kbrd/scanc_pc.h
===================================================================
--- kernel/genarch/include/kbrd/scanc_pc.h	(revision 411b6a6f0339f865eaac5f492f2277fdfbbd5fcc)
+++ kernel/genarch/include/kbrd/scanc_pc.h	(revision 411b6a6f0339f865eaac5f492f2277fdfbbd5fcc)
@@ -0,0 +1,57 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup genarch	
+ * @{
+ */
+/**
+ * @file
+ * @brief	Scan codes for pc keyboards.
+ */
+
+#ifndef KERN_SCANC_PC_H_
+#define KERN_SCANC_PC_H_
+
+#define SC_ESC		0x01
+#define SC_BACKSPACE	0x0e
+#define SC_LSHIFT       0x2a
+#define SC_RSHIFT       0x36
+#define SC_CAPSLOCK     0x3a
+#define SC_SPEC_ESCAPE  0xe0
+#define SC_LEFTARR      0x4b
+#define SC_RIGHTARR     0x4d
+#define SC_UPARR        0x48
+#define SC_DOWNARR      0x50
+#define SC_DELETE       0x53
+#define SC_HOME         0x47
+#define SC_END          0x4f
+
+#endif
+
+/** @}
+ */
Index: kernel/genarch/include/kbrd/scanc_sun.h
===================================================================
--- kernel/genarch/include/kbrd/scanc_sun.h	(revision 411b6a6f0339f865eaac5f492f2277fdfbbd5fcc)
+++ kernel/genarch/include/kbrd/scanc_sun.h	(revision 411b6a6f0339f865eaac5f492f2277fdfbbd5fcc)
@@ -0,0 +1,57 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup genarch	
+ * @{
+ */
+/**
+ * @file
+ * @brief	Scan codes for sun keyboards.
+ */
+
+#ifndef KERN_SCANC_SUN_H_
+#define KERN_SCANC_SUN_H_
+
+#define SC_ESC		0x1d
+#define SC_BACKSPACE	0x2b
+#define SC_LSHIFT       0x63
+#define SC_RSHIFT       0x6e
+#define SC_CAPSLOCK     0x77
+#define SC_SPEC_ESCAPE  0xe0	/* ??? */
+#define SC_LEFTARR      0x18
+#define SC_RIGHTARR     0x1c
+#define SC_UPARR        0x14
+#define SC_DOWNARR      0x1b
+#define SC_DELETE       0x42
+#define SC_HOME         0x34
+#define SC_END          0x4a
+
+#endif
+
+/** @}
+ */
Index: kernel/genarch/src/drivers/i8042/i8042.c
===================================================================
--- kernel/genarch/src/drivers/i8042/i8042.c	(revision 411b6a6f0339f865eaac5f492f2277fdfbbd5fcc)
+++ kernel/genarch/src/drivers/i8042/i8042.c	(revision 411b6a6f0339f865eaac5f492f2277fdfbbd5fcc)
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2009 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.
+ */
+
+/** @addtogroup genarch	
+ * @{
+ */
+/**
+ * @file
+ * @brief	i8042 processor driver
+ *
+ * It takes care of the i8042 serial communication.
+ */
+
+#include <genarch/drivers/i8042/i8042.h>
+#include <genarch/drivers/legacy/ia32/io.h>
+#include <arch/asm.h>
+#include <console/chardev.h>
+#include <mm/slab.h>
+
+#define i8042_SET_COMMAND 	0x60
+#define i8042_COMMAND 		0x69
+
+#define i8042_BUFFER_FULL_MASK	0x01
+#define i8042_WAIT_MASK		0x02
+
+static irq_ownership_t i8042_claim(irq_t *irq)
+{
+	i8042_instance_t *i8042_instance = irq->instance;
+	i8042_t *dev = i8042_instance->i8042;
+	if (pio_read_8(&dev->status) & i8042_BUFFER_FULL_MASK)
+		return IRQ_ACCEPT;
+	else
+		return IRQ_DECLINE;
+}
+
+static void i8042_irq_handler(irq_t *irq)
+{
+	i8042_instance_t *instance = irq->instance;
+	i8042_t *dev = instance->i8042;
+
+	uint8_t data;
+	uint8_t status;
+		
+	if (((status = pio_read_8(&dev->status)) & i8042_BUFFER_FULL_MASK)) {
+		data = pio_read_8(&dev->data);
+			
+		if (instance->devout)
+			chardev_push_character(instance->devout, data);
+	}
+}
+
+/** Initialize i8042. */
+bool
+i8042_init(i8042_t *dev, devno_t devno, inr_t inr, chardev_t *devout)
+{
+	i8042_instance_t *instance;
+
+	instance = malloc(sizeof(i8042_instance_t), FRAME_ATOMIC);
+	if (!instance)
+		return false;
+	
+	instance->devno = devno;
+	instance->i8042 = dev;
+	instance->devout = devout;
+	
+	irq_initialize(&instance->irq);
+	instance->irq.devno = devno;
+	instance->irq.inr = inr;
+	instance->irq.claim = i8042_claim;
+	instance->irq.handler = i8042_irq_handler;
+	instance->irq.instance = instance;
+	irq_register(&instance->irq);
+	
+	/*
+	 * Clear input buffer.
+	 */
+	while (pio_read_8(&dev->status) & i8042_BUFFER_FULL_MASK)
+		(void) pio_read_8(&dev->data);
+	
+	return true;
+}
+
+/** @}
+ */
Index: kernel/genarch/src/drivers/ns16550/ns16550.c
===================================================================
--- kernel/genarch/src/drivers/ns16550/ns16550.c	(revision 411b6a6f0339f865eaac5f492f2277fdfbbd5fcc)
+++ kernel/genarch/src/drivers/ns16550/ns16550.c	(revision 411b6a6f0339f865eaac5f492f2277fdfbbd5fcc)
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2009 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.
+ */
+
+/** @addtogroup genarch	
+ * @{
+ */
+/**
+ * @file
+ * @brief	NS 16550 serial controller driver.
+ */
+
+#include <genarch/drivers/ns16550/ns16550.h>
+#include <ddi/irq.h>
+#include <arch/asm.h>
+#include <console/chardev.h>
+#include <mm/slab.h>
+
+#define LSR_DATA_READY	0x01
+
+/** Initialize ns16550.
+ *
+ * @param dev		Addrress of the beginning of the device in I/O space.
+ * @param devno		Device number.
+ * @param inr		Interrupt number.
+ * @param cir		Clear interrupt function.
+ * @param cir_arg	First argument to cir.
+ * @param devout	Output character device.
+ *
+ * @return		True on success, false on failure.
+ */
+bool
+ns16550_init(ns16550_t *dev, devno_t devno, inr_t inr, cir_t cir, void *cir_arg,
+    chardev_t *devout)
+{
+	ns16550_instance_t *instance;
+	
+	instance = malloc(sizeof(ns16550_instance_t), FRAME_ATOMIC);
+	if (!instance)
+		return false;
+
+	instance->devno = devno;
+	instance->ns16550 = dev;
+	instance->devout = devout;
+	
+	irq_initialize(&instance->irq);
+	instance->irq.devno = devno;
+	instance->irq.inr = inr;
+	instance->irq.claim = ns16550_claim;
+	instance->irq.handler = ns16550_irq_handler;
+	instance->irq.instance = instance;
+	instance->irq.cir = cir;
+	instance->irq.cir_arg = cir_arg;
+	irq_register(&instance->irq);
+
+	while ((pio_read_8(&dev->lsr) & LSR_DATA_READY))
+		(void) pio_read_8(&dev->rbr);
+	
+	/* Enable interrupts */
+	pio_write_8(&dev->ier, IER_ERBFI);
+	pio_write_8(&dev->mcr, MCR_OUT2);
+	
+	return true;
+}
+
+irq_ownership_t ns16550_claim(irq_t *irq)
+{
+	ns16550_instance_t *instance = irq->instance;
+	ns16550_t *dev = instance->ns16550;
+
+	if (pio_read_8(&dev->lsr) & LSR_DATA_READY)
+		return IRQ_ACCEPT;
+	else
+		return IRQ_DECLINE;
+}
+
+void ns16550_irq_handler(irq_t *irq)
+{
+	ns16550_instance_t *instance = irq->instance;
+	ns16550_t *dev = instance->ns16550;
+
+	if (pio_read_8(&dev->lsr) & LSR_DATA_READY) {
+		uint8_t x;
+		
+		x = pio_read_8(&dev->rbr);
+		if (instance->devout)
+			chardev_push_character(instance->devout, x);
+	}
+}
+
+/** @}
+ */
Index: kernel/genarch/src/drivers/z8530/z8530.c
===================================================================
--- kernel/genarch/src/drivers/z8530/z8530.c	(revision 411b6a6f0339f865eaac5f492f2277fdfbbd5fcc)
+++ kernel/genarch/src/drivers/z8530/z8530.c	(revision 411b6a6f0339f865eaac5f492f2277fdfbbd5fcc)
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2009 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.
+ */
+
+/** @addtogroup genarch	
+ * @{
+ */
+/**
+ * @file
+ * @brief	Zilog 8530 serial controller driver.
+ */
+
+#include <genarch/drivers/z8530/z8530.h>
+#include <console/chardev.h>
+#include <ddi/irq.h>
+#include <arch/asm.h>
+#include <mm/slab.h>
+
+static inline void z8530_write(ioport8_t *ctl, uint8_t reg, uint8_t val)
+{
+	/*
+	 * Registers 8-15 will automatically issue the Point High
+	 * command as their bit 3 is 1.
+	 */
+	pio_write_8(ctl, reg);	/* select register */
+	pio_write_8(ctl, val);	/* write value */
+}
+
+static inline uint8_t z8530_read(ioport8_t *ctl, uint8_t reg) 
+{
+	/*
+	 * Registers 8-15 will automatically issue the Point High
+	 * command as their bit 3 is 1.
+	 */
+	pio_write_8(ctl, reg);	/* select register */
+	return pio_read_8(ctl);
+}
+
+/** Initialize z8530. */
+bool
+z8530_init(z8530_t *dev, devno_t devno, inr_t inr, cir_t cir, void *cir_arg,
+    chardev_t *devout)
+{
+	z8530_instance_t *instance;
+
+	instance = malloc(sizeof(z8530_instance_t), FRAME_ATOMIC);
+	if (!instance)
+		return false;
+
+	instance->devno = devno;
+	instance->z8530 = dev;
+	instance->devout = devout;
+
+	irq_initialize(&instance->irq);
+	instance->irq.devno = devno;
+	instance->irq.inr = inr;
+	instance->irq.claim = z8530_claim;
+	instance->irq.handler = z8530_irq_handler;
+	instance->irq.instance = instance;
+	instance->irq.cir = cir;
+	instance->irq.cir_arg = cir_arg;
+	irq_register(&instance->irq);
+
+	(void) z8530_read(&dev->ctl_a, RR8);
+
+	/*
+	 * Clear any pending TX interrupts or we never manage
+	 * to set FHC UART interrupt state to idle.
+	 */
+	z8530_write(&dev->ctl_a, WR0, WR0_TX_IP_RST);
+
+	/* interrupt on all characters */
+	z8530_write(&dev->ctl_a, WR1, WR1_IARCSC);
+
+	/* 8 bits per character and enable receiver */
+	z8530_write(&dev->ctl_a, WR3, WR3_RX8BITSCH | WR3_RX_ENABLE);
+	
+	/* Master Interrupt Enable. */
+	z8530_write(&dev->ctl_a, WR9, WR9_MIE);
+
+	return true;
+}
+
+irq_ownership_t z8530_claim(irq_t *irq)
+{
+	z8530_instance_t *instance = irq->instance;
+	z8530_t *dev = instance->z8530;
+
+	if (z8530_read(&dev->ctl_a, RR0) & RR0_RCA)
+		return IRQ_ACCEPT;
+	else
+		return IRQ_DECLINE;
+}
+
+void z8530_irq_handler(irq_t *irq)
+{
+	z8530_instance_t *instance = irq->instance;
+	z8530_t *dev = instance->z8530;
+	uint8_t x;
+
+	if (z8530_read(&dev->ctl_a, RR0) & RR0_RCA) {
+		x = z8530_read(&dev->ctl_a, RR8);
+		if (instance->devout)
+			chardev_push_character(instance->devout, x);
+	}
+}
+
+/** @}
+ */
Index: kernel/genarch/src/kbd/i8042.c
===================================================================
--- kernel/genarch/src/kbd/i8042.c	(revision e06da7efc998285c1aa3d8a9ceb29e2a5aea6fdb)
+++ 	(revision )
@@ -1,164 +1,0 @@
-/*
- * Copyright (c) 2009 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.
- */
-
-/** @addtogroup genarch	
- * @{
- */
-/**
- * @file
- * @brief	i8042 processor driver.
- *
- * It takes care of low-level keyboard functions.
- */
-
-#include <genarch/kbd/i8042.h>
-#include <arch/drivers/kbd.h>
-#include <genarch/kbd/key.h>
-#include <genarch/kbd/scanc.h>
-#include <genarch/kbd/scanc_pc.h>
-#include <genarch/drivers/legacy/ia32/io.h>
-#include <cpu.h>
-#include <arch/asm.h>
-#include <arch.h>
-#include <console/chardev.h>
-#include <console/console.h>
-#include <interrupt.h>
-
-/* Keyboard commands. */
-#define KBD_ENABLE	0xf4
-#define KBD_DISABLE	0xf5
-#define KBD_ACK		0xfa
-
-/*
- * 60  Write 8042 Command Byte: next data byte written to port 60h is
- *     placed in 8042 command register. Format:
- *
- *    |7|6|5|4|3|2|1|0|8042 Command Byte
- *     | | | | | | | `---- 1=enable output register full interrupt
- *     | | | | | | `----- should be 0
- *     | | | | | `------ 1=set status register system, 0=clear
- *     | | | | `------- 1=override keyboard inhibit, 0=allow inhibit
- *     | | | `-------- disable keyboard I/O by driving clock line low
- *     | | `--------- disable auxiliary device, drives clock line low
- *     | `---------- IBM scancode translation 0=AT, 1=PC/XT
- *     `----------- reserved, should be 0
- */
-
-#define i8042_SET_COMMAND 	0x60
-#define i8042_COMMAND 		0x69
-
-#define i8042_BUFFER_FULL_MASK	0x01
-#define i8042_WAIT_MASK		0x02
-#define i8042_MOUSE_DATA	0x20
-
-static void i8042_suspend(chardev_t *);
-static void i8042_resume(chardev_t *);
-
-static chardev_operations_t ops = {
-	.suspend = i8042_suspend,
-	.resume = i8042_resume,
-};
-
-static irq_ownership_t i8042_claim(irq_t *irq)
-{
-	i8042_instance_t *i8042_instance = irq->instance;
-	i8042_t *dev = i8042_instance->i8042;
-	if (pio_read_8(&dev->status) & i8042_BUFFER_FULL_MASK)
-		return IRQ_ACCEPT;
-	else
-		return IRQ_DECLINE;
-}
-
-static void i8042_irq_handler(irq_t *irq)
-{
-	i8042_instance_t *instance = irq->instance;
-	i8042_t *dev = instance->i8042;
-
-	uint8_t data;
-	uint8_t status;
-		
-	if (((status = pio_read_8(&dev->status)) & i8042_BUFFER_FULL_MASK)) {
-		data = pio_read_8(&dev->data);
-			
-		if ((status & i8042_MOUSE_DATA))
-			return;
-
-		if (data & KEY_RELEASE)
-			key_released(data ^ KEY_RELEASE);
-		else
-			key_pressed(data);
-	}
-}
-
-/** Initialize i8042. */
-bool
-i8042_init(i8042_t *dev, devno_t devno, inr_t inr)
-{
-	i8042_instance_t *instance;
-
-	chardev_initialize("i8042_kbd", &kbrd, &ops);
-	stdin = &kbrd;
-	
-	instance = malloc(sizeof(i8042_instance_t), FRAME_ATOMIC);
-	if (!instance)
-		return false;
-	
-	instance->devno = devno;
-	instance->i8042 = dev;
-	
-	irq_initialize(&instance->irq);
-	instance->irq.devno = devno;
-	instance->irq.inr = inr;
-	instance->irq.claim = i8042_claim;
-	instance->irq.handler = i8042_irq_handler;
-	instance->irq.instance = instance;
-	irq_register(&instance->irq);
-	
-	trap_virtual_enable_irqs(1 << inr);
-	
-	/*
-	 * Clear input buffer.
-	 */
-	while (pio_read_8(&dev->status) & i8042_BUFFER_FULL_MASK)
-		(void) pio_read_8(&dev->data);
-	
-	return true;
-}
-
-/* Called from getc(). */
-void i8042_resume(chardev_t *d)
-{
-}
-
-/* Called from getc(). */
-void i8042_suspend(chardev_t *d)
-{
-}
-
-/** @}
- */
Index: kernel/genarch/src/kbd/key.c
===================================================================
--- kernel/genarch/src/kbd/key.c	(revision e06da7efc998285c1aa3d8a9ceb29e2a5aea6fdb)
+++ 	(revision )
@@ -1,254 +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.
- */
-
-/** @addtogroup genarch	
- * @{
- */
-/**
- * @file
- * @brief	Key processing.
- */
-
-#include <genarch/kbd/key.h>
-#include <genarch/kbd/scanc.h>
-#ifdef CONFIG_I8042
-#include <genarch/kbd/scanc_pc.h>
-#endif
-
-#if (defined(US)) || (defined(US3))
-#include <genarch/kbd/scanc_sun.h>
-#endif
-
-#include <synch/spinlock.h>
-#include <console/chardev.h>
-#include <macros.h>
-
-#define PRESSED_SHIFT		(1<<0)
-#define PRESSED_CAPSLOCK	(1<<1)
-#define LOCKED_CAPSLOCK		(1<<0)
-
-#define ACTIVE_READ_BUFF_SIZE 16 	/* Must be power of 2 */
-
-chardev_t kbrd;
-
-static uint8_t active_read_buff[ACTIVE_READ_BUFF_SIZE];
-
-SPINLOCK_INITIALIZE(keylock);		/**< keylock protects keyflags and lockflags. */
-static volatile int keyflags;		/**< Tracking of multiple keypresses. */
-static volatile int lockflags;		/**< Tracking of multiple keys lockings. */
-
-/** Process release of key.
- *
- * @param sc Scancode of the key being released.
- */
-void key_released(uint8_t sc)
-{
-	spinlock_lock(&keylock);
-	switch (sc) {
-	case SC_LSHIFT:
-	case SC_RSHIFT:
-		keyflags &= ~PRESSED_SHIFT;
-		break;
-	case SC_CAPSLOCK:
-		keyflags &= ~PRESSED_CAPSLOCK;
-		if (lockflags & LOCKED_CAPSLOCK)
-			lockflags &= ~LOCKED_CAPSLOCK;
-		else
-			lockflags |= LOCKED_CAPSLOCK;
-		break;
-	default:
-		break;
-	}
-	spinlock_unlock(&keylock);
-}
-
-/** Process keypress.
- *
- * @param sc Scancode of the key being pressed.
- */
-void key_pressed(uint8_t sc)
-{
-	char *map = sc_primary_map;
-	char ascii = sc_primary_map[sc];
-	bool shift, capslock;
-	bool letter = false;
-
-	spinlock_lock(&keylock);
-	switch (sc) {
-	case SC_LSHIFT:
-	case SC_RSHIFT:
-	    	keyflags |= PRESSED_SHIFT;
-		break;
-	case SC_CAPSLOCK:
-		keyflags |= PRESSED_CAPSLOCK;
-		break;
-	case SC_SPEC_ESCAPE:
-		break;
-	case SC_LEFTARR:
-		chardev_push_character(&kbrd, 0x1b);
-		chardev_push_character(&kbrd, 0x5b);
-		chardev_push_character(&kbrd, 0x44);
-		break;
-	case SC_RIGHTARR:
-		chardev_push_character(&kbrd, 0x1b);
-		chardev_push_character(&kbrd, 0x5b);
-		chardev_push_character(&kbrd, 0x43);
-		break;
-	case SC_UPARR:
-		chardev_push_character(&kbrd, 0x1b);
-		chardev_push_character(&kbrd, 0x5b);
-		chardev_push_character(&kbrd, 0x41);
-		break;
-	case SC_DOWNARR:
-		chardev_push_character(&kbrd, 0x1b);
-		chardev_push_character(&kbrd, 0x5b);
-		chardev_push_character(&kbrd, 0x42);
-		break;
-	case SC_HOME:
-		chardev_push_character(&kbrd, 0x1b);
-		chardev_push_character(&kbrd, 0x4f);
-		chardev_push_character(&kbrd, 0x48);
-		break;
-	case SC_END:
-		chardev_push_character(&kbrd, 0x1b);
-		chardev_push_character(&kbrd, 0x4f);
-		chardev_push_character(&kbrd, 0x46);
-		break;
-	case SC_DELETE:
-		chardev_push_character(&kbrd, 0x1b);
-		chardev_push_character(&kbrd, 0x5b);
-		chardev_push_character(&kbrd, 0x33);
-		chardev_push_character(&kbrd, 0x7e);
-		break;
-	default:
-	    	letter = islower(ascii);
-		capslock = (keyflags & PRESSED_CAPSLOCK) ||
-		    (lockflags & LOCKED_CAPSLOCK);
-		shift = keyflags & PRESSED_SHIFT;
-		if (letter && capslock)
-			shift = !shift;
-		if (shift)
-			map = sc_secondary_map;
-		chardev_push_character(&kbrd, map[sc]);
-		break;
-	}
-	spinlock_unlock(&keylock);
-}
-
-uint8_t active_read_buff_read(void)
-{
-	static int i=0;
-	i &= (ACTIVE_READ_BUFF_SIZE-1);
-	if(!active_read_buff[i]) {
-		return 0;
-	}
-	return active_read_buff[i++];
-}
-
-void active_read_buff_write(uint8_t ch)
-{
-	static int i=0;
-	active_read_buff[i] = ch;
-	i++;
-	i &= (ACTIVE_READ_BUFF_SIZE-1);
-	active_read_buff[i]=0;
-}
-
-
-void active_read_key_pressed(uint8_t sc)
-{
-	char *map = sc_primary_map;
-	char ascii = sc_primary_map[sc];
-	bool shift, capslock;
-	bool letter = false;
-
-	/*spinlock_lock(&keylock);*/
-	switch (sc) {
-	case SC_LSHIFT:
-	case SC_RSHIFT:
-	    	keyflags |= PRESSED_SHIFT;
-		break;
-	case SC_CAPSLOCK:
-		keyflags |= PRESSED_CAPSLOCK;
-		break;
-	case SC_SPEC_ESCAPE:
-		break;
-	case SC_LEFTARR:
-		active_read_buff_write(0x1b);
-		active_read_buff_write(0x5b);
-		active_read_buff_write(0x44);
-		break;
-	case SC_RIGHTARR:
-		active_read_buff_write(0x1b);
-		active_read_buff_write(0x5b);
-		active_read_buff_write(0x43);
-		break;
-	case SC_UPARR:
-		active_read_buff_write(0x1b);
-		active_read_buff_write(0x5b);
-		active_read_buff_write(0x41);
-		break;
-	case SC_DOWNARR:
-		active_read_buff_write(0x1b);
-		active_read_buff_write(0x5b);
-		active_read_buff_write(0x42);
-		break;
-	case SC_HOME:
-		active_read_buff_write(0x1b);
-		active_read_buff_write(0x4f);
-		active_read_buff_write(0x48);
-		break;
-	case SC_END:
-		active_read_buff_write(0x1b);
-		active_read_buff_write(0x4f);
-		active_read_buff_write(0x46);
-		break;
-	case SC_DELETE:
-		active_read_buff_write(0x1b);
-		active_read_buff_write(0x5b);
-		active_read_buff_write(0x33);
-		active_read_buff_write(0x7e);
-		break;
-	default:
-	    	letter = islower(ascii);
-		capslock = (keyflags & PRESSED_CAPSLOCK) ||
-		    (lockflags & LOCKED_CAPSLOCK);
-		shift = keyflags & PRESSED_SHIFT;
-		if (letter && capslock)
-			shift = !shift;
-		if (shift)
-			map = sc_secondary_map;
-		active_read_buff_write(map[sc]);
-		break;
-	}
-	/*spinlock_unlock(&keylock);*/
-
-}
-
-/** @}
- */
Index: kernel/genarch/src/kbd/ns16550.c
===================================================================
--- kernel/genarch/src/kbd/ns16550.c	(revision e06da7efc998285c1aa3d8a9ceb29e2a5aea6fdb)
+++ 	(revision )
@@ -1,155 +1,0 @@
-/*
- * Copyright (c) 2009 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.
- */
-
-/** @addtogroup genarch	
- * @{
- */
-/**
- * @file
- * @brief	NS 16550 serial port / keyboard driver.
- */
-
-#include <genarch/kbd/ns16550.h>
-#include <genarch/kbd/key.h>
-#include <genarch/kbd/scanc.h>
-#include <genarch/kbd/scanc_sun.h>
-#include <arch/drivers/kbd.h>
-#include <ddi/irq.h>
-#include <cpu.h>
-#include <arch/asm.h>
-#include <arch.h>
-#include <console/chardev.h>
-#include <console/console.h>
-#include <interrupt.h>
-#include <arch/interrupt.h>
-#include <synch/spinlock.h>
-#include <mm/slab.h>
-
-#define LSR_DATA_READY	0x01
-
-/*
- * These codes read from ns16550 data register are silently ignored.
- */
-#define IGNORE_CODE	0x7f		/* all keys up */
-
-static void ns16550_suspend(chardev_t *);
-static void ns16550_resume(chardev_t *);
-
-static chardev_operations_t ops = {
-	.suspend = ns16550_suspend,
-	.resume = ns16550_resume,
-};
-
-/** Initialize ns16550.
- *
- * @param dev		Addrress of the beginning of the device in I/O space.
- * @param devno		Device number.
- * @param inr		Interrupt number.
- * @param cir		Clear interrupt function.
- * @param cir_arg	First argument to cir.
- *
- * @return		True on success, false on failure.
- */
-bool
-ns16550_init(ns16550_t *dev, devno_t devno, inr_t inr, cir_t cir, void *cir_arg)
-{
-	ns16550_instance_t *instance;
-
-	chardev_initialize("ns16550_kbd", &kbrd, &ops);
-	stdin = &kbrd;
-	
-	instance = malloc(sizeof(ns16550_instance_t), FRAME_ATOMIC);
-	if (!instance)
-		return false;
-
-	instance->devno = devno;
-	instance->ns16550 = dev;
-	
-	irq_initialize(&instance->irq);
-	instance->irq.devno = devno;
-	instance->irq.inr = inr;
-	instance->irq.claim = ns16550_claim;
-	instance->irq.handler = ns16550_irq_handler;
-	instance->irq.instance = instance;
-	instance->irq.cir = cir;
-	instance->irq.cir_arg = cir_arg;
-	irq_register(&instance->irq);
-
-	while ((pio_read_8(&dev->lsr) & LSR_DATA_READY))
-		(void) pio_read_8(&dev->rbr);
-	
-	/* Enable interrupts */
-	pio_write_8(&dev->ier, IER_ERBFI);
-	pio_write_8(&dev->mcr, MCR_OUT2);
-	
-	return true;
-}
-
-/* Called from getc(). */
-void ns16550_resume(chardev_t *d)
-{
-}
-
-/* Called from getc(). */
-void ns16550_suspend(chardev_t *d)
-{
-}
-
-irq_ownership_t ns16550_claim(irq_t *irq)
-{
-	ns16550_instance_t *ns16550_instance = irq->instance;
-	ns16550_t *dev = ns16550_instance->ns16550;
-
-	if (pio_read_8(&dev->lsr) & LSR_DATA_READY)
-		return IRQ_ACCEPT;
-	else
-		return IRQ_DECLINE;
-}
-
-void ns16550_irq_handler(irq_t *irq)
-{
-	ns16550_instance_t *ns16550_instance = irq->instance;
-	ns16550_t *dev = ns16550_instance->ns16550;
-
-	if (pio_read_8(&dev->lsr) & LSR_DATA_READY) {
-		uint8_t x;
-		
-		x = pio_read_8(&dev->rbr);
-		
-		if (x != IGNORE_CODE) {
-			if (x & KEY_RELEASE)
-				key_released(x ^ KEY_RELEASE);
-			else
-				key_pressed(x);
-		}
-	}
-
-}
-
-/** @}
- */
Index: kernel/genarch/src/kbd/scanc_pc.c
===================================================================
--- kernel/genarch/src/kbd/scanc_pc.c	(revision e06da7efc998285c1aa3d8a9ceb29e2a5aea6fdb)
+++ 	(revision )
@@ -1,200 +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.
- */
-
-/** @addtogroup genarch	
- * @{
- */
-/**
- * @file
- * @brief	Scan codes for pc keyboards.
- */
-
-#include <genarch/kbd/scanc.h>
-
-/** Primary meaning of scancodes. */
-char sc_primary_map[] = {
-	SPECIAL, /* 0x00 */
-	SPECIAL, /* 0x01 - Esc */
-	'1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=',
-	'\b', /* 0x0e - Backspace */
-	'\t', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n',
-	SPECIAL, /* 0x1d - LCtrl */
-	'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'',
-	'`',
-	SPECIAL, /* 0x2a - LShift */ 
-	'\\',
-	'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/',
-	SPECIAL, /* 0x36 - RShift */
-	'*',
-	SPECIAL, /* 0x38 - LAlt */
-	' ',
-	SPECIAL, /* 0x3a - CapsLock */
-	SPECIAL, /* 0x3b - F1 */
-	SPECIAL, /* 0x3c - F2 */
-	SPECIAL, /* 0x3d - F3 */
-	SPECIAL, /* 0x3e - F4 */
-	SPECIAL, /* 0x3f - F5 */
-	SPECIAL, /* 0x40 - F6 */
-	SPECIAL, /* 0x41 - F7 */
-	SPECIAL, /* 0x42 - F8 */
-	SPECIAL, /* 0x43 - F9 */
-	SPECIAL, /* 0x44 - F10 */
-	SPECIAL, /* 0x45 - NumLock */
-	SPECIAL, /* 0x46 - ScrollLock */
-	'7', '8', '9', '-',
-	'4', '5', '6', '+',
-	'1', '2', '3',
-	'0', '.',
-	SPECIAL, /* 0x54 - Alt-SysRq */
-	SPECIAL, /* 0x55 - F11/F12/PF1/FN */
-	SPECIAL, /* 0x56 - unlabelled key next to LAlt */
-	SPECIAL, /* 0x57 - F11 */
-	SPECIAL, /* 0x58 - F12 */
-	SPECIAL, /* 0x59 */
-	SPECIAL, /* 0x5a */
-	SPECIAL, /* 0x5b */
-	SPECIAL, /* 0x5c */
-	SPECIAL, /* 0x5d */
-	SPECIAL, /* 0x5e */
-	SPECIAL, /* 0x5f */
-	SPECIAL, /* 0x60 */
-	SPECIAL, /* 0x61 */
-	SPECIAL, /* 0x62 */
-	SPECIAL, /* 0x63 */
-	SPECIAL, /* 0x64 */
-	SPECIAL, /* 0x65 */
-	SPECIAL, /* 0x66 */
-	SPECIAL, /* 0x67 */
-	SPECIAL, /* 0x68 */
-	SPECIAL, /* 0x69 */
-	SPECIAL, /* 0x6a */
-	SPECIAL, /* 0x6b */
-	SPECIAL, /* 0x6c */
-	SPECIAL, /* 0x6d */
-	SPECIAL, /* 0x6e */
-	SPECIAL, /* 0x6f */
-	SPECIAL, /* 0x70 */
-	SPECIAL, /* 0x71 */
-	SPECIAL, /* 0x72 */
-	SPECIAL, /* 0x73 */
-	SPECIAL, /* 0x74 */
-	SPECIAL, /* 0x75 */
-	SPECIAL, /* 0x76 */
-	SPECIAL, /* 0x77 */
-	SPECIAL, /* 0x78 */
-	SPECIAL, /* 0x79 */
-	SPECIAL, /* 0x7a */
-	SPECIAL, /* 0x7b */
-	SPECIAL, /* 0x7c */
-	SPECIAL, /* 0x7d */
-	SPECIAL, /* 0x7e */
-	SPECIAL, /* 0x7f */
-};
-
-/** Secondary meaning of scancodes. */
-char sc_secondary_map[] = {
-	SPECIAL, /* 0x00 */
-	SPECIAL, /* 0x01 - Esc */
-	'!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+',
-	SPECIAL, /* 0x0e - Backspace */
-	'\t', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', '\n',
-	SPECIAL, /* 0x1d - LCtrl */
-	'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '"',
-	'~',
-	SPECIAL, /* 0x2a - LShift */ 
-	'|',
-	'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', '>', '?',
-	SPECIAL, /* 0x36 - RShift */
-	'*',
-	SPECIAL, /* 0x38 - LAlt */
-	' ',
-	SPECIAL, /* 0x3a - CapsLock */
-	SPECIAL, /* 0x3b - F1 */
-	SPECIAL, /* 0x3c - F2 */
-	SPECIAL, /* 0x3d - F3 */
-	SPECIAL, /* 0x3e - F4 */
-	SPECIAL, /* 0x3f - F5 */
-	SPECIAL, /* 0x40 - F6 */
-	SPECIAL, /* 0x41 - F7 */
-	SPECIAL, /* 0x42 - F8 */
-	SPECIAL, /* 0x43 - F9 */
-	SPECIAL, /* 0x44 - F10 */
-	SPECIAL, /* 0x45 - NumLock */
-	SPECIAL, /* 0x46 - ScrollLock */
-	'7', '8', '9', '-',
-	'4', '5', '6', '+',
-	'1', '2', '3',
-	'0', '.',
-	SPECIAL, /* 0x54 - Alt-SysRq */
-	SPECIAL, /* 0x55 - F11/F12/PF1/FN */
-	SPECIAL, /* 0x56 - unlabelled key next to LAlt */
-	SPECIAL, /* 0x57 - F11 */
-	SPECIAL, /* 0x58 - F12 */
-	SPECIAL, /* 0x59 */
-	SPECIAL, /* 0x5a */
-	SPECIAL, /* 0x5b */
-	SPECIAL, /* 0x5c */
-	SPECIAL, /* 0x5d */
-	SPECIAL, /* 0x5e */
-	SPECIAL, /* 0x5f */
-	SPECIAL, /* 0x60 */
-	SPECIAL, /* 0x61 */
-	SPECIAL, /* 0x62 */
-	SPECIAL, /* 0x63 */
-	SPECIAL, /* 0x64 */
-	SPECIAL, /* 0x65 */
-	SPECIAL, /* 0x66 */
-	SPECIAL, /* 0x67 */
-	SPECIAL, /* 0x68 */
-	SPECIAL, /* 0x69 */
-	SPECIAL, /* 0x6a */
-	SPECIAL, /* 0x6b */
-	SPECIAL, /* 0x6c */
-	SPECIAL, /* 0x6d */
-	SPECIAL, /* 0x6e */
-	SPECIAL, /* 0x6f */
-	SPECIAL, /* 0x70 */
-	SPECIAL, /* 0x71 */
-	SPECIAL, /* 0x72 */
-	SPECIAL, /* 0x73 */
-	SPECIAL, /* 0x74 */
-	SPECIAL, /* 0x75 */
-	SPECIAL, /* 0x76 */
-	SPECIAL, /* 0x77 */
-	SPECIAL, /* 0x78 */
-	SPECIAL, /* 0x79 */
-	SPECIAL, /* 0x7a */
-	SPECIAL, /* 0x7b */
-	SPECIAL, /* 0x7c */
-	SPECIAL, /* 0x7d */
-	SPECIAL, /* 0x7e */
-	SPECIAL, /* 0x7f */	
-};
-
-/** @}
- */
Index: kernel/genarch/src/kbd/scanc_sun.c
===================================================================
--- kernel/genarch/src/kbd/scanc_sun.c	(revision e06da7efc998285c1aa3d8a9ceb29e2a5aea6fdb)
+++ 	(revision )
@@ -1,304 +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.
- */
-
-/** @addtogroup genarch	
- * @{
- */
-/**
- * @file
- * @brief	Scan codes for Sun keyboards.
- */
-
-#include <genarch/kbd/scanc.h>
-
-/** Primary meaning of scancodes. */
-char sc_primary_map[] = {
-	[0x00] = SPECIAL,
-	[0x01] = SPECIAL,
-	[0x02] = SPECIAL,
-	[0x03] = SPECIAL,
-	[0x04] = SPECIAL,
-	[0x05] = SPECIAL,	/* F1 */
-	[0x06] = SPECIAL,	/* F2 */
-	[0x07] = SPECIAL,	/* F10 */
-	[0x08] = SPECIAL,	/* F3 */
-	[0x09] = SPECIAL,	/* F11 */
-	[0x0a] = SPECIAL,	/* F4 */
-	[0x0b] = SPECIAL,	/* F12 */
-	[0x0c] = SPECIAL,	/* F5 */
-	[0x0d] = SPECIAL,	/* RAlt */
-	[0x0e] = SPECIAL,	/* F6 */
-	[0x0f] = SPECIAL,
-	[0x10] = SPECIAL,	/* F7 */
-	[0x11] = SPECIAL,	/* F8 */
-	[0x12] = SPECIAL,	/* F9 */
-	[0x13] = SPECIAL,	/* LAlt */
-	[0x14] = SPECIAL,	/* Up Arrow */
-	[0x15] = SPECIAL,	/* Pause */
-	[0x16] = SPECIAL,
-	[0x17] = SPECIAL,	/* Scroll Lock */
-	[0x18] = SPECIAL,	/* Left Arrow */
-	[0x19] = SPECIAL,
-	[0x1a] = SPECIAL,
-	[0x1b] = SPECIAL,	/* Down Arrow */
-	[0x1c] = SPECIAL,	/* Right Arrow */
-	[0x1d] = SPECIAL,	/* Esc */
-	[0x1e] = '1',
-	[0x1f] = '2',
-	[0x20] = '3',
-	[0x21] = '4',
-	[0x22] = '5',
-	[0x23] = '6',
-	[0x24] = '7',
-	[0x25] = '8',
-	[0x26] = '9',
-	[0x27] = '0',
-	[0x28] = '-',
-	[0x29] = '=',
-	[0x2a] = '`',
-	[0x2b] = '\b',		/* Backspace */
-	[0x2c] = SPECIAL,	/* Insert */
-	[0x2d] = SPECIAL,
-	[0x2e] = '/',		/* numeric keypad */
-	[0x2f] = '*',		/* numeric keypad */
-	[0x30] = SPECIAL,
-	[0x31] = SPECIAL,
-	[0x32] = '.',		/* numeric keypad */
-	[0x33] = SPECIAL,
-	[0x34] = SPECIAL,	/* Home */
-	[0x35] = '\t',		/* Tab */
-	[0x36] = 'q',
-	[0x37] = 'w',
-	[0x38] = 'e',
-	[0x39] = 'r',
-	[0x3a] = 't',
-	[0x3b] = 'y',
-	[0x3c] = 'u',
-	[0x3d] = 'i',
-	[0x3e] = 'o',
-	[0x3f] = 'p',
-	[0x40] = '[',
-	[0x41] = ']',
-	[0x42] = SPECIAL,	/* Del */
-	[0x43] = SPECIAL,
-	[0x44] = '7',		/* numeric keypad */
-	[0x45] = '8',		/* numeric keypad */
-	[0x46] = '9',		/* numeric keypad */
-	[0x47] = '-',		/* numeric keypad */
-	[0x48] = SPECIAL,
-	[0x49] = SPECIAL,
-	[0x4a] = SPECIAL,	/* End */
-	[0x4b] = SPECIAL,
-	[0x4c] = SPECIAL,	/* Control */
-	[0x4d] = 'a',
-	[0x4e] = 's',
-	[0x4f] = 'd',
-	[0x50] = 'f',
-	[0x51] = 'g',
-	[0x52] = 'h',
-	[0x53] = 'j',
-	[0x54] = 'k',
-	[0x55] = 'l',
-	[0x56] = ';',
-	[0x57] = '\'',
-	[0x58] = '\\',
-	[0x59] = '\n',		/* Enter */
-	[0x5a] = '\n',		/* Enter on numeric keypad */
-	[0x5b] = '4',		/* numeric keypad */
-	[0x5c] = '5',		/* numeric keypad */
-	[0x5d] = '6',		/* numeric keypad */
-	[0x5e] = '0',		/* numeric keypad */
-	[0x5f] = SPECIAL,
-	[0x60] = SPECIAL,	/* Page Up */
-	[0x61] = SPECIAL,
-	[0x62] = SPECIAL,	/* Num Lock */
-	[0x63] = SPECIAL,	/* LShift */
-	[0x64] = 'z',
-	[0x65] = 'x',
-	[0x66] = 'c',
-	[0x67] = 'v',
-	[0x68] = 'b',
-	[0x69] = 'n',
-	[0x6a] = 'm',
-	[0x6b] = ',',
-	[0x6c] = '.',
-	[0x6d] = '/',
-	[0x6e] = SPECIAL,	/* RShift */
-	[0x6f] = SPECIAL,
-	[0x70] = '1',		/* numeric keypad */
-	[0x71] = '2',		/* numeric keypad */
-	[0x72] = '3',		/* numeric keypad */
-	[0x73] = SPECIAL,
-	[0x74] = SPECIAL,
-	[0x75] = SPECIAL,
-	[0x76] = SPECIAL,
-	[0x77] = SPECIAL,	/* Caps Lock */
-	[0x78] = SPECIAL,
-	[0x79] = ' ',
-	[0x7a] = SPECIAL,
-	[0x7b] = SPECIAL,	/* Page Down */
-	[0x7c] = SPECIAL,
-	[0x7d] = '+',		/* numeric key pad */
-	[0x7e] = SPECIAL,
-	[0x7f] = SPECIAL
-};
-
-/** Secondary meaning of scancodes. */
-char sc_secondary_map[] = {
-	[0x00] = SPECIAL,
-	[0x01] = SPECIAL,
-	[0x02] = SPECIAL,
-	[0x03] = SPECIAL,
-	[0x04] = SPECIAL,
-	[0x05] = SPECIAL,	/* F1 */
-	[0x06] = SPECIAL,	/* F2 */
-	[0x07] = SPECIAL,	/* F10 */
-	[0x08] = SPECIAL,	/* F3 */
-	[0x09] = SPECIAL,	/* F11 */
-	[0x0a] = SPECIAL,	/* F4 */
-	[0x0b] = SPECIAL,	/* F12 */
-	[0x0c] = SPECIAL,	/* F5 */
-	[0x0d] = SPECIAL,	/* RAlt */
-	[0x0e] = SPECIAL,	/* F6 */
-	[0x0f] = SPECIAL,
-	[0x10] = SPECIAL,	/* F7 */
-	[0x11] = SPECIAL,	/* F8 */
-	[0x12] = SPECIAL,	/* F9 */
-	[0x13] = SPECIAL,	/* LAlt */
-	[0x14] = SPECIAL,	/* Up Arrow */
-	[0x15] = SPECIAL,	/* Pause */
-	[0x16] = SPECIAL,
-	[0x17] = SPECIAL,	/* Scroll Lock */
-	[0x18] = SPECIAL,	/* Left Arrow */
-	[0x19] = SPECIAL,
-	[0x1a] = SPECIAL,
-	[0x1b] = SPECIAL,	/* Down Arrow */
-	[0x1c] = SPECIAL,	/* Right Arrow */
-	[0x1d] = SPECIAL,	/* Esc */
-	[0x1e] = '!',
-	[0x1f] = '@',
-	[0x20] = '#',
-	[0x21] = '$',
-	[0x22] = '%',
-	[0x23] = '^',
-	[0x24] = '&',
-	[0x25] = '*',
-	[0x26] = '(',
-	[0x27] = ')',
-	[0x28] = '_',
-	[0x29] = '+',
-	[0x2a] = '~',
-	[0x2b] = SPECIAL,	/* Backspace */
-	[0x2c] = SPECIAL,	/* Insert */
-	[0x2d] = SPECIAL,
-	[0x2e] = '/',		/* numeric keypad */
-	[0x2f] = '*',		/* numeric keypad */
-	[0x30] = SPECIAL,
-	[0x31] = SPECIAL,
-	[0x32] = '.',		/* numeric keypad */
-	[0x33] = SPECIAL,
-	[0x34] = SPECIAL,	/* Home */
-	[0x35] = SPECIAL,	/* Tab */
-	[0x36] = 'Q',
-	[0x37] = 'W',
-	[0x38] = 'E',
-	[0x39] = 'R',
-	[0x3a] = 'T',
-	[0x3b] = 'Y',
-	[0x3c] = 'U',
-	[0x3d] = 'I',
-	[0x3e] = 'O',
-	[0x3f] = 'P',
-	[0x40] = '{',
-	[0x41] = '}',
-	[0x42] = SPECIAL,	/* Del */
-	[0x43] = SPECIAL,
-	[0x44] = '7',		/* numeric keypad */
-	[0x45] = '8',		/* numeric keypad */
-	[0x46] = '9',		/* numeric keypad */
-	[0x47] = '-',		/* numeric keypad */
-	[0x48] = SPECIAL,
-	[0x49] = SPECIAL,
-	[0x4a] = SPECIAL,	/* End */
-	[0x4b] = SPECIAL,
-	[0x4c] = SPECIAL,	/* Control */
-	[0x4d] = 'A',
-	[0x4e] = 'S',
-	[0x4f] = 'D',
-	[0x50] = 'F',
-	[0x51] = 'G',
-	[0x52] = 'H',
-	[0x53] = 'J',
-	[0x54] = 'K',
-	[0x55] = 'L',
-	[0x56] = ':',
-	[0x57] = '"',
-	[0x58] = '|',
-	[0x59] = SPECIAL,	/* Enter */
-	[0x5a] = SPECIAL,	/* Enter on numeric keypad */
-	[0x5b] = '4',		/* numeric keypad */
-	[0x5c] = '5',		/* numeric keypad */
-	[0x5d] = '6',		/* numeric keypad */
-	[0x5e] = '0',		/* numeric keypad */
-	[0x5f] = SPECIAL,
-	[0x60] = SPECIAL,	/* Page Up */
-	[0x61] = SPECIAL,
-	[0x62] = SPECIAL,	/* Num Lock */
-	[0x63] = SPECIAL,	/* LShift */
-	[0x64] = 'Z',
-	[0x65] = 'X',
-	[0x66] = 'C',
-	[0x67] = 'V',
-	[0x68] = 'B',
-	[0x69] = 'N',
-	[0x6a] = 'M',
-	[0x6b] = '<',
-	[0x6c] = '>',
-	[0x6d] = '?',
-	[0x6e] = SPECIAL,	/* RShift */
-	[0x6f] = SPECIAL,
-	[0x70] = '1',		/* numeric keypad */
-	[0x71] = '2',		/* numeric keypad */
-	[0x72] = '3',		/* numeric keypad */
-	[0x73] = SPECIAL,
-	[0x74] = SPECIAL,
-	[0x75] = SPECIAL,
-	[0x76] = SPECIAL,
-	[0x77] = SPECIAL,	/* Caps Lock */
-	[0x78] = SPECIAL,
-	[0x79] = ' ',
-	[0x7a] = SPECIAL,
-	[0x7b] = SPECIAL,	/* Page Down */
-	[0x7c] = SPECIAL,
-	[0x7d] = '+',		/* numeric key pad */
-	[0x7e] = SPECIAL,
-	[0x7f] = SPECIAL
-};
-
-/** @}
- */
Index: kernel/genarch/src/kbd/z8530.c
===================================================================
--- kernel/genarch/src/kbd/z8530.c	(revision e06da7efc998285c1aa3d8a9ceb29e2a5aea6fdb)
+++ 	(revision )
@@ -1,163 +1,0 @@
-/*
- * Copyright (c) 2009 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.
- */
-
-/** @addtogroup genarch	
- * @{
- */
-/**
- * @file
- * @brief	Zilog 8530 serial port driver.
- */
-
-#include <genarch/kbd/z8530.h>
-#include <genarch/kbd/key.h>
-#include <genarch/kbd/scanc.h>
-#include <genarch/kbd/scanc_sun.h>
-#include <arch/drivers/kbd.h>
-#include <console/console.h>
-#include <console/chardev.h>
-#include <ddi/irq.h>
-#include <arch/asm.h>
-#include <mm/slab.h>
-
-static inline void z8530_write(ioport8_t *ctl, uint8_t reg, uint8_t val)
-{
-	/*
-	 * Registers 8-15 will automatically issue the Point High
-	 * command as their bit 3 is 1.
-	 */
-	pio_write_8(ctl, reg);	/* select register */
-	pio_write_8(ctl, val);	/* write value */
-}
-
-static inline uint8_t z8530_read(ioport8_t *ctl, uint8_t reg) 
-{
-	/*
-	 * Registers 8-15 will automatically issue the Point High
-	 * command as their bit 3 is 1.
-	 */
-	pio_write_8(ctl, reg);	/* select register */
-	return pio_read_8(ctl);
-}
-
-/*
- * These codes read from z8530 data register are silently ignored.
- */
-#define IGNORE_CODE	0x7f		/* all keys up */
-
-static void z8530_suspend(chardev_t *);
-static void z8530_resume(chardev_t *);
-
-static chardev_operations_t ops = {
-	.suspend = z8530_suspend,
-	.resume = z8530_resume,
-};
-
-/** Initialize z8530. */
-bool
-z8530_init(z8530_t *dev, devno_t devno, inr_t inr, cir_t cir, void *cir_arg)
-{
-	z8530_instance_t *instance;
-
-	chardev_initialize("z8530_kbd", &kbrd, &ops);
-	stdin = &kbrd;
-
-	instance = malloc(sizeof(z8530_instance_t), FRAME_ATOMIC);
-	if (!instance)
-		return false;
-
-	instance->devno = devno;
-	instance->z8530 = dev;
-
-	irq_initialize(&instance->irq);
-	instance->irq.devno = devno;
-	instance->irq.inr = inr;
-	instance->irq.claim = z8530_claim;
-	instance->irq.handler = z8530_irq_handler;
-	instance->irq.instance = instance;
-	instance->irq.cir = cir;
-	instance->irq.cir_arg = cir_arg;
-	irq_register(&instance->irq);
-
-	(void) z8530_read(&dev->ctl_a, RR8);
-
-	/*
-	 * Clear any pending TX interrupts or we never manage
-	 * to set FHC UART interrupt state to idle.
-	 */
-	z8530_write(&dev->ctl_a, WR0, WR0_TX_IP_RST);
-
-	/* interrupt on all characters */
-	z8530_write(&dev->ctl_a, WR1, WR1_IARCSC);
-
-	/* 8 bits per character and enable receiver */
-	z8530_write(&dev->ctl_a, WR3, WR3_RX8BITSCH | WR3_RX_ENABLE);
-	
-	/* Master Interrupt Enable. */
-	z8530_write(&dev->ctl_a, WR9, WR9_MIE);
-
-	return true;
-}
-
-/* Called from getc(). */
-void z8530_resume(chardev_t *d)
-{
-}
-
-/* Called from getc(). */
-void z8530_suspend(chardev_t *d)
-{
-}
-
-irq_ownership_t z8530_claim(irq_t *irq)
-{
-	z8530_instance_t *instance = irq->instance;
-	z8530_t *dev = instance->z8530;
-
-	return (z8530_read(&dev->ctl_a, RR0) & RR0_RCA);
-}
-
-void z8530_irq_handler(irq_t *irq)
-{
-	z8530_instance_t *instance = irq->instance;
-	z8530_t *dev = instance->z8530;
-	uint8_t x;
-
-	if (z8530_read(&dev->ctl_a, RR0) & RR0_RCA) {
-		x = z8530_read(&dev->ctl_a, RR8);
-		if (x != IGNORE_CODE) {
-			if (x & KEY_RELEASE)
-				key_released(x ^ KEY_RELEASE);
-			else
-				key_pressed(x);
-		}
-	}
-}
-
-/** @}
- */
Index: kernel/genarch/src/kbrd/kbrd.c
===================================================================
--- kernel/genarch/src/kbrd/kbrd.c	(revision 411b6a6f0339f865eaac5f492f2277fdfbbd5fcc)
+++ kernel/genarch/src/kbrd/kbrd.c	(revision 411b6a6f0339f865eaac5f492f2277fdfbbd5fcc)
@@ -0,0 +1,220 @@
+/*
+ * Copyright (c) 2009 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.
+ */
+
+/** @addtogroup genarch	
+ * @{
+ */
+/**
+ * @file
+ * @brief	Keyboard processing.
+ */
+
+#include <genarch/kbrd/kbrd.h>
+#include <genarch/kbrd/scanc.h>
+
+#ifdef CONFIG_PC_KBD
+#include <genarch/kbrd/scanc_pc.h>
+#endif
+
+#ifdef CONFIG_SUN_KBD
+#include <genarch/kbrd/scanc_sun.h>
+#endif
+
+#include <synch/spinlock.h>
+#include <console/chardev.h>
+#include <console/console.h>
+#include <proc/thread.h>
+#include <arch.h>
+#include <macros.h>
+
+#ifdef CONFIG_SUN_KBD
+#	define IGNORE_CODE	0x7f
+#endif
+
+#define KEY_RELEASE		0x80
+
+#define PRESSED_SHIFT		(1 << 0)
+#define PRESSED_CAPSLOCK	(1 << 1)
+#define LOCKED_CAPSLOCK		(1 << 0)
+
+chardev_t kbrdin;
+static chardev_t *kbdout;
+
+static void kbrdin_suspend(chardev_t *d)
+{
+}
+
+static void kbrdin_resume(chardev_t *d)
+{
+}
+
+chardev_operations_t kbrdin_ops = {
+	.suspend = kbrdin_suspend,
+	.resume = kbrdin_resume,
+};
+
+SPINLOCK_INITIALIZE(keylock);		/**< keylock protects keyflags and lockflags. */
+static volatile int keyflags;		/**< Tracking of multiple keypresses. */
+static volatile int lockflags;		/**< Tracking of multiple keys lockings. */
+
+static void key_released(uint8_t);
+static void key_pressed(uint8_t);
+
+static void kkbrd(void *arg)
+{
+	chardev_t *in = (chardev_t *) arg;
+	uint8_t sc;
+
+	while (1) {
+		sc = _getc(in);
+
+#ifdef CONFIG_SUN_KBD
+		if (sc == IGNORE_CODE)
+			continue;
+#endif
+		
+		if (sc & KEY_RELEASE)
+			key_released(sc ^ KEY_RELEASE);
+		else
+			key_pressed(sc);
+	}
+}
+
+
+void kbrd_init(chardev_t *devout)
+{
+	thread_t *t;
+
+	chardev_initialize("kbrd", &kbrdin, &kbrdin_ops);
+	kbdout = devout;
+	
+	t = thread_create(kkbrd, &kbrdin, TASK, 0, "kkbrd", false);
+	ASSERT(t);
+	thread_ready(t);
+}
+
+/** Process release of key.
+ *
+ * @param sc Scancode of the key being released.
+ */
+void key_released(uint8_t sc)
+{
+	spinlock_lock(&keylock);
+	switch (sc) {
+	case SC_LSHIFT:
+	case SC_RSHIFT:
+		keyflags &= ~PRESSED_SHIFT;
+		break;
+	case SC_CAPSLOCK:
+		keyflags &= ~PRESSED_CAPSLOCK;
+		if (lockflags & LOCKED_CAPSLOCK)
+			lockflags &= ~LOCKED_CAPSLOCK;
+		else
+			lockflags |= LOCKED_CAPSLOCK;
+		break;
+	default:
+		break;
+	}
+	spinlock_unlock(&keylock);
+}
+
+/** Process keypress.
+ *
+ * @param sc Scancode of the key being pressed.
+ */
+void key_pressed(uint8_t sc)
+{
+	char *map = sc_primary_map;
+	char ascii = sc_primary_map[sc];
+	bool shift, capslock;
+	bool letter = false;
+
+	spinlock_lock(&keylock);
+	switch (sc) {
+	case SC_LSHIFT:
+	case SC_RSHIFT:
+	    	keyflags |= PRESSED_SHIFT;
+		break;
+	case SC_CAPSLOCK:
+		keyflags |= PRESSED_CAPSLOCK;
+		break;
+	case SC_SPEC_ESCAPE:
+		break;
+	case SC_LEFTARR:
+		chardev_push_character(kbdout, 0x1b);
+		chardev_push_character(kbdout, 0x5b);
+		chardev_push_character(kbdout, 0x44);
+		break;
+	case SC_RIGHTARR:
+		chardev_push_character(kbdout, 0x1b);
+		chardev_push_character(kbdout, 0x5b);
+		chardev_push_character(kbdout, 0x43);
+		break;
+	case SC_UPARR:
+		chardev_push_character(kbdout, 0x1b);
+		chardev_push_character(kbdout, 0x5b);
+		chardev_push_character(kbdout, 0x41);
+		break;
+	case SC_DOWNARR:
+		chardev_push_character(kbdout, 0x1b);
+		chardev_push_character(kbdout, 0x5b);
+		chardev_push_character(kbdout, 0x42);
+		break;
+	case SC_HOME:
+		chardev_push_character(kbdout, 0x1b);
+		chardev_push_character(kbdout, 0x4f);
+		chardev_push_character(kbdout, 0x48);
+		break;
+	case SC_END:
+		chardev_push_character(kbdout, 0x1b);
+		chardev_push_character(kbdout, 0x4f);
+		chardev_push_character(kbdout, 0x46);
+		break;
+	case SC_DELETE:
+		chardev_push_character(kbdout, 0x1b);
+		chardev_push_character(kbdout, 0x5b);
+		chardev_push_character(kbdout, 0x33);
+		chardev_push_character(kbdout, 0x7e);
+		break;
+	default:
+	    	letter = islower(ascii);
+		capslock = (keyflags & PRESSED_CAPSLOCK) ||
+		    (lockflags & LOCKED_CAPSLOCK);
+		shift = keyflags & PRESSED_SHIFT;
+		if (letter && capslock)
+			shift = !shift;
+		if (shift)
+			map = sc_secondary_map;
+		chardev_push_character(kbdout, map[sc]);
+		break;
+	}
+	spinlock_unlock(&keylock);
+}
+
+/** @}
+ */
Index: kernel/genarch/src/kbrd/scanc_pc.c
===================================================================
--- kernel/genarch/src/kbrd/scanc_pc.c	(revision 411b6a6f0339f865eaac5f492f2277fdfbbd5fcc)
+++ kernel/genarch/src/kbrd/scanc_pc.c	(revision 411b6a6f0339f865eaac5f492f2277fdfbbd5fcc)
@@ -0,0 +1,200 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup genarch	
+ * @{
+ */
+/**
+ * @file
+ * @brief	Scan codes for pc keyboards.
+ */
+
+#include <genarch/kbrd/scanc.h>
+
+/** Primary meaning of scancodes. */
+char sc_primary_map[] = {
+	SPECIAL, /* 0x00 */
+	SPECIAL, /* 0x01 - Esc */
+	'1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=',
+	'\b', /* 0x0e - Backspace */
+	'\t', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n',
+	SPECIAL, /* 0x1d - LCtrl */
+	'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'',
+	'`',
+	SPECIAL, /* 0x2a - LShift */ 
+	'\\',
+	'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/',
+	SPECIAL, /* 0x36 - RShift */
+	'*',
+	SPECIAL, /* 0x38 - LAlt */
+	' ',
+	SPECIAL, /* 0x3a - CapsLock */
+	SPECIAL, /* 0x3b - F1 */
+	SPECIAL, /* 0x3c - F2 */
+	SPECIAL, /* 0x3d - F3 */
+	SPECIAL, /* 0x3e - F4 */
+	SPECIAL, /* 0x3f - F5 */
+	SPECIAL, /* 0x40 - F6 */
+	SPECIAL, /* 0x41 - F7 */
+	SPECIAL, /* 0x42 - F8 */
+	SPECIAL, /* 0x43 - F9 */
+	SPECIAL, /* 0x44 - F10 */
+	SPECIAL, /* 0x45 - NumLock */
+	SPECIAL, /* 0x46 - ScrollLock */
+	'7', '8', '9', '-',
+	'4', '5', '6', '+',
+	'1', '2', '3',
+	'0', '.',
+	SPECIAL, /* 0x54 - Alt-SysRq */
+	SPECIAL, /* 0x55 - F11/F12/PF1/FN */
+	SPECIAL, /* 0x56 - unlabelled key next to LAlt */
+	SPECIAL, /* 0x57 - F11 */
+	SPECIAL, /* 0x58 - F12 */
+	SPECIAL, /* 0x59 */
+	SPECIAL, /* 0x5a */
+	SPECIAL, /* 0x5b */
+	SPECIAL, /* 0x5c */
+	SPECIAL, /* 0x5d */
+	SPECIAL, /* 0x5e */
+	SPECIAL, /* 0x5f */
+	SPECIAL, /* 0x60 */
+	SPECIAL, /* 0x61 */
+	SPECIAL, /* 0x62 */
+	SPECIAL, /* 0x63 */
+	SPECIAL, /* 0x64 */
+	SPECIAL, /* 0x65 */
+	SPECIAL, /* 0x66 */
+	SPECIAL, /* 0x67 */
+	SPECIAL, /* 0x68 */
+	SPECIAL, /* 0x69 */
+	SPECIAL, /* 0x6a */
+	SPECIAL, /* 0x6b */
+	SPECIAL, /* 0x6c */
+	SPECIAL, /* 0x6d */
+	SPECIAL, /* 0x6e */
+	SPECIAL, /* 0x6f */
+	SPECIAL, /* 0x70 */
+	SPECIAL, /* 0x71 */
+	SPECIAL, /* 0x72 */
+	SPECIAL, /* 0x73 */
+	SPECIAL, /* 0x74 */
+	SPECIAL, /* 0x75 */
+	SPECIAL, /* 0x76 */
+	SPECIAL, /* 0x77 */
+	SPECIAL, /* 0x78 */
+	SPECIAL, /* 0x79 */
+	SPECIAL, /* 0x7a */
+	SPECIAL, /* 0x7b */
+	SPECIAL, /* 0x7c */
+	SPECIAL, /* 0x7d */
+	SPECIAL, /* 0x7e */
+	SPECIAL, /* 0x7f */
+};
+
+/** Secondary meaning of scancodes. */
+char sc_secondary_map[] = {
+	SPECIAL, /* 0x00 */
+	SPECIAL, /* 0x01 - Esc */
+	'!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+',
+	SPECIAL, /* 0x0e - Backspace */
+	'\t', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', '\n',
+	SPECIAL, /* 0x1d - LCtrl */
+	'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '"',
+	'~',
+	SPECIAL, /* 0x2a - LShift */ 
+	'|',
+	'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', '>', '?',
+	SPECIAL, /* 0x36 - RShift */
+	'*',
+	SPECIAL, /* 0x38 - LAlt */
+	' ',
+	SPECIAL, /* 0x3a - CapsLock */
+	SPECIAL, /* 0x3b - F1 */
+	SPECIAL, /* 0x3c - F2 */
+	SPECIAL, /* 0x3d - F3 */
+	SPECIAL, /* 0x3e - F4 */
+	SPECIAL, /* 0x3f - F5 */
+	SPECIAL, /* 0x40 - F6 */
+	SPECIAL, /* 0x41 - F7 */
+	SPECIAL, /* 0x42 - F8 */
+	SPECIAL, /* 0x43 - F9 */
+	SPECIAL, /* 0x44 - F10 */
+	SPECIAL, /* 0x45 - NumLock */
+	SPECIAL, /* 0x46 - ScrollLock */
+	'7', '8', '9', '-',
+	'4', '5', '6', '+',
+	'1', '2', '3',
+	'0', '.',
+	SPECIAL, /* 0x54 - Alt-SysRq */
+	SPECIAL, /* 0x55 - F11/F12/PF1/FN */
+	SPECIAL, /* 0x56 - unlabelled key next to LAlt */
+	SPECIAL, /* 0x57 - F11 */
+	SPECIAL, /* 0x58 - F12 */
+	SPECIAL, /* 0x59 */
+	SPECIAL, /* 0x5a */
+	SPECIAL, /* 0x5b */
+	SPECIAL, /* 0x5c */
+	SPECIAL, /* 0x5d */
+	SPECIAL, /* 0x5e */
+	SPECIAL, /* 0x5f */
+	SPECIAL, /* 0x60 */
+	SPECIAL, /* 0x61 */
+	SPECIAL, /* 0x62 */
+	SPECIAL, /* 0x63 */
+	SPECIAL, /* 0x64 */
+	SPECIAL, /* 0x65 */
+	SPECIAL, /* 0x66 */
+	SPECIAL, /* 0x67 */
+	SPECIAL, /* 0x68 */
+	SPECIAL, /* 0x69 */
+	SPECIAL, /* 0x6a */
+	SPECIAL, /* 0x6b */
+	SPECIAL, /* 0x6c */
+	SPECIAL, /* 0x6d */
+	SPECIAL, /* 0x6e */
+	SPECIAL, /* 0x6f */
+	SPECIAL, /* 0x70 */
+	SPECIAL, /* 0x71 */
+	SPECIAL, /* 0x72 */
+	SPECIAL, /* 0x73 */
+	SPECIAL, /* 0x74 */
+	SPECIAL, /* 0x75 */
+	SPECIAL, /* 0x76 */
+	SPECIAL, /* 0x77 */
+	SPECIAL, /* 0x78 */
+	SPECIAL, /* 0x79 */
+	SPECIAL, /* 0x7a */
+	SPECIAL, /* 0x7b */
+	SPECIAL, /* 0x7c */
+	SPECIAL, /* 0x7d */
+	SPECIAL, /* 0x7e */
+	SPECIAL, /* 0x7f */	
+};
+
+/** @}
+ */
Index: kernel/genarch/src/kbrd/scanc_sun.c
===================================================================
--- kernel/genarch/src/kbrd/scanc_sun.c	(revision 411b6a6f0339f865eaac5f492f2277fdfbbd5fcc)
+++ kernel/genarch/src/kbrd/scanc_sun.c	(revision 411b6a6f0339f865eaac5f492f2277fdfbbd5fcc)
@@ -0,0 +1,304 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup genarch	
+ * @{
+ */
+/**
+ * @file
+ * @brief	Scan codes for Sun keyboards.
+ */
+
+#include <genarch/kbrd/scanc.h>
+
+/** Primary meaning of scancodes. */
+char sc_primary_map[] = {
+	[0x00] = SPECIAL,
+	[0x01] = SPECIAL,
+	[0x02] = SPECIAL,
+	[0x03] = SPECIAL,
+	[0x04] = SPECIAL,
+	[0x05] = SPECIAL,	/* F1 */
+	[0x06] = SPECIAL,	/* F2 */
+	[0x07] = SPECIAL,	/* F10 */
+	[0x08] = SPECIAL,	/* F3 */
+	[0x09] = SPECIAL,	/* F11 */
+	[0x0a] = SPECIAL,	/* F4 */
+	[0x0b] = SPECIAL,	/* F12 */
+	[0x0c] = SPECIAL,	/* F5 */
+	[0x0d] = SPECIAL,	/* RAlt */
+	[0x0e] = SPECIAL,	/* F6 */
+	[0x0f] = SPECIAL,
+	[0x10] = SPECIAL,	/* F7 */
+	[0x11] = SPECIAL,	/* F8 */
+	[0x12] = SPECIAL,	/* F9 */
+	[0x13] = SPECIAL,	/* LAlt */
+	[0x14] = SPECIAL,	/* Up Arrow */
+	[0x15] = SPECIAL,	/* Pause */
+	[0x16] = SPECIAL,
+	[0x17] = SPECIAL,	/* Scroll Lock */
+	[0x18] = SPECIAL,	/* Left Arrow */
+	[0x19] = SPECIAL,
+	[0x1a] = SPECIAL,
+	[0x1b] = SPECIAL,	/* Down Arrow */
+	[0x1c] = SPECIAL,	/* Right Arrow */
+	[0x1d] = SPECIAL,	/* Esc */
+	[0x1e] = '1',
+	[0x1f] = '2',
+	[0x20] = '3',
+	[0x21] = '4',
+	[0x22] = '5',
+	[0x23] = '6',
+	[0x24] = '7',
+	[0x25] = '8',
+	[0x26] = '9',
+	[0x27] = '0',
+	[0x28] = '-',
+	[0x29] = '=',
+	[0x2a] = '`',
+	[0x2b] = '\b',		/* Backspace */
+	[0x2c] = SPECIAL,	/* Insert */
+	[0x2d] = SPECIAL,
+	[0x2e] = '/',		/* numeric keypad */
+	[0x2f] = '*',		/* numeric keypad */
+	[0x30] = SPECIAL,
+	[0x31] = SPECIAL,
+	[0x32] = '.',		/* numeric keypad */
+	[0x33] = SPECIAL,
+	[0x34] = SPECIAL,	/* Home */
+	[0x35] = '\t',		/* Tab */
+	[0x36] = 'q',
+	[0x37] = 'w',
+	[0x38] = 'e',
+	[0x39] = 'r',
+	[0x3a] = 't',
+	[0x3b] = 'y',
+	[0x3c] = 'u',
+	[0x3d] = 'i',
+	[0x3e] = 'o',
+	[0x3f] = 'p',
+	[0x40] = '[',
+	[0x41] = ']',
+	[0x42] = SPECIAL,	/* Del */
+	[0x43] = SPECIAL,
+	[0x44] = '7',		/* numeric keypad */
+	[0x45] = '8',		/* numeric keypad */
+	[0x46] = '9',		/* numeric keypad */
+	[0x47] = '-',		/* numeric keypad */
+	[0x48] = SPECIAL,
+	[0x49] = SPECIAL,
+	[0x4a] = SPECIAL,	/* End */
+	[0x4b] = SPECIAL,
+	[0x4c] = SPECIAL,	/* Control */
+	[0x4d] = 'a',
+	[0x4e] = 's',
+	[0x4f] = 'd',
+	[0x50] = 'f',
+	[0x51] = 'g',
+	[0x52] = 'h',
+	[0x53] = 'j',
+	[0x54] = 'k',
+	[0x55] = 'l',
+	[0x56] = ';',
+	[0x57] = '\'',
+	[0x58] = '\\',
+	[0x59] = '\n',		/* Enter */
+	[0x5a] = '\n',		/* Enter on numeric keypad */
+	[0x5b] = '4',		/* numeric keypad */
+	[0x5c] = '5',		/* numeric keypad */
+	[0x5d] = '6',		/* numeric keypad */
+	[0x5e] = '0',		/* numeric keypad */
+	[0x5f] = SPECIAL,
+	[0x60] = SPECIAL,	/* Page Up */
+	[0x61] = SPECIAL,
+	[0x62] = SPECIAL,	/* Num Lock */
+	[0x63] = SPECIAL,	/* LShift */
+	[0x64] = 'z',
+	[0x65] = 'x',
+	[0x66] = 'c',
+	[0x67] = 'v',
+	[0x68] = 'b',
+	[0x69] = 'n',
+	[0x6a] = 'm',
+	[0x6b] = ',',
+	[0x6c] = '.',
+	[0x6d] = '/',
+	[0x6e] = SPECIAL,	/* RShift */
+	[0x6f] = SPECIAL,
+	[0x70] = '1',		/* numeric keypad */
+	[0x71] = '2',		/* numeric keypad */
+	[0x72] = '3',		/* numeric keypad */
+	[0x73] = SPECIAL,
+	[0x74] = SPECIAL,
+	[0x75] = SPECIAL,
+	[0x76] = SPECIAL,
+	[0x77] = SPECIAL,	/* Caps Lock */
+	[0x78] = SPECIAL,
+	[0x79] = ' ',
+	[0x7a] = SPECIAL,
+	[0x7b] = SPECIAL,	/* Page Down */
+	[0x7c] = SPECIAL,
+	[0x7d] = '+',		/* numeric key pad */
+	[0x7e] = SPECIAL,
+	[0x7f] = SPECIAL
+};
+
+/** Secondary meaning of scancodes. */
+char sc_secondary_map[] = {
+	[0x00] = SPECIAL,
+	[0x01] = SPECIAL,
+	[0x02] = SPECIAL,
+	[0x03] = SPECIAL,
+	[0x04] = SPECIAL,
+	[0x05] = SPECIAL,	/* F1 */
+	[0x06] = SPECIAL,	/* F2 */
+	[0x07] = SPECIAL,	/* F10 */
+	[0x08] = SPECIAL,	/* F3 */
+	[0x09] = SPECIAL,	/* F11 */
+	[0x0a] = SPECIAL,	/* F4 */
+	[0x0b] = SPECIAL,	/* F12 */
+	[0x0c] = SPECIAL,	/* F5 */
+	[0x0d] = SPECIAL,	/* RAlt */
+	[0x0e] = SPECIAL,	/* F6 */
+	[0x0f] = SPECIAL,
+	[0x10] = SPECIAL,	/* F7 */
+	[0x11] = SPECIAL,	/* F8 */
+	[0x12] = SPECIAL,	/* F9 */
+	[0x13] = SPECIAL,	/* LAlt */
+	[0x14] = SPECIAL,	/* Up Arrow */
+	[0x15] = SPECIAL,	/* Pause */
+	[0x16] = SPECIAL,
+	[0x17] = SPECIAL,	/* Scroll Lock */
+	[0x18] = SPECIAL,	/* Left Arrow */
+	[0x19] = SPECIAL,
+	[0x1a] = SPECIAL,
+	[0x1b] = SPECIAL,	/* Down Arrow */
+	[0x1c] = SPECIAL,	/* Right Arrow */
+	[0x1d] = SPECIAL,	/* Esc */
+	[0x1e] = '!',
+	[0x1f] = '@',
+	[0x20] = '#',
+	[0x21] = '$',
+	[0x22] = '%',
+	[0x23] = '^',
+	[0x24] = '&',
+	[0x25] = '*',
+	[0x26] = '(',
+	[0x27] = ')',
+	[0x28] = '_',
+	[0x29] = '+',
+	[0x2a] = '~',
+	[0x2b] = SPECIAL,	/* Backspace */
+	[0x2c] = SPECIAL,	/* Insert */
+	[0x2d] = SPECIAL,
+	[0x2e] = '/',		/* numeric keypad */
+	[0x2f] = '*',		/* numeric keypad */
+	[0x30] = SPECIAL,
+	[0x31] = SPECIAL,
+	[0x32] = '.',		/* numeric keypad */
+	[0x33] = SPECIAL,
+	[0x34] = SPECIAL,	/* Home */
+	[0x35] = SPECIAL,	/* Tab */
+	[0x36] = 'Q',
+	[0x37] = 'W',
+	[0x38] = 'E',
+	[0x39] = 'R',
+	[0x3a] = 'T',
+	[0x3b] = 'Y',
+	[0x3c] = 'U',
+	[0x3d] = 'I',
+	[0x3e] = 'O',
+	[0x3f] = 'P',
+	[0x40] = '{',
+	[0x41] = '}',
+	[0x42] = SPECIAL,	/* Del */
+	[0x43] = SPECIAL,
+	[0x44] = '7',		/* numeric keypad */
+	[0x45] = '8',		/* numeric keypad */
+	[0x46] = '9',		/* numeric keypad */
+	[0x47] = '-',		/* numeric keypad */
+	[0x48] = SPECIAL,
+	[0x49] = SPECIAL,
+	[0x4a] = SPECIAL,	/* End */
+	[0x4b] = SPECIAL,
+	[0x4c] = SPECIAL,	/* Control */
+	[0x4d] = 'A',
+	[0x4e] = 'S',
+	[0x4f] = 'D',
+	[0x50] = 'F',
+	[0x51] = 'G',
+	[0x52] = 'H',
+	[0x53] = 'J',
+	[0x54] = 'K',
+	[0x55] = 'L',
+	[0x56] = ':',
+	[0x57] = '"',
+	[0x58] = '|',
+	[0x59] = SPECIAL,	/* Enter */
+	[0x5a] = SPECIAL,	/* Enter on numeric keypad */
+	[0x5b] = '4',		/* numeric keypad */
+	[0x5c] = '5',		/* numeric keypad */
+	[0x5d] = '6',		/* numeric keypad */
+	[0x5e] = '0',		/* numeric keypad */
+	[0x5f] = SPECIAL,
+	[0x60] = SPECIAL,	/* Page Up */
+	[0x61] = SPECIAL,
+	[0x62] = SPECIAL,	/* Num Lock */
+	[0x63] = SPECIAL,	/* LShift */
+	[0x64] = 'Z',
+	[0x65] = 'X',
+	[0x66] = 'C',
+	[0x67] = 'V',
+	[0x68] = 'B',
+	[0x69] = 'N',
+	[0x6a] = 'M',
+	[0x6b] = '<',
+	[0x6c] = '>',
+	[0x6d] = '?',
+	[0x6e] = SPECIAL,	/* RShift */
+	[0x6f] = SPECIAL,
+	[0x70] = '1',		/* numeric keypad */
+	[0x71] = '2',		/* numeric keypad */
+	[0x72] = '3',		/* numeric keypad */
+	[0x73] = SPECIAL,
+	[0x74] = SPECIAL,
+	[0x75] = SPECIAL,
+	[0x76] = SPECIAL,
+	[0x77] = SPECIAL,	/* Caps Lock */
+	[0x78] = SPECIAL,
+	[0x79] = ' ',
+	[0x7a] = SPECIAL,
+	[0x7b] = SPECIAL,	/* Page Down */
+	[0x7c] = SPECIAL,
+	[0x7d] = '+',		/* numeric key pad */
+	[0x7e] = SPECIAL,
+	[0x7f] = SPECIAL
+};
+
+/** @}
+ */
Index: kernel/generic/include/console/console.h
===================================================================
--- kernel/generic/include/console/console.h	(revision e06da7efc998285c1aa3d8a9ceb29e2a5aea6fdb)
+++ kernel/generic/include/console/console.h	(revision 411b6a6f0339f865eaac5f492f2277fdfbbd5fcc)
@@ -44,9 +44,11 @@
 extern bool silent;
 
+extern void console_init(void);
+
 extern void klog_init(void);
 extern void klog_update(void);
 
 extern uint8_t getc(chardev_t *chardev);
-uint8_t _getc(chardev_t *chardev);
+extern uint8_t _getc(chardev_t *chardev);
 extern count_t gets(chardev_t *chardev, char *buf, size_t buflen);
 extern void putchar(char c);
Index: kernel/generic/src/console/console.c
===================================================================
--- kernel/generic/src/console/console.c	(revision e06da7efc998285c1aa3d8a9ceb29e2a5aea6fdb)
+++ kernel/generic/src/console/console.c	(revision 411b6a6f0339f865eaac5f492f2277fdfbbd5fcc)
@@ -107,7 +107,27 @@
 }
 
+static void stdin_suspend(chardev_t *d)
+{
+}
+
+static void stdin_resume(chardev_t *d)
+{
+}
+
+static chardev_operations_t stdin_ops = {
+	.suspend = stdin_suspend,
+	.resume = stdin_resume,
+};
+
 /** Standard input character device */
+static chardev_t _stdin;
 chardev_t *stdin = NULL;
 chardev_t *stdout = &null_stdout;
+
+void console_init(void)
+{
+	chardev_initialize("stdin", &_stdin, &stdin_ops);
+	stdin = &_stdin;
+}
 
 /** Initialize kernel logging facility
Index: kernel/generic/src/main/main.c
===================================================================
--- kernel/generic/src/main/main.c	(revision e06da7efc998285c1aa3d8a9ceb29e2a5aea6fdb)
+++ kernel/generic/src/main/main.c	(revision 411b6a6f0339f865eaac5f492f2277fdfbbd5fcc)
@@ -257,4 +257,5 @@
 	LOG_EXEC(ipc_init());
 	LOG_EXEC(klog_init());
+	LOG_EXEC(console_init());
 	
 #ifdef CONFIG_KCONSOLE
