Index: boot/Makefile.common
===================================================================
--- boot/Makefile.common	(revision 0e126be78770a2c37ac932b2e25dd35bdc34e12e)
+++ boot/Makefile.common	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
@@ -142,5 +142,4 @@
 	$(USPACE_PATH)/app/ping/ping \
 	$(USPACE_PATH)/app/stats/stats \
-	$(USPACE_PATH)/app/usb/usb \
 	$(USPACE_PATH)/app/virtusbkbd/vuk \
 	$(USPACE_PATH)/app/tasks/tasks \
Index: uspace/Makefile
===================================================================
--- uspace/Makefile	(revision 0e126be78770a2c37ac932b2e25dd35bdc34e12e)
+++ uspace/Makefile	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
@@ -50,5 +50,4 @@
 	app/trace \
 	app/top \
-	app/usb \
 	app/virtusbkbd \
 	app/netstart \
Index: pace/app/usb/Makefile
===================================================================
--- uspace/app/usb/Makefile	(revision 0e126be78770a2c37ac932b2e25dd35bdc34e12e)
+++ 	(revision )
@@ -1,36 +1,0 @@
-#
-# Copyright (c) 2010 Vojtech Horky
-# 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 = ../..
-BINARY = usb
-LIBS = $(LIBUSB_PREFIX)/libusb.a
-EXTRA_CFLAGS = -I$(LIB_PREFIX)
-SOURCES = \
-	example.c
-
-include $(USPACE_PREFIX)/Makefile.common
Index: pace/app/usb/example.c
===================================================================
--- uspace/app/usb/example.c	(revision 0e126be78770a2c37ac932b2e25dd35bdc34e12e)
+++ 	(revision )
@@ -1,187 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * 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 usb
- * @{
- */
-/**
- * @file
- * @brief Simple application that connects to USB/HCD.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <vfs/vfs.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <str_error.h>
-#include <bool.h>
-#include <async.h>
-
-#include <usb/hcd.h>
-#include <usb/devreq.h>
-
-#define LOOPS 5
-#define MAX_SIZE_RECEIVE 64
-#define NAME "hcd-example"
-
-#define DEV_HCD_NAME "hcd-virt"
-
-#define __QUOTEME(x) #x
-#define _QUOTEME(x) __QUOTEME(x)
-
-#define VERBOSE_EXEC(cmd, fmt, ...) \
-	(printf("%s: %s" fmt "\n", NAME, _QUOTEME(cmd), __VA_ARGS__), cmd(__VA_ARGS__))
-
-#define EXEC2(cmd, fmt, ...) \
-	do { \
-		printf("%s: " fmt " = ", NAME, __VA_ARGS__); \
-		fflush(stdout); \
-		int _rc = cmd; \
-		if (_rc != EOK) { \
-			printf("E%d\n", _rc); \
-			printf("%s: ... aborting.\n", NAME); \
-			exit(_rc); \
-		} \
-		printf("EOK\n"); \
-	} while (false)
-#define EXEC(cmd, fmt, ...) \
-	EXEC2(cmd(__VA_ARGS__), _QUOTEME(cmd) fmt, __VA_ARGS__)
-
-static void fibril_sleep(size_t sec)
-{
-	while (sec-- > 0) {
-		async_usleep(1000*1000);
-	}
-}
-
-static void data_dump(uint8_t *data, size_t len)
-{
-	size_t i;
-	for (i = 0; i < len; i++) {
-		printf("  0x%02X", data[i]);
-		if (((i > 0) && (((i+1) % 10) == 0))
-		    || (i + 1 == len)) {
-			printf("\n");
-		}
-	}
-}
-
-int main(int argc, char * argv[])
-{
-	int hcd_phone = usb_hcd_connect(DEV_HCD_NAME);
-	if (hcd_phone < 0) {
-		printf("%s: Unable to start comunication with HCD at usb://%s (%d: %s).\n",
-		    NAME, DEV_HCD_NAME, hcd_phone, str_error(hcd_phone));
-		return 1;
-	}
-	
-	printf("%s: example communication with HCD\n", NAME);
-	
-	usb_target_t target = {0, 0};
-	usb_handle_t handle;
-	
-	
-	
-	usb_device_request_setup_packet_t setup_packet = {
-		.request_type = 0,
-		.request = USB_DEVREQ_SET_ADDRESS,
-		.index = 0,
-		.length = 0,
-	};
-	setup_packet.value = 5;
-	
-	printf("\n%s: === setting device address to %d ===\n", NAME,
-	    (int)setup_packet.value);
-	EXEC2(usb_hcd_async_transfer_control_write_setup(hcd_phone, target,
-	    &setup_packet, sizeof(setup_packet), &handle),
-	    "usb_hcd_async_transfer_control_write_setup(%d, {%d:%d}, &data, %u, &h)",
-	    hcd_phone, target.address, target.endpoint, sizeof(setup_packet));
-	    
-	EXEC(usb_hcd_async_wait_for, "(h=%x)", handle);
-	
-	EXEC2(usb_hcd_async_transfer_control_write_status(hcd_phone, target,
-	    &handle),
-	    "usb_hcd_async_transfer_control_write_status(%d, {%d:%d}, &h)",
-	    hcd_phone, target.address, target.endpoint);
-	
-	EXEC(usb_hcd_async_wait_for, "(h=%x)", handle);
-	
-	target.address = setup_packet.value;
-	
-	
-	printf("\n%s: === getting standard device descriptor ===\n", NAME);
-	usb_device_request_setup_packet_t get_descriptor = {
-		.request_type = 128,
-		.request = USB_DEVREQ_GET_DESCRIPTOR,
-		.index = 0,
-		.length = MAX_SIZE_RECEIVE,
-	};
-	get_descriptor.value_low = 0;
-	get_descriptor.value_high = 1;
-	
-	uint8_t descriptor[MAX_SIZE_RECEIVE];
-	size_t descriptor_length;
-	
-	EXEC2(usb_hcd_async_transfer_control_read_setup(hcd_phone, target,
-	    &get_descriptor, sizeof(get_descriptor), &handle),
-	    "usb_hcd_async_transfer_control_read_setup(%d, {%d:%d}, &data, %u, &h)",
-	    hcd_phone, target.address, target.endpoint, sizeof(get_descriptor));
-	
-	EXEC(usb_hcd_async_wait_for, "(h=%x)", handle);
-	
-	usb_handle_t data_handle;
-	EXEC2(usb_hcd_async_transfer_control_read_data(hcd_phone, target,
-	    descriptor, MAX_SIZE_RECEIVE, &descriptor_length, &data_handle),
-	    "usb_hcd_async_transfer_control_read_data(%d, {%d:%d}, &data, %u, &len, &h2)",
-	    hcd_phone, target.address, target.endpoint, MAX_SIZE_RECEIVE);
-	
-	EXEC2(usb_hcd_async_transfer_control_read_status(hcd_phone, target,
-	    &handle),
-	    "usb_hcd_async_transfer_control_read_status(%d, {%d:%d}, &h)",
-	    hcd_phone, target.address, target.endpoint);
-	
-	EXEC(usb_hcd_async_wait_for, "(h=%x)", handle);
-	EXEC(usb_hcd_async_wait_for, "(h2=%x)", data_handle);
-	
-	printf("%s: standard device descriptor dump (%dB):\n", NAME, descriptor_length);
-	data_dump(descriptor, descriptor_length);
-	
-	fibril_sleep(1);
-
-	printf("%s: exiting.\n", NAME);
-	
-	ipc_hangup(hcd_phone);
-	
-	return 0;
-}
-
-
-/** @}
- */
Index: uspace/app/virtusbkbd/Makefile
===================================================================
--- uspace/app/virtusbkbd/Makefile	(revision 0e126be78770a2c37ac932b2e25dd35bdc34e12e)
+++ uspace/app/virtusbkbd/Makefile	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
@@ -33,5 +33,5 @@
 
 LIBS = $(LIBUSB_PREFIX)/libusb.a $(LIBUSBVIRT_PREFIX)/libusbvirt.a
-EXTRA_CFLAGS = -I$(LIB_PREFIX)
+EXTRA_CFLAGS = -I$(LIBUSB_PREFIX)/include -I$(LIB_PREFIX)
 
 SOURCES = \
Index: uspace/app/virtusbkbd/kbdconfig.c
===================================================================
--- uspace/app/virtusbkbd/kbdconfig.c	(revision 0e126be78770a2c37ac932b2e25dd35bdc34e12e)
+++ uspace/app/virtusbkbd/kbdconfig.c	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
@@ -36,8 +36,8 @@
 #include "kbdconfig.h"
 #include "keys.h"
-#include <usb/hcd.h>
-#include <usb/hid.h>
-#include <usb/hidut.h>
-#include <usb/classes.h>
+#include <usb/usb.h>
+#include <usb/classes/hid.h>
+#include <usb/classes/hidut.h>
+#include <usb/classes/classes.h>
 
 /** Standard device descriptor. */
Index: uspace/app/virtusbkbd/keys.h
===================================================================
--- uspace/app/virtusbkbd/keys.h	(revision 0e126be78770a2c37ac932b2e25dd35bdc34e12e)
+++ uspace/app/virtusbkbd/keys.h	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
@@ -49,5 +49,5 @@
 /** USB key code. */
 typedef enum {
-	#include <usb/hidutkbd.h>
+	#include <usb/classes/hidutkbd.h>
 } key_code_t;
 
Index: uspace/app/virtusbkbd/virtusbkbd.c
===================================================================
--- uspace/app/virtusbkbd/virtusbkbd.c	(revision 0e126be78770a2c37ac932b2e25dd35bdc34e12e)
+++ uspace/app/virtusbkbd/virtusbkbd.c	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
@@ -45,7 +45,7 @@
 #include <async.h>
 
-#include <usb/hcd.h>
+#include <usb/usb.h>
 #include <usb/descriptor.h>
-#include <usb/hid.h>
+#include <usb/classes/hid.h>
 #include <usbvirt/device.h>
 #include <usbvirt/hub.h>
Index: uspace/drv/uhci/Makefile
===================================================================
--- uspace/drv/uhci/Makefile	(revision 0e126be78770a2c37ac932b2e25dd35bdc34e12e)
+++ uspace/drv/uhci/Makefile	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
@@ -29,5 +29,5 @@
 USPACE_PREFIX = ../..
 LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBUSB_PREFIX)/libusb.a
-EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIB_PREFIX)
+EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBUSB_PREFIX)/include
 BINARY = uhci
 
Index: uspace/drv/usbkbd/Makefile
===================================================================
--- uspace/drv/usbkbd/Makefile	(revision 0e126be78770a2c37ac932b2e25dd35bdc34e12e)
+++ uspace/drv/usbkbd/Makefile	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
@@ -29,5 +29,5 @@
 USPACE_PREFIX = ../..
 LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBUSB_PREFIX)/libusb.a
-EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIB_PREFIX)
+EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBUSB_PREFIX)/include
 BINARY = usbkbd
 
Index: uspace/drv/vhc/Makefile
===================================================================
--- uspace/drv/vhc/Makefile	(revision 0e126be78770a2c37ac932b2e25dd35bdc34e12e)
+++ uspace/drv/vhc/Makefile	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
@@ -34,4 +34,5 @@
 EXTRA_CFLAGS += \
 	-I$(LIB_PREFIX) \
+	-I$(LIBUSB_PREFIX)/include \
 	-I$(LIBDRV_PREFIX)/include
 BINARY = vhc
Index: uspace/drv/vhc/conn.h
===================================================================
--- uspace/drv/vhc/conn.h	(revision 0e126be78770a2c37ac932b2e25dd35bdc34e12e)
+++ uspace/drv/vhc/conn.h	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
@@ -36,5 +36,5 @@
 #define VHCD_CONN_H_
 
-#include <usb/hcd.h>
+#include <usb/usb.h>
 #include <usb/hcdhubd.h>
 #include "vhcd.h"
Index: uspace/drv/vhc/connhost.c
===================================================================
--- uspace/drv/vhc/connhost.c	(revision 0e126be78770a2c37ac932b2e25dd35bdc34e12e)
+++ uspace/drv/vhc/connhost.c	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
@@ -35,232 +35,9 @@
 #include <assert.h>
 #include <errno.h>
-#include <usb/hcd.h>
+#include <usb/usb.h>
 
 #include "vhcd.h"
 #include "conn.h"
 #include "hc.h"
-
-typedef struct {
-	ipc_callid_t caller;
-	void *buffer;
-	size_t size;
-} async_transaction_t;
-
-static void async_out_callback(void * buffer, size_t len,
-    usb_transaction_outcome_t outcome, void * arg)
-{
-	async_transaction_t * trans = (async_transaction_t *)arg;
-	
-	dprintf(2, "async_out_callback(buffer, %u, %d, %p) -> %x",
-	    len, outcome, arg, trans->caller);
-	
-	// FIXME - answer according to outcome
-	ipc_answer_1(trans->caller, EOK, 0);
-	
-	free(trans);
-	if (buffer) {
-		free(buffer);
-	}
-	dprintf(4, "async_out_callback answered");
-}
-
-static void async_to_device(ipc_callid_t iid, ipc_call_t icall, bool setup_transaction)
-{
-	size_t expected_len = IPC_GET_ARG3(icall);
-	usb_target_t target = {
-		.address = IPC_GET_ARG1(icall),
-		.endpoint = IPC_GET_ARG2(icall)
-	};
-	
-	dprintf(1, "async_to_device: dev=%d:%d, size=%d, iid=%x",
-	    target.address, target.endpoint, expected_len, iid);
-	
-	size_t len = 0;
-	void * buffer = NULL;
-	if (expected_len > 0) {
-		int rc = async_data_write_accept(&buffer, false,
-		    1, USB_MAX_PAYLOAD_SIZE,
-		    0, &len);
-		
-		if (rc != EOK) {
-			ipc_answer_0(iid, rc);
-			return;
-		}
-	}
-	
-	async_transaction_t * trans = malloc(sizeof(async_transaction_t));
-	trans->caller = iid;
-	trans->buffer = NULL;
-	trans->size = 0;
-	
-	hc_add_transaction_to_device(setup_transaction, target,
-	    buffer, len,
-	    async_out_callback, trans);
-	
-	dprintf(2, "async transaction to device scheduled (%p)", trans);
-}
-
-static void async_in_callback(void * buffer, size_t len,
-    usb_transaction_outcome_t outcome, void * arg)
-{	
-	async_transaction_t * trans = (async_transaction_t *)arg;
-	
-	dprintf(2, "async_in_callback(buffer, %u, %d, %p) -> %x",
-	    len, outcome, arg, trans->caller);
-	
-	trans->buffer = buffer;
-	trans->size = len;
-	
-	ipc_callid_t caller = trans->caller;
-	
-	if (buffer == NULL) {
-		free(trans);
-		trans = NULL;
-	}
-	
-	
-	// FIXME - answer according to outcome
-	ipc_answer_1(caller, EOK, (ipcarg_t)trans);
-	dprintf(4, "async_in_callback answered (%#x)", (ipcarg_t)trans);
-}
-
-static void async_from_device(ipc_callid_t iid, ipc_call_t icall)
-{
-	usb_target_t target = {
-		.address = IPC_GET_ARG1(icall),
-		.endpoint = IPC_GET_ARG2(icall)
-	};
-	size_t len = IPC_GET_ARG3(icall);
-	
-	dprintf(1, "async_from_device: dev=%d:%d, size=%d, iid=%x",
-	    target.address, target.endpoint, len, iid);
-	
-	void * buffer = NULL;
-	if (len > 0) {
-		buffer = malloc(len);
-	}
-	
-	async_transaction_t * trans = malloc(sizeof(async_transaction_t));
-	trans->caller = iid;
-	trans->buffer = NULL;
-	trans->size = 0;
-	
-	hc_add_transaction_from_device(target,
-	    buffer, len,
-	    async_in_callback, trans);
-	
-	dprintf(2, "async transfer from device scheduled (%p)", trans);
-}
-
-static void async_get_buffer(ipc_callid_t iid, ipc_call_t icall)
-{
-	ipcarg_t buffer_hash = IPC_GET_ARG1(icall);
-	async_transaction_t * trans = (async_transaction_t *)buffer_hash;
-	if (trans == NULL) {
-		ipc_answer_0(iid, ENOENT);
-		return;
-	}
-	if (trans->buffer == NULL) {
-		ipc_answer_0(iid, EINVAL);
-		free(trans);
-		return;
-	}
-	
-	ipc_callid_t callid;
-	size_t accepted_size;
-	if (!async_data_read_receive(&callid, &accepted_size)) {
-		ipc_answer_0(iid, EINVAL);
-		return;
-	}
-	
-	if (accepted_size > trans->size) {
-		accepted_size = trans->size;
-	}
-	async_data_read_finalize(callid, trans->buffer, accepted_size);
-	
-	ipc_answer_1(iid, EOK, accepted_size);
-	
-	free(trans->buffer);
-	free(trans);
-}
-
-
-/** Connection handler for communcation with host.
- * By host is typically meant top-level USB driver.
- *
- * This function also takes care of proper phone hung-up.
- *
- * @param phone_hash Incoming phone hash.
- */
-void connection_handler_host(ipcarg_t phone_hash)
-{
-	dprintf(0, "host connected through phone %#x", phone_hash);
-	
-	
-	while (true) {
-		ipc_callid_t callid;
-		ipc_call_t call;
-		
-		callid = async_get_call(&call);
-		
-		dprintf(6, "host on %#x calls [%x: %u (%u, %u, %u, %u, %u)]",
-		    phone_hash,
-		    callid,
-		    IPC_GET_METHOD(call),
-		    IPC_GET_ARG1(call), IPC_GET_ARG2(call), IPC_GET_ARG3(call),
-		    IPC_GET_ARG4(call), IPC_GET_ARG5(call));
-		
-		switch (IPC_GET_METHOD(call)) {
-
-			/* standard IPC methods */
-
-			case IPC_M_PHONE_HUNGUP:
-				ipc_answer_0(callid, EOK);
-				dprintf(0, "phone%#x: host hung-up",
-				    phone_hash);
-				return;
-			
-			case IPC_M_CONNECT_TO_ME:
-				ipc_answer_0(callid, ELIMIT);
-				break;
-			
-
-			/* USB methods */
-
-			case IPC_M_USB_HCD_TRANSACTION_SIZE:
-				ipc_answer_1(callid, EOK, USB_MAX_PAYLOAD_SIZE);
-				break;
-			
-			case IPC_M_USB_HCD_GET_BUFFER_ASYNC:
-				async_get_buffer(callid, call);
-				break;
-	
-			case IPC_M_USB_HCD_INTERRUPT_OUT_ASYNC:
-			case IPC_M_USB_HCD_CONTROL_WRITE_DATA_ASYNC:
-			case IPC_M_USB_HCD_CONTROL_READ_STATUS_ASYNC:
-				async_to_device(callid, call, false);
-				break;
-			
-			case IPC_M_USB_HCD_CONTROL_WRITE_SETUP_ASYNC:
-			case IPC_M_USB_HCD_CONTROL_READ_SETUP_ASYNC:
-				async_to_device(callid, call, true);
-				break;
-			
-			case IPC_M_USB_HCD_INTERRUPT_IN_ASYNC:
-			case IPC_M_USB_HCD_CONTROL_WRITE_STATUS_ASYNC:
-			case IPC_M_USB_HCD_CONTROL_READ_DATA_ASYNC:
-				async_from_device(callid, call);
-				break;
-			
-
-			/* end of known methods */
-			
-			default:
-				dprintf_inval_call(2, call, phone_hash);
-				ipc_answer_0(callid, EINVAL);
-				break;
-		}
-	}
-}
 
 static int enqueue_transfer_out(usb_hc_device_t *hc,
Index: uspace/drv/vhc/devices.h
===================================================================
--- uspace/drv/vhc/devices.h	(revision 0e126be78770a2c37ac932b2e25dd35bdc34e12e)
+++ uspace/drv/vhc/devices.h	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
@@ -37,5 +37,5 @@
 
 #include <adt/list.h>
-#include <usb/hcd.h>
+#include <usb/usb.h>
 
 #include "hc.h"
Index: uspace/drv/vhc/hc.h
===================================================================
--- uspace/drv/vhc/hc.h	(revision 0e126be78770a2c37ac932b2e25dd35bdc34e12e)
+++ uspace/drv/vhc/hc.h	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
@@ -36,5 +36,5 @@
 #define VHCD_HC_H_
 
-#include <usb/hcd.h>
+#include <usb/usb.h>
 #include <usbvirt/hub.h>
 
Index: uspace/drv/vhc/hcd.c
===================================================================
--- uspace/drv/vhc/hcd.c	(revision 0e126be78770a2c37ac932b2e25dd35bdc34e12e)
+++ uspace/drv/vhc/hcd.c	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
@@ -45,5 +45,5 @@
 #include <driver.h>
 
-#include <usb/hcd.h>
+#include <usb/usb.h>
 #include "vhcd.h"
 #include "hc.h"
Index: uspace/drv/vhc/hub.c
===================================================================
--- uspace/drv/vhc/hub.c	(revision 0e126be78770a2c37ac932b2e25dd35bdc34e12e)
+++ uspace/drv/vhc/hub.c	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
@@ -33,5 +33,5 @@
  * @brief Virtual USB hub.
  */
-#include <usb/classes.h>
+#include <usb/classes/classes.h>
 #include <usbvirt/hub.h>
 #include <usbvirt/device.h>
Index: uspace/drv/vhc/hubops.c
===================================================================
--- uspace/drv/vhc/hubops.c	(revision 0e126be78770a2c37ac932b2e25dd35bdc34e12e)
+++ uspace/drv/vhc/hubops.c	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
@@ -33,6 +33,6 @@
  * @brief Virtual USB hub operations.
  */
-#include <usb/classes.h>
-#include <usb/hub.h>
+#include <usb/classes/classes.h>
+#include <usb/classes/hub.h>
 #include <usbvirt/hub.h>
 #include <usbvirt/device.h>
Index: uspace/lib/drv/Makefile
===================================================================
--- uspace/lib/drv/Makefile	(revision 0e126be78770a2c37ac932b2e25dd35bdc34e12e)
+++ uspace/lib/drv/Makefile	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
@@ -29,5 +29,5 @@
 
 USPACE_PREFIX = ../..
-EXTRA_CFLAGS = -Iinclude -I$(LIB_PREFIX)
+EXTRA_CFLAGS = -Iinclude -I$(LIBUSB_PREFIX)/include
 LIBRARY = libdrv
 
Index: uspace/lib/usb/Makefile
===================================================================
--- uspace/lib/usb/Makefile	(revision 0e126be78770a2c37ac932b2e25dd35bdc34e12e)
+++ uspace/lib/usb/Makefile	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
@@ -30,11 +30,10 @@
 LIBRARY = libusb
 LIBS = $(LIBDRV_PREFIX)/libdrv.a
-EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIB_PREFIX)
+EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -Iinclude
 
 SOURCES = \
