Index: uspace/drv/isa/isa.c
===================================================================
--- uspace/drv/isa/isa.c	(revision 61257f414d6dfc36c096abb542ed95e187bfb391)
+++ uspace/drv/isa/isa.c	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -53,4 +53,5 @@
 
 #include <ddf/driver.h>
+#include <ddf/log.h>
 #include <ops/hw_res.h>
 
@@ -134,5 +135,5 @@
 	fd = open(conf_path, O_RDONLY);
 	if (fd < 0) {
-		printf(NAME ": unable to open %s\n", conf_path);
+		ddf_msg(LVL_ERROR, "Unable to open %s", conf_path);
 		goto cleanup;
 	}
@@ -141,8 +142,8 @@
 
 	len = lseek(fd, 0, SEEK_END);
-	lseek(fd, 0, SEEK_SET);	
+	lseek(fd, 0, SEEK_SET);
 	if (len == 0) {
-		printf(NAME ": fun_conf_read error: configuration file '%s' "
-		    "is empty.\n", conf_path);
+		ddf_msg(LVL_ERROR, "Configuration file '%s' is empty.",
+		    conf_path);
 		goto cleanup;
 	}
@@ -150,11 +151,10 @@
 	buf = malloc(len + 1);
 	if (buf == NULL) {
-		printf(NAME ": fun_conf_read error: memory allocation failed.\n");
+		ddf_msg(LVL_ERROR, "Memory allocation failed.");
 		goto cleanup;
 	}
 
 	if (0 >= read(fd, buf, len)) {
-		printf(NAME ": fun_conf_read error: unable to read file '%s'.\n",
-		    conf_path);
+		ddf_msg(LVL_ERROR, "Unable to read file '%s'.", conf_path);
 		goto cleanup;
 	}
@@ -252,5 +252,5 @@
 		fun->hw_resources.count++;
 
-		printf(NAME ": added irq 0x%x to function %s\n", irq,
+		ddf_msg(LVL_NOTE, "Added irq 0x%x to function %s", irq,
 		    fun->fnode->name);
 	}
@@ -270,6 +270,6 @@
 		fun->hw_resources.count++;
 
-		printf(NAME ": added io range (addr=0x%x, size=0x%x) to "
-		    "function %s\n", (unsigned int) addr, (unsigned int) len,
+		ddf_msg(LVL_NOTE, "Added io range (addr=0x%x, size=0x%x) to "
+		    "function %s", (unsigned int) addr, (unsigned int) len,
 		    fun->fnode->name);
 	}
@@ -331,6 +331,6 @@
 	score = (int)strtol(val, &end, 10);
 	if (val == end) {
-		printf(NAME " : error - could not read match score for "
-		    "function %s.\n", fun->fnode->name);
+		ddf_msg(LVL_ERROR, "Cannot read match score for function "
+		    "%s.", fun->fnode->name);
 		return;
 	}
@@ -339,15 +339,17 @@
 	get_match_id(&id, val);
 	if (id == NULL) {
-		printf(NAME " : error - could not read match id for "
-		    "function %s.\n", fun->fnode->name);
+		ddf_msg(LVL_ERROR, "Cannot read match ID for function %s.",
+		    fun->fnode->name);
 		return;
 	}
 
-	printf(NAME ": adding match id '%s' with score %d to function %s\n", id,
-	    score, fun->fnode->name);
+	ddf_msg(LVL_DEBUG, "Adding match id '%s' with score %d to "
+	    "function %s", id, score, fun->fnode->name);
 
 	rc = ddf_fun_add_match_id(fun->fnode, id, score);
-	if (rc != EOK)
-		printf(NAME ": error adding match ID: %s\n", str_error(rc));
+	if (rc != EOK) {
+		ddf_msg(LVL_ERROR, "Failed adding match ID: %s",
+		    str_error(rc));
+	}
 }
 
@@ -375,8 +377,8 @@
 	if (!prop_parse(fun, line, "io_range", &fun_parse_io_range) &&
 	    !prop_parse(fun, line, "irq", &fun_parse_irq) &&
-	    !prop_parse(fun, line, "match", &fun_parse_match_id))
-	{
-	    printf(NAME " error undefined device property at line '%s'\n",
-		line);
+	    !prop_parse(fun, line, "match", &fun_parse_match_id)) {
+
+		ddf_msg(LVL_ERROR, "Undefined device property at line '%s'",
+		    line);
 	}
 }
@@ -439,5 +441,5 @@
 	fun->fnode->ops = &isa_fun_ops;
 
-	printf(NAME ": Binding function %s.\n", fun->fnode->name);
+	ddf_msg(LVL_DEBUG, "Binding function %s.", fun->fnode->name);
 
 	/* XXX Handle error */
