Index: uspace/Makefile
===================================================================
--- uspace/Makefile	(revision 19397becd25f896f19a94f9f6867540d2c59da3d)
+++ uspace/Makefile	(revision d420b22fe09893c1b4117473e6787a4295055001)
@@ -155,12 +155,9 @@
 	drv/bus/usb/usbmid \
 	drv/bus/usb/vhc \
-	drv/char/atkbd \
 	drv/char/i8042 \
 	drv/char/ns8250 \
 	drv/char/pl050 \
-	drv/char/ps2mouse \
 	drv/char/ski-con \
 	drv/char/sun4v-con \
-	drv/char/xtkbd \
 	drv/test/test1 \
 	drv/test/test2 \
@@ -168,4 +165,7 @@
 	drv/fb/amdm37x_dispc \
 	drv/fb/kfb \
+	drv/hid/atkbd \
+	drv/hid/ps2mouse \
+	drv/hid/xtkbd \
 	drv/intctl/apic \
 	drv/intctl/i8259 \
Index: uspace/drv/char/atkbd/Makefile
===================================================================
--- uspace/drv/char/atkbd/Makefile	(revision 19397becd25f896f19a94f9f6867540d2c59da3d)
+++ 	(revision )
@@ -1,37 +1,0 @@
-#
-# Copyright (c) 2011 Jan Vesely
-# 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.
-#
-
-USPACE_PREFIX = ../../..
-LIBS = drv
-BINARY = atkbd
-
-SOURCES = \
-	main.c \
-	atkbd.c
-
-include $(USPACE_PREFIX)/Makefile.common
Index: uspace/drv/char/atkbd/atkbd.c
===================================================================
--- uspace/drv/char/atkbd/atkbd.c	(revision 19397becd25f896f19a94f9f6867540d2c59da3d)
+++ 	(revision )
@@ -1,409 +1,0 @@
-/*
- * Copyright (c) 2011 Jan Vesely
- * Copyright (c) 2009 Vineeth Pillai
- * 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 drvkbd
- * @{
- */
-/** @file
- * @brief AT keyboard driver
- */
-
-#include <errno.h>
-#include <ddf/log.h>
-#include <io/keycode.h>
-#include <io/chardev.h>
-#include <io/console.h>
-#include <ipc/kbdev.h>
-#include <abi/ipc/methods.h>
-#include "atkbd.h"
-
-#define AT_CAPS_SCAN_CODE 0x58
-#define AT_NUM_SCAN_CODE 0x77
-#define AT_SCROLL_SCAN_CODE 0x7E
-
-/* Set 2 scan codes (AT keyboard) */
-static const unsigned int scanmap_simple[] = {
-	[0x0e] = KC_BACKTICK,
-
-	[0x16] = KC_1,
-	[0x1e] = KC_2,
-	[0x26] = KC_3,
-	[0x25] = KC_4,
-	[0x2e] = KC_5,
-	[0x36] = KC_6,
-	[0x3d] = KC_7,
-	[0x3e] = KC_8,
-	[0x46] = KC_9,
-	[0x45] = KC_0,
-
-	[0x4e] = KC_MINUS,
-	[0x55] = KC_EQUALS,
-	[0x66] = KC_BACKSPACE,
-
-	[0x0d] = KC_TAB,
-
-	[0x15] = KC_Q,
-	[0x1d] = KC_W,
-	[0x24] = KC_E,
-	[0x2d] = KC_R,
-	[0x2c] = KC_T,
-	[0x35] = KC_Y,
-	[0x3c] = KC_U,
-	[0x43] = KC_I,
-	[0x44] = KC_O,
-	[0x4d] = KC_P,
-
-	[0x54] = KC_LBRACKET,
-	[0x5b] = KC_RBRACKET,
-
-	[0x58] = KC_CAPS_LOCK,
-
-	[0x1c] = KC_A,
-	[0x1b] = KC_S,
-	[0x23] = KC_D,
-	[0x2b] = KC_F,
-	[0x34] = KC_G,
-	[0x33] = KC_H,
-	[0x3b] = KC_J,
-	[0x42] = KC_K,
-	[0x4b] = KC_L,
-
-	[0x4c] = KC_SEMICOLON,
-	[0x52] = KC_QUOTE,
-	[0x5d] = KC_BACKSLASH,
-
-	[0x12] = KC_LSHIFT,
-
-	[0x1a] = KC_Z,
-	[0x22] = KC_X,
-	[0x21] = KC_C,
-	[0x2a] = KC_V,
-	[0x32] = KC_B,
-	[0x31] = KC_N,
-	[0x3a] = KC_M,
-
-	[0x41] = KC_COMMA,
-	[0x49] = KC_PERIOD,
-	[0x4a] = KC_SLASH,
-
-	[0x59] = KC_RSHIFT,
-
-	[0x14] = KC_LCTRL,
-	[0x11] = KC_LALT,
-	[0x29] = KC_SPACE,
-
-	[0x76] = KC_ESCAPE,
-
-	[0x05] = KC_F1,
-	[0x06] = KC_F2,
-	[0x04] = KC_F3,
-	[0x0c] = KC_F4,
-	[0x03] = KC_F5,
-	[0x0b] = KC_F6,
-	[0x02] = KC_F7,
-
-	[0x0a] = KC_F8,
-	[0x01] = KC_F9,
-	[0x09] = KC_F10,
-
-	[0x78] = KC_F11,
-	[0x07] = KC_F12,
-
-	[0x7e] = KC_SCROLL_LOCK,
-
-	[0x5a] = KC_ENTER,
-
-	[0x77] = KC_NUM_LOCK,
-	[0x7c] = KC_NTIMES,
-	[0x7b] = KC_NMINUS,
-	[0x79] = KC_NPLUS,
-	[0x6c] = KC_N7,
-	[0x75] = KC_N8,
-	[0x7d] = KC_N9,
-	[0x6b] = KC_N4,
-	[0x73] = KC_N5,
-	[0x74] = KC_N6,
-	[0x69] = KC_N1,
-	[0x72] = KC_N2,
-	[0x7a] = KC_N3,
-	[0x70] = KC_N0,
-	[0x71] = KC_NPERIOD,
-};
-
-#define KBD_SCANCODE_SET_EXTENDED		0xe0
-#define KBD_SCANCODE_SET_EXTENDED_SPECIAL	0xe1
-#define KBD_SCANCODE_KEY_RELEASE		0xf0
-
-static const unsigned int scanmap_e0[] = {
-	[0x65] = KC_RALT,
-	[0x59] = KC_RSHIFT,
-
-	[0x64] = KC_PRTSCR,
-
-	[0x70] = KC_INSERT,
-	[0x6c] = KC_HOME,
-	[0x7d] = KC_PAGE_UP,
-
-	[0x71] = KC_DELETE,
-	[0x69] = KC_END,
-	[0x7a] = KC_PAGE_DOWN,
-
-	[0x75] = KC_UP,
-	[0x6b] = KC_LEFT,
-	[0x72] = KC_DOWN,
-	[0x74] = KC_RIGHT,
-
-	[0x4a] = KC_NSLASH,
-	[0x5a] = KC_NENTER
-};
-
-static void push_event(async_sess_t *sess, kbd_event_type_t type,
-    unsigned int key)
-{
-	async_exch_t *exch = async_exchange_begin(sess);
-	async_msg_4(exch, KBDEV_EVENT, type, key, 0, 0);
-	async_exchange_end(exch);
-}
-
-/** Get data and parse scancodes.
- *
- * @param arg Pointer to at_kbd_t structure.
- *
- * @return EIO on error.
- *
- */
-static int polling(void *arg)
-{
-	const at_kbd_t *kbd = arg;
-	
-	assert(kbd);
-	assert(kbd->parent_sess);
-	
-	async_exch_t *parent_exch = async_exchange_begin(kbd->parent_sess);
-	
-	while (true) {
-		if (!parent_exch)
-			parent_exch = async_exchange_begin(kbd->parent_sess);
-
-		uint8_t code = 0;
-		ssize_t size = chardev_read(parent_exch, &code, 1);
-		if (size != 1)
-			return EIO;
-		
-		const unsigned int *map;
-		size_t map_size;
-		
-		if (code == KBD_SCANCODE_SET_EXTENDED) {
-			map = scanmap_e0;
-			map_size = sizeof(scanmap_e0) / sizeof(unsigned int);
-			
-			size = chardev_read(parent_exch, &code, 1);
-			if (size != 1)
-				return EIO;
-		} else if (code == KBD_SCANCODE_SET_EXTENDED_SPECIAL) {
-			size = chardev_read(parent_exch, &code, 1);
-			if (size != 1)
-				return EIO;
-			if (code != 0x14)
-				continue;
-
-			size = chardev_read(parent_exch, &code, 1);
-			if (size != 1)
-				return EIO;
-			if (code != 0x77)
-				continue;
-
-			size = chardev_read(parent_exch, &code, 1);
-			if (size != 1)
-				return EIO;
-			if (code != 0xe1)
-				continue;
-
-			size = chardev_read(parent_exch, &code, 1);
-			if (size != 1)
-				return EIO;
-			if (code != 0xf0)
-				continue;
-
-			size = chardev_read(parent_exch, &code, 1);
-			if (size != 1)
-				return EIO;
-			if (code != 0x14)
-				continue;
-
-			size = chardev_read(parent_exch, &code, 1);
-			if (size != 1)
-				return EIO;
-			if (code != 0xf0)
-				continue;
-
-			size = chardev_read(parent_exch, &code, 1);
-			if (size != 1)
-				return EIO;
-			if (code == 0x77)
-				push_event(kbd->client_sess, KEY_PRESS, KC_BREAK);
-
-			continue;
-		} else {
-			map = scanmap_simple;
-			map_size = sizeof(scanmap_simple) / sizeof(unsigned int);
-		}
-		
-		kbd_event_type_t type;
-		if (code == KBD_SCANCODE_KEY_RELEASE) {
-			type = KEY_RELEASE;
-			size = chardev_read(parent_exch, &code, 1);
-			if (size != 1)
-				return EIO;
-		} else {
-			type = KEY_PRESS;
-		}
-		
-		const unsigned int key = (code < map_size) ? map[code] : 0;
-		
-		if (key != 0)
-			push_event(kbd->client_sess, type, key);
-		else
-			ddf_msg(LVL_WARN, "Unknown scancode: %hhx", code);
-	}
-}
-
-/** Default handler for IPC methods not handled by DDF.
- *
- * @param fun     Device function handling the call.
- * @param icallid Call id.
- * @param icall   Call data.
- *
- */
-static void default_connection_handler(ddf_fun_t *fun,
-    ipc_callid_t icallid, ipc_call_t *icall)
-{
-	const sysarg_t method = IPC_GET_IMETHOD(*icall);
-	at_kbd_t *kbd = ddf_dev_data_get(ddf_fun_get_dev(fun));
-
-	switch (method) {
-	case KBDEV_SET_IND: {
-		async_answer_0(icallid, ENOTSUP);
-		break;
-	}
-	/*
-	 * This might be ugly but async_callback_receive_start makes no
-	 * difference for incorrect call and malloc failure.
-	 */
-	case IPC_M_CONNECT_TO_ME: {
-		async_sess_t *sess =
-		    async_callback_receive_start(EXCHANGE_SERIALIZE, icall);
-		
-		/* Probably ENOMEM error, try again. */
-		if (sess == NULL) {
-			ddf_msg(LVL_WARN,
-			    "Failed creating callback session");
-			async_answer_0(icallid, EAGAIN);
-			break;
-		}
-		
-		if (kbd->client_sess == NULL) {
-			kbd->client_sess = sess;
-			ddf_msg(LVL_DEBUG, "Set client session");
-			async_answer_0(icallid, EOK);
-		} else {
-			ddf_msg(LVL_ERROR, "Client session already set");
-			async_answer_0(icallid, ELIMIT);
-		}
-		
-		break;
-	}
-	default:
-		ddf_msg(LVL_ERROR, "Unknown method: %d.", (int)method);
-		async_answer_0(icallid, EINVAL);
-		break;
-	}
-}
-
-/** Keyboard function ops. */
-static ddf_dev_ops_t kbd_ops = {
-	.default_handler = default_connection_handler
-};
-
-/** Initialize keyboard driver structure.
- *
- * @param kbd Keyboard driver structure to initialize.
- * @param dev DDF device structure.
- *
- * Connects to parent, creates keyboard function, starts polling fibril.
- *
- */
-int at_kbd_init(at_kbd_t *kbd, ddf_dev_t *dev)
-{
-	assert(kbd);
-	assert(dev);
-	
-	kbd->client_sess = NULL;
-	kbd->parent_sess = ddf_dev_parent_sess_get(dev);
-	
-	if (!kbd->parent_sess) {
-		ddf_msg(LVL_ERROR, "Failed creating parent session.");
-		return EIO;
-	}
-	
-	kbd->kbd_fun = ddf_fun_create(dev, fun_exposed, "kbd");
-	if (!kbd->kbd_fun) {
-		ddf_msg(LVL_ERROR, "Failed creating function 'kbd'.");
-		return ENOMEM;
-	}
-	
-	ddf_fun_set_ops(kbd->kbd_fun, &kbd_ops);
-	
-	int ret = ddf_fun_bind(kbd->kbd_fun);
-	if (ret != EOK) {
-		ddf_msg(LVL_ERROR, "Failed binding function 'kbd'.");
-		ddf_fun_destroy(kbd->kbd_fun);
-		return EEXIST;
-	}
-	
-	ret = ddf_fun_add_to_category(kbd->kbd_fun, "keyboard");
-	if (ret != EOK) {
-		ddf_msg(LVL_ERROR, "Failed adding function 'kbd' to category "
-		    "'keyboard'.");
-		ddf_fun_unbind(kbd->kbd_fun);
-		ddf_fun_destroy(kbd->kbd_fun);
-		return ENOMEM;
-	}
-	
-	kbd->polling_fibril = fibril_create(polling, kbd);
-	if (!kbd->polling_fibril) {
-		ddf_msg(LVL_ERROR, "Failed creating polling fibril.");
-		ddf_fun_unbind(kbd->kbd_fun);
-		ddf_fun_destroy(kbd->kbd_fun);
-		return ENOMEM;
-	}
-	
-	fibril_add_ready(kbd->polling_fibril);
-	return EOK;
-}
Index: uspace/drv/char/atkbd/atkbd.h
===================================================================
--- uspace/drv/char/atkbd/atkbd.h	(revision 19397becd25f896f19a94f9f6867540d2c59da3d)
+++ 	(revision )
@@ -1,56 +1,0 @@
-/*
- * Copyright (c) 2011 Jan Vesely
- * 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 drvkbd
- * @{
- */
-/** @file
- * @brief AT keyboard driver
- */
-
-#ifndef _AT_KBD_H_
-#define _AT_KBD_H_
-
-#include <ddf/driver.h>
-#include <fibril.h>
-
-/** PC/AT keyboard driver structure. */
-typedef struct {
-	ddf_fun_t *kbd_fun;        /**< Keyboard function. */
-	async_sess_t *parent_sess; /**< Connection to device providing data. */
-	async_sess_t *client_sess; /**< Callback connection to client. */
-	fid_t polling_fibril;      /**< Fibril retrieving an parsing data. */
-} at_kbd_t;
-
-extern int at_kbd_init(at_kbd_t *, ddf_dev_t *);
-
-#endif
-
-/**
- * @}
- */
Index: uspace/drv/char/atkbd/atkbd.ma
===================================================================
--- uspace/drv/char/atkbd/atkbd.ma	(revision 19397becd25f896f19a94f9f6867540d2c59da3d)
+++ 	(revision )
@@ -1,1 +1,0 @@
-100 char/atkbd
Index: uspace/drv/char/atkbd/main.c
===================================================================
--- uspace/drv/char/atkbd/main.c	(revision 19397becd25f896f19a94f9f6867540d2c59da3d)
+++ 	(revision )
@@ -1,112 +1,0 @@
-/*
- * Copyright (c) 2011 Jan Vesely
- * 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 drvkbd
- * @{
- */
-/** @file
- * @brief AT keyboard driver
- */
-
-#include <inttypes.h>
-#include <ddf/driver.h>
-#include <device/hw_res_parsed.h>
-#include <errno.h>
-#include <str_error.h>
-#include <ddf/log.h>
-#include <stdio.h>
-
-#include "atkbd.h"
-
-#define NAME "atkbd"
-
-static int at_kbd_add(ddf_dev_t *device);
-
-/** DDF driver ops. */
-static driver_ops_t kbd_driver_ops = {
-	.dev_add = at_kbd_add,
-};
-
-/** DDF driver structure. */
-static driver_t kbd_driver = {
-	.name = NAME,
-	.driver_ops = &kbd_driver_ops
-};
-
-/** Initialize global driver structures (NONE).
- *
- * Driver debug level is set here.
- *
- * @param[in] argc Nmber of arguments in argv vector (ignored).
- * @param[in] argv Cmdline argument vector (ignored).
- *
- * @return Error code.
- *
- */
-int main(int argc, char *argv[])
-{
-	printf(NAME ": HelenOS AT keyboard driver.\n");
-	ddf_log_init(NAME);
-	return ddf_driver_main(&kbd_driver);
-}
-
-/** Initialize a new ddf driver instance of the driver
- *
- * @param[in] device DDF instance of the device to initialize.
- *
- * @return Error code.
- *
- */
-static int at_kbd_add(ddf_dev_t *device)
-{
-	int rc;
-
-	if (!device)
-		return EINVAL;
-
-	at_kbd_t *kbd = ddf_dev_data_alloc(device, sizeof(at_kbd_t));
-	if (kbd == NULL) {
-		ddf_msg(LVL_ERROR, "Failed to allocate AT_KBD driver instance.");
-		return ENOMEM;
-	}
-
-	rc = at_kbd_init(kbd, device);
-	if (rc != EOK) {
-		ddf_msg(LVL_ERROR, "Failed to initialize AT_KBD driver: %s.",
-		    str_error(rc));
-    		return rc;
-	}
-
-	ddf_msg(LVL_NOTE, "Controlling '%s' (%" PRIun ").",
-	    ddf_dev_get_name(device), ddf_dev_get_handle(device));
-	return EOK;
-}
-
-/**
- * @}
- */
Index: uspace/drv/char/ps2mouse/Makefile
===================================================================
--- uspace/drv/char/ps2mouse/Makefile	(revision 19397becd25f896f19a94f9f6867540d2c59da3d)
+++ 	(revision )
@@ -1,37 +1,0 @@
-#
-# Copyright (c) 2011 Jan Vesely
-# 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.
-#
-
-USPACE_PREFIX = ../../..
-LIBS = drv
-BINARY = ps2mouse
-
-SOURCES = \
-	main.c \
-	ps2mouse.c
-
-include $(USPACE_PREFIX)/Makefile.common
Index: uspace/drv/char/ps2mouse/main.c
===================================================================
--- uspace/drv/char/ps2mouse/main.c	(revision 19397becd25f896f19a94f9f6867540d2c59da3d)
+++ 	(revision )
@@ -1,106 +1,0 @@
-/*
- * Copyright (c) 2011 Jan Vesely
- * 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 drvmouse
- * @{
- */
-/** @file
- * @brief ps/2 mouse driver
- */
-
-#include <inttypes.h>
-#include <ddf/driver.h>
-#include <device/hw_res_parsed.h>
-#include <errno.h>
-#include <str_error.h>
-#include <ddf/log.h>
-#include <stdio.h>
-
-#include "ps2mouse.h"
-
-#define NAME "ps2mouse"
-
-static int mouse_add(ddf_dev_t *device);
-
-/** DDF driver ops. */
-static driver_ops_t mouse_driver_ops = {
-	.dev_add = mouse_add,
-};
-
-/** DDF driver structure. */
-static driver_t mouse_driver = {
-	.name = NAME,
-	.driver_ops = &mouse_driver_ops
-};
-
-/** Initialize global driver structures (NONE).
- *
- * @param[in] argc Nmber of arguments in argv vector (ignored).
- * @param[in] argv Cmdline argument vector (ignored).
- * @return Error code.
- *
- * Driver debug level is set here.
- */
-int main(int argc, char *argv[])
-{
-	printf(NAME ": HelenOS ps/2 mouse driver.\n");
-	ddf_log_init(NAME);
-	return ddf_driver_main(&mouse_driver);
-}
-
-/** Initialize a new ddf driver instance
- *
- * @param[in] device DDF instance of the device to initialize.
- * @return Error code.
- */
-static int mouse_add(ddf_dev_t *device)
-{
-	int rc;
-
-	if (!device)
-		return EINVAL;
-
-	ps2_mouse_t *mouse = ddf_dev_data_alloc(device, sizeof(ps2_mouse_t));
-	if (mouse == NULL) {
-		ddf_msg(LVL_ERROR, "Failed to allocate mouse driver instance.");
-		return ENOMEM;
-	}
-
-	rc = ps2_mouse_init(mouse, device);
-	if (rc != EOK) {
-		ddf_msg(LVL_ERROR, "Failed to initialize mouse driver: %s.",
-		    str_error(rc));
-		return rc;
-	}
-
-	ddf_msg(LVL_NOTE, "Controlling '%s' (%" PRIun ").",
-	    ddf_dev_get_name(device), ddf_dev_get_handle(device));
-	return EOK;
-}
-/**
- * @}
- */
Index: uspace/drv/char/ps2mouse/ps2mouse.c
===================================================================
--- uspace/drv/char/ps2mouse/ps2mouse.c	(revision 19397becd25f896f19a94f9f6867540d2c59da3d)
+++ 	(revision )
@@ -1,387 +1,0 @@
-/*
- * Copyright (c) 2011 Jan Vesely
- * 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 drvmouse
- * @{
- */
-/** @file
- * @brief ps2 mouse driver.
- */
-
-#include <stdbool.h>
-#include <errno.h>
-#include <ddf/log.h>
-#include <io/keycode.h>
-#include <io/chardev.h>
-#include <io/console.h>
-#include <ipc/mouseev.h>
-#include <abi/ipc/methods.h>
-
-#include "ps2mouse.h"
-
-#define PS2_MOUSE_GET_DEVICE_ID   0xf2
-#define PS2_MOUSE_SET_SAMPLE_RATE   0xf3
-#define PS2_MOUSE_ENABLE_DATA_REPORT   0xf4
-#define PS2_MOUSE_ACK   0xfa
-
-#define PS2_BUFSIZE 3
-#define INTELLIMOUSE_BUFSIZE 4
-
-#define Z_SIGN (1 << 3) /* 4th byte */
-#define X_SIGN (1 << 4) /* 1st byte */
-#define Y_SIGN (1 << 5) /* 1st byte */
-#define X_OVERFLOW (1 << 6) /* 1st byte */
-#define Y_OVERFLOW (1 << 7) /* 1st byte */
-
-#define BUTTON_LEFT   0
-#define BUTTON_RIGHT   1
-#define BUTTON_MIDDLE   2
-#define PS2_BUTTON_COUNT   3
-
-#define INTELLIMOUSE_ALWAYS_ZERO (0xc0)
-#define INTELLIMOUSE_BUTTON_4 (1 << 4) /* 4th byte */
-#define INTELLIMOUSE_BUTTON_5 (1 << 5) /* 4th byte */
-#define INTELLIMOUSE_BUTTON_COUNT 5
-
-#define PS2_BUTTON_MASK(button) (1 << button)
-
-#define MOUSE_READ_BYTE_TEST(sess, value_) \
-do { \
-	uint8_t value = (value_); \
-	uint8_t data = 0; \
-	const ssize_t size = chardev_read(sess, &data, 1); \
-	if (size != 1) { \
-		ddf_msg(LVL_ERROR, "Failed reading byte: %zd)", size);\
-		return size < 0 ? size : EIO; \
-	} \
-	if (data != value) { \
-		ddf_msg(LVL_DEBUG, "Failed testing byte: got %hhx vs. %hhx)", \
-		    data, value); \
-		return EIO; \
-	} \
-} while (0)
-
-#define MOUSE_WRITE_BYTE(sess, value_) \
-do { \
-	uint8_t value = (value_); \
-	uint8_t data = (value); \
-	const ssize_t size = chardev_write(sess, &data, 1); \
-	if (size < 0 ) { \
-		ddf_msg(LVL_ERROR, "Failed writing byte: %hhx", value); \
-		return size; \
-	} \
-} while (0)
-
-static int polling_ps2(void *);
-static int polling_intellimouse(void *);
-static int probe_intellimouse(async_exch_t *, bool);
-static void default_connection_handler(ddf_fun_t *, ipc_callid_t, ipc_call_t *);
-
-/** ps/2 mouse driver ops. */
-static ddf_dev_ops_t mouse_ops = {
-	.default_handler = default_connection_handler
-};
-
-/** Initialize mouse driver structure.
- * @param kbd Mouse driver structure to initialize.
- * @param dev DDF device structure.
- *
- * Connects to parent, creates keyboard function, starts polling fibril.
- */
-int ps2_mouse_init(ps2_mouse_t *mouse, ddf_dev_t *dev)
-{
-	mouse->client_sess = NULL;
-	mouse->parent_sess = ddf_dev_parent_sess_get(dev);
-	if (!mouse->parent_sess)
-		return ENOMEM;
-
-	mouse->mouse_fun = ddf_fun_create(dev, fun_exposed, "mouse");
-	if (!mouse->mouse_fun) {
-		return ENOMEM;
-	}
-	ddf_fun_set_ops(mouse->mouse_fun, &mouse_ops);
-
-	int ret = ddf_fun_bind(mouse->mouse_fun);
-	if (ret != EOK) {
-		ddf_fun_destroy(mouse->mouse_fun);
-		return ENOMEM;
-	}
-
-	ret = ddf_fun_add_to_category(mouse->mouse_fun, "mouse");
-	if (ret != EOK) {
-		ddf_fun_unbind(mouse->mouse_fun);
-		ddf_fun_destroy(mouse->mouse_fun);
-		return ENOMEM;
-	}
-	/* Probe IntelliMouse extensions. */
-	int (*polling_f)(void*) = polling_ps2;
-	async_exch_t *exch = async_exchange_begin(mouse->parent_sess);
-	if (probe_intellimouse(exch, false) == EOK) {
-		ddf_msg(LVL_NOTE, "Enabled IntelliMouse extensions");
-		polling_f = polling_intellimouse;
-		if (probe_intellimouse(exch, true) == EOK)
-			ddf_msg(LVL_NOTE, "Enabled 4th and 5th button.");
-	}
-	/* Enable mouse data reporting. */
-	uint8_t report = PS2_MOUSE_ENABLE_DATA_REPORT;
-	ssize_t size = chardev_write(exch, &report, 1);
-	if (size != 1) {
-		ddf_msg(LVL_ERROR, "Failed to enable data reporting.");
-		async_exchange_end(exch);
-		ddf_fun_unbind(mouse->mouse_fun);
-		ddf_fun_destroy(mouse->mouse_fun);
-		return EIO;
-	}
-
-	size = chardev_read(exch, &report, 1);
-	async_exchange_end(exch);
-	if (size != 1 || report != PS2_MOUSE_ACK) {
-		ddf_msg(LVL_ERROR, "Failed to confirm data reporting: %hhx.",
-		    report);
-		ddf_fun_unbind(mouse->mouse_fun);
-		ddf_fun_destroy(mouse->mouse_fun);
-		return EIO;
-	}
-
-	mouse->polling_fibril = fibril_create(polling_f, mouse);
-	if (!mouse->polling_fibril) {
-		ddf_fun_unbind(mouse->mouse_fun);
-		ddf_fun_destroy(mouse->mouse_fun);
-		return ENOMEM;
-	}
-	fibril_add_ready(mouse->polling_fibril);
-	return EOK;
-}
-
-/** Get data and parse ps2 protocol packets.
- * @param arg Pointer to ps2_mouse_t structure.
- * @return Never.
- */
-int polling_ps2(void *arg)
-{
-	assert(arg);
-	const ps2_mouse_t *mouse = arg;
-
-	assert(mouse->parent_sess);
-	bool buttons[PS2_BUTTON_COUNT] = {};
-	async_exch_t *parent_exch = async_exchange_begin(mouse->parent_sess);
-	while (1) {
-
-		uint8_t packet[PS2_BUFSIZE] = {};
-		const ssize_t size =
-		    chardev_read(parent_exch, packet, PS2_BUFSIZE);
-
-		if (size != PS2_BUFSIZE) {
-			ddf_msg(LVL_WARN, "Incorrect packet size: %zd.", size);
-			continue;
-		}
-		ddf_msg(LVL_DEBUG2, "Got packet: %hhx:%hhx:%hhx.",
-		    packet[0], packet[1], packet[2]);
-
-		async_exch_t *exch =
-		    async_exchange_begin(mouse->client_sess);
-		if (!exch) {
-			ddf_msg(LVL_ERROR,
-			    "Failed creating exchange.");
-			continue;
-		}
-
-		/* Buttons */
-		for (unsigned i = 0; i < PS2_BUTTON_COUNT; ++i) {
-			const bool status = (packet[0] & PS2_BUTTON_MASK(i));
-			if (buttons[i] != status) {
-				buttons[i] = status;
-				async_msg_2(exch, MOUSEEV_BUTTON_EVENT, i + 1,
-				    buttons[i]);
-			}
-		}
-
-		/* Movement */
-		const int16_t move_x =
-		    ((packet[0] & X_SIGN) ? 0xff00 : 0) | packet[1];
-		const int16_t move_y =
-		    (((packet[0] & Y_SIGN) ? 0xff00 : 0) | packet[2]);
-		//TODO: Consider overflow bit
-		if (move_x != 0 || move_y != 0) {
-			async_msg_2(exch, MOUSEEV_MOVE_EVENT, move_x, -move_y);
-		}
-		async_exchange_end(exch);
-	}
-	async_exchange_end(parent_exch);
-}
-
-/** Get data and parse ps2 protocol with IntelliMouse extension packets.
- * @param arg Pointer to ps2_mouse_t structure.
- * @return Never.
- */
-static int polling_intellimouse(void *arg)
-{
-	assert(arg);
-	const ps2_mouse_t *mouse = arg;
-
-	assert(mouse->parent_sess);
-	bool buttons[INTELLIMOUSE_BUTTON_COUNT] = {};
-	async_exch_t *parent_exch = NULL;
-	while (1) {
-		if (!parent_exch)
-			parent_exch = async_exchange_begin(mouse->parent_sess);
-
-		uint8_t packet[INTELLIMOUSE_BUFSIZE] = {};
-		const ssize_t size = chardev_read(
-		    parent_exch, packet, INTELLIMOUSE_BUFSIZE);
-
-		if (size != INTELLIMOUSE_BUFSIZE) {
-			ddf_msg(LVL_WARN, "Incorrect packet size: %zd.", size);
-			continue;
-		}
-		ddf_msg(LVL_DEBUG2, "Got packet: %hhx:%hhx:%hhx:%hhx.",
-		    packet[0], packet[1], packet[2], packet[3]);
-
-		async_exch_t *exch =
-		    async_exchange_begin(mouse->client_sess);
-		if (!exch) {
-			ddf_msg(LVL_ERROR,
-			    "Failed creating exchange.");
-			continue;
-		}
-
-		/* Buttons */
-		/* NOTE: Parsing 4th and 5th button works even if this extension
-		 * is not supported and whole 4th byte should be interpreted
-		 * as Z-axis movement. the upper 4 bits are just a sign
-		 * extension then. + sign is interpreted as "button up"
-		 * (i.e no change since that is the default) and - sign fails
-		 * the "imb" condition. Thus 4th and 5th buttons are never
-		 * down on wheel only extension. */
-		const bool imb = (packet[3] & INTELLIMOUSE_ALWAYS_ZERO) == 0;
-		const bool status[] = {
-			[0] = packet[0] & PS2_BUTTON_MASK(0),
-			[1] = packet[0] & PS2_BUTTON_MASK(1),
-			[2] = packet[0] & PS2_BUTTON_MASK(2),
-			[3] = (packet[3] & INTELLIMOUSE_BUTTON_4) && imb,
-			[4] = (packet[3] & INTELLIMOUSE_BUTTON_5) && imb,
-		};
-		for (unsigned i = 0; i < INTELLIMOUSE_BUTTON_COUNT; ++i) {
-			if (buttons[i] != status[i]) {
-				buttons[i] = status[i];
-				async_msg_2(exch, MOUSEEV_BUTTON_EVENT, i + 1,
-				    buttons[i]);
-			}
-		}
-
-		/* Movement */
-		const int16_t move_x =
-		    ((packet[0] & X_SIGN) ? 0xff00 : 0) | packet[1];
-		const int16_t move_y =
-		    (((packet[0] & Y_SIGN) ? 0xff00 : 0) | packet[2]);
-		const int8_t move_z =
-		    (((packet[3] & Z_SIGN) ? 0xf0 : 0) | (packet[3] & 0xf));
-		ddf_msg(LVL_DEBUG2, "Parsed moves: %d:%d:%hhd", move_x, move_y,
-		    move_z);
-		//TODO: Consider overflow bit
-		if (move_x != 0 || move_y != 0 || move_z != 0) {
-			async_msg_3(exch, MOUSEEV_MOVE_EVENT,
-			    move_x, -move_y, -move_z);
-		}
-		async_exchange_end(exch);
-	}
-	async_exchange_end(parent_exch);
-}
-
-/** Send magic sequence to initialize IntelliMouse extensions.
- * @param exch IPC exchange to the parent device.
- * @param buttons True selects magic sequence for 4th and 5th button,
- * false selects wheel support magic sequence.
- * See http://www.computer-engineering.org/ps2mouse/ for details.
- */
-static int probe_intellimouse(async_exch_t *exch, bool buttons)
-{
-	assert(exch);
-
-	MOUSE_WRITE_BYTE(exch, PS2_MOUSE_SET_SAMPLE_RATE);
-	MOUSE_READ_BYTE_TEST(exch, PS2_MOUSE_ACK);
-	MOUSE_WRITE_BYTE(exch, 200);
-	MOUSE_READ_BYTE_TEST(exch, PS2_MOUSE_ACK);
-
-	MOUSE_WRITE_BYTE(exch, PS2_MOUSE_SET_SAMPLE_RATE);
-	MOUSE_READ_BYTE_TEST(exch, PS2_MOUSE_ACK);
-	MOUSE_WRITE_BYTE(exch, buttons ? 200 : 100);
-	MOUSE_READ_BYTE_TEST(exch, PS2_MOUSE_ACK);
-
-	MOUSE_WRITE_BYTE(exch, PS2_MOUSE_SET_SAMPLE_RATE);
-	MOUSE_READ_BYTE_TEST(exch, PS2_MOUSE_ACK);
-	MOUSE_WRITE_BYTE(exch, 80);
-	MOUSE_READ_BYTE_TEST(exch, PS2_MOUSE_ACK);
-
-	MOUSE_WRITE_BYTE(exch, PS2_MOUSE_GET_DEVICE_ID);
-	MOUSE_READ_BYTE_TEST(exch, PS2_MOUSE_ACK);
-	MOUSE_READ_BYTE_TEST(exch, buttons ? 4 : 3);
-
-	return EOK;
-}
-
-/** Default handler for IPC methods not handled by DDF.
- *
- * @param fun Device function handling the call.
- * @param icallid Call id.
- * @param icall Call data.
- */
-void default_connection_handler(ddf_fun_t *fun,
-    ipc_callid_t icallid, ipc_call_t *icall)
-{
-	const sysarg_t method = IPC_GET_IMETHOD(*icall);
-	ps2_mouse_t *mouse = ddf_dev_data_get(ddf_fun_get_dev(fun));
-
-	switch (method) {
-	/* This might be ugly but async_callback_receive_start makes no
-	 * difference for incorrect call and malloc failure. */
-	case IPC_M_CONNECT_TO_ME: {
-		async_sess_t *sess =
-		    async_callback_receive_start(EXCHANGE_SERIALIZE, icall);
-		/* Probably ENOMEM error, try again. */
-		if (sess == NULL) {
-			ddf_msg(LVL_WARN,
-			    "Failed creating client callback session");
-			async_answer_0(icallid, EAGAIN);
-			break;
-		}
-		if (mouse->client_sess == NULL) {
-			mouse->client_sess = sess;
-			ddf_msg(LVL_DEBUG, "Set client session");
-			async_answer_0(icallid, EOK);
-		} else {
-			ddf_msg(LVL_ERROR, "Client session already set");
-			async_answer_0(icallid, ELIMIT);
-		}
-		break;
-	}
-	default:
-		ddf_msg(LVL_ERROR, "Unknown method: %d.", (int)method);
-		async_answer_0(icallid, EINVAL);
-		break;
-	}
-}
Index: uspace/drv/char/ps2mouse/ps2mouse.h
===================================================================
--- uspace/drv/char/ps2mouse/ps2mouse.h	(revision 19397becd25f896f19a94f9f6867540d2c59da3d)
+++ 	(revision )
@@ -1,54 +1,0 @@
-/*
- * Copyright (c) 2011 Jan Vesely
- * 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 drvmouse
- * @{
- */
-/** @file
- * @brief ps/2 mouse driver.
- */
-
-#ifndef _PS2MOUSE_H_
-#define _PS2MOUSE_H_
-
-#include <ddf/driver.h>
-#include <fibril.h>
-
-/** PS/2 mouse driver structure. */
-typedef struct {
-	ddf_fun_t *mouse_fun;      /**< Mouse function. */
-	async_sess_t *parent_sess; /**< Connection to device providing data. */
-	async_sess_t *client_sess;  /**< Callback connection to client. */
-	fid_t polling_fibril;      /**< Fibril retrieving an parsing data. */
-} ps2_mouse_t;
-
-int ps2_mouse_init(ps2_mouse_t *, ddf_dev_t *);
-
-#endif
-/**
- * @}
- */
Index: uspace/drv/char/ps2mouse/ps2mouse.ma
===================================================================
--- uspace/drv/char/ps2mouse/ps2mouse.ma	(revision 19397becd25f896f19a94f9f6867540d2c59da3d)
+++ 	(revision )
@@ -1,1 +1,0 @@
-100 char/ps2mouse
Index: uspace/drv/char/xtkbd/Makefile
===================================================================
--- uspace/drv/char/xtkbd/Makefile	(revision 19397becd25f896f19a94f9f6867540d2c59da3d)
+++ 	(revision )
@@ -1,37 +1,0 @@
-#
-# Copyright (c) 2011 Jan Vesely
-# 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.
-#
-
-USPACE_PREFIX = ../../..
-LIBS = drv
-BINARY = xtkbd
-
-SOURCES = \
-	main.c \
-	xtkbd.c
-
-include $(USPACE_PREFIX)/Makefile.common
Index: uspace/drv/char/xtkbd/main.c
===================================================================
--- uspace/drv/char/xtkbd/main.c	(revision 19397becd25f896f19a94f9f6867540d2c59da3d)
+++ 	(revision )
@@ -1,112 +1,0 @@
-/*
- * Copyright (c) 2011 Jan Vesely
- * 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 drvkbd
- * @{
- */
-/** @file
- * @brief XT keyboard driver
- */
-
-#include <inttypes.h>
-#include <ddf/driver.h>
-#include <device/hw_res_parsed.h>
-#include <errno.h>
-#include <str_error.h>
-#include <ddf/log.h>
-#include <stdio.h>
-
-#include "xtkbd.h"
-
-#define NAME "xtkbd"
-
-static int xt_kbd_add(ddf_dev_t *device);
-
-/** DDF driver ops. */
-static driver_ops_t kbd_driver_ops = {
-	.dev_add = xt_kbd_add,
-};
-
-/** DDF driver structure. */
-static driver_t kbd_driver = {
-	.name = NAME,
-	.driver_ops = &kbd_driver_ops
-};
-
-/** Initialize global driver structures (NONE).
- *
- * Driver debug level is set here.
- *
- * @param[in] argc Nmber of arguments in argv vector (ignored).
- * @param[in] argv Cmdline argument vector (ignored).
- *
- * @return Error code.
- *
- */
-int main(int argc, char *argv[])
-{
-	printf(NAME ": HelenOS XT keyboard driver.\n");
-	ddf_log_init(NAME);
-	return ddf_driver_main(&kbd_driver);
-}
-
-/** Initialize a new ddf driver instance of the driver
- *
- * @param[in] device DDF instance of the device to initialize.
- *
- * @return Error code.
- *
- */
-static int xt_kbd_add(ddf_dev_t *device)
-{
-	int rc;
-
-	if (!device)
-		return EINVAL;
-
-	xt_kbd_t *kbd = ddf_dev_data_alloc(device, sizeof(xt_kbd_t));
-	if (kbd == NULL) {
-		ddf_msg(LVL_ERROR, "Failed to allocate XT/KBD driver instance.");
-		return ENOMEM;
-	}
-
-	rc = xt_kbd_init(kbd, device);
-	if (rc != EOK) {
-		ddf_msg(LVL_ERROR, "Failed to initialize XT_KBD driver: %s.",
-		    str_error(rc));
-    		return rc;
-	}
-
-	ddf_msg(LVL_NOTE, "Controlling '%s' (%" PRIun ").",
-	    ddf_dev_get_name(device), ddf_dev_get_handle(device));
-	return EOK;
-}
-
-/**
- * @}
- */
Index: uspace/drv/char/xtkbd/xtkbd.c
===================================================================
--- uspace/drv/char/xtkbd/xtkbd.c	(revision 19397becd25f896f19a94f9f6867540d2c59da3d)
+++ 	(revision )
@@ -1,460 +1,0 @@
-/*
- * Copyright (c) 2011 Jan Vesely
- * 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 drvkbd
- * @{
- */
-/** @file
- * @brief XT keyboard driver
- */
-
-#include <errno.h>
-#include <ddf/log.h>
-#include <io/keycode.h>
-#include <io/chardev.h>
-#include <io/console.h>
-#include <ipc/kbdev.h>
-#include <abi/ipc/methods.h>
-#include "xtkbd.h"
-
-/** Scancode set 1 table. */
-static const unsigned int scanmap_simple[] = {
-	[0x29] = KC_BACKTICK,
-	
-	[0x02] = KC_1,
-	[0x03] = KC_2,
-	[0x04] = KC_3,
-	[0x05] = KC_4,
-	[0x06] = KC_5,
-	[0x07] = KC_6,
-	[0x08] = KC_7,
-	[0x09] = KC_8,
-	[0x0a] = KC_9,
-	[0x0b] = KC_0,
-	
-	[0x0c] = KC_MINUS,
-	[0x0d] = KC_EQUALS,
-	[0x0e] = KC_BACKSPACE,
-	
-	[0x0f] = KC_TAB,
-	
-	[0x10] = KC_Q,
-	[0x11] = KC_W,
-	[0x12] = KC_E,
-	[0x13] = KC_R,
-	[0x14] = KC_T,
-	[0x15] = KC_Y,
-	[0x16] = KC_U,
-	[0x17] = KC_I,
-	[0x18] = KC_O,
-	[0x19] = KC_P,
-	
-	[0x1a] = KC_LBRACKET,
-	[0x1b] = KC_RBRACKET,
-	
-	[0x3a] = KC_CAPS_LOCK,
-	
-	[0x1e] = KC_A,
-	[0x1f] = KC_S,
-	[0x20] = KC_D,
-	[0x21] = KC_F,
-	[0x22] = KC_G,
-	[0x23] = KC_H,
-	[0x24] = KC_J,
-	[0x25] = KC_K,
-	[0x26] = KC_L,
-	
-	[0x27] = KC_SEMICOLON,
-	[0x28] = KC_QUOTE,
-	[0x2b] = KC_BACKSLASH,
-	
-	[0x2a] = KC_LSHIFT,
-	
-	[0x2c] = KC_Z,
-	[0x2d] = KC_X,
-	[0x2e] = KC_C,
-	[0x2f] = KC_V,
-	[0x30] = KC_B,
-	[0x31] = KC_N,
-	[0x32] = KC_M,
-	
-	[0x33] = KC_COMMA,
-	[0x34] = KC_PERIOD,
-	[0x35] = KC_SLASH,
-	
-	[0x36] = KC_RSHIFT,
-	
-	[0x1d] = KC_LCTRL,
-	[0x38] = KC_LALT,
-	[0x39] = KC_SPACE,
-	
-	[0x01] = KC_ESCAPE,
-	
-	[0x3b] = KC_F1,
-	[0x3c] = KC_F2,
-	[0x3d] = KC_F3,
-	[0x3e] = KC_F4,
-	[0x3f] = KC_F5,
-	[0x40] = KC_F6,
-	[0x41] = KC_F7,
-	
-	[0x42] = KC_F8,
-	[0x43] = KC_F9,
-	[0x44] = KC_F10,
-	
-	[0x57] = KC_F11,
-	[0x58] = KC_F12,
-	
-	[0x46] = KC_SCROLL_LOCK,
-	
-	[0x1c] = KC_ENTER,
-	
-	[0x45] = KC_NUM_LOCK,
-	[0x37] = KC_NTIMES,
-	[0x4a] = KC_NMINUS,
-	[0x4e] = KC_NPLUS,
-	[0x47] = KC_N7,
-	[0x48] = KC_N8,
-	[0x49] = KC_N9,
-	[0x4b] = KC_N4,
-	[0x4c] = KC_N5,
-	[0x4d] = KC_N6,
-	[0x4f] = KC_N1,
-	[0x50] = KC_N2,
-	[0x51] = KC_N3,
-	[0x52] = KC_N0,
-	[0x53] = KC_NPERIOD
-};
-
-#define KBD_ACK  0xfa
-#define KBD_RESEND  0xfe
-#define KBD_SCANCODE_SET_EXTENDED  0xe0
-#define KBD_SCANCODE_SET_EXTENDED_SPECIAL  0xe1
-
-/** Scancode set 1 extended codes table */
-static const unsigned int scanmap_e0[] = {
-	[0x38] = KC_RALT,
-	[0x1d] = KC_RCTRL,
-	
-	[0x37] = KC_SYSREQ,
-	
-	[0x52] = KC_INSERT,
-	[0x47] = KC_HOME,
-	[0x49] = KC_PAGE_UP,
-	
-	[0x53] = KC_DELETE,
-	[0x4f] = KC_END,
-	[0x51] = KC_PAGE_DOWN,
-	
-	[0x48] = KC_UP,
-	[0x4b] = KC_LEFT,
-	[0x50] = KC_DOWN,
-	[0x4d] = KC_RIGHT,
-	
-	[0x35] = KC_NSLASH,
-	[0x1c] = KC_NENTER
-};
-
-#define KBD_CMD_SET_LEDS  0xed
-
-enum led_indicators {
-	LI_SCROLL = 0x01,
-	LI_NUM    = 0x02,
-	LI_CAPS   = 0x04
-};
-
-static void push_event(async_sess_t *sess, kbd_event_type_t type,
-    unsigned int key)
-{
-	async_exch_t *exch = async_exchange_begin(sess);
-	async_msg_4(exch, KBDEV_EVENT, type, key, 0, 0);
-	async_exchange_end(exch);
-}
-
-/** Get data and parse scancodes.
- *
- * @param arg Pointer to xt_kbd_t structure.
- *
- * @return EIO on error.
- *
- */
-static int polling(void *arg)
-{
-	const xt_kbd_t *kbd = arg;
-	
-	assert(kbd);
-	assert(kbd->parent_sess);
-	
-	async_exch_t *parent_exch = async_exchange_begin(kbd->parent_sess);
-	
-	while (true) {
-		if (!parent_exch)
-			parent_exch = async_exchange_begin(kbd->parent_sess);
-		
-		const unsigned int *map = scanmap_simple;
-		size_t map_size = sizeof(scanmap_simple) / sizeof(unsigned int);
-		
-		uint8_t code = 0;
-		ssize_t size = chardev_read(parent_exch, &code, 1);
-		if (size != 1)
-			return EIO;
-		
-		/* Ignore AT command reply */
-		if ((code == KBD_ACK) || (code == KBD_RESEND))
-			continue;
-		
-		/* Extended set */
-		if (code == KBD_SCANCODE_SET_EXTENDED) {
-			map = scanmap_e0;
-			map_size = sizeof(scanmap_e0) / sizeof(unsigned int);
-			
-			size = chardev_read(parent_exch, &code, 1);
-			if (size != 1)
-				return EIO;
-			
-			/* Handle really special keys */
-			
-			if (code == 0x2a) {  /* Print Screen */
-				size = chardev_read(parent_exch, &code, 1);
-				if (size != 1)
-					return EIO;
-				
-				if (code != 0xe0)
-					continue;
-				
-				size = chardev_read(parent_exch, &code, 1);
-				if (size != 1)
-					return EIO;
-				
-				if (code == 0x37)
-					push_event(kbd->client_sess, KEY_PRESS, KC_PRTSCR);
-				
-				continue;
-			}
-			
-			if (code == 0x46) {  /* Break */
-				size = chardev_read(parent_exch, &code, 1);
-				if (size != 1)
-					return EIO;
-				
-				if (code != 0xe0)
-					continue;
-				
-				size = chardev_read(parent_exch, &code, 1);
-				if (size != 1)
-					return EIO;
-				
-				if (code == 0xc6)
-					push_event(kbd->client_sess, KEY_PRESS, KC_BREAK);
-				
-				continue;
-			}
-		}
-		
-		/* Extended special set */
-		if (code == KBD_SCANCODE_SET_EXTENDED_SPECIAL) {
-			size = chardev_read(parent_exch, &code, 1);
-			if (size != 1)
-				return EIO;
-			
-			if (code != 0x1d)
-				continue;
-			
-			size = chardev_read(parent_exch, &code, 1);
-			if (size != 1)
-				return EIO;
-			
-			if (code != 0x45)
-				continue;
-			
-			size = chardev_read(parent_exch, &code, 1);
-			if (size != 1)
-				return EIO;
-			
-			if (code != 0xe1)
-				continue;
-			
-			size = chardev_read(parent_exch, &code, 1);
-			if (size != 1)
-				return EIO;
-			
-			if (code != 0x9d)
-				continue;
-			
-			size = chardev_read(parent_exch, &code, 1);
-			if (size != 1)
-				return EIO;
-			
-			if (code == 0xc5)
-				push_event(kbd->client_sess, KEY_PRESS, KC_PAUSE);
-			
-			continue;
-		}
-		
-		/* Bit 7 indicates press/release */
-		const kbd_event_type_t type =
-		    (code & 0x80) ? KEY_RELEASE : KEY_PRESS;
-		code &= ~0x80;
-		
-		const unsigned int key = (code < map_size) ? map[code] : 0;
-		
-		if (key != 0)
-			push_event(kbd->client_sess, type, key);
-		else
-			ddf_msg(LVL_WARN, "Unknown scancode: %hhx", code);
-	}
-}
-
-/** Default handler for IPC methods not handled by DDF.
- *
- * @param fun     Device function handling the call.
- * @param icallid Call id.
- * @param icall   Call data.
- *
- */
-static void default_connection_handler(ddf_fun_t *fun,
-    ipc_callid_t icallid, ipc_call_t *icall)
-{
-	const sysarg_t method = IPC_GET_IMETHOD(*icall);
-	xt_kbd_t *kbd = ddf_dev_data_get(ddf_fun_get_dev(fun));
-
-	switch (method) {
-	case KBDEV_SET_IND: {
-		/*
-		 * XT keyboards do not support setting mods,
-		 * assume AT keyboard with Scan Code Set 1.
-		 */
-		const unsigned mods = IPC_GET_ARG1(*icall);
-		const uint8_t status = 0 |
-		    ((mods & KM_CAPS_LOCK) ? LI_CAPS : 0) |
-		    ((mods & KM_NUM_LOCK) ? LI_NUM : 0) |
-		    ((mods & KM_SCROLL_LOCK) ? LI_SCROLL : 0);
-		uint8_t cmds[] = { KBD_CMD_SET_LEDS, status };
-		
-		async_exch_t *exch = async_exchange_begin(kbd->parent_sess);
-		const ssize_t size = chardev_write(exch, cmds, sizeof(cmds));
-		async_exchange_end(exch);
-		
-		async_answer_0(icallid, size < 0 ? size : EOK);
-		break;
-	}
-	/*
-	 * This might be ugly but async_callback_receive_start makes no
-	 * difference for incorrect call and malloc failure.
-	 */
-	case IPC_M_CONNECT_TO_ME: {
-		async_sess_t *sess =
-		    async_callback_receive_start(EXCHANGE_SERIALIZE, icall);
-		
-		/* Probably ENOMEM error, try again. */
-		if (sess == NULL) {
-			ddf_msg(LVL_WARN,
-			    "Failed creating callback session");
-			async_answer_0(icallid, EAGAIN);
-			break;
-		}
-		
-		if (kbd->client_sess == NULL) {
-			kbd->client_sess = sess;
-			ddf_msg(LVL_DEBUG, "Set client session");
-			async_answer_0(icallid, EOK);
-		} else {
-			ddf_msg(LVL_ERROR, "Client session already set");
-			async_answer_0(icallid, ELIMIT);
-		}
-		
-		break;
-	}
-	default:
-		ddf_msg(LVL_ERROR, "Unknown method: %d.", (int)method);
-		async_answer_0(icallid, EINVAL);
-		break;
-	}
-}
-
-/** Keyboard function ops. */
-static ddf_dev_ops_t kbd_ops = {
-	.default_handler = default_connection_handler
-};
-
-/** Initialize keyboard driver structure.
- *
- * @param kbd Keyboard driver structure to initialize.
- * @param dev DDF device structure.
- *
- * Connects to parent, creates keyboard function, starts polling fibril.
- *
- */
-int xt_kbd_init(xt_kbd_t *kbd, ddf_dev_t *dev)
-{
-	assert(kbd);
-	assert(dev);
-	
-	kbd->client_sess = NULL;
-	kbd->parent_sess = ddf_dev_parent_sess_get(dev);
-	
-	if (!kbd->parent_sess) {
-		ddf_msg(LVL_ERROR, "Failed creating parent session.");
-		return EIO;
-	}
-	
-	kbd->kbd_fun = ddf_fun_create(dev, fun_exposed, "kbd");
-	if (!kbd->kbd_fun) {
-		ddf_msg(LVL_ERROR, "Failed creating function 'kbd'.");
-		return ENOMEM;
-	}
-	
-	ddf_fun_set_ops(kbd->kbd_fun, &kbd_ops);
-	
-	int ret = ddf_fun_bind(kbd->kbd_fun);
-	if (ret != EOK) {
-		ddf_msg(LVL_ERROR, "Failed binding function 'kbd'.");
-		ddf_fun_destroy(kbd->kbd_fun);
-		return EEXIST;
-	}
-	
-	ret = ddf_fun_add_to_category(kbd->kbd_fun, "keyboard");
-	if (ret != EOK) {
-		ddf_msg(LVL_ERROR, "Failed adding function 'kbd' to category "
-		    "'keyboard'.");
-		ddf_fun_unbind(kbd->kbd_fun);
-		ddf_fun_destroy(kbd->kbd_fun);
-		return ENOMEM;
-	}
-	
-	kbd->polling_fibril = fibril_create(polling, kbd);
-	if (!kbd->polling_fibril) {
-		ddf_msg(LVL_ERROR, "Failed creating polling fibril.");
-		ddf_fun_unbind(kbd->kbd_fun);
-		ddf_fun_destroy(kbd->kbd_fun);
-		return ENOMEM;
-	}
-	
-	fibril_add_ready(kbd->polling_fibril);
-	return EOK;
-}
Index: uspace/drv/char/xtkbd/xtkbd.h
===================================================================
--- uspace/drv/char/xtkbd/xtkbd.h	(revision 19397becd25f896f19a94f9f6867540d2c59da3d)
+++ 	(revision )
@@ -1,56 +1,0 @@
-/*
- * Copyright (c) 2011 Jan Vesely
- * 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 drvkbd
- * @{
- */
-/** @file
- * @brief XT keyboard driver
- */
-
-#ifndef _XT_KBD_H_
-#define _XT_KBD_H_
-
-#include <ddf/driver.h>
-#include <fibril.h>
-
-/** PC/XT keyboard driver structure. */
-typedef struct {
-	ddf_fun_t *kbd_fun;        /**< Keyboard function. */
-	async_sess_t *parent_sess; /**< Connection to device providing data. */
-	async_sess_t *client_sess; /**< Callback connection to client. */
-	fid_t polling_fibril;      /**< Fibril retrieving an parsing data. */
-} xt_kbd_t;
-
-extern int xt_kbd_init(xt_kbd_t *, ddf_dev_t *);
-
-#endif
-
-/**
- * @}
- */
Index: uspace/drv/char/xtkbd/xtkbd.ma
===================================================================
--- uspace/drv/char/xtkbd/xtkbd.ma	(revision 19397becd25f896f19a94f9f6867540d2c59da3d)
+++ 	(revision )
@@ -1,1 +1,0 @@
-100 char/xtkbd
Index: uspace/drv/hid/atkbd/Makefile
===================================================================
--- uspace/drv/hid/atkbd/Makefile	(revision d420b22fe09893c1b4117473e6787a4295055001)
+++ uspace/drv/hid/atkbd/Makefile	(revision d420b22fe09893c1b4117473e6787a4295055001)
@@ -0,0 +1,37 @@
+#
+# Copyright (c) 2011 Jan Vesely
+# 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.
+#
+
+USPACE_PREFIX = ../../..
+LIBS = drv
+BINARY = atkbd
+
+SOURCES = \
+	main.c \
+	atkbd.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/drv/hid/atkbd/atkbd.c
===================================================================
--- uspace/drv/hid/atkbd/atkbd.c	(revision d420b22fe09893c1b4117473e6787a4295055001)
+++ uspace/drv/hid/atkbd/atkbd.c	(revision d420b22fe09893c1b4117473e6787a4295055001)
@@ -0,0 +1,409 @@
+/*
+ * Copyright (c) 2011 Jan Vesely
+ * Copyright (c) 2009 Vineeth Pillai
+ * 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 drvkbd
+ * @{
+ */
+/** @file
+ * @brief AT keyboard driver
+ */
+
+#include <errno.h>
+#include <ddf/log.h>
+#include <io/keycode.h>
+#include <io/chardev.h>
+#include <io/console.h>
+#include <ipc/kbdev.h>
+#include <abi/ipc/methods.h>
+#include "atkbd.h"
+
+#define AT_CAPS_SCAN_CODE 0x58
+#define AT_NUM_SCAN_CODE 0x77
+#define AT_SCROLL_SCAN_CODE 0x7E
+
+/* Set 2 scan codes (AT keyboard) */
+static const unsigned int scanmap_simple[] = {
+	[0x0e] = KC_BACKTICK,
+
+	[0x16] = KC_1,
+	[0x1e] = KC_2,
+	[0x26] = KC_3,
+	[0x25] = KC_4,
+	[0x2e] = KC_5,
+	[0x36] = KC_6,
+	[0x3d] = KC_7,
+	[0x3e] = KC_8,
+	[0x46] = KC_9,
+	[0x45] = KC_0,
+
+	[0x4e] = KC_MINUS,
+	[0x55] = KC_EQUALS,
+	[0x66] = KC_BACKSPACE,
+
+	[0x0d] = KC_TAB,
+
+	[0x15] = KC_Q,
+	[0x1d] = KC_W,
+	[0x24] = KC_E,
+	[0x2d] = KC_R,
+	[0x2c] = KC_T,
+	[0x35] = KC_Y,
+	[0x3c] = KC_U,
+	[0x43] = KC_I,
+	[0x44] = KC_O,
+	[0x4d] = KC_P,
+
+	[0x54] = KC_LBRACKET,
+	[0x5b] = KC_RBRACKET,
+
+	[0x58] = KC_CAPS_LOCK,
+
+	[0x1c] = KC_A,
+	[0x1b] = KC_S,
+	[0x23] = KC_D,
+	[0x2b] = KC_F,
+	[0x34] = KC_G,
+	[0x33] = KC_H,
+	[0x3b] = KC_J,
+	[0x42] = KC_K,
+	[0x4b] = KC_L,
+
+	[0x4c] = KC_SEMICOLON,
+	[0x52] = KC_QUOTE,
+	[0x5d] = KC_BACKSLASH,
+
+	[0x12] = KC_LSHIFT,
+
+	[0x1a] = KC_Z,
+	[0x22] = KC_X,
+	[0x21] = KC_C,
+	[0x2a] = KC_V,
+	[0x32] = KC_B,
+	[0x31] = KC_N,
+	[0x3a] = KC_M,
+
+	[0x41] = KC_COMMA,
+	[0x49] = KC_PERIOD,
+	[0x4a] = KC_SLASH,
+
+	[0x59] = KC_RSHIFT,
+
+	[0x14] = KC_LCTRL,
+	[0x11] = KC_LALT,
+	[0x29] = KC_SPACE,
+
+	[0x76] = KC_ESCAPE,
+
+	[0x05] = KC_F1,
+	[0x06] = KC_F2,
+	[0x04] = KC_F3,
+	[0x0c] = KC_F4,
+	[0x03] = KC_F5,
+	[0x0b] = KC_F6,
+	[0x02] = KC_F7,
+
+	[0x0a] = KC_F8,
+	[0x01] = KC_F9,
+	[0x09] = KC_F10,
+
+	[0x78] = KC_F11,
+	[0x07] = KC_F12,
+
+	[0x7e] = KC_SCROLL_LOCK,
+
+	[0x5a] = KC_ENTER,
+
+	[0x77] = KC_NUM_LOCK,
+	[0x7c] = KC_NTIMES,
+	[0x7b] = KC_NMINUS,
+	[0x79] = KC_NPLUS,
+	[0x6c] = KC_N7,
+	[0x75] = KC_N8,
+	[0x7d] = KC_N9,
+	[0x6b] = KC_N4,
+	[0x73] = KC_N5,
+	[0x74] = KC_N6,
+	[0x69] = KC_N1,
+	[0x72] = KC_N2,
+	[0x7a] = KC_N3,
+	[0x70] = KC_N0,
+	[0x71] = KC_NPERIOD,
+};
+
+#define KBD_SCANCODE_SET_EXTENDED		0xe0
+#define KBD_SCANCODE_SET_EXTENDED_SPECIAL	0xe1
+#define KBD_SCANCODE_KEY_RELEASE		0xf0
+
+static const unsigned int scanmap_e0[] = {
+	[0x65] = KC_RALT,
+	[0x59] = KC_RSHIFT,
+
+	[0x64] = KC_PRTSCR,
+
+	[0x70] = KC_INSERT,
+	[0x6c] = KC_HOME,
+	[0x7d] = KC_PAGE_UP,
+
+	[0x71] = KC_DELETE,
+	[0x69] = KC_END,
+	[0x7a] = KC_PAGE_DOWN,
+
+	[0x75] = KC_UP,
+	[0x6b] = KC_LEFT,
+	[0x72] = KC_DOWN,
+	[0x74] = KC_RIGHT,
+
+	[0x4a] = KC_NSLASH,
+	[0x5a] = KC_NENTER
+};
+
+static void push_event(async_sess_t *sess, kbd_event_type_t type,
+    unsigned int key)
+{
+	async_exch_t *exch = async_exchange_begin(sess);
+	async_msg_4(exch, KBDEV_EVENT, type, key, 0, 0);
+	async_exchange_end(exch);
+}
+
+/** Get data and parse scancodes.
+ *
+ * @param arg Pointer to at_kbd_t structure.
+ *
+ * @return EIO on error.
+ *
+ */
+static int polling(void *arg)
+{
+	const at_kbd_t *kbd = arg;
+	
+	assert(kbd);
+	assert(kbd->parent_sess);
+	
+	async_exch_t *parent_exch = async_exchange_begin(kbd->parent_sess);
+	
+	while (true) {
+		if (!parent_exch)
+			parent_exch = async_exchange_begin(kbd->parent_sess);
+
+		uint8_t code = 0;
+		ssize_t size = chardev_read(parent_exch, &code, 1);
+		if (size != 1)
+			return EIO;
+		
+		const unsigned int *map;
+		size_t map_size;
+		
+		if (code == KBD_SCANCODE_SET_EXTENDED) {
+			map = scanmap_e0;
+			map_size = sizeof(scanmap_e0) / sizeof(unsigned int);
+			
+			size = chardev_read(parent_exch, &code, 1);
+			if (size != 1)
+				return EIO;
+		} else if (code == KBD_SCANCODE_SET_EXTENDED_SPECIAL) {
+			size = chardev_read(parent_exch, &code, 1);
+			if (size != 1)
+				return EIO;
+			if (code != 0x14)
+				continue;
+
+			size = chardev_read(parent_exch, &code, 1);
+			if (size != 1)
+				return EIO;
+			if (code != 0x77)
+				continue;
+
+			size = chardev_read(parent_exch, &code, 1);
+			if (size != 1)
+				return EIO;
+			if (code != 0xe1)
+				continue;
+
+			size = chardev_read(parent_exch, &code, 1);
+			if (size != 1)
+				return EIO;
+			if (code != 0xf0)
+				continue;
+
+			size = chardev_read(parent_exch, &code, 1);
+			if (size != 1)
+				return EIO;
+			if (code != 0x14)
+				continue;
+
+			size = chardev_read(parent_exch, &code, 1);
+			if (size != 1)
+				return EIO;
+			if (code != 0xf0)
+				continue;
+
+			size = chardev_read(parent_exch, &code, 1);
+			if (size != 1)
+				return EIO;
+			if (code == 0x77)
+				push_event(kbd->client_sess, KEY_PRESS, KC_BREAK);
+
+			continue;
+		} else {
+			map = scanmap_simple;
+			map_size = sizeof(scanmap_simple) / sizeof(unsigned int);
+		}
+		
+		kbd_event_type_t type;
+		if (code == KBD_SCANCODE_KEY_RELEASE) {
+			type = KEY_RELEASE;
+			size = chardev_read(parent_exch, &code, 1);
+			if (size != 1)
+				return EIO;
+		} else {
+			type = KEY_PRESS;
+		}
+		
+		const unsigned int key = (code < map_size) ? map[code] : 0;
+		
+		if (key != 0)
+			push_event(kbd->client_sess, type, key);
+		else
+			ddf_msg(LVL_WARN, "Unknown scancode: %hhx", code);
+	}
+}
+
+/** Default handler for IPC methods not handled by DDF.
+ *
+ * @param fun     Device function handling the call.
+ * @param icallid Call id.
+ * @param icall   Call data.
+ *
+ */
+static void default_connection_handler(ddf_fun_t *fun,
+    ipc_callid_t icallid, ipc_call_t *icall)
+{
+	const sysarg_t method = IPC_GET_IMETHOD(*icall);
+	at_kbd_t *kbd = ddf_dev_data_get(ddf_fun_get_dev(fun));
+
+	switch (method) {
+	case KBDEV_SET_IND: {
+		async_answer_0(icallid, ENOTSUP);
+		break;
+	}
+	/*
+	 * This might be ugly but async_callback_receive_start makes no
+	 * difference for incorrect call and malloc failure.
+	 */
+	case IPC_M_CONNECT_TO_ME: {
+		async_sess_t *sess =
+		    async_callback_receive_start(EXCHANGE_SERIALIZE, icall);
+		
+		/* Probably ENOMEM error, try again. */
+		if (sess == NULL) {
+			ddf_msg(LVL_WARN,
+			    "Failed creating callback session");
+			async_answer_0(icallid, EAGAIN);
+			break;
+		}
+		
+		if (kbd->client_sess == NULL) {
+			kbd->client_sess = sess;
+			ddf_msg(LVL_DEBUG, "Set client session");
+			async_answer_0(icallid, EOK);
+		} else {
+			ddf_msg(LVL_ERROR, "Client session already set");
+			async_answer_0(icallid, ELIMIT);
+		}
+		
+		break;
+	}
+	default:
+		ddf_msg(LVL_ERROR, "Unknown method: %d.", (int)method);
+		async_answer_0(icallid, EINVAL);
+		break;
+	}
+}
+
+/** Keyboard function ops. */
+static ddf_dev_ops_t kbd_ops = {
+	.default_handler = default_connection_handler
+};
+
+/** Initialize keyboard driver structure.
+ *
+ * @param kbd Keyboard driver structure to initialize.
+ * @param dev DDF device structure.
+ *
+ * Connects to parent, creates keyboard function, starts polling fibril.
+ *
+ */
+int at_kbd_init(at_kbd_t *kbd, ddf_dev_t *dev)
+{
+	assert(kbd);
+	assert(dev);
+	
+	kbd->client_sess = NULL;
+	kbd->parent_sess = ddf_dev_parent_sess_get(dev);
+	
+	if (!kbd->parent_sess) {
+		ddf_msg(LVL_ERROR, "Failed creating parent session.");
+		return EIO;
+	}
+	
+	kbd->kbd_fun = ddf_fun_create(dev, fun_exposed, "kbd");
+	if (!kbd->kbd_fun) {
+		ddf_msg(LVL_ERROR, "Failed creating function 'kbd'.");
+		return ENOMEM;
+	}
+	
+	ddf_fun_set_ops(kbd->kbd_fun, &kbd_ops);
+	
+	int ret = ddf_fun_bind(kbd->kbd_fun);
+	if (ret != EOK) {
+		ddf_msg(LVL_ERROR, "Failed binding function 'kbd'.");
+		ddf_fun_destroy(kbd->kbd_fun);
+		return EEXIST;
+	}
+	
+	ret = ddf_fun_add_to_category(kbd->kbd_fun, "keyboard");
+	if (ret != EOK) {
+		ddf_msg(LVL_ERROR, "Failed adding function 'kbd' to category "
+		    "'keyboard'.");
+		ddf_fun_unbind(kbd->kbd_fun);
+		ddf_fun_destroy(kbd->kbd_fun);
+		return ENOMEM;
+	}
+	
+	kbd->polling_fibril = fibril_create(polling, kbd);
+	if (!kbd->polling_fibril) {
+		ddf_msg(LVL_ERROR, "Failed creating polling fibril.");
+		ddf_fun_unbind(kbd->kbd_fun);
+		ddf_fun_destroy(kbd->kbd_fun);
+		return ENOMEM;
+	}
+	
+	fibril_add_ready(kbd->polling_fibril);
+	return EOK;
+}
Index: uspace/drv/hid/atkbd/atkbd.h
===================================================================
--- uspace/drv/hid/atkbd/atkbd.h	(revision d420b22fe09893c1b4117473e6787a4295055001)
+++ uspace/drv/hid/atkbd/atkbd.h	(revision d420b22fe09893c1b4117473e6787a4295055001)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2011 Jan Vesely
+ * 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 drvkbd
+ * @{
+ */
+/** @file
+ * @brief AT keyboard driver
+ */
+
+#ifndef _AT_KBD_H_
+#define _AT_KBD_H_
+
+#include <ddf/driver.h>
+#include <fibril.h>
+
+/** PC/AT keyboard driver structure. */
+typedef struct {
+	ddf_fun_t *kbd_fun;        /**< Keyboard function. */
+	async_sess_t *parent_sess; /**< Connection to device providing data. */
+	async_sess_t *client_sess; /**< Callback connection to client. */
+	fid_t polling_fibril;      /**< Fibril retrieving an parsing data. */
+} at_kbd_t;
+
+extern int at_kbd_init(at_kbd_t *, ddf_dev_t *);
+
+#endif
+
+/**
+ * @}
+ */
Index: uspace/drv/hid/atkbd/atkbd.ma
===================================================================
--- uspace/drv/hid/atkbd/atkbd.ma	(revision d420b22fe09893c1b4117473e6787a4295055001)
+++ uspace/drv/hid/atkbd/atkbd.ma	(revision d420b22fe09893c1b4117473e6787a4295055001)
@@ -0,0 +1,1 @@
+100 char/atkbd
Index: uspace/drv/hid/atkbd/main.c
===================================================================
--- uspace/drv/hid/atkbd/main.c	(revision d420b22fe09893c1b4117473e6787a4295055001)
+++ uspace/drv/hid/atkbd/main.c	(revision d420b22fe09893c1b4117473e6787a4295055001)
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2011 Jan Vesely
+ * 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 drvkbd
+ * @{
+ */
+/** @file
+ * @brief AT keyboard driver
+ */
+
+#include <inttypes.h>
+#include <ddf/driver.h>
+#include <device/hw_res_parsed.h>
+#include <errno.h>
+#include <str_error.h>
+#include <ddf/log.h>
+#include <stdio.h>
+
+#include "atkbd.h"
+
+#define NAME "atkbd"
+
+static int at_kbd_add(ddf_dev_t *device);
+
+/** DDF driver ops. */
+static driver_ops_t kbd_driver_ops = {
+	.dev_add = at_kbd_add,
+};
+
+/** DDF driver structure. */
+static driver_t kbd_driver = {
+	.name = NAME,
+	.driver_ops = &kbd_driver_ops
+};
+
+/** Initialize global driver structures (NONE).
+ *
+ * Driver debug level is set here.
+ *
+ * @param[in] argc Nmber of arguments in argv vector (ignored).
+ * @param[in] argv Cmdline argument vector (ignored).
+ *
+ * @return Error code.
+ *
+ */
+int main(int argc, char *argv[])
+{
+	printf(NAME ": HelenOS AT keyboard driver.\n");
+	ddf_log_init(NAME);
+	return ddf_driver_main(&kbd_driver);
+}
+
+/** Initialize a new ddf driver instance of the driver
+ *
+ * @param[in] device DDF instance of the device to initialize.
+ *
+ * @return Error code.
+ *
+ */
+static int at_kbd_add(ddf_dev_t *device)
+{
+	int rc;
+
+	if (!device)
+		return EINVAL;
+
+	at_kbd_t *kbd = ddf_dev_data_alloc(device, sizeof(at_kbd_t));
+	if (kbd == NULL) {
+		ddf_msg(LVL_ERROR, "Failed to allocate AT_KBD driver instance.");
+		return ENOMEM;
+	}
+
+	rc = at_kbd_init(kbd, device);
+	if (rc != EOK) {
+		ddf_msg(LVL_ERROR, "Failed to initialize AT_KBD driver: %s.",
+		    str_error(rc));
+    		return rc;
+	}
+
+	ddf_msg(LVL_NOTE, "Controlling '%s' (%" PRIun ").",
+	    ddf_dev_get_name(device), ddf_dev_get_handle(device));
+	return EOK;
+}
+
+/**
+ * @}
+ */
Index: uspace/drv/hid/ps2mouse/Makefile
===================================================================
--- uspace/drv/hid/ps2mouse/Makefile	(revision d420b22fe09893c1b4117473e6787a4295055001)
+++ uspace/drv/hid/ps2mouse/Makefile	(revision d420b22fe09893c1b4117473e6787a4295055001)
@@ -0,0 +1,37 @@
+#
+# Copyright (c) 2011 Jan Vesely
+# 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.
+#
+
+USPACE_PREFIX = ../../..
+LIBS = drv
+BINARY = ps2mouse
+
+SOURCES = \
+	main.c \
+	ps2mouse.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/drv/hid/ps2mouse/main.c
===================================================================
--- uspace/drv/hid/ps2mouse/main.c	(revision d420b22fe09893c1b4117473e6787a4295055001)
+++ uspace/drv/hid/ps2mouse/main.c	(revision d420b22fe09893c1b4117473e6787a4295055001)
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2011 Jan Vesely
+ * 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 drvmouse
+ * @{
+ */
+/** @file
+ * @brief ps/2 mouse driver
+ */
+
+#include <inttypes.h>
+#include <ddf/driver.h>
+#include <device/hw_res_parsed.h>
+#include <errno.h>
+#include <str_error.h>
+#include <ddf/log.h>
+#include <stdio.h>
+
+#include "ps2mouse.h"
+
+#define NAME "ps2mouse"
+
+static int mouse_add(ddf_dev_t *device);
+
+/** DDF driver ops. */
+static driver_ops_t mouse_driver_ops = {
+	.dev_add = mouse_add,
+};
+
+/** DDF driver structure. */
+static driver_t mouse_driver = {
+	.name = NAME,
+	.driver_ops = &mouse_driver_ops
+};
+
+/** Initialize global driver structures (NONE).
+ *
+ * @param[in] argc Nmber of arguments in argv vector (ignored).
+ * @param[in] argv Cmdline argument vector (ignored).
+ * @return Error code.
+ *
+ * Driver debug level is set here.
+ */
+int main(int argc, char *argv[])
+{
+	printf(NAME ": HelenOS ps/2 mouse driver.\n");
+	ddf_log_init(NAME);
+	return ddf_driver_main(&mouse_driver);
+}
+
+/** Initialize a new ddf driver instance
+ *
+ * @param[in] device DDF instance of the device to initialize.
+ * @return Error code.
+ */
+static int mouse_add(ddf_dev_t *device)
+{
+	int rc;
+
+	if (!device)
+		return EINVAL;
+
+	ps2_mouse_t *mouse = ddf_dev_data_alloc(device, sizeof(ps2_mouse_t));
+	if (mouse == NULL) {
+		ddf_msg(LVL_ERROR, "Failed to allocate mouse driver instance.");
+		return ENOMEM;
+	}
+
+	rc = ps2_mouse_init(mouse, device);
+	if (rc != EOK) {
+		ddf_msg(LVL_ERROR, "Failed to initialize mouse driver: %s.",
+		    str_error(rc));
+		return rc;
+	}
+
+	ddf_msg(LVL_NOTE, "Controlling '%s' (%" PRIun ").",
+	    ddf_dev_get_name(device), ddf_dev_get_handle(device));
+	return EOK;
+}
+/**
+ * @}
+ */
Index: uspace/drv/hid/ps2mouse/ps2mouse.c
===================================================================
--- uspace/drv/hid/ps2mouse/ps2mouse.c	(revision d420b22fe09893c1b4117473e6787a4295055001)
+++ uspace/drv/hid/ps2mouse/ps2mouse.c	(revision d420b22fe09893c1b4117473e6787a4295055001)
@@ -0,0 +1,387 @@
+/*
+ * Copyright (c) 2011 Jan Vesely
+ * 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 drvmouse
+ * @{
+ */
+/** @file
+ * @brief ps2 mouse driver.
+ */
+
+#include <stdbool.h>
+#include <errno.h>
+#include <ddf/log.h>
+#include <io/keycode.h>
+#include <io/chardev.h>
+#include <io/console.h>
+#include <ipc/mouseev.h>
+#include <abi/ipc/methods.h>
+
+#include "ps2mouse.h"
+
+#define PS2_MOUSE_GET_DEVICE_ID   0xf2
+#define PS2_MOUSE_SET_SAMPLE_RATE   0xf3
+#define PS2_MOUSE_ENABLE_DATA_REPORT   0xf4
+#define PS2_MOUSE_ACK   0xfa
+
+#define PS2_BUFSIZE 3
+#define INTELLIMOUSE_BUFSIZE 4
+
+#define Z_SIGN (1 << 3) /* 4th byte */
+#define X_SIGN (1 << 4) /* 1st byte */
+#define Y_SIGN (1 << 5) /* 1st byte */
+#define X_OVERFLOW (1 << 6) /* 1st byte */
+#define Y_OVERFLOW (1 << 7) /* 1st byte */
+
+#define BUTTON_LEFT   0
+#define BUTTON_RIGHT   1
+#define BUTTON_MIDDLE   2
+#define PS2_BUTTON_COUNT   3
+
+#define INTELLIMOUSE_ALWAYS_ZERO (0xc0)
+#define INTELLIMOUSE_BUTTON_4 (1 << 4) /* 4th byte */
+#define INTELLIMOUSE_BUTTON_5 (1 << 5) /* 4th byte */
+#define INTELLIMOUSE_BUTTON_COUNT 5
+
+#define PS2_BUTTON_MASK(button) (1 << button)
+
+#define MOUSE_READ_BYTE_TEST(sess, value_) \
+do { \
+	uint8_t value = (value_); \
+	uint8_t data = 0; \
+	const ssize_t size = chardev_read(sess, &data, 1); \
+	if (size != 1) { \
+		ddf_msg(LVL_ERROR, "Failed reading byte: %zd)", size);\
+		return size < 0 ? size : EIO; \
+	} \
+	if (data != value) { \
+		ddf_msg(LVL_DEBUG, "Failed testing byte: got %hhx vs. %hhx)", \
+		    data, value); \
+		return EIO; \
+	} \
+} while (0)
+
+#define MOUSE_WRITE_BYTE(sess, value_) \
+do { \
+	uint8_t value = (value_); \
+	uint8_t data = (value); \
+	const ssize_t size = chardev_write(sess, &data, 1); \
+	if (size < 0 ) { \
+		ddf_msg(LVL_ERROR, "Failed writing byte: %hhx", value); \
+		return size; \
+	} \
+} while (0)
+
+static int polling_ps2(void *);
+static int polling_intellimouse(void *);
+static int probe_intellimouse(async_exch_t *, bool);
+static void default_connection_handler(ddf_fun_t *, ipc_callid_t, ipc_call_t *);
+
+/** ps/2 mouse driver ops. */
+static ddf_dev_ops_t mouse_ops = {
+	.default_handler = default_connection_handler
+};
+
+/** Initialize mouse driver structure.
+ * @param kbd Mouse driver structure to initialize.
+ * @param dev DDF device structure.
+ *
+ * Connects to parent, creates keyboard function, starts polling fibril.
+ */
+int ps2_mouse_init(ps2_mouse_t *mouse, ddf_dev_t *dev)
+{
+	mouse->client_sess = NULL;
+	mouse->parent_sess = ddf_dev_parent_sess_get(dev);
+	if (!mouse->parent_sess)
+		return ENOMEM;
+
+	mouse->mouse_fun = ddf_fun_create(dev, fun_exposed, "mouse");
+	if (!mouse->mouse_fun) {
+		return ENOMEM;
+	}
+	ddf_fun_set_ops(mouse->mouse_fun, &mouse_ops);
+
+	int ret = ddf_fun_bind(mouse->mouse_fun);
+	if (ret != EOK) {
+		ddf_fun_destroy(mouse->mouse_fun);
+		return ENOMEM;
+	}
+
+	ret = ddf_fun_add_to_category(mouse->mouse_fun, "mouse");
+	if (ret != EOK) {
+		ddf_fun_unbind(mouse->mouse_fun);
+		ddf_fun_destroy(mouse->mouse_fun);
+		return ENOMEM;
+	}
+	/* Probe IntelliMouse extensions. */
+	int (*polling_f)(void*) = polling_ps2;
+	async_exch_t *exch = async_exchange_begin(mouse->parent_sess);
+	if (probe_intellimouse(exch, false) == EOK) {
+		ddf_msg(LVL_NOTE, "Enabled IntelliMouse extensions");
+		polling_f = polling_intellimouse;
+		if (probe_intellimouse(exch, true) == EOK)
+			ddf_msg(LVL_NOTE, "Enabled 4th and 5th button.");
+	}
+	/* Enable mouse data reporting. */
+	uint8_t report = PS2_MOUSE_ENABLE_DATA_REPORT;
+	ssize_t size = chardev_write(exch, &report, 1);
+	if (size != 1) {
+		ddf_msg(LVL_ERROR, "Failed to enable data reporting.");
+		async_exchange_end(exch);
+		ddf_fun_unbind(mouse->mouse_fun);
+		ddf_fun_destroy(mouse->mouse_fun);
+		return EIO;
+	}
+
+	size = chardev_read(exch, &report, 1);
+	async_exchange_end(exch);
+	if (size != 1 || report != PS2_MOUSE_ACK) {
+		ddf_msg(LVL_ERROR, "Failed to confirm data reporting: %hhx.",
+		    report);
+		ddf_fun_unbind(mouse->mouse_fun);
+		ddf_fun_destroy(mouse->mouse_fun);
+		return EIO;
+	}
+
+	mouse->polling_fibril = fibril_create(polling_f, mouse);
+	if (!mouse->polling_fibril) {
+		ddf_fun_unbind(mouse->mouse_fun);
+		ddf_fun_destroy(mouse->mouse_fun);
+		return ENOMEM;
+	}
+	fibril_add_ready(mouse->polling_fibril);
+	return EOK;
+}
+
+/** Get data and parse ps2 protocol packets.
+ * @param arg Pointer to ps2_mouse_t structure.
+ * @return Never.
+ */
+int polling_ps2(void *arg)
+{
+	assert(arg);
+	const ps2_mouse_t *mouse = arg;
+
+	assert(mouse->parent_sess);
+	bool buttons[PS2_BUTTON_COUNT] = {};
+	async_exch_t *parent_exch = async_exchange_begin(mouse->parent_sess);
+	while (1) {
+
+		uint8_t packet[PS2_BUFSIZE] = {};
+		const ssize_t size =
+		    chardev_read(parent_exch, packet, PS2_BUFSIZE);
+
+		if (size != PS2_BUFSIZE) {
+			ddf_msg(LVL_WARN, "Incorrect packet size: %zd.", size);
+			continue;
+		}
+		ddf_msg(LVL_DEBUG2, "Got packet: %hhx:%hhx:%hhx.",
+		    packet[0], packet[1], packet[2]);
+
+		async_exch_t *exch =
+		    async_exchange_begin(mouse->client_sess);
+		if (!exch) {
+			ddf_msg(LVL_ERROR,
+			    "Failed creating exchange.");
+			continue;
+		}
+
+		/* Buttons */
+		for (unsigned i = 0; i < PS2_BUTTON_COUNT; ++i) {
+			const bool status = (packet[0] & PS2_BUTTON_MASK(i));
+			if (buttons[i] != status) {
+				buttons[i] = status;
+				async_msg_2(exch, MOUSEEV_BUTTON_EVENT, i + 1,
+				    buttons[i]);
+			}
+		}
+
+		/* Movement */
+		const int16_t move_x =
+		    ((packet[0] & X_SIGN) ? 0xff00 : 0) | packet[1];
+		const int16_t move_y =
+		    (((packet[0] & Y_SIGN) ? 0xff00 : 0) | packet[2]);
+		//TODO: Consider overflow bit
+		if (move_x != 0 || move_y != 0) {
+			async_msg_2(exch, MOUSEEV_MOVE_EVENT, move_x, -move_y);
+		}
+		async_exchange_end(exch);
+	}
+	async_exchange_end(parent_exch);
+}
+
+/** Get data and parse ps2 protocol with IntelliMouse extension packets.
+ * @param arg Pointer to ps2_mouse_t structure.
+ * @return Never.
+ */
+static int polling_intellimouse(void *arg)
+{
+	assert(arg);
+	const ps2_mouse_t *mouse = arg;
+
+	assert(mouse->parent_sess);
+	bool buttons[INTELLIMOUSE_BUTTON_COUNT] = {};
+	async_exch_t *parent_exch = NULL;
+	while (1) {
+		if (!parent_exch)
+			parent_exch = async_exchange_begin(mouse->parent_sess);
+
+		uint8_t packet[INTELLIMOUSE_BUFSIZE] = {};
+		const ssize_t size = chardev_read(
+		    parent_exch, packet, INTELLIMOUSE_BUFSIZE);
+
+		if (size != INTELLIMOUSE_BUFSIZE) {
+			ddf_msg(LVL_WARN, "Incorrect packet size: %zd.", size);
+			continue;
+		}
+		ddf_msg(LVL_DEBUG2, "Got packet: %hhx:%hhx:%hhx:%hhx.",
+		    packet[0], packet[1], packet[2], packet[3]);
+
+		async_exch_t *exch =
+		    async_exchange_begin(mouse->client_sess);
+		if (!exch) {
+			ddf_msg(LVL_ERROR,
+			    "Failed creating exchange.");
+			continue;
+		}
+
+		/* Buttons */
+		/* NOTE: Parsing 4th and 5th button works even if this extension
+		 * is not supported and whole 4th byte should be interpreted
+		 * as Z-axis movement. the upper 4 bits are just a sign
+		 * extension then. + sign is interpreted as "button up"
+		 * (i.e no change since that is the default) and - sign fails
+		 * the "imb" condition. Thus 4th and 5th buttons are never
+		 * down on wheel only extension. */
+		const bool imb = (packet[3] & INTELLIMOUSE_ALWAYS_ZERO) == 0;
+		const bool status[] = {
+			[0] = packet[0] & PS2_BUTTON_MASK(0),
+			[1] = packet[0] & PS2_BUTTON_MASK(1),
+			[2] = packet[0] & PS2_BUTTON_MASK(2),
+			[3] = (packet[3] & INTELLIMOUSE_BUTTON_4) && imb,
+			[4] = (packet[3] & INTELLIMOUSE_BUTTON_5) && imb,
+		};
+		for (unsigned i = 0; i < INTELLIMOUSE_BUTTON_COUNT; ++i) {
+			if (buttons[i] != status[i]) {
+				buttons[i] = status[i];
+				async_msg_2(exch, MOUSEEV_BUTTON_EVENT, i + 1,
+				    buttons[i]);
+			}
+		}
+
+		/* Movement */
+		const int16_t move_x =
+		    ((packet[0] & X_SIGN) ? 0xff00 : 0) | packet[1];
+		const int16_t move_y =
+		    (((packet[0] & Y_SIGN) ? 0xff00 : 0) | packet[2]);
+		const int8_t move_z =
+		    (((packet[3] & Z_SIGN) ? 0xf0 : 0) | (packet[3] & 0xf));
+		ddf_msg(LVL_DEBUG2, "Parsed moves: %d:%d:%hhd", move_x, move_y,
+		    move_z);
+		//TODO: Consider overflow bit
+		if (move_x != 0 || move_y != 0 || move_z != 0) {
+			async_msg_3(exch, MOUSEEV_MOVE_EVENT,
+			    move_x, -move_y, -move_z);
+		}
+		async_exchange_end(exch);
+	}
+	async_exchange_end(parent_exch);
+}
+
+/** Send magic sequence to initialize IntelliMouse extensions.
+ * @param exch IPC exchange to the parent device.
+ * @param buttons True selects magic sequence for 4th and 5th button,
+ * false selects wheel support magic sequence.
+ * See http://www.computer-engineering.org/ps2mouse/ for details.
+ */
+static int probe_intellimouse(async_exch_t *exch, bool buttons)
+{
+	assert(exch);
+
+	MOUSE_WRITE_BYTE(exch, PS2_MOUSE_SET_SAMPLE_RATE);
+	MOUSE_READ_BYTE_TEST(exch, PS2_MOUSE_ACK);
+	MOUSE_WRITE_BYTE(exch, 200);
+	MOUSE_READ_BYTE_TEST(exch, PS2_MOUSE_ACK);
+
+	MOUSE_WRITE_BYTE(exch, PS2_MOUSE_SET_SAMPLE_RATE);
+	MOUSE_READ_BYTE_TEST(exch, PS2_MOUSE_ACK);
+	MOUSE_WRITE_BYTE(exch, buttons ? 200 : 100);
+	MOUSE_READ_BYTE_TEST(exch, PS2_MOUSE_ACK);
+
+	MOUSE_WRITE_BYTE(exch, PS2_MOUSE_SET_SAMPLE_RATE);
+	MOUSE_READ_BYTE_TEST(exch, PS2_MOUSE_ACK);
+	MOUSE_WRITE_BYTE(exch, 80);
+	MOUSE_READ_BYTE_TEST(exch, PS2_MOUSE_ACK);
+
+	MOUSE_WRITE_BYTE(exch, PS2_MOUSE_GET_DEVICE_ID);
+	MOUSE_READ_BYTE_TEST(exch, PS2_MOUSE_ACK);
+	MOUSE_READ_BYTE_TEST(exch, buttons ? 4 : 3);
+
+	return EOK;
+}
+
+/** Default handler for IPC methods not handled by DDF.
+ *
+ * @param fun Device function handling the call.
+ * @param icallid Call id.
+ * @param icall Call data.
+ */
+void default_connection_handler(ddf_fun_t *fun,
+    ipc_callid_t icallid, ipc_call_t *icall)
+{
+	const sysarg_t method = IPC_GET_IMETHOD(*icall);
+	ps2_mouse_t *mouse = ddf_dev_data_get(ddf_fun_get_dev(fun));
+
+	switch (method) {
+	/* This might be ugly but async_callback_receive_start makes no
+	 * difference for incorrect call and malloc failure. */
+	case IPC_M_CONNECT_TO_ME: {
+		async_sess_t *sess =
+		    async_callback_receive_start(EXCHANGE_SERIALIZE, icall);
+		/* Probably ENOMEM error, try again. */
+		if (sess == NULL) {
+			ddf_msg(LVL_WARN,
+			    "Failed creating client callback session");
+			async_answer_0(icallid, EAGAIN);
+			break;
+		}
+		if (mouse->client_sess == NULL) {
+			mouse->client_sess = sess;
+			ddf_msg(LVL_DEBUG, "Set client session");
+			async_answer_0(icallid, EOK);
+		} else {
+			ddf_msg(LVL_ERROR, "Client session already set");
+			async_answer_0(icallid, ELIMIT);
+		}
+		break;
+	}
+	default:
+		ddf_msg(LVL_ERROR, "Unknown method: %d.", (int)method);
+		async_answer_0(icallid, EINVAL);
+		break;
+	}
+}
Index: uspace/drv/hid/ps2mouse/ps2mouse.h
===================================================================
--- uspace/drv/hid/ps2mouse/ps2mouse.h	(revision d420b22fe09893c1b4117473e6787a4295055001)
+++ uspace/drv/hid/ps2mouse/ps2mouse.h	(revision d420b22fe09893c1b4117473e6787a4295055001)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2011 Jan Vesely
+ * 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 drvmouse
+ * @{
+ */
+/** @file
+ * @brief ps/2 mouse driver.
+ */
+
+#ifndef _PS2MOUSE_H_
+#define _PS2MOUSE_H_
+
+#include <ddf/driver.h>
+#include <fibril.h>
+
+/** PS/2 mouse driver structure. */
+typedef struct {
+	ddf_fun_t *mouse_fun;      /**< Mouse function. */
+	async_sess_t *parent_sess; /**< Connection to device providing data. */
+	async_sess_t *client_sess;  /**< Callback connection to client. */
+	fid_t polling_fibril;      /**< Fibril retrieving an parsing data. */
+} ps2_mouse_t;
+
+int ps2_mouse_init(ps2_mouse_t *, ddf_dev_t *);
+
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/hid/ps2mouse/ps2mouse.ma
===================================================================
--- uspace/drv/hid/ps2mouse/ps2mouse.ma	(revision d420b22fe09893c1b4117473e6787a4295055001)
+++ uspace/drv/hid/ps2mouse/ps2mouse.ma	(revision d420b22fe09893c1b4117473e6787a4295055001)
@@ -0,0 +1,1 @@
+100 char/ps2mouse
Index: uspace/drv/hid/xtkbd/Makefile
===================================================================
--- uspace/drv/hid/xtkbd/Makefile	(revision d420b22fe09893c1b4117473e6787a4295055001)
+++ uspace/drv/hid/xtkbd/Makefile	(revision d420b22fe09893c1b4117473e6787a4295055001)
@@ -0,0 +1,37 @@
+#
+# Copyright (c) 2011 Jan Vesely
+# 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.
+#
+
+USPACE_PREFIX = ../../..
+LIBS = drv
+BINARY = xtkbd
+
+SOURCES = \
+	main.c \
+	xtkbd.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/drv/hid/xtkbd/main.c
===================================================================
--- uspace/drv/hid/xtkbd/main.c	(revision d420b22fe09893c1b4117473e6787a4295055001)
+++ uspace/drv/hid/xtkbd/main.c	(revision d420b22fe09893c1b4117473e6787a4295055001)
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2011 Jan Vesely
+ * 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 drvkbd
+ * @{
+ */
+/** @file
+ * @brief XT keyboard driver
+ */
+
+#include <inttypes.h>
+#include <ddf/driver.h>
+#include <device/hw_res_parsed.h>
+#include <errno.h>
+#include <str_error.h>
+#include <ddf/log.h>
+#include <stdio.h>
+
+#include "xtkbd.h"
+
+#define NAME "xtkbd"
+
+static int xt_kbd_add(ddf_dev_t *device);
+
+/** DDF driver ops. */
+static driver_ops_t kbd_driver_ops = {
+	.dev_add = xt_kbd_add,
+};
+
+/** DDF driver structure. */
+static driver_t kbd_driver = {
+	.name = NAME,
+	.driver_ops = &kbd_driver_ops
+};
+
+/** Initialize global driver structures (NONE).
+ *
+ * Driver debug level is set here.
+ *
+ * @param[in] argc Nmber of arguments in argv vector (ignored).
+ * @param[in] argv Cmdline argument vector (ignored).
+ *
+ * @return Error code.
+ *
+ */
+int main(int argc, char *argv[])
+{
+	printf(NAME ": HelenOS XT keyboard driver.\n");
+	ddf_log_init(NAME);
+	return ddf_driver_main(&kbd_driver);
+}
+
+/** Initialize a new ddf driver instance of the driver
+ *
+ * @param[in] device DDF instance of the device to initialize.
+ *
+ * @return Error code.
+ *
+ */
+static int xt_kbd_add(ddf_dev_t *device)
+{
+	int rc;
+
+	if (!device)
+		return EINVAL;
+
+	xt_kbd_t *kbd = ddf_dev_data_alloc(device, sizeof(xt_kbd_t));
+	if (kbd == NULL) {
+		ddf_msg(LVL_ERROR, "Failed to allocate XT/KBD driver instance.");
+		return ENOMEM;
+	}
+
+	rc = xt_kbd_init(kbd, device);
+	if (rc != EOK) {
+		ddf_msg(LVL_ERROR, "Failed to initialize XT_KBD driver: %s.",
+		    str_error(rc));
+    		return rc;
+	}
+
+	ddf_msg(LVL_NOTE, "Controlling '%s' (%" PRIun ").",
+	    ddf_dev_get_name(device), ddf_dev_get_handle(device));
+	return EOK;
+}
+
+/**
+ * @}
+ */
Index: uspace/drv/hid/xtkbd/xtkbd.c
===================================================================
--- uspace/drv/hid/xtkbd/xtkbd.c	(revision d420b22fe09893c1b4117473e6787a4295055001)
+++ uspace/drv/hid/xtkbd/xtkbd.c	(revision d420b22fe09893c1b4117473e6787a4295055001)
@@ -0,0 +1,460 @@
+/*
+ * Copyright (c) 2011 Jan Vesely
+ * 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 drvkbd
+ * @{
+ */
+/** @file
+ * @brief XT keyboard driver
+ */
+
+#include <errno.h>
+#include <ddf/log.h>
+#include <io/keycode.h>
+#include <io/chardev.h>
+#include <io/console.h>
+#include <ipc/kbdev.h>
+#include <abi/ipc/methods.h>
+#include "xtkbd.h"
+
+/** Scancode set 1 table. */
+static const unsigned int scanmap_simple[] = {
+	[0x29] = KC_BACKTICK,
+	
+	[0x02] = KC_1,
+	[0x03] = KC_2,
+	[0x04] = KC_3,
+	[0x05] = KC_4,
+	[0x06] = KC_5,
+	[0x07] = KC_6,
+	[0x08] = KC_7,
+	[0x09] = KC_8,
+	[0x0a] = KC_9,
+	[0x0b] = KC_0,
+	
+	[0x0c] = KC_MINUS,
+	[0x0d] = KC_EQUALS,
+	[0x0e] = KC_BACKSPACE,
+	
+	[0x0f] = KC_TAB,
+	
+	[0x10] = KC_Q,
+	[0x11] = KC_W,
+	[0x12] = KC_E,
+	[0x13] = KC_R,
+	[0x14] = KC_T,
+	[0x15] = KC_Y,
+	[0x16] = KC_U,
+	[0x17] = KC_I,
+	[0x18] = KC_O,
+	[0x19] = KC_P,
+	
+	[0x1a] = KC_LBRACKET,
+	[0x1b] = KC_RBRACKET,
+	
+	[0x3a] = KC_CAPS_LOCK,
+	
+	[0x1e] = KC_A,
+	[0x1f] = KC_S,
+	[0x20] = KC_D,
+	[0x21] = KC_F,
+	[0x22] = KC_G,
+	[0x23] = KC_H,
+	[0x24] = KC_J,
+	[0x25] = KC_K,
+	[0x26] = KC_L,
+	
+	[0x27] = KC_SEMICOLON,
+	[0x28] = KC_QUOTE,
+	[0x2b] = KC_BACKSLASH,
+	
+	[0x2a] = KC_LSHIFT,
+	
+	[0x2c] = KC_Z,
+	[0x2d] = KC_X,
+	[0x2e] = KC_C,
+	[0x2f] = KC_V,
+	[0x30] = KC_B,
+	[0x31] = KC_N,
+	[0x32] = KC_M,
+	
+	[0x33] = KC_COMMA,
+	[0x34] = KC_PERIOD,
+	[0x35] = KC_SLASH,
+	
+	[0x36] = KC_RSHIFT,
+	
+	[0x1d] = KC_LCTRL,
+	[0x38] = KC_LALT,
+	[0x39] = KC_SPACE,
+	
+	[0x01] = KC_ESCAPE,
+	
+	[0x3b] = KC_F1,
+	[0x3c] = KC_F2,
+	[0x3d] = KC_F3,
+	[0x3e] = KC_F4,
+	[0x3f] = KC_F5,
+	[0x40] = KC_F6,
+	[0x41] = KC_F7,
+	
+	[0x42] = KC_F8,
+	[0x43] = KC_F9,
+	[0x44] = KC_F10,
+	
+	[0x57] = KC_F11,
+	[0x58] = KC_F12,
+	
+	[0x46] = KC_SCROLL_LOCK,
+	
+	[0x1c] = KC_ENTER,
+	
+	[0x45] = KC_NUM_LOCK,
+	[0x37] = KC_NTIMES,
+	[0x4a] = KC_NMINUS,
+	[0x4e] = KC_NPLUS,
+	[0x47] = KC_N7,
+	[0x48] = KC_N8,
+	[0x49] = KC_N9,
+	[0x4b] = KC_N4,
+	[0x4c] = KC_N5,
+	[0x4d] = KC_N6,
+	[0x4f] = KC_N1,
+	[0x50] = KC_N2,
+	[0x51] = KC_N3,
+	[0x52] = KC_N0,
+	[0x53] = KC_NPERIOD
+};
+
+#define KBD_ACK  0xfa
+#define KBD_RESEND  0xfe
+#define KBD_SCANCODE_SET_EXTENDED  0xe0
+#define KBD_SCANCODE_SET_EXTENDED_SPECIAL  0xe1
+
+/** Scancode set 1 extended codes table */
+static const unsigned int scanmap_e0[] = {
+	[0x38] = KC_RALT,
+	[0x1d] = KC_RCTRL,
+	
+	[0x37] = KC_SYSREQ,
+	
+	[0x52] = KC_INSERT,
+	[0x47] = KC_HOME,
+	[0x49] = KC_PAGE_UP,
+	
+	[0x53] = KC_DELETE,
+	[0x4f] = KC_END,
+	[0x51] = KC_PAGE_DOWN,
+	
+	[0x48] = KC_UP,
+	[0x4b] = KC_LEFT,
+	[0x50] = KC_DOWN,
+	[0x4d] = KC_RIGHT,
+	
+	[0x35] = KC_NSLASH,
+	[0x1c] = KC_NENTER
+};
+
+#define KBD_CMD_SET_LEDS  0xed
+
+enum led_indicators {
+	LI_SCROLL = 0x01,
+	LI_NUM    = 0x02,
+	LI_CAPS   = 0x04
+};
+
+static void push_event(async_sess_t *sess, kbd_event_type_t type,
+    unsigned int key)
+{
+	async_exch_t *exch = async_exchange_begin(sess);
+	async_msg_4(exch, KBDEV_EVENT, type, key, 0, 0);
+	async_exchange_end(exch);
+}
+
+/** Get data and parse scancodes.
+ *
+ * @param arg Pointer to xt_kbd_t structure.
+ *
+ * @return EIO on error.
+ *
+ */
+static int polling(void *arg)
+{
+	const xt_kbd_t *kbd = arg;
+	
+	assert(kbd);
+	assert(kbd->parent_sess);
+	
+	async_exch_t *parent_exch = async_exchange_begin(kbd->parent_sess);
+	
+	while (true) {
+		if (!parent_exch)
+			parent_exch = async_exchange_begin(kbd->parent_sess);
+		
+		const unsigned int *map = scanmap_simple;
+		size_t map_size = sizeof(scanmap_simple) / sizeof(unsigned int);
+		
+		uint8_t code = 0;
+		ssize_t size = chardev_read(parent_exch, &code, 1);
+		if (size != 1)
+			return EIO;
+		
+		/* Ignore AT command reply */
+		if ((code == KBD_ACK) || (code == KBD_RESEND))
+			continue;
+		
+		/* Extended set */
+		if (code == KBD_SCANCODE_SET_EXTENDED) {
+			map = scanmap_e0;
+			map_size = sizeof(scanmap_e0) / sizeof(unsigned int);
+			
+			size = chardev_read(parent_exch, &code, 1);
+			if (size != 1)
+				return EIO;
+			
+			/* Handle really special keys */
+			
+			if (code == 0x2a) {  /* Print Screen */
+				size = chardev_read(parent_exch, &code, 1);
+				if (size != 1)
+					return EIO;
+				
+				if (code != 0xe0)
+					continue;
+				
+				size = chardev_read(parent_exch, &code, 1);
+				if (size != 1)
+					return EIO;
+				
+				if (code == 0x37)
+					push_event(kbd->client_sess, KEY_PRESS, KC_PRTSCR);
+				
+				continue;
+			}
+			
+			if (code == 0x46) {  /* Break */
+				size = chardev_read(parent_exch, &code, 1);
+				if (size != 1)
+					return EIO;
+				
+				if (code != 0xe0)
+					continue;
+				
+				size = chardev_read(parent_exch, &code, 1);
+				if (size != 1)
+					return EIO;
+				
+				if (code == 0xc6)
+					push_event(kbd->client_sess, KEY_PRESS, KC_BREAK);
+				
+				continue;
+			}
+		}
+		
+		/* Extended special set */
+		if (code == KBD_SCANCODE_SET_EXTENDED_SPECIAL) {
+			size = chardev_read(parent_exch, &code, 1);
+			if (size != 1)
+				return EIO;
+			
+			if (code != 0x1d)
+				continue;
+			
+			size = chardev_read(parent_exch, &code, 1);
+			if (size != 1)
+				return EIO;
+			
+			if (code != 0x45)
+				continue;
+			
+			size = chardev_read(parent_exch, &code, 1);
+			if (size != 1)
+				return EIO;
+			
+			if (code != 0xe1)
+				continue;
+			
+			size = chardev_read(parent_exch, &code, 1);
+			if (size != 1)
+				return EIO;
+			
+			if (code != 0x9d)
+				continue;
+			
+			size = chardev_read(parent_exch, &code, 1);
+			if (size != 1)
+				return EIO;
+			
+			if (code == 0xc5)
+				push_event(kbd->client_sess, KEY_PRESS, KC_PAUSE);
+			
+			continue;
+		}
+		
+		/* Bit 7 indicates press/release */
+		const kbd_event_type_t type =
+		    (code & 0x80) ? KEY_RELEASE : KEY_PRESS;
+		code &= ~0x80;
+		
+		const unsigned int key = (code < map_size) ? map[code] : 0;
+		
+		if (key != 0)
+			push_event(kbd->client_sess, type, key);
+		else
+			ddf_msg(LVL_WARN, "Unknown scancode: %hhx", code);
+	}
+}
+
+/** Default handler for IPC methods not handled by DDF.
+ *
+ * @param fun     Device function handling the call.
+ * @param icallid Call id.
+ * @param icall   Call data.
+ *
+ */
+static void default_connection_handler(ddf_fun_t *fun,
+    ipc_callid_t icallid, ipc_call_t *icall)
+{
+	const sysarg_t method = IPC_GET_IMETHOD(*icall);
+	xt_kbd_t *kbd = ddf_dev_data_get(ddf_fun_get_dev(fun));
+
+	switch (method) {
+	case KBDEV_SET_IND: {
+		/*
+		 * XT keyboards do not support setting mods,
+		 * assume AT keyboard with Scan Code Set 1.
+		 */
+		const unsigned mods = IPC_GET_ARG1(*icall);
+		const uint8_t status = 0 |
+		    ((mods & KM_CAPS_LOCK) ? LI_CAPS : 0) |
+		    ((mods & KM_NUM_LOCK) ? LI_NUM : 0) |
+		    ((mods & KM_SCROLL_LOCK) ? LI_SCROLL : 0);
+		uint8_t cmds[] = { KBD_CMD_SET_LEDS, status };
+		
+		async_exch_t *exch = async_exchange_begin(kbd->parent_sess);
+		const ssize_t size = chardev_write(exch, cmds, sizeof(cmds));
+		async_exchange_end(exch);
+		
+		async_answer_0(icallid, size < 0 ? size : EOK);
+		break;
+	}
+	/*
+	 * This might be ugly but async_callback_receive_start makes no
+	 * difference for incorrect call and malloc failure.
+	 */
+	case IPC_M_CONNECT_TO_ME: {
+		async_sess_t *sess =
+		    async_callback_receive_start(EXCHANGE_SERIALIZE, icall);
+		
+		/* Probably ENOMEM error, try again. */
+		if (sess == NULL) {
+			ddf_msg(LVL_WARN,
+			    "Failed creating callback session");
+			async_answer_0(icallid, EAGAIN);
+			break;
+		}
+		
+		if (kbd->client_sess == NULL) {
+			kbd->client_sess = sess;
+			ddf_msg(LVL_DEBUG, "Set client session");
+			async_answer_0(icallid, EOK);
+		} else {
+			ddf_msg(LVL_ERROR, "Client session already set");
+			async_answer_0(icallid, ELIMIT);
+		}
+		
+		break;
+	}
+	default:
+		ddf_msg(LVL_ERROR, "Unknown method: %d.", (int)method);
+		async_answer_0(icallid, EINVAL);
+		break;
+	}
+}
+
+/** Keyboard function ops. */
+static ddf_dev_ops_t kbd_ops = {
+	.default_handler = default_connection_handler
+};
+
+/** Initialize keyboard driver structure.
+ *
+ * @param kbd Keyboard driver structure to initialize.
+ * @param dev DDF device structure.
+ *
+ * Connects to parent, creates keyboard function, starts polling fibril.
+ *
+ */
+int xt_kbd_init(xt_kbd_t *kbd, ddf_dev_t *dev)
+{
+	assert(kbd);
+	assert(dev);
+	
+	kbd->client_sess = NULL;
+	kbd->parent_sess = ddf_dev_parent_sess_get(dev);
+	
+	if (!kbd->parent_sess) {
+		ddf_msg(LVL_ERROR, "Failed creating parent session.");
+		return EIO;
+	}
+	
+	kbd->kbd_fun = ddf_fun_create(dev, fun_exposed, "kbd");
+	if (!kbd->kbd_fun) {
+		ddf_msg(LVL_ERROR, "Failed creating function 'kbd'.");
+		return ENOMEM;
+	}
+	
+	ddf_fun_set_ops(kbd->kbd_fun, &kbd_ops);
+	
+	int ret = ddf_fun_bind(kbd->kbd_fun);
+	if (ret != EOK) {
+		ddf_msg(LVL_ERROR, "Failed binding function 'kbd'.");
+		ddf_fun_destroy(kbd->kbd_fun);
+		return EEXIST;
+	}
+	
+	ret = ddf_fun_add_to_category(kbd->kbd_fun, "keyboard");
+	if (ret != EOK) {
+		ddf_msg(LVL_ERROR, "Failed adding function 'kbd' to category "
+		    "'keyboard'.");
+		ddf_fun_unbind(kbd->kbd_fun);
+		ddf_fun_destroy(kbd->kbd_fun);
+		return ENOMEM;
+	}
+	
+	kbd->polling_fibril = fibril_create(polling, kbd);
+	if (!kbd->polling_fibril) {
+		ddf_msg(LVL_ERROR, "Failed creating polling fibril.");
+		ddf_fun_unbind(kbd->kbd_fun);
+		ddf_fun_destroy(kbd->kbd_fun);
+		return ENOMEM;
+	}
+	
+	fibril_add_ready(kbd->polling_fibril);
+	return EOK;
+}
Index: uspace/drv/hid/xtkbd/xtkbd.h
===================================================================
--- uspace/drv/hid/xtkbd/xtkbd.h	(revision d420b22fe09893c1b4117473e6787a4295055001)
+++ uspace/drv/hid/xtkbd/xtkbd.h	(revision d420b22fe09893c1b4117473e6787a4295055001)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2011 Jan Vesely
+ * 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 drvkbd
+ * @{
+ */
+/** @file
+ * @brief XT keyboard driver
+ */
+
+#ifndef _XT_KBD_H_
+#define _XT_KBD_H_
+
+#include <ddf/driver.h>
+#include <fibril.h>
+
+/** PC/XT keyboard driver structure. */
+typedef struct {
+	ddf_fun_t *kbd_fun;        /**< Keyboard function. */
+	async_sess_t *parent_sess; /**< Connection to device providing data. */
+	async_sess_t *client_sess; /**< Callback connection to client. */
+	fid_t polling_fibril;      /**< Fibril retrieving an parsing data. */
+} xt_kbd_t;
+
+extern int xt_kbd_init(xt_kbd_t *, ddf_dev_t *);
+
+#endif
+
+/**
+ * @}
+ */
Index: uspace/drv/hid/xtkbd/xtkbd.ma
===================================================================
--- uspace/drv/hid/xtkbd/xtkbd.ma	(revision d420b22fe09893c1b4117473e6787a4295055001)
+++ uspace/drv/hid/xtkbd/xtkbd.ma	(revision d420b22fe09893c1b4117473e6787a4295055001)
@@ -0,0 +1,1 @@
+100 char/xtkbd