-	hcd.c \
-	hcdhubd.c \
-	usb.c \
-	usbdrv.c
+	src/hcdhubd.c \
+	src/usb.c \
+	src/usbdrv.c
 
 include $(USPACE_PREFIX)/Makefile.common
Index: pace/lib/usb/classes.h
===================================================================
--- uspace/lib/usb/classes.h	(revision 0e126be78770a2c37ac932b2e25dd35bdc34e12e)
+++ 	(revision )
@@ -1,66 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * 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 libusb usb
- * @{
- */
-/** @file
- * @brief USB device classes and subclasses.
- */
-#ifndef LIBUSB_CLASSES_H_
-#define LIBUSB_CLASSES_H_
-
-/** USB device class. */
-typedef enum {
-	USB_CLASS_USE_INTERFACE = 0x00,
-	USB_CLASS_AUDIO = 0x01,
-	USB_CLASS_COMMUNICATIONS_CDC_CONTROL = 0x02,
-	USB_CLASS_HID = 0x03,
-	USB_CLASS_PHYSICAL = 0x05,
-	USB_CLASS_IMAGE = 0x06,
-	USB_CLASS_PRINTER = 0x07,
-	USB_CLASS_MASS_STORAGE = 0x08,
-	USB_CLASS_HUB = 0x09,
-	USB_CLASS_CDC_DATA = 0x0A,
-	USB_CLASS_SMART_CARD = 0x0B,
-	USB_CLASS_CONTENT_SECURITY = 0x0D,
-	USB_CLASS_VIDEO = 0x0E,
-	USB_CLASS_PERSONAL_HEALTHCARE = 0x0F,
-	USB_CLASS_DIAGNOSTIC = 0xDC,
-	USB_CLASS_WIRELESS_CONTROLLER = 0xE0,
-	USB_CLASS_MISCELLANEOUS = 0xEF,
-	USB_CLASS_APPLICATION_SPECIFIC = 0xFE,
-	USB_CLASS_VENDOR_SPECIFIC = 0xFF,
-	/* USB_CLASS_ = 0x, */
-} usb_class_t;
-
-
-#endif
-/**
- * @}
- */
Index: pace/lib/usb/descriptor.h
===================================================================
--- uspace/lib/usb/descriptor.h	(revision 0e126be78770a2c37ac932b2e25dd35bdc34e12e)
+++ 	(revision )
@@ -1,176 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * 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 libusb usb
- * @{
- */
-/** @file
- * @brief Standard USB descriptors.
- */
-#ifndef LIBUSB_DESCRIPTOR_H_
-#define LIBUSB_DESCRIPTOR_H_
-
-#include <ipc/ipc.h>
-#include <async.h>
-
-/** Descriptor type. */
-typedef enum {
-	USB_DESCTYPE_DEVICE = 1,
-	USB_DESCTYPE_CONFIGURATION = 2,
-	USB_DESCTYPE_STRING = 3,
-	USB_DESCTYPE_INTERFACE = 4,
-	USB_DESCTYPE_ENDPOINT = 5,
-	USB_DESCTYPE_HID = 0x21,
-	USB_DESCTYPE_HID_REPORT = 0x22,
-	USB_DESCTYPE_HID_PHYSICAL = 0x23,
-	USB_DESCTYPE_HUB = 0x29,
-	/* USB_DESCTYPE_ = */
-} usb_descriptor_type_t;
-
-/** Standard USB device descriptor.
- */
-typedef struct {
-	/** Size of this descriptor in bytes. */
-	uint8_t length;
-	/** Descriptor type (USB_DESCTYPE_DEVICE). */
-	uint8_t descriptor_type;
-	/** USB specification release number.
-	 * The number shall be coded as binary-coded decimal (BCD).
-	 */
-	uint16_t usb_spec_version;
-	/** Device class. */
-	uint8_t device_class;
-	/** Device sub-class. */
-	uint8_t device_subclass;
-	/** Device protocol. */
-	uint8_t device_protocol;
-	/** Maximum packet size for endpoint zero.
-	 * Valid values are only 8, 16, 32, 64).
-	 */
-	uint8_t max_packet_size;
-	/** Vendor ID. */
-	uint16_t vendor_id;
-	/** Product ID. */
-	uint16_t product_id;
-	/** Device release number (in BCD). */
-	uint16_t device_version;
-	/** Manufacturer descriptor index. */
-	uint8_t str_manufacturer;
-	/** Product descriptor index. */
-	uint8_t str_product;
-	/** Device serial number desriptor index. */
-	uint8_t str_serial_number;
-	/** Number of possible configurations. */
-	uint8_t configuration_count;
-} __attribute__ ((packed)) usb_standard_device_descriptor_t;
-
-/** Standard USB configuration descriptor.
- */
-typedef struct {
-	/** Size of this descriptor in bytes. */
-	uint8_t length;
-	/** Descriptor type (USB_DESCTYPE_CONFIGURATION). */
-	uint8_t descriptor_type;
-	/** Total length of all data of this configuration.
-	 * This includes the combined length of all descriptors
-	 * (configuration, interface, endpoint, class-specific and
-	 * vendor-specific) valid for this configuration.
-	 */
-	uint16_t total_length;
-	/** Number of possible interfaces under this configuration. */
-	uint8_t interface_count;
-	/** Configuration value used when setting this configuration. */
-	uint8_t configuration_number;
-	/** String descriptor describing this configuration. */
-	uint8_t str_configuration;
-	/** Attribute bitmap. */
-	uint8_t attributes;
-	/** Maximum power consumption from the USB under this configuration.
-	 * Expressed in 2mA unit (e.g. 50 ~ 100mA).
-	 */
-	uint8_t max_power;
-} __attribute__ ((packed)) usb_standard_configuration_descriptor_t;
-
-/** Standard USB interface descriptor.
- */
-typedef struct {
-	/** Size of this descriptor in bytes. */
-	uint8_t length;
-	/** Descriptor type (USB_DESCTYPE_INTERFACE). */
-	uint8_t descriptor_type;
-	/** Number of interface.
-	 * Zero-based index into array of interfaces for current configuration.
-	 */
-	uint8_t interface_number;
-	/** Alternate setting for value in interface_number. */
-	uint8_t alternate_setting;
-	/** Number of endpoints used by this interface.
-	 * This number must exclude usage of endpoint zero
-	 * (default control pipe).
-	 */
-	uint8_t endpoint_count;
-	/** Class code. */
-	uint8_t interface_class;
-	/** Subclass code. */
-	uint8_t interface_subclass;
-	/** Protocol code. */
-	uint8_t interface_protocol;
-	/** String descriptor describing this interface. */
-	uint8_t str_interface;
-} __attribute__ ((packed)) usb_standard_interface_descriptor_t;
-
-/** Standard USB endpoint descriptor.
- */
-typedef struct {
-	/** Size of this descriptor in bytes. */
-	uint8_t length;
-	/** Descriptor type (USB_DESCTYPE_ENDPOINT). */
-	uint8_t descriptor_type;
-	/** Endpoint address together with data flow direction. */
-	uint8_t endpoint_address;
-	/** Endpoint attributes.
-	 * Includes transfer type (usb_transfer_type_t).
-	 */
-	uint8_t attributes;
-	/** Maximum packet size. */
-	uint16_t max_packet_size;
-	/** Polling interval in milliseconds.
-	 * Ignored for bulk and control endpoints.
-	 * Isochronous endpoints must use value 1.
-	 * Interrupt endpoints any value from 1 to 255.
-	 */
-	uint8_t poll_interval;
-} __attribute__ ((packed)) usb_standard_endpoint_descriptor_t;
-
-
-/* TODO: string descriptors. */
-
-#endif
-/**
- * @}
- */
Index: pace/lib/usb/devreq.h
===================================================================
--- uspace/lib/usb/devreq.h	(revision 0e126be78770a2c37ac932b2e25dd35bdc34e12e)
+++ 	(revision )
@@ -1,88 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * 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 libusb usb
- * @{
- */
-/** @file
- * @brief Standard USB device requests.
- */
-#ifndef LIBUSB_DEVREQ_H_
-#define LIBUSB_DEVREQ_H_
-
-#include <ipc/ipc.h>
-#include <async.h>
-
-/** Standard device request. */
-typedef enum {
-	USB_DEVREQ_GET_STATUS = 0,
-	USB_DEVREQ_CLEAR_FEATURE = 1,
-	USB_DEVREQ_SET_FEATURE = 3,
-	USB_DEVREQ_SET_ADDRESS = 5,
-	USB_DEVREQ_GET_DESCRIPTOR = 6,
-	USB_DEVREQ_SET_DESCRIPTOR = 7,
-	USB_DEVREQ_GET_CONFIGURATION = 8,
-	USB_DEVREQ_SET_CONFIGURATION = 9,
-	USB_DEVREQ_GET_INTERFACE = 10,
-	USB_DEVREQ_SET_INTERFACE = 11,
-	USB_DEVREQ_SYNCH_FRAME = 12,
-	USB_DEVREQ_LAST_STD
-} usb_stddevreq_t;
-
-/** Device request setup packet.
- * The setup packet describes the request.
- */
-typedef struct {
-	/** Request type.
-	 * The type combines transfer direction, request type and
-	 * intended recipient.
-	 */
-	uint8_t request_type;
-	/** Request identification. */
-	uint8_t request;
-	/** Main parameter to the request. */
-	union {
-		/* FIXME: add #ifdefs according to host endianess */
-		struct {
-			uint8_t value_low;
-			uint8_t value_high;
-		};
-		uint16_t value;
-	};
-	/** Auxilary parameter to the request.
-	 * Typically, it is offset to something.
-	 */
-	uint16_t index;
-	/** Length of extra data. */
-	uint16_t length;
-} __attribute__ ((packed)) usb_device_request_setup_packet_t;
-
-#endif
-/**
- * @}
- */
Index: pace/lib/usb/hcd.c
===================================================================
--- uspace/lib/usb/hcd.c	(revision 0e126be78770a2c37ac932b2e25dd35bdc34e12e)
+++ 	(revision )
@@ -1,417 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * 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 libusb usb
- * @{
- */
-/** @file
- * @brief USB Host Controller Driver (implementation).
- */
-#include "hcd.h"
-#include <devmap.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <vfs/vfs.h>
-#include <errno.h>
-
-/** Information about pending transaction on HC. */
-typedef struct {
-	/** Phone to host controller driver. */
-	int phone;
-	/** Data buffer. */
-	void *buffer;
-	/** Buffer size. */
-	size_t size;
-	/** Storage for actual number of bytes transferred. */
-	size_t *size_transferred;
-	/** Initial call replay data. */
-	ipc_call_t reply;
-	/** Initial call identifier. */
-	aid_t request;
-} transfer_info_t;
-
-#define NAMESPACE "usb"
-
-
-/** Create necessary phones for communicating with HCD.
- * This function wraps following calls:
- * -# open <code>/dev/usb/<i>hcd_path</i></code> for reading
- * -# access phone of file opened in previous step
- * -# return the (outgoing) phone
- *
- * @warning This function is wrapper for several actions and therefore
- * it is not possible - in case of error - to determine at which point
- * error occurred.
- *
- * @param hcd_path HCD identification under devfs
- *     (without <code>/dev/usb/</code>).
- * @return Phone for communicating with HCD or error code from errno.h.
- */
-int usb_hcd_connect(const char * hcd_path)
-{
-	char dev_path[DEVMAP_NAME_MAXLEN + 1];
-	snprintf(dev_path, DEVMAP_NAME_MAXLEN,
-	    "/dev/%s/%s", NAMESPACE, hcd_path);
-	
-	int fd = open(dev_path, O_RDONLY);
-	if (fd < 0) {
-		return fd;
-	}
-	
-	int hcd_phone = fd_phone(fd);
-	
-	if (hcd_phone < 0) {
-		return hcd_phone;
-	}
-
-	return hcd_phone;
-}
-
-/** Send data to HCD.
- *
- * @param phone Opened phone to HCD.
- * @param method Method used for calling.
- * @param target Target device.
- * @param buffer Data buffer (NULL to skip data transfer phase).
- * @param size Buffer size (must be zero when @p buffer is NULL).
- * @param handle Storage for transaction handle (cannot be NULL).
- * @return Error status.
- * @retval EINVAL Invalid parameter.
- * @retval ENOMEM Not enough memory to complete the operation.
- */
-static int async_send_buffer(int phone, int method,
-    usb_target_t target,
-    void *buffer, size_t size,
-    usb_handle_t *handle)
-{
-	if (phone < 0) {
-		return EINVAL;
-	}
-	
-	if ((buffer == NULL) && (size > 0)) {
-		return EINVAL;
-	}
-	
-	if (handle == NULL) {
-		return EINVAL;
-	}
-
-	transfer_info_t *transfer
-	    = (transfer_info_t *) malloc(sizeof(transfer_info_t));
-	if (transfer == NULL) {
-		return ENOMEM;
-	}
-	
-	transfer->size_transferred = NULL;
-	transfer->buffer = NULL;
-	transfer->size = 0;
-	transfer->phone = phone;
-
-	int rc;
-	
-	transfer->request = async_send_3(phone,
-	    method,
-	    target.address, target.endpoint,
-	    size,
-	    &transfer->reply);
-	
-	if (size > 0) {
-		rc = async_data_write_start(phone, buffer, size);
-		if (rc != EOK) {
-			async_wait_for(transfer->request, NULL);
-			return rc;
-		}
-	}
-	
-	*handle = (usb_handle_t) transfer;
-	
-	return EOK;
-}
-
-/** Prepare data retrieval.
- *
- * @param phone Opened phone to HCD.
- * @param method Method used for calling.
- * @param target Target device.
- * @param buffer Buffer where to store retrieved data
- * 	(NULL to skip data transfer phase).
- * @param size Buffer size (must be zero when @p buffer is NULL).
- * @param actual_size Storage where actual number of bytes transferred will
- * 	be stored.
- * @param handle Storage for transaction handle (cannot be NULL).
- * @return Error status.
- * @retval EINVAL Invalid parameter.
- * @retval ENOMEM Not enough memory to complete the operation.
- */
-static int async_recv_buffer(int phone, int method,
-    usb_target_t target,
-    void *buffer, size_t size, size_t *actual_size,
-    usb_handle_t *handle)
-{
-	if (phone < 0) {
-		return EINVAL;
-	}
-	
-	if ((buffer == NULL) && (size > 0)) {
-		return EINVAL;
-	}
-	
-	if (handle == NULL) {
-		return EINVAL;
-	}
-
-	transfer_info_t *transfer
-	    = (transfer_info_t *) malloc(sizeof(transfer_info_t));
-	if (transfer == NULL) {
-		return ENOMEM;
-	}
-	
-	transfer->size_transferred = actual_size;
-	transfer->buffer = buffer;
-	transfer->size = size;
-	transfer->phone = phone;
-	
-	transfer->request = async_send_3(phone,
-	    method,
-	    target.address, target.endpoint,
-	    size,
-	    &transfer->reply);
-	
-	*handle = (usb_handle_t) transfer;
-	
-	return EOK;
-}
-
-/** Read buffer from HCD.
- *
- * @param phone Opened phone to HCD.
- * @param hash Buffer hash (obtained after completing IN transaction).
- * @param buffer Buffer where to store data data.
- * @param size Buffer size.
- * @param actual_size Storage where actual number of bytes transferred will
- * 	be stored.
- * @return Error status.
- */
-static int read_buffer_in(int phone, ipcarg_t hash,
-    void *buffer, size_t size, size_t *actual_size)
-{
-	ipc_call_t answer_data;
-	ipcarg_t answer_rc;
-	aid_t req;
-	int rc;
-	
-	req = async_send_1(phone,
-	    IPC_M_USB_HCD_GET_BUFFER_ASYNC,
-	    hash,
-	    &answer_data);
-	
-	rc = async_data_read_start(phone, buffer, size);
-	if (rc != EOK) {
-		async_wait_for(req, NULL);
-		return EINVAL;
-	}
-	
-	async_wait_for(req, &answer_rc);
-	rc = (int)answer_rc;
-	
-	if (rc != EOK) {
-		return rc;
-	}
-	
-	*actual_size = IPC_GET_ARG1(answer_data);
-	
-	return EOK;
-}
-
-/** Blocks caller until given USB transaction is finished.
- * After the transaction is finished, the user can access all output data
- * given to initial call function.
- *
- * @param handle Transaction handle.
- * @return Error status.
- * @retval EOK No error.
- * @retval EBADMEM Invalid handle.
- * @retval ENOENT Data buffer associated with transaction does not exist.
- */
-int usb_hcd_async_wait_for(usb_handle_t handle)
-{
-	if (handle == 0) {
-		return EBADMEM;
-	}
-	
-	int rc = EOK;
-	
-	transfer_info_t *transfer = (transfer_info_t *) handle;
-	
-	ipcarg_t answer_rc;
-	async_wait_for(transfer->request, &answer_rc);
-	
-	if (answer_rc != EOK) {
-		rc = (int) answer_rc;
-		goto leave;
-	}
-	
-	/*
-	 * If the buffer is not NULL, we must accept some data.
-	 */
-	if ((transfer->buffer != NULL) && (transfer->size > 0)) {
-		/*
-		 * The buffer hash identifies the data on the server
-		 * side.
-		 * We will use it when actually reading-in the data.
-		 */
-		ipcarg_t buffer_hash = IPC_GET_ARG1(transfer->reply);
-		if (buffer_hash == 0) {
-			rc = ENOENT;
-			goto leave;
-		}
-		
-		size_t actual_size;
-		rc = read_buffer_in(transfer->phone, buffer_hash,
-		    transfer->buffer, transfer->size, &actual_size);
-		
-		if (rc != EOK) {
-			goto leave;
-		}
-		
-		if (transfer->size_transferred) {
-			*(transfer->size_transferred) = actual_size;
-		}
-	}
-	
-leave:
-	free(transfer);
-	
-	return rc;
-}
-
-/** Send interrupt data to device. */
-int usb_hcd_async_transfer_interrupt_out(int hcd_phone,
-    usb_target_t target,
-    void *buffer, size_t size,
-    usb_handle_t *handle)
-{
-	return async_send_buffer(hcd_phone,
-	    IPC_M_USB_HCD_INTERRUPT_OUT_ASYNC,
-	    target,
-	    buffer, size,
-	    handle);
-}
-
-/** Request interrupt data from device. */
-int usb_hcd_async_transfer_interrupt_in(int hcd_phone,
-    usb_target_t target,
-    void *buffer, size_t size, size_t *actual_size,
-    usb_handle_t *handle)
-{
-	return async_recv_buffer(hcd_phone,
-	    IPC_M_USB_HCD_INTERRUPT_IN_ASYNC,
-	    target,
-	    buffer, size, actual_size,
-	    handle);
-}
-
-/** Start WRITE control transfer. */
-int usb_hcd_async_transfer_control_write_setup(int hcd_phone,
-    usb_target_t target,
-    void *buffer, size_t size,
-    usb_handle_t *handle)
-{
-	return async_send_buffer(hcd_phone,
-	    IPC_M_USB_HCD_CONTROL_WRITE_SETUP_ASYNC,
-	    target,
-	    buffer, size,
-	    handle);
-}
-
-/** Send data during WRITE control transfer. */
-int usb_hcd_async_transfer_control_write_data(int hcd_phone,
-    usb_target_t target,
-    void *buffer, size_t size,
-    usb_handle_t *handle)
-{
-	return async_send_buffer(hcd_phone,
-	    IPC_M_USB_HCD_CONTROL_WRITE_DATA_ASYNC,
-	    target,
-	    buffer, size,
-	    handle);
-}
-
-/** Terminate WRITE control transfer. */
-int usb_hcd_async_transfer_control_write_status(int hcd_phone,
-    usb_target_t target,
-    usb_handle_t *handle)
-{
-	return async_recv_buffer(hcd_phone,
-	    IPC_M_USB_HCD_CONTROL_WRITE_STATUS_ASYNC,
-	    target,
-	    NULL, 0, NULL,
-	    handle);
-}
-
-/** Start READ control transfer. */
-int usb_hcd_async_transfer_control_read_setup(int hcd_phone,
-    usb_target_t target,
-    void *buffer, size_t size,
-    usb_handle_t *handle)
-{
-	return async_send_buffer(hcd_phone,
-	    IPC_M_USB_HCD_CONTROL_READ_SETUP_ASYNC,
-	    target,
-	    buffer, size,
-	    handle);
-}
-
-/** Request data during READ control transfer. */
-int usb_hcd_async_transfer_control_read_data(int hcd_phone,
-    usb_target_t target,
-    void *buffer, size_t size, size_t *actual_size,
-    usb_handle_t *handle)
-{
-	return async_recv_buffer(hcd_phone,
-	    IPC_M_USB_HCD_CONTROL_READ_DATA_ASYNC,
-	    target,
-	    buffer, size, actual_size,
-	    handle);
-}
-
-/** Terminate READ control transfer. */
-int usb_hcd_async_transfer_control_read_status(int hcd_phone,
-    usb_target_t target,
-    usb_handle_t *handle)
-{
-	return async_send_buffer(hcd_phone,
-	    IPC_M_USB_HCD_CONTROL_READ_STATUS_ASYNC,
-	    target,
-	    NULL, 0,
-	    handle);
-}
-
-/**
- * @}
- */
Index: pace/lib/usb/hcd.h
===================================================================
--- uspace/lib/usb/hcd.h	(revision 0e126be78770a2c37ac932b2e25dd35bdc34e12e)
+++ 	(revision )
@@ -1,253 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * 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 libusb usb
- * @{
- */
-/** @file
- * @brief USB Host Controller Driver.
- */
-#ifndef LIBUSB_HCD_H_
-#define LIBUSB_HCD_H_
-
-#include "usb.h"
-
-#include <ipc/ipc.h>
-#include <async.h>
-
-/** Maximum size of transaction payload. */
-#define USB_MAX_PAYLOAD_SIZE 1020
-
-/** Opaque handle of active USB transaction.
- * This handle is when informing about transaction outcome (or status).
- */
-typedef ipcarg_t usb_transaction_handle_t;
-
-
-/** USB packet identifier. */
-typedef enum {
-#define _MAKE_PID_NIBBLE(tag, type) \
-	((uint8_t)(((tag) << 2) | (type)))
-#define _MAKE_PID(tag, type) \
-	( \
-	    _MAKE_PID_NIBBLE(tag, type) \
-	    | ((~_MAKE_PID_NIBBLE(tag, type)) << 4) \
-	)
-	USB_PID_OUT = _MAKE_PID(0, 1),
-	USB_PID_IN = _MAKE_PID(2, 1),
-	USB_PID_SOF = _MAKE_PID(1, 1),
-	USB_PID_SETUP = _MAKE_PID(3, 1),
-	
-	USB_PID_DATA0 = _MAKE_PID(0 ,3),
-	USB_PID_DATA1 = _MAKE_PID(2 ,3),
-	
-	USB_PID_ACK = _MAKE_PID(0 ,2),
-	USB_PID_NAK = _MAKE_PID(2 ,2),
-	USB_PID_STALL = _MAKE_PID(3 ,2),
-	
-	USB_PID_PRE = _MAKE_PID(3 ,0),
-	/* USB_PID_ = _MAKE_PID( ,), */
-#undef _MAKE_PID
-#undef _MAKE_PID_NIBBLE
-} usb_packet_id;
-
-/** IPC methods for HCD.
- *
- * Notes for async methods:
- *
- * Methods for sending data to device (OUT transactions)
- * - e.g. IPC_M_USB_HCD_INTERRUPT_OUT_ASYNC -
- * always use the same semantics:
- * - first, IPC call with given method is made
- *   - argument #1 is target address
- *   - argument #2 is target endpoint
- *   - argument #3 is buffer size
- * - this call is immediately followed by IPC data write (from caller)
- * - the initial call (and the whole transaction) is answer after the
- *   transaction is scheduled by the HC and acknowledged by the device
- *   or immediatelly after error is detected
- * - the answer carries only the error code
- *
- * Methods for retrieving data from device (IN transactions)
- * - e.g. IPC_M_USB_HCD_INTERRUPT_IN_ASYNC -
- * also use the same semantics:
- * - first, IPC call with given method is made
- *   - argument #1 is target address
- *   - argument #2 is target endpoint
- *   - argument #3 is buffer size
- * - the call is not answered until the device returns some data (or until
- *   error occurs)
- * - if the call is answered with EOK, first argument of the answer is buffer
- *   hash that could be used to retrieve the actual data
- *
- * Some special methods (NO-DATA transactions) do not send any data. These
- * might behave as both OUT or IN transactions because communication parts
- * where actual buffers are exchanged are ommitted.
- *
- * The mentioned data retrieval can be done any time after receiving EOK
- * answer to IN method.
- * This retrieval is done using the IPC_M_USB_HCD_GET_BUFFER_ASYNC where
- * the first argument is buffer hash from call answer.
- * This call must be immediatelly followed by data read-in and after the
- * data are transferred, the initial call (IPC_M_USB_HCD_GET_BUFFER_ASYNC)
- * is answered. Each buffer can be retrieved only once.
- *
- * For all these methods, wrap functions exists. Important rule: functions
- * for IN transactions have (as parameters) buffers where retrieved data
- * will be stored. These buffers must be already allocated and shall not be
- * touch until the transaction is completed
- * (e.g. not before calling usb_hcd_async_wait_for() with appropriate handle).
- * OUT transactions buffers can be freed immediatelly after call is dispatched
- * (i.e. after return from wrapping function).
- *
- */
-typedef enum {
-	/** Tell maximum size of the transaction buffer (payload).
-	 * 
-	 * Arguments of the call:
-	 *  (none)
-	 * 
-	 * Answer:
-	 * - EOK - always
-	 * 
-	 * Arguments of the answer:
-	 * - buffer size (in bytes):
-	 */
-	IPC_M_USB_HCD_TRANSACTION_SIZE = IPC_FIRST_USER_METHOD,
-	
-	/** Asks for data buffer.
-	 * See explanation at usb_hcd_method_t.
-	 */
-	IPC_M_USB_HCD_GET_BUFFER_ASYNC,
-	
-	
-	
-	/** Send interrupt data to device.
-	 * See explanation at usb_hcd_method_t (OUT transaction).
-	 */
-	IPC_M_USB_HCD_INTERRUPT_OUT_ASYNC,
-	
-	/** Get interrupt data from device.
-	 * See explanation at usb_hcd_method_t (IN transaction).
-	 */
-	IPC_M_USB_HCD_INTERRUPT_IN_ASYNC,
-	
-	
-	/** Start WRITE control transfer.
-	 * See explanation at usb_hcd_method_t (OUT transaction).
-	 */
-	IPC_M_USB_HCD_CONTROL_WRITE_SETUP_ASYNC,
-	
-	/** Send control-transfer data to device.
-	 * See explanation at usb_hcd_method_t (OUT transaction).
-	 */
-	IPC_M_USB_HCD_CONTROL_WRITE_DATA_ASYNC,
-	
-	/** Terminate WRITE control transfer.
-	 * See explanation at usb_hcd_method_t (NO-DATA transaction).
-	 */
-	IPC_M_USB_HCD_CONTROL_WRITE_STATUS_ASYNC,
-	
-	
-	
-	/** Start READ control transfer.
-	 * See explanation at usb_hcd_method_t (OUT transaction).
-	 */
-	IPC_M_USB_HCD_CONTROL_READ_SETUP_ASYNC,
-	
-	/** Get control-transfer data from device.
-	 * See explanation at usb_hcd_method_t (IN transaction).
-	 */
-	IPC_M_USB_HCD_CONTROL_READ_DATA_ASYNC,
-	
-	/** Terminate READ control transfer.
-	 * See explanation at usb_hcd_method_t (NO-DATA transaction).
-	 */
-	IPC_M_USB_HCD_CONTROL_READ_STATUS_ASYNC,
-	
-	
-	/* IPC_M_USB_HCD_ */
-} usb_hcd_method_t;
-
-/** IPC methods for callbacks from HCD. */
-typedef enum {
-	/** Confimation after data sent.
-	 * 
-	 * Arguments of the call:
-	 * - transaction handle
-	 * - transaction outcome
-	 */
-	IPC_M_USB_HCD_DATA_SENT = IPC_FIRST_USER_METHOD,
-	
-	/** Notification of data received.
-	 * This call initiates sending a data buffer from HCD to the client.
-	 * See IPC_M_USB_HCD_SEND_DATA for details for buffer transfer is
-	 * done.
-	 * 
-	 * Arguments of the call:
-	 * - transaction handle
-	 * - transaction outcome
-	 * - actual data length
-	 */
-	IPC_M_USB_HCD_DATA_RECEIVED,
-	
-	/** Notification about a serious trouble with HC.
-	 */
-	IPC_M_USB_HCD_CONTROLLER_FAILURE,
-	
-	/* IPC_M_USB_HCD_ */
-} usb_hcd_callback_method_t;
-
-
-int usb_hcd_connect(const char *);
-
-int usb_hcd_async_transfer_interrupt_out(int, usb_target_t,
-    void *, size_t, usb_handle_t *);
-int usb_hcd_async_transfer_interrupt_in(int, usb_target_t,
-    void *, size_t, size_t *, usb_handle_t *);
-
-int usb_hcd_async_transfer_control_write_setup(int, usb_target_t,
-    void *, size_t, usb_handle_t *);
-int usb_hcd_async_transfer_control_write_data(int, usb_target_t,
-    void *, size_t, usb_handle_t *);
-int usb_hcd_async_transfer_control_write_status(int, usb_target_t,
-    usb_handle_t *);
-
-int usb_hcd_async_transfer_control_read_setup(int, usb_target_t,
-    void *, size_t, usb_handle_t *);
-int usb_hcd_async_transfer_control_read_data(int, usb_target_t,
-    void *, size_t, size_t *, usb_handle_t *);
-int usb_hcd_async_transfer_control_read_status(int, usb_target_t,
-    usb_handle_t *);
-
-int usb_hcd_async_wait_for(usb_handle_t);
-
-#endif
-/**
- * @}
- */
Index: pace/lib/usb/hcdhubd.c
===================================================================
--- uspace/lib/usb/hcdhubd.c	(revision 0e126be78770a2c37ac932b2e25dd35bdc34e12e)
+++ 	(revision )
@@ -1,349 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * 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 libusb usb
- * @{
- */
-/** @file
- * @brief HC driver and hub driver (implementation).
- */
-#include "hcdhubd.h"
-#include <usb_iface.h>
-#include <driver.h>
-#include <bool.h>
-#include <errno.h>
-
-/** List of handled host controllers. */
-static LIST_INITIALIZE(hc_list);
-
-/** Our HC driver. */
-static usb_hc_driver_t *hc_driver = NULL;
-
-static usb_iface_t usb_interface = {
-	.interrupt_out = NULL,
-	.interrupt_in = NULL
-};
-
-static device_ops_t usb_device_ops = {
-	.interfaces[USB_DEV_IFACE] = &usb_interface
-};
-
-/** Callback when new device is detected and must be handled by this driver.
- *
- * @param dev New device.
- * @return Error code.
- */
-static int add_device(device_t *dev)
-{
-	/*
-	 * FIXME: use some magic to determine whether hub or another HC
-	 * was connected.
-	 */
-	bool is_hc = true;
-
-	if (is_hc) {
-		/*
-		 * We are the HC itself.
-		 */
-		usb_hc_device_t *hc_dev = malloc(sizeof(usb_hc_device_t));
-		list_initialize(&hc_dev->link);
-		hc_dev->transfer_ops = NULL;
-
-		hc_dev->generic = dev;
-		dev->ops = &usb_device_ops;
-		hc_dev->generic->driver_data = hc_dev;
-
-		int rc = hc_driver->add_hc(hc_dev);
-		if (rc != EOK) {
-			free(hc_dev);
-			return rc;
-		}
-
-		/*
-		 * FIXME: The following line causes devman to hang.
-		 * Will investigate later why.
-		 */
-		// add_device_to_class(dev, "usbhc");
-
-		list_append(&hc_dev->link, &hc_list);
-
-		return EOK;
-	} else {
-		/*
-		 * We are some (probably deeply nested) hub.
-		 * Thus, assign our own operations and explore already
-		 * connected devices.
-		 */
-		return ENOTSUP;
-	}
-}
-
-/** Check changes on all known hubs.
- */
-static void check_hub_changes(void)
-{
-	/*
-	 * Iterate through all HCs.
-	 */
-	link_t *link_hc;
-	for (link_hc = hc_list.next;
-	    link_hc != &hc_list;
-	    link_hc = link_hc->next) {
-		usb_hc_device_t *hc = list_get_instance(link_hc,
-		    usb_hc_device_t, link);
-		/*
-		 * Iterate through all their hubs.
-		 */
-		link_t *link_hub;
-		for (link_hub = hc->hubs.next;
-		    link_hub != &hc->hubs;
-		    link_hub = link_hub->next) {
-			usb_hcd_hub_info_t *hub = list_get_instance(link_hub,
-			    usb_hcd_hub_info_t, link);
-
-			/*
-			 * Check status change pipe of this hub.
-			 */
-			usb_target_t target = {
-				.address = hub->device->address,
-				.endpoint = 1
-			};
-
-			// FIXME: count properly
-			size_t byte_length = (hub->port_count / 8) + 1;
-
-			void *change_bitmap = malloc(byte_length);
-			size_t actual_size;
-			usb_handle_t handle;
-
-			/*
-			 * Send the request.
-			 * FIXME: check returned value for possible errors
-			 */
-			usb_hc_async_interrupt_in(hc, target,
-			    change_bitmap, byte_length, &actual_size,
-			    &handle);
-
-			usb_hc_async_wait_for(handle);
-
-			/*
-			 * TODO: handle the changes.
-			 */
-		}
-	}
-}
-
-/** Operations for combined HC and HUB driver. */
-static driver_ops_t hc_driver_generic_ops = {
-	.add_device = add_device
-};
-
-/** Combined HC and HUB driver. */
-static driver_t hc_driver_generic = {
-	.driver_ops = &hc_driver_generic_ops
-};
-
-/** Main USB host controller driver routine.
- *
- * @see driver_main
- *
- * @param hc Host controller driver.
- * @return Error code.
- */
-int usb_hcd_main(usb_hc_driver_t *hc)
-{
-	hc_driver = hc;
-	hc_driver_generic.name = hc->name;
-
-	/*
-	 * Launch here fibril that will periodically check all
-	 * attached hubs for status change.
-	 * WARN: This call will effectively do nothing.
-	 */
-	check_hub_changes();
-
-	/*
-	 * Run the device driver framework.
-	 */
-	return driver_main(&hc_driver_generic);
-}
-
-/** Add a root hub for given host controller.
- * This function shall be called only once for each host controller driven
- * by this driver.
- * It takes care of creating child device - hub - that will be driven by
- * this task.
- *
- * @param dev Host controller device.
- * @return Error code.
- */
-int usb_hcd_add_root_hub(usb_hc_device_t *dev)
-{
-	int rc;
-
-	/*
-	 * For testing/debugging purposes only.
-	 * Try to send some data to default USB address.
-	 */
-	usb_target_t target = {0, 0};
-	usb_handle_t handle = 0;
-	char *data = (char *) "Hello, World!";
-
-
-	(void)usb_hc_async_interrupt_out(dev, target, data, str_length(data), &handle);
-	(void)usb_hc_async_wait_for(handle);
-
-	/*
-	 * Announce presence of child device.
-	 */
-	device_t *hub = NULL;
-	match_id_t *match_id = NULL;
-
-	hub = create_device();
-	if (hub == NULL) {
-		rc = ENOMEM;
-		goto failure;
-	}
-	hub->name = "usbhub";
-
-	match_id = create_match_id();
-	if (match_id == NULL) {
-		rc = ENOMEM;
-		goto failure;
-	}
-
-	char *id;
-	rc = asprintf(&id, "usb&hc=%s&hub", dev->generic->name);
-	if (rc <= 0) {
-		rc = ENOMEM;
-		goto failure;
-	}
-
-	match_id->id = id;
-	match_id->score = 30;
-
-	add_match_id(&hub->match_ids, match_id);
-
-	rc = child_device_register(hub, dev->generic);
-	if (rc != EOK) {
-		goto failure;
-	}
-
-	printf("%s: registered root hub\n", dev->generic->name);
-	return EOK;
-
-failure:
-	if (hub != NULL) {
-		hub->name = NULL;
-		delete_device(hub);
-	}
-	delete_match_id(match_id);
-
-	return rc;
-}
-
-/** Issue interrupt OUT transfer to HC driven by current task.
- *
- * @param hc Host controller to handle the transfer.
- * @param target Target device address.
- * @param buffer Data buffer.
- * @param size Buffer size.
- * @param handle Transfer handle.
- * @return Error code.
- */
-int usb_hc_async_interrupt_out(usb_hc_device_t *hc, usb_target_t target,
-    void *buffer, size_t size,
-    usb_handle_t *handle)
-{
-	if ((hc->transfer_ops == NULL)
-	    || (hc->transfer_ops->transfer_out == NULL)) {
-		return ENOTSUP;
-	}
-
-	/*
-	 * For debugging purposes only.
-	 * We need to find appropriate device in list of managed device
-	 * and pass it to the transfer callback function.
-	 */
-	usb_hcd_attached_device_info_t dev = {
-		.address = target.address,
-		.endpoint_count = 0,
-		.endpoints = NULL,
-	};
-	usb_hc_endpoint_info_t endpoint = {
-		.endpoint = target.endpoint,
-		.transfer_type = USB_TRANSFER_INTERRUPT,
-		.direction = USB_DIRECTION_OUT,
-		.data_toggle = 0
-	};
-
-	hc->transfer_ops->transfer_out(hc, &dev, &endpoint, buffer, size, NULL, NULL);
-
-	*handle = NULL;
-
-	return EOK;
-}
-
-
-/** Issue interrupt IN transfer to HC driven by current task.
- *
- * @warning The @p buffer and @p actual_size parameters shall not be
- * touched until this transfer is waited for by usb_hc_async_wait_for().
- *
- * @param hc Host controller to handle the transfer.
- * @param target Target device address.
- * @param buffer Data buffer.
- * @param size Buffer size.
- * @param actual_size Size of actually transferred data.
- * @param handle Transfer handle.
- * @return Error code.
- */
-int usb_hc_async_interrupt_in(usb_hc_device_t *hc, usb_target_t target,
-    void *buffer, size_t size, size_t *actual_size,
-    usb_handle_t *handle)
-{
-	/*
-	 * TODO: verify that given endpoint is of interrupt type and
-	 * call hc->transfer_ops->transfer_in()
-	 */
-	return ENOTSUP;
-}
-
-/** Wait for transfer to complete.
- *
- * @param handle Transfer handle.
- * @return Error code.
- */
-int usb_hc_async_wait_for(usb_handle_t handle)
-{
-	return ENOTSUP;
-}
-
-/**
- * @}
- */
Index: pace/lib/usb/hcdhubd.h
===================================================================
--- uspace/lib/usb/hcdhubd.h	(revision 0e126be78770a2c37ac932b2e25dd35bdc34e12e)
+++ 	(revision )
@@ -1,165 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * 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 libusb usb
- * @{
- */
-/** @file
- * @brief HC driver and hub driver.
- */
-#ifndef LIBUSB_HCDHUBD_H_
-#define LIBUSB_HCDHUBD_H_
-
-#include <adt/list.h>
-#include <driver.h>
-#include "usb.h"
-#include "hcd.h"
-
-/** Endpoint properties. */
-typedef struct {
-	/** Endpoint number. */
-	usb_endpoint_t endpoint;
-	/** Transfer type. */
-	usb_transfer_type_t transfer_type;
-	/** Endpoint direction. */
-	usb_direction_t direction;
-	/** Data toggle bit. */
-	int data_toggle;
-} usb_hc_endpoint_info_t;
-
-/** Information about attached USB device. */
-typedef struct {
-	/** Assigned address. */
-	usb_address_t address;
-	/** Number of endpoints. */
-	size_t endpoint_count;
-	/** Endpoint properties. */
-	usb_hc_endpoint_info_t *endpoints;
-	/** Link to other attached devices of the same HC. */
-	link_t link;
-} usb_hcd_attached_device_info_t;
-
-/** Information about attached hub. */
-typedef struct {
-	/** Number of ports. */
-	size_t port_count;
-	/** General device info. */
-	usb_hcd_attached_device_info_t *device;
-	/** Link to other hubs. */
-	link_t link;
-} usb_hcd_hub_info_t;
-
-/** Host controller device. */
-typedef struct usb_hc_device usb_hc_device_t;
-
-/** Callback for OUT transfers. */
-typedef void (*usb_hcd_transfer_callback_out_t)
-    (usb_hc_device_t *, usb_transaction_outcome_t, void *);
-
-/** Callback for IN transfers. */
-typedef void (*usb_hcd_transfer_callback_in_t)
-    (usb_hc_device_t *, size_t, usb_transaction_outcome_t, void *);
-
-
-/** Transfer functions provided by each USB host controller driver. */
-typedef struct {
-	/** OUT transfer.
-	 * @param hc Host controller that shall enqueue the transfer.
-	 * @param dev Target device.
-	 * @param ep Target endpoint.
-	 * @param buffer Buffer to be sent.
-	 * @param size Buffer size.
-	 * @param callback Callback after transfer was processed by hardware.
-	 * @param arg Callback argument.
-	 */
-	int (*transfer_out)(usb_hc_device_t *hc,
-	    usb_hcd_attached_device_info_t *dev, usb_hc_endpoint_info_t *ep,
-	    void *buffer, size_t size,
-	    usb_hcd_transfer_callback_out_t callback, void *arg);
-
-	/** SETUP transfer. */
-	int (*transfer_setup)(usb_hc_device_t *,
-	    usb_hcd_attached_device_info_t *, usb_hc_endpoint_info_t *,
-	    void *, size_t,
-	    usb_hcd_transfer_callback_out_t, void *);
-
-	/** IN transfer. */
-	int (*transfer_in)(usb_hc_device_t *,
-	    usb_hcd_attached_device_info_t *, usb_hc_endpoint_info_t *,
-	    void *, size_t,
-	    usb_hcd_transfer_callback_in_t, void *);
-} usb_hcd_transfer_ops_t;
-
-struct usb_hc_device {
-	/** Transfer operations. */
-	usb_hcd_transfer_ops_t *transfer_ops;
-
-	/** Custom HC data. */
-	void *data;
-
-	/** Generic device entry (read-only). */
-	device_t *generic;
-
-	/** List of attached devices. */
-	link_t attached_devices;
-
-	/** List of hubs operating from this HC. */
-	link_t hubs;
-
-	/** Link to other driven HCs. */
-	link_t link;
-};
-
-/** Host controller driver. */
-typedef struct {
-	/** Driver name. */
-	const char *name;
-	/** Callback when device (host controller) is added. */
-	int (*add_hc)(usb_hc_device_t *device);
-} usb_hc_driver_t;
-
-
-int usb_hcd_main(usb_hc_driver_t *);
-int usb_hcd_add_root_hub(usb_hc_device_t *dev);
-
-
-/*
- * Functions to be used by drivers within same task as the HC driver.
- * This will probably include only hub drivers.
- */
-
-
-int usb_hc_async_interrupt_out(usb_hc_device_t *, usb_target_t,
-    void *, size_t, usb_handle_t *);
-int usb_hc_async_interrupt_in(usb_hc_device_t *, usb_target_t,
-    void *, size_t, size_t *, usb_handle_t *);
-
-int usb_hc_async_wait_for(usb_handle_t);
-
-
-#endif
Index: pace/lib/usb/hid.h
===================================================================
--- uspace/lib/usb/hid.h	(revision 0e126be78770a2c37ac932b2e25dd35bdc34e12e)
+++ 	(revision )
@@ -1,59 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * 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 libusb usb
- * @{
- */
-/** @file
- * @brief USB HID device related types.
- */
-#ifndef LIBUSB_HID_H_
-#define LIBUSB_HID_H_
-
-/** USB/HID device requests. */
-typedef enum {
-	USB_HIDREQ_GET_REPORT = 1,
-	USB_HIDREQ_GET_IDLE = 2,
-	USB_HIDREQ_GET_PROTOCOL = 3,
-	/* Values 4 to 8 are reserved. */
-	USB_HIDREQ_SET_REPORT = 9,
-	USB_HIDREQ_SET_IDLE = 10,
-	USB_HIDREQ_SET_PROTOCOL = 11
-} usb_hid_request_t;
-
-/** USB/HID interface protocols. */
-typedef enum {
-	USB_HID_PROTOCOL_NONE = 0,
-	USB_HID_PROTOCOL_KEYBOARD = 1,
-	USB_HID_PROTOCOL_MOUSE = 2
-} usb_hid_protocol_t;
-
-#endif
-/**
- * @}
- */
Index: pace/lib/usb/hidut.h
===================================================================
--- uspace/lib/usb/hidut.h	(revision 0e126be78770a2c37ac932b2e25dd35bdc34e12e)
+++ 	(revision )
@@ -1,68 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * 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 libusb usb
- * @{
- */
-/** @file
- * @brief USB HID Usage Tables.
- */
-#ifndef LIBUSB_HIDUT_H_
-#define LIBUSB_HIDUT_H_
-
-/** USB/HID Usage Pages. */
-typedef enum {
-	USB_HIDUT_PAGE_GENERIC_DESKTOP = 1,
-	USB_HIDUT_PAGE_SIMULATION = 2,
-	USB_HIDUT_PAGE_VR = 3,
-	USB_HIDUT_PAGE_SPORT = 4,
-	USB_HIDUT_PAGE_GAME = 5,
-	USB_HIDUT_PAGE_GENERIC_DEVICE = 6,
-	USB_HIDUT_PAGE_KEYBOARD = 7,
-	USB_HIDUT_PAGE_LED = 8,
-	USB_HIDUT_PAGE_BUTTON = 9
-	/* USB_HIDUT_PAGE_ = , */
-} usb_hidut_usage_page_t;
-
-/** Usages for Generic Desktop Page. */
-typedef enum {
-	USB_HIDUT_USAGE_GENERIC_DESKTOP_POINTER = 1,
-	USB_HIDUT_USAGE_GENERIC_DESKTOP_MOUSE = 2,
-	USB_HIDUT_USAGE_GENERIC_DESKTOP_JOYSTICK = 4,
-	USB_HIDUT_USAGE_GENERIC_DESKTOP_GAMEPAD = 5,
-	USB_HIDUT_USAGE_GENERIC_DESKTOP_KEYBOARD = 6,
-	USB_HIDUT_USAGE_GENERIC_DESKTOP_KEYPAD = 7
-	/* USB_HIDUT_USAGE_GENERIC_DESKTOP_ = , */
-	
-} usb_hidut_usage_generic_desktop_t;
-
-
-#endif
-/**
- * @}
- */
Index: pace/lib/usb/hidutkbd.h
===================================================================
--- uspace/lib/usb/hidutkbd.h	(revision 0e126be78770a2c37ac932b2e25dd35bdc34e12e)
+++ 	(revision )
@@ -1,175 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * 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 libusb usb
- * @{
- */
-/** @file
- * @brief USB HID key codes.
- * @details
- * This is not a typical header as by default it is equal to empty file.
- * However, by cleverly defining the USB_HIDUT_KBD_KEY you can use it
- * to generate conversion tables etc.
- *
- * For example, this creates enum for known keys:
- * @code
-#define USB_HIDUT_KBD_KEY(name, usage_id, l, lc, l1, l2) \
-	USB_KBD_KEY_##name = usage_id,
-typedef enum {
-	#include <usb/hidutkbd.h>
-} usb_key_code_t;
- @endcode
- *
- * Maybe, it might be better that you would place such enums into separate
- * files and create them as separate step before compiling to allow tools
- * such as Doxygen get the definitions right.
- *
- * @warning This file does not include guard to prevent multiple inclusions
- * into a single file.
- */
-
-
-#ifndef USB_HIDUT_KBD_KEY
-/** Declare keyboard key.
- * @param name Key name (identifier).
- * @param usage_id Key code (see Keyboard/Keypad Page (0x07) in HUT1.12.
- * @param letter Corresponding character (0 if not applicable).
- * @param letter_caps Corresponding character with Caps on.
- * @param letter_mod1 Corresponding character with modifier #1 on.
- * @param letter_mod2 Corresponding character with modifier #2 on.
- */
-#define USB_HIDUT_KBD_KEY(name, usage_id, letter, letter_caps, letter_mod1, letter_mod2)
-
-#endif
-
-#define __NONPRINT(name, usage_id) \
-	USB_HIDUT_KBD_KEY(name, usage_id, 0, 0, 0, 0)
-
-/* US alphabet letters */
-USB_HIDUT_KBD_KEY(A, 0x04, 'a', 'A', 0, 0)
-USB_HIDUT_KBD_KEY(B, 0x05, 'b', 'B', 0, 0)
-USB_HIDUT_KBD_KEY(C, 0x06, 'c', 'C', 0, 0)
-USB_HIDUT_KBD_KEY(D, 0x07, 'd', 'D', 0, 0)
-USB_HIDUT_KBD_KEY(E, 0x08, 'e', 'E', 0, 0)
-USB_HIDUT_KBD_KEY(F, 0x09, 'f', 'F', 0, 0)
-USB_HIDUT_KBD_KEY(G, 0x0A, 'g', 'G', 0, 0)
-USB_HIDUT_KBD_KEY(H, 0x0B, 'h', 'H', 0, 0)
-USB_HIDUT_KBD_KEY(I, 0x0C, 'i', 'I', 0, 0)
-USB_HIDUT_KBD_KEY(J, 0x0D, 'j', 'J', 0, 0)
-USB_HIDUT_KBD_KEY(K, 0x0E, 'k', 'K', 0, 0)
-USB_HIDUT_KBD_KEY(L, 0x0F, 'l', 'L', 0, 0)
-USB_HIDUT_KBD_KEY(M, 0x10, 'm', 'M', 0, 0)
-USB_HIDUT_KBD_KEY(N, 0x11, 'n', 'N', 0, 0)
-USB_HIDUT_KBD_KEY(O, 0x12, 'o', 'O', 0, 0)
-USB_HIDUT_KBD_KEY(P, 0x13, 'p', 'P', 0, 0)
-USB_HIDUT_KBD_KEY(Q, 0x14, 'q', 'Q', 0, 0)
-USB_HIDUT_KBD_KEY(R, 0x15, 'r', 'R', 0, 0)
-USB_HIDUT_KBD_KEY(S, 0x16, 's', 'S', 0, 0)
-USB_HIDUT_KBD_KEY(T, 0x17, 't', 'T', 0, 0)
-USB_HIDUT_KBD_KEY(U, 0x18, 'u', 'U', 0, 0)
-USB_HIDUT_KBD_KEY(V, 0x19, 'v', 'V', 0, 0)
-USB_HIDUT_KBD_KEY(W, 0x1A, 'w', 'W', 0, 0)
-USB_HIDUT_KBD_KEY(X, 0x1B, 'x', 'X', 0, 0)
-USB_HIDUT_KBD_KEY(Y, 0x1C, 'y', 'Y', 0, 0)
-USB_HIDUT_KBD_KEY(Z, 0x1D, 'z', 'Z', 0, 0)
-
-/* Keyboard digits */
-USB_HIDUT_KBD_KEY(1, 0x1E, '1', '!', 0, 0)
-USB_HIDUT_KBD_KEY(2, 0x1F, '2', '@', 0, 0)
-USB_HIDUT_KBD_KEY(3, 0x20, '3', '#', 0, 0)
-USB_HIDUT_KBD_KEY(4, 0x21, '4', '$', 0, 0)
-USB_HIDUT_KBD_KEY(5, 0x22, '5', '%', 0, 0)
-USB_HIDUT_KBD_KEY(6, 0x23, '6', '^', 0, 0)
-USB_HIDUT_KBD_KEY(7, 0x24, '7', '&', 0, 0)
-USB_HIDUT_KBD_KEY(8, 0x25, '8', '*', 0, 0)
-USB_HIDUT_KBD_KEY(9, 0x26, '9', '(', 0, 0)
-USB_HIDUT_KBD_KEY(0, 0x27, '0', ')', 0, 0)
-
-/* More-or-less typewriter command keys */
-USB_HIDUT_KBD_KEY(ENTER, 0x28, '\n', 0, 0, 0)
-USB_HIDUT_KBD_KEY(ESCAPE, 0x29, 0, 0, 0, 0)
-USB_HIDUT_KBD_KEY(BACKSPACE, 0x2A, '\b', 0, 0, 0)
-USB_HIDUT_KBD_KEY(TAB, 0x2B, '\t', 0, 0, 0)
-USB_HIDUT_KBD_KEY(SPACE, 0x2C, ' ', 0, 0, 0)
-
-/* Special (printable) characters */
-USB_HIDUT_KBD_KEY(DASH, 0x2D, '-', '_', 0, 0)
-USB_HIDUT_KBD_KEY(EQUALS, 0x2E, '=', '+', 0, 0)
-USB_HIDUT_KBD_KEY(LEFT_BRACKET, 0x2F, '[', '{', 0, 0)
-USB_HIDUT_KBD_KEY(RIGHT_BRACKET, 0x30, ']', '}', 0, 0)
-USB_HIDUT_KBD_KEY(BACKSLASH, 0x31, '\\', '|', 0, 0)
-USB_HIDUT_KBD_KEY(HASH, 0x32, '#', '~', 0, 0)
-USB_HIDUT_KBD_KEY(SEMICOLON, 0x33, ';', ':', 0, 0)
-USB_HIDUT_KBD_KEY(APOSTROPHE, 0x34, '\'', '"', 0, 0)
-USB_HIDUT_KBD_KEY(GRAVE_ACCENT, 0x35, '`', '~', 0, 0)
-USB_HIDUT_KBD_KEY(COMMA, 0x36, ',', '<', 0, 0)
-USB_HIDUT_KBD_KEY(PERIOD, 0x37, '.', '>', 0, 0)
-USB_HIDUT_KBD_KEY(SLASH, 0x38, '/', '?', 0, 0)
-
-USB_HIDUT_KBD_KEY(CAPS_LOCK, 0x39, 0, 0, 0, 0)
-
-/* Function keys */
-__NONPRINT( F1, 0x3A)
-__NONPRINT( F2, 0x3B)
-__NONPRINT( F3, 0x3C)
-__NONPRINT( F4, 0x3D)
-__NONPRINT( F5, 0x3E)
-__NONPRINT( F6, 0x3F)
-__NONPRINT( F7, 0x40)
-__NONPRINT( F8, 0x41)
-__NONPRINT( F9, 0x42)
-__NONPRINT(F10, 0x43)
-__NONPRINT(F11, 0x44)
-__NONPRINT(F12, 0x45)
-
-/* Cursor movement keys & co. */
-__NONPRINT(PRINT_SCREEN, 0x46)
-__NONPRINT(SCROLL_LOCK, 0x47)
-__NONPRINT(PAUSE, 0x48)
-__NONPRINT(INSERT, 0x49)
-__NONPRINT(HOME, 0x4A)
-__NONPRINT(PAGE_UP, 0x4B)
-__NONPRINT(DELETE, 0x4C)
-__NONPRINT(END, 0x4D)
-__NONPRINT(PAGE_DOWN, 0x4E)
-__NONPRINT(RIGHT_ARROW, 0x4F)
-__NONPRINT(LEFT_ARROW, 0x50)
-__NONPRINT(DOWN_ARROW, 0x51)
-__NONPRINT(UP_ARROW, 0x52)
-
-
-
-
-/* USB_HIDUT_KBD_KEY(, 0x, '', '', 0, 0) */
-
-#undef __NONPRINT
-
-/**
- * @}
- */
-
Index: pace/lib/usb/hub.h
===================================================================
--- uspace/lib/usb/hub.h	(revision 0e126be78770a2c37ac932b2e25dd35bdc34e12e)
+++ 	(revision )
@@ -1,74 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * 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 libusb usb
- * @{
- */
-/** @file
- * @brief USB hub related structures.
- */
-#ifndef LIBUSB_HUB_H_
-#define LIBUSB_HUB_H_
-
-/** Hub class request. */
-typedef enum {
-	USB_HUB_REQUEST_GET_STATUS = 0,
-	USB_HUB_REQUEST_CLEAR_FEATURE = 1,
-	USB_HUB_REQUEST_GET_STATE = 2,
-	USB_HUB_REQUEST_SET_FEATURE = 3,
-	USB_HUB_REQUEST_GET_DESCRIPTOR = 6,
-	USB_HUB_REQUEST_SET_DESCRIPTOR = 7,
-	/* USB_HUB_REQUEST_ = , */
-} usb_hub_class_request_t;
-
-/** Hub class feature selector.
- * @warning The constants are not unique (feature selectors are used
- * for hub and port).
- */
-typedef enum {
-	USB_HUB_FEATURE_C_HUB_LOCAL_POWER = 0,
-	USB_HUB_FEATURE_C_HUB_OVER_CURRENT = 1,
-	USB_HUB_FEATURE_PORT_CONNECTION = 0,
-	USB_HUB_FEATURE_PORT_ENABLE = 1,
-	USB_HUB_FEATURE_PORT_SUSPEND = 2,
-	USB_HUB_FEATURE_PORT_OVER_CURRENT = 3,
-	USB_HUB_FEATURE_PORT_RESET = 4,
-	USB_HUB_FEATURE_PORT_POWER = 8,
-	USB_HUB_FEATURE_PORT_LOW_SPEED = 9,
-	USB_HUB_FEATURE_C_PORT_CONNECTION = 16,
-	USB_HUB_FEATURE_C_PORT_ENABLE = 17,
-	USB_HUB_FEATURE_C_PORT_SUSPEND = 18,
-	USB_HUB_FEATURE_C_PORT_OVER_CURRENT = 19,
-	USB_HUB_FEATURE_C_PORT_RESET = 20,
-	/* USB_HUB_FEATURE_ = , */
-} usb_hub_class_feature_t;
-
-#endif
-/**
- * @}
- */
Index: uspace/lib/usb/include/usb/classes/classes.h
===================================================================
--- uspace/lib/usb/include/usb/classes/classes.h	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
+++ uspace/lib/usb/include/usb/classes/classes.h	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * 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 libusb usb
+ * @{
+ */
+/** @file
+ * @brief USB device classes and subclasses.
+ */
+#ifndef LIBUSB_CLASSES_H_
+#define LIBUSB_CLASSES_H_
+
+/** USB device class. */
+typedef enum {
+	USB_CLASS_USE_INTERFACE = 0x00,
+	USB_CLASS_AUDIO = 0x01,
+	USB_CLASS_COMMUNICATIONS_CDC_CONTROL = 0x02,
+	USB_CLASS_HID = 0x03,
+	USB_CLASS_PHYSICAL = 0x05,
+	USB_CLASS_IMAGE = 0x06,
+	USB_CLASS_PRINTER = 0x07,
+	USB_CLASS_MASS_STORAGE = 0x08,
+	USB_CLASS_HUB = 0x09,
+	USB_CLASS_CDC_DATA = 0x0A,
+	USB_CLASS_SMART_CARD = 0x0B,
+	USB_CLASS_CONTENT_SECURITY = 0x0D,
+	USB_CLASS_VIDEO = 0x0E,
+	USB_CLASS_PERSONAL_HEALTHCARE = 0x0F,
+	USB_CLASS_DIAGNOSTIC = 0xDC,
+	USB_CLASS_WIRELESS_CONTROLLER = 0xE0,
+	USB_CLASS_MISCELLANEOUS = 0xEF,
+	USB_CLASS_APPLICATION_SPECIFIC = 0xFE,
+	USB_CLASS_VENDOR_SPECIFIC = 0xFF,
+	/* USB_CLASS_ = 0x, */
+} usb_class_t;
+
+
+#endif
+/**
+ * @}
+ */
Index: uspace/lib/usb/include/usb/classes/hid.h
===================================================================
--- uspace/lib/usb/include/usb/classes/hid.h	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
+++ uspace/lib/usb/include/usb/classes/hid.h	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * 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 libusb usb
+ * @{
+ */
+/** @file
+ * @brief USB HID device related types.
+ */
+#ifndef LIBUSB_HID_H_
+#define LIBUSB_HID_H_
+
+/** USB/HID device requests. */
+typedef enum {
+	USB_HIDREQ_GET_REPORT = 1,
+	USB_HIDREQ_GET_IDLE = 2,
+	USB_HIDREQ_GET_PROTOCOL = 3,
+	/* Values 4 to 8 are reserved. */
+	USB_HIDREQ_SET_REPORT = 9,
+	USB_HIDREQ_SET_IDLE = 10,
+	USB_HIDREQ_SET_PROTOCOL = 11
+} usb_hid_request_t;
+
+/** USB/HID interface protocols. */
+typedef enum {
+	USB_HID_PROTOCOL_NONE = 0,
+	USB_HID_PROTOCOL_KEYBOARD = 1,
+	USB_HID_PROTOCOL_MOUSE = 2
+} usb_hid_protocol_t;
+
+#endif
+/**
+ * @}
+ */
Index: uspace/lib/usb/include/usb/classes/hidut.h
===================================================================
--- uspace/lib/usb/include/usb/classes/hidut.h	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
+++ uspace/lib/usb/include/usb/classes/hidut.h	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * 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 libusb usb
+ * @{
+ */
+/** @file
+ * @brief USB HID Usage Tables.
+ */
+#ifndef LIBUSB_HIDUT_H_
+#define LIBUSB_HIDUT_H_
+
+/** USB/HID Usage Pages. */
+typedef enum {
+	USB_HIDUT_PAGE_GENERIC_DESKTOP = 1,
+	USB_HIDUT_PAGE_SIMULATION = 2,
+	USB_HIDUT_PAGE_VR = 3,
+	USB_HIDUT_PAGE_SPORT = 4,
+	USB_HIDUT_PAGE_GAME = 5,
+	USB_HIDUT_PAGE_GENERIC_DEVICE = 6,
+	USB_HIDUT_PAGE_KEYBOARD = 7,
+	USB_HIDUT_PAGE_LED = 8,
+	USB_HIDUT_PAGE_BUTTON = 9
+	/* USB_HIDUT_PAGE_ = , */
+} usb_hidut_usage_page_t;
+
+/** Usages for Generic Desktop Page. */
+typedef enum {
+	USB_HIDUT_USAGE_GENERIC_DESKTOP_POINTER = 1,
+	USB_HIDUT_USAGE_GENERIC_DESKTOP_MOUSE = 2,
+	USB_HIDUT_USAGE_GENERIC_DESKTOP_JOYSTICK = 4,
+	USB_HIDUT_USAGE_GENERIC_DESKTOP_GAMEPAD = 5,
+	USB_HIDUT_USAGE_GENERIC_DESKTOP_KEYBOARD = 6,
+	USB_HIDUT_USAGE_GENERIC_DESKTOP_KEYPAD = 7
+	/* USB_HIDUT_USAGE_GENERIC_DESKTOP_ = , */
+	
+} usb_hidut_usage_generic_desktop_t;
+
+
+#endif
+/**
+ * @}
+ */
Index: uspace/lib/usb/include/usb/classes/hidutkbd.h
===================================================================
--- uspace/lib/usb/include/usb/classes/hidutkbd.h	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
+++ uspace/lib/usb/include/usb/classes/hidutkbd.h	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
@@ -0,0 +1,175 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * 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 libusb usb
+ * @{
+ */
+/** @file
+ * @brief USB HID key codes.
+ * @details
+ * This is not a typical header as by default it is equal to empty file.
+ * However, by cleverly defining the USB_HIDUT_KBD_KEY you can use it
+ * to generate conversion tables etc.
+ *
+ * For example, this creates enum for known keys:
+ * @code
+#define USB_HIDUT_KBD_KEY(name, usage_id, l, lc, l1, l2) \
+	USB_KBD_KEY_##name = usage_id,
+typedef enum {
+	#include <usb/hidutkbd.h>
+} usb_key_code_t;
+ @endcode
+ *
+ * Maybe, it might be better that you would place such enums into separate
+ * files and create them as separate step before compiling to allow tools
+ * such as Doxygen get the definitions right.
+ *
+ * @warning This file does not include guard to prevent multiple inclusions
+ * into a single file.
+ */
+
+
+#ifndef USB_HIDUT_KBD_KEY
+/** Declare keyboard key.
+ * @param name Key name (identifier).
+ * @param usage_id Key code (see Keyboard/Keypad Page (0x07) in HUT1.12.
+ * @param letter Corresponding character (0 if not applicable).
+ * @param letter_caps Corresponding character with Caps on.
+ * @param letter_mod1 Corresponding character with modifier #1 on.
+ * @param letter_mod2 Corresponding character with modifier #2 on.
+ */
+#define USB_HIDUT_KBD_KEY(name, usage_id, letter, letter_caps, letter_mod1, letter_mod2)
+
+#endif
+
+#define __NONPRINT(name, usage_id) \
+	USB_HIDUT_KBD_KEY(name, usage_id, 0, 0, 0, 0)
+
+/* US alphabet letters */
+USB_HIDUT_KBD_KEY(A, 0x04, 'a', 'A', 0, 0)
+USB_HIDUT_KBD_KEY(B, 0x05, 'b', 'B', 0, 0)
+USB_HIDUT_KBD_KEY(C, 0x06, 'c', 'C', 0, 0)
+USB_HIDUT_KBD_KEY(D, 0x07, 'd', 'D', 0, 0)
+USB_HIDUT_KBD_KEY(E, 0x08, 'e', 'E', 0, 0)
+USB_HIDUT_KBD_KEY(F, 0x09, 'f', 'F', 0, 0)
+USB_HIDUT_KBD_KEY(G, 0x0A, 'g', 'G', 0, 0)
+USB_HIDUT_KBD_KEY(H, 0x0B, 'h', 'H', 0, 0)
+USB_HIDUT_KBD_KEY(I, 0x0C, 'i', 'I', 0, 0)
+USB_HIDUT_KBD_KEY(J, 0x0D, 'j', 'J', 0, 0)
+USB_HIDUT_KBD_KEY(K, 0x0E, 'k', 'K', 0, 0)
+USB_HIDUT_KBD_KEY(L, 0x0F, 'l', 'L', 0, 0)
+USB_HIDUT_KBD_KEY(M, 0x10, 'm', 'M', 0, 0)
+USB_HIDUT_KBD_KEY(N, 0x11, 'n', 'N', 0, 0)
+USB_HIDUT_KBD_KEY(O, 0x12, 'o', 'O', 0, 0)
+USB_HIDUT_KBD_KEY(P, 0x13, 'p', 'P', 0, 0)
+USB_HIDUT_KBD_KEY(Q, 0x14, 'q', 'Q', 0, 0)
+USB_HIDUT_KBD_KEY(R, 0x15, 'r', 'R', 0, 0)
+USB_HIDUT_KBD_KEY(S, 0x16, 's', 'S', 0, 0)
+USB_HIDUT_KBD_KEY(T, 0x17, 't', 'T', 0, 0)
+USB_HIDUT_KBD_KEY(U, 0x18, 'u', 'U', 0, 0)
+USB_HIDUT_KBD_KEY(V, 0x19, 'v', 'V', 0, 0)
+USB_HIDUT_KBD_KEY(W, 0x1A, 'w', 'W', 0, 0)
+USB_HIDUT_KBD_KEY(X, 0x1B, 'x', 'X', 0, 0)
+USB_HIDUT_KBD_KEY(Y, 0x1C, 'y', 'Y', 0, 0)
+USB_HIDUT_KBD_KEY(Z, 0x1D, 'z', 'Z', 0, 0)
+
+/* Keyboard digits */
+USB_HIDUT_KBD_KEY(1, 0x1E, '1', '!', 0, 0)
+USB_HIDUT_KBD_KEY(2, 0x1F, '2', '@', 0, 0)
+USB_HIDUT_KBD_KEY(3, 0x20, '3', '#', 0, 0)
+USB_HIDUT_KBD_KEY(4, 0x21, '4', '$', 0, 0)
+USB_HIDUT_KBD_KEY(5, 0x22, '5', '%', 0, 0)
+USB_HIDUT_KBD_KEY(6, 0x23, '6', '^', 0, 0)
+USB_HIDUT_KBD_KEY(7, 0x24, '7', '&', 0, 0)
+USB_HIDUT_KBD_KEY(8, 0x25, '8', '*', 0, 0)
+USB_HIDUT_KBD_KEY(9, 0x26, '9', '(', 0, 0)
+USB_HIDUT_KBD_KEY(0, 0x27, '0', ')', 0, 0)
+
+/* More-or-less typewriter command keys */
+USB_HIDUT_KBD_KEY(ENTER, 0x28, '\n', 0, 0, 0)
+USB_HIDUT_KBD_KEY(ESCAPE, 0x29, 0, 0, 0, 0)
+USB_HIDUT_KBD_KEY(BACKSPACE, 0x2A, '\b', 0, 0, 0)
+USB_HIDUT_KBD_KEY(TAB, 0x2B, '\t', 0, 0, 0)
+USB_HIDUT_KBD_KEY(SPACE, 0x2C, ' ', 0, 0, 0)
+
+/* Special (printable) characters */
+USB_HIDUT_KBD_KEY(DASH, 0x2D, '-', '_', 0, 0)
+USB_HIDUT_KBD_KEY(EQUALS, 0x2E, '=', '+', 0, 0)
+USB_HIDUT_KBD_KEY(LEFT_BRACKET, 0x2F, '[', '{', 0, 0)
+USB_HIDUT_KBD_KEY(RIGHT_BRACKET, 0x30, ']', '}', 0, 0)
+USB_HIDUT_KBD_KEY(BACKSLASH, 0x31, '\\', '|', 0, 0)
+USB_HIDUT_KBD_KEY(HASH, 0x32, '#', '~', 0, 0)
+USB_HIDUT_KBD_KEY(SEMICOLON, 0x33, ';', ':', 0, 0)
+USB_HIDUT_KBD_KEY(APOSTROPHE, 0x34, '\'', '"', 0, 0)
+USB_HIDUT_KBD_KEY(GRAVE_ACCENT, 0x35, '`', '~', 0, 0)
+USB_HIDUT_KBD_KEY(COMMA, 0x36, ',', '<', 0, 0)
+USB_HIDUT_KBD_KEY(PERIOD, 0x37, '.', '>', 0, 0)
+USB_HIDUT_KBD_KEY(SLASH, 0x38, '/', '?', 0, 0)
+
+USB_HIDUT_KBD_KEY(CAPS_LOCK, 0x39, 0, 0, 0, 0)
+
+/* Function keys */
+__NONPRINT( F1, 0x3A)
+__NONPRINT( F2, 0x3B)
+__NONPRINT( F3, 0x3C)
+__NONPRINT( F4, 0x3D)
+__NONPRINT( F5, 0x3E)
+__NONPRINT( F6, 0x3F)
+__NONPRINT( F7, 0x40)
+__NONPRINT( F8, 0x41)
+__NONPRINT( F9, 0x42)
+__NONPRINT(F10, 0x43)
+__NONPRINT(F11, 0x44)
+__NONPRINT(F12, 0x45)
+
+/* Cursor movement keys & co. */
+__NONPRINT(PRINT_SCREEN, 0x46)
+__NONPRINT(SCROLL_LOCK, 0x47)
+__NONPRINT(PAUSE, 0x48)
+__NONPRINT(INSERT, 0x49)
+__NONPRINT(HOME, 0x4A)
+__NONPRINT(PAGE_UP, 0x4B)
+__NONPRINT(DELETE, 0x4C)
+__NONPRINT(END, 0x4D)
+__NONPRINT(PAGE_DOWN, 0x4E)
+__NONPRINT(RIGHT_ARROW, 0x4F)
+__NONPRINT(LEFT_ARROW, 0x50)
+__NONPRINT(DOWN_ARROW, 0x51)
+__NONPRINT(UP_ARROW, 0x52)
+
+
+
+
+/* USB_HIDUT_KBD_KEY(, 0x, '', '', 0, 0) */
+
+#undef __NONPRINT
+
+/**
+ * @}
+ */
+
Index: uspace/lib/usb/include/usb/classes/hub.h
===================================================================
--- uspace/lib/usb/include/usb/classes/hub.h	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
+++ uspace/lib/usb/include/usb/classes/hub.h	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * 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 libusb usb
+ * @{
+ */
+/** @file
+ * @brief USB hub related structures.
+ */
+#ifndef LIBUSB_HUB_H_
+#define LIBUSB_HUB_H_
+
+/** Hub class request. */
+typedef enum {
+	USB_HUB_REQUEST_GET_STATUS = 0,
+	USB_HUB_REQUEST_CLEAR_FEATURE = 1,
+	USB_HUB_REQUEST_GET_STATE = 2,
+	USB_HUB_REQUEST_SET_FEATURE = 3,
+	USB_HUB_REQUEST_GET_DESCRIPTOR = 6,
+	USB_HUB_REQUEST_SET_DESCRIPTOR = 7,
+	/* USB_HUB_REQUEST_ = , */
+} usb_hub_class_request_t;
+
+/** Hub class feature selector.
+ * @warning The constants are not unique (feature selectors are used
+ * for hub and port).
+ */
+typedef enum {
+	USB_HUB_FEATURE_C_HUB_LOCAL_POWER = 0,
+	USB_HUB_FEATURE_C_HUB_OVER_CURRENT = 1,
+	USB_HUB_FEATURE_PORT_CONNECTION = 0,
+	USB_HUB_FEATURE_PORT_ENABLE = 1,
+	USB_HUB_FEATURE_PORT_SUSPEND = 2,
+	USB_HUB_FEATURE_PORT_OVER_CURRENT = 3,
+	USB_HUB_FEATURE_PORT_RESET = 4,
+	USB_HUB_FEATURE_PORT_POWER = 8,
+	USB_HUB_FEATURE_PORT_LOW_SPEED = 9,
+	USB_HUB_FEATURE_C_PORT_CONNECTION = 16,
+	USB_HUB_FEATURE_C_PORT_ENABLE = 17,
+	USB_HUB_FEATURE_C_PORT_SUSPEND = 18,
+	USB_HUB_FEATURE_C_PORT_OVER_CURRENT = 19,
+	USB_HUB_FEATURE_C_PORT_RESET = 20,
+	/* USB_HUB_FEATURE_ = , */
+} usb_hub_class_feature_t;
+
+#endif
+/**
+ * @}
+ */
Index: uspace/lib/usb/include/usb/descriptor.h
===================================================================
--- uspace/lib/usb/include/usb/descriptor.h	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
+++ uspace/lib/usb/include/usb/descriptor.h	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
@@ -0,0 +1,176 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * 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 libusb usb
+ * @{
+ */
+/** @file
+ * @brief Standard USB descriptors.
+ */
+#ifndef LIBUSB_DESCRIPTOR_H_
+#define LIBUSB_DESCRIPTOR_H_
+
+#include <ipc/ipc.h>
+#include <async.h>
+
+/** Descriptor type. */
+typedef enum {
+	USB_DESCTYPE_DEVICE = 1,
+	USB_DESCTYPE_CONFIGURATION = 2,
+	USB_DESCTYPE_STRING = 3,
+	USB_DESCTYPE_INTERFACE = 4,
+	USB_DESCTYPE_ENDPOINT = 5,
+	USB_DESCTYPE_HID = 0x21,
+	USB_DESCTYPE_HID_REPORT = 0x22,
+	USB_DESCTYPE_HID_PHYSICAL = 0x23,
+	USB_DESCTYPE_HUB = 0x29,
+	/* USB_DESCTYPE_ = */
+} usb_descriptor_type_t;
+
+/** Standard USB device descriptor.
+ */
+typedef struct {
+	/** Size of this descriptor in bytes. */
+	uint8_t length;
+	/** Descriptor type (USB_DESCTYPE_DEVICE). */
+	uint8_t descriptor_type;
+	/** USB specification release number.
+	 * The number shall be coded as binary-coded decimal (BCD).
+	 */
+	uint16_t usb_spec_version;
+	/** Device class. */
+	uint8_t device_class;
+	/** Device sub-class. */
+	uint8_t device_subclass;
+	/** Device protocol. */
+	uint8_t device_protocol;
+	/** Maximum packet size for endpoint zero.
+	 * Valid values are only 8, 16, 32, 64).
+	 */
+	uint8_t max_packet_size;
+	/** Vendor ID. */
+	uint16_t vendor_id;
+	/** Product ID. */
+	uint16_t product_id;
+	/** Device release number (in BCD). */
+	uint16_t device_version;
+	/** Manufacturer descriptor index. */
+	uint8_t str_manufacturer;
+	/** Product descriptor index. */
+	uint8_t str_product;
+	/** Device serial number desriptor index. */
+	uint8_t str_serial_number;
+	/** Number of possible configurations. */
+	uint8_t configuration_count;
+} __attribute__ ((packed)) usb_standard_device_descriptor_t;
+
+/** Standard USB configuration descriptor.
+ */
+typedef struct {
+	/** Size of this descriptor in bytes. */
+	uint8_t length;
+	/** Descriptor type (USB_DESCTYPE_CONFIGURATION). */
+	uint8_t descriptor_type;
+	/** Total length of all data of this configuration.
+	 * This includes the combined length of all descriptors
+	 * (configuration, interface, endpoint, class-specific and
+	 * vendor-specific) valid for this configuration.
+	 */
+	uint16_t total_length;
+	/** Number of possible interfaces under this configuration. */
+	uint8_t interface_count;
+	/** Configuration value used when setting this configuration. */
+	uint8_t configuration_number;
+	/** String descriptor describing this configuration. */
+	uint8_t str_configuration;
+	/** Attribute bitmap. */
+	uint8_t attributes;
+	/** Maximum power consumption from the USB under this configuration.
+	 * Expressed in 2mA unit (e.g. 50 ~ 100mA).
+	 */
+	uint8_t max_power;
+} __attribute__ ((packed)) usb_standard_configuration_descriptor_t;
+
+/** Standard USB interface descriptor.
+ */
+typedef struct {
+	/** Size of this descriptor in bytes. */
+	uint8_t length;
+	/** Descriptor type (USB_DESCTYPE_INTERFACE). */
+	uint8_t descriptor_type;
+	/** Number of interface.
+	 * Zero-based index into array of interfaces for current configuration.
+	 */
+	uint8_t interface_number;
+	/** Alternate setting for value in interface_number. */
+	uint8_t alternate_setting;
+	/** Number of endpoints used by this interface.
+	 * This number must exclude usage of endpoint zero
+	 * (default control pipe).
+	 */
+	uint8_t endpoint_count;
+	/** Class code. */
+	uint8_t interface_class;
+	/** Subclass code. */
+	uint8_t interface_subclass;
+	/** Protocol code. */
+	uint8_t interface_protocol;
+	/** String descriptor describing this interface. */
+	uint8_t str_interface;
+} __attribute__ ((packed)) usb_standard_interface_descriptor_t;
+
+/** Standard USB endpoint descriptor.
+ */
+typedef struct {
+	/** Size of this descriptor in bytes. */
+	uint8_t length;
+	/** Descriptor type (USB_DESCTYPE_ENDPOINT). */
+	uint8_t descriptor_type;
+	/** Endpoint address together with data flow direction. */
+	uint8_t endpoint_address;
+	/** Endpoint attributes.
+	 * Includes transfer type (usb_transfer_type_t).
+	 */
+	uint8_t attributes;
+	/** Maximum packet size. */
+	uint16_t max_packet_size;
+	/** Polling interval in milliseconds.
+	 * Ignored for bulk and control endpoints.
+	 * Isochronous endpoints must use value 1.
+	 * Interrupt endpoints any value from 1 to 255.
+	 */
+	uint8_t poll_interval;
+} __attribute__ ((packed)) usb_standard_endpoint_descriptor_t;
+
+
+/* TODO: string descriptors. */
+
+#endif
+/**
+ * @}
+ */
Index: uspace/lib/usb/include/usb/devreq.h
===================================================================
--- uspace/lib/usb/include/usb/devreq.h	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
+++ uspace/lib/usb/include/usb/devreq.h	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * 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 libusb usb
+ * @{
+ */
+/** @file
+ * @brief Standard USB device requests.
+ */
+#ifndef LIBUSB_DEVREQ_H_
+#define LIBUSB_DEVREQ_H_
+
+#include <ipc/ipc.h>
+#include <async.h>
+
+/** Standard device request. */
+typedef enum {
+	USB_DEVREQ_GET_STATUS = 0,
+	USB_DEVREQ_CLEAR_FEATURE = 1,
+	USB_DEVREQ_SET_FEATURE = 3,
+	USB_DEVREQ_SET_ADDRESS = 5,
+	USB_DEVREQ_GET_DESCRIPTOR = 6,
+	USB_DEVREQ_SET_DESCRIPTOR = 7,
+	USB_DEVREQ_GET_CONFIGURATION = 8,
+	USB_DEVREQ_SET_CONFIGURATION = 9,
+	USB_DEVREQ_GET_INTERFACE = 10,
+	USB_DEVREQ_SET_INTERFACE = 11,
+	USB_DEVREQ_SYNCH_FRAME = 12,
+	USB_DEVREQ_LAST_STD
+} usb_stddevreq_t;
+
+/** Device request setup packet.
+ * The setup packet describes the request.
+ */
+typedef struct {
+	/** Request type.
+	 * The type combines transfer direction, request type and
+	 * intended recipient.
+	 */
+	uint8_t request_type;
+	/** Request identification. */
+	uint8_t request;
+	/** Main parameter to the request. */
+	union {
+		/* FIXME: add #ifdefs according to host endianess */
+		struct {
+			uint8_t value_low;
+			uint8_t value_high;
+		};
+		uint16_t value;
+	};
+	/** Auxiliary parameter to the request.
+	 * Typically, it is offset to something.
+	 */
+	uint16_t index;
+	/** Length of extra data. */
+	uint16_t length;
+} __attribute__ ((packed)) usb_device_request_setup_packet_t;
+
+#endif
+/**
+ * @}
+ */
Index: uspace/lib/usb/include/usb/hcdhubd.h
===================================================================
--- uspace/lib/usb/include/usb/hcdhubd.h	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
+++ uspace/lib/usb/include/usb/hcdhubd.h	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * 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 libusb usb
+ * @{
+ */
+/** @file
+ * @brief HC driver and hub driver.
+ */
+#ifndef LIBUSB_HCDHUBD_H_
+#define LIBUSB_HCDHUBD_H_
+
+#include <adt/list.h>
+#include <driver.h>
+#include <usb/usb.h>
+
+/** Endpoint properties. */
+typedef struct {
+	/** Endpoint number. */
+	usb_endpoint_t endpoint;
+	/** Transfer type. */
+	usb_transfer_type_t transfer_type;
+	/** Endpoint direction. */
+	usb_direction_t direction;
+	/** Data toggle bit. */
+	int data_toggle;
+} usb_hc_endpoint_info_t;
+
+/** Information about attached USB device. */
+typedef struct {
+	/** Assigned address. */
+	usb_address_t address;
+	/** Number of endpoints. */
+	size_t endpoint_count;
+	/** Endpoint properties. */
+	usb_hc_endpoint_info_t *endpoints;
+	/** Link to other attached devices of the same HC. */
+	link_t link;
+} usb_hcd_attached_device_info_t;
+
+/** Information about attached hub. */
+typedef struct {
+	/** Number of ports. */
+	size_t port_count;
+	/** General device info. */
+	usb_hcd_attached_device_info_t *device;
+	/** Link to other hubs. */
+	link_t link;
+} usb_hcd_hub_info_t;
+
+/** Host controller device. */
+typedef struct usb_hc_device usb_hc_device_t;
+
+/** Callback for OUT transfers. */
+typedef void (*usb_hcd_transfer_callback_out_t)
+    (usb_hc_device_t *, usb_transaction_outcome_t, void *);
+
+/** Callback for IN transfers. */
+typedef void (*usb_hcd_transfer_callback_in_t)
+    (usb_hc_device_t *, size_t, usb_transaction_outcome_t, void *);
+
+
+/** Transfer functions provided by each USB host controller driver. */
+typedef struct {
+	/** OUT transfer.
+	 * @param hc Host controller that shall enqueue the transfer.
+	 * @param dev Target device.
+	 * @param ep Target endpoint.
+	 * @param buffer Buffer to be sent.
+	 * @param size Buffer size.
+	 * @param callback Callback after transfer was processed by hardware.
+	 * @param arg Callback argument.
+	 */
+	int (*transfer_out)(usb_hc_device_t *hc,
+	    usb_hcd_attached_device_info_t *dev, usb_hc_endpoint_info_t *ep,
+	    void *buffer, size_t size,
+	    usb_hcd_transfer_callback_out_t callback, void *arg);
+
+	/** SETUP transfer. */
+	int (*transfer_setup)(usb_hc_device_t *,
+	    usb_hcd_attached_device_info_t *, usb_hc_endpoint_info_t *,
+	    void *, size_t,
+	    usb_hcd_transfer_callback_out_t, void *);
+
+	/** IN transfer. */
+	int (*transfer_in)(usb_hc_device_t *,
+	    usb_hcd_attached_device_info_t *, usb_hc_endpoint_info_t *,
+	    void *, size_t,
+	    usb_hcd_transfer_callback_in_t, void *);
+} usb_hcd_transfer_ops_t;
+
+struct usb_hc_device {
+	/** Transfer operations. */
+	usb_hcd_transfer_ops_t *transfer_ops;
+
+	/** Custom HC data. */
+	void *data;
+
+	/** Generic device entry (read-only). */
+	device_t *generic;
+
+	/** List of attached devices. */
+	link_t attached_devices;
+
+	/** List of hubs operating from this HC. */
+	link_t hubs;
+
+	/** Link to other driven HCs. */
+	link_t link;
+};
+
+/** Host controller driver. */
+typedef struct {
+	/** Driver name. */
+	const char *name;
+	/** Callback when device (host controller) is added. */
+	int (*add_hc)(usb_hc_device_t *device);
+} usb_hc_driver_t;
+
+
+int usb_hcd_main(usb_hc_driver_t *);
+int usb_hcd_add_root_hub(usb_hc_device_t *dev);
+
+
+/*
+ * Functions to be used by drivers within same task as the HC driver.
+ * This will probably include only hub drivers.
+ */
+
+
+int usb_hc_async_interrupt_out(usb_hc_device_t *, usb_target_t,
+    void *, size_t, usb_handle_t *);
+int usb_hc_async_interrupt_in(usb_hc_device_t *, usb_target_t,
+    void *, size_t, size_t *, usb_handle_t *);
+
+int usb_hc_async_wait_for(usb_handle_t);
+
+
+#endif
Index: uspace/lib/usb/include/usb/usb.h
===================================================================
--- uspace/lib/usb/include/usb/usb.h	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
+++ uspace/lib/usb/include/usb/usb.h	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * 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 libusb usb
+ * @{
+ */
+/** @file
+ * @brief Base USB types.
+ */
+#ifndef LIBUSB_USB_H_
+#define LIBUSB_USB_H_
+
+#include <sys/types.h>
+#include <ipc/ipc.h>
+
+/** USB transfer type. */
+typedef enum {
+	USB_TRANSFER_CONTROL = 0,
+	USB_TRANSFER_ISOCHRONOUS = 1,
+	USB_TRANSFER_BULK = 2,
+	USB_TRANSFER_INTERRUPT = 3
+} usb_transfer_type_t;
+
+const char * usb_str_transfer_type(usb_transfer_type_t t);
+
+/** USB data transfer direction. */
+typedef enum {
+	USB_DIRECTION_IN,
+	USB_DIRECTION_OUT
+} usb_direction_t;
+
+/** USB transaction outcome. */
+typedef enum {
+	USB_OUTCOME_OK,
+	USB_OUTCOME_CRCERROR,
+	USB_OUTCOME_BABBLE
+} usb_transaction_outcome_t;
+
+const char * usb_str_transaction_outcome(usb_transaction_outcome_t o);
+
+/** USB address type.
+ * Negative values could be used to indicate error.
+ */
+typedef int usb_address_t;
+
+/** USB endpoint number type.
+ * Negative values could be used to indicate error.
+ */
+typedef int usb_endpoint_t;
+
+/** Maximum endpoint number in USB 1.1.
+ */
+#define USB11_ENDPOINT_MAX 16
+
+
+/** USB complete address type. 
+ * Pair address + endpoint is identification of transaction recipient.
+ */
+typedef struct {
+	usb_address_t address;
+	usb_endpoint_t endpoint;
+} usb_target_t;
+
+static inline int usb_target_same(usb_target_t a, usb_target_t b)
+{
+	return (a.address == b.address)
+	    && (a.endpoint == b.endpoint);
+}
+
+/** General handle type.
+ * Used by various USB functions as opaque handle.
+ */
+typedef ipcarg_t usb_handle_t;
+
+/** USB packet identifier. */
+typedef enum {
+#define _MAKE_PID_NIBBLE(tag, type) \
+	((uint8_t)(((tag) << 2) | (type)))
+#define _MAKE_PID(tag, type) \
+	( \
+	    _MAKE_PID_NIBBLE(tag, type) \
+	    | ((~_MAKE_PID_NIBBLE(tag, type)) << 4) \
+	)
+	USB_PID_OUT = _MAKE_PID(0, 1),
+	USB_PID_IN = _MAKE_PID(2, 1),
+	USB_PID_SOF = _MAKE_PID(1, 1),
+	USB_PID_SETUP = _MAKE_PID(3, 1),
+
+	USB_PID_DATA0 = _MAKE_PID(0 ,3),
+	USB_PID_DATA1 = _MAKE_PID(2 ,3),
+
+	USB_PID_ACK = _MAKE_PID(0 ,2),
+	USB_PID_NAK = _MAKE_PID(2 ,2),
+	USB_PID_STALL = _MAKE_PID(3 ,2),
+
+	USB_PID_PRE = _MAKE_PID(3 ,0),
+	/* USB_PID_ = _MAKE_PID( ,), */
+#undef _MAKE_PID
+#undef _MAKE_PID_NIBBLE
+} usb_packet_id;
+
+#endif
+/**
+ * @}
+ */
Index: uspace/lib/usb/include/usb/usbdrv.h
===================================================================
--- uspace/lib/usb/include/usb/usbdrv.h	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
+++ uspace/lib/usb/include/usb/usbdrv.h	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * 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 libusb usb
+ * @{
+ */
+/** @file
+ * @brief USB driver.
+ */
+#ifndef LIBUSB_USBDRV_H_
+#define LIBUSB_USBDRV_H_
+
+#include "usb.h"
+#include <driver.h>
+
+int usb_drv_hc_connect(device_t *, unsigned int);
+
+usb_address_t usb_drv_get_my_address(int, device_t *);
+
+int usb_drv_async_interrupt_out(int, usb_target_t,
+    void *, size_t, usb_handle_t *);
+int usb_drv_async_interrupt_in(int, usb_target_t,
+    void *, size_t, size_t *, usb_handle_t *);
+
+int usb_drv_async_wait_for(usb_handle_t);
+
+#endif
+/**
+ * @}
+ */
Index: uspace/lib/usb/src/hcdhubd.c
===================================================================
--- uspace/lib/usb/src/hcdhubd.c	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
+++ uspace/lib/usb/src/hcdhubd.c	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
@@ -0,0 +1,349 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * 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 libusb usb
+ * @{
+ */
+/** @file
+ * @brief HC driver and hub driver (implementation).
+ */
+#include <usb/hcdhubd.h>
+#include <usb_iface.h>
+#include <driver.h>
+#include <bool.h>
+#include <errno.h>
+
+/** List of handled host controllers. */
+static LIST_INITIALIZE(hc_list);
+
+/** Our HC driver. */
+static usb_hc_driver_t *hc_driver = NULL;
+
+static usb_iface_t usb_interface = {
+	.interrupt_out = NULL,
+	.interrupt_in = NULL
+};
+
+static device_ops_t usb_device_ops = {
+	.interfaces[USB_DEV_IFACE] = &usb_interface
+};
+
+/** Callback when new device is detected and must be handled by this driver.
+ *
+ * @param dev New device.
+ * @return Error code.
+ */
+static int add_device(device_t *dev)
+{
+	/*
+	 * FIXME: use some magic to determine whether hub or another HC
+	 * was connected.
+	 */
+	bool is_hc = true;
+
+	if (is_hc) {
+		/*
+		 * We are the HC itself.
+		 */
+		usb_hc_device_t *hc_dev = malloc(sizeof(usb_hc_device_t));
+		list_initialize(&hc_dev->link);
+		hc_dev->transfer_ops = NULL;
+
+		hc_dev->generic = dev;
+		dev->ops = &usb_device_ops;
+		hc_dev->generic->driver_data = hc_dev;
+
+		int rc = hc_driver->add_hc(hc_dev);
+		if (rc != EOK) {
+			free(hc_dev);
+			return rc;
+		}
+
+		/*
+		 * FIXME: The following line causes devman to hang.
+		 * Will investigate later why.
+		 */
+		// add_device_to_class(dev, "usbhc");
+
+		list_append(&hc_dev->link, &hc_list);
+
+		return EOK;
+	} else {
+		/*
+		 * We are some (probably deeply nested) hub.
+		 * Thus, assign our own operations and explore already
+		 * connected devices.
+		 */
+		return ENOTSUP;
+	}
+}
+
+/** Check changes on all known hubs.
+ */
+static void check_hub_changes(void)
+{
+	/*
+	 * Iterate through all HCs.
+	 */
+	link_t *link_hc;
+	for (link_hc = hc_list.next;
+	    link_hc != &hc_list;
+	    link_hc = link_hc->next) {
+		usb_hc_device_t *hc = list_get_instance(link_hc,
+		    usb_hc_device_t, link);
+		/*
+		 * Iterate through all their hubs.
+		 */
+		link_t *link_hub;
+		for (link_hub = hc->hubs.next;
+		    link_hub != &hc->hubs;
+		    link_hub = link_hub->next) {
+			usb_hcd_hub_info_t *hub = list_get_instance(link_hub,
+			    usb_hcd_hub_info_t, link);
+
+			/*
+			 * Check status change pipe of this hub.
+			 */
+			usb_target_t target = {
+				.address = hub->device->address,
+				.endpoint = 1
+			};
+
+			// FIXME: count properly
+			size_t byte_length = (hub->port_count / 8) + 1;
+
+			void *change_bitmap = malloc(byte_length);
+			size_t actual_size;
+			usb_handle_t handle;
+
+			/*
+			 * Send the request.
+			 * FIXME: check returned value for possible errors
+			 */
+			usb_hc_async_interrupt_in(hc, target,
+			    change_bitmap, byte_length, &actual_size,
+			    &handle);
+
+			usb_hc_async_wait_for(handle);
+
+			/*
+			 * TODO: handle the changes.
+			 */
+		}
+	}
+}
+
+/** Operations for combined HC and HUB driver. */
+static driver_ops_t hc_driver_generic_ops = {
+	.add_device = add_device
+};
+
+/** Combined HC and HUB driver. */
+static driver_t hc_driver_generic = {
+	.driver_ops = &hc_driver_generic_ops
+};
+
+/** Main USB host controller driver routine.
+ *
+ * @see driver_main
+ *
+ * @param hc Host controller driver.
+ * @return Error code.
+ */
+int usb_hcd_main(usb_hc_driver_t *hc)
+{
+	hc_driver = hc;
+	hc_driver_generic.name = hc->name;
+
+	/*
+	 * Launch here fibril that will periodically check all
+	 * attached hubs for status change.
+	 * WARN: This call will effectively do nothing.
+	 */
+	check_hub_changes();
+
+	/*
+	 * Run the device driver framework.
+	 */
+	return driver_main(&hc_driver_generic);
+}
+
+/** Add a root hub for given host controller.
+ * This function shall be called only once for each host controller driven
+ * by this driver.
+ * It takes care of creating child device - hub - that will be driven by
+ * this task.
+ *
+ * @param dev Host controller device.
+ * @return Error code.
+ */
+int usb_hcd_add_root_hub(usb_hc_device_t *dev)
+{
+	int rc;
+
+	/*
+	 * For testing/debugging purposes only.
+	 * Try to send some data to default USB address.
+	 */
+	usb_target_t target = {0, 0};
+	usb_handle_t handle = 0;
+	char *data = (char *) "Hello, World!";
+
+
+	(void)usb_hc_async_interrupt_out(dev, target, data, str_length(data), &handle);
+	(void)usb_hc_async_wait_for(handle);
+
+	/*
+	 * Announce presence of child device.
+	 */
+	device_t *hub = NULL;
+	match_id_t *match_id = NULL;
+
+	hub = create_device();
+	if (hub == NULL) {
+		rc = ENOMEM;
+		goto failure;
+	}
+	hub->name = "usbhub";
+
+	match_id = create_match_id();
+	if (match_id == NULL) {
+		rc = ENOMEM;
+		goto failure;
+	}
+
+	char *id;
+	rc = asprintf(&id, "usb&hc=%s&hub", dev->generic->name);
+	if (rc <= 0) {
+		rc = ENOMEM;
+		goto failure;
+	}
+
+	match_id->id = id;
+	match_id->score = 30;
+
+	add_match_id(&hub->match_ids, match_id);
+
+	rc = child_device_register(hub, dev->generic);
+	if (rc != EOK) {
+		goto failure;
+	}
+
+	printf("%s: registered root hub\n", dev->generic->name);
+	return EOK;
+
+failure:
+	if (hub != NULL) {
+		hub->name = NULL;
+		delete_device(hub);
+	}
+	delete_match_id(match_id);
+
+	return rc;
+}
+
+/** Issue interrupt OUT transfer to HC driven by current task.
+ *
+ * @param hc Host controller to handle the transfer.
+ * @param target Target device address.
+ * @param buffer Data buffer.
+ * @param size Buffer size.
+ * @param handle Transfer handle.
+ * @return Error code.
+ */
+int usb_hc_async_interrupt_out(usb_hc_device_t *hc, usb_target_t target,
+    void *buffer, size_t size,
+    usb_handle_t *handle)
+{
+	if ((hc->transfer_ops == NULL)
+	    || (hc->transfer_ops->transfer_out == NULL)) {
+		return ENOTSUP;
+	}
+
+	/*
+	 * For debugging purposes only.
+	 * We need to find appropriate device in list of managed device
+	 * and pass it to the transfer callback function.
+	 */
+	usb_hcd_attached_device_info_t dev = {
+		.address = target.address,
+		.endpoint_count = 0,
+		.endpoints = NULL,
+	};
+	usb_hc_endpoint_info_t endpoint = {
+		.endpoint = target.endpoint,
+		.transfer_type = USB_TRANSFER_INTERRUPT,
+		.direction = USB_DIRECTION_OUT,
+		.data_toggle = 0
+	};
+
+	hc->transfer_ops->transfer_out(hc, &dev, &endpoint, buffer, size, NULL, NULL);
+
+	*handle = NULL;
+
+	return EOK;
+}
+
+
+/** Issue interrupt IN transfer to HC driven by current task.
+ *
+ * @warning The @p buffer and @p actual_size parameters shall not be
+ * touched until this transfer is waited for by usb_hc_async_wait_for().
+ *
+ * @param hc Host controller to handle the transfer.
+ * @param target Target device address.
+ * @param buffer Data buffer.
+ * @param size Buffer size.
+ * @param actual_size Size of actually transferred data.
+ * @param handle Transfer handle.
+ * @return Error code.
+ */
+int usb_hc_async_interrupt_in(usb_hc_device_t *hc, usb_target_t target,
+    void *buffer, size_t size, size_t *actual_size,
+    usb_handle_t *handle)
+{
+	/*
+	 * TODO: verify that given endpoint is of interrupt type and
+	 * call hc->transfer_ops->transfer_in()
+	 */
+	return ENOTSUP;
+}
+
+/** Wait for transfer to complete.
+ *
+ * @param handle Transfer handle.
+ * @return Error code.
+ */
+int usb_hc_async_wait_for(usb_handle_t handle)
+{
+	return ENOTSUP;
+}
+
+/**
+ * @}
+ */
Index: uspace/lib/usb/src/usb.c
===================================================================
--- uspace/lib/usb/src/usb.c	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
+++ uspace/lib/usb/src/usb.c	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * 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 libusb usb
+ * @{
+ */
+/** @file
+ * @brief Base USB types.
+ */
+#include <usb/usb.h>
+#include <errno.h>
+
+
+/** String representation for USB transfer type. */
+const char * usb_str_transfer_type(usb_transfer_type_t t)
+{
+	switch (t) {
+		case USB_TRANSFER_ISOCHRONOUS:
+			return "isochronous";
+		case USB_TRANSFER_INTERRUPT:
+			return "interrupt";
+		case USB_TRANSFER_CONTROL:
+			return "control";
+		case USB_TRANSFER_BULK:
+			return "bulk";
+		default:
+			return "unknown";
+	}
+}
+
+/** String representation of USB transaction outcome. */
+const char * usb_str_transaction_outcome(usb_transaction_outcome_t o)
+{
+	switch (o) {
+		case USB_OUTCOME_OK:
+			return "ok";
+		case USB_OUTCOME_CRCERROR:
+			return "CRC error";
+		case USB_OUTCOME_BABBLE:
+			return "babble";
+		default:
+			return "unknown";
+	}
+}
+
+
+/**
+ * @}
+ */
Index: uspace/lib/usb/src/usbdrv.c
===================================================================
--- uspace/lib/usb/src/usbdrv.c	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
+++ uspace/lib/usb/src/usbdrv.c	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
@@ -0,0 +1,327 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * 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 libusb usb
+ * @{
+ */
+/** @file
+ * @brief USB driver (implementation).
+ */
+#include <usb/usbdrv.h>
+#include <usb_iface.h>
+#include <errno.h>
+
+/** Information about pending transaction on HC. */
+typedef struct {
+	/** Phone to host controller driver. */
+	int phone;
+	/** Data buffer. */
+	void *buffer;
+	/** Buffer size. */
+	size_t size;
+	/** Storage for actual number of bytes transferred. */
+	size_t *size_transferred;
+	/** Initial call replay data. */
+	ipc_call_t reply;
+	/** Initial call identifier. */
+	aid_t request;
+} transfer_info_t;
+
+/** Connect to host controller the device is physically attached to.
+ *
+ * @param handle Device handle.
+ * @param flags Connection flags (blocking connection).
+ * @return Phone to corresponding HC or error code.
+ */
+int usb_drv_hc_connect(device_t *dev, unsigned int flags)
+{
+	/*
+	 * Call parent hub to obtain device handle of respective HC.
+	 */
+	return ENOTSUP;
+}
+
+/** Tell USB address assigned to given device.
+ *
+ * @param phone Phone to my HC.
+ * @param dev Device in question.
+ * @return USB address or error code.
+ */
+usb_address_t usb_drv_get_my_address(int phone, device_t *dev)
+{
+	return ENOTSUP;
+}
+
+/** Send data to HCD.
+ *
+ * @param phone Phone to HC.
+ * @param method Method used for calling.
+ * @param target Targeted device.
+ * @param buffer Data buffer (NULL to skip data transfer phase).
+ * @param size Buffer size (must be zero when @p buffer is NULL).
+ * @param handle Storage for transaction handle (cannot be NULL).
+ * @return Error status.
+ * @retval EINVAL Invalid parameter.
+ * @retval ENOMEM Not enough memory to complete the operation.
+ */
+static int async_send_buffer(int phone, int method,
+    usb_target_t target,
+    void *buffer, size_t size,
+    usb_handle_t *handle)
+{
+	if (phone < 0) {
+		return EINVAL;
+	}
+
+	if ((buffer == NULL) && (size > 0)) {
+		return EINVAL;
+	}
+
+	if (handle == NULL) {
+		return EINVAL;
+	}
+
+	transfer_info_t *transfer
+	    = (transfer_info_t *) malloc(sizeof(transfer_info_t));
+	if (transfer == NULL) {
+		return ENOMEM;
+	}
+
+	transfer->size_transferred = NULL;
+	transfer->buffer = NULL;
+	transfer->size = 0;
+	transfer->phone = phone;
+
+	int rc;
+
+	transfer->request = async_send_4(phone,
+	    DEV_IFACE_ID(USB_DEV_IFACE),
+	    method,
+	    target.address, target.endpoint,
+	    size,
+	    &transfer->reply);
+
+	if (size > 0) {
+		rc = async_data_write_start(phone, buffer, size);
+		if (rc != EOK) {
+			async_wait_for(transfer->request, NULL);
+			return rc;
+		}
+	}
+
+	*handle = (usb_handle_t) transfer;
+
+	return EOK;
+}
+
+/** Prepare data retrieval.
+ *
+ * @param phone Opened phone to HCD.
+ * @param method Method used for calling.
+ * @param target Targeted device.
+ * @param buffer Buffer where to store retrieved data
+ * 	(NULL to skip data transfer phase).
+ * @param size Buffer size (must be zero when @p buffer is NULL).
+ * @param actual_size Storage where actual number of bytes transferred will
+ * 	be stored.
+ * @param handle Storage for transaction handle (cannot be NULL).
+ * @return Error status.
+ * @retval EINVAL Invalid parameter.
+ * @retval ENOMEM Not enough memory to complete the operation.
+ */
+static int async_recv_buffer(int phone, int method,
+    usb_target_t target,
+    void *buffer, size_t size, size_t *actual_size,
+    usb_handle_t *handle)
+{
+	if (phone < 0) {
+		return EINVAL;
+	}
+
+	if ((buffer == NULL) && (size > 0)) {
+		return EINVAL;
+	}
+
+	if (handle == NULL) {
+		return EINVAL;
+	}
+
+	transfer_info_t *transfer
+	    = (transfer_info_t *) malloc(sizeof(transfer_info_t));
+	if (transfer == NULL) {
+		return ENOMEM;
+	}
+
+	transfer->size_transferred = actual_size;
+	transfer->buffer = buffer;
+	transfer->size = size;
+	transfer->phone = phone;
+
+	transfer->request = async_send_4(phone,
+	    DEV_IFACE_ID(USB_DEV_IFACE),
+	    method,
+	    target.address, target.endpoint,
+	    size,
+	    &transfer->reply);
+
+	*handle = (usb_handle_t) transfer;
+
+	return EOK;
+}
+
+/** Read buffer from HCD.
+ *
+ * @param phone Opened phone to HCD.
+ * @param hash Buffer hash (obtained after completing IN transaction).
+ * @param buffer Buffer where to store data data.
+ * @param size Buffer size.
+ * @param actual_size Storage where actual number of bytes transferred will
+ * 	be stored.
+ * @return Error status.
+ */
+static int read_buffer_in(int phone, ipcarg_t hash,
+    void *buffer, size_t size, size_t *actual_size)
+{
+	ipc_call_t answer_data;
+	ipcarg_t answer_rc;
+	aid_t req;
+	int rc;
+
+	req = async_send_2(phone,
+	    DEV_IFACE_ID(USB_DEV_IFACE),
+	    IPC_M_USB_GET_BUFFER,
+	    hash,
+	    &answer_data);
+
+	rc = async_data_read_start(phone, buffer, size);
+	if (rc != EOK) {
+		async_wait_for(req, NULL);
+		return EINVAL;
+	}
+
+	async_wait_for(req, &answer_rc);
+	rc = (int)answer_rc;
+
+	if (rc != EOK) {
+		return rc;
+	}
+
+	*actual_size = IPC_GET_ARG1(answer_data);
+
+	return EOK;
+}
+
+/** Blocks caller until given USB transaction is finished.
+ * After the transaction is finished, the user can access all output data
+ * given to initial call function.
+ *
+ * @param handle Transaction handle.
+ * @return Error status.
+ * @retval EOK No error.
+ * @retval EBADMEM Invalid handle.
+ * @retval ENOENT Data buffer associated with transaction does not exist.
+ */
+int usb_drv_async_wait_for(usb_handle_t handle)
+{
+	if (handle == 0) {
+		return EBADMEM;
+	}
+
+	int rc = EOK;
+
+	transfer_info_t *transfer = (transfer_info_t *) handle;
+
+	ipcarg_t answer_rc;
+	async_wait_for(transfer->request, &answer_rc);
+
+	if (answer_rc != EOK) {
+		rc = (int) answer_rc;
+		goto leave;
+	}
+
+	/*
+	 * If the buffer is not NULL, we must accept some data.
+	 */
+	if ((transfer->buffer != NULL) && (transfer->size > 0)) {
+		/*
+		 * The buffer hash identifies the data on the server
+		 * side.
+		 * We will use it when actually reading-in the data.
+		 */
+		ipcarg_t buffer_hash = IPC_GET_ARG1(transfer->reply);
+		if (buffer_hash == 0) {
+			rc = ENOENT;
+			goto leave;
+		}
+
+		size_t actual_size;
+		rc = read_buffer_in(transfer->phone, buffer_hash,
+		    transfer->buffer, transfer->size, &actual_size);
+
+		if (rc != EOK) {
+			goto leave;
+		}
+
+		if (transfer->size_transferred) {
+			*(transfer->size_transferred) = actual_size;
+		}
+	}
+
+leave:
+	free(transfer);
+
+	return rc;
+}
+
+/** Send interrupt data to device. */
+int usb_drv_async_interrupt_out(int phone, usb_target_t target,
+    void *buffer, size_t size,
+    usb_handle_t *handle)
+{
+	return async_send_buffer(phone,
+	    IPC_M_USB_INTERRUPT_OUT,
+	    target,
+	    buffer, size,
+	    handle);
+}
+
+/** Request interrupt data from device. */
+int usb_drv_async_interrupt_in(int phone, usb_target_t target,
+    void *buffer, size_t size, size_t *actual_size,
+    usb_handle_t *handle)
+{
+	return async_recv_buffer(phone,
+	    IPC_M_USB_INTERRUPT_IN,
+	    target,
+	    buffer, size, actual_size,
+	    handle);
+}
+
+/**
+ * @}
+ */
Index: pace/lib/usb/usb.c
===================================================================
--- uspace/lib/usb/usb.c	(revision 0e126be78770a2c37ac932b2e25dd35bdc34e12e)
+++ 	(revision )
@@ -1,74 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * 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 libusb usb
- * @{
- */
-/** @file
- * @brief Base USB types.
- */
-#include "usb.h"
-#include <errno.h>
-
-
-/** String representation for USB transfer type. */
-const char * usb_str_transfer_type(usb_transfer_type_t t)
-{
-	switch (t) {
-		case USB_TRANSFER_ISOCHRONOUS:
-			return "isochronous";
-		case USB_TRANSFER_INTERRUPT:
-			return "interrupt";
-		case USB_TRANSFER_CONTROL:
-			return "control";
-		case USB_TRANSFER_BULK:
-			return "bulk";
-		default:
-			return "unknown";
-	}
-}
-
-/** String representation of USB transaction outcome. */
-const char * usb_str_transaction_outcome(usb_transaction_outcome_t o)
-{
-	switch (o) {
-		case USB_OUTCOME_OK:
-			return "ok";
-		case USB_OUTCOME_CRCERROR:
-			return "CRC error";
-		case USB_OUTCOME_BABBLE:
-			return "babble";
-		default:
-			return "unknown";
-	}
-}
-
-
-/**
- * @}
- */
Index: pace/lib/usb/usb.h
===================================================================
--- uspace/lib/usb/usb.h	(revision 0e126be78770a2c37ac932b2e25dd35bdc34e12e)
+++ 	(revision )
@@ -1,103 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * 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 libusb usb
- * @{
- */
-/** @file
- * @brief Base USB types.
- */
-#ifndef LIBUSB_USB_H_
-#define LIBUSB_USB_H_
-
-#include <sys/types.h>
-#include <ipc/ipc.h>
-
-/** USB transfer type. */
-typedef enum {
-	USB_TRANSFER_CONTROL = 0,
-	USB_TRANSFER_ISOCHRONOUS = 1,
-	USB_TRANSFER_BULK = 2,
-	USB_TRANSFER_INTERRUPT = 3
-} usb_transfer_type_t;
-
-const char * usb_str_transfer_type(usb_transfer_type_t t);
-
-/** USB data transfer direction. */
-typedef enum {
-	USB_DIRECTION_IN,
-	USB_DIRECTION_OUT
-} usb_direction_t;
-
-/** USB transaction outcome. */
-typedef enum {
-	USB_OUTCOME_OK,
-	USB_OUTCOME_CRCERROR,
-	USB_OUTCOME_BABBLE
-} usb_transaction_outcome_t;
-
-const char * usb_str_transaction_outcome(usb_transaction_outcome_t o);
-
-/** USB address type.
- * Negative values could be used to indicate error.
- */
-typedef int usb_address_t;
-
-/** USB endpoint number type.
- * Negative values could be used to indicate error.
- */
-typedef int usb_endpoint_t;
-
-/** Maximum endpoint number in USB 1.1.
- */
-#define USB11_ENDPOINT_MAX 16
-
-
-/** USB complete address type. 
- * Pair address + endpoint is identification of transaction recipient.
- */
-typedef struct {
-	usb_address_t address;
-	usb_endpoint_t endpoint;
-} usb_target_t;
-
-static inline int usb_target_same(usb_target_t a, usb_target_t b)
-{
-	return (a.address == b.address)
-	    && (a.endpoint == b.endpoint);
-}
-
-/** General handle type.
- * Used by various USB functions as opaque handle.
- */
-typedef ipcarg_t usb_handle_t;
-
-#endif
-/**
- * @}
- */
Index: pace/lib/usb/usbdrv.c
===================================================================
--- uspace/lib/usb/usbdrv.c	(revision 0e126be78770a2c37ac932b2e25dd35bdc34e12e)
+++ 	(revision )
@@ -1,327 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * 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 libusb usb
- * @{
- */
-/** @file
- * @brief USB driver (implementation).
- */
-#include "usbdrv.h"
-#include <usb_iface.h>
-#include <errno.h>
-
-/** Information about pending transaction on HC. */
-typedef struct {
-	/** Phone to host controller driver. */
-	int phone;
-	/** Data buffer. */
-	void *buffer;
-	/** Buffer size. */
-	size_t size;
-	/** Storage for actual number of bytes transferred. */
-	size_t *size_transferred;
-	/** Initial call replay data. */
-	ipc_call_t reply;
-	/** Initial call identifier. */
-	aid_t request;
-} transfer_info_t;
-
-/** Connect to host controller the device is physically attached to.
- *
- * @param handle Device handle.
- * @param flags Connection flags (blocking connection).
- * @return Phone to corresponding HC or error code.
- */
-int usb_drv_hc_connect(device_t *dev, unsigned int flags)
-{
-	/*
-	 * Call parent hub to obtain device handle of respective HC.
-	 */
-	return ENOTSUP;
-}
-
-/** Tell USB address assigned to given device.
- *
- * @param phone Phone to my HC.
- * @param dev Device in question.
- * @return USB address or error code.
- */
-usb_address_t usb_drv_get_my_address(int phone, device_t *dev)
-{
-	return ENOTSUP;
-}
-
-/** Send data to HCD.
- *
- * @param phone Phone to HC.
- * @param method Method used for calling.
- * @param target Targeted device.
- * @param buffer Data buffer (NULL to skip data transfer phase).
- * @param size Buffer size (must be zero when @p buffer is NULL).
- * @param handle Storage for transaction handle (cannot be NULL).
- * @return Error status.
- * @retval EINVAL Invalid parameter.
- * @retval ENOMEM Not enough memory to complete the operation.
- */
-static int async_send_buffer(int phone, int method,
-    usb_target_t target,
-    void *buffer, size_t size,
-    usb_handle_t *handle)
-{
-	if (phone < 0) {
-		return EINVAL;
-	}
-
-	if ((buffer == NULL) && (size > 0)) {
-		return EINVAL;
-	}
-
-	if (handle == NULL) {
-		return EINVAL;
-	}
-
-	transfer_info_t *transfer
-	    = (transfer_info_t *) malloc(sizeof(transfer_info_t));
-	if (transfer == NULL) {
-		return ENOMEM;
-	}
-
-	transfer->size_transferred = NULL;
-	transfer->buffer = NULL;
-	transfer->size = 0;
-	transfer->phone = phone;
-
-	int rc;
-
-	transfer->request = async_send_4(phone,
-	    DEV_IFACE_ID(USB_DEV_IFACE),
-	    method,
-	    target.address, target.endpoint,
-	    size,
-	    &transfer->reply);
-
-	if (size > 0) {
-		rc = async_data_write_start(phone, buffer, size);
-		if (rc != EOK) {
-			async_wait_for(transfer->request, NULL);
-			return rc;
-		}
-	}
-
-	*handle = (usb_handle_t) transfer;
-
-	return EOK;
-}
-
-/** Prepare data retrieval.
- *
- * @param phone Opened phone to HCD.
- * @param method Method used for calling.
- * @param target Targeted device.
- * @param buffer Buffer where to store retrieved data
- * 	(NULL to skip data transfer phase).
- * @param size Buffer size (must be zero when @p buffer is NULL).
- * @param actual_size Storage where actual number of bytes transferred will
- * 	be stored.
- * @param handle Storage for transaction handle (cannot be NULL).
- * @return Error status.
- * @retval EINVAL Invalid parameter.
- * @retval ENOMEM Not enough memory to complete the operation.
- */
-static int async_recv_buffer(int phone, int method,
-    usb_target_t target,
-    void *buffer, size_t size, size_t *actual_size,
-    usb_handle_t *handle)
-{
-	if (phone < 0) {
-		return EINVAL;
-	}
-
-	if ((buffer == NULL) && (size > 0)) {
-		return EINVAL;
-	}
-
-	if (handle == NULL) {
-		return EINVAL;
-	}
-
-	transfer_info_t *transfer
-	    = (transfer_info_t *) malloc(sizeof(transfer_info_t));
-	if (transfer == NULL) {
-		return ENOMEM;
-	}
-
-	transfer->size_transferred = actual_size;
-	transfer->buffer = buffer;
-	transfer->size = size;
-	transfer->phone = phone;
-
-	transfer->request = async_send_4(phone,
-	    DEV_IFACE_ID(USB_DEV_IFACE),
-	    method,
-	    target.address, target.endpoint,
-	    size,
-	    &transfer->reply);
-
-	*handle = (usb_handle_t) transfer;
-
-	return EOK;
-}
-
-/** Read buffer from HCD.
- *
- * @param phone Opened phone to HCD.
- * @param hash Buffer hash (obtained after completing IN transaction).
- * @param buffer Buffer where to store data data.
- * @param size Buffer size.
- * @param actual_size Storage where actual number of bytes transferred will
- * 	be stored.
- * @return Error status.
- */
-static int read_buffer_in(int phone, ipcarg_t hash,
-    void *buffer, size_t size, size_t *actual_size)
-{
-	ipc_call_t answer_data;
-	ipcarg_t answer_rc;
-	aid_t req;
-	int rc;
-
-	req = async_send_2(phone,
-	    DEV_IFACE_ID(USB_DEV_IFACE),
-	    IPC_M_USB_GET_BUFFER,
-	    hash,
-	    &answer_data);
-
-	rc = async_data_read_start(phone, buffer, size);
-	if (rc != EOK) {
-		async_wait_for(req, NULL);
-		return EINVAL;
-	}
-
-	async_wait_for(req, &answer_rc);
-	rc = (int)answer_rc;
-
-	if (rc != EOK) {
-		return rc;
-	}
-
-	*actual_size = IPC_GET_ARG1(answer_data);
-
-	return EOK;
-}
-
-/** Blocks caller until given USB transaction is finished.
- * After the transaction is finished, the user can access all output data
- * given to initial call function.
- *
- * @param handle Transaction handle.
- * @return Error status.
- * @retval EOK No error.
- * @retval EBADMEM Invalid handle.
- * @retval ENOENT Data buffer associated with transaction does not exist.
- */
-int usb_drv_async_wait_for(usb_handle_t handle)
-{
-	if (handle == 0) {
-		return EBADMEM;
-	}
-
-	int rc = EOK;
-
-	transfer_info_t *transfer = (transfer_info_t *) handle;
-
-	ipcarg_t answer_rc;
-	async_wait_for(transfer->request, &answer_rc);
-
-	if (answer_rc != EOK) {
-		rc = (int) answer_rc;
-		goto leave;
-	}
-
-	/*
-	 * If the buffer is not NULL, we must accept some data.
-	 */
-	if ((transfer->buffer != NULL) && (transfer->size > 0)) {
-		/*
-		 * The buffer hash identifies the data on the server
-		 * side.
-		 * We will use it when actually reading-in the data.
-		 */
-		ipcarg_t buffer_hash = IPC_GET_ARG1(transfer->reply);
-		if (buffer_hash == 0) {
-			rc = ENOENT;
-			goto leave;
-		}
-
-		size_t actual_size;
-		rc = read_buffer_in(transfer->phone, buffer_hash,
-		    transfer->buffer, transfer->size, &actual_size);
-
-		if (rc != EOK) {
-			goto leave;
-		}
-
-		if (transfer->size_transferred) {
-			*(transfer->size_transferred) = actual_size;
-		}
-	}
-
-leave:
-	free(transfer);
-
-	return rc;
-}
-
-/** Send interrupt data to device. */
-int usb_drv_async_interrupt_out(int phone, usb_target_t target,
-    void *buffer, size_t size,
-    usb_handle_t *handle)
-{
-	return async_send_buffer(phone,
-	    IPC_M_USB_INTERRUPT_OUT,
-	    target,
-	    buffer, size,
-	    handle);
-}
-
-/** Request interrupt data from device. */
-int usb_drv_async_interrupt_in(int phone, usb_target_t target,
-    void *buffer, size_t size, size_t *actual_size,
-    usb_handle_t *handle)
-{
-	return async_recv_buffer(phone,
-	    IPC_M_USB_INTERRUPT_IN,
-	    target,
-	    buffer, size, actual_size,
-	    handle);
-}
-
-/**
- * @}
- */
Index: pace/lib/usb/usbdrv.h
===================================================================
--- uspace/lib/usb/usbdrv.h	(revision 0e126be78770a2c37ac932b2e25dd35bdc34e12e)
+++ 	(revision )
@@ -1,55 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * 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 libusb usb
- * @{
- */
-/** @file
- * @brief USB driver.
- */
-#ifndef LIBUSB_USBDRV_H_
-#define LIBUSB_USBDRV_H_
-
-#include "usb.h"
-#include <driver.h>
-
-int usb_drv_hc_connect(device_t *, unsigned int);
-
-usb_address_t usb_drv_get_my_address(int, device_t *);
-
-int usb_drv_async_interrupt_out(int, usb_target_t,
-    void *, size_t, usb_handle_t *);
-int usb_drv_async_interrupt_in(int, usb_target_t,
-    void *, size_t, size_t *, usb_handle_t *);
-
-int usb_drv_async_wait_for(usb_handle_t);
-
-#endif
-/**
- * @}
- */
Index: uspace/lib/usbvirt/Makefile
===================================================================
--- uspace/lib/usbvirt/Makefile	(revision 0e126be78770a2c37ac932b2e25dd35bdc34e12e)
+++ uspace/lib/usbvirt/Makefile	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
@@ -31,5 +31,5 @@
 
 LIBS = $(LIBUSB_PREFIX)/libusb.a
-EXTRA_CFLAGS = -I$(LIB_PREFIX)
+EXTRA_CFLAGS = -I$(LIBUSB_PREFIX)/include
 
 SOURCES = \
Index: uspace/lib/usbvirt/callback.c
===================================================================
--- uspace/lib/usbvirt/callback.c	(revision 0e126be78770a2c37ac932b2e25dd35bdc34e12e)
+++ uspace/lib/usbvirt/callback.c	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
@@ -45,4 +45,5 @@
 
 #define NAMESPACE "usb"
+#define USB_MAX_PAYLOAD_SIZE 1020
 
 /** Wrapper for SETUP transaction over telephone. */
Index: uspace/lib/usbvirt/device.h
===================================================================
--- uspace/lib/usbvirt/device.h	(revision 0e126be78770a2c37ac932b2e25dd35bdc34e12e)
+++ uspace/lib/usbvirt/device.h	(revision 4b4c797d23deaa3f0f365f40c3d0d3960c0218c7)
@@ -36,5 +36,5 @@
 #define LIBUSBVIRT_DEVICE_H_
 
-#include <usb/hcd.h>
+#include <usb/usb.h>
 #include <usb/descriptor.h>
 #include <usb/devreq.h>