@@ -467,18 +469,18 @@
 static int isa_add_device(ddf_dev_t *dev)
 {
-	printf(NAME ": isa_add_device, device handle = %d\n",
+	ddf_msg(LVL_DEBUG, "isa_add_device, device handle = %d",
 	    (int) dev->handle);
 
 	/* Make the bus device more visible. Does not do anything. */
-	printf(NAME ": adding a 'ctl' function\n");
+	ddf_msg(LVL_DEBUG, "Adding a 'ctl' function");
 
 	ddf_fun_t *ctl = ddf_fun_create(dev, fun_exposed, "ctl");
 	if (ctl == NULL) {
-		printf(NAME ": Error creating control function.\n");
+		ddf_msg(LVL_ERROR, "Failed creating control function.");
 		return EXDEV;
 	}
 
 	if (ddf_fun_bind(ctl) != EOK) {
-		printf(NAME ": Error binding control function.\n");
+		ddf_msg(LVL_ERROR, "Failed binding control function.");
 		return EXDEV;
 	}
@@ -486,5 +488,5 @@
 	/* Add functions as specified in the configuration file. */
 	isa_functions_add(dev);
-	printf(NAME ": finished the enumeration of legacy functions\n");
+	ddf_msg(LVL_NOTE, "Finished enumerating legacy functions");
 
 	return EOK;
@@ -493,4 +495,5 @@
 static void isa_init() 
 {
+	ddf_log_init(NAME, LVL_ERROR);
 	isa_fun_ops.interfaces[HW_RES_DEV_IFACE] = &isa_fun_hw_res_ops;
 }
Index: uspace/drv/ns8250/ns8250.c
===================================================================
--- uspace/drv/ns8250/ns8250.c	(revision 61257f414d6dfc36c096abb542ed95e187bfb391)
+++ uspace/drv/ns8250/ns8250.c	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -55,4 +55,5 @@
 #include <ddf/driver.h>
 #include <ddf/interrupt.h>
+#include <ddf/log.h>
 #include <ops/char_dev.h>
 
@@ -275,11 +276,11 @@
 static bool ns8250_pio_enable(ns8250_t *ns)
 {
-	printf(NAME ": ns8250_pio_enable %s\n", ns->dev->name);
+	ddf_msg(LVL_DEBUG, "ns8250_pio_enable %s", ns->dev->name);
 	
 	/* Gain control over port's registers. */
 	if (pio_enable((void *)(uintptr_t) ns->io_addr, REG_COUNT,
 	    (void **) &ns->port)) {
-		printf(NAME ": error - cannot gain the port %#" PRIx32 " for device "
-		    "%s.\n", ns->io_addr, ns->dev->name);
+		ddf_msg(LVL_ERROR, "Cannot map the port %#" PRIx32
+		    " for device %s.", ns->io_addr, ns->dev->name);
 		return false;
 	}
@@ -295,5 +296,5 @@
 static bool ns8250_dev_probe(ns8250_t *ns)
 {
-	printf(NAME ": ns8250_dev_probe %s\n", ns->dev->name);
+	ddf_msg(LVL_DEBUG, "ns8250_dev_probe %s", ns->dev->name);
 	
 	ioport8_t *port_addr = ns->port;
@@ -313,6 +314,8 @@
 	pio_write_8(port_addr + 4, olddata);
 	
-	if (!res)
-		printf(NAME ": device %s is not present.\n", ns->dev->name);
+	if (!res) {
+		ddf_msg(LVL_DEBUG, "Device %s is not present.",
+		    ns->dev->name);
+	}
 	
 	return res;
@@ -326,5 +329,5 @@
 static int ns8250_dev_initialize(ns8250_t *ns)
 {
-	printf(NAME ": ns8250_dev_initialize %s\n", ns->dev->name);
+	ddf_msg(LVL_DEBUG, "ns8250_dev_initialize %s", ns->dev->name);
 	
 	int ret = EOK;
@@ -337,6 +340,6 @@
 	    IPC_FLAG_BLOCKING);
 	if (ns->dev->parent_phone < 0) {
-		printf(NAME ": failed to connect to the parent driver of the "
-		    "device %s.\n", ns->dev->name);
+		ddf_msg(LVL_ERROR, "Failed to connect to parent driver of "
+		    "device %s.", ns->dev->name);
 		ret = ns->dev->parent_phone;
 		goto failed;
@@ -346,6 +349,6 @@
 	ret = hw_res_get_resource_list(ns->dev->parent_phone, &hw_resources);
 	if (ret != EOK) {
-		printf(NAME ": failed to get hw resources for the device "
-		    "%s.\n", ns->dev->name);
+		ddf_msg(LVL_ERROR, "Failed to get HW resources for device "
+		    "%s.", ns->dev->name);
 		goto failed;
 	}
@@ -362,5 +365,5 @@
 			ns->irq = res->res.interrupt.irq;
 			irq = true;
-			printf(NAME ": the %s device was asigned irq = 0x%x.\n",
+			ddf_msg(LVL_NOTE, "Device %s was asigned irq = 0x%x.",
 			    ns->dev->name, ns->irq);
 			break;
@@ -369,13 +372,13 @@
 			ns->io_addr = res->res.io_range.address;
 			if (res->res.io_range.size < REG_COUNT) {
-				printf(NAME ": i/o range assigned to the device "
-				    "%s is too small.\n", ns->dev->name);
+				ddf_msg(LVL_ERROR, "I/O range assigned to "
+				    "device %s is too small.", ns->dev->name);
 				ret = ELIMIT;
 				goto failed;
 			}
 			ioport = true;
-			printf(NAME ": the %s device was asigned i/o address = "
-			    "0x%x.\n", ns->dev->name, ns->io_addr);
-			break;
+			ddf_msg(LVL_NOTE, "Device %s was asigned I/O address = "
+			    "0x%x.", ns->dev->name, ns->io_addr);
+    			break;
 			
 		default:
@@ -385,5 +388,5 @@
 	
 	if (!irq || !ioport) {
-		printf(NAME ": missing hw resource(s) for the device %s.\n",
+		ddf_msg(LVL_ERROR, "Missing HW resource(s) for device %s.",
 		    ns->dev->name);
 		ret = ENOENT;
@@ -470,6 +473,6 @@
 	
 	if (baud_rate < 50 || MAX_BAUD_RATE % baud_rate != 0) {
-		printf(NAME ": error - somebody tried to set invalid baud rate "
-		    "%d\n", baud_rate);
+		ddf_msg(LVL_ERROR, "Invalid baud rate %d requested.",
+		    baud_rate);
 		return EINVAL;
 	}
@@ -654,9 +657,9 @@
 			if (ns->client_connected) {
 				if (!buf_push_back(&ns->input_buffer, val)) {
-					printf(NAME ": buffer overflow on "
-					    "%s.\n", ns->dev->name);
+					ddf_msg(LVL_WARN, "Buffer overflow on "
+					    "%s.", ns->dev->name);
 				} else {
-					printf(NAME ": the character %c saved "
-					    "to the buffer of %s.\n",
+					ddf_msg(LVL_DEBUG2, "Character %c saved "
+					    "to the buffer of %s.",
 					    val, ns->dev->name);
 				}
@@ -714,5 +717,5 @@
 	int rc;
 	
-	printf(NAME ": ns8250_add_device %s (handle = %d)\n",
+	ddf_msg(LVL_DEBUG, "ns8250_add_device %s (handle = %d)",
 	    dev->name, (int) dev->handle);
 	
@@ -749,5 +752,5 @@
 	/* Register interrupt handler. */
 	if (ns8250_register_interrupt_handler(ns) != EOK) {
-		printf(NAME ": failed to register interrupt handler.\n");
+		ddf_msg(LVL_ERROR, "Failed to register interrupt handler.");
 		rc = EADDRNOTAVAIL;
 		goto fail;
@@ -757,6 +760,6 @@
 	rc = ns8250_interrupt_enable(ns);
 	if (rc != EOK) {
-		printf(NAME ": failed to enable the interrupt. Error code = "
-		    "%d.\n", rc);
+		ddf_msg(LVL_ERROR, "Failed to enable the interrupt. Error code = "
+		    "%d.", rc);
 		goto fail;
 	}
@@ -764,5 +767,5 @@
 	fun = ddf_fun_create(dev, fun_exposed, "a");
 	if (fun == NULL) {
-		printf(NAME ": error creating function.\n");
+		ddf_msg(LVL_ERROR, "Failed creating function.");
 		goto fail;
 	}
@@ -772,5 +775,5 @@
 	rc = ddf_fun_bind(fun);
 	if (rc != EOK) {
-		printf(NAME ": error binding function.\n");
+		ddf_msg(LVL_ERROR, "Failed binding function.");
 		goto fail;
 	}
@@ -780,5 +783,5 @@
 	ddf_fun_add_to_class(fun, "serial");
 	
-	printf(NAME ": the %s device has been successfully initialized.\n",
+	ddf_msg(LVL_NOTE, "Device %s successfully initialized.",
 	    dev->name);
 	
@@ -862,6 +865,6 @@
 	fibril_mutex_unlock(&data->mutex);
 	
-	printf(NAME ": ns8250_get_props: baud rate %d, parity 0x%x, word "
-	    "length %d, stop bits %d\n", *baud_rate, *parity, *word_length,
+	ddf_msg(LVL_DEBUG, "ns8250_get_props: baud rate %d, parity 0x%x, word "
+	    "length %d, stop bits %d", *baud_rate, *parity, *word_length,
 	    *stop_bits);
 }
@@ -879,6 +882,6 @@
     unsigned int parity, unsigned int word_length, unsigned int stop_bits)
 {
-	printf(NAME ": ns8250_set_props: baud rate %d, parity 0x%x, word "
-	    "length %d, stop bits %d\n", baud_rate, parity, word_length,
+	ddf_msg(LVL_DEBUG, "ns8250_set_props: baud rate %d, parity 0x%x, word "
+	    "length %d, stop bits %d", baud_rate, parity, word_length,
 	    stop_bits);
 	
@@ -940,4 +943,6 @@
 static void ns8250_init(void)
 {
+	ddf_log_init(NAME, LVL_ERROR);
+	
 	ns8250_dev_ops.open = &ns8250_open;
 	ns8250_dev_ops.close = &ns8250_close;
Index: uspace/drv/ohci/batch.c
===================================================================
--- uspace/drv/ohci/batch.c	(revision 61257f414d6dfc36c096abb542ed95e187bfb391)
+++ uspace/drv/ohci/batch.c	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -73,7 +73,7 @@
 	CHECK_NULL_DISPOSE_RETURN(instance,
 	    "Failed to allocate batch instance.\n");
-	usb_transfer_batch_init(instance, target, transfer_type, speed, max_packet_size,
-	    buffer, NULL, buffer_size, NULL, setup_size, func_in,
-	    func_out, arg, fun, NULL);
+	usb_transfer_batch_init(instance, target, transfer_type, speed,
+	    max_packet_size, buffer, NULL, buffer_size, NULL, setup_size,
+	    func_in, func_out, arg, fun, NULL, NULL);
 
         if (buffer_size > 0) {
Index: uspace/drv/ohci/hc.c
===================================================================
--- uspace/drv/ohci/hc.c	(revision 61257f414d6dfc36c096abb542ed95e187bfb391)
+++ uspace/drv/ohci/hc.c	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -45,4 +45,6 @@
 
 static int interrupt_emulator(hc_t *instance);
+static void hc_gain_control(hc_t *instance);
+static void hc_init_hw(hc_t *instance);
 /*----------------------------------------------------------------------------*/
 int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun)
@@ -58,5 +60,5 @@
 
 	char *match_str = NULL;
-	int ret = asprintf(&match_str, "usb&mid");
+	int ret = asprintf(&match_str, "usb&class=hub");
 	ret = (match_str == NULL) ? ret : EOK;
 	if (ret < 0) {
@@ -77,12 +79,21 @@
 	assert(instance);
 	int ret = EOK;
+#define CHECK_RET_RETURN(ret, message...) \
+if (ret != EOK) { \
+	usb_log_error(message); \
+	return ret; \
+} else (void)0
 
 	ret = pio_enable((void*)regs, reg_size, (void**)&instance->registers);
-	if (ret != EOK) {
-		usb_log_error("Failed to gain access to device registers.\n");
-		return ret;
-	}
+	CHECK_RET_RETURN(ret,
+	    "Failed(%d) to gain access to device registers: %s.\n",
+	    ret, str_error(ret));
+
 	instance->ddf_instance = fun;
 	usb_device_keeper_init(&instance->manager);
+	ret = usb_endpoint_manager_init(&instance->ep_manager,
+	    BANDWIDTH_AVAILABLE_USB11);
+	CHECK_RET_RETURN(ret, "Failed to initialize endpoint manager: %s.\n",
+	    ret, str_error(ret));
 
 	if (!interrupts) {
@@ -92,5 +103,9 @@
 	}
 
+	hc_gain_control(instance);
+
 	rh_init(&instance->rh, dev, instance->registers);
+
+	hc_init_hw(instance);
 
 	/* TODO: implement */
@@ -117,4 +132,6 @@
 		rh_interrupt(&instance->rh);
 
+	usb_log_info("OHCI interrupt: %x.\n", status);
+
 	/* TODO: Check for further interrupt causes */
 	/* TODO: implement */
@@ -126,5 +143,5 @@
 	usb_log_info("Started interrupt emulator.\n");
 	while (1) {
-		uint32_t status = instance->registers->interrupt_status;
+		const uint32_t status = instance->registers->interrupt_status;
 		instance->registers->interrupt_status = status;
 		hc_interrupt(instance, status);
@@ -133,4 +150,65 @@
 	return EOK;
 }
+/*----------------------------------------------------------------------------*/
+void hc_gain_control(hc_t *instance)
+{
+	assert(instance);
+	/* Interrupt routing enabled => smm driver is active */
+	if (instance->registers->control & C_IR) {
+		usb_log_info("Found SMM driver requesting ownership change.\n");
+		instance->registers->command_status |= CS_OCR;
+		while (instance->registers->control & C_IR) {
+			async_usleep(1000);
+		}
+		usb_log_info("Ownership taken from SMM driver.\n");
+		return;
+	}
+
+	const unsigned hc_status =
+	    (instance->registers->control >> C_HCFS_SHIFT) & C_HCFS_MASK;
+	/* Interrupt routing disabled && status != USB_RESET => BIOS active */
+	if (hc_status != C_HCFS_RESET) {
+		usb_log_info("Found BIOS driver.\n");
+		if (hc_status == C_HCFS_OPERATIONAL) {
+			usb_log_info("HC operational(BIOS).\n");
+			return;
+		}
+		/* HC is suspended assert resume for 20ms */
+		instance->registers->control &= (C_HCFS_RESUME << C_HCFS_SHIFT);
+		async_usleep(20000);
+		return;
+	}
+
+	/* HC is in reset (hw startup) => no other driver
+	 * maintain reset for at least the time specified in USB spec (50 ms)*/
+	async_usleep(50000);
+
+	/* turn off legacy emulation */
+	volatile uint32_t *ohci_emulation_reg =
+	    (uint32_t*)((char*)instance->registers + 0x100);
+	usb_log_info("OHCI legacy register status %p: %x.\n",
+		ohci_emulation_reg, *ohci_emulation_reg);
+	*ohci_emulation_reg = 0;
+
+}
+/*----------------------------------------------------------------------------*/
+void hc_init_hw(hc_t *instance)
+{
+	assert(instance);
+	const uint32_t fm_interval = instance->registers->fm_interval;
+	instance->registers->command_status = CS_HCR;
+	async_usleep(10);
+	instance->registers->fm_interval = fm_interval;
+	assert((instance->registers->command_status & CS_HCR) == 0);
+	/* hc is now in suspend state */
+	/* TODO: init HCCA block */
+	/* TODO: init queues */
+	/* TODO: enable queues */
+	/* TODO: enable interrupts */
+	/* TODO: set periodic start to 90% */
+
+	instance->registers->control &= (C_HCFS_OPERATIONAL << C_HCFS_SHIFT);
+	usb_log_info("OHCI HC up and running.\n");
+}
 /**
  * @}
Index: uspace/drv/ohci/hc.h
===================================================================
--- uspace/drv/ohci/hc.h	(revision 61257f414d6dfc36c096abb542ed95e187bfb391)
+++ uspace/drv/ohci/hc.h	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -42,4 +42,5 @@
 #include <usb/usb.h>
 #include <usb/host/device_keeper.h>
+#include <usb/host/usb_endpoint_manager.h>
 #include <usbhc_iface.h>
 
@@ -47,4 +48,5 @@
 #include "ohci_regs.h"
 #include "root_hub.h"
+#include "hw_struct/hcca.h"
 
 typedef struct hc {
@@ -54,4 +56,5 @@
 	ddf_fun_t *ddf_instance;
 	usb_device_keeper_t manager;
+	usb_endpoint_manager_t ep_manager;
 	fid_t interrupt_emulator;
 } hc_t;
Index: uspace/drv/ohci/hw_struct/completion_codes.h
===================================================================
--- uspace/drv/ohci/hw_struct/completion_codes.h	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
+++ uspace/drv/ohci/hw_struct/completion_codes.h	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2011 Jan Vesely
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/** @addtogroup drvusbohci
+ * @{
+ */
+/** @file
+ * @brief OHCI driver
+ */
+#ifndef DRV_OHCI_HW_STRUCT_COMPLETION_CODES_H
+#define DRV_OHCI_HW_STRUCT_COMPLETION_CODES_H
+
+#define CC_NOERROR (0x0)
+#define CC_CRC (0x1)
+#define CC_BITSTUFF (0x2)
+#define CC_TOGGLE (0x3)
+#define CC_STALL (0x4)
+#define CC_NORESPONSE (0x5)
+#define CC_PIDFAIL (0x6)
+#define CC_PIDUNEXPECTED (0x7)
+#define CC_DATAOVERRRUN (0x8)
+#define CC_DATAUNDERRRUN (0x9)
+#define CC_BUFFEROVERRRUN (0xc)
+#define CC_BUFFERUNDERRUN (0xd)
+#define CC_NOACCESS1 (0xe)
+#define CC_NOACCESS2 (0xf)
+
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/ohci/hw_struct/endpoint_descriptor.h
===================================================================
--- uspace/drv/ohci/hw_struct/endpoint_descriptor.h	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
+++ uspace/drv/ohci/hw_struct/endpoint_descriptor.h	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2011 Jan Vesely
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/** @addtogroup drvusbohci
+ * @{
+ */
+/** @file
+ * @brief OHCI driver
+ */
+#ifndef DRV_OHCI_HW_STRUCT_ENDPOINT_DESCRIPTOR_H
+#define DRV_OHCI_HW_STRUCT_ENDPOINT_DESCRIPTOR_H
+
+#include <stdint.h>
+
+#include "completion_codes.h"
+
+typedef struct ed {
+	volatile uint32_t status;
+#define ED_STATUS_FA_MASK (0x7f)   /* USB device address   */
+#define ED_STATUS_FA_SHIFT (0)
+#define ED_STATUS_EN_MASK (0xf)    /* USB endpoint address */
+#define ED_STATUS_EN_SHIFT (6)
+#define ED_STATUS_D_MASK (0x3)     /* direction */
+#define ED_STATUS_D_SHIFT (10)
+#define ED_STATUS_D_IN (0x1)
+#define ED_STATUS_D_OUT (0x2)
+
+#define ED_STATUS_S_FLAG (1 << 13) /* speed flag */
+#define ED_STATUS_K_FLAG (1 << 14) /* skip flag (no not execute this ED) */
+#define ED_STATUS_F_FLAG (1 << 15) /* format: 1 = isochronous*/
+#define ED_STATUS_MPS_MASK (0x3ff) /* max_packet_size*/
+#define ED_STATUS_MPS_SHIFT (16)
+
+	volatile uint32_t td_tail;
+#define ED_TDTAIL_PTR_MASK (0xfffffff0)
+#define ED_TDTAIL_PTR_SHIFT (0)
+
+	volatile uint32_t td_head;
+#define ED_TDHEAD_PTR_MASK (0xfffffff0)
+#define ED_TDHEAD_PTR_SHIFT (0)
+#define ED_TDHEAD_ZERO_MASK (0x3)
+#define ED_TDHEAD_ZERO_SHIFT (2)
+#define ED_TDHEAD_TOGGLE_CARRY (0x2)
+
+	volatile uint32_t next;
+#define ED_NEXT_PTR_MASK (0xfffffff0)
+#define ED_NEXT_PTR_SHIFT (0)
+} __attribute__((packed)) ed_t;
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/ohci/hw_struct/hcca.h
===================================================================
--- uspace/drv/ohci/hw_struct/hcca.h	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
+++ uspace/drv/ohci/hw_struct/hcca.h	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2011 Jan Vesely
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/** @addtogroup drvusbohci
+ * @{
+ */
+/** @file
+ * @brief OHCI driver
+ */
+#ifndef DRV_OHCI_HW_STRUCT_HCCA_H
+#define DRV_OHCI_HW_STRUCT_HCCA_H
+
+#include <stdint.h>
+
+typedef struct hcca {
+	uint32_t int_ep[32];
+	uint16_t frame_number;
+	uint16_t pad1;
+	uint32_t done_head;
+	uint32_t reserved[29];
+} __attribute__((packed)) hcca_t;
+
+#endif
+/**
+ * @}
+ */
+
Index: uspace/drv/ohci/hw_struct/iso_transfer_descriptor.h
===================================================================
--- uspace/drv/ohci/hw_struct/iso_transfer_descriptor.h	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
+++ uspace/drv/ohci/hw_struct/iso_transfer_descriptor.h	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2011 Jan Vesely
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/** @addtogroup drvusbohci
+ * @{
+ */
+/** @file
+ * @brief OHCI driver
+ */
+#ifndef DRV_OHCI_HW_STRUCT_ISO_TRANSFER_DESCRIPTOR_H
+#define DRV_OHCI_HW_STRUCT_ISO_TRANSFER_DESCRIPTOR_H
+
+#include <stdint.h>
+
+#include "completion_codes.h"
+
+typedef struct itd {
+	volatile uint32_t status;
+#define ITD_STATUS_SF_MASK (0xffff) /* starting frame */
+#define ITD_STATUS_SF_SHIFT (0)
+#define ITD_STATUS_DI_MASK (0x7) /* delay int, wait DI frames before int */
+#define ITD_STATUS_DI_SHIFT (21)
+#define ITD_STATUS_DI_NO_INTERRUPT (0x7)
+#define ITD_STATUS_FC_MASK (0x7) /* frame count */
+#define ITD_STATUS_FC_SHIFT (24)
+#define ITD_STATUS_CC_MASK (0xf) /* condition code */
+#define ITD_STATUS_CC_SHIFT (28)
+
+	volatile uint32_t page;   /* page number of the first byte in buffer */
+#define ITD_PAGE_BP0_MASK (0xfffff000)
+#define ITD_PAGE_BP0_SHIFT (0)
+
+	volatile uint32_t next;
+#define ITD_NEXT_PTR_MASK (0xfffffff0)
+#define ITD_NEXT_PTR_SHIFT (0)
+
+	volatile uint32_t be; /* buffer end, address of the last byte */
+
+	volatile uint16_t offset[8];
+#define ITD_OFFSET_SIZE_MASK (0x3ff)
+#define ITD_OFFSET_SIZE_SHIFT (0)
+#define ITD_OFFSET_CC_MASK (0xf)
+#define ITD_OFFSET_CC_SHIFT (12)
+
+} __attribute__((packed)) itd_t;
+#endif
+/**
+ * @}
+ */
+
+
Index: uspace/drv/ohci/hw_struct/transfer_descriptor.h
===================================================================
--- uspace/drv/ohci/hw_struct/transfer_descriptor.h	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
+++ uspace/drv/ohci/hw_struct/transfer_descriptor.h	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2011 Jan Vesely
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/** @addtogroup drvusbohci
+ * @{
+ */
+/** @file
+ * @brief OHCI driver
+ */
+#ifndef DRV_OHCI_HW_STRUCT_TRANSFER_DESCRIPTOR_H
+#define DRV_OHCI_HW_STRUCT_TRANSFER_DESCRIPTOR_H
+
+#include <stdint.h>
+
+#include "completion_codes.h"
+
+typedef struct td {
+	volatile uint32_t status;
+#define TD_STATUS_ROUND_FLAG (1 << 18)
+#define TD_STATUS_DP_MASK (0x3) /* direction/PID */
+#define TD_STATUS_DP_SHIFT (19)
+#define TD_STATUS_DP_SETUP (0x0)
+#define TD_STATUS_DP_IN (0x1)
+#define TD_STATUS_DP_OUT (0x2)
+#define TD_STATUS_DI_MASK (0x7) /* delay interrupt, wait DI frames before int */
+#define TD_STATUS_DI_SHIFT (21)
+#define TD_STATUS_DI_NO_INTERRUPT (0x7)
+#define TD_STATUS_T_MASK (0x3)  /* data toggle 1x = use ED toggle carry */
+#define TD_STATUS_T_SHIFT (24)
+#define TD_STATUS_EC_MASK (0x3) /* error count */
+#define TD_STATUS_EC_SHIFT (26)
+#define TD_STATUS_CC_MASK (0xf) /* condition code */
+#define TD_STATUS_CC_SHIFT (28)
+
+	volatile uint32_t cbp; /* current buffer ptr, data to be transfered */
+	volatile uint32_t next;
+#define TD_NEXT_PTR_MASK (0xfffffff0)
+#define TD_NEXT_PTR_SHIFT (0)
+
+	volatile uint32_t be; /* buffer end, address of the last byte */
+} __attribute__((packed)) td_t;
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/ohci/iface.c
===================================================================
--- uspace/drv/ohci/iface.c	(revision 61257f414d6dfc36c096abb542ed95e187bfb391)
+++ uspace/drv/ohci/iface.c	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -151,7 +151,17 @@
     size_t max_packet_size, unsigned int interval)
 {
-	UNSUPPORTED("register_endpoint");
-
-	return ENOTSUP;
+	assert(fun);
+	hc_t *hc = fun_to_hc(fun);
+	assert(hc);
+	if (address == hc->rh.address)
+		return EOK;
+	const usb_speed_t speed =
+		usb_device_keeper_get_speed(&hc->manager, address);
+	const size_t size = max_packet_size;
+	usb_log_debug("Register endpoint %d:%d %s %s(%d) %zu(%zu) %u.\n",
+	    address, endpoint, usb_str_transfer_type(transfer_type),
+	    usb_str_speed(speed), direction, size, max_packet_size, interval);
+	// TODO use real endpoint here!
+	return usb_endpoint_manager_register_ep(&hc->ep_manager,NULL, 0);
 }
 /*----------------------------------------------------------------------------*/
@@ -168,7 +178,11 @@
     usb_endpoint_t endpoint, usb_direction_t direction)
 {
-	UNSUPPORTED("unregister_endpoint");
-
-	return ENOTSUP;
+	assert(fun);
+	hc_t *hc = fun_to_hc(fun);
+	assert(hc);
+	usb_log_debug("Unregister endpoint %d:%d %d.\n",
+	    address, endpoint, direction);
+	return usb_endpoint_manager_unregister_ep(&hc->ep_manager, address,
+	    endpoint, direction);
 }
 /*----------------------------------------------------------------------------*/
Index: uspace/drv/ohci/ohci.c
===================================================================
--- uspace/drv/ohci/ohci.c	(revision 61257f414d6dfc36c096abb542ed95e187bfb391)
+++ uspace/drv/ohci/ohci.c	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -31,5 +31,5 @@
  */
 /** @file
- * @brief UHCI driver
+ * @brief OHCI driver
  */
 #include <errno.h>
@@ -117,10 +117,10 @@
 /** Initialize hc and rh ddf structures and their respective drivers.
  *
- * @param[in] instance UHCI structure to use.
+ * @param[in] instance OHCI structure to use.
  * @param[in] device DDF instance of the device to use.
  *
  * This function does all the preparatory work for hc and rh drivers:
  *  - gets device hw resources
- *  - disables UHCI legacy support
+ *  - disables OHCI legacy support
  *  - asks for interrupt
  *  - registers interrupt handler
@@ -185,5 +185,5 @@
 	ret = ddf_fun_bind(instance->hc_fun);
 	CHECK_RET_DEST_FUN_RETURN(ret,
-	    "Failed(%d) to bind UHCI device function: %s.\n",
+	    "Failed(%d) to bind OHCI device function: %s.\n",
 	    ret, str_error(ret));
 #undef CHECK_RET_HC_RETURN
@@ -216,5 +216,5 @@
 	ret = ddf_fun_bind(instance->rh_fun);
 	CHECK_RET_FINI_RETURN(ret,
-	    "Failed(%d) to register UHCI root hub.\n", ret);
+	    "Failed(%d) to register OHCI root hub.\n", ret);
 
 	return EOK;
Index: uspace/drv/ohci/ohci_regs.h
===================================================================
--- uspace/drv/ohci/ohci_regs.h	(revision 61257f414d6dfc36c096abb542ed95e187bfb391)
+++ uspace/drv/ohci/ohci_regs.h	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -39,7 +39,32 @@
 typedef struct ohci_regs
 {
-	volatile uint32_t revision;
+	const volatile uint32_t revision;
 	volatile uint32_t control;
+#define C_CSBR_MASK (0x3)
+#define C_CSBR_SHIFT (0)
+#define C_PLE (1 << 2)
+#define C_IE (1 << 3)
+#define C_CLE (1 << 4)
+#define C_BLE (1 << 5)
+
+#define C_HCFS_MASK (0x3)
+#define C_HCFS_SHIFT (6)
+#define C_HCFS_RESET (0x0)
+#define C_HCFS_OPERATIONAL (0x1)
+#define C_HCFS_RESUME (0x2)
+#define C_HCFS_SUSPEND (0x3)
+
+#define C_IR (1 << 8)
+#define C_RWC (1 << 9)
+#define C_RWE (1 << 10)
+
 	volatile uint32_t command_status;
+#define CS_HCR (1 << 0)
+#define CS_CLF (1 << 1)
+#define CS_BLF (1 << 2)
+#define CS_OCR (1 << 3)
+#define CS_SOC_MASK (0x3)
+#define CS_SOC_SHIFT (16)
+
 	volatile uint32_t interrupt_status;
 #define IS_SO (1 << 0)
@@ -51,4 +76,5 @@
 #define IS_RHSC (1 << 6)
 #define IS_OC (1 << 30)
+
 	volatile uint32_t interupt_enable;
 #define IE_SO   (1 << 0)
Index: uspace/drv/ohci/root_hub.c
===================================================================
--- uspace/drv/ohci/root_hub.c	(revision 61257f414d6dfc36c096abb542ed95e187bfb391)
+++ uspace/drv/ohci/root_hub.c	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -40,4 +40,5 @@
 #include "root_hub.h"
 #include "usb/classes/classes.h"
+#include "usb/devdrv.h"
 #include <usb/request.h>
 #include <usb/classes/hub.h>
@@ -61,5 +62,5 @@
 		/// \TODO these values migt be different
 		.str_serial_number = 0,
-		.usb_spec_version = 0,
+		.usb_spec_version = 0x110,
 };
 
@@ -110,67 +111,42 @@
 };
 
-/** Root hub initialization
- * @return Error code.
- */
-int rh_init(rh_t *instance, ddf_dev_t *dev, ohci_regs_t *regs)
-{
-	assert(instance);
-	instance->address = -1;
-	instance->registers = regs;
-	instance->device = dev;
-
-
-	usb_log_info("OHCI root hub with %d ports.\n", regs->rh_desc_a & 0xff);
-
-	//start generic usb hub driver
+static const uint32_t hub_clear_feature_valid_mask =
+	(1 << USB_HUB_FEATURE_C_HUB_LOCAL_POWER) +
+	(1 << USB_HUB_FEATURE_C_HUB_OVER_CURRENT);
+
+static const uint32_t hub_clear_feature_by_writing_one_mask =
+	1 << USB_HUB_FEATURE_C_HUB_LOCAL_POWER;
+
+static const uint32_t hub_set_feature_valid_mask =
+	(1 << USB_HUB_FEATURE_C_HUB_OVER_CURRENT);
+
 	
-	/* TODO: implement */
-	return EOK;
-}
-/*----------------------------------------------------------------------------*/
-
-/**
- * create answer to port status_request
- *
- * Copy content of corresponding port status register to answer buffer.
- *
- * @param instance root hub instance
- * @param port port number, counted from 1
- * @param request structure containing both request and response information
- * @return error code
- */
-static int process_get_port_status_request(rh_t *instance, uint16_t port,
-		usb_transfer_batch_t * request){
-	if(port<1 || port>instance->port_count)
-		return EINVAL;
-	uint32_t * uint32_buffer = (uint32_t*)request->buffer;
-	request->transfered_size = 4;
-	uint32_buffer[0] = instance->registers->rh_port_status[port -1];
-	return EOK;
-}
-
-/**
- * create answer to port status_request
- *
- * Copy content of hub status register to answer buffer.
- *
- * @param instance root hub instance
- * @param request structure containing both request and response information
- * @return error code
- */
-static int process_get_hub_status_request(rh_t *instance,
-		usb_transfer_batch_t * request){
-	uint32_t * uint32_buffer = (uint32_t*)request->buffer;
-	//bits, 0,1,16,17
-	request->transfered_size = 4;
-	uint32_t mask = 1 & (1<<1) & (1<<16) & (1<<17);
-	uint32_buffer[0] = mask & instance->registers->rh_status;
-	return EOK;
-
-}
+static const uint32_t hub_set_feature_direct_mask =
+	(1 << USB_HUB_FEATURE_C_HUB_OVER_CURRENT);
+
+static const uint32_t port_set_feature_valid_mask =
+	(1 << USB_HUB_FEATURE_PORT_ENABLE) +
+	(1 << USB_HUB_FEATURE_PORT_SUSPEND) +
+	(1 << USB_HUB_FEATURE_PORT_RESET) +
+	(1 << USB_HUB_FEATURE_PORT_POWER);
+
+static const uint32_t port_clear_feature_valid_mask =
+	(1 << USB_HUB_FEATURE_PORT_CONNECTION) +
+	(1 << USB_HUB_FEATURE_PORT_SUSPEND) +
+	(1 << USB_HUB_FEATURE_PORT_OVER_CURRENT) +
+	(1 << USB_HUB_FEATURE_PORT_POWER) +
+	(1 << USB_HUB_FEATURE_C_PORT_CONNECTION) +
+	(1 << USB_HUB_FEATURE_C_PORT_ENABLE) +
+	(1 << USB_HUB_FEATURE_C_PORT_SUSPEND) +
+	(1 << USB_HUB_FEATURE_C_PORT_OVER_CURRENT) +
+	(1 << USB_HUB_FEATURE_C_PORT_RESET);
+//note that USB_HUB_FEATURE_PORT_POWER bit is translated into USB_HUB_FEATURE_PORT_LOW_SPEED
+
+
+
 
 /**
  * Create hub descriptor used in hub-driver <-> hub communication
- * 
+ *
  * This means creating byt array from data in root hub registers. For more
  * info see usb hub specification.
@@ -197,5 +173,5 @@
 	result[2] = instance->port_count;
 	uint32_t hub_desc_reg = instance->registers->rh_desc_a;
-	result[3] = 
+	result[3] =
 			((hub_desc_reg >> 8) %2) +
 			(((hub_desc_reg >> 9) %2) << 1) +
@@ -219,4 +195,110 @@
 	(*out_size) = size;
 }
+
+
+/** initialize hub descriptors
+ *
+ * Initialized are device and full configuration descriptor. These need to
+ * be initialized only once per hub.
+ * @instance root hub instance
+ */
+static void rh_init_descriptors(rh_t *instance){
+	memcpy(&instance->descriptors.device, &ohci_rh_device_descriptor,
+		sizeof(ohci_rh_device_descriptor)
+	);
+	usb_standard_configuration_descriptor_t descriptor;
+	memcpy(&descriptor,&ohci_rh_conf_descriptor,
+			sizeof(ohci_rh_conf_descriptor));
+	uint8_t * hub_descriptor;
+	size_t hub_desc_size;
+	usb_create_serialized_hub_descriptor(instance, &hub_descriptor,
+			&hub_desc_size);
+
+	descriptor.total_length =
+			sizeof(usb_standard_configuration_descriptor_t)+
+			sizeof(usb_standard_endpoint_descriptor_t)+
+			sizeof(usb_standard_interface_descriptor_t)+
+			hub_desc_size;
+	
+	uint8_t * full_config_descriptor =
+			(uint8_t*) malloc(descriptor.total_length);
+	memcpy(full_config_descriptor, &descriptor, sizeof(descriptor));
+	memcpy(full_config_descriptor + sizeof(descriptor),
+			&ohci_rh_iface_descriptor, sizeof(ohci_rh_iface_descriptor));
+	memcpy(full_config_descriptor + sizeof(descriptor) +
+				sizeof(ohci_rh_iface_descriptor),
+			&ohci_rh_ep_descriptor, sizeof(ohci_rh_ep_descriptor));
+	memcpy(full_config_descriptor + sizeof(descriptor) +
+				sizeof(ohci_rh_iface_descriptor) +
+				sizeof(ohci_rh_ep_descriptor),
+			hub_descriptor, hub_desc_size);
+	
+	instance->descriptors.configuration = full_config_descriptor;
+	instance->descriptors.configuration_size = descriptor.total_length;
+}
+
+/** Root hub initialization
+ * @return Error code.
+ */
+int rh_init(rh_t *instance, ddf_dev_t *dev, ohci_regs_t *regs)
+{
+	assert(instance);
+	instance->address = -1;
+	instance->registers = regs;
+	instance->device = dev;
+	instance->port_count = instance->registers->rh_desc_a & 0xff;
+	rh_init_descriptors(instance);
+	/// \TODO set port power mode
+
+
+	usb_log_info("OHCI root hub with %d ports.\n", instance->port_count);
+
+	//start generic usb hub driver
+	
+	/* TODO: implement */
+	return EOK;
+}
+/*----------------------------------------------------------------------------*/
+
+/**
+ * create answer to port status_request
+ *
+ * Copy content of corresponding port status register to answer buffer.
+ *
+ * @param instance root hub instance
+ * @param port port number, counted from 1
+ * @param request structure containing both request and response information
+ * @return error code
+ */
+static int process_get_port_status_request(rh_t *instance, uint16_t port,
+		usb_transfer_batch_t * request){
+	if(port<1 || port>instance->port_count)
+		return EINVAL;
+	uint32_t * uint32_buffer = (uint32_t*)request->transport_buffer;
+	request->transfered_size = 4;
+	uint32_buffer[0] = instance->registers->rh_port_status[port -1];
+	return EOK;
+}
+
+/**
+ * create answer to port status_request
+ *
+ * Copy content of hub status register to answer buffer.
+ *
+ * @param instance root hub instance
+ * @param request structure containing both request and response information
+ * @return error code
+ */
+static int process_get_hub_status_request(rh_t *instance,
+		usb_transfer_batch_t * request){
+	uint32_t * uint32_buffer = (uint32_t*)request->transport_buffer;
+	//bits, 0,1,16,17
+	request->transfered_size = 4;
+	uint32_t mask = 1 & (1<<1) & (1<<16) & (1<<17);
+	uint32_buffer[0] = mask & instance->registers->rh_status;
+	return EOK;
+
+}
+
 
 
@@ -284,28 +366,5 @@
 	}
 }
-
-/**
- * create standart configuration descriptor for the root hub instance
- * @param instance root hub instance
- * @return newly allocated descriptor
- */
-static usb_standard_configuration_descriptor_t *
-usb_ohci_rh_create_standart_configuration_descriptor(rh_t *instance){
-	usb_standard_configuration_descriptor_t * descriptor =
-			malloc(sizeof(usb_standard_configuration_descriptor_t));
-	memcpy(descriptor, &ohci_rh_conf_descriptor,
-		sizeof(usb_standard_configuration_descriptor_t));
-	/// \TODO should this include device descriptor?
-	const size_t hub_descriptor_size = 7 +
-			2* (instance->port_count / 8 +
-			((instance->port_count % 8 > 0) ? 1 : 0));
-	descriptor->total_length =
-			sizeof(usb_standard_configuration_descriptor_t)+
-			sizeof(usb_standard_endpoint_descriptor_t)+
-			sizeof(usb_standard_interface_descriptor_t)+
-			hub_descriptor_size;
-	return descriptor;
-}
-
+ 
 /**
  * create answer to a descriptor request
@@ -344,10 +403,6 @@
 		case USB_DESCTYPE_CONFIGURATION: {
 			usb_log_debug("USB_DESCTYPE_CONFIGURATION\n");
-			usb_standard_configuration_descriptor_t * descriptor =
-					usb_ohci_rh_create_standart_configuration_descriptor(
-						instance);
-			result_descriptor = descriptor;
-			size = sizeof(usb_standard_configuration_descriptor_t);
-			del = true;
+			result_descriptor = instance->descriptors.configuration;
+			size = instance->descriptors.configuration_size;
 			break;
 		}
@@ -380,5 +435,7 @@
 	}
 	request->transfered_size = size;
-	memcpy(request->buffer,result_descriptor,size);
+	memcpy(request->transport_buffer,result_descriptor,size);
+	usb_log_debug("sent desctiptor: %s\n",
+			usb_debug_str_buffer((uint8_t*)request->transport_buffer,size,size));
 	if (del)
 		free(result_descriptor);
@@ -400,5 +457,5 @@
 	if(request->buffer_size != 1)
 		return EINVAL;
-	request->buffer[0] = 1;
+	request->transport_buffer[0] = 1;
 	request->transfered_size = 1;
 	return EOK;
@@ -406,26 +463,49 @@
 
 /**
- * process feature-enabling/disabling request on hub
+ * process feature-enabling request on hub
  * 
  * @param instance root hub instance
  * @param feature feature selector
- * @param enable enable or disable specified feature
  * @return error code
  */
 static int process_hub_feature_set_request(rh_t *instance,
-		uint16_t feature, bool enable){
-	if(feature > USB_HUB_FEATURE_C_HUB_OVER_CURRENT)
+		uint16_t feature){
+	if(! ((1<<feature) & hub_set_feature_valid_mask))
 		return EINVAL;
 	instance->registers->rh_status =
-			enable ?
 			(instance->registers->rh_status | (1<<feature))
-			:
-			(instance->registers->rh_status & (~(1<<feature)));
-	/// \TODO any error?
-	return EOK;
-}
-
-/**
- * process feature-enabling/disabling request on hub
+			& (~ hub_clear_feature_by_writing_one_mask);
+	return EOK;
+}
+
+/**
+ * process feature-disabling request on hub
+ *
+ * @param instance root hub instance
+ * @param feature feature selector
+ * @return error code
+ */
+static int process_hub_feature_clear_request(rh_t *instance,
+		uint16_t feature){
+	if(! ((1<<feature) & hub_clear_feature_valid_mask))
+		return EINVAL;
+	//is the feature cleared directly?
+	if ((1<<feature) & hub_set_feature_direct_mask){
+		instance->registers->rh_status =
+			(instance->registers->rh_status & (~(1<<feature)))
+			& (~ hub_clear_feature_by_writing_one_mask);
+	}else{//the feature is cleared by writing '1'
+		instance->registers->rh_status =
+				(instance->registers->rh_status
+				& (~ hub_clear_feature_by_writing_one_mask))
+				| (1<<feature);
+	}
+	return EOK;
+}
+
+
+
+/**
+ * process feature-enabling request on hub
  * 
  * @param instance root hub instance
@@ -436,17 +516,43 @@
  */
 static int process_port_feature_set_request(rh_t *instance,
-		uint16_t feature, uint16_t port, bool enable){
-	if(feature > USB_HUB_FEATURE_C_PORT_RESET)
+		uint16_t feature, uint16_t port){
+	if(!((1<<feature) & port_set_feature_valid_mask))
 		return EINVAL;
 	if(port<1 || port>instance->port_count)
 		return EINVAL;
 	instance->registers->rh_port_status[port - 1] =
-			enable ?
 			(instance->registers->rh_port_status[port - 1] | (1<<feature))
-			:
-			(instance->registers->rh_port_status[port - 1] & (~(1<<feature)));
+			& (~port_clear_feature_valid_mask);
 	/// \TODO any error?
 	return EOK;
 }
+
+/**
+ * process feature-disabling request on hub
+ *
+ * @param instance root hub instance
+ * @param feature feature selector
+ * @param port port number, counted from 1
+ * @param enable enable or disable the specified feature
+ * @return error code
+ */
+static int process_port_feature_clear_request(rh_t *instance,
+		uint16_t feature, uint16_t port){
+	if(!((1<<feature) & port_clear_feature_valid_mask))
+		return EINVAL;
+	if(port<1 || port>instance->port_count)
+		return EINVAL;
+	if(feature == USB_HUB_FEATURE_PORT_POWER)
+		feature = USB_HUB_FEATURE_PORT_LOW_SPEED;
+	if(feature == USB_HUB_FEATURE_PORT_SUSPEND)
+		feature = USB_HUB_FEATURE_PORT_OVER_CURRENT;
+	instance->registers->rh_port_status[port - 1] =
+			(instance->registers->rh_port_status[port - 1] 
+			& (~port_clear_feature_valid_mask))
+			| (1<<feature);
+	/// \TODO any error?
+	return EOK;
+}
+
 
 /**
@@ -530,16 +636,31 @@
 			(usb_device_request_setup_packet_t*)request->setup_buffer;
 	request->transfered_size = 0;
-	if(setup_request->request == USB_DEVREQ_CLEAR_FEATURE
-				|| setup_request->request == USB_DEVREQ_SET_FEATURE){
+	if(setup_request->request == USB_DEVREQ_CLEAR_FEATURE){
 		if(setup_request->request_type == USB_HUB_REQ_TYPE_SET_HUB_FEATURE){
 			usb_log_debug("USB_HUB_REQ_TYPE_SET_HUB_FEATURE\n");
-			return process_hub_feature_set_request(instance, setup_request->value,
-					setup_request->request == USB_DEVREQ_SET_FEATURE);
+			return process_hub_feature_clear_request(instance,
+					setup_request->value);
 		}
 		if(setup_request->request_type == USB_HUB_REQ_TYPE_SET_PORT_FEATURE){
 			usb_log_debug("USB_HUB_REQ_TYPE_SET_PORT_FEATURE\n");
-			return process_port_feature_set_request(instance, setup_request->value,
-					setup_request->index,
-					setup_request->request == USB_DEVREQ_SET_FEATURE);
+			return process_port_feature_clear_request(instance,
+					setup_request->value,
+					setup_request->index);
+		}
+		usb_log_debug("USB_HUB_REQ_TYPE_INVALID %d\n",
+				setup_request->request_type);
+		return EINVAL;
+	}
+	if(setup_request->request == USB_DEVREQ_SET_FEATURE){
+		if(setup_request->request_type == USB_HUB_REQ_TYPE_SET_HUB_FEATURE){
+			usb_log_debug("USB_HUB_REQ_TYPE_SET_HUB_FEATURE\n");
+			return process_hub_feature_set_request(instance,
+					setup_request->value);
+		}
+		if(setup_request->request_type == USB_HUB_REQ_TYPE_SET_PORT_FEATURE){
+			usb_log_debug("USB_HUB_REQ_TYPE_SET_PORT_FEATURE\n");
+			return process_port_feature_set_request(instance,
+					setup_request->value,
+					setup_request->index);
 		}
 		usb_log_debug("USB_HUB_REQ_TYPE_INVALID %d\n",setup_request->request_type);
Index: uspace/drv/ohci/root_hub.h
===================================================================
--- uspace/drv/ohci/root_hub.h	(revision 61257f414d6dfc36c096abb542ed95e187bfb391)
+++ uspace/drv/ohci/root_hub.h	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -37,4 +37,5 @@
 
 #include <usb/usb.h>
+#include <usb/devdrv.h>
 
 #include "ohci_regs.h"
@@ -53,4 +54,6 @@
 	/** hub port count */
 	int port_count;
+	/** hubs descriptors */
+	usb_device_descriptors_t descriptors;
 } rh_t;
 
Index: uspace/drv/pciintel/pci.c
===================================================================
--- uspace/drv/pciintel/pci.c	(revision 61257f414d6dfc36c096abb542ed95e187bfb391)
+++ uspace/drv/pciintel/pci.c	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -48,4 +48,5 @@
 
 #include <ddf/driver.h>
+#include <ddf/log.h>
 #include <devman.h>
 #include <ipc/devman.h>
@@ -106,9 +107,11 @@
 	}
 
-	size_t i;
-	for (i = 0; i < dev_data->hw_resources.count; i++) {
-		if (dev_data->hw_resources.resources[i].type == INTERRUPT) {
-			int irq = dev_data->hw_resources.resources[i].res.interrupt.irq;
-			int rc = async_req_1_0(irc_phone, IRC_ENABLE_INTERRUPT, irq);
+	size_t i = 0;
+	hw_resource_list_t *res = &dev_data->hw_resources;
+	for (; i < res->count; i++) {
+		if (res->resources[i].type == INTERRUPT) {
+			const int irq = res->resources[i].res.interrupt.irq;
+			const int rc =
+			    async_req_1_0(irc_phone, IRC_ENABLE_INTERRUPT, irq);
 			if (rc != EOK) {
 				async_hangup(irc_phone);
@@ -325,5 +328,5 @@
 
 	if (match_id_str == NULL) {
-		printf(NAME ": out of memory creating match ID.\n");
+		ddf_msg(LVL_ERROR, "Out of memory creating match ID.");
 		return;
 	}
@@ -331,5 +334,5 @@
 	rc = ddf_fun_add_match_id(fun->fnode, match_id_str, 90);
 	if (rc != EOK) {
-		printf(NAME ": error adding match ID: %s\n",
+		ddf_msg(LVL_ERROR, "Failed adding match ID: %s",
 		    str_error(rc));
 	}
@@ -428,7 +431,7 @@
 	
 	if (range_addr != 0) {
-		printf(NAME ": function %s : ", fun->fnode->name);
-		printf("address = %" PRIx64, range_addr);
-		printf(", size = %x\n", (unsigned int) range_size);
+		ddf_msg(LVL_DEBUG, "Function %s : address = %" PRIx64
+		    ", size = %x", fun->fnode->name, range_addr,
+		    (unsigned int) range_size);
 	}
 	
@@ -455,5 +458,5 @@
 	hw_res_list->count++;
 	
-	printf(NAME ": function %s uses irq %x.\n", fun->fnode->name, irq);
+	ddf_msg(LVL_NOTE, "Function %s uses irq %x.", fun->fnode->name, irq);
 }
 
@@ -511,5 +514,5 @@
 			char *fun_name = pci_fun_create_name(fun);
 			if (fun_name == NULL) {
-				printf(NAME ": out of memory.\n");
+				ddf_msg(LVL_ERROR, "Out of memory.");
 				return;
 			}
@@ -517,5 +520,5 @@
 			fnode = ddf_fun_create(bus->dnode, fun_inner, fun_name);
 			if (fnode == NULL) {
-				printf(NAME ": error creating function.\n");
+				ddf_msg(LVL_ERROR, "Failed creating function.");
 				return;
 			}
@@ -531,5 +534,5 @@
 			fnode->driver_data = fun;
 			
-			printf(NAME ": adding new function %s.\n",
+			ddf_msg(LVL_DEBUG, "Adding new function %s.",
 			    fnode->name);
 			
@@ -548,6 +551,7 @@
 				child_bus = pci_conf_read_8(fun,
 				    PCI_BRIDGE_SEC_BUS_NUM);
-				printf(NAME ": device is pci-to-pci bridge, "
-				    "secondary bus number = %d.\n", bus_num);
+				ddf_msg(LVL_DEBUG, "Device is pci-to-pci "
+				    "bridge, secondary bus number = %d.",
+				    bus_num);
 				if (child_bus > bus_num)
 					pci_bus_scan(bus, child_bus);
@@ -571,10 +575,10 @@
 	int rc;
 	
-	printf(NAME ": pci_add_device\n");
+	ddf_msg(LVL_DEBUG, "pci_add_device");
 	dnode->parent_phone = -1;
 	
 	bus = pci_bus_new();
 	if (bus == NULL) {
-		printf(NAME ": pci_add_device allocation failed.\n");
+		ddf_msg(LVL_ERROR, "pci_add_device allocation failed.");
 		rc = ENOMEM;
 		goto fail;
@@ -586,6 +590,6 @@
 	    IPC_FLAG_BLOCKING);
 	if (dnode->parent_phone < 0) {
-		printf(NAME ": pci_add_device failed to connect to the "
-		    "parent's driver.\n");
+		ddf_msg(LVL_ERROR, "pci_add_device failed to connect to the "
+		    "parent's driver.");
 		rc = dnode->parent_phone;
 		goto fail;
@@ -596,11 +600,11 @@
 	rc = hw_res_get_resource_list(dnode->parent_phone, &hw_resources);
 	if (rc != EOK) {
-		printf(NAME ": pci_add_device failed to get hw resources for "
-		    "the device.\n");
+		ddf_msg(LVL_ERROR, "pci_add_device failed to get hw resources "
+		    "for the device.");
 		goto fail;
 	}
 	got_res = true;
 	
-	printf(NAME ": conf_addr = %" PRIx64 ".\n",
+	ddf_msg(LVL_DEBUG, "conf_addr = %" PRIx64 ".",
 	    hw_resources.resources[0].res.io_range.address);
 	
@@ -614,5 +618,5 @@
 	if (pio_enable((void *)(uintptr_t)bus->conf_io_addr, 8,
 	    &bus->conf_addr_port)) {
-		printf(NAME ": failed to enable configuration ports.\n");
+		ddf_msg(LVL_ERROR, "Failed to enable configuration ports.");
 		rc = EADDRNOTAVAIL;
 		goto fail;
@@ -621,9 +625,9 @@
 	
 	/* Make the bus device more visible. It has no use yet. */
-	printf(NAME ": adding a 'ctl' function\n");
+	ddf_msg(LVL_DEBUG, "Adding a 'ctl' function");
 	
 	ctl = ddf_fun_create(bus->dnode, fun_exposed, "ctl");
 	if (ctl == NULL) {
-		printf(NAME ": error creating control function.\n");
+		ddf_msg(LVL_ERROR, "Failed creating control function.");
 		rc = ENOMEM;
 		goto fail;
@@ -632,10 +636,10 @@
 	rc = ddf_fun_bind(ctl);
 	if (rc != EOK) {
-		printf(NAME ": error binding control function.\n");
+		ddf_msg(LVL_ERROR, "Failed binding control function.");
 		goto fail;
 	}
 	
 	/* Enumerate functions. */
-	printf(NAME ": scanning the bus\n");
+	ddf_msg(LVL_DEBUG, "Scanning the bus");
 	pci_bus_scan(bus, 0);
 	
@@ -659,4 +663,5 @@
 static void pciintel_init(void)
 {
+	ddf_log_init(NAME, LVL_ERROR);
 	pci_fun_ops.interfaces[HW_RES_DEV_IFACE] = &pciintel_hw_res_ops;
 	pci_fun_ops.interfaces[PCI_DEV_IFACE] = &pci_dev_ops;
@@ -738,5 +743,5 @@
 int main(int argc, char *argv[])
 {
-	printf(NAME ": HelenOS pci bus driver (intel method 1).\n");
+	printf(NAME ": HelenOS PCI bus driver (Intel method 1).\n");
 	pciintel_init();
 	return ddf_driver_main(&pci_driver);
Index: uspace/drv/root/root.c
===================================================================
--- uspace/drv/root/root.c	(revision 61257f414d6dfc36c096abb542ed95e187bfb391)
+++ uspace/drv/root/root.c	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -52,4 +52,5 @@
 
 #include <ddf/driver.h>
+#include <ddf/log.h>
 #include <devman.h>
 #include <ipc/devman.h>
@@ -89,11 +90,11 @@
 	int rc;
 
-	printf(NAME ": adding new function for virtual devices.\n");
-	printf(NAME ":   function node is `%s' (%d %s)\n", name,
+	ddf_msg(LVL_DEBUG, "Adding new function for virtual devices. "
+	    "Function node is `%s' (%d %s)", name,
 	    VIRTUAL_FUN_MATCH_SCORE, VIRTUAL_FUN_MATCH_ID);
 
 	fun = ddf_fun_create(dev, fun_inner, name);
 	if (fun == NULL) {
-		printf(NAME ": error creating function %s\n", name);
+		ddf_msg(LVL_ERROR, "Failed creating function %s", name);
 		return ENOMEM;
 	}
@@ -102,5 +103,6 @@
 	    VIRTUAL_FUN_MATCH_SCORE);
 	if (rc != EOK) {
-		printf(NAME ": error adding match IDs to function %s\n", name);
+		ddf_msg(LVL_ERROR, "Failed adding match IDs to function %s",
+		    name);
 		ddf_fun_destroy(fun);
 		return rc;
@@ -109,5 +111,5 @@
 	rc = ddf_fun_bind(fun);
 	if (rc != EOK) {
-		printf(NAME ": error binding function %s: %s\n", name,
+		ddf_msg(LVL_ERROR, "Failed binding function %s: %s", name,
 		    str_error(rc));
 		ddf_fun_destroy(fun);
@@ -136,5 +138,5 @@
 	platform = sysinfo_get_data("platform", &platform_size);
 	if (platform == NULL) {
-		printf(NAME ": Failed to obtain platform name.\n");
+		ddf_msg(LVL_ERROR, "Failed to obtain platform name.");
 		return ENOENT;
 	}
@@ -143,5 +145,5 @@
 	platform = realloc(platform, platform_size + 1);
 	if (platform == NULL) {
-		printf(NAME ": Memory allocation failed.\n");
+		ddf_msg(LVL_ERROR, "Memory allocation failed.");
 		return ENOMEM;
 	}
@@ -151,16 +153,16 @@
 	/* Construct match ID. */
 	if (asprintf(&match_id, PLATFORM_FUN_MATCH_ID_FMT, platform) == -1) {
-		printf(NAME ": Memory allocation failed.\n");
+		ddf_msg(LVL_ERROR, "Memory allocation failed.");
 		return ENOMEM;
 	}
 
 	/* Add function. */
-	printf(NAME ": adding platform function\n");
-	printf(NAME ":   function node is `%s' (%d %s)\n", PLATFORM_FUN_NAME,
-	    PLATFORM_FUN_MATCH_SCORE, match_id);
+	ddf_msg(LVL_DEBUG, "Adding platform function. Function node is `%s' "
+	    " (%d %s)", PLATFORM_FUN_NAME, PLATFORM_FUN_MATCH_SCORE,
+	    match_id);
 
 	fun = ddf_fun_create(dev, fun_inner, name);
 	if (fun == NULL) {
-		printf(NAME ": error creating function %s\n", name);
+		ddf_msg(LVL_ERROR, "Error creating function %s", name);
 		return ENOMEM;
 	}
@@ -168,5 +170,6 @@
 	rc = ddf_fun_add_match_id(fun, match_id, PLATFORM_FUN_MATCH_SCORE);
 	if (rc != EOK) {
-		printf(NAME ": error adding match IDs to function %s\n", name);
+		ddf_msg(LVL_ERROR, "Failed adding match IDs to function %s",
+		    name);
 		ddf_fun_destroy(fun);
 		return rc;
@@ -175,5 +178,5 @@
 	rc = ddf_fun_bind(fun);
 	if (rc != EOK) {
-		printf(NAME ": error binding function %s: %s\n", name,
+		ddf_msg(LVL_ERROR, "Failed binding function %s: %s", name,
 		    str_error(rc));
 		ddf_fun_destroy(fun);
@@ -191,5 +194,5 @@
 static int root_add_device(ddf_dev_t *dev)
 {
-	printf(NAME ": root_add_device, device handle=%" PRIun "\n",
+	ddf_msg(LVL_DEBUG, "root_add_device, device handle=%" PRIun,
 	    dev->handle);
 
@@ -204,5 +207,5 @@
 	int res = add_platform_fun(dev);
 	if (EOK != res)
-		printf(NAME ": failed to add child device for platform.\n");
+		ddf_msg(LVL_ERROR, "Failed adding child device for platform.");
 
 	return res;
@@ -212,4 +215,6 @@
 {
 	printf(NAME ": HelenOS root device driver\n");
+
+	ddf_log_init(NAME, LVL_ERROR);
 	return ddf_driver_main(&root_driver);
 }
Index: uspace/drv/rootpc/rootpc.c
===================================================================
--- uspace/drv/rootpc/rootpc.c	(revision 61257f414d6dfc36c096abb542ed95e187bfb391)
+++ uspace/drv/rootpc/rootpc.c	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -47,4 +47,5 @@
 
 #include <ddf/driver.h>
+#include <ddf/log.h>
 #include <devman.h>
 #include <ipc/devman.h>
@@ -119,5 +120,5 @@
     rootpc_fun_t *fun)
 {
-	printf(NAME ": adding new function '%s'.\n", name);
+	ddf_msg(LVL_DEBUG, "Adding new function '%s'.", name);
 	
 	ddf_fun_t *fnode = NULL;
@@ -145,5 +146,5 @@
 	/* Register function. */
 	if (ddf_fun_bind(fnode) != EOK) {
-		printf(NAME ": error binding function %s.\n", name);
+		ddf_msg(LVL_ERROR, "Failed binding function %s.", name);
 		goto failure;
 	}
@@ -158,5 +159,5 @@
 		ddf_fun_destroy(fnode);
 	
-	printf(NAME ": failed to add function '%s'.\n", name);
+	ddf_msg(LVL_ERROR, "Failed adding function '%s'.", name);
 	
 	return false;
@@ -176,10 +177,10 @@
 static int rootpc_add_device(ddf_dev_t *dev)
 {
-	printf(NAME ": rootpc_add_device, device handle = %d\n",
+	ddf_msg(LVL_DEBUG, "rootpc_add_device, device handle = %d",
 	    (int)dev->handle);
 	
 	/* Register functions. */
 	if (!rootpc_add_functions(dev)) {
-		printf(NAME ": failed to add functions for PC platform.\n");
+		ddf_msg(LVL_ERROR, "Failed to add functions for PC platform.");
 	}
 	
@@ -189,4 +190,5 @@
 static void root_pc_init(void)
 {
+	ddf_log_init(NAME, LVL_ERROR);
 	rootpc_fun_ops.interfaces[HW_RES_DEV_IFACE] = &fun_hw_res_ops;
 }
Index: uspace/drv/rootvirt/rootvirt.c
===================================================================
--- uspace/drv/rootvirt/rootvirt.c	(revision 61257f414d6dfc36c096abb542ed95e187bfb391)
+++ uspace/drv/rootvirt/rootvirt.c	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -40,4 +40,5 @@
 #include <str_error.h>
 #include <ddf/driver.h>
+#include <ddf/log.h>
 
 #define NAME "rootvirt"
@@ -83,10 +84,10 @@
 	int rc;
 
-	printf(NAME ": registering function `%s' (match \"%s\")\n",
+	ddf_msg(LVL_DEBUG, "Registering function `%s' (match \"%s\")",
 	    vfun->name, vfun->match_id);
 
 	fun = ddf_fun_create(vdev, fun_inner, vfun->name);
 	if (fun == NULL) {
-		printf(NAME ": error creating function %s\n", vfun->name);
+		ddf_msg(LVL_ERROR, "Failed creating function %s", vfun->name);
 		return ENOMEM;
 	}
@@ -94,5 +95,5 @@
 	rc = ddf_fun_add_match_id(fun, vfun->match_id, 10);
 	if (rc != EOK) {
-		printf(NAME ": error adding match IDs to function %s\n",
+		ddf_msg(LVL_ERROR, "Failed adding match IDs to function %s",
 		    vfun->name);
 		ddf_fun_destroy(fun);
@@ -102,11 +103,11 @@
 	rc = ddf_fun_bind(fun);
 	if (rc != EOK) {
-		printf(NAME ": error binding function %s: %s\n", vfun->name,
-		    str_error(rc));
+		ddf_msg(LVL_ERROR, "Failed binding function %s: %s",
+		    vfun->name, str_error(rc));
 		ddf_fun_destroy(fun);
 		return rc;
 	}
 
-	printf(NAME ": registered child device `%s'\n", vfun->name);
+	ddf_msg(LVL_NOTE, "Registered child device `%s'", vfun->name);
 	return EOK;
 }
@@ -124,5 +125,5 @@
 	}
 
-	printf(NAME ": add_device(handle=%d)\n", (int)dev->handle);
+	ddf_msg(LVL_DEBUG, "add_device(handle=%d)", (int)dev->handle);
 
 	/*
@@ -142,4 +143,6 @@
 {
 	printf(NAME ": HelenOS virtual devices root driver\n");
+
+	ddf_log_init(NAME, LVL_ERROR);
 	return ddf_driver_main(&rootvirt_driver);
 }
Index: uspace/drv/test1/test1.c
===================================================================
--- uspace/drv/test1/test1.c	(revision 61257f414d6dfc36c096abb542ed95e187bfb391)
+++ uspace/drv/test1/test1.c	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -35,4 +35,5 @@
 #include <str_error.h>
 #include <ddf/driver.h>
+#include <ddf/log.h>
 
 #include "test1.h"
@@ -58,34 +59,49 @@
  */
 static int register_fun_verbose(ddf_dev_t *parent, const char *message,
-    const char *name, const char *match_id, int match_score)
+    const char *name, const char *match_id, int match_score,
+    int expected_rc)
 {
-	ddf_fun_t *fun;
+	ddf_fun_t *fun = NULL;
 	int rc;
 
-	printf(NAME ": registering function `%s': %s.\n", name, message);
+	ddf_msg(LVL_DEBUG, "Registering function `%s': %s.", name, message);
 
 	fun = ddf_fun_create(parent, fun_inner, name);
 	if (fun == NULL) {
-		printf(NAME ": error creating function %s\n", name);
-		return ENOMEM;
+		ddf_msg(LVL_ERROR, "Failed creating function %s", name);
+		rc = ENOMEM;
+		goto leave;
 	}
 
-	rc = ddf_fun_add_match_id(fun, match_id, match_score);
+	rc = ddf_fun_add_match_id(fun, str_dup(match_id), match_score);
 	if (rc != EOK) {
-		printf(NAME ": error adding match IDs to function %s\n", name);
-		ddf_fun_destroy(fun);
-		return rc;
+		ddf_msg(LVL_ERROR, "Failed adding match IDs to function %s",
+		    name);
+		goto leave;
 	}
 
 	rc = ddf_fun_bind(fun);
 	if (rc != EOK) {
-		printf(NAME ": error binding function %s: %s\n", name,
+		ddf_msg(LVL_ERROR, "Failed binding function %s: %s", name,
 		    str_error(rc));
-		ddf_fun_destroy(fun);
-		return rc;
+		goto leave;
 	}
 
-	printf(NAME ": registered child device `%s'\n", name);
-	return EOK;
+	ddf_msg(LVL_NOTE, "Registered child device `%s'", name);
+	rc = EOK;
+
+leave:
+	if (rc != expected_rc) {
+		fprintf(stderr,
+		    NAME ": Unexpected error registering function `%s'.\n" 
+		    NAME ":     Expected \"%s\" but got \"%s\".\n",
+		    name, str_error(expected_rc), str_error(rc));
+	}
+
+	if ((rc != EOK) && (fun != NULL)) {
+		ddf_fun_destroy(fun);
+	}
+
+	return rc;
 }
 
@@ -112,10 +128,10 @@
 	int rc;
 
-	printf(NAME ": add_device(name=\"%s\", handle=%d)\n",
+	ddf_msg(LVL_DEBUG, "add_device(name=\"%s\", handle=%d)",
 	    dev->name, (int) dev->handle);
 
 	fun_a = ddf_fun_create(dev, fun_exposed, "a");
 	if (fun_a == NULL) {
-		printf(NAME ": error creating function 'a'.\n");
+		ddf_msg(LVL_ERROR, "Failed creating function 'a'.");
 		return ENOMEM;
 	}
@@ -123,5 +139,5 @@
 	rc = ddf_fun_bind(fun_a);
 	if (rc != EOK) {
-		printf(NAME ": error binding function 'a'.\n");
+		ddf_msg(LVL_ERROR, "Failed binding function 'a'.");
 		return rc;
 	}
@@ -133,12 +149,17 @@
 		ddf_fun_add_to_class(fun_a, "virt-null");
 	} else if (str_cmp(dev->name, "test1") == 0) {
-		(void) register_fun_verbose(dev, "cloning myself ;-)", "clone",
-		    "virtual&test1", 10);
+		(void) register_fun_verbose(dev,
+		    "cloning myself ;-)", "clone",
+		    "virtual&test1", 10, EOK);
+		(void) register_fun_verbose(dev,
+		    "cloning myself twice ;-)", "clone",
+		    "virtual&test1", 10, EEXISTS);
 	} else if (str_cmp(dev->name, "clone") == 0) {
-		(void) register_fun_verbose(dev, "run by the same task", "child",
-		    "virtual&test1&child", 10);
+		(void) register_fun_verbose(dev,
+		    "run by the same task", "child",
+		    "virtual&test1&child", 10, EOK);
 	}
 
-	printf(NAME ": device `%s' accepted.\n", dev->name);
+	ddf_msg(LVL_DEBUG, "Device `%s' accepted.", dev->name);
 
 	return EOK;
@@ -148,4 +169,5 @@
 {
 	printf(NAME ": HelenOS test1 virtual device driver\n");
+	ddf_log_init(NAME, LVL_ERROR);
 	return ddf_driver_main(&test1_driver);
 }
Index: uspace/drv/test2/test2.c
===================================================================
--- uspace/drv/test2/test2.c	(revision 61257f414d6dfc36c096abb542ed95e187bfb391)
+++ uspace/drv/test2/test2.c	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -36,4 +36,5 @@
 #include <str_error.h>
 #include <ddf/driver.h>
+#include <ddf/log.h>
 
 #define NAME "test2"
@@ -64,9 +65,9 @@
 	int rc;
 
-	printf(NAME ": registering function `%s': %s.\n", name, message);
+	ddf_msg(LVL_DEBUG, "Registering function `%s': %s.", name, message);
 
 	fun = ddf_fun_create(parent, fun_inner, name);
 	if (fun == NULL) {
-		printf(NAME ": error creating function %s\n", name);
+		ddf_msg(LVL_ERROR, "Failed creating function %s", name);
 		return ENOMEM;
 	}
@@ -74,5 +75,6 @@
 	rc = ddf_fun_add_match_id(fun, match_id, match_score);
 	if (rc != EOK) {
-		printf(NAME ": error adding match IDs to function %s\n", name);
+		ddf_msg(LVL_ERROR, "Failed adding match IDs to function %s",
+		    name);
 		ddf_fun_destroy(fun);
 		return rc;
@@ -81,5 +83,5 @@
 	rc = ddf_fun_bind(fun);
 	if (rc != EOK) {
-		printf(NAME ": error binding function %s: %s\n", name,
+		ddf_msg(LVL_ERROR, "Failed binding function %s: %s", name,
 		    str_error(rc));
 		ddf_fun_destroy(fun);
@@ -87,5 +89,5 @@
 	}
 
-	printf(NAME ": registered child device `%s'\n", name);
+	ddf_msg(LVL_NOTE, "Registered child device `%s'", name);
 	return EOK;
 }
@@ -111,5 +113,5 @@
 	fun_a = ddf_fun_create(dev, fun_exposed, "a");
 	if (fun_a == NULL) {
-		printf(NAME ": error creating function 'a'.\n");
+		ddf_msg(LVL_ERROR, "Failed creating function 'a'.");
 		return ENOMEM;
 	}
@@ -117,5 +119,5 @@
 	rc = ddf_fun_bind(fun_a);
 	if (rc != EOK) {
-		printf(NAME ": error binding function 'a'.\n");
+		ddf_msg(LVL_ERROR, "Failed binding function 'a'.");
 		return rc;
 	}
@@ -128,5 +130,5 @@
 static int test2_add_device(ddf_dev_t *dev)
 {
-	printf(NAME ": test2_add_device(name=\"%s\", handle=%d)\n",
+	ddf_msg(LVL_DEBUG, "test2_add_device(name=\"%s\", handle=%d)",
 	    dev->name, (int) dev->handle);
 
@@ -134,5 +136,5 @@
 		fid_t postpone = fibril_create(postponed_birth, dev);
 		if (postpone == 0) {
-			printf(NAME ": fibril_create() error\n");
+			ddf_msg(LVL_ERROR, "fibril_create() failed.");
 			return ENOMEM;
 		}
@@ -149,4 +151,5 @@
 {
 	printf(NAME ": HelenOS test2 virtual device driver\n");
+	ddf_log_init(NAME, LVL_ERROR);
 	return ddf_driver_main(&test2_driver);
 }
Index: uspace/drv/uhci-hcd/batch.c
===================================================================
--- uspace/drv/uhci-hcd/batch.c	(revision 61257f414d6dfc36c096abb542ed95e187bfb391)
+++ uspace/drv/uhci-hcd/batch.c	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -49,5 +49,4 @@
 	td_t *tds;
 	size_t transfers;
-	usb_device_keeper_t *manager;
 } uhci_batch_t;
 
@@ -73,5 +72,5 @@
  * @param[in] func_out function to call on outbound transaction completion
  * @param[in] arg additional parameter to func_in or func_out
- * @param[in] manager Pointer to toggle management structure.
+ * @param[in] ep Pointer to endpoint toggle management structure.
  * @return Valid pointer if all substructures were successfully created,
  * NULL otherwise.
@@ -86,6 +85,5 @@
     char* setup_buffer, size_t setup_size,
     usbhc_iface_transfer_in_callback_t func_in,
-    usbhc_iface_transfer_out_callback_t func_out, void *arg,
-    usb_device_keeper_t *manager
+    usbhc_iface_transfer_out_callback_t func_out, void *arg, endpoint_t *ep
     )
 {
@@ -105,7 +103,8 @@
 	CHECK_NULL_DISPOSE_RETURN(instance,
 	    "Failed to allocate batch instance.\n");
-	usb_transfer_batch_init(instance, target, transfer_type, speed, max_packet_size,
+	usb_transfer_batch_init(instance, target,
+	    transfer_type, speed, max_packet_size,
 	    buffer, NULL, buffer_size, NULL, setup_size, func_in,
-	    func_out, arg, fun, NULL);
+	    func_out, arg, fun, ep, NULL);
 
 
@@ -114,5 +113,4 @@
 	    "Failed to allocate batch instance.\n");
 	bzero(data, sizeof(uhci_batch_t));
-	data->manager = manager;
 	instance->private_data = data;
 
@@ -180,8 +178,7 @@
 			    instance, i, data->tds[i].status);
 			td_print_status(&data->tds[i]);
-
-			usb_device_keeper_set_toggle(data->manager,
-			    instance->target, instance->direction,
-			    td_toggle(&data->tds[i]));
+			if (instance->ep != NULL)
+				endpoint_toggle_set(instance->ep,
+				    td_toggle(&data->tds[i]));
 			if (i > 0)
 				goto substract_ret;
@@ -310,6 +307,5 @@
 
 	const bool low_speed = instance->speed == USB_SPEED_LOW;
-	int toggle = usb_device_keeper_get_toggle(
-	    data->manager, instance->target, instance->direction);
+	int toggle = endpoint_toggle_get(instance->ep);
 	assert(toggle == 0 || toggle == 1);
 
@@ -342,6 +338,5 @@
 	}
 	td_set_ioc(&data->tds[transfer - 1]);
-	usb_device_keeper_set_toggle(data->manager, instance->target,
-	    instance->direction, toggle);
+	endpoint_toggle_set(instance->ep, toggle);
 }
 /*----------------------------------------------------------------------------*/
Index: uspace/drv/uhci-hcd/batch.h
===================================================================
--- uspace/drv/uhci-hcd/batch.h	(revision 61257f414d6dfc36c096abb542ed95e187bfb391)
+++ uspace/drv/uhci-hcd/batch.h	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -35,9 +35,8 @@
 #define DRV_UHCI_BATCH_H
 
-#include <adt/list.h>
-
 #include <usbhc_iface.h>
 #include <usb/usb.h>
 #include <usb/host/device_keeper.h>
+#include <usb/host/endpoint.h>
 #include <usb/host/batch.h>
 
@@ -57,5 +56,5 @@
     usbhc_iface_transfer_out_callback_t func_out,
 		void *arg,
-		usb_device_keeper_t *manager
+		endpoint_t *ep
 		);
 
Index: uspace/drv/uhci-hcd/hc.c
===================================================================
--- uspace/drv/uhci-hcd/hc.c	(revision 61257f414d6dfc36c096abb542ed95e187bfb391)
+++ uspace/drv/uhci-hcd/hc.c	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -66,7 +66,8 @@
 static int hc_interrupt_emulator(void *arg);
 static int hc_debug_checker(void *arg);
-
+#if 0
 static bool usb_is_allowed(
     bool low_speed, usb_transfer_type_t transfer, size_t size);
+#endif
 /*----------------------------------------------------------------------------*/
 /** Initialize UHCI hcd driver structure
@@ -238,4 +239,9 @@
 	usb_device_keeper_init(&instance->manager);
 	usb_log_debug("Initialized device manager.\n");
+
+	ret =
+	    usb_endpoint_manager_init(&instance->ep_manager,
+	        BANDWIDTH_AVAILABLE_USB11);
+	assert(ret == EOK);
 
 	return EOK;
@@ -322,14 +328,4 @@
 	assert(instance);
 	assert(batch);
-	const int low_speed = (batch->speed == USB_SPEED_LOW);
-	if (!usb_is_allowed(
-	    low_speed, batch->transfer_type, batch->max_packet_size)) {
-		usb_log_warning(
-		    "Invalid USB transfer specified %s SPEED %d %zu.\n",
-		    low_speed ? "LOW" : "FULL" , batch->transfer_type,
-		    batch->max_packet_size);
-		return ENOTSUP;
-	}
-	/* TODO: check available bandwidth here */
 
 	transfer_list_t *list =
@@ -338,5 +334,5 @@
 	if (batch->transfer_type == USB_TRANSFER_CONTROL) {
 		usb_device_keeper_use_control(
-		    &instance->manager, batch->target.address);
+		    &instance->manager, batch->target);
 	}
 	transfer_list_add_batch(list, batch);
@@ -358,4 +354,5 @@
 {
 	assert(instance);
+//	status |= 1; //Uncomment to work around qemu hang
 	/* TODO: Resume interrupts are not supported */
 	/* Lower 2 bits are transaction error and transaction complete */
@@ -376,7 +373,25 @@
 			usb_transfer_batch_t *batch =
 			    list_get_instance(item, usb_transfer_batch_t, link);
-			if (batch->transfer_type == USB_TRANSFER_CONTROL) {
+			switch (batch->transfer_type)
+			{
+			case USB_TRANSFER_CONTROL:
 				usb_device_keeper_release_control(
-				    &instance->manager, batch->target.address);
+				    &instance->manager, batch->target);
+				break;
+			case USB_TRANSFER_INTERRUPT:
+			case USB_TRANSFER_ISOCHRONOUS: {
+/*
+				int ret = bandwidth_free(&instance->bandwidth,
+				    batch->target.address,
+				    batch->target.endpoint,
+				    batch->direction);
+				if (ret != EOK)
+					usb_log_warning("Failed(%d) to free "
+					    "reserved bw: %s.\n", ret,
+					    str_error(ret));
+*/
+				}
+			default:
+				break;
 			}
 			batch->next_step(batch);
@@ -499,4 +514,5 @@
  * @return True if transaction is allowed by USB specs, false otherwise
  */
+#if 0
 bool usb_is_allowed(
     bool low_speed, usb_transfer_type_t transfer, size_t size)
@@ -516,4 +532,5 @@
 	return false;
 }
+#endif
 /**
  * @}
Index: uspace/drv/uhci-hcd/hc.h
===================================================================
--- uspace/drv/uhci-hcd/hc.h	(revision 61257f414d6dfc36c096abb542ed95e187bfb391)
+++ uspace/drv/uhci-hcd/hc.h	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -43,4 +43,5 @@
 #include <usbhc_iface.h>
 #include <usb/host/device_keeper.h>
+#include <usb/host/usb_endpoint_manager.h>
 
 #include "batch.h"
@@ -84,4 +85,5 @@
 typedef struct hc {
 	usb_device_keeper_t manager;
+	usb_endpoint_manager_t ep_manager;
 
 	regs_t *registers;
Index: uspace/drv/uhci-hcd/hw_struct/queue_head.h
===================================================================
--- uspace/drv/uhci-hcd/hw_struct/queue_head.h	(revision 61257f414d6dfc36c096abb542ed95e187bfb391)
+++ uspace/drv/uhci-hcd/hw_struct/queue_head.h	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -39,5 +39,4 @@
 
 #include "link_pointer.h"
-#include "utils/malloc32.h"
 
 typedef struct queue_head {
Index: uspace/drv/uhci-hcd/iface.c
===================================================================
--- uspace/drv/uhci-hcd/iface.c	(revision 61257f414d6dfc36c096abb542ed95e187bfb391)
+++ uspace/drv/uhci-hcd/iface.c	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -36,4 +36,5 @@
 
 #include <usb/debug.h>
+#include <usb/host/endpoint.h>
 
 #include "iface.h"
@@ -54,4 +55,23 @@
 	usb_device_keeper_reserve_default_address(&hc->manager, speed);
 	return EOK;
+#if 0
+	endpoint_t *ep = malloc(sizeof(endpoint_t));
+	if (ep == NULL)
+		return ENOMEM;
+	const size_t max_packet_size = speed == USB_SPEED_LOW ? 8 : 64;
+	endpoint_init(ep, USB_TRANSFER_CONTROL, speed, max_packet_size);
+	int ret;
+try_retgister:
+	ret = usb_endpoint_manager_register_ep(&hc->ep_manager,
+	    USB_ADDRESS_DEFAULT, 0, USB_DIRECTION_BOTH, ep, endpoint_destroy, 0);
+	if (ret == EEXISTS) {
+		async_usleep(1000);
+		goto try_retgister;
+	}
+	if (ret != EOK) {
+		endpoint_destroy(ep);
+	}
+	return ret;
+#endif
 }
 /*----------------------------------------------------------------------------*/
@@ -67,4 +87,6 @@
 	assert(hc);
 	usb_log_debug("Default address release.\n");
+//	return usb_endpoint_manager_unregister_ep(&hc->ep_manager,
+//	    USB_ADDRESS_DEFAULT, 0, USB_DIRECTION_BOTH);
 	usb_device_keeper_release_default_address(&hc->manager);
 	return EOK;
@@ -128,4 +150,54 @@
 }
 /*----------------------------------------------------------------------------*/
+static int register_endpoint(
+    ddf_fun_t *fun, usb_address_t address, usb_endpoint_t endpoint,
+    usb_transfer_type_t transfer_type, usb_direction_t direction,
+    size_t max_packet_size, unsigned int interval)
+{
+	hc_t *hc = fun_to_hc(fun);
+	assert(hc);
+	const usb_speed_t speed =
+	    usb_device_keeper_get_speed(&hc->manager, address);
+	const size_t size =
+	    (transfer_type == USB_TRANSFER_INTERRUPT
+	    || transfer_type == USB_TRANSFER_ISOCHRONOUS) ?
+	    max_packet_size : 0;
+	int ret;
+
+	endpoint_t *ep = malloc(sizeof(endpoint_t));
+	if (ep == NULL)
+		return ENOMEM;
+	ret = endpoint_init(ep, address, endpoint, direction,
+	    transfer_type, speed, max_packet_size);
+	if (ret != EOK) {
+		free(ep);
+		return ret;
+	}
+
+	usb_log_debug("Register endpoint %d:%d %s %s(%d) %zu(%zu) %u.\n",
+	    address, endpoint, usb_str_transfer_type(transfer_type),
+	    usb_str_speed(speed), direction, size, max_packet_size, interval);
+
+	ret = usb_endpoint_manager_register_ep(&hc->ep_manager, ep, size);
+	if (ret != EOK) {
+		endpoint_destroy(ep);
+	} else {
+		usb_device_keeper_add_ep(&hc->manager, address, ep);
+	}
+	return ret;
+}
+/*----------------------------------------------------------------------------*/
+static int unregister_endpoint(
+    ddf_fun_t *fun, usb_address_t address,
+    usb_endpoint_t endpoint, usb_direction_t direction)
+{
+	hc_t *hc = fun_to_hc(fun);
+	assert(hc);
+	usb_log_debug("Unregister endpoint %d:%d %d.\n",
+	    address, endpoint, direction);
+	return usb_endpoint_manager_unregister_ep(&hc->ep_manager, address,
+	    endpoint, direction);
+}
+/*----------------------------------------------------------------------------*/
 /** Interrupt out transaction interface function
  *
@@ -146,13 +218,33 @@
 	hc_t *hc = fun_to_hc(fun);
 	assert(hc);
-	usb_speed_t speed =
-	    usb_device_keeper_get_speed(&hc->manager, target.address);
 
 	usb_log_debug("Interrupt OUT %d:%d %zu(%zu).\n",
 	    target.address, target.endpoint, size, max_packet_size);
 
+	size_t res_bw;
+	endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager,
+	    target.address, target.endpoint, USB_DIRECTION_OUT, &res_bw);
+	if (ep == NULL) {
+		usb_log_error("Endpoint(%d:%d) not registered for INT OUT.\n",
+			target.address, target.endpoint);
+		return ENOENT;
+	}
+	const size_t bw = bandwidth_count_usb11(ep->speed, ep->transfer_type,
+	    size, ep->max_packet_size);
+	if (res_bw < bw)
+	{
+		usb_log_error("Endpoint(%d:%d) INT IN needs %zu bw "
+		    "but only %zu is reserved.\n",
+		    target.address, target.endpoint, bw, res_bw);
+		return ENOENT;
+	}
+	assert(ep->speed ==
+	    usb_device_keeper_get_speed(&hc->manager, target.address));
+	assert(ep->max_packet_size == max_packet_size);
+	assert(ep->transfer_type == USB_TRANSFER_INTERRUPT);
+
 	usb_transfer_batch_t *batch =
-	    batch_get(fun, target, USB_TRANSFER_INTERRUPT, max_packet_size,
-	        speed, data, size, NULL, 0, NULL, callback, arg, &hc->manager);
+	    batch_get(fun, target, ep->transfer_type, ep->max_packet_size,
+	        ep->speed, data, size, NULL, 0, NULL, callback, arg, ep);
 	if (!batch)
 		return ENOMEM;
@@ -183,12 +275,34 @@
 	hc_t *hc = fun_to_hc(fun);
 	assert(hc);
-	usb_speed_t speed =
-	    usb_device_keeper_get_speed(&hc->manager, target.address);
+
 	usb_log_debug("Interrupt IN %d:%d %zu(%zu).\n",
 	    target.address, target.endpoint, size, max_packet_size);
 
+	size_t res_bw;
+	endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager,
+	    target.address, target.endpoint, USB_DIRECTION_IN, &res_bw);
+	if (ep == NULL) {
+		usb_log_error("Endpoint(%d:%d) not registered for INT IN.\n",
+		    target.address, target.endpoint);
+		return ENOENT;
+	}
+	const size_t bw = bandwidth_count_usb11(ep->speed, ep->transfer_type,
+	    size, ep->max_packet_size);
+	if (res_bw < bw)
+	{
+		usb_log_error("Endpoint(%d:%d) INT IN needs %zu bw "
+		    "but only %zu bw is reserved.\n",
+		    target.address, target.endpoint, bw, res_bw);
+		return ENOENT;
+	}
+
+	assert(ep->speed ==
+	    usb_device_keeper_get_speed(&hc->manager, target.address));
+	assert(ep->max_packet_size == max_packet_size);
+	assert(ep->transfer_type == USB_TRANSFER_INTERRUPT);
+
 	usb_transfer_batch_t *batch =
-	    batch_get(fun, target, USB_TRANSFER_INTERRUPT, max_packet_size,
-	        speed, data, size, NULL, 0, callback, NULL, arg, &hc->manager);
+	    batch_get(fun, target, ep->transfer_type, ep->max_packet_size,
+	        ep->speed, data, size, NULL, 0, callback, NULL, arg, ep);
 	if (!batch)
 		return ENOMEM;
@@ -219,13 +333,23 @@
 	hc_t *hc = fun_to_hc(fun);
 	assert(hc);
-	usb_speed_t speed =
-	    usb_device_keeper_get_speed(&hc->manager, target.address);
 
 	usb_log_debug("Bulk OUT %d:%d %zu(%zu).\n",
 	    target.address, target.endpoint, size, max_packet_size);
 
+	endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager,
+	    target.address, target.endpoint, USB_DIRECTION_OUT, NULL);
+	if (ep == NULL) {
+		usb_log_error("Endpoint(%d:%d) not registered for BULK OUT.\n",
+			target.address, target.endpoint);
+		return ENOENT;
+	}
+	assert(ep->speed ==
+	    usb_device_keeper_get_speed(&hc->manager, target.address));
+	assert(ep->max_packet_size == max_packet_size);
+	assert(ep->transfer_type == USB_TRANSFER_BULK);
+
 	usb_transfer_batch_t *batch =
-	    batch_get(fun, target, USB_TRANSFER_BULK, max_packet_size, speed,
-	        data, size, NULL, 0, NULL, callback, arg, &hc->manager);
+	    batch_get(fun, target, ep->transfer_type, ep->max_packet_size,
+	        ep->speed, data, size, NULL, 0, NULL, callback, arg, ep);
 	if (!batch)
 		return ENOMEM;
@@ -256,12 +380,22 @@
 	hc_t *hc = fun_to_hc(fun);
 	assert(hc);
-	usb_speed_t speed =
-	    usb_device_keeper_get_speed(&hc->manager, target.address);
 	usb_log_debug("Bulk IN %d:%d %zu(%zu).\n",
 	    target.address, target.endpoint, size, max_packet_size);
 
+	endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager,
+	    target.address, target.endpoint, USB_DIRECTION_IN, NULL);
+	if (ep == NULL) {
+		usb_log_error("Endpoint(%d:%d) not registered for BULK IN.\n",
+			target.address, target.endpoint);
+		return ENOENT;
+	}
+	assert(ep->speed ==
+	    usb_device_keeper_get_speed(&hc->manager, target.address));
+	assert(ep->max_packet_size == max_packet_size);
+	assert(ep->transfer_type == USB_TRANSFER_BULK);
+
 	usb_transfer_batch_t *batch =
-	    batch_get(fun, target, USB_TRANSFER_BULK, max_packet_size, speed,
-	        data, size, NULL, 0, callback, NULL, arg, &hc->manager);
+	    batch_get(fun, target, ep->transfer_type, ep->max_packet_size,
+	        ep->speed, data, size, NULL, 0, callback, NULL, arg, ep);
 	if (!batch)
 		return ENOMEM;
@@ -299,4 +433,10 @@
 	usb_log_debug("Control WRITE (%d) %d:%d %zu(%zu).\n",
 	    speed, target.address, target.endpoint, size, max_packet_size);
+	endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager,
+	    target.address, target.endpoint, USB_DIRECTION_BOTH, NULL);
+	if (ep == NULL) {
+		usb_log_warning("Endpoint(%d:%d) not registered for CONTROL.\n",
+			target.address, target.endpoint);
+	}
 
 	if (setup_size != 8)
@@ -305,6 +445,5 @@
 	usb_transfer_batch_t *batch =
 	    batch_get(fun, target, USB_TRANSFER_CONTROL, max_packet_size, speed,
-	        data, size, setup_data, setup_size, NULL, callback, arg,
-	        &hc->manager);
+	        data, size, setup_data, setup_size, NULL, callback, arg, ep);
 	if (!batch)
 		return ENOMEM;
@@ -344,8 +483,13 @@
 	usb_log_debug("Control READ(%d) %d:%d %zu(%zu).\n",
 	    speed, target.address, target.endpoint, size, max_packet_size);
+	endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager,
+	    target.address, target.endpoint, USB_DIRECTION_BOTH, NULL);
+	if (ep == NULL) {
+		usb_log_warning("Endpoint(%d:%d) not registered for CONTROL.\n",
+			target.address, target.endpoint);
+	}
 	usb_transfer_batch_t *batch =
 	    batch_get(fun, target, USB_TRANSFER_CONTROL, max_packet_size, speed,
-	        data, size, setup_data, setup_size, callback, NULL, arg,
-		&hc->manager);
+	        data, size, setup_data, setup_size, callback, NULL, arg, ep);
 	if (!batch)
 		return ENOMEM;
@@ -365,4 +509,7 @@
 	.release_address = release_address,
 
+	.register_endpoint = register_endpoint,
+	.unregister_endpoint = unregister_endpoint,
+
 	.interrupt_out = interrupt_out,
 	.interrupt_in = interrupt_in,
Index: uspace/drv/uhci-hcd/transfer_list.h
===================================================================
--- uspace/drv/uhci-hcd/transfer_list.h	(revision 61257f414d6dfc36c096abb542ed95e187bfb391)
+++ uspace/drv/uhci-hcd/transfer_list.h	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -39,4 +39,5 @@
 #include "batch.h"
 #include "hw_struct/queue_head.h"
+#include "utils/malloc32.h"
 
 typedef struct transfer_list
Index: uspace/drv/uhci-hcd/utils/malloc32.h
===================================================================
--- uspace/drv/uhci-hcd/utils/malloc32.h	(revision 61257f414d6dfc36c096abb542ed95e187bfb391)
+++ uspace/drv/uhci-hcd/utils/malloc32.h	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -36,4 +36,5 @@
 
 #include <assert.h>
+#include <errno.h>
 #include <malloc.h>
 #include <mem.h>
Index: uspace/drv/uhci-rhd/main.c
===================================================================
--- uspace/drv/uhci-rhd/main.c	(revision 61257f414d6dfc36c096abb542ed95e187bfb391)
+++ uspace/drv/uhci-rhd/main.c	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -44,71 +44,9 @@
 
 #define NAME "uhci-rhd"
+
 static int hc_get_my_registers(ddf_dev_t *dev,
     uintptr_t *io_reg_address, size_t *io_reg_size);
-#if 0
 /*----------------------------------------------------------------------------*/
-static int usb_iface_get_hc_handle(ddf_fun_t *fun, devman_handle_t *handle)
-{
-	assert(fun);
-	assert(fun->driver_data);
-	assert(handle);
-
-	*handle = ((uhci_root_hub_t*)fun->driver_data)->hc_handle;
-
-	return EOK;
-}
-/*----------------------------------------------------------------------------*/
-static usb_iface_t uhci_rh_usb_iface = {
-	.get_hc_handle = usb_iface_get_hc_handle,
-	.get_address = usb_iface_get_address_hub_impl
-};
-/*----------------------------------------------------------------------------*/
-static ddf_dev_ops_t uhci_rh_ops = {
-	.interfaces[USB_DEV_IFACE] = &uhci_rh_usb_iface,
-};
-#endif
-/*----------------------------------------------------------------------------*/
-/** Initialize a new ddf driver instance of UHCI root hub.
- *
- * @param[in] device DDF instance of the device to initialize.
- * @return Error code.
- */
-static int uhci_rh_add_device(ddf_dev_t *device)
-{
-	if (!device)
-		return ENOTSUP;
-
-	usb_log_debug2("%s called device %d\n", __FUNCTION__, device->handle);
-
-	//device->ops = &uhci_rh_ops;
-	uintptr_t io_regs = 0;
-	size_t io_size = 0;
-
-	int ret = hc_get_my_registers(device, &io_regs, &io_size);
-	if (ret != EOK) {
-		usb_log_error("Failed to get registers from parent HC: %s.\n",
-		    str_error(ret));
-	}
-	usb_log_debug("I/O regs at %#X (size %zu).\n", io_regs, io_size);
-
-	uhci_root_hub_t *rh = malloc(sizeof(uhci_root_hub_t));
-	if (!rh) {
-		usb_log_error("Failed to allocate driver instance.\n");
-		return ENOMEM;
-	}
-
-	ret = uhci_root_hub_init(rh, (void*)io_regs, io_size, device);
-	if (ret != EOK) {
-		usb_log_error("Failed to initialize driver instance: %s.\n",
-		    str_error(ret));
-		free(rh);
-		return ret;
-	}
-
-	device->driver_data = rh;
-	usb_log_info("Controlling root hub `%s' (%llu).\n",
-	    device->name, device->handle);
-	return EOK;
-}
+static int uhci_rh_add_device(ddf_dev_t *device);
 /*----------------------------------------------------------------------------*/
 static driver_ops_t uhci_rh_driver_ops = {
@@ -132,8 +70,52 @@
 {
 	printf(NAME ": HelenOS UHCI root hub driver.\n");
+	usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME);
+	return ddf_driver_main(&uhci_rh_driver);
+}
+/*----------------------------------------------------------------------------*/
+/** Initialize a new ddf driver instance of UHCI root hub.
+ *
+ * @param[in] device DDF instance of the device to initialize.
+ * @return Error code.
+ */
+static int uhci_rh_add_device(ddf_dev_t *device)
+{
+	if (!device)
+		return EINVAL;
 
-	usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME);
+	usb_log_debug2("%s called device %d\n", __FUNCTION__, device->handle);
 
-	return ddf_driver_main(&uhci_rh_driver);
+	uintptr_t io_regs = 0;
+	size_t io_size = 0;
+	uhci_root_hub_t *rh = NULL;
+	int ret = EOK;
+
+#define CHECK_RET_FREE_RH_RETURN(ret, message...) \
+if (ret != EOK) { \
+	usb_log_error(message); \
+	if (rh) \
+		free(rh); \
+	return ret; \
+} else (void)0
+
+	ret = hc_get_my_registers(device, &io_regs, &io_size);
+	CHECK_RET_FREE_RH_RETURN(ret,
+	    "Failed(%d) to get registers from HC: %s.\n", ret, str_error(ret));
+	usb_log_debug("I/O regs at %#x (size %zu).\n", io_regs, io_size);
+
+	rh = malloc(sizeof(uhci_root_hub_t));
+	ret = (rh == NULL) ? ENOMEM : EOK;
+	CHECK_RET_FREE_RH_RETURN(ret,
+	    "Failed to allocate rh driver instance.\n");
+
+	ret = uhci_root_hub_init(rh, (void*)io_regs, io_size, device);
+	CHECK_RET_FREE_RH_RETURN(ret,
+	    "Failed(%d) to initialize rh driver instance: %s.\n",
+	    ret, str_error(ret));
+
+	device->driver_data = rh;
+	usb_log_info("Controlling root hub '%s' (%llu).\n",
+	    device->name, device->handle);
+	return EOK;
 }
 /*----------------------------------------------------------------------------*/
@@ -156,10 +138,9 @@
 	}
 
-	int rc;
-
 	hw_resource_list_t hw_resources;
-	rc = hw_res_get_resource_list(parent_phone, &hw_resources);
-	if (rc != EOK) {
-		goto leave;
+	int ret = hw_res_get_resource_list(parent_phone, &hw_resources);
+	if (ret != EOK) {
+		async_hangup(parent_phone);
+		return ret;
 	}
 
@@ -168,24 +149,18 @@
 	bool io_found = false;
 
-	size_t i;
-	for (i = 0; i < hw_resources.count; i++) {
+	size_t i = 0;
+	for (; i < hw_resources.count; i++) {
 		hw_resource_t *res = &hw_resources.resources[i];
-		switch (res->type)
-		{
-		case IO_RANGE:
-			io_address = (uintptr_t) res->res.io_range.address;
+		if (res->type == IO_RANGE) {
+			io_address = res->res.io_range.address;
 			io_size = res->res.io_range.size;
 			io_found = true;
-
-		default:
-			break;
 		}
 	}
+	async_hangup(parent_phone);
 
 	if (!io_found) {
-		rc = ENOENT;
-		goto leave;
+		return ENOENT;
 	}
-
 	if (io_reg_address != NULL) {
 		*io_reg_address = io_address;
@@ -194,9 +169,5 @@
 		*io_reg_size = io_size;
 	}
-	rc = EOK;
-
-leave:
-	async_hangup(parent_phone);
-	return rc;
+	return EOK;
 }
 /**
Index: uspace/drv/uhci-rhd/port.c
===================================================================
--- uspace/drv/uhci-rhd/port.c	(revision 61257f414d6dfc36c096abb542ed95e187bfb391)
+++ uspace/drv/uhci-rhd/port.c	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -43,9 +43,9 @@
 #include "port.h"
 
+static int uhci_port_check(void *port);
+static int uhci_port_reset_enable(int portno, void *arg);
 static int uhci_port_new_device(uhci_port_t *port, usb_speed_t speed);
 static int uhci_port_remove_device(uhci_port_t *port);
 static int uhci_port_set_enabled(uhci_port_t *port, bool enabled);
-static int uhci_port_check(void *port);
-static int uhci_port_reset_enable(int portno, void *arg);
 static void uhci_port_print_status(
     uhci_port_t *port, const port_status_t value);
@@ -74,5 +74,4 @@
 	pio_write_16(port->address, value);
 }
-
 /*----------------------------------------------------------------------------*/
 /** Initialize UHCI root hub port instance.
@@ -259,13 +258,13 @@
 
 	usb_address_t dev_addr;
-	int rc = usb_hc_new_device_wrapper(port->rh, &port->hc_connection,
+	int ret = usb_hc_new_device_wrapper(port->rh, &port->hc_connection,
 	    speed, uhci_port_reset_enable, port->number, port,
 	    &dev_addr, &port->attached_device, NULL, NULL, NULL);
 
-	if (rc != EOK) {
+	if (ret != EOK) {
 		usb_log_error("%s: Failed(%d) to add device: %s.\n",
-		    port->id_string, rc, str_error(rc));
+		    port->id_string, ret, str_error(ret));
 		uhci_port_set_enabled(port, false);
-		return rc;
+		return ret;
 	}
 
@@ -287,7 +286,7 @@
 int uhci_port_remove_device(uhci_port_t *port)
 {
-	usb_log_error("%s: Don't know how to remove device %d.\n",
-	    port->id_string, (unsigned int)port->attached_device);
-	return EOK;
+	usb_log_error("%s: Don't know how to remove device %llu.\n",
+	    port->id_string, port->attached_device);
+	return ENOTSUP;
 }
 /*----------------------------------------------------------------------------*/
@@ -341,5 +340,5 @@
 	    (value & STATUS_CONNECTED_CHANGED) ? " CONNECTED-CHANGE," : "",
 	    (value & STATUS_CONNECTED) ? " CONNECTED," : "",
-	    (value & STATUS_ALWAYS_ONE) ? " ALWAYS ONE" : " ERROR: NO ALWAYS ONE"
+	    (value & STATUS_ALWAYS_ONE) ? " ALWAYS ONE" : " ERR: NO ALWAYS ONE"
 	);
 }
Index: uspace/drv/uhci-rhd/root_hub.c
===================================================================
--- uspace/drv/uhci-rhd/root_hub.c	(revision 61257f414d6dfc36c096abb542ed95e187bfb391)
+++ uspace/drv/uhci-rhd/root_hub.c	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -51,10 +51,9 @@
 	assert(instance);
 	assert(rh);
-	int ret;
 
 	/* Allow access to root hub port registers */
 	assert(sizeof(port_status_t) * UHCI_ROOT_HUB_PORT_COUNT <= size);
 	port_status_t *regs;
-	ret = pio_enable(addr, size, (void**)&regs);
+	int ret = pio_enable(addr, size, (void**)&regs);
 	if (ret < 0) {
 		usb_log_error(
@@ -84,7 +83,6 @@
  *
  * @param[in] instance Root hub structure to use.
- * @return Error code.
  */
-int uhci_root_hub_fini(uhci_root_hub_t* instance)
+void uhci_root_hub_fini(uhci_root_hub_t* instance)
 {
 	assert(instance);
@@ -93,5 +91,4 @@
 		uhci_port_fini(&instance->ports[i]);
 	}
-	return EOK;
 }
 /*----------------------------------------------------------------------------*/
Index: uspace/drv/uhci-rhd/root_hub.h
===================================================================
--- uspace/drv/uhci-rhd/root_hub.h	(revision 61257f414d6dfc36c096abb542ed95e187bfb391)
+++ uspace/drv/uhci-rhd/root_hub.h	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -50,5 +50,5 @@
   uhci_root_hub_t *instance, void *addr, size_t size, ddf_dev_t *rh);
 
-int uhci_root_hub_fini(uhci_root_hub_t *instance);
+void uhci_root_hub_fini(uhci_root_hub_t *instance);
 #endif
 /**
Index: uspace/drv/usbhub/Makefile
===================================================================
--- uspace/drv/usbhub/Makefile	(revision 61257f414d6dfc36c096abb542ed95e187bfb391)
+++ uspace/drv/usbhub/Makefile	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -34,7 +34,7 @@
 SOURCES = \
 	main.c \
+	ports.c \
 	utils.c \
-	usbhub.c \
-	usblist.c
+	usbhub.c
 
 include $(USPACE_PREFIX)/Makefile.common
Index: uspace/drv/usbhub/port_status.h
===================================================================
--- uspace/drv/usbhub/port_status.h	(revision 61257f414d6dfc36c096abb542ed95e187bfb391)
+++ uspace/drv/usbhub/port_status.h	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -95,4 +95,20 @@
 }
 
+/**
+ * set the device request to be a port feature clear request
+ * @param request
+ * @param port
+ * @param feature_selector
+ */
+static inline void usb_hub_set_disable_port_feature_request(
+usb_device_request_setup_packet_t * request, uint16_t port,
+		uint16_t feature_selector
+){
+	request->index = port;
+	request->request_type = USB_HUB_REQ_TYPE_SET_PORT_FEATURE;
+	request->request = USB_HUB_REQUEST_CLEAR_FEATURE;
+	request->value = feature_selector;
+	request->length = 0;
+}
 
 /**
Index: uspace/drv/usbhub/ports.c
===================================================================
--- uspace/drv/usbhub/ports.c	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
+++ uspace/drv/usbhub/ports.c	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -0,0 +1,331 @@
+/*
+ * Copyright (c) 2011 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 drvusbhub
+ * @{
+ */
+/** @file
+ * Hub ports functions.
+ */
+#include "port_status.h"
+#include <inttypes.h>
+#include <errno.h>
+#include <str_error.h>
+#include <usb/request.h>
+#include <usb/debug.h>
+
+/** Retrieve port status.
+ *
+ * @param[in] ctrl_pipe Control pipe to use.
+ * @param[in] port Port number (starting at 1).
+ * @param[out] status Where to store the port status.
+ * @return Error code.
+ */
+static int get_port_status(usb_pipe_t *ctrl_pipe, size_t port,
+    usb_port_status_t *status)
+{
+	size_t recv_size;
+	usb_device_request_setup_packet_t request;
+	usb_port_status_t status_tmp;
+
+	usb_hub_set_port_status_request(&request, port);
+	int rc = usb_pipe_control_read(ctrl_pipe,
+	    &request, sizeof(usb_device_request_setup_packet_t),
+	    &status_tmp, sizeof(status_tmp), &recv_size);
+	if (rc != EOK) {
+		return rc;
+	}
+
+	if (recv_size != sizeof (status_tmp)) {
+		return ELIMIT;
+	}
+
+	if (status != NULL) {
+		*status = status_tmp;
+	}
+
+	return EOK;
+}
+
+/** Information for fibril for device discovery. */
+struct add_device_phase1 {
+	usb_hub_info_t *hub;
+	size_t port;
+	usb_speed_t speed;
+};
+
+/** Callback for enabling a specific port.
+ *
+ * We wait on a CV until port is reseted.
+ * That is announced via change on interrupt pipe.
+ *
+ * @param port_no Port number (starting at 1).
+ * @param arg Custom argument, points to @c usb_hub_info_t.
+ * @return Error code.
+ */
+static int enable_port_callback(int port_no, void *arg)
+{
+	usb_hub_info_t *hub = (usb_hub_info_t *) arg;
+	int rc;
+	usb_device_request_setup_packet_t request;
+	usb_hub_port_t *my_port = hub->ports + port_no;
+
+	usb_hub_set_reset_port_request(&request, port_no);
+	rc = usb_pipe_control_write(hub->control_pipe,
+	    &request, sizeof(request), NULL, 0);
+	if (rc != EOK) {
+		usb_log_warning("Port reset failed: %s.\n", str_error(rc));
+		return rc;
+	}
+
+	/*
+	 * Wait until reset completes.
+	 */
+	fibril_mutex_lock(&my_port->reset_mutex);
+	while (!my_port->reset_completed) {
+		fibril_condvar_wait(&my_port->reset_cv, &my_port->reset_mutex);
+	}
+	fibril_mutex_unlock(&my_port->reset_mutex);
+
+	/* Clear the port reset change. */
+	rc = usb_hub_clear_port_feature(hub->control_pipe,
+	    port_no, USB_HUB_FEATURE_C_PORT_RESET);
+	if (rc != EOK) {
+		usb_log_error("Failed to clear port %d reset feature: %s.\n",
+		    port_no, str_error(rc));
+		return rc;
+	}
+
+	return EOK;
+}
+
+/** Fibril for adding a new device.
+ *
+ * Separate fibril is needed because the port reset completion is announced
+ * via interrupt pipe and thus we cannot block here.
+ *
+ * @param arg Pointer to struct add_device_phase1.
+ * @return 0 Always.
+ */
+static int add_device_phase1_worker_fibril(void *arg)
+{
+	struct add_device_phase1 *data
+	    = (struct add_device_phase1 *) arg;
+
+	usb_address_t new_address;
+	devman_handle_t child_handle;
+
+	int rc = usb_hc_new_device_wrapper(data->hub->usb_device->ddf_dev,
+	    &data->hub->connection, data->speed,
+	    enable_port_callback, (int) data->port, data->hub,
+	    &new_address, &child_handle,
+	    NULL, NULL, NULL);
+
+	if (rc != EOK) {
+		usb_log_error("Failed registering device on port %zu: %s.\n",
+		    data->port, str_error(rc));
+		goto leave;
+	}
+
+	data->hub->ports[data->port].attached_device.handle = child_handle;
+	data->hub->ports[data->port].attached_device.address = new_address;
+
+	usb_log_info("Detected new device on `%s' (port %zu), " \
+	    "address %d (handle %" PRIun ").\n",
+	    data->hub->usb_device->ddf_dev->name, data->port,
+	    new_address, child_handle);
+
+leave:
+	free(arg);
+
+	return EOK;
+}
+
+/** Start device adding when connection change is detected.
+ *
+ * This fires a new fibril to complete the device addition.
+ *
+ * @param hub Hub where the change occured.
+ * @param port Port index (starting at 1).
+ * @param speed Speed of the device.
+ * @return Error code.
+ */
+static int add_device_phase1_new_fibril(usb_hub_info_t *hub, size_t port,
+    usb_speed_t speed)
+{
+	struct add_device_phase1 *data
+	    = malloc(sizeof(struct add_device_phase1));
+	if (data == NULL) {
+		return ENOMEM;
+	}
+	data->hub = hub;
+	data->port = port;
+	data->speed = speed;
+
+	usb_hub_port_t *the_port = hub->ports + port;
+
+	fibril_mutex_lock(&the_port->reset_mutex);
+	the_port->reset_completed = false;
+	fibril_mutex_unlock(&the_port->reset_mutex);
+
+	int rc = usb_hub_clear_port_feature(hub->control_pipe, port,
+	    USB_HUB_FEATURE_C_PORT_CONNECTION);
+	if (rc != EOK) {
+		free(data);
+		usb_log_warning("Failed to clear port change flag: %s.\n",
+		    str_error(rc));
+		return rc;
+	}
+
+	fid_t fibril = fibril_create(add_device_phase1_worker_fibril, data);
+	if (fibril == 0) {
+		free(data);
+		return ENOMEM;
+	}
+	fibril_add_ready(fibril);
+
+	return EOK;
+}
+
+/** Process change on a single port.
+ *
+ * @param hub Hub to which the port belongs.
+ * @param port Port index (starting at 1).
+ */
+static void process_port_change(usb_hub_info_t *hub, size_t port)
+{
+	int rc;
+
+	usb_port_status_t port_status;
+
+	rc = get_port_status(&hub->usb_device->ctrl_pipe, port, &port_status);
+	if (rc != EOK) {
+		usb_log_error("Failed to get port %zu status: %s.\n",
+		    port, str_error(rc));
+		return;
+	}
+
+	/*
+	 * Check exact nature of the change.
+	 */
+	usb_log_debug("Port %zu change status: %x.\n", port,
+	    (unsigned int) port_status);
+
+	if (usb_port_connect_change(&port_status)) {
+		bool device_connected = usb_port_dev_connected(&port_status);
+		usb_log_debug("Connection change on port %zu: %s.\n", port,
+		    device_connected ? "device attached" : "device removed");
+
+		if (device_connected) {
+			rc = add_device_phase1_new_fibril(hub, port,
+			    usb_port_speed(&port_status));
+			if (rc != EOK) {
+				usb_log_error(
+				    "Cannot handle change on port %zu: %s.\n",
+				    str_error(rc));
+			}
+		} else {
+			usb_hub_removed_device(hub, port);
+		}
+	}
+
+	if (usb_port_overcurrent_change(&port_status)) {
+		if (usb_port_over_current(&port_status)) {
+			usb_log_warning("Overcurrent on port %zu.\n", port);
+			usb_hub_over_current(hub, port);
+		} else {
+			usb_log_debug("Overcurrent on port %zu autoresolved.\n",
+			    port);
+		}
+	}
+
+	if (usb_port_reset_completed(&port_status)) {
+		usb_log_debug("Port %zu reset complete.\n", port);
+		if (usb_port_enabled(&port_status)) {
+			/* Finalize device adding. */
+			usb_hub_port_t *the_port = hub->ports + port;
+			fibril_mutex_lock(&the_port->reset_mutex);
+			the_port->reset_completed = true;
+			fibril_condvar_broadcast(&the_port->reset_cv);
+			fibril_mutex_unlock(&the_port->reset_mutex);
+		} else {
+			usb_log_warning(
+			    "Port %zu reset complete but port not enabled.\n",
+			    port);
+		}
+	}
+
+	usb_port_set_connect_change(&port_status, false);
+	usb_port_set_reset(&port_status, false);
+	usb_port_set_reset_completed(&port_status, false);
+	usb_port_set_dev_connected(&port_status, false);
+	if (port_status >> 16) {
+		usb_log_warning("Unsupported change on port %zu: %x.\n",
+		    port, (unsigned int) port_status);
+	}
+}
+
+
+/** Callback for polling hub for port changes.
+ *
+ * @param dev Device where the change occured.
+ * @param change_bitmap Bitmap of changed ports.
+ * @param change_bitmap_size Size of the bitmap in bytes.
+ * @param arg Custom argument, points to @c usb_hub_info_t.
+ * @return Whether to continue polling.
+ */
+bool hub_port_changes_callback(usb_device_t *dev,
+    uint8_t *change_bitmap, size_t change_bitmap_size, void *arg)
+{
+	usb_hub_info_t *hub = (usb_hub_info_t *) arg;
+
+	/* FIXME: check that we received enough bytes. */
+	if (change_bitmap_size == 0) {
+		goto leave;
+	}
+
+	size_t port;
+	for (port = 1; port < hub->port_count + 1; port++) {
+		bool change = (change_bitmap[port / 8] >> (port % 8)) % 2;
+		if (change) {
+			process_port_change(hub, port);
+		}
+	}
+
+
+leave:
+	/* FIXME: proper interval. */
+	async_usleep(1000 * 1000 * 10 );
+
+	return true;
+}
+
+
+/**
+ * @}
+ */
Index: uspace/drv/usbhub/ports.h
===================================================================
--- uspace/drv/usbhub/ports.h	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
+++ uspace/drv/usbhub/ports.h	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2011 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 drvusbhub
+ * @{
+ */
+/** @file
+ * Hub ports related functions.
+ */
+#ifndef DRV_USBHUB_PORTS_H
+#define DRV_USBHUB_PORTS_H
+
+#include <ipc/devman.h>
+#include <usb/usb.h>
+#include <ddf/driver.h>
+#include <fibril_synch.h>
+
+#include <usb/hub.h>
+
+#include <usb/pipes.h>
+#include <usb/devdrv.h>
+
+/** Information about single port on a hub. */
+typedef struct {
+	/** Mutex needed by CV for checking port reset. */
+	fibril_mutex_t reset_mutex;
+	/** CV for waiting to port reset completion. */
+	fibril_condvar_t reset_cv;
+	/** Whether port reset is completed.
+	 * Guarded by @c reset_mutex.
+	 */
+	bool reset_completed;
+
+	/** Information about attached device. */
+	usb_hc_attached_device_t attached_device;
+} usb_hub_port_t;
+
+/** Initialize hub port information.
+ *
+ * @param port Port to be initialized.
+ */
+static inline void usb_hub_port_init(usb_hub_port_t *port) {
+	port->attached_device.address = -1;
+	port->attached_device.handle = 0;
+	fibril_mutex_initialize(&port->reset_mutex);
+	fibril_condvar_initialize(&port->reset_cv);
+}
+
+bool hub_port_changes_callback(usb_device_t *, uint8_t *, size_t, void *);
+
+
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/usbhub/usbhub.c
===================================================================
--- uspace/drv/usbhub/usbhub.c	(revision 61257f414d6dfc36c096abb542ed95e187bfb391)
+++ uspace/drv/usbhub/usbhub.c	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -53,32 +53,6 @@
 #include "usb/classes/classes.h"
 
-
-static void usb_hub_init_add_device(usb_hub_info_t * hub, uint16_t port,
-		usb_speed_t speed);
-
 static int usb_hub_trigger_connecting_non_removable_devices(
 		usb_hub_info_t * hub, usb_hub_descriptor_t * descriptor);
-
-/**
- * control loop running in hub`s fibril
- *
- * Hub`s fibril periodically asks for changes on hub and if needded calls
- * change handling routine.
- * @warning currently hub driver asks for changes once a second
- * @param hub_info_param hub representation pointer
- * @return zero
- */
-int usb_hub_control_loop(void * hub_info_param){
-	usb_hub_info_t * hub_info = (usb_hub_info_t*)hub_info_param;
-	int errorCode = EOK;
-
-	while(errorCode == EOK){
-		errorCode = usb_hub_check_hub_changes(hub_info);
-		async_usleep(1000 * 1000 );/// \TODO proper number once
-	}
-	usb_log_error("something in ctrl loop went wrong, errno %d\n",errorCode);
-
-	return 0;
-}
 
 
@@ -152,10 +126,8 @@
 	usb_log_debug("setting port count to %d\n",descriptor->ports_count);
 	hub_info->port_count = descriptor->ports_count;
-	hub_info->attached_devs = (usb_hc_attached_device_t*)
-	    malloc((hub_info->port_count+1) * sizeof(usb_hc_attached_device_t));
-	int i;
-	for(i=0;i<hub_info->port_count+1;++i){
-		hub_info->attached_devs[i].handle=0;
-		hub_info->attached_devs[i].address=0;
+	hub_info->ports = malloc(sizeof(usb_hub_port_t) * (hub_info->port_count+1));
+	size_t port;
+	for (port = 0; port < hub_info->port_count + 1; port++) {
+		usb_hub_port_init(&hub_info->ports[port]);
 	}
 	//handle non-removable devices
@@ -259,16 +231,44 @@
 	assert(rc == EOK);
 
-	//create fibril for the hub control loop
-	fid_t fid = fibril_create(usb_hub_control_loop, hub_info);
-	if (fid == 0) {
-		usb_log_error("failed to start monitoring fibril for new hub.\n");
-		return ENOMEM;
-	}
-	fibril_add_ready(fid);
-	usb_log_debug("Hub fibril created.\n");
+	/*
+	 * The processing will require opened control pipe and connection
+	 * to the host controller.
+	 * It is waste of resources but let's hope there will be less
+	 * hubs than the phone limit.
+	 * FIXME: with some proper locking over pipes and session
+	 * auto destruction, this could work better.
+	 */
+	rc = usb_pipe_start_session(&usb_dev->ctrl_pipe);
+	if (rc != EOK) {
+		usb_log_error("Failed to start session on control pipe: %s.\n",
+		    str_error(rc));
+		goto leave;
+	}
+	rc = usb_hc_connection_open(&hub_info->connection);
+	if (rc != EOK) {
+		usb_pipe_end_session(&usb_dev->ctrl_pipe);
+		usb_log_error("Failed to open connection to HC: %s.\n",
+		    str_error(rc));
+		goto leave;
+	}
+
+	rc = usb_device_auto_poll(hub_info->usb_device, 0,
+	    hub_port_changes_callback, ((hub_info->port_count+1) / 8) + 1,
+	    NULL, hub_info);
+	if (rc != EOK) {
+		usb_log_error("Failed to create polling fibril: %s.\n",
+		    str_error(rc));
+		free(hub_info);
+		return rc;
+	}
 
 	usb_log_info("Controlling hub `%s' (%d ports).\n",
 	    hub_info->usb_device->ddf_dev->name, hub_info->port_count);
 	return EOK;
+
+leave:
+	free(hub_info);
+
+	return rc;
 }
 
@@ -317,6 +317,6 @@
 			//set the status change bit, so it will be noticed in driver loop
 			if(usb_port_dev_connected(&status)){
-				usb_hub_set_enable_port_feature_request(&request, port,
-						USB_HUB_FEATURE_C_PORT_CONNECTION);
+				usb_hub_set_disable_port_feature_request(&request, port,
+						USB_HUB_FEATURE_PORT_CONNECTION);
 				opResult = usb_pipe_control_read(
 						hub->control_pipe,
@@ -326,8 +326,53 @@
 				if (opResult != EOK) {
 					usb_log_warning(
-							"could not set port change on port %d errno:%d\n",
+							"could not clear port connection on port %d errno:%d\n",
 							port, opResult);
 				}
+				usb_log_debug("cleared port connection\n");
+				usb_hub_set_enable_port_feature_request(&request, port,
+						USB_HUB_FEATURE_PORT_ENABLE);
+				opResult = usb_pipe_control_read(
+						hub->control_pipe,
+						&request, sizeof(usb_device_request_setup_packet_t),
+						&status, 4, &rcvd_size
+						);
+				if (opResult != EOK) {
+					usb_log_warning(
+							"could not set port enabled on port %d errno:%d\n",
+							port, opResult);
+				}
+				usb_log_debug("port set to enabled - should lead to connection change\n");
 			}
+		}
+	}
+	/// \TODO this is just a debug code
+	for(port=1;port<=descriptor->ports_count;++port){
+		bool is_non_removable =
+				((non_removable_dev_bitmap[port/8]) >> (port%8)) %2;
+		if(is_non_removable){
+			usb_log_debug("port %d is non-removable\n",port);
+			usb_port_status_t status;
+			size_t rcvd_size;
+			usb_device_request_setup_packet_t request;
+			//int opResult;
+			usb_hub_set_port_status_request(&request, port);
+			//endpoint 0
+			opResult = usb_pipe_control_read(
+					hub->control_pipe,
+					&request, sizeof(usb_device_request_setup_packet_t),
+					&status, 4, &rcvd_size
+					);
+			if (opResult != EOK) {
+				usb_log_error("could not get port status %d\n",opResult);
+			}
+			if (rcvd_size != sizeof (usb_port_status_t)) {
+				usb_log_error("received status has incorrect size\n");
+			}
+			//something connected/disconnected
+			if (usb_port_connect_change(&status)) {
+				usb_log_debug("some connection changed\n");
+			}
+			usb_log_debug("status: %s\n",usb_debug_str_buffer(
+					(uint8_t *)&status,4,4));
 		}
 	}
@@ -352,135 +397,4 @@
 	hub->is_default_address_used = false;
 	return EOK;
-}
-
-/**
- * Reset the port with new device and reserve the default address.
- * @param hub hub representation
- * @param port port number, starting from 1
- * @param speed transfer speed of attached device, one of low, full or high
- */
-static void usb_hub_init_add_device(usb_hub_info_t * hub, uint16_t port,
-		usb_speed_t speed) {
-	//if this hub already uses default address, it cannot request it once more
-	if(hub->is_default_address_used) return;
-	usb_log_debug("some connection changed\n");
-	assert(hub->control_pipe->hc_phone);
-	int opResult = usb_hub_clear_port_feature(hub->control_pipe,
-				port, USB_HUB_FEATURE_C_PORT_CONNECTION);
-	if(opResult != EOK){
-		usb_log_warning("could not clear port-change-connection flag\n");
-	}
-	usb_device_request_setup_packet_t request;
-	
-	//get default address
-	opResult = usb_hc_reserve_default_address(&hub->connection, speed);
-	
-	if (opResult != EOK) {
-		usb_log_warning("cannot assign default address, it is probably used %d\n",
-				opResult);
-		return;
-	}
-	hub->is_default_address_used = true;
-	//reset port
-	usb_hub_set_reset_port_request(&request, port);
-	opResult = usb_pipe_control_write(
-			hub->control_pipe,
-			&request,sizeof(usb_device_request_setup_packet_t),
-			NULL, 0
-			);
-	if (opResult != EOK) {
-		usb_log_error("something went wrong when reseting a port %d\n",opResult);
-		usb_hub_release_default_address(hub);
-	}
-	return;
-}
-
-/**
- * Finalize adding new device after port reset
- *
- * Set device`s address and start it`s driver.
- * @param hub hub representation
- * @param port port number, starting from 1
- * @param speed transfer speed of attached device, one of low, full or high
- */
-static void usb_hub_finalize_add_device( usb_hub_info_t * hub,
-		uint16_t port, usb_speed_t speed) {
-
-	int opResult;
-	usb_log_debug("finalizing add device\n");
-	opResult = usb_hub_clear_port_feature(hub->control_pipe,
-	    port, USB_HUB_FEATURE_C_PORT_RESET);
-
-	if (opResult != EOK) {
-		usb_log_error("failed to clear port reset feature\n");
-		usb_hub_release_default_address(hub);
-		return;
-	}
-	//create connection to device
-	usb_pipe_t new_device_pipe;
-	usb_device_connection_t new_device_connection;
-	usb_device_connection_initialize_on_default_address(
-			&new_device_connection,
-			&hub->connection
-			);
-	usb_pipe_initialize_default_control(
-			&new_device_pipe,
-			&new_device_connection);
-	usb_pipe_probe_default_control(&new_device_pipe);
-
-	/* Request address from host controller. */
-	usb_address_t new_device_address = usb_hc_request_address(
-			&hub->connection,
-			speed
-			);
-	if (new_device_address < 0) {
-		usb_log_error("failed to get free USB address\n");
-		opResult = new_device_address;
-		usb_hub_release_default_address(hub);
-		return;
-	}
-	usb_log_debug("setting new address %d\n",new_device_address);
-	//opResult = usb_drv_req_set_address(hc, USB_ADDRESS_DEFAULT,
-	//    new_device_address);
-	usb_pipe_start_session(&new_device_pipe);
-	opResult = usb_request_set_address(&new_device_pipe,new_device_address);
-	usb_pipe_end_session(&new_device_pipe);
-	if (opResult != EOK) {
-		usb_log_error("could not set address for new device %d\n",opResult);
-		usb_hub_release_default_address(hub);
-		return;
-	}
-
-	//opResult = usb_hub_release_default_address(hc);
-	opResult = usb_hub_release_default_address(hub);
-	if(opResult!=EOK){
-		return;
-	}
-
-	devman_handle_t child_handle;
-	//??
-    opResult = usb_device_register_child_in_devman(new_device_address,
-            hub->connection.hc_handle, hub->usb_device->ddf_dev, &child_handle,
-            NULL, NULL, NULL);
-
-	if (opResult != EOK) {
-		usb_log_error("could not start driver for new device %d\n",opResult);
-		return;
-	}
-	hub->attached_devs[port].handle = child_handle;
-	hub->attached_devs[port].address = new_device_address;
-
-	//opResult = usb_drv_bind_address(hc, new_device_address, child_handle);
-	opResult = usb_hc_register_device(
-			&hub->connection,
-			&hub->attached_devs[port]);
-	if (opResult != EOK) {
-		usb_log_error("could not assign address of device in hcd %d\n",opResult);
-		return;
-	}
-	usb_log_info("Detected new device on `%s' (port %d), " \
-	    "address %d (handle %llu).\n",
-	    hub->usb_device->ddf_dev->name, (int) port,
-	    new_device_address, child_handle);
 }
 
@@ -494,5 +408,5 @@
  * @param port port number, starting from 1
  */
-static void usb_hub_removed_device(
+void usb_hub_removed_device(
     usb_hub_info_t * hub,uint16_t port) {
 
@@ -507,5 +421,5 @@
 	
 	//close address
-	if(hub->attached_devs[port].address!=0){
+	if(hub->ports[port].attached_device.address >= 0){
 		/*uncomment this code to use it when DDF allows device removal
 		opResult = usb_hc_unregister_device(
@@ -534,5 +448,5 @@
  * @param port port number, starting from 1
  */
-static void usb_hub_over_current( usb_hub_info_t * hub,
+void usb_hub_over_current( usb_hub_info_t * hub,
 		uint16_t port){
 	int opResult;
@@ -545,150 +459,4 @@
 }
 
-/**
- * Process interrupts on given hub port
- *
- * Accepts connection, over current and port reset change.
- * @param hub hub representation
- * @param port port number, starting from 1
- */
-static void usb_hub_process_interrupt(usb_hub_info_t * hub, 
-        uint16_t port) {
-	usb_log_debug("interrupt at port %d\n", port);
-	//determine type of change
-	usb_pipe_t *pipe = hub->control_pipe;
-	
-	int opResult;
-
-	usb_port_status_t status;
-	size_t rcvd_size;
-	usb_device_request_setup_packet_t request;
-	//int opResult;
-	usb_hub_set_port_status_request(&request, port);
-	//endpoint 0
-
-	opResult = usb_pipe_control_read(
-			pipe,
-			&request, sizeof(usb_device_request_setup_packet_t),
-			&status, 4, &rcvd_size
-			);
-	if (opResult != EOK) {
-		usb_log_error("could not get port status\n");
-		return;
-	}
-	if (rcvd_size != sizeof (usb_port_status_t)) {
-		usb_log_error("received status has incorrect size\n");
-		return;
-	}
-	//something connected/disconnected
-	if (usb_port_connect_change(&status)) {
-		if (usb_port_dev_connected(&status)) {
-			usb_log_debug("some connection changed\n");
-			usb_hub_init_add_device(hub, port, usb_port_speed(&status));
-		} else {
-			usb_hub_removed_device(hub, port);
-		}
-	}
-	//over current
-	if (usb_port_overcurrent_change(&status)) {
-		//check if it was not auto-resolved
-		if(usb_port_over_current(&status)){
-			usb_hub_over_current(hub,port);
-		}else{
-			usb_log_debug("over current condition was auto-resolved on port %d\n",
-					port);
-		}
-	}
-	//port reset
-	if (usb_port_reset_completed(&status)) {
-		usb_log_debug("port reset complete\n");
-		if (usb_port_enabled(&status)) {
-			usb_hub_finalize_add_device(hub, port, usb_port_speed(&status));
-		} else {
-			usb_log_warning("port reset, but port still not enabled\n");
-		}
-	}
-
-	usb_port_set_connect_change(&status, false);
-	usb_port_set_reset(&status, false);
-	usb_port_set_reset_completed(&status, false);
-	usb_port_set_dev_connected(&status, false);
-	if (status>>16) {
-		usb_log_info("there was some unsupported change on port %d: %X\n",
-				port,status);
-
-	}
-}
-
-/**
- * check changes on hub
- *
- * Handles changes on each port with a status change.
- * @param hub_info hub representation
- * @return error code
- */
-int usb_hub_check_hub_changes(usb_hub_info_t * hub_info){
-	int opResult;
-	opResult = usb_pipe_start_session(
-			hub_info->status_change_pipe);
-	if(opResult != EOK){
-		usb_log_error("could not initialize communication for hub; %d\n",
-				opResult);
-		return opResult;
-	}
-
-	size_t port_count = hub_info->port_count;
-
-	/// FIXME: count properly
-	size_t byte_length = ((port_count+1) / 8) + 1;
-		void *change_bitmap = malloc(byte_length);
-	size_t actual_size;
-
-	/*
-	 * Send the request.
-	 */
-	opResult = usb_pipe_read(
-			hub_info->status_change_pipe,
-			change_bitmap, byte_length, &actual_size
-			);
-
-	if (opResult != EOK) {
-		free(change_bitmap);
-		usb_log_warning("something went wrong while getting status of hub\n");
-		usb_pipe_end_session(hub_info->status_change_pipe);
-		return opResult;
-	}
-	unsigned int port;
-	opResult = usb_pipe_start_session(hub_info->control_pipe);
-	if(opResult!=EOK){
-		usb_log_error("could not start control pipe session %d\n", opResult);
-		usb_pipe_end_session(hub_info->status_change_pipe);
-		return opResult;
-	}
-	opResult = usb_hc_connection_open(&hub_info->connection);
-	if(opResult!=EOK){
-		usb_log_error("could not start host controller session %d\n",
-				opResult);
-		usb_pipe_end_session(hub_info->control_pipe);
-		usb_pipe_end_session(hub_info->status_change_pipe);
-		return opResult;
-	}
-
-	///todo, opresult check, pre obe konekce
-	for (port = 1; port < port_count+1; ++port) {
-		bool interrupt =
-				(((uint8_t*) change_bitmap)[port / 8] >> (port % 8)) % 2;
-		if (interrupt) {
-			usb_hub_process_interrupt(
-			        hub_info, port);
-		}
-	}
-	usb_hc_connection_close(&hub_info->connection);
-	usb_pipe_end_session(hub_info->control_pipe);
-	usb_pipe_end_session(hub_info->status_change_pipe);
-	free(change_bitmap);
-	return EOK;
-}
-
-
 
 /**
Index: uspace/drv/usbhub/usbhub.h
===================================================================
--- uspace/drv/usbhub/usbhub.h	(revision 61257f414d6dfc36c096abb542ed95e187bfb391)
+++ uspace/drv/usbhub/usbhub.h	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -47,12 +47,15 @@
 #include <usb/devdrv.h>
 
+#include "ports.h"
+
+
 
 /** Information about attached hub. */
 typedef struct {
 	/** Number of ports. */
-	int port_count;
+	size_t port_count;
 
-	/** attached device handles, for each port one */
-	usb_hc_attached_device_t * attached_devs;
+	/** Ports. */
+	usb_hub_port_t *ports;
 	
 	/** connection to hcd */
@@ -100,4 +103,6 @@
 int usb_hub_check_hub_changes(usb_hub_info_t * hub_info_param);
 
+void usb_hub_removed_device(usb_hub_info_t *, uint16_t);
+void usb_hub_over_current(usb_hub_info_t *, uint16_t);
 
 int usb_hub_add_device(usb_device_t * usb_dev);
Index: uspace/drv/usbhub/usbhub_private.h
===================================================================
--- uspace/drv/usbhub/usbhub_private.h	(revision 61257f414d6dfc36c096abb542ed95e187bfb391)
+++ uspace/drv/usbhub/usbhub_private.h	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -38,5 +38,4 @@
 
 #include "usbhub.h"
-#include "usblist.h"
 
 #include <adt/list.h>
Index: uspace/drv/usbhub/usblist.c
===================================================================
--- uspace/drv/usbhub/usblist.c	(revision 61257f414d6dfc36c096abb542ed95e187bfb391)
+++ 	(revision )
@@ -1,80 +1,0 @@
-/*
- * Copyright (c) 2010 Matus Dekanek
- * 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 drvusbhub
- * @{
- */
-/** @file
- * @brief usblist implementation
- */
-#include <sys/types.h>
-
-#include "usbhub_private.h"
-
-
-usb_general_list_t * usb_lst_create(void) {
-	usb_general_list_t* result = usb_new(usb_general_list_t);
-	usb_lst_init(result);
-	return result;
-}
-
-void usb_lst_init(usb_general_list_t * lst) {
-	lst->prev = lst;
-	lst->next = lst;
-	lst->data = NULL;
-}
-
-void usb_lst_prepend(usb_general_list_t* item, void* data) {
-	usb_general_list_t* appended = usb_new(usb_general_list_t);
-	appended->data = data;
-	appended->next = item;
-	appended->prev = item->prev;
-	item->prev->next = appended;
-	item->prev = appended;
-}
-
-void usb_lst_append(usb_general_list_t* item, void* data) {
-	usb_general_list_t* appended = usb_new(usb_general_list_t);
-	appended->data = data;
-	appended->next = item->next;
-	appended->prev = item;
-	item->next->prev = appended;
-	item->next = appended;
-}
-
-void usb_lst_remove(usb_general_list_t* item) {
-	item->next->prev = item->prev;
-	item->prev->next = item->next;
-}
-
-
-
-/**
- * @}
- */
-
-
Index: uspace/drv/usbhub/usblist.h
===================================================================
--- uspace/drv/usbhub/usblist.h	(revision 61257f414d6dfc36c096abb542ed95e187bfb391)
+++ 	(revision )
@@ -1,82 +1,0 @@
-/*
- * Copyright (c) 2010 Matus Dekanek
- * 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 drvusbhub
- * @{
- */
-/** @file
- * @brief HC driver and hub driver.
- *
- * My private list implementation; I did not like the original helenos list.
- * This one does not depend on the structure of stored data and has
- * much simpler and more straight-forward semantics.
- */
-#ifndef USBLIST_H
-#define	USBLIST_H
-
-/**
- * general list structure
- */
-typedef struct usb_general_list{
-	void * data;
-	struct usb_general_list * prev, * next;
-} usb_general_list_t;
-
-/** create head of usb general list */
-usb_general_list_t * usb_lst_create(void);
-
-/** initialize head of usb general list */
-void usb_lst_init(usb_general_list_t * lst);
-
-
-/** is the list empty? */
-static inline bool usb_lst_empty(usb_general_list_t * lst){
-	return lst?(lst->next==lst):true;
-}
-
-/** append data behind item */
-void usb_lst_append(usb_general_list_t * lst, void * data);
-
-/** prepend data beore item */
-void usb_lst_prepend(usb_general_list_t * lst, void * data);
-
-/** remove list item from list */
-void usb_lst_remove(usb_general_list_t * item);
-
-/** get data o specified type from list item */
-#define usb_lst_get_data(item, type)  (type *) (item->data)
-
-/** get usb_hub_info_t data from list item */
-static inline usb_hub_info_t * usb_hub_lst_get_data(usb_general_list_t * item) {
-	return usb_lst_get_data(item,usb_hub_info_t);
-}
-
-#endif	/* USBLIST_H */
-/**
- * @}
- */
Index: uspace/drv/usbmid/explore.c
===================================================================
--- uspace/drv/usbmid/explore.c	(revision 61257f414d6dfc36c096abb542ed95e187bfb391)
+++ uspace/drv/usbmid/explore.c	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -48,21 +48,33 @@
 };
 
-/** Find starting indexes of all interface descriptors in a configuration.
- *
- * @param config_descriptor Full configuration descriptor.
- * @param config_descriptor_size Size of @p config_descriptor in bytes.
- * @param interface_positions Array where to store indexes of interfaces.
- * @param interface_count Size of @p interface_positions array.
- * @return Number of found interfaces.
- * @retval (size_t)-1 Error occured.
- */
-static size_t find_interface_descriptors(uint8_t *config_descriptor,
-    size_t config_descriptor_size,
-    size_t *interface_positions, size_t interface_count)
+/** Tell whether given interface is already in the list.
+ *
+ * @param list List of usbmid_interface_t members to be searched.
+ * @param interface_no Interface number caller is looking for.
+ * @return Interface @p interface_no is already present in the list.
+ */
+static bool interface_in_list(link_t *list, int interface_no)
 {
-	if (interface_count == 0) {
-		return (size_t) -1;
-	}
-
+	link_t *l;
+	for (l = list->next; l != list; l = l->next) {
+		usbmid_interface_t *iface
+		    = list_get_instance(l, usbmid_interface_t, link);
+		if (iface->interface_no == interface_no) {
+			return true;
+		}
+	}
+
+	return false;
+}
+
+/** Create list of interfaces from configuration descriptor.
+ *
+ * @param config_descriptor Configuration descriptor.
+ * @param config_descriptor_size Size of configuration descriptor in bytes.
+ * @param list List where to add the interfaces.
+ */
+static void create_interfaces(uint8_t *config_descriptor,
+    size_t config_descriptor_size, link_t *list)
+{
 	usb_dp_parser_data_t data = {
 		.data = config_descriptor,
@@ -75,30 +87,43 @@
 	};
 
-	uint8_t *interface = usb_dp_get_nested_descriptor(&parser, &data,
+	uint8_t *interface_ptr = usb_dp_get_nested_descriptor(&parser, &data,
 	    data.data);
-	if (interface == NULL) {
-		return (size_t) -1;
-	}
-	if (interface[1] != USB_DESCTYPE_INTERFACE) {
-		return (size_t) -1;
-	}
-
-	size_t found_interfaces = 0;
-	interface_positions[found_interfaces] = interface - config_descriptor;
-	found_interfaces++;
-
-	while (interface != NULL) {
-		interface = usb_dp_get_sibling_descriptor(&parser, &data,
-		    data.data, interface);
-		if ((interface != NULL)
-		    && (found_interfaces < interface_count)
-		    && (interface[1] == USB_DESCTYPE_INTERFACE)) {
-			interface_positions[found_interfaces]
-			    = interface - config_descriptor;
-			found_interfaces++;
-		}
-	}
-
-	return found_interfaces;
+	if (interface_ptr == NULL) {
+		return;
+	}
+
+	do {
+		if (interface_ptr[1] != USB_DESCTYPE_INTERFACE) {
+			goto next_descriptor;
+		}
+
+		usb_standard_interface_descriptor_t *interface
+		    = (usb_standard_interface_descriptor_t *) interface_ptr;
+
+		/* Skip alternate interfaces. */
+		if (!interface_in_list(list, interface->interface_number)) {
+			usbmid_interface_t *iface
+			    = malloc(sizeof(usbmid_interface_t));
+			if (iface == NULL) {
+				break;
+			}
+			link_initialize(&iface->link);
+			iface->fun = NULL;
+			iface->interface_no = interface->interface_number;
+			iface->interface = interface;
+
+			list_append(&iface->link, list);
+		}
+
+		/* TODO: add the alternatives and create match ids from them
+		 * as well.
+		 */
+
+next_descriptor:
+		interface_ptr = usb_dp_get_sibling_descriptor(&parser, &data,
+		    data.data, interface_ptr);
+
+	} while (interface_ptr != NULL);
+
 }
 
@@ -130,23 +155,4 @@
 	    (usb_standard_configuration_descriptor_t *) config_descriptor_raw;
 
-	size_t *interface_descriptors
-	    = malloc(sizeof(size_t) * config_descriptor->interface_count);
-	if (interface_descriptors == NULL) {
-		usb_log_error("Out of memory (wanted %zuB).\n",
-		    sizeof(size_t) * config_descriptor->interface_count);
-		free(config_descriptor_raw);
-		return false;
-	}
-	size_t interface_descriptors_count
-	    = find_interface_descriptors(
-	    config_descriptor_raw, config_descriptor_size,
-	    interface_descriptors, config_descriptor->interface_count);
-
-	if (interface_descriptors_count == (size_t) -1) {
-		usb_log_error("Problem parsing configuration descriptor.\n");
-		free(interface_descriptors);
-		return false;
-	}
-
 	/* Select the first configuration */
 	rc = usb_request_set_configuration(&dev->ctrl_pipe,
@@ -155,8 +161,6 @@
 		usb_log_error("Failed to set device configuration: %s.\n",
 		    str_error(rc));
-		free(interface_descriptors);
-		return false;
-	}
-
+		return false;
+	}
 
 	/* Create control function */
@@ -164,5 +168,4 @@
 	if (ctl_fun == NULL) {
 		usb_log_error("Failed to create control function.\n");
-		free(interface_descriptors);
 		return false;
 	}
@@ -174,21 +177,25 @@
 		usb_log_error("Failed to bind control function: %s.\n",
 		    str_error(rc));
-		free(interface_descriptors);
-		return false;
-	}
-
-	/* Spawn interface children */
-	size_t i;
-	for (i = 0; i < interface_descriptors_count; i++) {
-		usb_standard_interface_descriptor_t *interface
-		    = (usb_standard_interface_descriptor_t *)
-		    (config_descriptor_raw + interface_descriptors[i]);
-		usb_log_debug2("Interface descriptor at index %zu (type %d).\n",
-		    interface_descriptors[i], (int) interface->descriptor_type);
+		return false;
+	}
+
+	/* Create interface children. */
+	link_t interface_list;
+	list_initialize(&interface_list);
+	create_interfaces(config_descriptor_raw, config_descriptor_size,
+	    &interface_list);
+
+	link_t *link;
+	for (link = interface_list.next; link != &interface_list;
+	    link = link->next) {
+		usbmid_interface_t *iface = list_get_instance(link,
+		    usbmid_interface_t, link);
+
 		usb_log_info("Creating child for interface %d (%s).\n",
-		    (int) interface->interface_number,
-		    usb_str_class(interface->interface_class));
-		rc = usbmid_spawn_interface_child(dev, &dev->descriptors.device,
-		    interface);
+		    (int) iface->interface_no,
+		    usb_str_class(iface->interface->interface_class));
+
+		rc = usbmid_spawn_interface_child(dev, iface,
+		    &dev->descriptors.device, iface->interface);
 		if (rc != EOK) {
 			usb_log_error("Failed to create interface child: %s.\n",
Index: uspace/drv/usbmid/usbmid.c
===================================================================
--- uspace/drv/usbmid/usbmid.c	(revision 61257f414d6dfc36c096abb542ed95e187bfb391)
+++ uspace/drv/usbmid/usbmid.c	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -79,30 +79,9 @@
 };
 
-/** Create new interface for USB MID device.
- *
- * @param fun Backing generic DDF device function (representing interface).
- * @param iface_no Interface number.
- * @return New interface.
- * @retval NULL Error occured.
- */
-usbmid_interface_t *usbmid_interface_create(ddf_fun_t *fun, int iface_no)
-{
-	usbmid_interface_t *iface = malloc(sizeof(usbmid_interface_t));
-	if (iface == NULL) {
-		usb_log_error("Out of memory (wanted %zuB).\n",
-		    sizeof(usbmid_interface_t));
-		return NULL;
-	}
-
-	iface->fun = fun;
-	iface->interface_no = iface_no;
-
-	return iface;
-}
-
 
 /** Spawn new child device from one interface.
  *
  * @param parent Parent MID device.
+ * @param iface Interface information.
  * @param device_descriptor Device descriptor.
  * @param interface_descriptor Interface descriptor.
@@ -110,4 +89,5 @@
  */
 int usbmid_spawn_interface_child(usb_device_t *parent,
+    usbmid_interface_t *iface,
     const usb_standard_device_descriptor_t *device_descriptor,
     const usb_standard_interface_descriptor_t *interface_descriptor)
@@ -115,5 +95,4 @@
 	ddf_fun_t *child = NULL;
 	char *child_name = NULL;
-	usbmid_interface_t *child_as_interface = NULL;
 	int rc;
 
@@ -137,14 +116,7 @@
 	}
 
+	iface->fun = child;
 
-
-	child_as_interface = usbmid_interface_create(child,
-	    (int) interface_descriptor->interface_number);
-	if (child_as_interface == NULL) {
-		rc = ENOMEM;
-		goto error_leave;
-	}
-
-	child->driver_data = child_as_interface;
+	child->driver_data = iface;
 	child->ops = &child_device_ops;
 
@@ -172,7 +144,4 @@
 		free(child_name);
 	}
-	if (child_as_interface != NULL) {
-		free(child_as_interface);
-	}
 
 	return rc;
Index: uspace/drv/usbmid/usbmid.h
===================================================================
--- uspace/drv/usbmid/usbmid.h	(revision 61257f414d6dfc36c096abb542ed95e187bfb391)
+++ uspace/drv/usbmid/usbmid.h	(revision f8e8738d31d2b92e00a460fe812bda69bfb6ef51)
@@ -37,4 +37,5 @@
 #define USBMID_H_
 
+#include <adt/list.h>
 #include <ddf/driver.h>
 #include <usb/usb.h>
@@ -49,12 +50,14 @@
 	/** Function container. */
 	ddf_fun_t *fun;
-
+	/** Interface descriptor. */
+	usb_standard_interface_descriptor_t *interface;
 	/** Interface number. */
 	int interface_no;
+	/** List link. */
+	link_t link;
 } usbmid_interface_t;
 
-usbmid_interface_t *usbmid_interface_create(ddf_fun_t *, int);
 bool usbmid_explore_device(usb_device_t *);
-int usbmid_spawn_interface_child(usb_device_t *,
+int usbmid_spawn_interface_child(usb_device_t *, usbmid_interface_t *,
     const usb_standard_device_descriptor_t *,
     const usb_standard_interface_descriptor_t *);
