Index: uspace/kbd/Makefile
===================================================================
--- uspace/kbd/Makefile	(revision 9dae51d7af10e4e1cc8b9dc8f11dd75a35e17135)
+++ uspace/kbd/Makefile	(revision 9141377d3aec1027ed16cfa6e2085fc028ba13f7)
@@ -50,16 +50,30 @@
 
 ifeq ($(ARCH), ia32)
-	ARCH_SOURCES += arch/$(ARCH)/src/mouse.c
+	ARCH_SOURCES += \
+		arch/$(ARCH)/src/mouse.c \
+		arch/$(ARCH)/src/scanc.c
+	GENARCH_SOURCES = \
+		genarch/src/kbd.c
 	CFLAGS += -DMOUSE_ENABLED
 endif
 ifeq ($(ARCH), amd64)
-	ARCH_SOURCES += arch/$(ARCH)/src/mouse.c
+	ARCH_SOURCES += \
+		arch/$(ARCH)/src/mouse.c \
+		arch/$(ARCH)/src/scanc.c
+	GENARCH_SOURCES = \
+		genarch/src/kbd.c
 	CFLAGS += -DMOUSE_ENABLED
 endif
-
+ifeq ($(ARCH), sparc64)
+	ARCH_SOURCES += \
+		arch/$(ARCH)/src/scanc.c
+	GENARCH_SOURCES = \
+		genarch/src/kbd.c
+endif
 
 
 GENERIC_OBJECTS := $(addsuffix .o,$(basename $(GENERIC_SOURCES)))
 ARCH_OBJECTS := $(addsuffix .o,$(basename $(ARCH_SOURCES)))
+GENARCH_OBJECTS := $(addsuffix .o,$(basename $(GENARCH_SOURCES)))
 
 .PHONY: all clean depend disasm links
@@ -71,13 +85,14 @@
 links:
 	ln -sfn ../arch/$(ARCH)/include include/arch
+	ln -sfn ../genarch/include include/genarch
 
 clean:
-	-rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend include/arch
+	-rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend include/arch include/genarch
 
 depend:
 	$(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend
 
-$(OUTPUT): $(ARCH_OBJECTS) $(GENERIC_OBJECTS) $(LIBS)
-	$(LD) -T $(LIBC_PREFIX)/arch/$(ARCH)/_link.ld -e __entry_driver $(GENERIC_OBJECTS) $(ARCH_OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
+$(OUTPUT): $(ARCH_OBJECTS) $(GENERIC_OBJECTS) $(GENARCH_OBJECTS) $(LIBS)
+	$(LD) -T $(LIBC_PREFIX)/arch/$(ARCH)/_link.ld -e __entry_driver $(GENERIC_OBJECTS) $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
 
 disasm:
Index: uspace/kbd/arch/sparc64/include/kbd.h
===================================================================
--- uspace/kbd/arch/sparc64/include/kbd.h	(revision 9dae51d7af10e4e1cc8b9dc8f11dd75a35e17135)
+++ uspace/kbd/arch/sparc64/include/kbd.h	(revision 9141377d3aec1027ed16cfa6e2085fc028ba13f7)
@@ -35,10 +35,6 @@
  */
 
-#ifndef __sparc64_KBD_H__
-#define __sparc64_KBD_H__
-
-#include <key_buffer.h>
-
-int kbd_arch_init(void);
+#ifndef KBD_sparc64_KBD_H_
+#define KBD_sparc64_KBD_H_
 
 #endif
Index: uspace/kbd/arch/sparc64/include/scanc.h
===================================================================
--- uspace/kbd/arch/sparc64/include/scanc.h	(revision 9141377d3aec1027ed16cfa6e2085fc028ba13f7)
+++ uspace/kbd/arch/sparc64/include/scanc.h	(revision 9141377d3aec1027ed16cfa6e2085fc028ba13f7)
@@ -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 KBD_SCANC_SUN_H_
+#define KBD_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: uspace/kbd/arch/sparc64/src/kbd.c
===================================================================
--- uspace/kbd/arch/sparc64/src/kbd.c	(revision 9dae51d7af10e4e1cc8b9dc8f11dd75a35e17135)
+++ uspace/kbd/arch/sparc64/src/kbd.c	(revision 9141377d3aec1027ed16cfa6e2085fc028ba13f7)
@@ -40,14 +40,40 @@
 #include <kbd.h>
 #include <keys.h>
+#include <stdio.h>
+#include <types.h>
+#include <genarch/kbd.h>
 
+#define KBD_KEY_RELEASE		0x80
+#define KBD_ALL_KEYS_UP		0x7f
+
+irq_cmd_t z8530_cmds[] = {
+	{ CMD_MEM_READ_1, 0, 0, 1 }
+};
+	
+irq_code_t z8530_kbd = {
+	1,
+	z8530_cmds
+};
 
 int kbd_arch_init(void)
 {
+	z8530_cmds[0].addr = (void *) sysinfo_value("kbd.address.virtual") + 6;
+	ipc_register_irq(sysinfo_value("kbd.irq"), &z8530_kbd);
 	return 0;
 }
 
+/** Process keyboard events */
+int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call)
+{
+	int scan_code = IPC_GET_ARG1(*call);
 
-int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call) 
-{
+	if (scan_code == KBD_ALL_KEYS_UP)
+		return 1;
+		
+	if (scan_code & KBD_KEY_RELEASE)
+		key_released(keybuffer, scan_code ^ KBD_KEY_RELEASE);
+	else
+		key_pressed(keybuffer, scan_code);
+
 	return 1;
 }
Index: uspace/kbd/arch/sparc64/src/scanc.c
===================================================================
--- uspace/kbd/arch/sparc64/src/scanc.c	(revision 9141377d3aec1027ed16cfa6e2085fc028ba13f7)
+++ uspace/kbd/arch/sparc64/src/scanc.c	(revision 9141377d3aec1027ed16cfa6e2085fc028ba13f7)
@@ -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/scanc.h>
+
+/** Primary meaning of scancodes. */
+int sc_primary_map[] = {
+	[0x00] = SPECIAL,
+	[0x01] = SPECIAL,
+	[0x02] = SPECIAL,
+	[0x03] = SPECIAL,
+	[0x04] = SPECIAL,
+	[0x05] = FUNCTION_KEYS + 1,	/* F1 */
+	[0x06] = FUNCTION_KEYS + 2,	/* F2 */
+	[0x07] = FUNCTION_KEYS + 10,	/* F10 */
+	[0x08] = FUNCTION_KEYS + 3,	/* F3 */
+	[0x09] = FUNCTION_KEYS + 11,	/* F11 */
+	[0x0a] = FUNCTION_KEYS + 4,	/* F4 */
+	[0x0b] = FUNCTION_KEYS + 12,	/* F12 */
+	[0x0c] = FUNCTION_KEYS + 5,	/* F5 */
+	[0x0d] = SPECIAL,	/* RAlt */
+	[0x0e] = FUNCTION_KEYS + 6,	/* F6 */
+	[0x0f] = SPECIAL,
+	[0x10] = FUNCTION_KEYS + 7,	/* F7 */
+	[0x11] = FUNCTION_KEYS + 8,	/* F8 */
+	[0x12] = FUNCTION_KEYS + 9,	/* 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. */
+int 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: uspace/kbd/genarch/include/kbd.h
===================================================================
--- uspace/kbd/genarch/include/kbd.h	(revision 9141377d3aec1027ed16cfa6e2085fc028ba13f7)
+++ uspace/kbd/genarch/include/kbd.h	(revision 9141377d3aec1027ed16cfa6e2085fc028ba13f7)
@@ -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 kbd
+ * @{
+ */ 
+/** @file
+ */
+
+#ifndef KBD_genarch_KBD_H_
+#define KBD_genarch_KBD_H_
+
+#include <key_buffer.h>
+
+extern void key_released(keybuffer_t *keybuffer, unsigned char key);
+extern void key_pressed(keybuffer_t *keybuffer, unsigned char key);
+
+#endif
+
+/**
+ * @}
+ */ 
Index: uspace/kbd/genarch/include/scanc.h
===================================================================
--- uspace/kbd/genarch/include/scanc.h	(revision 9141377d3aec1027ed16cfa6e2085fc028ba13f7)
+++ uspace/kbd/genarch/include/scanc.h	(revision 9141377d3aec1027ed16cfa6e2085fc028ba13f7)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2001-2004 Jakub Jermar
+ * Copyright (C) 2006 Josef Cejka
+ * 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 kbd
+ * @{
+ */ 
+/** @file
+ */
+
+#ifndef KBD_SCANC_H_
+#define KBD_SCANC_H_
+
+#define FUNCTION_KEYS 0x100
+
+#define SPECIAL		255
+
+extern int sc_primary_map[];
+extern int sc_secondary_map[];
+
+#endif
+
+/**
+ * @}
+ */ 
Index: uspace/kbd/genarch/src/kbd.c
===================================================================
--- uspace/kbd/genarch/src/kbd.c	(revision 9141377d3aec1027ed16cfa6e2085fc028ba13f7)
+++ uspace/kbd/genarch/src/kbd.c	(revision 9141377d3aec1027ed16cfa6e2085fc028ba13f7)
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2001-2004 Jakub Jermar
+ * Copyright (C) 2006 Josef Cejka
+ * 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 kbd
+ * @brief	Handling of keyboard IRQ notifications for several architectures.
+ * @ingroup  kbd
+ * @{
+ */ 
+/** @file
+ */
+
+#include <key_buffer.h>
+#include <arch/scanc.h>
+#include <genarch/scanc.h>
+#include <genarch/kbd.h>
+#include <libc.h>
+
+#define PRESSED_SHIFT		(1<<0)
+#define PRESSED_CAPSLOCK	(1<<1)
+#define LOCKED_CAPSLOCK		(1<<0)
+
+static volatile int keyflags;		/**< Tracking of multiple keypresses. */
+static volatile int lockflags;		/**< Tracking of multiple keys lockings. */
+
+void key_released(keybuffer_t *keybuffer, unsigned char key)
+{
+	switch (key) {
+	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;
+	}
+}
+
+void key_pressed(keybuffer_t *keybuffer, unsigned char key)
+{
+	int *map = sc_primary_map;
+	int ascii = sc_primary_map[key];
+	int shift, capslock;
+	int letter = 0;
+
+	static int esc_count = 0;
+
+	if (key == SC_ESC) {
+		esc_count++;
+		if (esc_count == 3)
+			__SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE);
+	} else {
+		esc_count = 0;
+	}
+	
+	switch (key) {
+	case SC_LSHIFT:
+	case SC_RSHIFT:
+	    	keyflags |= PRESSED_SHIFT;
+		break;
+	case SC_CAPSLOCK:
+		keyflags |= PRESSED_CAPSLOCK;
+		break;
+	case SC_SPEC_ESCAPE:
+		break;
+	default:
+	    	letter = ((ascii >= 'a') && (ascii <= 'z'));
+		capslock = (keyflags & PRESSED_CAPSLOCK) || (lockflags & LOCKED_CAPSLOCK);
+		shift = keyflags & PRESSED_SHIFT;
+		if (letter && capslock)
+			shift = !shift;
+		if (shift)
+			map = sc_secondary_map;
+		if (map[key] != SPECIAL)
+			keybuffer_push(keybuffer, map[key]);	
+		break;
+	}
+}
+
+/**
+ * @}
+ */ 
