Index: uspace/drv/bus/usb/ehci/Makefile
===================================================================
--- uspace/drv/bus/usb/ehci/Makefile	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/ehci/Makefile	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -31,4 +31,5 @@
 LIBS = \
 	$(LIBUSBHOST_PREFIX)/libusbhost.a \
+	$(LIBUSBVIRT_PREFIX)/libusbvirt.a \
 	$(LIBUSB_PREFIX)/libusb.a \
 	$(LIBDRV_PREFIX)/libdrv.a
@@ -36,5 +37,7 @@
 EXTRA_CFLAGS += \
 	-I$(LIBUSB_PREFIX)/include \
+	-I$(LIBUSBDEV_PREFIX)/include \
 	-I$(LIBUSBHOST_PREFIX)/include \
+	-I$(LIBUSBVIRT_PREFIX)/include \
 	-I$(LIBDRV_PREFIX)/include
 
@@ -42,4 +45,7 @@
 
 SOURCES = \
+	ehci.c \
+	ehci_rh.c \
+	hc.c \
 	main.c \
 	res.c
Index: uspace/drv/bus/usb/ehci/ehci.c
===================================================================
--- uspace/drv/bus/usb/ehci/ehci.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
+++ uspace/drv/bus/usb/ehci/ehci.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -0,0 +1,158 @@
+/*
+ * 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 drvusbehci
+ * @{
+ */
+/** @file
+ * @brief EHCI driver
+ */
+
+#include <assert.h>
+#include <errno.h>
+#include <ddf/interrupt.h>
+#include <device/hw_res_parsed.h>
+#include <stdbool.h>
+#include <str_error.h>
+#include <sys/types.h>
+
+#include <usb/usb.h>
+#include <usb/debug.h>
+
+#include <usb/host/ddf_helpers.h>
+#include <usb/host/usb_bus.h>
+
+#include "ehci.h"
+//#include "ehci_endpoint.h"
+#include "hc.h"
+
+
+/** IRQ handling callback, identifies device
+ *
+ * @param[in] dev DDF instance of the device to use.
+ * @param[in] iid (Unused).
+ * @param[in] call Pointer to the call that represents interrupt.
+ */
+static void irq_handler(ddf_dev_t *dev, ipc_callid_t iid, ipc_call_t *call)
+{
+	assert(dev);
+	hcd_t *hcd = dev_to_hcd(dev);
+	if (!hcd || !hcd->driver.data) {
+		usb_log_warning("Interrupt on device that is not ready.\n");
+		return;
+	}
+
+	const uint16_t status = IPC_GET_ARG1(*call);
+	hc_interrupt(hcd->driver.data, status);
+}
+
+/** Initialize hc and rh ddf structures and their respective drivers.
+ *
+ * @param[in] device DDF instance of the device to use.
+ * @param[in] instance EHCI structure to use.
+ *
+ * This function does all the preparatory work for hc and rh drivers:
+ *  - gets device hw resources
+ *  - disables EHCI legacy support
+ *  - asks for interrupt
+ *  - registers interrupt handler
+ */
+int device_setup_ehci(ddf_dev_t *device)
+{
+	hw_res_list_parsed_t hw_res;
+	int ret = hcd_ddf_get_registers(device, &hw_res);
+	if (ret != EOK ||
+	    hw_res.irqs.count != 1 || hw_res.mem_ranges.count != 1) {
+		usb_log_error("Failed to get register memory addresses "
+		    "for %" PRIun ": %s.\n", ddf_dev_get_handle(device),
+		    str_error(ret));
+		return ret;
+	}
+	addr_range_t regs = hw_res.mem_ranges.ranges[0];
+	const int irq = hw_res.irqs.irqs[0];
+	hw_res_list_parsed_clean(&hw_res);
+
+	usb_log_debug("Memory mapped regs at %p (size %zu), IRQ %d.\n",
+	    RNGABSPTR(regs), RNGSZ(regs), irq);
+
+	/* Initialize generic HCD driver */
+	ret = hcd_ddf_setup_hc(device, USB_SPEED_HIGH,
+	    BANDWIDTH_AVAILABLE_USB20, bandwidth_count_usb20);
+	if (ret != EOK) {
+		usb_log_error("Failed to setup generic hcd structures: %s.",
+		    str_error(ret));
+		return ret;
+	}
+
+	hc_t *hc = malloc(sizeof(hc_t));
+	if (!hc) {
+		usb_log_error("Failed to allocate driver structure.\n");
+		ret = ENOMEM;
+		goto ddf_hc_clean;
+	}
+
+	/* Try to enable interrupts */
+	bool interrupts = false;
+	ret = hcd_ddf_setup_interrupts(device, &regs, irq, irq_handler,
+	    hc_gen_irq_code);
+	if (ret != EOK) {
+		usb_log_warning("Failed to enable interrupts: %s."
+		    " Falling back to polling\n", str_error(ret));
+	} else {
+		usb_log_debug("Hw interrupts enabled.\n");
+		interrupts = true;
+	}
+
+	/* Initialize EHCI HC */
+	ret = hc_init(hc, &regs, interrupts);
+	if (ret != EOK) {
+		usb_log_error("Failed to init hc: %s.\n", str_error(ret));
+		goto unregister_irq;
+	}
+
+	/* Connect EHCI to generic HCD */
+	hcd_set_implementation(dev_to_hcd(device), hc,
+	    hc_schedule, NULL, NULL);
+
+	/* HC should be running OK. We can add root hub */
+	ret = hcd_ddf_setup_root_hub(device);
+	if (ret != EOK) {
+		usb_log_error("Failed to register EHCI root hub: %s.\n",
+		    str_error(ret));
+		hc_fini(hc);
+unregister_irq:
+		unregister_interrupt_handler(device, irq);
+		free(hc);
+ddf_hc_clean:
+		hcd_ddf_clean_hc(device);
+	}
+	return ret;
+}
+/**
+ * @}
+ */
Index: uspace/drv/bus/usb/ehci/ehci.h
===================================================================
--- uspace/drv/bus/usb/ehci/ehci.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
+++ uspace/drv/bus/usb/ehci/ehci.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2013 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 drvusbehci
+ * @{
+ */
+/** @file
+ * @brief EHCI driver main structure for both host controller and root-hub.
+ */
+#ifndef DRV_EHCI_EHCI_H
+#define DRV_EHCI_EHCI_H
+#include <ddf/driver.h>
+
+int device_setup_ehci(ddf_dev_t *device);
+
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/bus/usb/ehci/ehci_regs.h
===================================================================
--- uspace/drv/bus/usb/ehci/ehci_regs.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
+++ uspace/drv/bus/usb/ehci/ehci_regs.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -0,0 +1,172 @@
+/*
+ * Copyright (c) 2013 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 drvusbehci
+ * @{
+ */
+/** @file
+ * @brief EHCI host controller register structure
+ */
+#ifndef DRV_EHCI_EHCI_REGS_H
+#define DRV_EHCI_EHCI_REGS_H
+#include <sys/types.h>
+#include <byteorder.h>
+#include <macros.h>
+#include <ddi.h>
+
+#define EHCI_WR(reg, val) pio_write_32(&(reg), host2uint32_t_le(val))
+#define EHCI_RD(reg) uint32_t_le2host(pio_read_32(&(reg)))
+#define EHCI_RD8(reg) pio_read_8(&(reg))
+//#define EHCI_SET(reg, val) reg |= host2uint32_t_le(val)
+//#define EHCI_CLR(reg, val) reg &= host2uint32_t_le(~val)
+
+/** EHCI memory mapped capability registers structure */
+typedef struct ehci_cap_regs {
+	const ioport8_t caplength;
+	PADD8;
+	const ioport16_t hciversion;
+	const ioport32_t hcsparams;
+#define EHCI_CAPS_HCS_DEBUG_PORT_MASK   0xf
+#define EHCI_CAPS_HCS_DEBUG_PORT_SHIFT  (1 << 20)
+#define EHCI_CAPS_HCS_INDICATORS_FLAG   (1 << 16)
+#define EHCI_CAPS_HCS_N_CC_MASK         0xf
+#define EHCI_CAPS_HCS_N_CC_SHIFT        12
+#define EHCI_CAPS_HCS_N_PCC_MASK        0xf
+#define EHCI_CAPS_HCS_N_PCC_SHIFT       8
+#define EHCI_CAPS_HCS_ROUTING_FLAG      (1 << 7)
+#define EHCI_CAPS_HCS_PPC_FLAG          (1 << 4)
+#define EHCI_CAPS_HCS_N_PORTS_MASK      0xf
+#define EHCI_CAPS_HCS_N_PORTS_SHIFT     0
+
+	const ioport32_t hccparams;
+#define EHCI_CAPS_HCC_EECP_MASK           0xff
+#define EHCI_CAPS_HCC_EECP_SHIFT          8
+#define EHCI_CAPS_HCC_ISO_THRESHOLD_MASK  0xf
+#define EHCI_CAPS_HCC_ISO_THRESHOLD_SHIFT 4
+#define EHCI_CAPS_HCC_ASYNC_PART_FLAG     (1 << 2)
+#define EHCI_CAPS_HCC_PROG_FRAME_FLAG     (1 << 1)
+#define EHCI_CAPS_HCC_64_FLAG             (1 << 0)
+	ioport8_t hcsp_portoute[8];
+
+} ehci_caps_regs_t;
+
+
+/** EHCI memory mapped operational registers structure */
+typedef struct ehci_regs {
+	ioport32_t usbcmd;
+#define USB_CMD_INT_THRESHOLD_MASK     0xff
+#define USB_CMD_INT_THRESHOLD_SHIFT    16
+#define USB_CMD_PARK_MODE_FLAG         (1 << 11)
+#define USB_CMD_PARK_COUNT_MASK        0x3
+#define USB_CMD_PARK_COUNT_SHIFT       8
+#define USB_CMD_LIGHT_RESET            (1 << 7)
+#define USB_CMD_IRQ_ASYNC_DOORBELL     (1 << 6)
+#define USB_CMD_ASYNC_SCHEDULE_FLAG    (1 << 5)
+#define USB_CMD_PERIODIC_SCHEDULE_FLAG (1 << 4)
+#define USB_CMD_FRAME_LIST_SIZE_MASK   0x3
+#define USB_CMD_FRAME_LIST_SIZE_SHIFT  2
+#define USB_CMD_FRAME_LIST_SIZE_1024   0x0
+#define USB_CMD_FRAME_LIST_SIZE_512    0x1
+#define USB_CMD_FRAME_LIST_SIZE_256    0x2
+#define USB_CMD_HC_RESET_FLAG          (1 << 1)
+#define USB_CMD_RUN_FLAG               (1 << 0)
+
+	ioport32_t usbsts;
+#define USB_STS_ASYNC_SCHED_FLAG         (1 << 15)
+#define USB_STS_PERIODIC_SCHED_FLAG      (1 << 14)
+#define USB_STS_RECLAMATION_FLAG         (1 << 13)
+#define USB_STS_HC_HALTED_FLAG           (1 << 12)
+#define USB_STS_IRQ_ASYNC_ADVANCE_FLAG   (1 <<  5)
+#define USB_STS_HOST_ERROR_FLAG          (1 <<  4)
+#define USB_STS_FRAME_ROLLOVER_FLAG      (1 <<  3)
+#define USB_STS_PORT_CHANGE_FLAG         (1 <<  2)
+#define USB_STS_ERR_IRQ_FLAG             (1 <<  1)
+#define USB_STS_IRQ_FLAG                 (1 <<  0)
+
+	ioport32_t usbintr;
+#define USB_INTR_ASYNC_ADVANCE_FLAG   (1 << 5)
+#define USB_INTR_HOST_ERR_FLAG        (1 << 4)
+#define USB_INTR_FRAME_ROLLOVER_FLAG  (1 << 3)
+#define USB_INTR_PORT_CHANGE_FLAG     (1 << 2)
+#define USB_INTR_ERR_IRQ_FLAG         (1 << 1)
+#define USB_INTR_IRQ_FLAG             (1 << 0)
+
+	ioport32_t frindex;
+#define USB_FRINDEX_MASK   0xfff
+
+	ioport32_t ctrldssegment;
+	ioport32_t periodiclistbase;
+#define USB_PERIODIC_LIST_BASE_MASK   0xfffff000
+
+	ioport32_t asynclistaddr;
+#define USB_ASYNCLIST_MASK   0xfffffff0
+
+	PADD32[9];
+
+	ioport32_t configflag;
+#define USB_CONFIG_FLAG_FLAG   (1 << 0)
+
+	ioport32_t portsc[];
+#define USB_PORTSC_WKOC_E_FLAG       (1 << 22)
+#define USB_PORTSC_WKDSCNNT_E_FLAG   (1 << 21)
+#define USB_PORTSC_WKCNNT_E_FLAG     (1 << 20)
+#define USB_PORTSC_PORT_TEST_MASK    0xf
+#define USB_PORTSC_PORT_TEST_SHIFT   16
+#define USB_PORTSC_NO_TEST           0x0
+#define USB_PORTSC_TEST_J_STATE      0x1
+#define USB_PORTSC_TEST_K_STATE      0x2
+#define USB_PORTSC_TEST_SE0_NAK      0x3
+#define USB_PORTSC_TEST_PACKET       0x4
+#define USB_PORTSC_TEST_FORCE_ENABLE 0x5
+#define USB_PORTSC_INDICATOR_MASK    0x3
+#define USB_PORTSC_INDICATOR_SHIFT   14
+#define USB_PORTSC_INDICATOR_OFF     0x0
+#define USB_PORTSC_INDICATOR_AMBER   0x1
+#define USB_PORTSC_INDICATOR_GREEN   0x2
+#define USB_PORTSC_PORT_OWNER_FLAG   (1 << 13)
+#define USB_PORTSC_PORT_POWER_FLAG   (1 << 12)
+#define USB_PORTSC_LINE_STATUS_MASK  0x3
+#define USB_PORTSC_LINE_STATUS_SHIFT 10
+#define USB_PORTSC_LINE_STATUS_SE0   0x0
+#define USB_PORTSC_LINE_STATUS_K     0x1
+#define USB_PORTSC_LINE_STATUS_J     0x2
+#define USB_PORTSC_PORT_RESET_FLAG   (1 << 8)
+#define USB_PORTSC_SUSPEND_FLAG      (1 << 7)
+#define USB_PORTSC_RESUME_FLAG       (1 << 6)
+#define USB_PORTSC_OC_CHANGE_FLAG    (1 << 5)
+#define USB_PORTSC_OC_ACTIVE_FLAG    (1 << 4)
+#define USB_PORTSC_EN_CHANGE_FLAG    (1 << 3)
+#define USB_PORTSC_ENABLED_FLAG      (1 << 2)
+#define USB_PORTSC_CONNECT_CH_FLAG   (1 << 1)
+#define USB_PORTSC_CONNECT_FLAG      (1 << 0)
+} ehci_regs_t;
+
+#endif
+/**
+ * @}
+ */
+
Index: uspace/drv/bus/usb/ehci/ehci_rh.c
===================================================================
--- uspace/drv/bus/usb/ehci/ehci_rh.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
+++ uspace/drv/bus/usb/ehci/ehci_rh.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -0,0 +1,476 @@
+/*
+ * Copyright (c) 2013 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 drvusbehci
+ * @{
+ */
+/** @file
+ * @brief EHCI driver
+ */
+
+#include <assert.h>
+#include <errno.h>
+#include <mem.h>
+#include <sys/types.h>
+
+#include <usb/classes/hub.h>
+#include <usb/debug.h>
+#include <usb/descriptor.h>
+#include <usb/request.h>
+#include <usb/usb.h>
+
+#include <usb/host/endpoint.h>
+#include <usbvirt/device.h>
+
+#include "ehci_rh.h"
+
+enum {
+	HUB_STATUS_CHANGE_PIPE = 1,
+};
+
+static usbvirt_device_ops_t ops;
+
+/** Initialize internal USB HUB class descriptor.
+ * @param instance EHCI root hub.
+ * Use register based info to create accurate descriptor.
+ */
+static void ehci_rh_hub_desc_init(ehci_rh_t *instance, unsigned hcs)
+{
+	assert(instance);
+	const unsigned dsize = sizeof(usb_hub_descriptor_header_t) +
+	    STATUS_BYTES(instance->port_count) * 2;
+	assert(dsize <= sizeof(instance->hub_descriptor));
+
+	instance->hub_descriptor.header.length = dsize;
+	instance->hub_descriptor.header.descriptor_type = USB_DESCTYPE_HUB;
+	instance->hub_descriptor.header.port_count = instance->port_count;
+	/* Bits 0,1 indicate power switching mode
+	 * Bit 2 indicates device type (compound device)
+	 * Bits 3,4 indicate over-current protection mode */
+	instance->hub_descriptor.header.characteristics = 0 |
+	    ((hcs & EHCI_CAPS_HCS_PPC_FLAG) ? 0x09 : 0x12) |
+	    ((hcs & EHCI_CAPS_HCS_INDICATORS_FLAG) ? 0x80 : 0) |
+	    (0x3 << 5); /* Need 32 FS bit times */ // TODO Implement
+	instance->hub_descriptor.header.characteristics_reserved = 0;
+	instance->hub_descriptor.header.power_good_time = 50;
+	/* bHubContrCurrent, root hubs don't need no power. */
+	instance->hub_descriptor.header.max_current = 0;
+
+	/* Device removable and some legacy 1.0 stuff*/
+	instance->hub_descriptor.rempow[0] = 0xff;
+	instance->hub_descriptor.rempow[1] = 0xff;
+	instance->hub_descriptor.rempow[2] = 0xff;
+	instance->hub_descriptor.rempow[3] = 0xff;
+
+}
+/** Initialize EHCI root hub.
+ * @param instance Place to initialize.
+ * @param regs EHCI device registers.
+ * @param name Device name.
+ * return Error code, EOK on success.
+ *
+ * Selects preconfigured port powering mode, sets up descriptor, and
+ * initializes internal virtual hub.
+ */
+int ehci_rh_init(ehci_rh_t *instance, ehci_caps_regs_t *caps, ehci_regs_t *regs,
+const char *name)
+{
+	assert(instance);
+	instance->registers = regs;
+	instance->port_count =
+	    (EHCI_RD(caps->hcsparams) >> EHCI_CAPS_HCS_N_PORTS_SHIFT) &
+	    EHCI_CAPS_HCS_N_PORTS_MASK;
+	usb_log_debug2("hcsparams: %x.\n", EHCI_RD(caps->hcsparams));
+	usb_log_info("%s: Found %u ports.\n", name, instance->port_count);
+
+	if (EHCI_RD(caps->hcsparams) & EHCI_CAPS_HCS_PPC_FLAG) {
+		usb_log_info("%s: No power switching.\n", name);
+	} else {
+		usb_log_info("%s: Per-port power switching.\n", name);
+	}
+
+	ehci_rh_hub_desc_init(instance, EHCI_RD(caps->hcsparams));
+	instance->unfinished_interrupt_transfer = NULL;
+	return virthub_base_init(&instance->base, name, &ops, instance,
+	    NULL, &instance->hub_descriptor.header, HUB_STATUS_CHANGE_PIPE);
+}
+
+/** Schedule USB request.
+ * @param instance OCHI root hub instance.
+ * @param batch USB requst batch to schedule.
+ * @return Always EOK.
+ * Most requests complete even before this function returns,
+ * status change requests might be postponed until there is something to report.
+ */
+int ehci_rh_schedule(ehci_rh_t *instance, usb_transfer_batch_t *batch)
+{
+	assert(instance);
+	assert(batch);
+	const usb_target_t target = {{
+		.address = batch->ep->address,
+		.endpoint = batch->ep->endpoint,
+	}};
+	batch->error = virthub_base_request(&instance->base, target,
+	    usb_transfer_batch_direction(batch), (void*)batch->setup_buffer,
+	    batch->buffer, batch->buffer_size, &batch->transfered_size);
+	if (batch->error == ENAK) {
+		/* This is safe because only status change interrupt transfers
+		 * return NAK. The assertion holds true because the batch
+		 * existence prevents communication with that ep */
+		assert(instance->unfinished_interrupt_transfer == NULL);
+		instance->unfinished_interrupt_transfer = batch;
+	} else {
+		usb_transfer_batch_finish(batch, NULL);
+		usb_transfer_batch_destroy(batch);
+	}
+	return EOK;
+}
+
+/** Handle EHCI RHSC interrupt.
+ * @param instance EHCI root hub isntance.
+ * @return Always EOK.
+ *
+ * Interrupt means there is a change of status to report. It may trigger
+ * processing of a postponed request.
+ */
+int ehci_rh_interrupt(ehci_rh_t *instance)
+{
+	//TODO atomic swap needed
+	usb_transfer_batch_t *batch = instance->unfinished_interrupt_transfer;
+	instance->unfinished_interrupt_transfer = NULL;
+	if (batch) {
+		const usb_target_t target = {{
+			.address = batch->ep->address,
+			.endpoint = batch->ep->endpoint,
+		}};
+		batch->error = virthub_base_request(&instance->base, target,
+		    usb_transfer_batch_direction(batch),
+		    (void*)batch->setup_buffer,
+		    batch->buffer, batch->buffer_size, &batch->transfered_size);
+		usb_transfer_batch_finish(batch, NULL);
+		usb_transfer_batch_destroy(batch);
+	}
+	return EOK;
+}
+
+/* HUB ROUTINES IMPLEMENTATION */
+#define TEST_SIZE_INIT(size, port, hub) \
+do { \
+	hub = virthub_get_data(device); \
+	assert(hub);\
+	if (uint16_usb2host(setup_packet->length) != size) \
+		return ESTALL; \
+	port = uint16_usb2host(setup_packet->index) - 1; \
+	if (port > hub->port_count) \
+		return EINVAL; \
+} while (0)
+
+/** Hub status request handler.
+ * @param device Virtual hub device
+ * @param setup_packet USB setup stage data.
+ * @param[out] data destination data buffer, size must be at least
+ *             setup_packet->length bytes
+ * @param[out] act_size Sized of the valid response part of the buffer.
+ * @return Error code.
+ */
+static int req_get_status(usbvirt_device_t *device,
+    const usb_device_request_setup_packet_t *setup_packet,
+    uint8_t *data, size_t *act_size)
+{
+	ehci_rh_t *hub = virthub_get_data(device);
+	assert(hub);
+	if (uint16_usb2host(setup_packet->length) != 4)
+		return ESTALL;
+	const uint32_t val = 0;
+	//TODO: implement
+	memcpy(data, &val, sizeof(val));
+	*act_size = sizeof(val);
+	return EOK;
+}
+
+/** Hub set feature request handler.
+ * @param device Virtual hub device
+ * @param setup_packet USB setup stage data.
+ * @param[out] data destination data buffer, size must be at least
+ *             setup_packet->length bytes
+ * @param[out] act_size Sized of the valid response part of the buffer.
+ * @return Error code.
+ */
+static int req_clear_hub_feature(usbvirt_device_t *device,
+    const usb_device_request_setup_packet_t *setup_packet,
+    uint8_t *data, size_t *act_size)
+{
+	ehci_rh_t *hub = virthub_get_data(device);
+	assert(hub);
+
+	/*
+	 * Chapter 11.16.2 specifies that only C_HUB_LOCAL_POWER and
+	 * C_HUB_OVER_CURRENT are supported.
+	 * C_HUB_LOCAL_POWER is not supported
+	 * because root hubs do not support local power status feature.
+	 * C_HUB_OVER_CURRENT is represented by EHCI RHS_OCIC_FLAG.
+	 * (EHCI pg. 127)
+	 */
+	const unsigned feature = uint16_usb2host(setup_packet->value);
+	if (feature == USB_HUB_FEATURE_C_HUB_OVER_CURRENT) {
+		//TODO: Implement
+//		EHCI_WR(hub->registers->rh_status, RHS_OCIC_FLAG);
+	}
+	return EOK;
+}
+
+/** Port status request handler.
+ * @param device Virtual hub device
+ * @param setup_packet USB setup stage data.
+ * @param[out] data destination data buffer, size must be at least
+ *             setup_packet->length bytes
+ * @param[out] act_size Sized of the valid response part of the buffer.
+ * @return Error code.
+ */
+static int req_get_port_status(usbvirt_device_t *device,
+    const usb_device_request_setup_packet_t *setup_packet,
+    uint8_t *data, size_t *act_size)
+{
+	ehci_rh_t *hub;
+	unsigned port;
+	TEST_SIZE_INIT(4, port, hub);
+	if (setup_packet->value != 0)
+		return EINVAL;
+
+	const uint32_t status = 0;
+	// TODO: Implement
+	//EHCI_RD(hub->registers->rh_port_status[port]);
+	memcpy(data, &status, sizeof(status));
+	*act_size = sizeof(status);
+	return EOK;
+}
+
+/** Port clear feature request handler.
+ * @param device Virtual hub device
+ * @param setup_packet USB setup stage data.
+ * @param[out] data destination data buffer, size must be at least
+ *             setup_packet->length bytes
+ * @param[out] act_size Sized of the valid response part of the buffer.
+ * @return Error code.
+ */
+static int req_clear_port_feature(usbvirt_device_t *device,
+    const usb_device_request_setup_packet_t *setup_packet,
+    uint8_t *data, size_t *act_size)
+{
+	ehci_rh_t *hub;
+	unsigned port;
+	TEST_SIZE_INIT(0, port, hub);
+	const unsigned feature = uint16_usb2host(setup_packet->value);
+	/* Enabled features to clear: see page 269 of USB specs */
+	switch (feature)
+	{
+	case USB_HUB_FEATURE_PORT_POWER:          /*8*/
+		{
+//			EHCI_WR(hub->registers->rh_port_status[port],
+//			    RHPS_CLEAR_PORT_POWER);
+//			    TODO: Implement
+			return EOK;
+		}
+
+	case USB_HUB_FEATURE_PORT_ENABLE:         /*1*/
+//		EHCI_WR(hub->registers->rh_port_status[port],
+//		    RHPS_CLEAR_PORT_ENABLE);
+		return EOK;
+
+	case USB_HUB_FEATURE_PORT_SUSPEND:        /*2*/
+//		EHCI_WR(hub->registers->rh_port_status[port],
+//		    RHPS_CLEAR_PORT_SUSPEND);
+		return EOK;
+
+	case USB_HUB_FEATURE_C_PORT_CONNECTION:   /*16*/
+	case USB_HUB_FEATURE_C_PORT_ENABLE:       /*17*/
+	case USB_HUB_FEATURE_C_PORT_SUSPEND:      /*18*/
+	case USB_HUB_FEATURE_C_PORT_OVER_CURRENT: /*19*/
+	case USB_HUB_FEATURE_C_PORT_RESET:        /*20*/
+		usb_log_debug2("Clearing port C_CONNECTION, C_ENABLE, "
+		    "C_SUSPEND, C_OC or C_RESET on port %"PRIu16".\n", port);
+		/* Bit offsets correspond to the feature number */
+//		EHCI_WR(hub->registers->rh_port_status[port],
+//		    1 << feature);
+		return EOK;
+
+	default:
+		return ENOTSUP;
+	}
+}
+
+/** Port set feature request handler.
+ * @param device Virtual hub device
+ * @param setup_packet USB setup stage data.
+ * @param[out] data destination data buffer, size must be at least
+ *             setup_packet->length bytes
+ * @param[out] act_size Sized of the valid response part of the buffer.
+ * @return Error code.
+ */
+static int req_set_port_feature(usbvirt_device_t *device,
+    const usb_device_request_setup_packet_t *setup_packet,
+    uint8_t *data, size_t *act_size)
+{
+	ehci_rh_t *hub;
+	unsigned port;
+	TEST_SIZE_INIT(0, port, hub);
+	const unsigned feature = uint16_usb2host(setup_packet->value);
+	switch (feature) {
+	case USB_HUB_FEATURE_PORT_POWER:   /*8*/
+	{
+		/* No power switching */
+//		if (rhda & RHDA_NPS_FLAG)
+			return EOK;
+		/* Ganged power switching, one port powers all */
+//		if (!(rhda & RHDA_PSM_FLAG)) {
+//			EHCI_WR(hub->registers->rh_status,RHS_SET_GLOBAL_POWER);
+//			return EOK;
+//		}
+	}
+	/* Fall through, for per port power */
+	case USB_HUB_FEATURE_PORT_ENABLE:  /*1*/
+	case USB_HUB_FEATURE_PORT_SUSPEND: /*2*/
+	case USB_HUB_FEATURE_PORT_RESET:   /*4*/
+		usb_log_debug2("Setting port POWER, ENABLE, SUSPEND or RESET "
+		    "on port %"PRIu16".\n", port);
+		/* Bit offsets correspond to the feature number */
+//		EHCI_WR(hub->registers->rh_port_status[port], 1 << feature);
+		return EOK;
+	default:
+		return ENOTSUP;
+	}
+}
+
+/** Status change handler.
+ * @param device Virtual hub device
+ * @param endpoint Endpoint number
+ * @param tr_type Transfer type
+ * @param buffer Response destination
+ * @param buffer_size Bytes available in buffer
+ * @param actual_size Size us the used part of the dest buffer.
+ *
+ * Produces status mask. Bit 0 indicates hub status change the other bits
+ * represent port status change. Endian does not matter as UHCI root hubs
+ * only need 1 byte.
+ */
+static int req_status_change_handler(usbvirt_device_t *device,
+    usb_endpoint_t endpoint, usb_transfer_type_t tr_type,
+    void *buffer, size_t buffer_size, size_t *actual_size)
+{
+	ehci_rh_t *hub = virthub_get_data(device);
+	assert(hub);
+
+	if (buffer_size < STATUS_BYTES(hub->port_count))
+		return ESTALL;
+
+	uint16_t mask = 0;
+
+	/* Only local power source change and over-current change can happen */
+//	if (EHCI_RD(hub->registers->rh_status) & (RHS_LPSC_FLAG | RHS_OCIC_FLAG)) {
+//		mask |= 1;
+//	}
+
+	for (unsigned port = 1; port <= hub->port_count; ++port) {
+		/* Write-clean bits are those that indicate change */
+//		if (EHCI_RD(hub->registers->rh_port_status[port - 1])
+//		    & RHPS_CHANGE_WC_MASK) {
+//			mask |= (1 << port);
+//		}
+	}
+
+	usb_log_debug2("EHCI root hub interrupt mask: %hx.\n", mask);
+
+	if (mask == 0)
+		return ENAK;
+	mask = uint16_host2usb(mask);
+	memcpy(buffer, &mask, STATUS_BYTES(hub->port_count));
+	*actual_size = STATUS_BYTES(hub->port_count);
+	return EOK;
+}
+
+/** EHCI root hub request handlers */
+static const usbvirt_control_request_handler_t control_transfer_handlers[] = {
+	{
+		STD_REQ_IN(USB_REQUEST_RECIPIENT_DEVICE, USB_DEVREQ_GET_DESCRIPTOR),
+		.name = "GetDescriptor",
+		.callback = virthub_base_get_hub_descriptor,
+	},
+	{
+		CLASS_REQ_IN(USB_REQUEST_RECIPIENT_DEVICE, USB_DEVREQ_GET_DESCRIPTOR),
+		.name = "GetDescriptor",
+		.callback = virthub_base_get_hub_descriptor,
+	},
+	{
+		CLASS_REQ_IN(USB_REQUEST_RECIPIENT_DEVICE, USB_HUB_REQUEST_GET_DESCRIPTOR),
+		.name = "GetHubDescriptor",
+		.callback = virthub_base_get_hub_descriptor,
+	},
+	{
+		CLASS_REQ_IN(USB_REQUEST_RECIPIENT_OTHER, USB_HUB_REQUEST_GET_STATUS),
+		.name = "GetPortStatus",
+		.callback = req_get_port_status,
+	},
+	{
+		CLASS_REQ_OUT(USB_REQUEST_RECIPIENT_DEVICE, USB_HUB_REQUEST_CLEAR_FEATURE),
+		.name = "ClearHubFeature",
+		.callback = req_clear_hub_feature,
+	},
+	{
+		CLASS_REQ_OUT(USB_REQUEST_RECIPIENT_OTHER, USB_HUB_REQUEST_CLEAR_FEATURE),
+		.name = "ClearPortFeature",
+		.callback = req_clear_port_feature,
+	},
+	{
+		CLASS_REQ_IN(USB_REQUEST_RECIPIENT_DEVICE, USB_HUB_REQUEST_GET_STATUS),
+		.name = "GetHubStatus",
+		.callback = req_get_status,
+	},
+	{
+		CLASS_REQ_IN(USB_REQUEST_RECIPIENT_OTHER, USB_HUB_REQUEST_GET_STATUS),
+		.name = "GetPortStatus",
+		.callback = req_get_port_status,
+	},
+	{
+		CLASS_REQ_OUT(USB_REQUEST_RECIPIENT_DEVICE, USB_HUB_REQUEST_SET_FEATURE),
+		.name = "SetHubFeature",
+		.callback = req_nop,
+	},
+	{
+		CLASS_REQ_OUT(USB_REQUEST_RECIPIENT_OTHER, USB_HUB_REQUEST_SET_FEATURE),
+		.name = "SetPortFeature",
+		.callback = req_set_port_feature,
+	},
+	{
+		.callback = NULL
+	}
+};
+
+/** Virtual EHCI root hub ops */
+static usbvirt_device_ops_t ops = {
+        .control = control_transfer_handlers,
+        .data_in[HUB_STATUS_CHANGE_PIPE] = req_status_change_handler,
+};
Index: uspace/drv/bus/usb/ehci/ehci_rh.h
===================================================================
--- uspace/drv/bus/usb/ehci/ehci_rh.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
+++ uspace/drv/bus/usb/ehci/ehci_rh.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2013 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 drvusbehci
+ * @{
+ */
+/** @file
+ * @brief EHCI driver
+ */
+#ifndef DRV_EHCI_EHCI_RH_H
+#define DRV_EHCI_EHCI_RH_H
+
+#include <assert.h>
+#include <sys/types.h>
+
+#include <usb/usb.h>
+#include <usb/classes/hub.h>
+#include <usb/host/usb_transfer_batch.h>
+#include <usbvirt/virthub_base.h>
+
+#include "ehci_regs.h"
+
+enum {
+	EHCI_MAX_PORTS = 15,
+};
+
+typedef struct {
+	/** Virtual hub instance */
+	virthub_base_t base;
+	/** EHCI device registers */
+	ehci_regs_t *registers;
+	/** Number of downstream ports, EHCI limits this to 15 */
+	unsigned port_count;
+	/** USB hub descriptor describing the EHCI root hub */
+	struct {
+		usb_hub_descriptor_header_t header;
+		uint8_t rempow[STATUS_BYTES(EHCI_MAX_PORTS) * 2];
+	} __attribute__((packed)) hub_descriptor;
+	/** interrupt transfer waiting for an actual interrupt to occur */
+	usb_transfer_batch_t *unfinished_interrupt_transfer;
+} ehci_rh_t;
+
+int ehci_rh_init(ehci_rh_t *instance, ehci_caps_regs_t *caps, ehci_regs_t *regs,
+    const char *name);
+int ehci_rh_schedule(ehci_rh_t *instance, usb_transfer_batch_t *batch);
+int ehci_rh_interrupt(ehci_rh_t *instance);
+
+/** Get EHCI rh address.
+ *
+ * @param instance UHCI rh instance.
+ * @return USB address assigned to the hub.
+ * Wrapper for virtual hub address
+ */
+static inline usb_address_t ehci_rh_get_address(ehci_rh_t *instance)
+{
+	assert(instance);
+	return virthub_base_get_address(&instance->base);
+}
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/bus/usb/ehci/hc.c
===================================================================
--- uspace/drv/bus/usb/ehci/hc.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
+++ uspace/drv/bus/usb/ehci/hc.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -0,0 +1,279 @@
+/*
+ * 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 drvusbehcihc
+ * @{
+ */
+/** @file
+ * @brief EHCI Host controller driver routines
+ */
+
+#include <assert.h>
+#include <async.h>
+#include <errno.h>
+#include <macros.h>
+#include <mem.h>
+#include <stdlib.h>
+#include <str_error.h>
+#include <sys/types.h>
+
+#include <usb/debug.h>
+#include <usb/usb.h>
+
+//#include "ehci_endpoint.h"
+//#include "ehci_batch.h"
+#include "utils/malloc32.h"
+
+#include "hc.h"
+
+#define EHCI_USED_INTERRUPTS \
+    (USB_INTR_IRQ_FLAG | USB_INTR_ERR_IRQ_FLAG | USB_INTR_PORT_CHANGE_FLAG)
+
+static const irq_pio_range_t ehci_pio_ranges[] = {
+	{
+		.base = 0,
+		.size = sizeof(ehci_regs_t)
+	}
+};
+
+static const irq_cmd_t ehci_irq_commands[] = {
+	{
+		.cmd = CMD_PIO_READ_32,
+		.dstarg = 1,
+		.addr = NULL
+	},
+	{
+		.cmd = CMD_AND,
+		.srcarg = 1,
+		.dstarg = 2,
+		.value = 0
+	},
+	{
+		.cmd = CMD_PREDICATE,
+		.srcarg = 2,
+		.value = 2
+	},
+	{
+		.cmd = CMD_PIO_WRITE_A_32,
+		.srcarg = 1,
+		.addr = NULL
+	},
+	{
+		.cmd = CMD_ACCEPT
+	}
+};
+
+static void hc_gain_control(hc_t *instance);
+static void hc_start(hc_t *instance);
+static int hc_init_memory(hc_t *instance);
+static int interrupt_emulator(hc_t *instance);
+
+/** Generate IRQ code.
+ * @param[out] ranges PIO ranges buffer.
+ * @param[in] ranges_size Size of the ranges buffer (bytes).
+ * @param[out] cmds Commands buffer.
+ * @param[in] cmds_size Size of the commands buffer (bytes).
+ * @param[in] regs Device's register range.
+ *
+ * @return Error code.
+ */
+int hc_gen_irq_code(irq_code_t *code, addr_range_t *regs)
+{
+	assert(code);
+	if (RNGSZ(*regs) < sizeof(ehci_regs_t))
+		return EOVERFLOW;
+
+	code->ranges = malloc(sizeof(ehci_pio_ranges));
+	if (code->ranges == NULL)
+		return ENOMEM;
+
+	code->cmds = malloc(sizeof(ehci_irq_commands));
+	if (code->cmds == NULL) {
+		free(code->ranges);
+		return ENOMEM;
+	}
+
+	code->rangecount = ARRAY_SIZE(ehci_pio_ranges);
+	code->cmdcount = ARRAY_SIZE(ehci_irq_commands);
+
+	memcpy(code->ranges, ehci_pio_ranges, sizeof(ehci_pio_ranges));
+	code->ranges[0].base = RNGABS(*regs);
+
+	memcpy(code->cmds, ehci_irq_commands, sizeof(ehci_irq_commands));
+	ehci_caps_regs_t *caps = NULL;
+	int ret = pio_enable_range(regs, (void**)&caps);
+	if (ret != EOK) {
+		return ret;
+	}
+	ehci_regs_t *registers =
+	    (ehci_regs_t *)(RNGABSPTR(*regs) + EHCI_RD8(caps->caplength));
+	code->cmds[0].addr = (void *) &registers->usbsts;
+	code->cmds[3].addr = (void *) &registers->usbsts;
+	EHCI_WR(code->cmds[1].value, EHCI_USED_INTERRUPTS);
+
+	return EOK;
+}
+
+/** Initialize EHCI hc driver structure
+ *
+ * @param[in] instance Memory place for the structure.
+ * @param[in] regs Device's I/O registers range.
+ * @param[in] interrupts True if w interrupts should be used
+ * @return Error code
+ */
+int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts)
+{
+	assert(instance);
+
+	int ret = pio_enable_range(regs, (void **) &instance->caps);
+	if (ret != EOK) {
+		usb_log_error("Failed to gain access to device registers: %s.\n",
+		    str_error(ret));
+		return ret;
+	}
+	instance->registers =
+	    (void*)instance->caps + EHCI_RD8(instance->caps->caplength);
+
+	list_initialize(&instance->pending_batches);
+	fibril_mutex_initialize(&instance->guard);
+
+	ret = hc_init_memory(instance);
+	if (ret != EOK) {
+		usb_log_error("Failed to create EHCI memory structures: %s.\n",
+		    str_error(ret));
+		return ret;
+	}
+
+	hc_gain_control(instance);
+
+	if (!interrupts) {
+		instance->interrupt_emulator =
+		    fibril_create((int(*)(void*))interrupt_emulator, instance);
+		fibril_add_ready(instance->interrupt_emulator);
+	}
+
+	ehci_rh_init(
+	    &instance->rh, instance->caps, instance->registers, "ehci rh");
+	hc_start(instance);
+
+	return EOK;
+}
+
+void hc_enqueue_endpoint(hc_t *instance, const endpoint_t *ep)
+{
+}
+
+void hc_dequeue_endpoint(hc_t *instance, const endpoint_t *ep)
+{
+}
+
+/** Add USB transfer to the schedule.
+ *
+ * @param[in] instance EHCI hc driver structure.
+ * @param[in] batch Batch representing the transfer.
+ * @return Error code.
+ */
+int hc_schedule(hcd_t *hcd, usb_transfer_batch_t *batch)
+{
+	assert(hcd);
+	hc_t *instance = hcd->driver.data;
+	assert(instance);
+
+	/* Check for root hub communication */
+	if (batch->ep->address == ehci_rh_get_address(&instance->rh)) {
+		usb_log_debug("EHCI root hub request.\n");
+		return ehci_rh_schedule(&instance->rh, batch);
+	}
+	return ENOTSUP;
+}
+
+/** Interrupt handling routine
+ *
+ * @param[in] instance EHCI hc driver structure.
+ * @param[in] status Value of the status register at the time of interrupt.
+ */
+void hc_interrupt(hc_t *instance, uint32_t status)
+{
+	status = EHCI_RD(status);
+	assert(instance);
+	if (status & USB_STS_PORT_CHANGE_FLAG) {
+		ehci_rh_interrupt(&instance->rh);
+	}
+}
+
+/** Check status register regularly
+ *
+ * @param[in] instance EHCI hc driver structure.
+ * @return Error code
+ */
+int interrupt_emulator(hc_t *instance)
+{
+	assert(instance);
+	usb_log_info("Started interrupt emulator.\n");
+	while (1) {
+//		const uint32_t status = instance->registers->interrupt_status;
+//		instance->registers->interrupt_status = status;
+//		hc_interrupt(instance, status);
+		async_usleep(10000);
+	}
+	return EOK;
+}
+
+/** Turn off any (BIOS)driver that might be in control of the device.
+ *
+ * This function implements routines described in chapter 5.1.1.3 of the EHCI
+ * specification (page 40, pdf page 54).
+ *
+ * @param[in] instance EHCI hc driver structure.
+ */
+void hc_gain_control(hc_t *instance)
+{
+	assert(instance);
+}
+
+/** EHCI hw initialization routine.
+ *
+ * @param[in] instance EHCI hc driver structure.
+ */
+void hc_start(hc_t *instance)
+{
+}
+
+/** Initialize memory structures used by the EHCI hcd.
+ *
+ * @param[in] instance EHCI hc driver structure.
+ * @return Error code.
+ */
+int hc_init_memory(hc_t *instance)
+{
+	return EOK;
+}
+
+/**
+ * @}
+ */
Index: uspace/drv/bus/usb/ehci/hc.h
===================================================================
--- uspace/drv/bus/usb/ehci/hc.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
+++ uspace/drv/bus/usb/ehci/hc.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -0,0 +1,94 @@
+/*
+ * 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 drvusbehci
+ * @{
+ */
+/** @file
+ * @brief EHCI host controller driver structure
+ */
+#ifndef DRV_EHCI_HC_H
+#define DRV_EHCI_HC_H
+
+#include <adt/list.h>
+#include <ddi.h>
+#include <ddf/driver.h>
+#include <device/hw_res_parsed.h>
+#include <fibril.h>
+#include <fibril_synch.h>
+#include <stdbool.h>
+#include <sys/types.h>
+
+#include <usb/host/hcd.h>
+#include <usb/host/endpoint.h>
+#include <usb/host/usb_transfer_batch.h>
+
+#include "ehci_regs.h"
+#include "ehci_rh.h"
+//#include "endpoint_list.h"
+
+/** Main EHCI driver structure */
+typedef struct hc {
+	/** Memory mapped CAPS register area */
+	ehci_caps_regs_t *caps;
+	/** Memory mapped I/O registers area */
+	ehci_regs_t *registers;
+
+	/** Transfer schedules */
+//	endpoint_list_t lists[4];
+	/** List of active transfers */
+	list_t pending_batches;
+
+	/** Fibril for periodic checks if interrupts can't be used */
+	fid_t interrupt_emulator;
+
+	/** Guards schedule and endpoint manipulation */
+	fibril_mutex_t guard;
+
+	/** USB hub emulation structure */
+	ehci_rh_t rh;
+} hc_t;
+
+int hc_gen_irq_code(irq_code_t *code, addr_range_t *regs);
+int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun);
+int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts);
+
+/** Safely dispose host controller internal structures
+ *
+ * @param[in] instance Host controller structure to use.
+ */
+static inline void hc_fini(hc_t *instance) { /* TODO: implement*/ };
+
+void hc_enqueue_endpoint(hc_t *instance, const endpoint_t *ep);
+void hc_dequeue_endpoint(hc_t *instance, const endpoint_t *ep);
+int hc_schedule(hcd_t *hcd, usb_transfer_batch_t *batch);
+
+void hc_interrupt(hc_t *instance, uint32_t status);
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/bus/usb/ehci/hw_struct/fstn.h
===================================================================
--- uspace/drv/bus/usb/ehci/hw_struct/fstn.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
+++ uspace/drv/bus/usb/ehci/hw_struct/fstn.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2013 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 drvusbehci
+ * @{
+ */
+/** @file
+ * @brief EHCI driver
+ */
+#ifndef DRV_EHCI_HW_STRUCT_FSTN_H
+#define DRV_EHCI_HW_STRUCT_FSTN_H
+
+#include "link_pointer.h"
+
+typedef struct fstn {
+	link_pointer_t normal_path;
+	link_pointer_t back_path;
+} fstn_t;
+
+#endif
+/**
+ * @}
+ */
+
Index: uspace/drv/bus/usb/ehci/hw_struct/iso_transfer_descriptor.h
===================================================================
--- uspace/drv/bus/usb/ehci/hw_struct/iso_transfer_descriptor.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
+++ uspace/drv/bus/usb/ehci/hw_struct/iso_transfer_descriptor.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013 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 drvusbehci
+ * @{
+ */
+/** @file
+ * @brief EHCI driver
+ */
+#ifndef DRV_EHCI_HW_STRUCT_ISO_TRANSFER_DESCRIPTOR_H
+#define DRV_EHCI_HW_STRUCT_ISO_TRANSFER_DESCRIPTOR_H
+
+#include <sys/types.h>
+#include "link_pointer.h"
+
+/** Isochronous transfer descriptor (HS only) */
+typedef struct itd {
+	link_pointer_t next;
+
+	volatile uint32_t transaction[8];
+#define ITD_TRANSACTION_STATUS_ACTIVE_FLAG  (1 << 31)
+#define ITD_TRANSACTION_STATUS_BUFFER_ERROR_FLAG  (1 << 30)
+#define ITD_TRANSACTION_STATUS_BABBLE_FLAG   (1 << 29)
+#define ITD_TRANSACTION_STATUS_TRANS_ERROR_FLAG  (1 << 28)
+#define ITD_TRANSACTION_LENGHT_MASK    0xfff
+#define ITD_TRANSACTION_LENGHT_SHIFT   16
+#define ITD_TRANSACTION_IOC_FLAG       (1 << 15)
+#define ITD_TRANSACTION_PG_MASK        0x3
+#define ITD_TRANSACTION_PG_SHIFT       12
+#define ITD_TRANSACTION_OFFSET_MASK    0xfff
+#define ITD_TRANSACTION_OFFSET_SHIFT   0
+
+	volatile uint32_t buffer_pointer[7]
+#define ITD_BUFFER_POINTER_MASK      0xfffff000
+/* First buffer pointer */
+#define ITD_BUFFER_POINTER_EP_MASK      0xf
+#define ITD_BUFFER_POINTER_EP_SHIFT     8
+#define ITD_BUFFER_POINTER_ADDR_MASK    0x3f
+#define ITD_BUFFER_POINTER_ADDR_SHIFT   0
+/* Second buffer pointer */
+#define ITD_BUFFER_POINTER_IN_FLAG            (1 << 11)
+#define ITD_BUFFER_POINTER_MAX_PACKET_MASK    0x3ff
+#define ITD_BUFFER_POINTER_MAX_PACKET_SHIFT   0
+/* Third buffer pointer */
+#define ITD_BUFFER_POINTER_MULTI_MASK    0x3
+#define ITD_BUFFER_POINTER_MULTI_SHIFT   0
+
+} itd_t;
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/bus/usb/ehci/hw_struct/link_pointer.h
===================================================================
--- uspace/drv/bus/usb/ehci/hw_struct/link_pointer.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
+++ uspace/drv/bus/usb/ehci/hw_struct/link_pointer.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2013 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 drvusbehci
+ * @{
+ */
+/** @file
+ * @brief EHCI driver
+ */
+#ifndef DRV_EHCI_HW_STRUCT_LINK_POINTER_H
+#define DRV_EHCI_HW_STRUCT_LINK_POINTER_H
+
+#include <sys/types.h>
+
+/** EHCI link pointer, used by many data structures */
+typedef volatile uint32_t link_pointer_t;
+
+#define LINK_POINTER_ADDRESS_MASK   0xfffffff0 /* upper 28 bits */
+
+#define LINK_POINTER_TERMINATE_FLAG   (1 << 0)
+
+enum {
+	LINK_POINTER_TYPE_iTD  = 0x0 << 1,
+	LINK_POINTER_TYPE_QH   = 0x1 << 1,
+	LINK_POINTER_TYPE_siTD = 0x2 << 1,
+	LINK_POINTER_TYPE_FSTN = 0x3 << 1,
+	LINK_POINTER_TYPE_MASK = 0x3 << 1,
+};
+
+#define LINK_POINTER_QH(address) \
+	((address & LINK_POINTER_ADDRESS_MASK) | LINK_POINTER_TYPE_QH)
+
+#define LINK_POINTER_TD(address) \
+	(address & LINK_POINTER_ADDRESS_MASK)
+
+#define LINK_POINTER_TERM \
+	((link_pointer_t)LINK_POINTER_TERMINATE_FLAG)
+
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/bus/usb/ehci/hw_struct/mem_access.h
===================================================================
--- uspace/drv/bus/usb/ehci/hw_struct/mem_access.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
+++ uspace/drv/bus/usb/ehci/hw_struct/mem_access.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2013 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_EHCI_HW_MEM_ACCESS_H
+#define DRV_EHCI_HW_MEM_ACCESS_H
+
+#include <byteorder.h>
+
+#define EHCI_MEM32_WR(reg, val) reg = host2uint32_t_le(val)
+#define EHCI_MEM32_RD(reg) uint32_t_le2host(reg)
+#define EHCI_MEM32_SET(reg, val) reg |= host2uint32_t_le(val)
+#define EHCI_MEM32_CLR(reg, val) reg &= host2uint32_t_le(~val)
+
+#endif
+
+/*
+ * @}
+ */
+
Index: uspace/drv/bus/usb/ehci/hw_struct/queue_head.h
===================================================================
--- uspace/drv/bus/usb/ehci/hw_struct/queue_head.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
+++ uspace/drv/bus/usb/ehci/hw_struct/queue_head.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2013 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 drvusbehci
+ * @{
+ */
+/** @file
+ * @brief EHCI driver
+ */
+#ifndef DRV_EHCI_HW_STRUCT_QH_H
+#define DRV_EHCI_HW_STRUCT_QH_H
+
+#include <assert.h>
+#include <sys/types.h>
+
+#include "link_pointer.h"
+
+/** This structure is defined in EHCI design guide p. 46 */
+typedef struct queue_head {
+	link_pointer_t horizontal;
+
+	volatile uint32_t ep_char;
+#define QH_EP_CHAR_RL_MASK    0xf
+#define QH_EP_CHAR_RL_SHIFT   28
+#define QH_EP_CHAR_C_FLAG     (1 << 27)
+#define QH_EP_CHAR_LENGTH_MASK   0x7ff
+#define QH_EP_CHAR_LENGTH_SHIFT  16
+#define QH_EP_CHAR_H_FLAG     (1 << 15)
+#define QH_EP_CHAR_DTC_FLAG   (1 << 14)
+#define QH_EP_CHAR_EPS_MASK   0x3
+#define QH_EP_CHAR_EPS_SHIFT  12
+#define QH_EP_CHAR_EPS_FS     0x0
+#define QH_EP_CHAR_EPS_LS     0x1
+#define QH_EP_CHAR_EPS_HS     0x2
+#define QH_EP_CHAR_EP_MASK    0xf
+#define QH_EP_CHAR_EP_SHIFT   8
+#define QH_EP_CHAR_INACT_FLAG (1 << 7)
+#define QH_EP_CHAR_ADDR_MASK  0x3f
+#define QH_EP_CHAR_ADDR_SHIFT 0
+
+	volatile uint32_t ep_cap;
+#define QH_EP_CAP_MULTI_MASK   0x3
+#define QH_EP_CAP_MULTI_SHIFT  30
+#define QH_EP_CAP_PORT_MASK    0x7f
+#define QH_EP_CAP_PORT_SHIFT   23
+#define QH_EP_CAP_HUB_MASK     0x7f
+#define QH_EP_CAP_HUB_SHIFT    16
+#define QH_EP_CAP_C_MASK_MASK  0xff
+#define QH_EP_CAP_C_MASK_SHIFT 8
+#define QH_EP_CAP_S_MASK_MASK  0xff
+#define QH_EP_CAP_S_MASL_SHIFT 0
+
+	link_pointer_t current;
+/* Transfer overlay starts here */
+	link_pointer_t next;
+	link_pointer_t alternate;
+#define QH_ALTERNATE_NACK_CNT_MASK   0x7
+#define QH_ALTERNATE_NACK_CNT_SHIFT  1
+
+	volatile uint32_t status;
+#define QH_STATUS_TOGGLE_FLAG   (1 << 31)
+#define QH_STATUS_TOTAL_MASK    0x7fff
+#define QH_STATUS_TOTAL_SHIFT   16
+#define QH_STATUS_IOC_FLAG      (1 << 15)
+#define QH_STATUS_C_PAGE_MASK   0x7
+#define QH_STATUS_C_PAGE_SHIFT  12
+#define QH_STATUS_CERR_MASK     0x3
+#define QH_STATUS_CERR_SHIFT    10
+#define QH_STATUS_PID_MASK      0x3
+#define QH_STATUS_PID_SHIFT     8
+#define QH_STATUS_ACTIVE_FLAG   (1 << 7)
+#define QH_STATUS_HALTED_FLAG   (1 << 6)
+#define QH_STATUS_BUFF_ERROR_FLAG  (1 << 5)
+#define QH_STATUS_BABBLE_FLAG   (1 << 4)
+#define QH_STATUS_TRANS_ERR_FLAG   (1 << 3)
+#define QH_STATUS_MISSED_FLAG   (1 << 2)
+#define QH_STATUS_SPLIT_FLAG    (1 << 1)
+#define QH_STATUS_PING_FLAG     (1 << 0)
+
+	volatile uint32_t buffer_pointer[5];
+#define QH_BUFFER_POINTER_MASK   0xfffff000
+/* Only the first buffer pointer */
+#define QH_BUFFER_POINTER_OFFSET_MASK   0xfff
+#define QH_BUFFER_POINTER_OFFSET_SHIFT  0
+/* Only the second buffer pointer */
+#define QH_BUFFER_POINTER_C_MASK_MASK   0xff
+#define QH_BUFFER_POINTER_C_MASK_SHIFFT 0
+/* Only the third buffer pointer */
+#define QH_BUFFER_POINTER_S_MASK      0x7f
+#define QH_BUFFER_POINTER_S_SHIFT     5
+#define QH_BUFFER_POINTER_FTAG_MASK   0x1f
+#define QH_BUFFER_POINTER_FTAG_SHIFT  0
+
+} qh_t;
+
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/bus/usb/ehci/hw_struct/split_iso_transfer_descriptor.h
===================================================================
--- uspace/drv/bus/usb/ehci/hw_struct/split_iso_transfer_descriptor.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
+++ uspace/drv/bus/usb/ehci/hw_struct/split_iso_transfer_descriptor.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2013 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 drvusbehci
+ * @{
+ */
+/** @file
+ * @brief EHCI driver
+ */
+#ifndef DRV_EHCI_HW_STRUCT_SPLIT_ISO_TRANSFER_DESCRIPTOR_H
+#define DRV_EHCI_HW_STRUCT_SPLIT_ISO_TRANSFER_DESCRIPTOR_H
+
+#include <sys/types.h>
+#include "link_pointer.h"
+
+/** Isochronous transfer descriptor (split only) */
+typedef struct sitd {
+	link_pointer_t next;
+
+	volatile uint32_t ep;
+#define SITD_EP_IN_FLAG         (1 << 31)
+#define SITD_EP_PORT_MASK       0x3f
+#define SITD_EP_PORT_SHIFT      24
+#define SITD_EP_HUB_ADDR_MASK   0x3f
+#define SITD_EP_HUB_ADDR_SHIFT  16
+#define SITD_EP_EP_MASK         0xf
+#define SITD_EP_EP_SHIFT        8
+#define SITD_EP_ADDR_MASK       0x3f
+#define SITD_EP_ADDR_SHIFT      0
+
+	volatile uint32_t uframe;
+#define SITD_uFRAME_CMASK_MASK    0xff
+#define SITD_uFRAME_CMASK_SHIFT   8
+#define SITD_uFRAME_SMASK_MASK    0xff
+#define SITD_uFRAME_SMASK_SHIFT   0
+
+	volatile uint32_t status;
+#define SITD_STATUS_IOC_FLAG            (1 << 31)
+#define SITD_STATUS_PAGE_FLAG           (1 << 30)
+#define SITD_STATUS_TOTAL_MASK          0x3ff
+#define SITD_STATUS_TOTAL_SHIFT         16
+#define SITD_STATUS_uFRAME_CMASK_MASK   0xff
+#define SITD_STATUS_uFRAME_CMAKS_SHIFT  8
+#define SITD_STATUS_ACTIVE_FLAG         (1 << 7)
+#define SITD_STATUS_ERR_FLAG            (1 << 6)
+#define SITD_STATUS_DATA_ERROR_FLAG     (1 << 5)
+#define SITD_STATUS_BABBLE_FLAG         (1 << 4)
+#define SITD_STATUS_TRANS_ERROR_FLAG    (1 << 3)
+#define SITD_STATUS_MISSED_uFRAME_FLAG  (1 << 2)
+#define SITD_STATUS_SPLIT_COMPLETE_FLAG (1 << 1)
+
+	volatile uint32_t buffer_pointer[2];
+#define SITD_BUFFER_POINTER_MASK   0xfffff000
+/* Only the first page pointer */
+#define SITD_BUFFER_POINTER_CURRENT_MASK    0xfff
+#define SITD_BUFFER_POINTER_CURRENT_SHIFT   0
+/* Only the second page pointer */
+#define SITD_BUFFER_POINTER_TP_MASK       0x3
+#define SITD_BUFFER_POINTER_TP_SHIFT      3
+#define SITD_BUFFER_POINTER_COUNT_MASK    0x7
+#define SITD_BUFFER_POINTER_COUNT_SHIFT   0
+
+	link_pointer_t back;
+} sitd_t;
+#endif
+/**
+ * @}
+ */
+
Index: uspace/drv/bus/usb/ehci/hw_struct/transfer_descriptor.h
===================================================================
--- uspace/drv/bus/usb/ehci/hw_struct/transfer_descriptor.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
+++ uspace/drv/bus/usb/ehci/hw_struct/transfer_descriptor.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013 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 drvusbehci
+ * @{
+ */
+/** @file
+ * @brief EHCI driver
+ */
+#ifndef DRV_EHCI_HW_STRUCT_TRANSFER_DESCRIPTOR_H
+#define DRV_EHCI_HW_STRUCT_TRANSFER_DESCRIPTOR_H
+
+#include <sys/types.h>
+#include "link_pointer.h"
+
+/** Transfer descriptor (non-ISO) */
+typedef struct td {
+	link_pointer_t next;
+	link_pointer_t alternate;
+
+	volatile uint32_t status;
+#define TD_STATUS_TOGGLE_FLAG   (1 << 31)
+#define TD_STATUS_TOTAL_MASK    0x7fff
+#define TD_STATUS_TOTAL_SHIFT   16
+#define TD_STATUS_IOC_FLAG      (1 << 15)
+#define TD_STATUS_C_PAGE_MASK   0x7
+#define TD_STATUS_C_PAGE_SHIFT  12
+#define TD_STATUS_CERR_MASK     0x3
+#define TD_STATUS_CERR_SHIFT    10
+#define TD_STATUS_PID_MASK      0x3
+#define TD_STATUS_PID_SHIFT     8
+#define TD_STATUS_PID_OUT       0x0
+#define TD_STATUS_PID_IN        0x1
+#define TD_STATUS_PID_SETUP     0x2
+#define TD_STATUS_ACTIVE_FLAG   (1 << 7)
+#define TD_STATUS_HALTED_FLAG   (1 << 6)
+#define TD_STATUS_BUFF_ERROR_FLAG  (1 << 5)
+#define TD_STATUS_BABBLE_FLAG   (1 << 4)
+#define TD_STATUS_TRANS_ERR_FLAG   (1 << 3)
+#define TD_STATUS_MISSED_FLAG   (1 << 2)
+#define TD_STATUS_SPLIT_FLAG    (1 << 1)
+#define TD_STATUS_PING_FLAG     (1 << 0)
+
+	volatile uint32_t buffer_pointer[5];
+#define SITD_BUFFER_POINTER_MASK   0xfffff000
+/* Only the first page pointer */
+#define SITD_BUFFER_POINTER_CURRENT_MASK    0xfff
+#define SITD_BUFFER_POINTER_CURRENT_SHIFT   0
+
+} td_t;
+#endif
+/**
+ * @}
+ */
+
Index: uspace/drv/bus/usb/ehci/main.c
===================================================================
--- uspace/drv/bus/usb/ehci/main.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/ehci/main.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -33,18 +33,16 @@
  * Main routines of EHCI driver.
  */
-
 #include <ddf/driver.h>
 #include <ddf/interrupt.h>
 #include <device/hw_res.h>
 #include <errno.h>
-#include <stdbool.h>
 #include <str_error.h>
 
 #include <usb_iface.h>
-#include <usb/ddfiface.h>
 #include <usb/debug.h>
-#include <usb/host/hcd.h>
+#include <usb/host/ddf_helpers.h>
 
 #include "res.h"
+#include "ehci.h"
 
 #define NAME "ehci"
@@ -60,7 +58,4 @@
 	.driver_ops = &ehci_driver_ops
 };
-static ddf_dev_ops_t hc_ops = {
-	.interfaces[USBHC_DEV_IFACE] = &hcd_iface,
-};
 
 
@@ -72,61 +67,34 @@
 static int ehci_dev_add(ddf_dev_t *device)
 {
-	ddf_fun_t *hc_fun = NULL;
-	bool fun_bound = false;
-
 	assert(device);
-
-	addr_range_t reg_range;
-	int irq = 0;
-
-	int rc = get_my_registers(device, &reg_range, &irq);
-	if (rc != EOK) {
-		usb_log_error("Failed to get memory addresses for %" PRIun
-		    ": %s.\n", ddf_dev_get_handle(device), str_error(rc));
-		goto error;
+	hw_res_list_parsed_t hw_res;
+	int ret = hcd_ddf_get_registers(device, &hw_res);
+	if (ret != EOK ||
+	    hw_res.irqs.count != 1 || hw_res.mem_ranges.count != 1) {
+		usb_log_error("Failed to get register memory addresses "
+		    "for %" PRIun ": %s.\n", ddf_dev_get_handle(device),
+		    str_error(ret));
+		return ret;
 	}
+	addr_range_t regs = hw_res.mem_ranges.ranges[0];
+	const int irq = hw_res.irqs.irqs[0];
+	hw_res_list_parsed_clean(&hw_res);
 
 	usb_log_info("Memory mapped regs at %p (size %zu), IRQ %d.\n",
-	    RNGABSPTR(reg_range), RNGSZ(reg_range), irq);
+	    RNGABSPTR(regs), RNGSZ(regs), irq);
 
-	rc = disable_legacy(device, &reg_range);
-	if (rc != EOK) {
+	ret = disable_legacy(device, &regs);
+	if (ret != EOK) {
 		usb_log_error("Failed to disable legacy USB: %s.\n",
-		    str_error(rc));
-		goto error;
-	}
-
-	hc_fun = ddf_fun_create(device, fun_exposed, "ehci_hc");
-	if (hc_fun == NULL) {
-		usb_log_error("Failed to create EHCI function.\n");
-		rc = ENOMEM;
-		goto error;
-	}
-
-	hcd_t *ehci_hc = ddf_fun_data_alloc(hc_fun, sizeof(hcd_t));
-	if (ehci_hc == NULL) {
-		usb_log_error("Failed to alloc generic HC driver.\n");
-		rc = ENOMEM;
-		goto error;
+		    str_error(ret));
+		return ret;
 	}
 
 	/* High Speed, no bandwidth */
-	hcd_init(ehci_hc, USB_SPEED_HIGH, 0, NULL);
-	ddf_fun_set_ops(hc_fun,  &hc_ops);
-
-	rc = ddf_fun_bind(hc_fun);
-	if (rc != EOK) {
-		usb_log_error("Failed to bind EHCI function: %s.\n",
-		    str_error(rc));
-		goto error;
-	}
-
-	fun_bound = true;
-
-	rc = ddf_fun_add_to_category(hc_fun, USB_HC_CATEGORY);
-	if (rc != EOK) {
-		usb_log_error("Failed to add EHCI to HC class: %s.\n",
-		    str_error(rc));
-		goto error;
+	ret = device_setup_ehci(device);
+	if (ret != EOK) {
+		usb_log_error("Failed to init ehci driver: %s\n",
+		    str_error(ret));
+		return ret;
 	}
 
@@ -135,10 +103,4 @@
 
 	return EOK;
-error:
-	if (fun_bound)
-		ddf_fun_unbind(hc_fun);
-	if (hc_fun != NULL)
-		ddf_fun_destroy(hc_fun);
-	return rc;
 }
 
Index: uspace/drv/bus/usb/ehci/res.c
===================================================================
--- uspace/drv/bus/usb/ehci/res.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/ehci/res.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -46,16 +46,5 @@
 
 #include "res.h"
-
-#define HCC_PARAMS_OFFSET 0x8
-#define HCC_PARAMS_EECP_MASK 0xff
-#define HCC_PARAMS_EECP_OFFSET 8
-
-#define CMD_OFFSET 0x0
-#define STS_OFFSET 0x4
-#define INT_OFFSET 0x8
-#define CFG_OFFSET 0x40
-
-#define USBCMD_RUN 1
-#define USBSTS_HALTED (1 << 12)
+#include "ehci_regs.h"
 
 #define USBLEGSUP_OFFSET 0
@@ -66,62 +55,4 @@
 #define DEFAULT_WAIT 1000
 #define WAIT_STEP 10
-
-
-/** Get address of registers and IRQ for given device.
- *
- * @param[in] dev Device asking for the addresses.
- * @param[out] mem_regs_p Pointer to the register range.
- * @param[out] irq_no IRQ assigned to the device.
- * @return Error code.
- */
-int get_my_registers(ddf_dev_t *dev,
-    addr_range_t *mem_regs_p, int *irq_no)
-{
-	assert(dev);
-	
-	async_sess_t *parent_sess = devman_parent_device_connect(
-	    EXCHANGE_SERIALIZE, ddf_dev_get_handle(dev), IPC_FLAG_BLOCKING);
-	if (!parent_sess)
-		return ENOMEM;
-	
-	hw_res_list_parsed_t hw_res;
-	hw_res_list_parsed_init(&hw_res);
-	const int ret = hw_res_get_list_parsed(parent_sess, &hw_res, 0);
-	async_hangup(parent_sess);
-	if (ret != EOK) {
-		return ret;
-	}
-
-	if (hw_res.irqs.count != 1 || hw_res.mem_ranges.count != 1) {
-		hw_res_list_parsed_clean(&hw_res);
-		return ENOENT;
-	}
-
-	if (mem_regs_p)
-		*mem_regs_p = hw_res.mem_ranges.ranges[0];
-	if (irq_no)
-		*irq_no = hw_res.irqs.irqs[0];
-
-	hw_res_list_parsed_clean(&hw_res);
-	return EOK;
-}
-
-/** Calls the PCI driver with a request to enable interrupts
- *
- * @param[in] device Device asking for interrupts
- * @return Error code.
- */
-int enable_interrupts(ddf_dev_t *device)
-{
-	async_sess_t *parent_sess = devman_parent_device_connect(
-	    EXCHANGE_SERIALIZE, ddf_dev_get_handle(device), IPC_FLAG_BLOCKING);
-	if (!parent_sess)
-		return ENOMEM;
-	
-	const bool enabled = hw_res_enable_interrupt(parent_sess);
-	async_hangup(parent_sess);
-	
-	return enabled ? EOK : EIO;
-}
 
 /** Implements BIOS hands-off routine as described in EHCI spec
@@ -142,14 +73,17 @@
 		return ENOMEM;
 
+#define CHECK_RET_HANGUP_RETURN(ret, message...) \
+	if (ret != EOK) { \
+		usb_log_error(message); \
+		async_hangup(parent_sess); \
+		return ret; \
+	} else (void)0
+
 	/* Read the first EEC. i.e. Legacy Support register */
 	uint32_t usblegsup;
-	int rc = pci_config_space_read_32(parent_sess,
+	int ret = pci_config_space_read_32(parent_sess,
 	    eecp + USBLEGSUP_OFFSET, &usblegsup);
-	if (rc != EOK) {
-		usb_log_error("Failed to read USBLEGSUP: %s.\n",
-		    str_error(rc));
-		goto error;
-	}
-
+	CHECK_RET_HANGUP_RETURN(ret,
+	    "Failed to read USBLEGSUP: %s.\n", str_error(ret));
 	usb_log_debug("USBLEGSUP: %" PRIx32 ".\n", usblegsup);
 
@@ -157,31 +91,17 @@
 	 * byte. (OS Control semaphore)*/
 	usb_log_debug("Requesting OS control.\n");
-	rc = pci_config_space_write_8(parent_sess,
+	ret = pci_config_space_write_8(parent_sess,
 	    eecp + USBLEGSUP_OFFSET + 3, 1);
-	if (rc != EOK) {
-		usb_log_error("Failed to request OS EHCI control: %s.\n",
-		    str_error(rc));
-		goto error;
-	}
+	CHECK_RET_HANGUP_RETURN(ret, "Failed to request OS EHCI control: %s.\n",
+	    str_error(ret));
 
 	size_t wait = 0;
 	/* Wait for BIOS to release control. */
-	rc = pci_config_space_read_32(
+	ret = pci_config_space_read_32(
 	    parent_sess, eecp + USBLEGSUP_OFFSET, &usblegsup);
-	if (rc != EOK) {
-		usb_log_error("Failed reading PCI config space: %s.\n",
-		    str_error(rc));
-		goto error;
-	}
-
 	while ((wait < DEFAULT_WAIT) && (usblegsup & USBLEGSUP_BIOS_CONTROL)) {
 		async_usleep(WAIT_STEP);
-		rc = pci_config_space_read_32(parent_sess,
+		ret = pci_config_space_read_32(parent_sess,
 		    eecp + USBLEGSUP_OFFSET, &usblegsup);
-		if (rc != EOK) {
-			usb_log_error("Failed reading PCI config space: %s.\n",
-			    str_error(rc));
-			goto error;
-		}
 		wait += WAIT_STEP;
 	}
@@ -196,12 +116,8 @@
 	usb_log_warning( "BIOS failed to release control after "
 	    "%zu usecs, force it.\n", wait);
-	rc = pci_config_space_write_32(parent_sess,
+	ret = pci_config_space_write_32(parent_sess,
 	    eecp + USBLEGSUP_OFFSET, USBLEGSUP_OS_CONTROL);
-	if (rc != EOK) {
-		usb_log_error("Failed to force OS control: "
-		    "%s.\n", str_error(rc));
-		goto error;
-	}
-
+	CHECK_RET_HANGUP_RETURN(ret, "Failed to force OS control: "
+	    "%s.\n", str_error(ret));
 	/*
 	 * Check capability type here, value of 01h identifies the capability
@@ -213,12 +129,8 @@
 		/* Read the second EEC Legacy Support and Control register */
 		uint32_t usblegctlsts;
-		rc = pci_config_space_read_32(parent_sess,
+		ret = pci_config_space_read_32(parent_sess,
 		    eecp + USBLEGCTLSTS_OFFSET, &usblegctlsts);
-		if (rc != EOK) {
-			usb_log_error("Failed to get USBLEGCTLSTS: %s.\n",
-			    str_error(rc));
-			goto error;
-		}
-
+		CHECK_RET_HANGUP_RETURN(ret, "Failed to get USBLEGCTLSTS: %s.\n",
+		    str_error(ret));
 		usb_log_debug("USBLEGCTLSTS: %" PRIx32 ".\n", usblegctlsts);
 		/*
@@ -227,20 +139,12 @@
 		 * interfering. NOTE: Three upper bits are WC
 		 */
-		rc = pci_config_space_write_32(parent_sess,
+		ret = pci_config_space_write_32(parent_sess,
 		    eecp + USBLEGCTLSTS_OFFSET, 0xe0000000);
-		if (rc != EOK) {
-			usb_log_error("Failed(%d) zero USBLEGCTLSTS.\n", rc);
-			goto error;
-		}
-
+		CHECK_RET_HANGUP_RETURN(ret, "Failed(%d) zero USBLEGCTLSTS.\n", ret);
 		udelay(10);
-		rc = pci_config_space_read_32(parent_sess,
+		ret = pci_config_space_read_32(parent_sess,
 		    eecp + USBLEGCTLSTS_OFFSET, &usblegctlsts);
-		if (rc != EOK) {
-			usb_log_error("Failed to get USBLEGCTLSTS 2: %s.\n",
-			    str_error(rc));
-			goto error;
-		}
-
+		CHECK_RET_HANGUP_RETURN(ret, "Failed to get USBLEGCTLSTS 2: %s.\n",
+		    str_error(ret));
 		usb_log_debug("Zeroed USBLEGCTLSTS: %" PRIx32 ".\n",
 		    usblegctlsts);
@@ -248,18 +152,12 @@
 
 	/* Read again Legacy Support register */
-	rc = pci_config_space_read_32(parent_sess,
+	ret = pci_config_space_read_32(parent_sess,
 	    eecp + USBLEGSUP_OFFSET, &usblegsup);
-	if (rc != EOK) {
-		usb_log_error("Failed to read USBLEGSUP: %s.\n",
-		    str_error(rc));
-		goto error;
-	}
-
+	CHECK_RET_HANGUP_RETURN(ret, "Failed to read USBLEGSUP: %s.\n",
+	    str_error(ret));
 	usb_log_debug("USBLEGSUP: %" PRIx32 ".\n", usblegsup);
 	async_hangup(parent_sess);
 	return EOK;
-error:
-	async_hangup(parent_sess);
-	return rc;
+#undef CHECK_RET_HANGUP_RETURN
 }
 
@@ -271,15 +169,16 @@
 	/* Map EHCI registers */
 	void *regs = NULL;
-	int rc = pio_enable_range(reg_range, &regs);
-	if (rc != EOK) {
+	int ret = pio_enable_range(reg_range, &regs);
+	if (ret != EOK) {
 		usb_log_error("Failed to map registers %p: %s.\n",
-		    RNGABSPTR(*reg_range), str_error(rc));
-		return rc;
+		    RNGABSPTR(*reg_range), str_error(ret));
+		return ret;
 	}
 
 	usb_log_debug2("Registers mapped at: %p.\n", regs);
 
-	const uint32_t hcc_params =
-	    *(uint32_t*)(regs + HCC_PARAMS_OFFSET);
+	ehci_caps_regs_t *ehci_caps = regs;
+
+	const uint32_t hcc_params = EHCI_RD(ehci_caps->hccparams);
 	usb_log_debug("Value of hcc params register: %x.\n", hcc_params);
 
@@ -287,13 +186,14 @@
 	 * position of EEC registers (points to PCI config space) */
 	const uint32_t eecp =
-	    (hcc_params >> HCC_PARAMS_EECP_OFFSET) & HCC_PARAMS_EECP_MASK;
+	    (hcc_params >> EHCI_CAPS_HCC_EECP_SHIFT) & EHCI_CAPS_HCC_EECP_MASK;
 	usb_log_debug("Value of EECP: %x.\n", eecp);
 
-	rc = disable_extended_caps(device, eecp);
-	if (rc != EOK) {
+	ret = disable_extended_caps(device, eecp);
+	if (ret != EOK) {
 		usb_log_error("Failed to disable extended capabilities: %s.\n",
-		    str_error(rc));
-		return rc;
-	}
+		    str_error(ret));
+		return ret;
+	}
+
 
 	/*
@@ -302,25 +202,17 @@
 
 	/* Get size of capability registers in memory space. */
-	const unsigned operation_offset = *(uint8_t*)regs;
+	const unsigned operation_offset = EHCI_RD8(ehci_caps->caplength);
 	usb_log_debug("USBCMD offset: %d.\n", operation_offset);
 
-	/* Zero USBCMD register. */
-	volatile uint32_t *usbcmd =
-	    (uint32_t*)((uint8_t*)regs + operation_offset + CMD_OFFSET);
-	volatile uint32_t *usbsts =
-	    (uint32_t*)((uint8_t*)regs + operation_offset + STS_OFFSET);
-	volatile uint32_t *usbconf =
-	    (uint32_t*)((uint8_t*)regs + operation_offset + CFG_OFFSET);
-	volatile uint32_t *usbint =
-	    (uint32_t*)((uint8_t*)regs + operation_offset + INT_OFFSET);
-	usb_log_debug("USBCMD value: %x.\n", *usbcmd);
-	if (*usbcmd & USBCMD_RUN) {
-		*usbsts = 0x3f; /* ack all interrupts */
-		*usbint = 0; /* disable all interrupts */
-		*usbconf = 0; /* release control of RH ports */
-
-		*usbcmd = 0;
+	ehci_regs_t *ehci_regs = regs + operation_offset;
+
+	usb_log_debug("USBCMD value: %x.\n", EHCI_RD(ehci_regs->usbcmd));
+	if (EHCI_RD(ehci_regs->usbcmd) & USB_CMD_RUN_FLAG) {
+		EHCI_WR(ehci_regs->usbintr, 0); /* disable all interrupts */
+		EHCI_WR(ehci_regs->usbsts, 0x3f); /* ack all interrupts */
+		EHCI_WR(ehci_regs->configflag, 0); /* release RH ports */
+		EHCI_WR(ehci_regs->usbcmd, 0);
 		/* Wait until hc is halted */
-		while ((*usbsts & USBSTS_HALTED) == 0);
+		while ((EHCI_RD(ehci_regs->usbsts) & USB_STS_HC_HALTED_FLAG) == 0);
 		usb_log_info("EHCI turned off.\n");
 	} else {
@@ -332,7 +224,10 @@
 	    "\t USBINT(%p): %x(0x0 = no interrupts).\n"
 	    "\t CONFIG(%p): %x(0x0 = ports controlled by companion hc).\n",
-	    usbcmd, *usbcmd, usbsts, *usbsts, usbint, *usbint, usbconf,*usbconf);
-
-	return rc;
+	    &ehci_regs->usbcmd, EHCI_RD(ehci_regs->usbcmd),
+	    &ehci_regs->usbsts, EHCI_RD(ehci_regs->usbsts),
+	    &ehci_regs->usbintr, EHCI_RD(ehci_regs->usbintr),
+	    &ehci_regs->configflag, EHCI_RD(ehci_regs->configflag));
+
+	return ret;
 }
 
Index: uspace/drv/bus/usb/ehci/res.h
===================================================================
--- uspace/drv/bus/usb/ehci/res.h	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/ehci/res.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -39,6 +39,4 @@
 #include <device/hw_res_parsed.h>
 
-int get_my_registers(ddf_dev_t *, addr_range_t *, int *);
-int enable_interrupts(ddf_dev_t *);
 int disable_legacy(ddf_dev_t *, addr_range_t *);
 
Index: uspace/drv/bus/usb/ehci/utils/malloc32.h
===================================================================
--- uspace/drv/bus/usb/ehci/utils/malloc32.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
+++ uspace/drv/bus/usb/ehci/utils/malloc32.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013 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 drvusbehci
+ * @{
+ */
+/** @file
+ * @brief EHCI driver
+ */
+#ifndef DRV_EHCI_UTILS_MALLOC32_H
+#define DRV_EHCI_UTILS_MALLOC32_H
+
+#include <as.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <sys/types.h>
+
+/* Generic TDs and EDs require 16byte alignment,
+ * Isochronous TD require 32byte alignment,
+ * buffers do not have to be aligned.
+ */
+#define EHCI_ALIGN 32
+
+/** Get physical address translation
+ *
+ * @param[in] addr Virtual address to translate
+ * @return Physical address if exists, NULL otherwise.
+ */
+static inline uintptr_t addr_to_phys(const void *addr)
+{
+	uintptr_t result;
+	int ret = as_get_physical_mapping(addr, &result);
+	
+	if (ret != EOK)
+		return 0;
+	
+	return result;
+}
+
+/** Physical mallocator simulator
+ *
+ * @param[in] size Size of the required memory space
+ * @return Address of the aligned and big enough memory place, NULL on failure.
+ */
+static inline void * malloc32(size_t size)
+	{ return memalign(EHCI_ALIGN, size); }
+
+/** Physical mallocator simulator
+ *
+ * @param[in] addr Address of the place allocated by malloc32
+ */
+static inline void free32(void *addr)
+	{ free(addr); }
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/bus/usb/ohci/Makefile
===================================================================
--- uspace/drv/bus/usb/ohci/Makefile	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/ohci/Makefile	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -31,5 +31,5 @@
 LIBS = \
 	$(LIBUSBHOST_PREFIX)/libusbhost.a \
-	$(LIBUSBDEV_PREFIX)/libusbdev.a \
+	$(LIBUSBVIRT_PREFIX)/libusbvirt.a \
 	$(LIBUSB_PREFIX)/libusb.a \
 	$(LIBDRV_PREFIX)/libdrv.a
@@ -39,4 +39,5 @@
 	-I$(LIBUSBDEV_PREFIX)/include \
 	-I$(LIBUSBHOST_PREFIX)/include \
+	-I$(LIBUSBVIRT_PREFIX)/include \
 	-I$(LIBDRV_PREFIX)/include
 
@@ -50,6 +51,5 @@
 	ohci_batch.c \
 	ohci_endpoint.c \
-	res.c \
-	root_hub.c \
+	ohci_rh.c \
 	hw_struct/endpoint_descriptor.c \
 	hw_struct/transfer_descriptor.c
Index: uspace/drv/bus/usb/ohci/endpoint_list.c
===================================================================
--- uspace/drv/bus/usb/ohci/endpoint_list.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/ohci/endpoint_list.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -34,7 +34,11 @@
  */
 
+#include <assert.h>
 #include <errno.h>
+#include <libarch/barrier.h>
+
 #include <usb/debug.h>
-#include <libarch/barrier.h>
+
+#include "utils/malloc32.h"
 #include "endpoint_list.h"
 
Index: uspace/drv/bus/usb/ohci/endpoint_list.h
===================================================================
--- uspace/drv/bus/usb/ohci/endpoint_list.h	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/ohci/endpoint_list.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -35,5 +35,8 @@
 #define DRV_OHCI_ENDPOINT_LIST_H
 
+#include <adt/list.h>
+#include <assert.h>
 #include <fibril_synch.h>
+#include <sys/types.h>
 
 #include "ohci_endpoint.h"
@@ -65,4 +68,5 @@
 	assert(instance);
 	free32(instance->list_head);
+	instance->list_head = NULL;
 }
 
Index: uspace/drv/bus/usb/ohci/hc.c
===================================================================
--- uspace/drv/bus/usb/ohci/hc.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/ohci/hc.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -34,16 +34,21 @@
  */
 
+#include <assert.h>
+#include <async.h>
 #include <errno.h>
-#include <stdbool.h>
+#include <macros.h>
+#include <mem.h>
+#include <stdlib.h>
 #include <str_error.h>
-#include <adt/list.h>
-#include <libarch/ddi.h>
+#include <sys/types.h>
 
 #include <usb/debug.h>
 #include <usb/usb.h>
-#include <usb/ddfiface.h>
+
+#include "ohci_endpoint.h"
+#include "ohci_batch.h"
+#include "utils/malloc32.h"
 
 #include "hc.h"
-#include "ohci_endpoint.h"
 
 #define OHCI_USED_INTERRUPTS \
@@ -84,14 +89,4 @@
 };
 
-enum {
-	/** Number of PIO ranges used in IRQ code */
-	hc_irq_pio_range_count = 
-	    sizeof(ohci_pio_ranges) / sizeof(irq_pio_range_t),
-
-	/** Number of commands used in IRQ code */
-	hc_irq_cmd_count =
-	    sizeof(ohci_irq_commands) / sizeof(irq_cmd_t)
-};
-
 static void hc_gain_control(hc_t *instance);
 static void hc_start(hc_t *instance);
@@ -99,5 +94,4 @@
 static int hc_init_memory(hc_t *instance);
 static int interrupt_emulator(hc_t *instance);
-static int hc_schedule(hcd_t *hcd, usb_transfer_batch_t *batch);
 
 /** Generate IRQ code.
@@ -110,146 +104,33 @@
  * @return Error code.
  */
-int
-hc_get_irq_code(irq_pio_range_t ranges[], size_t ranges_size, irq_cmd_t cmds[],
-    size_t cmds_size, addr_range_t *regs)
-{
-	if ((ranges_size < sizeof(ohci_pio_ranges)) ||
-	    (cmds_size < sizeof(ohci_irq_commands)) ||
-	    (RNGSZ(*regs) < sizeof(ohci_regs_t)))
+int hc_gen_irq_code(irq_code_t *code, addr_range_t *regs)
+{
+	assert(code);
+	if (RNGSZ(*regs) < sizeof(ohci_regs_t))
 		return EOVERFLOW;
 
-	memcpy(ranges, ohci_pio_ranges, sizeof(ohci_pio_ranges));
-	ranges[0].base = RNGABS(*regs);
-
-	memcpy(cmds, ohci_irq_commands, sizeof(ohci_irq_commands));
+	code->ranges = malloc(sizeof(ohci_pio_ranges));
+	if (code->ranges == NULL)
+		return ENOMEM;
+
+	code->cmds = malloc(sizeof(ohci_irq_commands));
+	if (code->cmds == NULL) {
+		free(code->ranges);
+		return ENOMEM;
+	}
+
+	code->rangecount = ARRAY_SIZE(ohci_pio_ranges);
+	code->cmdcount = ARRAY_SIZE(ohci_irq_commands);
+
+	memcpy(code->ranges, ohci_pio_ranges, sizeof(ohci_pio_ranges));
+	code->ranges[0].base = RNGABS(*regs);
+
+	memcpy(code->cmds, ohci_irq_commands, sizeof(ohci_irq_commands));
 	ohci_regs_t *registers = (ohci_regs_t *) RNGABSPTR(*regs);
-	cmds[0].addr = (void *) &registers->interrupt_status;
-	cmds[3].addr = (void *) &registers->interrupt_status;
-	OHCI_WR(cmds[1].value, OHCI_USED_INTERRUPTS);
+	code->cmds[0].addr = (void *) &registers->interrupt_status;
+	code->cmds[3].addr = (void *) &registers->interrupt_status;
+	OHCI_WR(code->cmds[1].value, OHCI_USED_INTERRUPTS);
 
 	return EOK;
-}
-
-/** Register interrupt handler.
- *
- * @param[in] device Host controller DDF device
- * @param[in] regs Register range
- * @param[in] irq Interrupt number
- * @paran[in] handler Interrupt handler
- *
- * @return EOK on success or negative error code
- */
-int hc_register_irq_handler(ddf_dev_t *device, addr_range_t *regs, int irq,
-    interrupt_handler_t handler)
-{
-	int rc;
-
-	irq_pio_range_t irq_ranges[hc_irq_pio_range_count];
-	irq_cmd_t irq_cmds[hc_irq_cmd_count];
-
-	irq_code_t irq_code = {
-		.rangecount = hc_irq_pio_range_count,
-		.ranges = irq_ranges,
-		.cmdcount = hc_irq_cmd_count,
-		.cmds = irq_cmds
-	};
-
-	rc = hc_get_irq_code(irq_ranges, sizeof(irq_ranges), irq_cmds,
-	    sizeof(irq_cmds), regs);
-	if (rc != EOK) {
-		usb_log_error("Failed to generate IRQ code: %s.\n",
-		    str_error(rc));
-		return rc;
-	}
-
-	/* Register handler to avoid interrupt lockup */
-	rc = register_interrupt_handler(device, irq, handler, &irq_code);
-	if (rc != EOK) {
-		usb_log_error("Failed to register interrupt handler: %s.\n",
-		    str_error(rc));
-		return rc;
-	}
-
-	return EOK;
-}
-
-/** Announce OHCI root hub to the DDF
- *
- * @param[in] instance OHCI driver intance
- * @param[in] hub_fun DDF fuction representing OHCI root hub
- * @return Error code
- */
-int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun)
-{
-	bool addr_reqd = false;
-	bool ep_added = false;
-	bool fun_bound = false;
-	int rc;
-
-	assert(instance);
-	assert(hub_fun);
-
-	/* Try to get address 1 for root hub. */
-	instance->rh.address = 1;
-	rc = usb_device_manager_request_address(
-	    &instance->generic.dev_manager, &instance->rh.address, false,
-	    USB_SPEED_FULL);
-	if (rc != EOK) {
-		usb_log_error("Failed to get OHCI root hub address: %s\n",
-		    str_error(rc));
-		goto error;
-	}
-
-	addr_reqd = true;
-
-	rc = usb_endpoint_manager_add_ep(
-	    &instance->generic.ep_manager, instance->rh.address, 0,
-	    USB_DIRECTION_BOTH, USB_TRANSFER_CONTROL, USB_SPEED_FULL, 64,
-	    0, NULL, NULL);
-	if (rc != EOK) {
-    	        usb_log_error("Failed to register root hub control endpoint: %s.\n",
-		    str_error(rc));
-		goto error;
-	}
-
-	ep_added = true;
-
-	rc = ddf_fun_add_match_id(hub_fun, "usb&class=hub", 100);
-	if (rc != EOK) {
-		usb_log_error("Failed to add root hub match-id: %s.\n",
-		    str_error(rc));
-		goto error;
-	}
-
-	rc = ddf_fun_bind(hub_fun);
-	if (rc != EOK) {
-		usb_log_error("Failed to bind root hub function: %s.\n",
-		    str_error(rc));
-		goto error;
-	}
-
-	fun_bound = true;
-
-	rc = usb_device_manager_bind_address(&instance->generic.dev_manager,
-	    instance->rh.address, ddf_fun_get_handle(hub_fun));
-	if (rc != EOK) {
-		usb_log_warning("Failed to bind root hub address: %s.\n",
-		    str_error(rc));
-	}
-
-	return EOK;
-error:
-	if (fun_bound)
-		ddf_fun_unbind(hub_fun);
-	if (ep_added) {
-		usb_endpoint_manager_remove_ep(
-		    &instance->generic.ep_manager, instance->rh.address, 0,
-		    USB_DIRECTION_BOTH, NULL, NULL);
-	}
-	if (addr_reqd) {
-		usb_device_manager_release_address(
-		    &instance->generic.dev_manager, instance->rh.address);
-	}
-	return rc;
 }
 
@@ -265,28 +146,20 @@
 	assert(instance);
 
-	int rc = pio_enable_range(regs, (void **) &instance->registers);
-	if (rc != EOK) {
+	int ret = pio_enable_range(regs, (void **) &instance->registers);
+	if (ret != EOK) {
 		usb_log_error("Failed to gain access to device registers: %s.\n",
-		    str_error(rc));
-		return rc;
+		    str_error(ret));
+		return ret;
 	}
 
 	list_initialize(&instance->pending_batches);
-
-	hcd_init(&instance->generic, USB_SPEED_FULL,
-	    BANDWIDTH_AVAILABLE_USB11, bandwidth_count_usb11);
-	instance->generic.private_data = instance;
-	instance->generic.schedule = hc_schedule;
-	instance->generic.ep_add_hook = ohci_endpoint_init;
-	instance->generic.ep_remove_hook = ohci_endpoint_fini;
-
-	rc = hc_init_memory(instance);
-	if (rc != EOK) {
+	fibril_mutex_initialize(&instance->guard);
+
+	ret = hc_init_memory(instance);
+	if (ret != EOK) {
 		usb_log_error("Failed to create OHCI memory structures: %s.\n",
-		    str_error(rc));
-		return rc;
-	}
-
-	fibril_mutex_initialize(&instance->guard);
+		    str_error(ret));
+		return ret;
+	}
 
 	hc_gain_control(instance);
@@ -298,5 +171,5 @@
 	}
 
-	rh_init(&instance->rh, instance->registers);
+	ohci_rh_init(&instance->rh, instance->registers, "ohci rh");
 	hc_start(instance);
 
@@ -381,12 +254,11 @@
 {
 	assert(hcd);
-	hc_t *instance = hcd->private_data;
+	hc_t *instance = hcd->driver.data;
 	assert(instance);
 
 	/* Check for root hub communication */
-	if (batch->ep->address == instance->rh.address) {
+	if (batch->ep->address == ohci_rh_get_address(&instance->rh)) {
 		usb_log_debug("OHCI root hub request.\n");
-		rh_request(&instance->rh, batch);
-		return EOK;
+		return ohci_rh_schedule(&instance->rh, batch);
 	}
 	ohci_transfer_batch_t *ohci_batch = ohci_transfer_batch_get(batch);
@@ -427,5 +299,5 @@
 	usb_log_debug2("OHCI(%p) interrupt: %x.\n", instance, status);
 	if (status & I_RHSC)
-		rh_interrupt(&instance->rh);
+		ohci_rh_interrupt(&instance->rh);
 
 	if (status & I_WDH) {
@@ -512,5 +384,5 @@
 		OHCI_SET(instance->registers->command_status, CS_OCR);
 		/* Hope that SMM actually knows its stuff or we can hang here */
-		while (OHCI_RD(instance->registers->control & C_IR)) {
+		while (OHCI_RD(instance->registers->control) & C_IR) {
 			async_usleep(1000);
 		}
@@ -625,5 +497,5 @@
 do { \
 	const char *name = usb_str_transfer_type(type); \
-	int ret = endpoint_list_init(&instance->lists[type], name); \
+	const int ret = endpoint_list_init(&instance->lists[type], name); \
 	if (ret != EOK) { \
 		usb_log_error("Failed to setup %s endpoint list: %s.\n", \
Index: uspace/drv/bus/usb/ohci/hc.h
===================================================================
--- uspace/drv/bus/usb/ohci/hc.h	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/ohci/hc.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -35,16 +35,19 @@
 #define DRV_OHCI_HC_H
 
-#include <ddf/interrupt.h>
+#include <adt/list.h>
+#include <ddi.h>
+#include <ddf/driver.h>
+#include <device/hw_res_parsed.h>
 #include <fibril.h>
 #include <fibril_synch.h>
-#include <adt/list.h>
-#include <ddi.h>
+#include <stdbool.h>
+#include <sys/types.h>
 
-#include <usb/usb.h>
 #include <usb/host/hcd.h>
+#include <usb/host/endpoint.h>
+#include <usb/host/usb_transfer_batch.h>
 
-#include "ohci_batch.h"
 #include "ohci_regs.h"
-#include "root_hub.h"
+#include "ohci_rh.h"
 #include "endpoint_list.h"
 #include "hw_struct/hcca.h"
@@ -52,7 +55,4 @@
 /** Main OHCI driver structure */
 typedef struct hc {
-	/** Generic USB hc driver */
-	hcd_t generic;
-
 	/** Memory mapped I/O registers area */
 	ohci_regs_t *registers;
@@ -72,11 +72,8 @@
 
 	/** USB hub emulation structure */
-	rh_t rh;
+	ohci_rh_t rh;
 } hc_t;
 
-int hc_get_irq_code(irq_pio_range_t [], size_t, irq_cmd_t [], size_t,
-    addr_range_t *);
-int hc_register_irq_handler(ddf_dev_t *, addr_range_t *, int,
-    interrupt_handler_t);
+int hc_gen_irq_code(irq_code_t *code, addr_range_t *regs);
 int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun);
 int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts);
@@ -90,4 +87,5 @@
 void hc_enqueue_endpoint(hc_t *instance, const endpoint_t *ep);
 void hc_dequeue_endpoint(hc_t *instance, const endpoint_t *ep);
+int hc_schedule(hcd_t *hcd, usb_transfer_batch_t *batch);
 
 void hc_interrupt(hc_t *instance, uint32_t status);
Index: uspace/drv/bus/usb/ohci/hw_struct/completion_codes.h
===================================================================
--- uspace/drv/bus/usb/ohci/hw_struct/completion_codes.h	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/ohci/hw_struct/completion_codes.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -37,20 +37,22 @@
 #include <errno.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)
+enum {
+	CC_NOERROR = 0x0,
+	CC_CRC = 0x1,
+	CC_BITSTUFF = 0x2,
+	CC_TOGGLE = 0x3,
+	CC_STALL = 0x4,
+	CC_NORESPONSE = 0x5,
+	CC_PIDFAIL = 0x6,
+	CC_PIDUNEXPECTED = 0x7,
+	CC_DATAOVERRRUN = 0x8,
+	CC_DATAUNDERRRUN = 0x9,
+	CC_BUFFEROVERRRUN = 0xc,
+	CC_BUFFERUNDERRUN = 0xd,
+	CC_NOACCESS1 = 0xe,
+	CC_NOACCESS2 = 0xf,
+};
 
-inline static int cc_to_rc(int cc)
+inline static unsigned cc_to_rc(unsigned cc)
 {
 	switch (cc) {
Index: uspace/drv/bus/usb/ohci/hw_struct/endpoint_descriptor.c
===================================================================
--- uspace/drv/bus/usb/ohci/hw_struct/endpoint_descriptor.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/ohci/hw_struct/endpoint_descriptor.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -32,4 +32,14 @@
  * @brief OHCI driver
  */
+
+#include <assert.h>
+#include <macros.h>
+#include <mem.h>
+
+#include <usb/usb.h>
+
+#include "../utils/malloc32.h"
+#include "mem_access.h"
+
 #include "endpoint_descriptor.h"
 
@@ -48,5 +58,5 @@
  * @param td TD to put in the list.
  *
- * If @param ep is NULL, dummy ED is initalized with only skip flag set.
+ * If @param ep is NULL, dummy ED is initialized with only skip flag set.
  */
 void ed_init(ed_t *instance, const endpoint_t *ep, const td_t *td)
@@ -61,6 +71,8 @@
 		return;
 	}
-	/* Non-dummy ED must have TD assigned */
+	/* Non-dummy ED must have corresponding EP and TD assigned */
 	assert(td);
+	assert(ep);
+	assert(ep->direction < ARRAY_SIZE(dir));
 
 	/* Status: address, endpoint nr, direction mask and max packet size. */
@@ -77,4 +89,5 @@
 
 	/* Isochronous format flag */
+	// TODO: We need iTD instead of TD for iso transfers
 	if (ep->transfer_type == USB_TRANSFER_ISOCHRONOUS)
 		OHCI_MEM32_SET(instance->status, ED_STATUS_F_FLAG);
Index: uspace/drv/bus/usb/ohci/hw_struct/endpoint_descriptor.h
===================================================================
--- uspace/drv/bus/usb/ohci/hw_struct/endpoint_descriptor.h	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/ohci/hw_struct/endpoint_descriptor.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -36,5 +36,6 @@
 
 #include <assert.h>
-#include <stdint.h>
+#include <stdbool.h>
+#include <sys/types.h>
 
 #include <usb/host/endpoint.h>
Index: uspace/drv/bus/usb/ohci/hw_struct/hcca.h
===================================================================
--- uspace/drv/bus/usb/ohci/hw_struct/hcca.h	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/ohci/hw_struct/hcca.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -35,6 +35,7 @@
 #define DRV_OHCI_HW_STRUCT_HCCA_H
 
-#include <stdint.h>
 #include <malloc.h>
+#include <sys/types.h>
+#include <macros.h>
 
 #include "mem_access.h"
@@ -50,10 +51,12 @@
 	/** Frame number. */
 	uint16_t frame_number;
-	uint16_t pad1;
+	PADD16;
 	/** Pointer to the last completed TD. (useless) */
 	uint32_t done_head;
 	/** Padding to make the size 256B */
-	uint32_t reserved[30];
+	PADD32[30];
 } hcca_t;
+
+STATIC_ASSERT(sizeof(hcca_t) == 256);
 
 /** Allocate properly aligned structure.
@@ -65,6 +68,5 @@
 static inline hcca_t * hcca_get(void)
 {
-	assert(sizeof(hcca_t) == 256);
-	hcca_t *hcca = memalign(256, sizeof(hcca_t));
+	hcca_t *hcca = memalign(sizeof(hcca_t), sizeof(hcca_t));
 	if (hcca)
 		memset(hcca, 0, sizeof(hcca_t));
@@ -80,7 +82,6 @@
 {
 	assert(hcca);
-	assert(index < HCCA_INT_EP_COUNT);
+	assert(index < ARRAY_SIZE(hcca->int_ep));
 	OHCI_MEM32_WR(hcca->int_ep[index], pa);
-
 }
 #endif
Index: uspace/drv/bus/usb/ohci/hw_struct/iso_transfer_descriptor.h
===================================================================
--- uspace/drv/bus/usb/ohci/hw_struct/iso_transfer_descriptor.h	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/ohci/hw_struct/iso_transfer_descriptor.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -35,5 +35,5 @@
 #define DRV_OHCI_HW_STRUCT_ISO_TRANSFER_DESCRIPTOR_H
 
-#include <stdint.h>
+#include <sys/types.h>
 
 #include "completion_codes.h"
Index: uspace/drv/bus/usb/ohci/hw_struct/mem_access.h
===================================================================
--- uspace/drv/bus/usb/ohci/hw_struct/mem_access.h	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/ohci/hw_struct/mem_access.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -47,3 +47,2 @@
  * @}
  */
-
Index: uspace/drv/bus/usb/ohci/hw_struct/transfer_descriptor.c
===================================================================
--- uspace/drv/bus/usb/ohci/hw_struct/transfer_descriptor.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/ohci/hw_struct/transfer_descriptor.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -32,7 +32,13 @@
  * @brief OHCI driver
  */
+
+#include <assert.h>
+#include <mem.h>
+
 #include <usb/usb.h>
-#include <mem.h>
+
 #include "../utils/malloc32.h"
+#include "completion_codes.h"
+#include "mem_access.h"
 #include "transfer_descriptor.h"
 
Index: uspace/drv/bus/usb/ohci/hw_struct/transfer_descriptor.h
===================================================================
--- uspace/drv/bus/usb/ohci/hw_struct/transfer_descriptor.h	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/ohci/hw_struct/transfer_descriptor.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -35,4 +35,5 @@
 #define DRV_OHCI_HW_STRUCT_TRANSFER_DESCRIPTOR_H
 
+#include <assert.h>
 #include <stdbool.h>
 #include <stdint.h>
Index: uspace/drv/bus/usb/ohci/main.c
===================================================================
--- uspace/drv/bus/usb/ohci/main.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/ohci/main.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -33,6 +33,9 @@
  * Main routines of OHCI driver.
  */
+
+#include <assert.h>
 #include <ddf/driver.h>
 #include <errno.h>
+#include <io/log.h>
 #include <str_error.h>
 
Index: uspace/drv/bus/usb/ohci/ohci.c
===================================================================
--- uspace/drv/bus/usb/ohci/ohci.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/ohci/ohci.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -34,30 +34,23 @@
  */
 
-/* XXX Fix this */
-#define _DDF_DATA_IMPLANT
+#include <assert.h>
+#include <errno.h>
+#include <ddf/interrupt.h>
+#include <device/hw_res_parsed.h>
+#include <stdbool.h>
+#include <str_error.h>
+#include <sys/types.h>
 
-#include <errno.h>
-#include <str_error.h>
-#include <ddf/interrupt.h>
-#include <usb_iface.h>
 #include <usb/usb.h>
-#include <usb/ddfiface.h>
 #include <usb/debug.h>
 
+#include <usb/host/ddf_helpers.h>
+#include <usb/host/usb_bus.h>
+
 #include "ohci.h"
-#include "res.h"
+#include "ohci_endpoint.h"
 #include "hc.h"
 
-typedef struct ohci {
-	ddf_fun_t *hc_fun;
-	ddf_fun_t *rh_fun;
 
-	hc_t hc;
-} ohci_t;
-
-static inline ohci_t *dev_to_ohci(ddf_dev_t *dev)
-{
-	return ddf_dev_data_get(dev);
-}
 /** IRQ handling callback, identifies device
  *
@@ -69,64 +62,13 @@
 {
 	assert(dev);
-
-	ohci_t *ohci = dev_to_ohci(dev);
-	if (!ohci) {
+	hcd_t *hcd = dev_to_hcd(dev);
+	if (!hcd || !hcd->driver.data) {
 		usb_log_warning("Interrupt on device that is not ready.\n");
 		return;
 	}
+
 	const uint16_t status = IPC_GET_ARG1(*call);
-	hc_interrupt(&ohci->hc, status);
+	hc_interrupt(hcd->driver.data, status);
 }
-
-/** Get USB address assigned to root hub.
- *
- * @param[in] fun Root hub function.
- * @param[out] address Store the address here.
- * @return Error code.
- */
-static int rh_get_my_address(ddf_fun_t *fun, usb_address_t *address)
-{
-	assert(fun);
-
-	if (address != NULL) {
-		*address = dev_to_ohci(ddf_fun_get_dev(fun))->hc.rh.address;
-	}
-
-	return EOK;
-}
-
-/** Gets handle of the respective hc (this device, hc function).
- *
- * @param[in] root_hub_fun Root hub function seeking hc handle.
- * @param[out] handle Place to write the handle.
- * @return Error code.
- */
-static int rh_get_hc_handle(
-    ddf_fun_t *fun, devman_handle_t *handle)
-{
-	assert(fun);
-	ddf_fun_t *hc_fun = dev_to_ohci(ddf_fun_get_dev(fun))->hc_fun;
-	assert(hc_fun);
-
-	if (handle != NULL)
-		*handle = ddf_fun_get_handle(hc_fun);
-	return EOK;
-}
-
-/** Root hub USB interface */
-static usb_iface_t usb_iface = {
-	.get_hc_handle = rh_get_hc_handle,
-	.get_my_address = rh_get_my_address,
-};
-
-/** Standard USB HC options (HC interface) */
-static ddf_dev_ops_t hc_ops = {
-	.interfaces[USBHC_DEV_IFACE] = &hcd_iface,
-};
-
-/** Standard USB RH options (RH interface) */
-static ddf_dev_ops_t rh_ops = {
-	.interfaces[USB_DEV_IFACE] = &usb_iface,
-};
 
 /** Initialize hc and rh ddf structures and their respective drivers.
@@ -143,70 +85,43 @@
 int device_setup_ohci(ddf_dev_t *device)
 {
-	bool ih_registered = false;
-	bool hc_inited = false;
-	int rc;
-
-	if (device == NULL)
-		return EBADMEM;
-
-	ohci_t *instance = ddf_dev_data_alloc(device,sizeof(ohci_t));
-	if (instance == NULL) {
-		usb_log_error("Failed to allocate OHCI driver.\n");
-		return ENOMEM;
-	}
-
-	instance->hc_fun = ddf_fun_create(device, fun_exposed, "ohci_hc");
-	if (instance->hc_fun == NULL) {
-		usb_log_error("Failed to create OHCI HC function: %s.\n",
-		    str_error(ENOMEM));
-		rc = ENOMEM;
-		goto error;
-	}
-
-	ddf_fun_set_ops(instance->hc_fun, &hc_ops);
-	ddf_fun_data_implant(instance->hc_fun, &instance->hc);
-
-	instance->rh_fun = ddf_fun_create(device, fun_inner, "ohci_rh");
-	if (instance->rh_fun == NULL) {
-		usb_log_error("Failed to create OHCI RH function: %s.\n",
-		    str_error(ENOMEM));
-		rc = ENOMEM;
-		goto error;
-	}
-
-	ddf_fun_set_ops(instance->rh_fun, &rh_ops);
-
-	addr_range_t regs;
-	int irq = 0;
-
-	rc = get_my_registers(device, &regs, &irq);
-	if (rc != EOK) {
+	hw_res_list_parsed_t hw_res;
+	int ret = hcd_ddf_get_registers(device, &hw_res);
+	if (ret != EOK ||
+	    hw_res.irqs.count != 1 || hw_res.mem_ranges.count != 1) {
 		usb_log_error("Failed to get register memory addresses "
 		    "for %" PRIun ": %s.\n", ddf_dev_get_handle(device),
-		    str_error(rc));
-		goto error;
+		    str_error(ret));
+		return ret;
 	}
+	addr_range_t regs = hw_res.mem_ranges.ranges[0];
+	const int irq = hw_res.irqs.irqs[0];
+	hw_res_list_parsed_clean(&hw_res);
 
 	usb_log_debug("Memory mapped regs at %p (size %zu), IRQ %d.\n",
 	    RNGABSPTR(regs), RNGSZ(regs), irq);
 
-	rc = hc_register_irq_handler(device, &regs, irq, irq_handler);
-	if (rc != EOK) {
-		usb_log_error("Failed to register interrupt handler: %s.\n",
-		    str_error(rc));
-		goto error;
+	/* Initialize generic HCD driver */
+	ret = hcd_ddf_setup_hc(device, USB_SPEED_FULL,
+	    BANDWIDTH_AVAILABLE_USB11, bandwidth_count_usb11);
+	if (ret != EOK) {
+		usb_log_error("Failed to setup generic hcd structures: %s.",
+		    str_error(ret));
+		return ret;
 	}
 
-	ih_registered = true;
+	hc_t *hc = malloc(sizeof(hc_t));
+	if (!hc) {
+		usb_log_error("Failed to allocate driver structure.\n");
+		ret = ENOMEM;
+		goto ddf_hc_clean;
+	}
 
 	/* Try to enable interrupts */
 	bool interrupts = false;
-	rc = enable_interrupts(device);
-	if (rc != EOK) {
+	ret = hcd_ddf_setup_interrupts(device, &regs, irq, irq_handler,
+	    hc_gen_irq_code);
+	if (ret != EOK) {
 		usb_log_warning("Failed to enable interrupts: %s."
-		    " Falling back to polling\n", str_error(rc));
-		/* We don't need that handler */
-		unregister_interrupt_handler(device, irq);
-		ih_registered = false;
+		    " Falling back to polling\n", str_error(ret));
 	} else {
 		usb_log_debug("Hw interrupts enabled.\n");
@@ -214,45 +129,28 @@
 	}
 
-	rc = hc_init(&instance->hc, &regs, interrupts);
-	if (rc != EOK) {
-		usb_log_error("Failed to init ohci_hcd: %s.\n", str_error(rc));
-		goto error;
+	/* Initialize OHCI HC */
+	ret = hc_init(hc, &regs, interrupts);
+	if (ret != EOK) {
+		usb_log_error("Failed to init hc: %s.\n", str_error(ret));
+		goto unregister_irq;
 	}
 
-	hc_inited = true;
+	/* Connect OHCI to generic HCD */
+	hcd_set_implementation(dev_to_hcd(device), hc,
+	    hc_schedule, ohci_endpoint_init, ohci_endpoint_fini);
 
-	rc = ddf_fun_bind(instance->hc_fun);
-	if (rc != EOK) {
-		usb_log_error("Failed to bind OHCI device function: %s.\n",
-		    str_error(rc));
-		goto error;
+	/* HC should be running OK. We can add root hub */
+	ret = hcd_ddf_setup_root_hub(device);
+	if (ret != EOK) {
+		usb_log_error("Failed to register OHCI root hub: %s.\n",
+		    str_error(ret));
+		hc_fini(hc);
+unregister_irq:
+		unregister_interrupt_handler(device, irq);
+		free(hc);
+ddf_hc_clean:
+		hcd_ddf_clean_hc(device);
 	}
-
-	rc = ddf_fun_add_to_category(instance->hc_fun, USB_HC_CATEGORY);
-	if (rc != EOK) {
-		usb_log_error("Failed to add OHCI to HC category: %s.\n",
-		    str_error(rc));
-		goto error;
-	}
-
-	rc = hc_register_hub(&instance->hc, instance->rh_fun);
-	if (rc != EOK) {
-		usb_log_error("Failed to register OHCI root hub: %s.\n",
-		    str_error(rc));
-		goto error;
-	}
-
-	return EOK;
-
-error:
-	if (hc_inited)
-		hc_fini(&instance->hc);
-	if (ih_registered)
-		unregister_interrupt_handler(device, irq);
-	if (instance->hc_fun != NULL)
-		ddf_fun_destroy(instance->hc_fun);
-	if (instance->rh_fun != NULL)
-		ddf_fun_destroy(instance->rh_fun);
-	return rc;
+	return ret;
 }
 /**
Index: uspace/drv/bus/usb/ohci/ohci.h
===================================================================
--- uspace/drv/bus/usb/ohci/ohci.h	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/ohci/ohci.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -34,5 +34,4 @@
 #ifndef DRV_OHCI_OHCI_H
 #define DRV_OHCI_OHCI_H
-#include <ddi.h>
 #include <ddf/driver.h>
 
Index: uspace/drv/bus/usb/ohci/ohci_batch.c
===================================================================
--- uspace/drv/bus/usb/ohci/ohci_batch.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/ohci/ohci_batch.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -32,7 +32,10 @@
  * @brief OHCI driver USB transaction structure
  */
+
+#include <assert.h>
 #include <errno.h>
-#include <str_error.h>
 #include <macros.h>
+#include <mem.h>
+#include <stdbool.h>
 
 #include <usb/usb.h>
Index: uspace/drv/bus/usb/ohci/ohci_batch.h
===================================================================
--- uspace/drv/bus/usb/ohci/ohci_batch.h	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/ohci/ohci_batch.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -36,6 +36,6 @@
 
 #include <adt/list.h>
-#include <usbhc_iface.h>
-#include <usb/usb.h>
+#include <assert.h>
+#include <stdbool.h>
 #include <usb/host/usb_transfer_batch.h>
 
Index: uspace/drv/bus/usb/ohci/ohci_endpoint.c
===================================================================
--- uspace/drv/bus/usb/ohci/ohci_endpoint.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/ohci/ohci_endpoint.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -32,4 +32,8 @@
  * @brief OHCI driver
  */
+
+#include <assert.h>
+#include <stdlib.h>
+
 #include "utils/malloc32.h"
 #include "ohci_endpoint.h"
@@ -90,5 +94,5 @@
 	endpoint_set_hc_data(
 	    ep, ohci_ep, ohci_ep_toggle_get, ohci_ep_toggle_set);
-	hc_enqueue_endpoint(hcd->private_data, ep);
+	hc_enqueue_endpoint(hcd->driver.data, ep);
 	return EOK;
 }
@@ -104,5 +108,5 @@
 	assert(ep);
 	ohci_endpoint_t *instance = ohci_endpoint_get(ep);
-	hc_dequeue_endpoint(hcd->private_data, ep);
+	hc_dequeue_endpoint(hcd->driver.data, ep);
 	if (instance) {
 		free32(instance->ed);
Index: uspace/drv/bus/usb/ohci/ohci_regs.h
===================================================================
--- uspace/drv/bus/usb/ohci/ohci_regs.h	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/ohci/ohci_regs.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -34,12 +34,12 @@
 #ifndef DRV_OHCI_OHCI_REGS_H
 #define DRV_OHCI_OHCI_REGS_H
+#include <ddi.h>
 #include <sys/types.h>
 #include <byteorder.h>
 
-#define OHCI_WR(reg, val) reg = host2uint32_t_le(val)
-#define OHCI_RD(reg) uint32_t_le2host(reg)
-#define OHCI_SET(reg, val) reg |= host2uint32_t_le(val)
-#define OHCI_CLR(reg, val) reg &= host2uint32_t_le(~val)
-
+#define OHCI_WR(reg, val) pio_write_32(&(reg), host2uint32_t_le(val))
+#define OHCI_RD(reg) uint32_t_le2host(pio_read_32(&(reg)))
+#define OHCI_SET(reg, val) pio_set_32(&(reg), host2uint32_t_le(val), 1)
+#define OHCI_CLR(reg, val) pio_clear_32(&(reg), host2uint32_t_le(val), 1)
 
 #define LEGACY_REGS_OFFSET 0x100
@@ -215,14 +215,14 @@
 	/** Root hub per port status */
 	ioport32_t rh_port_status[];
-#define RHPS_CCS_FLAG (1 << 0) /* r: current connect status,
+#define RHPS_CCS_FLAG (1 << 0)                /* r: current connect status,
                                                * w: 1-clear port enable, 0-N/S*/
 #define RHPS_CLEAR_PORT_ENABLE RHPS_CCS_FLAG
-#define RHPS_PES_FLAG (1 << 1) /* r: port enable status
+#define RHPS_PES_FLAG (1 << 1)               /* r: port enable status
                                               * w: 1-set port enable, 0-N/S */
 #define RHPS_SET_PORT_ENABLE RHPS_PES_FLAG
-#define RHPS_PSS_FLAG (1 << 2) /* r: port suspend status
+#define RHPS_PSS_FLAG (1 << 2)                /* r: port suspend status
                                                * w: 1-set port suspend, 0-N/S */
 #define RHPS_SET_PORT_SUSPEND RHPS_PSS_FLAG
-#define RHPS_POCI_FLAG (1 << 3) /* r: port over-current
+#define RHPS_POCI_FLAG (1 << 3)                /* r: port over-current
                                                 * (if reports are per-port
                                                 * w: 1-clear port suspend
@@ -230,11 +230,11 @@
                                                 *    0-nothing */
 #define RHPS_CLEAR_PORT_SUSPEND RHPS_POCI_FLAG
-#define RHPS_PRS_FLAG (1 << 4) /* r: port reset status
+#define RHPS_PRS_FLAG (1 << 4)                /* r: port reset status
                                                * w: 1-set port reset, 0-N/S */
 #define RHPS_SET_PORT_RESET RHPS_PRS_FLAG
-#define RHPS_PPS_FLAG (1 << 8) /* r: port power status
+#define RHPS_PPS_FLAG (1 << 8)               /* r: port power status
                                               * w: 1-set port power, 0-N/S */
 #define RHPS_SET_PORT_POWER RHPS_PPS_FLAG
-#define RHPS_LSDA_FLAG (1 << 9) /* r: low speed device attached
+#define RHPS_LSDA_FLAG (1 << 9)                /* r: low speed device attached
                                                 * w: 1-clear port power, 0-N/S*/
 #define RHPS_CLEAR_PORT_POWER RHPS_LSDA_FLAG
Index: uspace/drv/bus/usb/ohci/ohci_rh.c
===================================================================
--- uspace/drv/bus/usb/ohci/ohci_rh.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
+++ uspace/drv/bus/usb/ohci/ohci_rh.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -0,0 +1,530 @@
+/*
+ * Copyright (c) 2013 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
+ */
+
+#include <assert.h>
+#include <errno.h>
+#include <mem.h>
+#include <sys/types.h>
+
+#include <usb/classes/hub.h>
+#include <usb/debug.h>
+#include <usb/descriptor.h>
+#include <usb/request.h>
+#include <usb/usb.h>
+
+#include <usb/host/endpoint.h>
+#include <usbvirt/device.h>
+
+#include "ohci_rh.h"
+
+enum {
+	HUB_STATUS_CHANGE_PIPE = 1,
+};
+
+static usbvirt_device_ops_t ops;
+
+/** Initialize internal USB HUB class descriptor.
+ * @param instance OHCI root hub.
+ * Use register based info to create accurate descriptor.
+ */
+static void ohci_rh_hub_desc_init(ohci_rh_t *instance)
+{
+	assert(instance);
+	const unsigned dsize = sizeof(usb_hub_descriptor_header_t) +
+	    STATUS_BYTES(instance->port_count) * 2;
+	assert(dsize <= sizeof(instance->hub_descriptor));
+	const uint32_t hub_desc = OHCI_RD(instance->registers->rh_desc_a);
+	const uint32_t port_desc = OHCI_RD(instance->registers->rh_desc_b);
+
+	instance->hub_descriptor.header.length = dsize;
+	instance->hub_descriptor.header.descriptor_type = USB_DESCTYPE_HUB;
+	instance->hub_descriptor.header.port_count = instance->port_count;
+	instance->hub_descriptor.header.characteristics = 0 |
+	    /* Bits 0,1 indicate power switching mode */
+	    ((hub_desc & RHDA_PSM_FLAG)  ? 0x01 : 0) |
+	    ((hub_desc & RHDA_NPS_FLAG)  ? 0x02 : 0) |
+	    /* Bit 2 indicates device type (compound device) */
+	    ((hub_desc & RHDA_DT_FLAG)   ? 0x04 : 0) |
+	    /* Bits 3,4 indicate over-current protection mode */
+	    ((hub_desc & RHDA_OCPM_FLAG) ? 0x08 : 0) |
+	    ((hub_desc & RHDA_NOCP_FLAG) ? 0x10 : 0);
+	instance->hub_descriptor.header.power_good_time =
+	    hub_desc >> RHDA_POTPGT_SHIFT;
+	/* bHubContrCurrent, root hubs don't need no power. */
+	instance->hub_descriptor.header.max_current = 0;
+
+	/* Device Removable and some legacy 1.0 stuff*/
+	instance->hub_descriptor.rempow[0] =
+	    (port_desc >> RHDB_DR_SHIFT) & 0xff;
+	if (STATUS_BYTES(instance->port_count) == 1) {
+		instance->hub_descriptor.rempow[1] = 0xff;
+	} else {
+		instance->hub_descriptor.rempow[1] =
+		     ((port_desc >> RHDB_DR_SHIFT) >> 8) & 0xff;
+	}
+
+	instance->hub_descriptor.rempow[2] = 0xff;
+	instance->hub_descriptor.rempow[3] = 0xff;
+
+}
+/** Initialize OHCI root hub.
+ * @param instance Place to initialize.
+ * @param regs OHCI device registers.
+ * @param name Device name.
+ * return Error code, EOK on success.
+ *
+ * Selects preconfigured port powering mode, sets up descriptor, and
+ * initializes internal virtual hub.
+ */
+int ohci_rh_init(ohci_rh_t *instance, ohci_regs_t *regs, const char *name)
+{
+	assert(instance);
+	instance->registers = regs;
+	instance->port_count = OHCI_RD(regs->rh_desc_a) & RHDA_NDS_MASK;
+	usb_log_debug2("rh_desc_a: %x.\n", OHCI_RD(regs->rh_desc_a));
+	if (instance->port_count > OHCI_MAX_PORTS) {
+		usb_log_warning("OHCI specification does not allow %d ports. "
+		    "Max %d ports will be used.\n", instance->port_count,
+		    OHCI_MAX_PORTS);
+		instance->port_count = OHCI_MAX_PORTS;
+	}
+	usb_log_info("%s: Found %u ports.\n", name, instance->port_count);
+
+#if defined OHCI_POWER_SWITCH_no
+	usb_log_info("%s: Set power mode to no power switching.\n", name);
+	/* Set port power mode to no power-switching. (always on) */
+	OHCI_SET(regs->rh_desc_a, RHDA_NPS_FLAG);
+
+	/* Set to no over-current reporting */
+	OHCI_SET(regs->rh_desc_a, RHDA_NOCP_FLAG);
+
+#elif defined OHCI_POWER_SWITCH_ganged
+	usb_log_info("%s: Set power mode to ganged power switching.\n", name);
+	/* Set port power mode to ganged power-switching. */
+	OHCI_CLR(regs->rh_desc_a, RHDA_NPS_FLAG);
+	OHCI_CLR(regs->rh_desc_a, RHDA_PSM_FLAG);
+
+	/* Turn off power (hub driver will turn this back on)*/
+	OHCI_WR(regs->rh_status, RHS_CLEAR_GLOBAL_POWER);
+
+	/* Set to global over-current */
+	OHCI_CLR(regs->rh_desc_a, RHDA_NOCP_FLAG);
+	OHCI_CLR(regs->rh_desc_a, RHDA_OCPM_FLAG);
+#else
+	usb_log_info("%s: Set power mode to per-port power switching.\n", name);
+	/* Set port power mode to per port power-switching. */
+	OHCI_CLR(regs->rh_desc_a, RHDA_NPS_FLAG);
+	OHCI_SET(regs->rh_desc_a, RHDA_PSM_FLAG);
+
+	/* Control all ports by global switch and turn them off */
+	OHCI_CLR(regs->rh_desc_b, RHDB_PCC_MASK << RHDB_PCC_SHIFT);
+	OHCI_WR(regs->rh_status, RHS_CLEAR_GLOBAL_POWER);
+
+	/* Return control to per port state */
+	OHCI_SET(regs->rh_desc_b, RHDB_PCC_MASK << RHDB_PCC_SHIFT);
+
+	/* Set per port over-current */
+	OHCI_CLR(regs->rh_desc_a, RHDA_NOCP_FLAG);
+	OHCI_SET(regs->rh_desc_a, RHDA_OCPM_FLAG);
+#endif
+
+	ohci_rh_hub_desc_init(instance);
+	instance->unfinished_interrupt_transfer = NULL;
+	return virthub_base_init(&instance->base, name, &ops, instance,
+	    NULL, &instance->hub_descriptor.header, HUB_STATUS_CHANGE_PIPE);
+}
+
+/** Schedule USB request.
+ * @param instance OCHI root hub instance.
+ * @param batch USB requst batch to schedule.
+ * @return Always EOK.
+ * Most requests complete even before this function returns,
+ * status change requests might be postponed until there is something to report.
+ */
+int ohci_rh_schedule(ohci_rh_t *instance, usb_transfer_batch_t *batch)
+{
+	assert(instance);
+	assert(batch);
+	const usb_target_t target = {{
+		.address = batch->ep->address,
+		.endpoint = batch->ep->endpoint,
+	}};
+	batch->error = virthub_base_request(&instance->base, target,
+	    usb_transfer_batch_direction(batch), (void*)batch->setup_buffer,
+	    batch->buffer, batch->buffer_size, &batch->transfered_size);
+	if (batch->error == ENAK) {
+		/* This is safe because only status change interrupt transfers
+		 * return NAK. The assertion holds true because the batch
+		 * existence prevents communication with that ep */
+		assert(instance->unfinished_interrupt_transfer == NULL);
+		instance->unfinished_interrupt_transfer = batch;
+	} else {
+		usb_transfer_batch_finish(batch, NULL);
+		usb_transfer_batch_destroy(batch);
+	}
+	return EOK;
+}
+
+/** Handle OHCI RHSC interrupt.
+ * @param instance OHCI root hub isntance.
+ * @return Always EOK.
+ *
+ * Interrupt means there is a change of status to report. It may trigger
+ * processing of a postponed request.
+ */
+int ohci_rh_interrupt(ohci_rh_t *instance)
+{
+	//TODO atomic swap needed
+	usb_transfer_batch_t *batch = instance->unfinished_interrupt_transfer;
+	instance->unfinished_interrupt_transfer = NULL;
+	if (batch) {
+		const usb_target_t target = {{
+			.address = batch->ep->address,
+			.endpoint = batch->ep->endpoint,
+		}};
+		batch->error = virthub_base_request(&instance->base, target,
+		    usb_transfer_batch_direction(batch),
+		    (void*)batch->setup_buffer,
+		    batch->buffer, batch->buffer_size, &batch->transfered_size);
+		usb_transfer_batch_finish(batch, NULL);
+		usb_transfer_batch_destroy(batch);
+	}
+	return EOK;
+}
+
+/* HUB ROUTINES IMPLEMENTATION */
+#define TEST_SIZE_INIT(size, port, hub) \
+do { \
+	hub = virthub_get_data(device); \
+	assert(hub);\
+	if (uint16_usb2host(setup_packet->length) != size) \
+		return ESTALL; \
+	port = uint16_usb2host(setup_packet->index) - 1; \
+	if (port > hub->port_count) \
+		return EINVAL; \
+} while (0)
+
+/** Hub status request handler.
+ * @param device Virtual hub device
+ * @param setup_packet USB setup stage data.
+ * @param[out] data destination data buffer, size must be at least
+ *             setup_packet->length bytes
+ * @param[out] act_size Sized of the valid response part of the buffer.
+ * @return Error code.
+ */
+static int req_get_status(usbvirt_device_t *device,
+    const usb_device_request_setup_packet_t *setup_packet,
+    uint8_t *data, size_t *act_size)
+{
+	ohci_rh_t *hub = virthub_get_data(device);
+	assert(hub);
+	if (uint16_usb2host(setup_packet->length) != 4)
+		return ESTALL;
+	const uint32_t val = OHCI_RD(hub->registers->rh_status) &
+	    (RHS_LPS_FLAG | RHS_LPSC_FLAG | RHS_OCI_FLAG | RHS_OCIC_FLAG);
+	memcpy(data, &val, sizeof(val));
+	*act_size = sizeof(val);
+	return EOK;
+}
+
+/** Hub set feature request handler.
+ * @param device Virtual hub device
+ * @param setup_packet USB setup stage data.
+ * @param[out] data destination data buffer, size must be at least
+ *             setup_packet->length bytes
+ * @param[out] act_size Sized of the valid response part of the buffer.
+ * @return Error code.
+ */
+static int req_clear_hub_feature(usbvirt_device_t *device,
+    const usb_device_request_setup_packet_t *setup_packet,
+    uint8_t *data, size_t *act_size)
+{
+	ohci_rh_t *hub = virthub_get_data(device);
+	assert(hub);
+
+	/*
+	 * Chapter 11.16.2 specifies that only C_HUB_LOCAL_POWER and
+	 * C_HUB_OVER_CURRENT are supported.
+	 * C_HUB_LOCAL_POWER is not supported
+	 * because root hubs do not support local power status feature.
+	 * C_HUB_OVER_CURRENT is represented by OHCI RHS_OCIC_FLAG.
+	 * (OHCI pg. 127)
+	 */
+	const unsigned feature = uint16_usb2host(setup_packet->value);
+	if (feature == USB_HUB_FEATURE_C_HUB_OVER_CURRENT) {
+		OHCI_WR(hub->registers->rh_status, RHS_OCIC_FLAG);
+	}
+	return EOK;
+}
+
+/** Port status request handler.
+ * @param device Virtual hub device
+ * @param setup_packet USB setup stage data.
+ * @param[out] data destination data buffer, size must be at least
+ *             setup_packet->length bytes
+ * @param[out] act_size Sized of the valid response part of the buffer.
+ * @return Error code.
+ */
+static int req_get_port_status(usbvirt_device_t *device,
+    const usb_device_request_setup_packet_t *setup_packet,
+    uint8_t *data, size_t *act_size)
+{
+	ohci_rh_t *hub;
+	unsigned port;
+	TEST_SIZE_INIT(4, port, hub);
+	if (setup_packet->value != 0)
+		return EINVAL;
+
+	const uint32_t status = OHCI_RD(hub->registers->rh_port_status[port]);
+	memcpy(data, &status, sizeof(status));
+	*act_size = sizeof(status);
+	return EOK;
+}
+
+/** Port clear feature request handler.
+ * @param device Virtual hub device
+ * @param setup_packet USB setup stage data.
+ * @param[out] data destination data buffer, size must be at least
+ *             setup_packet->length bytes
+ * @param[out] act_size Sized of the valid response part of the buffer.
+ * @return Error code.
+ */
+static int req_clear_port_feature(usbvirt_device_t *device,
+    const usb_device_request_setup_packet_t *setup_packet,
+    uint8_t *data, size_t *act_size)
+{
+	ohci_rh_t *hub;
+	unsigned port;
+	TEST_SIZE_INIT(0, port, hub);
+	const unsigned feature = uint16_usb2host(setup_packet->value);
+	/* Enabled features to clear: see page 269 of USB specs */
+	switch (feature)
+	{
+	case USB_HUB_FEATURE_PORT_POWER:          /*8*/
+		{
+			const uint32_t rhda =
+			    OHCI_RD(hub->registers->rh_desc_a);
+			/* No power switching */
+			if (rhda & RHDA_NPS_FLAG)
+				return ENOTSUP;
+			/* Ganged power switching, one port powers all */
+			if (!(rhda & RHDA_PSM_FLAG)) {
+				OHCI_WR(hub->registers->rh_status,
+				    RHS_CLEAR_GLOBAL_POWER);
+				return EOK;
+			}
+			OHCI_WR(hub->registers->rh_port_status[port],
+			    RHPS_CLEAR_PORT_POWER);
+			return EOK;
+		}
+
+	case USB_HUB_FEATURE_PORT_ENABLE:         /*1*/
+		OHCI_WR(hub->registers->rh_port_status[port],
+		    RHPS_CLEAR_PORT_ENABLE);
+		return EOK;
+
+	case USB_HUB_FEATURE_PORT_SUSPEND:        /*2*/
+		OHCI_WR(hub->registers->rh_port_status[port],
+		    RHPS_CLEAR_PORT_SUSPEND);
+		return EOK;
+
+	case USB_HUB_FEATURE_C_PORT_CONNECTION:   /*16*/
+	case USB_HUB_FEATURE_C_PORT_ENABLE:       /*17*/
+	case USB_HUB_FEATURE_C_PORT_SUSPEND:      /*18*/
+	case USB_HUB_FEATURE_C_PORT_OVER_CURRENT: /*19*/
+	case USB_HUB_FEATURE_C_PORT_RESET:        /*20*/
+		usb_log_debug2("Clearing port C_CONNECTION, C_ENABLE, "
+		    "C_SUSPEND, C_OC or C_RESET on port %"PRIu16".\n", port);
+		/* Bit offsets correspond to the feature number */
+		OHCI_WR(hub->registers->rh_port_status[port],
+		    1 << feature);
+		return EOK;
+
+	default:
+		return ENOTSUP;
+	}
+}
+
+/** Port set feature request handler.
+ * @param device Virtual hub device
+ * @param setup_packet USB setup stage data.
+ * @param[out] data destination data buffer, size must be at least
+ *             setup_packet->length bytes
+ * @param[out] act_size Sized of the valid response part of the buffer.
+ * @return Error code.
+ */
+static int req_set_port_feature(usbvirt_device_t *device,
+    const usb_device_request_setup_packet_t *setup_packet,
+    uint8_t *data, size_t *act_size)
+{
+	ohci_rh_t *hub;
+	unsigned port;
+	TEST_SIZE_INIT(0, port, hub);
+	const unsigned feature = uint16_usb2host(setup_packet->value);
+	switch (feature) {
+	case USB_HUB_FEATURE_PORT_POWER:   /*8*/
+	{
+		const uint32_t rhda = OHCI_RD(hub->registers->rh_desc_a);
+		/* No power switching */
+		if (rhda & RHDA_NPS_FLAG)
+			return EOK;
+		/* Ganged power switching, one port powers all */
+		if (!(rhda & RHDA_PSM_FLAG)) {
+			OHCI_WR(hub->registers->rh_status,RHS_SET_GLOBAL_POWER);
+			return EOK;
+		}
+	}
+	/* Fall through, for per port power */
+	case USB_HUB_FEATURE_PORT_ENABLE:  /*1*/
+	case USB_HUB_FEATURE_PORT_SUSPEND: /*2*/
+	case USB_HUB_FEATURE_PORT_RESET:   /*4*/
+		usb_log_debug2("Setting port POWER, ENABLE, SUSPEND or RESET "
+		    "on port %"PRIu16".\n", port);
+		/* Bit offsets correspond to the feature number */
+		OHCI_WR(hub->registers->rh_port_status[port], 1 << feature);
+		return EOK;
+	default:
+		return ENOTSUP;
+	}
+}
+
+/** Status change handler.
+ * @param device Virtual hub device
+ * @param endpoint Endpoint number
+ * @param tr_type Transfer type
+ * @param buffer Response destination
+ * @param buffer_size Bytes available in buffer
+ * @param actual_size Size us the used part of the dest buffer.
+ *
+ * Produces status mask. Bit 0 indicates hub status change the other bits
+ * represent port status change. Endian does not matter as UHCI root hubs
+ * only need 1 byte.
+ */
+static int req_status_change_handler(usbvirt_device_t *device,
+    usb_endpoint_t endpoint, usb_transfer_type_t tr_type,
+    void *buffer, size_t buffer_size, size_t *actual_size)
+{
+	ohci_rh_t *hub = virthub_get_data(device);
+	assert(hub);
+
+	if (buffer_size < STATUS_BYTES(hub->port_count))
+		return ESTALL;
+
+	uint16_t mask = 0;
+
+	/* Only local power source change and over-current change can happen */
+	if (OHCI_RD(hub->registers->rh_status) & (RHS_LPSC_FLAG | RHS_OCIC_FLAG)) {
+		mask |= 1;
+	}
+
+	for (unsigned port = 1; port <= hub->port_count; ++port) {
+		/* Write-clean bits are those that indicate change */
+		if (OHCI_RD(hub->registers->rh_port_status[port - 1])
+		    & RHPS_CHANGE_WC_MASK) {
+			mask |= (1 << port);
+		}
+	}
+
+	usb_log_debug2("OHCI root hub interrupt mask: %hx.\n", mask);
+
+	if (mask == 0)
+		return ENAK;
+	mask = uint16_host2usb(mask);
+	memcpy(buffer, &mask, STATUS_BYTES(hub->port_count));
+	*actual_size = STATUS_BYTES(hub->port_count);
+	return EOK;
+}
+
+/** OHCI root hub request handlers */
+static const usbvirt_control_request_handler_t control_transfer_handlers[] = {
+	{
+		STD_REQ_IN(USB_REQUEST_RECIPIENT_DEVICE, USB_DEVREQ_GET_DESCRIPTOR),
+		.name = "GetDescriptor",
+		.callback = virthub_base_get_hub_descriptor,
+	},
+	{
+		CLASS_REQ_IN(USB_REQUEST_RECIPIENT_DEVICE, USB_DEVREQ_GET_DESCRIPTOR),
+		.name = "GetDescriptor",
+		.callback = virthub_base_get_hub_descriptor,
+	},
+	{
+		CLASS_REQ_IN(USB_REQUEST_RECIPIENT_DEVICE, USB_HUB_REQUEST_GET_DESCRIPTOR),
+		.name = "GetHubDescriptor",
+		.callback = virthub_base_get_hub_descriptor,
+	},
+	{
+		CLASS_REQ_IN(USB_REQUEST_RECIPIENT_OTHER, USB_HUB_REQUEST_GET_STATUS),
+		.name = "GetPortStatus",
+		.callback = req_get_port_status,
+	},
+	{
+		CLASS_REQ_OUT(USB_REQUEST_RECIPIENT_DEVICE, USB_HUB_REQUEST_CLEAR_FEATURE),
+		.name = "ClearHubFeature",
+		.callback = req_clear_hub_feature,
+	},
+	{
+		CLASS_REQ_OUT(USB_REQUEST_RECIPIENT_OTHER, USB_HUB_REQUEST_CLEAR_FEATURE),
+		.name = "ClearPortFeature",
+		.callback = req_clear_port_feature,
+	},
+	{
+		CLASS_REQ_IN(USB_REQUEST_RECIPIENT_DEVICE, USB_HUB_REQUEST_GET_STATUS),
+		.name = "GetHubStatus",
+		.callback = req_get_status,
+	},
+	{
+		CLASS_REQ_IN(USB_REQUEST_RECIPIENT_OTHER, USB_HUB_REQUEST_GET_STATUS),
+		.name = "GetPortStatus",
+		.callback = req_get_port_status,
+	},
+	{
+		CLASS_REQ_OUT(USB_REQUEST_RECIPIENT_DEVICE, USB_HUB_REQUEST_SET_FEATURE),
+		.name = "SetHubFeature",
+		.callback = req_nop,
+	},
+	{
+		CLASS_REQ_OUT(USB_REQUEST_RECIPIENT_OTHER, USB_HUB_REQUEST_SET_FEATURE),
+		.name = "SetPortFeature",
+		.callback = req_set_port_feature,
+	},
+	{
+		.callback = NULL
+	}
+};
+
+/** Virtual OHCI root hub ops */
+static usbvirt_device_ops_t ops = {
+        .control = control_transfer_handlers,
+        .data_in[HUB_STATUS_CHANGE_PIPE] = req_status_change_handler,
+};
Index: uspace/drv/bus/usb/ohci/ohci_rh.h
===================================================================
--- uspace/drv/bus/usb/ohci/ohci_rh.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
+++ uspace/drv/bus/usb/ohci/ohci_rh.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2013 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_OHCI_RH_H
+#define DRV_OHCI_OHCI_RH_H
+
+#include <assert.h>
+#include <sys/types.h>
+
+#include <usb/usb.h>
+#include <usb/classes/hub.h>
+#include <usb/host/usb_transfer_batch.h>
+#include <usbvirt/virthub_base.h>
+
+#include "ohci_regs.h"
+
+enum {
+	OHCI_MAX_PORTS = 15,
+};
+
+typedef struct {
+	/** Virtual hub instance */
+	virthub_base_t base;
+	/** OHCI device registers */
+	ohci_regs_t *registers;
+	/** Number of downstream ports, OHCI limits this to 15 */
+	unsigned port_count;
+	/** USB hub descriptor describing the OHCI root hub */
+	struct {
+		usb_hub_descriptor_header_t header;
+		uint8_t rempow[STATUS_BYTES(OHCI_MAX_PORTS) * 2];
+	} __attribute__((packed)) hub_descriptor;
+	/** interrupt transfer waiting for an actual interrupt to occur */
+	usb_transfer_batch_t *unfinished_interrupt_transfer;
+} ohci_rh_t;
+
+int ohci_rh_init(ohci_rh_t *instance, ohci_regs_t *regs, const char *name);
+int ohci_rh_schedule(ohci_rh_t *instance, usb_transfer_batch_t *batch);
+int ohci_rh_interrupt(ohci_rh_t *instance);
+
+/** Get OHCI rh address.
+ *
+ * @param instance UHCI rh instance.
+ * @return USB address assigned to the hub.
+ * Wrapper for virtual hub address
+ */
+static inline usb_address_t ohci_rh_get_address(ohci_rh_t *instance)
+{
+	assert(instance);
+	return virthub_base_get_address(&instance->base);
+}
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/bus/usb/ohci/res.c
===================================================================
--- uspace/drv/bus/usb/ohci/res.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ 	(revision )
@@ -1,108 +1,0 @@
-/*
- * Copyright (c) 2011 Jan Vesely
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**
- * @addtogroup drvusbohci
- * @{
- */
-/**
- * @file
- * PCI related functions needed by the OHCI driver.
- */
-
-#include <errno.h>
-#include <assert.h>
-#include <devman.h>
-#include <device/hw_res_parsed.h>
-
-#include <usb/debug.h>
-
-#include "res.h"
-
-/** Get address of registers and IRQ for given device.
- *
- * @param[in] dev Device asking for the addresses.
- * @param[out] p_regs Pointer to register range.
- * @param[out] irq_no IRQ assigned to the device.
- * @return Error code.
- */
-int get_my_registers(ddf_dev_t *dev, addr_range_t *p_regs, int *irq_no)
-{
-	assert(dev);
-
-	async_sess_t *parent_sess =
-	    devman_parent_device_connect(EXCHANGE_SERIALIZE,
-	    ddf_dev_get_handle(dev), IPC_FLAG_BLOCKING);
-	if (!parent_sess)
-		return ENOMEM;
-
-	hw_res_list_parsed_t hw_res;
-	hw_res_list_parsed_init(&hw_res);
-	const int ret = hw_res_get_list_parsed(parent_sess, &hw_res, 0);
-	async_hangup(parent_sess);
-	if (ret != EOK) {
-		return ret;
-	}
-
-	/* We want one irq and one mem range. */
-	if (hw_res.irqs.count != 1 || hw_res.mem_ranges.count != 1) {
-		hw_res_list_parsed_clean(&hw_res);
-		return EINVAL;
-	}
-
-	if (p_regs)
-		*p_regs = hw_res.mem_ranges.ranges[0];
-	if (irq_no)
-		*irq_no = hw_res.irqs.irqs[0];
-
-	hw_res_list_parsed_clean(&hw_res);
-	return EOK;
-}
-
-/** Call the PCI driver with a request to enable interrupts
- *
- * @param[in] device Device asking for interrupts
- * @return Error code.
- */
-int enable_interrupts(ddf_dev_t *device)
-{
-	async_sess_t *parent_sess =
-	    devman_parent_device_connect(EXCHANGE_SERIALIZE,
-	    ddf_dev_get_handle(device), IPC_FLAG_BLOCKING);
-	if (!parent_sess)
-		return ENOMEM;
-	
-	const bool enabled = hw_res_enable_interrupt(parent_sess);
-	async_hangup(parent_sess);
-	
-	return enabled ? EOK : EIO;
-}
-
-/**
- * @}
- */
Index: uspace/drv/bus/usb/ohci/res.h
===================================================================
--- uspace/drv/bus/usb/ohci/res.h	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ 	(revision )
@@ -1,47 +1,0 @@
-/*
- * 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 drvusbohci
- * @{
- */
-/** @file
- * PCI related functions needed by OHCI driver.
- */
-#ifndef DRV_OHCI_RES_H
-#define DRV_OHCI_RES_H
-
-#include <ddf/driver.h>
-#include <device/hw_res_parsed.h>
-
-int get_my_registers(ddf_dev_t *, addr_range_t *, int *);
-int enable_interrupts(ddf_dev_t *);
-
-#endif
-/**
- * @}
- */
-
Index: uspace/drv/bus/usb/ohci/root_hub.c
===================================================================
--- uspace/drv/bus/usb/ohci/root_hub.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ 	(revision )
@@ -1,843 +1,0 @@
-/*
- * Copyright (c) 2011 Jan Vesely
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/** @addtogroup drvusbohci
- * @{
- */
-/** @file
- * @brief OHCI driver
- */
-#include <assert.h>
-#include <byteorder.h>
-#include <errno.h>
-#include <str_error.h>
-#include <fibril_synch.h>
-
-#include <usb/usb.h>
-#include <usb/debug.h>
-#include <usb/dev/request.h>
-#include <usb/classes/hub.h>
-
-#include <usb/classes/classes.h>
-#include <usb/classes/hub.h>
-#include <usb/dev/driver.h>
-#include "ohci_regs.h"
-#include "root_hub.h"
-
-/**
- * standart device descriptor for ohci root hub
- */
-static const usb_standard_device_descriptor_t ohci_rh_device_descriptor = {
-	.configuration_count = 1,
-	.descriptor_type = USB_DESCTYPE_DEVICE,
-	.device_class = USB_CLASS_HUB,
-	.device_protocol = 0,
-	.device_subclass = 0,
-	.device_version = 0,
-	.length = sizeof(usb_standard_device_descriptor_t),
-	.max_packet_size = 64,
-	.vendor_id = 0x16db, /* HelenOS does not have USB vendor ID assigned.*/
-	.product_id = 0x0001,
-	.str_serial_number = 0,
-	.usb_spec_version = 0x110,
-};
-
-/**
- * standart configuration descriptor with filled common values
- * for ohci root hubs
- */
-static const usb_standard_configuration_descriptor_t ohci_rh_conf_descriptor = {
-	.attributes = 1 << 7,
-	.configuration_number = 1,
-	.descriptor_type = USB_DESCTYPE_CONFIGURATION,
-	.interface_count = 1,
-	.length = sizeof(usb_standard_configuration_descriptor_t),
-	.max_power = 0, /* root hubs don't need no power */
-	.str_configuration = 0,
-};
-
-/**
- * standart ohci root hub interface descriptor
- */
-static const usb_standard_interface_descriptor_t ohci_rh_iface_descriptor = {
-	.alternate_setting = 0,
-	.descriptor_type = USB_DESCTYPE_INTERFACE,
-	.endpoint_count = 1,
-	.interface_class = USB_CLASS_HUB,
-	.interface_number = 1,
-	.interface_protocol = 0,
-	.interface_subclass = 0,
-	.length = sizeof(usb_standard_interface_descriptor_t),
-	.str_interface = 0,
-};
-
-/**
- * standart ohci root hub endpoint descriptor
- */
-static const usb_standard_endpoint_descriptor_t ohci_rh_ep_descriptor = {
-	.attributes = USB_TRANSFER_INTERRUPT,
-	.descriptor_type = USB_DESCTYPE_ENDPOINT,
-	.endpoint_address = 1 | (1 << 7),
-	.length = sizeof(usb_standard_endpoint_descriptor_t),
-	.max_packet_size = 2,
-	.poll_interval = 255,
-};
-
-static void create_serialized_hub_descriptor(rh_t *instance);
-static void rh_init_descriptors(rh_t *instance);
-static uint16_t create_interrupt_mask(const rh_t *instance);
-static void get_status(const rh_t *instance, usb_transfer_batch_t *request);
-static void get_descriptor(const rh_t *instance, usb_transfer_batch_t *request);
-static void set_feature(const rh_t *instance, usb_transfer_batch_t *request);
-static void clear_feature(const rh_t *instance, usb_transfer_batch_t *request);
-static int set_feature_port(
-    const rh_t *instance, uint16_t feature, uint16_t port);
-static int clear_feature_port(
-    const rh_t *instance, uint16_t feature, uint16_t port);
-static void control_request(rh_t *instance, usb_transfer_batch_t *request);
-static inline void interrupt_request(
-    usb_transfer_batch_t *request, uint16_t mask, size_t size)
-{
-	assert(request);
-	usb_log_debug("Sending interrupt vector(%zu) %hhx:%hhx.\n",
-	    size, ((uint8_t*)&mask)[0], ((uint8_t*)&mask)[1]);
-	usb_transfer_batch_finish_error(request, &mask, size, EOK);
-	usb_transfer_batch_destroy(request);
-}
-
-#define TRANSFER_END_DATA(request, data, bytes) \
-do { \
-	usb_transfer_batch_finish_error(request, data, bytes, EOK); \
-	usb_transfer_batch_destroy(request); \
-	return; \
-} while (0)
-
-#define TRANSFER_END(request, error) \
-do { \
-	usb_transfer_batch_finish_error(request, NULL, 0, error); \
-	usb_transfer_batch_destroy(request); \
-	return; \
-} while (0)
-
-/** Root Hub driver structure initialization.
- *
- * Reads info registers and prepares descriptors. Sets power mode.
- */
-void rh_init(rh_t *instance, ohci_regs_t *regs)
-{
-	assert(instance);
-	assert(regs);
-
-	instance->registers = regs;
-	instance->port_count = OHCI_RD(regs->rh_desc_a) & RHDA_NDS_MASK;
-	usb_log_debug2("rh_desc_a: %x.\n", OHCI_RD(regs->rh_desc_a));
-	if (instance->port_count > 15) {
-		usb_log_warning("OHCI specification does not allow more than 15"
-		    " ports. Max 15 ports will be used");
-		instance->port_count = 15;
-	}
-
-	/* Don't forget the hub status bit and round up */
-	instance->interrupt_mask_size = 1 + (instance->port_count / 8);
-	instance->unfinished_interrupt_transfer = NULL;
-
-#if defined OHCI_POWER_SWITCH_no
-	usb_log_debug("OHCI rh: Set power mode to no power switching.\n");
-	/* Set port power mode to no power-switching. (always on) */
-	OHCI_SET(regs->rh_desc_a, RHDA_NPS_FLAG);
-
-	/* Set to no over-current reporting */
-	OHCI_SET(regs->rh_desc_a, RHDA_NOCP_FLAG);
-
-#elif defined OHCI_POWER_SWITCH_ganged
-	usb_log_debug("OHCI rh: Set power mode to ganged power switching.\n");
-	/* Set port power mode to ganged power-switching. */
-	OHCI_CLR(regs->rh_desc_a, RHDA_NPS_FLAG);
-	OHCI_CLR(regs->rh_desc_a, RHDA_PSM_FLAG);
-
-	/* Turn off power (hub driver will turn this back on)*/
-	OHCI_WR(regs->rh_status, RHS_CLEAR_GLOBAL_POWER);
-
-	/* Set to global over-current */
-	OHCI_CLR(regs->rh_desc_a, RHDA_NOCP_FLAG);
-	OHCI_CLR(regs->rh_desc_a, RHDA_OCPM_FLAG);
-#else
-	usb_log_debug("OHCI rh: Set power mode to per-port power switching.\n");
-	/* Set port power mode to per port power-switching. */
-	OHCI_CLR(regs->rh_desc_a, RHDA_NPS_FLAG);
-	OHCI_SET(regs->rh_desc_a, RHDA_PSM_FLAG);
-
-	/* Control all ports by global switch and turn them off */
-	OHCI_CLR(regs->rh_desc_b, RHDB_PCC_MASK << RHDB_PCC_SHIFT);
-	OHCI_WR(regs->rh_status, RHS_CLEAR_GLOBAL_POWER);
-
-	/* Return control to per port state */
-	OHCI_SET(regs->rh_desc_b, RHDB_PCC_MASK << RHDB_PCC_SHIFT);
-
-	/* Set per port over-current */
-	OHCI_CLR(regs->rh_desc_a, RHDA_NOCP_FLAG);
-	OHCI_SET(regs->rh_desc_a, RHDA_OCPM_FLAG);
-#endif
-
-	fibril_mutex_initialize(&instance->guard);
-	rh_init_descriptors(instance);
-
-	usb_log_info("Root hub (%zu ports) initialized.\n",
-	    instance->port_count);
-}
-
-/**
- * Process root hub request.
- *
- * @param instance Root hub instance
- * @param request Structure containing both request and response information
- * @return Error code
- */
-void rh_request(rh_t *instance, usb_transfer_batch_t *request)
-{
-	assert(instance);
-	assert(request);
-
-	switch (request->ep->transfer_type)
-	{
-	case USB_TRANSFER_CONTROL:
-		usb_log_debug("Root hub got CONTROL packet\n");
-		control_request(instance, request);
-		break;
-
-	case USB_TRANSFER_INTERRUPT:
-		usb_log_debug("Root hub got INTERRUPT packet\n");
-		fibril_mutex_lock(&instance->guard);
-		assert(instance->unfinished_interrupt_transfer == NULL);
-		const uint16_t mask = create_interrupt_mask(instance);
-		if (mask == 0) {
-			usb_log_debug("No changes(%hx)...\n", mask);
-			instance->unfinished_interrupt_transfer = request;
-		} else {
-			usb_log_debug("Processing changes...\n");
-			interrupt_request(
-			    request, mask, instance->interrupt_mask_size);
-		}
-		fibril_mutex_unlock(&instance->guard);
-		break;
-
-	default:
-		usb_log_error("Root hub got unsupported request.\n");
-		TRANSFER_END(request, ENOTSUP);
-	}
-}
-
-/**
- * Process interrupt on a hub device.
- *
- * If there is no pending interrupt transfer, nothing happens.
- * @param instance
- */
-void rh_interrupt(rh_t *instance)
-{
-	assert(instance);
-
-	fibril_mutex_lock(&instance->guard);
-	if (instance->unfinished_interrupt_transfer) {
-		usb_log_debug("Finalizing interrupt transfer\n");
-		const uint16_t mask = create_interrupt_mask(instance);
-		interrupt_request(instance->unfinished_interrupt_transfer,
-		    mask, instance->interrupt_mask_size);
-		instance->unfinished_interrupt_transfer = NULL;
-	}
-	fibril_mutex_unlock(&instance->guard);
-}
-
-/**
- * Create hub descriptor.
- *
- * For descriptor format see USB hub specification (chapter 11.15.2.1, pg. 263)
- *
- * @param instance Root hub instance
- * @return Error code
- */
-void create_serialized_hub_descriptor(rh_t *instance)
-{
-	assert(instance);
-
-	/* 7 bytes + 2 port bit fields (port count + global bit) */
-	size_t size = 7 + (instance->interrupt_mask_size * 2);
-	assert(size <= HUB_DESCRIPTOR_MAX_SIZE);
-	instance->hub_descriptor_size = size;
-
-	const uint32_t hub_desc = OHCI_RD(instance->registers->rh_desc_a);
-	const uint32_t port_desc = OHCI_RD(instance->registers->rh_desc_b);
-
-	/* bDescLength */
-	instance->descriptors.hub[0] = size;
-	/* bDescriptorType */
-	instance->descriptors.hub[1] = USB_DESCTYPE_HUB;
-	/* bNmbrPorts */
-	instance->descriptors.hub[2] = instance->port_count;
-	/* wHubCharacteristics */
-	instance->descriptors.hub[3] = 0 |
-	    /* The lowest 2 bits indicate power switching mode */
-	    (((hub_desc & RHDA_PSM_FLAG)  ? 1 : 0) << 0) |
-	    (((hub_desc & RHDA_NPS_FLAG)  ? 1 : 0) << 1) |
-	    /* Bit 3 indicates device type (compound device) */
-	    (((hub_desc & RHDA_DT_FLAG)   ? 1 : 0) << 2) |
-	    /* Bits 4,5 indicate over-current protection mode */
-	    (((hub_desc & RHDA_OCPM_FLAG) ? 1 : 0) << 3) |
-	    (((hub_desc & RHDA_NOCP_FLAG) ? 1 : 0) << 4);
-
-	/* Reserved */
-	instance->descriptors.hub[4] = 0;
-	/* bPwrOn2PwrGood */
-	instance->descriptors.hub[5] = hub_desc >> RHDA_POTPGT_SHIFT;
-	/* bHubContrCurrent, root hubs don't need no power. */
-	instance->descriptors.hub[6] = 0;
-
-	/* Device Removable and some legacy 1.0 stuff*/
-	instance->descriptors.hub[7] = (port_desc >> RHDB_DR_SHIFT) & 0xff;
-	instance->descriptors.hub[8] = 0xff;
-	if (instance->interrupt_mask_size == 2) {
-		instance->descriptors.hub[8] =
-		    (port_desc >> RHDB_DR_SHIFT) >> 8;
-		instance->descriptors.hub[9]  = 0xff;
-		instance->descriptors.hub[10] = 0xff;
-	}
-}
-
-/** Initialize hub descriptors.
- *
- * A full configuration descriptor is assembled. The configuration and endpoint
- * descriptors have local modifications.
- * @param instance Root hub instance
- * @return Error code
- */
-void rh_init_descriptors(rh_t *instance)
-{
-	assert(instance);
-
-	instance->descriptors.configuration = ohci_rh_conf_descriptor;
-	instance->descriptors.interface = ohci_rh_iface_descriptor;
-	instance->descriptors.endpoint = ohci_rh_ep_descriptor;
-	create_serialized_hub_descriptor(instance);
-
-	instance->descriptors.endpoint.max_packet_size =
-	    instance->interrupt_mask_size;
-
-	instance->descriptors.configuration.total_length = uint16_host2usb(
-	    sizeof(usb_standard_configuration_descriptor_t) +
-	    sizeof(usb_standard_endpoint_descriptor_t) +
-	    sizeof(usb_standard_interface_descriptor_t) +
-	    instance->hub_descriptor_size);
-}
-
-/**
- * Create bitmap of changes to answer status interrupt.
- *
- * Result contains bitmap where bit 0 indicates change on hub and
- * bit i indicates change on i`th port (i>0). For more info see
- * Hub and Port status bitmap specification in USB specification
- * (chapter 11.13.4).
- * @param instance root hub instance
- * @return Mask of changes.
- */
-uint16_t create_interrupt_mask(const rh_t *instance)
-{
-	assert(instance);
-	uint16_t mask = 0;
-
-	/* Only local power source change and over-current change can happen */
-	if (OHCI_RD(instance->registers->rh_status)
-	    & (RHS_LPSC_FLAG | RHS_OCIC_FLAG)) {
-		mask |= 1;
-	}
-	for (size_t port = 1; port <= instance->port_count; ++port) {
-		/* Write-clean bits are those that indicate change */
-		if (OHCI_RD(instance->registers->rh_port_status[port - 1])
-		    & RHPS_CHANGE_WC_MASK) {
-			mask |= (1 << port);
-		}
-	}
-	usb_log_debug2("OHCI root hub interrupt mask: %hx.\n", mask);
-	return uint16_host2usb(mask);
-}
-
-/**
- * Create answer to status request.
- *
- * This might be either hub status or port status request. If neither,
- * ENOTSUP is returned.
- * @param instance root hub instance
- * @param request structure containing both request and response information
- * @return error code
- */
-void get_status(const rh_t *instance, usb_transfer_batch_t *request)
-{
-	assert(instance);
-	assert(request);
-
-
-	usb_device_request_setup_packet_t *request_packet =
-	    (usb_device_request_setup_packet_t*)request->setup_buffer;
-
-	const uint16_t index = uint16_usb2host(request_packet->index);
-
-	switch (request_packet->request_type)
-	{
-	case USB_HUB_REQ_TYPE_GET_HUB_STATUS:
-	/* Hub status: just filter relevant info from rh_status reg */
-		if (request->buffer_size < 4) {
-			usb_log_error("Buffer(%zu) too small for hub get "
-			    "status request.\n", request->buffer_size);
-			TRANSFER_END(request, EOVERFLOW);
-		} else {
-			const uint32_t data =
-			    OHCI_RD(instance->registers->rh_status) &
-			        (RHS_LPS_FLAG | RHS_LPSC_FLAG
-			            | RHS_OCI_FLAG | RHS_OCIC_FLAG);
-			TRANSFER_END_DATA(request, &data, sizeof(data));
-		}
-
-	/* Copy appropriate rh_port_status register, OHCI designers were
-	 * kind enough to make those bit values match USB specification */
-	case USB_HUB_REQ_TYPE_GET_PORT_STATUS:
-		if (request->buffer_size < 4) {
-			usb_log_error("Buffer(%zu) too small for hub get "
-			    "status request.\n", request->buffer_size);
-			TRANSFER_END(request, EOVERFLOW);
-		} else {
-			const unsigned port = index;
-			if (port < 1 || port > instance->port_count)
-				TRANSFER_END(request, EINVAL);
-			/* Register format matches the format of port status
-			 * field */
-			const uint32_t data = uint32_host2usb(OHCI_RD(
-			    instance->registers->rh_port_status[port - 1]));
-			TRANSFER_END_DATA(request, &data, sizeof(data));
-		}
-	case SETUP_REQUEST_TO_HOST(USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_DEVICE):
-		if (request->buffer_size < 2) {
-			usb_log_error("Buffer(%zu) too small for hub generic "
-			    "get status request.\n", request->buffer_size);
-			TRANSFER_END(request, EOVERFLOW);
-		} else {
-			const uint16_t data =
-			    uint16_host2usb(USB_DEVICE_STATUS_SELF_POWERED);
-			TRANSFER_END_DATA(request, &data, sizeof(data));
-		}
-
-	case SETUP_REQUEST_TO_HOST(USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_INTERFACE):
-		/* Hubs are allowed to have only one interface */
-		if (index != 0)
-			TRANSFER_END(request, EINVAL);
-		/* Fall through, as the answer will be the same: 0x0000 */
-	case SETUP_REQUEST_TO_HOST(USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_ENDPOINT):
-		/* Endpoint 0 (default control) and 1 (interrupt) */
-		if (index >= 2)
-			TRANSFER_END(request, EINVAL);
-
-		if (request->buffer_size < 2) {
-			usb_log_error("Buffer(%zu) too small for hub generic "
-			    "get status request.\n", request->buffer_size);
-			TRANSFER_END(request, EOVERFLOW);
-		} else {
-			/* Endpoints are OK. (We don't halt) */
-			const uint16_t data = 0;
-			TRANSFER_END_DATA(request, &data, sizeof(data));
-		}
-
-	default:
-		usb_log_error("Unsupported GET_STATUS request.\n");
-		TRANSFER_END(request, ENOTSUP);
-	}
-
-}
-
-/**
- * Create answer to a descriptor request.
- *
- * This might be a request for standard (configuration, device, endpoint or
- * interface) or device specific (hub) descriptor.
- * @param instance Root hub instance
- * @param request Structure containing both request and response information
- * @return Error code
- */
-void get_descriptor(const rh_t *instance, usb_transfer_batch_t *request)
-{
-	assert(instance);
-	assert(request);
-
-	usb_device_request_setup_packet_t *setup_request =
-	    (usb_device_request_setup_packet_t *) request->setup_buffer;
-	/* "The wValue field specifies the descriptor type in the high byte
-	 * and the descriptor index in the low byte (refer to Table 9-5)." */
-	const int desc_type = uint16_usb2host(setup_request->value) >> 8;
-	switch (desc_type)
-	{
-	case USB_DESCTYPE_HUB:
-		usb_log_debug2("USB_DESCTYPE_HUB\n");
-		/* Hub descriptor was generated locally.
-		 * Class specific request. */
-		TRANSFER_END_DATA(request, instance->descriptors.hub,
-		    instance->hub_descriptor_size);
-
-	case USB_DESCTYPE_DEVICE:
-		usb_log_debug2("USB_DESCTYPE_DEVICE\n");
-		/* Device descriptor is shared
-		 * (No one should ask for it, as the device is already setup)
-		 * Standard USB device request. */
-		TRANSFER_END_DATA(request, &ohci_rh_device_descriptor,
-		    sizeof(ohci_rh_device_descriptor));
-
-	case USB_DESCTYPE_CONFIGURATION:
-		usb_log_debug2("USB_DESCTYPE_CONFIGURATION\n");
-		/* Start with configuration and add others depending on
-		 * request size. Standard USB request. */
-		TRANSFER_END_DATA(request, &instance->descriptors,
-		    instance->descriptors.configuration.total_length);
-
-	case USB_DESCTYPE_INTERFACE:
-		usb_log_debug2("USB_DESCTYPE_INTERFACE\n");
-		/* Use local interface descriptor. There is one and it
-		 * might be modified. Hub driver should not ask or this
-		 * descriptor as it is not part of standard requests set. */
-		TRANSFER_END_DATA(request, &instance->descriptors.interface,
-		    sizeof(instance->descriptors.interface));
-
-	case USB_DESCTYPE_ENDPOINT:
-		/* Use local endpoint descriptor. There is one
-		 * it might have max_packet_size field modified. Hub driver
-		 * should not ask for this descriptor as it is not part
-		 * of standard requests set. */
-		usb_log_debug2("USB_DESCTYPE_ENDPOINT\n");
-		TRANSFER_END_DATA(request, &instance->descriptors.endpoint,
-		    sizeof(instance->descriptors.endpoint));
-
-	default:
-		usb_log_debug2("USB_DESCTYPE_EINVAL %d \n"
-		    "\ttype %d\n\trequest %d\n\tvalue "
-		    "%d\n\tindex %d\n\tlen %d\n ",
-		    setup_request->value,
-		    setup_request->request_type, setup_request->request,
-		    desc_type, setup_request->index,
-		    setup_request->length);
-		TRANSFER_END(request, EINVAL);
-	}
-
-	TRANSFER_END(request, ENOTSUP);
-}
-
-/**
- * process feature-enabling 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
- */
-int set_feature_port(const rh_t *instance, uint16_t feature, uint16_t port)
-{
-	assert(instance);
-
-	if (port < 1 || port > instance->port_count)
-		return EINVAL;
-
-	switch (feature) {
-	case USB_HUB_FEATURE_PORT_POWER:   /*8*/
-		{
-			const uint32_t rhda =
-			    OHCI_RD(instance->registers->rh_desc_a);
-			/* No power switching */
-			if (rhda & RHDA_NPS_FLAG)
-				return EOK;
-			/* Ganged power switching, one port powers all */
-			if (!(rhda & RHDA_PSM_FLAG)) {
-				OHCI_WR(instance->registers->rh_status,
-				    RHS_SET_GLOBAL_POWER);
-				return EOK;
-			}
-		}
-			/* Fall through */
-	case USB_HUB_FEATURE_PORT_ENABLE:  /*1*/
-	case USB_HUB_FEATURE_PORT_SUSPEND: /*2*/
-	case USB_HUB_FEATURE_PORT_RESET:   /*4*/
-		usb_log_debug2("Setting port POWER, ENABLE, SUSPEND or RESET "
-		    "on port %"PRIu16".\n", port);
-		OHCI_WR(instance->registers->rh_port_status[port - 1],
-		    1 << feature);
-		return EOK;
-	default:
-		return ENOTSUP;
-	}
-}
-
-/**
- * Process feature clear request.
- *
- * @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
- */
-int clear_feature_port(const rh_t *instance, uint16_t feature, uint16_t port)
-{
-	assert(instance);
-
-	if (port < 1 || port > instance->port_count)
-		return EINVAL;
-
-	/* Enabled features to clear: see page 269 of USB specs */
-	switch (feature)
-	{
-	case USB_HUB_FEATURE_PORT_POWER:          /*8*/
-		{
-			const uint32_t rhda =
-			    OHCI_RD(instance->registers->rh_desc_a);
-			/* No power switching */
-			if (rhda & RHDA_NPS_FLAG)
-				return ENOTSUP;
-			/* Ganged power switching, one port powers all */
-			if (!(rhda & RHDA_PSM_FLAG)) {
-				OHCI_WR(instance->registers->rh_status,
-				    RHS_CLEAR_GLOBAL_POWER);
-				return EOK;
-			}
-			OHCI_WR(instance->registers->rh_port_status[port - 1],
-			    RHPS_CLEAR_PORT_POWER);
-			return EOK;
-		}
-
-	case USB_HUB_FEATURE_PORT_ENABLE:         /*1*/
-		OHCI_WR(instance->registers->rh_port_status[port - 1],
-		    RHPS_CLEAR_PORT_ENABLE);
-		return EOK;
-
-	case USB_HUB_FEATURE_PORT_SUSPEND:        /*2*/
-		OHCI_WR(instance->registers->rh_port_status[port - 1],
-		    RHPS_CLEAR_PORT_SUSPEND);
-		return EOK;
-
-	case USB_HUB_FEATURE_C_PORT_CONNECTION:   /*16*/
-	case USB_HUB_FEATURE_C_PORT_ENABLE:       /*17*/
-	case USB_HUB_FEATURE_C_PORT_SUSPEND:      /*18*/
-	case USB_HUB_FEATURE_C_PORT_OVER_CURRENT: /*19*/
-	case USB_HUB_FEATURE_C_PORT_RESET:        /*20*/
-		usb_log_debug2("Clearing port C_CONNECTION, C_ENABLE, "
-		    "C_SUSPEND, C_OC or C_RESET on port %"PRIu16".\n", port);
-		/* Bit offsets correspond to the feature number */
-		OHCI_WR(instance->registers->rh_port_status[port - 1],
-		    1 << feature);
-		return EOK;
-
-	default:
-		return ENOTSUP;
-	}
-}
-
-/**
- * process one of requests that do not request nor carry additional data
- *
- * Request can be one of USB_DEVREQ_CLEAR_FEATURE, USB_DEVREQ_SET_FEATURE or
- * USB_DEVREQ_SET_ADDRESS.
- * @param instance root hub instance
- * @param request structure containing both request and response information
- * @return error code
- */
-void set_feature(const rh_t *instance, usb_transfer_batch_t *request)
-{
-	assert(instance);
-	assert(request);
-
-	usb_device_request_setup_packet_t *setup_request =
-	    (usb_device_request_setup_packet_t *) request->setup_buffer;
-	switch (setup_request->request_type)
-	{
-	case USB_HUB_REQ_TYPE_SET_PORT_FEATURE:
-		usb_log_debug("USB_HUB_REQ_TYPE_SET_PORT_FEATURE\n");
-		const int ret = set_feature_port(instance,
-		    setup_request->value, setup_request->index);
-		TRANSFER_END(request, ret);
-
-	case USB_HUB_REQ_TYPE_SET_HUB_FEATURE:
-		/* Chapter 11.16.2 specifies that hub can be recipient
-		 * only for C_HUB_LOCAL_POWER and C_HUB_OVER_CURRENT
-		 * features. It makes no sense to SET either. */
-		usb_log_error("Invalid HUB set feature request.\n");
-		TRANSFER_END(request, ENOTSUP);
-	//TODO: Consider standard USB requests: REMOTE WAKEUP, ENDPOINT STALL
-	default:
-		usb_log_error("Invalid set feature request type: %d\n",
-		    setup_request->request_type);
-		TRANSFER_END(request, ENOTSUP);
-	}
-}
-
-/**
- * process one of requests that do not request nor carry additional data
- *
- * Request can be one of USB_DEVREQ_CLEAR_FEATURE, USB_DEVREQ_SET_FEATURE or
- * USB_DEVREQ_SET_ADDRESS.
- * @param instance root hub instance
- * @param request structure containing both request and response information
- * @return error code
- */
-void clear_feature(const rh_t *instance, usb_transfer_batch_t *request)
-{
-	assert(instance);
-	assert(request);
-
-	usb_device_request_setup_packet_t *setup_request =
-	    (usb_device_request_setup_packet_t *) request->setup_buffer;
-
-	switch (setup_request->request_type)
-	{
-	case USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE:
-		usb_log_debug("USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE\n");
-		const int ret = clear_feature_port(instance,
-		    setup_request->value, setup_request->index);
-		TRANSFER_END(request, ret);
-
-	case USB_HUB_REQ_TYPE_CLEAR_HUB_FEATURE:
-		usb_log_debug("USB_HUB_REQ_TYPE_CLEAR_HUB_FEATURE\n");
-		/*
-		 * Chapter 11.16.2 specifies that only C_HUB_LOCAL_POWER and
-		 * C_HUB_OVER_CURRENT are supported.
-		 * C_HUB_OVER_CURRENT is represented by OHCI RHS_OCIC_FLAG.
-		 * C_HUB_LOCAL_POWER is not supported
-		 * as root hubs do not support local power status feature.
-		 * (OHCI pg. 127) */
-		if (uint16_usb2host(setup_request->value)
-		    == USB_HUB_FEATURE_C_HUB_OVER_CURRENT) {
-			OHCI_WR(instance->registers->rh_status, RHS_OCIC_FLAG);
-			TRANSFER_END(request, EOK);
-		}
-	//TODO: Consider standard USB requests: REMOTE WAKEUP, ENDPOINT STALL
-	default:
-		usb_log_error("Invalid clear feature request type: %d\n",
-		    setup_request->request_type);
-		TRANSFER_END(request, ENOTSUP);
-	}
-}
-
-/**
- * Process hub control request.
- *
- * If needed, writes answer into the request structure.
- * Request can be one of
- * USB_DEVREQ_GET_STATUS,
- * USB_DEVREQ_GET_DESCRIPTOR,
- * USB_DEVREQ_GET_CONFIGURATION,
- * USB_DEVREQ_CLEAR_FEATURE,
- * USB_DEVREQ_SET_FEATURE,
- * USB_DEVREQ_SET_ADDRESS,
- * USB_DEVREQ_SET_DESCRIPTOR or
- * USB_DEVREQ_SET_CONFIGURATION.
- *
- * @param instance root hub instance
- * @param request structure containing both request and response information
- * @return error code
- */
-void control_request(rh_t *instance, usb_transfer_batch_t *request)
-{
-	assert(instance);
-	assert(request);
-
-	if (!request->setup_buffer) {
-		usb_log_error("Root hub received empty transaction!");
-		TRANSFER_END(request, EBADMEM);
-	}
-
-	if (sizeof(usb_device_request_setup_packet_t) > request->setup_size) {
-		usb_log_error("Setup packet too small\n");
-		TRANSFER_END(request, EOVERFLOW);
-	}
-
-	usb_log_debug2("CTRL packet: %s.\n",
-	    usb_debug_str_buffer((uint8_t *) request->setup_buffer, 8, 8));
-	usb_device_request_setup_packet_t *setup_request =
-	    (usb_device_request_setup_packet_t *) request->setup_buffer;
-	switch (setup_request->request)
-	{
-	case USB_DEVREQ_GET_STATUS:
-		usb_log_debug("USB_DEVREQ_GET_STATUS\n");
-		get_status(instance, request);
-		break;
-
-	case USB_DEVREQ_GET_DESCRIPTOR:
-		usb_log_debug("USB_DEVREQ_GET_DESCRIPTOR\n");
-		get_descriptor(instance, request);
-		break;
-
-	case USB_DEVREQ_GET_CONFIGURATION:
-		usb_log_debug("USB_DEVREQ_GET_CONFIGURATION\n");
-		if (request->buffer_size == 0)
-			TRANSFER_END(request, EOVERFLOW);
-		const uint8_t config = 1;
-		TRANSFER_END_DATA(request, &config, sizeof(config));
-
-	case USB_DEVREQ_CLEAR_FEATURE:
-		usb_log_debug2("USB_DEVREQ_CLEAR_FEATURE\n");
-		clear_feature(instance, request);
-		break;
-
-	case USB_DEVREQ_SET_FEATURE:
-		usb_log_debug2("USB_DEVREQ_SET_FEATURE\n");
-		set_feature(instance, request);
-		break;
-
-	case USB_DEVREQ_SET_ADDRESS:
-		usb_log_debug("USB_DEVREQ_SET_ADDRESS: %u\n",
-		    setup_request->value);
-		if (uint16_usb2host(setup_request->value) > 127)
-			TRANSFER_END(request, EINVAL);
-
-		instance->address = uint16_usb2host(setup_request->value);
-		TRANSFER_END(request, EOK);
-
-	case USB_DEVREQ_SET_CONFIGURATION:
-		usb_log_debug("USB_DEVREQ_SET_CONFIGURATION: %u\n",
-		    uint16_usb2host(setup_request->value));
-		/* We have only one configuration, it's number is 1 */
-		if (uint16_usb2host(setup_request->value) != 1)
-			TRANSFER_END(request, EINVAL);
-		TRANSFER_END(request, EOK);
-
-	/* Both class specific and std is optional for hubs */
-	case USB_DEVREQ_SET_DESCRIPTOR:
-	/* Hubs have only one interface GET/SET is not supported */
-	case USB_DEVREQ_GET_INTERFACE:
-	case USB_DEVREQ_SET_INTERFACE:
-	default:
-		/* Hub class GET_STATE(2) falls in here too. */
-		usb_log_error("Received unsupported request: %d.\n",
-		    setup_request->request);
-		TRANSFER_END(request, ENOTSUP);
-	}
-}
-/**
- * @}
- */
Index: uspace/drv/bus/usb/ohci/root_hub.h
===================================================================
--- uspace/drv/bus/usb/ohci/root_hub.h	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ 	(revision )
@@ -1,79 +1,0 @@
-/*
- * Copyright (c) 2011 Jan Vesely
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/** @addtogroup drvusbohci
- * @{
- */
-/** @file
- * @brief OHCI driver
- */
-#ifndef DRV_OHCI_ROOT_HUB_H
-#define DRV_OHCI_ROOT_HUB_H
-
-#include <usb/usb.h>
-#include <usb/dev/driver.h>
-#include <usb/host/usb_transfer_batch.h>
-
-#include "ohci_regs.h"
-
-#define HUB_DESCRIPTOR_MAX_SIZE (7 + 2 + 2)
-
-/**
- * ohci root hub representation
- */
-typedef struct rh {
-	fibril_mutex_t guard;
-	/** pointer to ohci driver registers */
-	ohci_regs_t *registers;
-	/** usb address of the root hub */
-	usb_address_t address;
-	/** hub port count */
-	size_t port_count;
-	/** interrupt transfer waiting for an actual interrupt to occur */
-	usb_transfer_batch_t *unfinished_interrupt_transfer;
-	/** size of interrupt buffer */
-	size_t interrupt_mask_size;
-	/** Descriptors */
-	struct {
-		usb_standard_configuration_descriptor_t configuration;
-		usb_standard_interface_descriptor_t interface;
-		usb_standard_endpoint_descriptor_t endpoint;
-		uint8_t hub[HUB_DESCRIPTOR_MAX_SIZE];
-	} __attribute__ ((packed)) descriptors;
-	/** size of hub descriptor */
-	size_t hub_descriptor_size;
-} rh_t;
-
-void rh_init(rh_t *instance, ohci_regs_t *regs);
-
-void rh_request(rh_t *instance, usb_transfer_batch_t *request);
-
-void rh_interrupt(rh_t *instance);
-#endif
-/**
- * @}
- */
Index: uspace/drv/bus/usb/ohci/utils/malloc32.h
===================================================================
--- uspace/drv/bus/usb/ohci/utils/malloc32.h	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/ohci/utils/malloc32.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -35,10 +35,8 @@
 #define DRV_OHCI_UTILS_MALLOC32_H
 
-#include <assert.h>
-#include <malloc.h>
-#include <unistd.h>
+#include <as.h>
 #include <errno.h>
-#include <mem.h>
-#include <as.h>
+#include <stdlib.h>
+#include <sys/types.h>
 
 /* Generic TDs and EDs require 16byte alignment,
Index: uspace/drv/bus/usb/uhci/Makefile
===================================================================
--- uspace/drv/bus/usb/uhci/Makefile	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/uhci/Makefile	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -31,4 +31,5 @@
 LIBS = \
 	$(LIBUSBHOST_PREFIX)/libusbhost.a \
+	$(LIBUSBVIRT_PREFIX)/libusbvirt.a \
 	$(LIBUSB_PREFIX)/libusb.a \
 	$(LIBDRV_PREFIX)/libdrv.a
@@ -36,5 +37,7 @@
 EXTRA_CFLAGS += \
 	-I$(LIBUSB_PREFIX)/include \
+	-I$(LIBUSBDEV_PREFIX)/include \
 	-I$(LIBUSBHOST_PREFIX)/include \
+	-I$(LIBUSBVIRT_PREFIX)/include \
 	-I$(LIBDRV_PREFIX)/include
 
@@ -44,9 +47,8 @@
 	hc.c \
 	main.c \
-	res.c \
-	root_hub.c \
 	transfer_list.c \
 	uhci.c \
 	uhci_batch.c \
+	uhci_rh.c \
 	hw_struct/transfer_descriptor.c
 
Index: uspace/drv/bus/usb/uhci/hc.c
===================================================================
--- uspace/drv/bus/usb/uhci/hc.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/uhci/hc.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -32,14 +32,24 @@
  * @brief UHCI Host controller driver routines
  */
+
+#include <adt/list.h>
+#include <assert.h>
+#include <async.h>
+#include <ddi.h>
+#include <device/hw_res_parsed.h>
+#include <fibril.h>
 #include <errno.h>
+#include <macros.h>
+#include <mem.h>
+#include <stdlib.h>
 #include <str_error.h>
-#include <adt/list.h>
-#include <ddi.h>
+#include <sys/types.h>
 
 #include <usb/debug.h>
 #include <usb/usb.h>
 
+#include "uhci_batch.h"
+#include "utils/malloc32.h"
 #include "hc.h"
-#include "uhci_batch.h"
 
 #define UHCI_INTR_ALLOW_INTERRUPTS \
@@ -85,85 +95,42 @@
 static int hc_init_mem_structures(hc_t *instance);
 static int hc_init_transfer_lists(hc_t *instance);
-static int hc_schedule(hcd_t *hcd, usb_transfer_batch_t *batch);
 
 static int hc_interrupt_emulator(void *arg);
 static int hc_debug_checker(void *arg);
 
-enum {
-	/** Number of PIO ranges used in IRQ code */
-	hc_irq_pio_range_count =
-	    sizeof(uhci_irq_pio_ranges) / sizeof(irq_pio_range_t),
-
-	/* Number of commands used in IRQ code */
-	hc_irq_cmd_count =
-	    sizeof(uhci_irq_commands) / sizeof(irq_cmd_t)
-};
 
 /** Generate IRQ code.
- * @param[out] ranges PIO ranges buffer.
- * @param[in] ranges_size Size of the ranges buffer (bytes).
- * @param[out] cmds Commands buffer.
- * @param[in] cmds_size Size of the commands buffer (bytes).
+ * @param[out] code IRQ code structure.
  * @param[in] regs Device's register range.
  *
  * @return Error code.
  */
-int
-hc_get_irq_code(irq_pio_range_t ranges[], size_t ranges_size, irq_cmd_t cmds[],
-    size_t cmds_size, addr_range_t *regs)
-{
-	if ((ranges_size < sizeof(uhci_irq_pio_ranges)) ||
-	    (cmds_size < sizeof(uhci_irq_commands)) ||
-	    (RNGSZ(*regs) < sizeof(uhci_regs_t)))
+int hc_gen_irq_code(irq_code_t *code, addr_range_t *regs)
+{
+	assert(code);
+
+	if (RNGSZ(*regs) < sizeof(uhci_regs_t))
 		return EOVERFLOW;
 
-	memcpy(ranges, uhci_irq_pio_ranges, sizeof(uhci_irq_pio_ranges));
-	ranges[0].base = RNGABS(*regs);
-
-	memcpy(cmds, uhci_irq_commands, sizeof(uhci_irq_commands));
+	code->ranges = malloc(sizeof(uhci_irq_pio_ranges));
+	if (code->ranges == NULL)
+		return ENOMEM;
+
+	code->cmds = malloc(sizeof(uhci_irq_commands));
+	if (code->cmds == NULL) {
+		free(code->ranges);
+		return ENOMEM;
+	}
+
+	code->rangecount = ARRAY_SIZE(uhci_irq_pio_ranges);
+	code->cmdcount = ARRAY_SIZE(uhci_irq_commands);
+
+	memcpy(code->ranges, uhci_irq_pio_ranges, sizeof(uhci_irq_pio_ranges));
+	code->ranges[0].base = RNGABS(*regs);
+
+	memcpy(code->cmds, uhci_irq_commands, sizeof(uhci_irq_commands));
 	uhci_regs_t *registers = (uhci_regs_t *) RNGABSPTR(*regs);
-	cmds[0].addr = &registers->usbsts;
-	cmds[3].addr = &registers->usbsts;
-
-	return EOK;
-}
-
-/** Register interrupt handler.
- *
- * @param[in] device Host controller DDF device
- * @param[in] regs Register range
- * @param[in] irq Interrupt number
- * @paran[in] handler Interrupt handler
- *
- * @return EOK on success or negative error code
- */
-int hc_register_irq_handler(ddf_dev_t *device, addr_range_t *regs, int irq,
-    interrupt_handler_t handler)
-{
-	int rc;
-	irq_pio_range_t irq_ranges[hc_irq_pio_range_count];
-	irq_cmd_t irq_cmds[hc_irq_cmd_count];
-	rc = hc_get_irq_code(irq_ranges, sizeof(irq_ranges), irq_cmds,
-	    sizeof(irq_cmds), regs);
-	if (rc != EOK) {
-		usb_log_error("Failed to generate IRQ commands: %s.\n",
-		    str_error(rc));
-		return rc;
-	}
-
-	irq_code_t irq_code = {
-		.rangecount = hc_irq_pio_range_count,
-		.ranges = irq_ranges,
-		.cmdcount = hc_irq_cmd_count,
-		.cmds = irq_cmds
-	};
-
-        /* Register handler to avoid interrupt lockup */
-        rc = register_interrupt_handler(device, irq, handler, &irq_code);
-        if (rc != EOK) {
-    		usb_log_error("Failed to register interrupt handler: %s.\n",
-    		    str_error(rc));
-    		return rc;
-    	}
+	code->cmds[0].addr = (void*)&registers->usbsts;
+	code->cmds[3].addr = (void*)&registers->usbsts;
 
 	return EOK;
@@ -195,9 +162,8 @@
 		    &instance->transfers_bulk_full, &done);
 
-		while (!list_empty(&done)) {
-			link_t *item = list_first(&done);
-			list_remove(item);
+		list_foreach_safe(done, current, next) {
+			list_remove(current);
 			uhci_transfer_batch_t *batch =
-			    uhci_transfer_batch_from_link(item);
+			    uhci_transfer_batch_from_link(current);
 			uhci_transfer_batch_finish_dispose(batch);
 		}
@@ -240,6 +206,7 @@
 int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts)
 {
+	assert(instance);
+	assert(regs);
 	assert(regs->size >= sizeof(uhci_regs_t));
-	int rc;
 
 	instance->hw_interrupts = interrupts;
@@ -248,28 +215,22 @@
 	/* allow access to hc control registers */
 	uhci_regs_t *io;
-	rc = pio_enable_range(regs, (void **) &io);
-	if (rc != EOK) {
+	int ret = pio_enable_range(regs, (void **) &io);
+	if (ret != EOK) {
 		usb_log_error("Failed to gain access to registers at %p: %s.\n",
-		    io, str_error(rc));
-		return rc;
-	}
-
+	            io, str_error(ret));
+		return ret;
+	}
 	instance->registers = io;
+
 	usb_log_debug(
 	    "Device registers at %p (%zuB) accessible.\n", io, regs->size);
 
-	rc = hc_init_mem_structures(instance);
-	if (rc != EOK) {
-		usb_log_error("Failed to initialize UHCI memory structures: %s.\n",
-		    str_error(rc));
-		return rc;
-	}
-
-	hcd_init(&instance->generic, USB_SPEED_FULL,
-	    BANDWIDTH_AVAILABLE_USB11, bandwidth_count_usb11);
-
-	instance->generic.private_data = instance;
-	instance->generic.schedule = hc_schedule;
-	instance->generic.ep_add_hook = NULL;
+	ret = hc_init_mem_structures(instance);
+	if (ret != EOK) {
+		usb_log_error("Failed to init UHCI memory structures: %s.\n",
+		    str_error(ret));
+		// TODO: we should disable pio here
+		return ret;
+	}
 
 	hc_init_hw(instance);
@@ -280,4 +241,6 @@
 	}
 	(void)hc_debug_checker;
+
+	uhci_rh_init(&instance->rh, instance->registers->ports, "uhci");
 
 	return EOK;
@@ -440,7 +403,11 @@
 {
 	assert(hcd);
-	hc_t *instance = hcd->private_data;
+	hc_t *instance = hcd->driver.data;
 	assert(instance);
 	assert(batch);
+
+	if (batch->ep->address == uhci_rh_get_address(&instance->rh))
+		return uhci_rh_schedule(&instance->rh, batch);
+
 	uhci_transfer_batch_t *uhci_batch = uhci_transfer_batch_get(batch);
 	if (!uhci_batch) {
Index: uspace/drv/bus/usb/uhci/hc.h
===================================================================
--- uspace/drv/bus/usb/uhci/hc.h	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/uhci/hc.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -36,15 +36,20 @@
 #define DRV_UHCI_HC_H
 
-#include <ddf/interrupt.h>
 #include <device/hw_res_parsed.h>
 #include <fibril.h>
+#include <macros.h>
+#include <stdbool.h>
+#include <sys/types.h>
 #include <usb/host/hcd.h>
+#include <usb/host/usb_transfer_batch.h>
 
+#include "uhci_rh.h"
 #include "transfer_list.h"
+#include "hw_struct/link_pointer.h"
 
 /** UHCI I/O registers layout */
 typedef struct uhci_regs {
 	/** Command register, controls HC behaviour */
-	uint16_t usbcmd;
+	ioport16_t usbcmd;
 #define UHCI_CMD_MAX_PACKET (1 << 7)
 #define UHCI_CMD_CONFIGURE  (1 << 6)
@@ -57,5 +62,5 @@
 
 	/** Status register, 1 means interrupt is asserted (if enabled) */
-	uint16_t usbsts;
+	ioport16_t usbsts;
 #define UHCI_STATUS_HALTED (1 << 5)
 #define UHCI_STATUS_PROCESS_ERROR (1 << 4)
@@ -68,5 +73,5 @@
 
 	/** Interrupt enabled registers */
-	uint16_t usbintr;
+	ioport16_t usbintr;
 #define UHCI_INTR_SHORT_PACKET (1 << 3)
 #define UHCI_INTR_COMPLETE (1 << 2)
@@ -75,11 +80,14 @@
 
 	/** Register stores frame number used in SOF packet */
-	uint16_t frnum;
+	ioport16_t frnum;
 
 	/** Pointer(physical) to the Frame List */
-	uint32_t flbaseadd;
+	ioport32_t flbaseadd;
 
 	/** SOF modification to match external timers */
-	uint8_t sofmod;
+	ioport8_t sofmod;
+
+	PADD8[3];
+	ioport16_t ports[];
 } uhci_regs_t;
 
@@ -92,7 +100,5 @@
 /** Main UHCI driver structure */
 typedef struct hc {
-	/** Generic HCD driver structure */
-	hcd_t generic;
-
+	uhci_rh_t rh;
 	/** Addresses of I/O registers */
 	uhci_regs_t *registers;
@@ -121,10 +127,8 @@
 } hc_t;
 
-int hc_register_irq_handler(ddf_dev_t *, addr_range_t *, int,
-    interrupt_handler_t);
-int hc_get_irq_code(irq_pio_range_t [], size_t, irq_cmd_t [], size_t,
-    addr_range_t *);
+int hc_gen_irq_code(irq_code_t *code, addr_range_t *regs);
 void hc_interrupt(hc_t *instance, uint16_t status);
 int hc_init(hc_t *instance, addr_range_t *regs, bool interupts);
+int hc_schedule(hcd_t *hcd, usb_transfer_batch_t *batch);
 
 /** Safely dispose host controller internal structures
Index: uspace/drv/bus/usb/uhci/hw_struct/link_pointer.h
===================================================================
--- uspace/drv/bus/usb/uhci/hw_struct/link_pointer.h	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/uhci/hw_struct/link_pointer.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -35,4 +35,6 @@
 #define DRV_UHCI_HW_STRUCT_LINK_POINTER_H
 
+#include <sys/types.h>
+
 /** UHCI link pointer, used by many data structures */
 typedef uint32_t link_pointer_t;
Index: uspace/drv/bus/usb/uhci/hw_struct/queue_head.h
===================================================================
--- uspace/drv/bus/usb/uhci/hw_struct/queue_head.h	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/uhci/hw_struct/queue_head.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -34,5 +34,7 @@
 #ifndef DRV_UHCI_HW_STRUCT_QH_H
 #define DRV_UHCI_HW_STRUCT_QH_H
+
 #include <assert.h>
+#include <sys/types.h>
 
 #include "link_pointer.h"
Index: uspace/drv/bus/usb/uhci/hw_struct/transfer_descriptor.c
===================================================================
--- uspace/drv/bus/usb/uhci/hw_struct/transfer_descriptor.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/uhci/hw_struct/transfer_descriptor.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -32,7 +32,12 @@
  * @brief UHCI driver
  */
+
+#include <assert.h>
 #include <errno.h>
+
 #include <usb/debug.h>
+#include <usb/usb.h>
 
+#include "link_pointer.h"
 #include "transfer_descriptor.h"
 #include "../utils/malloc32.h"
Index: uspace/drv/bus/usb/uhci/hw_struct/transfer_descriptor.h
===================================================================
--- uspace/drv/bus/usb/uhci/hw_struct/transfer_descriptor.h	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/uhci/hw_struct/transfer_descriptor.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -35,6 +35,8 @@
 #define DRV_UHCI_HW_STRUCT_TRANSFER_DESCRIPTOR_H
 
-#include <mem.h>
+#include <assert.h>
 #include <usb/usb.h>
+#include <stdbool.h>
+#include <sys/types.h>
 
 #include "link_pointer.h"
Index: uspace/drv/bus/usb/uhci/main.c
===================================================================
--- uspace/drv/bus/usb/uhci/main.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/uhci/main.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -32,9 +32,11 @@
  * @brief UHCI driver initialization
  */
+
+#include <assert.h>
 #include <ddf/driver.h>
 #include <errno.h>
+#include <io/log.h>
+#include <stdio.h>
 #include <str_error.h>
-
-#include <usb/ddfiface.h>
 #include <usb/debug.h>
 
Index: uspace/drv/bus/usb/uhci/res.c
===================================================================
--- uspace/drv/bus/usb/uhci/res.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ 	(revision )
@@ -1,128 +1,0 @@
-/*
- * 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 drvusbuhcihc
- * @{
- */
-/**
- * @file
- * PCI related functions needed by the UHCI driver.
- */
-
-#include <errno.h>
-#include <assert.h>
-#include <devman.h>
-#include <device/hw_res_parsed.h>
-#include <pci_dev_iface.h>
-
-#include "res.h"
-
-/** Get I/O address of registers and IRQ for given device.
- *
- * @param[in] dev Device asking for the addresses.
- * @param[out] io_regs_p Pointer to register I/O range.
- * @param[out] irq_no IRQ assigned to the device.
- * @return Error code.
- */
-int get_my_registers(ddf_dev_t *dev, addr_range_t *io_regs_p, int *irq_no)
-{
-	assert(dev);
-
-	async_sess_t *parent_sess =
-	    devman_parent_device_connect(EXCHANGE_SERIALIZE,
-	    ddf_dev_get_handle(dev), IPC_FLAG_BLOCKING);
-	if (!parent_sess)
-		return ENOMEM;
-
-	hw_res_list_parsed_t hw_res;
-	hw_res_list_parsed_init(&hw_res);
-	const int ret = hw_res_get_list_parsed(parent_sess, &hw_res, 0);
-	async_hangup(parent_sess);
-	if (ret != EOK) {
-		return ret;
-	}
-
-	/* We want one irq and one io range. */
-	if (hw_res.irqs.count != 1 || hw_res.io_ranges.count != 1) {
-		hw_res_list_parsed_clean(&hw_res);
-		return EINVAL;
-	}
-
-	if (io_regs_p)
-		*io_regs_p = hw_res.io_ranges.ranges[0];
-	if (irq_no)
-		*irq_no = hw_res.irqs.irqs[0];
-
-	hw_res_list_parsed_clean(&hw_res);
-	return EOK;
-}
-
-/** Call the PCI driver with a request to enable interrupts
- *
- * @param[in] device Device asking for interrupts
- * @return Error code.
- */
-int enable_interrupts(ddf_dev_t *device)
-{
-	async_sess_t *parent_sess =
-	    devman_parent_device_connect(EXCHANGE_SERIALIZE,
-	    ddf_dev_get_handle(device), IPC_FLAG_BLOCKING);
-	if (!parent_sess)
-		return ENOMEM;
-
-	const bool enabled = hw_res_enable_interrupt(parent_sess);
-	async_hangup(parent_sess);
-
-	return enabled ? EOK : EIO;
-}
-
-/** Call the PCI driver with a request to clear legacy support register
- *
- * @param[in] device Device asking to disable interrupts
- * @return Error code.
- */
-int disable_legacy(ddf_dev_t *device)
-{
-	assert(device);
-
-	async_sess_t *parent_sess = devman_parent_device_connect(
-	    EXCHANGE_SERIALIZE, ddf_dev_get_handle(device), IPC_FLAG_BLOCKING);
-	if (!parent_sess)
-		return ENOMEM;
-
-	/* See UHCI design guide page 45 for these values.
-	 * Write all WC bits in USB legacy register */
-	const int rc = pci_config_space_write_16(parent_sess, 0xc0, 0xaf00);
-
-	async_hangup(parent_sess);
-	return rc;
-}
-
-/**
- * @}
- */
Index: uspace/drv/bus/usb/uhci/res.h
===================================================================
--- uspace/drv/bus/usb/uhci/res.h	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ 	(revision )
@@ -1,49 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup drvusbuhcihc
- * @{
- */
-/** @file
- * @brief UHCI driver PCI helper functions
- */
-#ifndef DRV_UHCI_PCI_H
-#define DRV_UHCI_PCI_H
-
-#include <ddf/driver.h>
-#include <device/hw_res_parsed.h>
-
-int get_my_registers(ddf_dev_t *, addr_range_t *, int *);
-int enable_interrupts(ddf_dev_t *);
-int disable_legacy(ddf_dev_t *);
-
-#endif
-/**
- * @}
- */
-
Index: uspace/drv/bus/usb/uhci/root_hub.c
===================================================================
--- uspace/drv/bus/usb/uhci/root_hub.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ 	(revision )
@@ -1,83 +1,0 @@
-/*
- * Copyright (c) 2011 Jan Vesely
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/** @addtogroup drvusbuhci
- * @{
- */
-/** @file
- * @brief UHCI driver
- */
-#include <assert.h>
-#include <errno.h>
-#include <str_error.h>
-#include <stdio.h>
-#include <device/hw_res_parsed.h>
-
-#include <usb/debug.h>
-
-#include "root_hub.h"
-
-/** Root hub initialization
- * @param[in] instance RH structure to initialize
- * @param[in] fun DDF function representing UHCI root hub
- * @param[in] reg_addr Address of root hub status and control registers.
- * @param[in] reg_size Size of accessible address space.
- * @return Error code.
- */
-int
-rh_init(rh_t *instance, ddf_fun_t *fun, addr_range_t *regs, uintptr_t reg_addr,
-    size_t reg_size)
-{
-	assert(instance);
-	assert(fun);
-
-	/* Crop the PIO window to the absolute address range of UHCI I/O. */
-	instance->pio_window.mem.base = 0;
-	instance->pio_window.mem.size = 0;
-	instance->pio_window.io.base = RNGABS(*regs);
-	instance->pio_window.io.size = RNGSZ(*regs);
-
-	/* Initialize resource structure */
-	instance->resource_list.count = 1;
-	instance->resource_list.resources = &instance->io_regs;
-
-	instance->io_regs.type = IO_RANGE;
-	instance->io_regs.res.io_range.address = reg_addr;
-	instance->io_regs.res.io_range.size = reg_size;
-	instance->io_regs.res.io_range.relative = true;
-	instance->io_regs.res.io_range.endianness = LITTLE_ENDIAN;
-
-	const int ret = ddf_fun_add_match_id(fun, "usb&uhci&root-hub", 100);
-	if (ret != EOK) {
-		usb_log_error("Failed to add root hub match id: %s\n",
-		    str_error(ret));
-	}
-	return ret;
-}
-/**
- * @}
- */
Index: uspace/drv/bus/usb/uhci/root_hub.h
===================================================================
--- uspace/drv/bus/usb/uhci/root_hub.h	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ 	(revision )
@@ -1,57 +1,0 @@
-/*
- * Copyright (c) 2011 Jan Vesely
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup drvusbuhci
- * @{
- */
-/** @file
- * @brief UHCI driver
- */
-#ifndef DRV_UHCI_RH_H
-#define DRV_UHCI_RH_H
-
-#include <ddf/driver.h>
-#include <ops/hw_res.h>
-#include <ops/pio_window.h>
-
-/** DDF support structure for uhci_rhd driver, provides I/O resources */
-typedef struct rh {
-	/** List of resources available to the root hub. */
-	hw_resource_list_t resource_list;
-	/** The only resource in the RH resource list */
-	hw_resource_t io_regs;
-	/** PIO window in which the RH will operate. */
-	pio_window_t pio_window;	
-} rh_t;
-
-extern int rh_init(rh_t *, ddf_fun_t *, addr_range_t *, uintptr_t, size_t);
-
-#endif
-/**
- * @}
- */
Index: uspace/drv/bus/usb/uhci/transfer_list.c
===================================================================
--- uspace/drv/bus/usb/uhci/transfer_list.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/uhci/transfer_list.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -34,8 +34,13 @@
  */
 
+#include <assert.h>
 #include <errno.h>
+#include <libarch/barrier.h>
+#include <sys/types.h>
 #include <usb/debug.h>
-#include <libarch/barrier.h>
-
+#include <usb/host/usb_transfer_batch.h>
+
+#include "utils/malloc32.h"
+#include "hw_struct/link_pointer.h"
 #include "transfer_list.h"
 
Index: uspace/drv/bus/usb/uhci/transfer_list.h
===================================================================
--- uspace/drv/bus/usb/uhci/transfer_list.h	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/uhci/transfer_list.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -35,4 +35,5 @@
 #define DRV_UHCI_TRANSFER_LIST_H
 
+#include <adt/list.h>
 #include <fibril_synch.h>
 
Index: uspace/drv/bus/usb/uhci/uhci.c
===================================================================
--- uspace/drv/bus/usb/uhci/uhci.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/uhci/uhci.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -34,39 +34,26 @@
  */
 
-/* XXX Fix this */
-#define _DDF_DATA_IMPLANT
-
+#include <assert.h>
+#include <ddf/driver.h>
+#include <ddf/interrupt.h>
+#include <device/hw_res_parsed.h>
+#include <device/pci.h>
+#include <devman.h>
 #include <errno.h>
 #include <stdbool.h>
+#include <stdlib.h>
 #include <str_error.h>
-#include <ddf/interrupt.h>
-#include <usb_iface.h>
-#include <usb/ddfiface.h>
+#include <sys/types.h>
+
 #include <usb/debug.h>
+#include <usb/usb.h>
+#include <usb/host/ddf_helpers.h>
+#include <usb/host/hcd.h>
+#include <usb/host/usb_bus.h>
 
 #include "uhci.h"
 
-#include "res.h"
 #include "hc.h"
-#include "root_hub.h"
 
-/** Structure representing both functions of UHCI hc, USB host controller
- * and USB root hub */
-typedef struct uhci {
-	/** Pointer to DDF representation of UHCI host controller */
-	ddf_fun_t *hc_fun;
-	/** Pointer to DDF representation of UHCI root hub */
-	ddf_fun_t *rh_fun;
-
-	/** Internal driver's representation of UHCI host controller */
-	hc_t hc;
-	/** Internal driver's representation of UHCI root hub */
-	rh_t rh;
-} uhci_t;
-
-static inline uhci_t *dev_to_uhci(ddf_dev_t *dev)
-{
-	return ddf_dev_data_get(dev);
-}
 
 /** IRQ handling callback, forward status from call to diver structure.
@@ -79,76 +66,34 @@
 {
 	assert(dev);
-	uhci_t *uhci = dev_to_uhci(dev);
-	if (!uhci) {
+	hcd_t *hcd = dev_to_hcd(dev);
+	if (!hcd || !hcd->driver.data) {
 		usb_log_error("Interrupt on not yet initialized device.\n");
 		return;
 	}
 	const uint16_t status = IPC_GET_ARG1(*call);
-	hc_interrupt(&uhci->hc, status);
+	hc_interrupt(hcd->driver.data, status);
 }
 
-/** Operations supported by the HC driver */
-static ddf_dev_ops_t hc_ops = {
-	.interfaces[USBHC_DEV_IFACE] = &hcd_iface, /* see iface.h/c */
-};
-
-/** Gets handle of the respective hc.
+/** Call the PCI driver with a request to clear legacy support register
  *
- * @param[in] fun DDF function of uhci device.
- * @param[out] handle Host cotnroller handle.
+ * @param[in] device Device asking to disable interrupts
  * @return Error code.
  */
-static int usb_iface_get_hc_handle(ddf_fun_t *fun, devman_handle_t *handle)
+static int disable_legacy(ddf_dev_t *device)
 {
-	ddf_fun_t *hc_fun = dev_to_uhci(ddf_fun_get_dev(fun))->hc_fun;
-	assert(hc_fun);
+	assert(device);
 
-	if (handle != NULL)
-		*handle = ddf_fun_get_handle(hc_fun);
-	return EOK;
+	async_sess_t *parent_sess = devman_parent_device_connect(
+	    EXCHANGE_SERIALIZE, ddf_dev_get_handle(device), IPC_FLAG_BLOCKING);
+	if (!parent_sess)
+		return ENOMEM;
+
+	/* See UHCI design guide page 45 for these values.
+	 * Write all WC bits in USB legacy register */
+	const int rc = pci_config_space_write_16(parent_sess, 0xc0, 0xaf00);
+
+	async_hangup(parent_sess);
+	return rc;
 }
-
-/** USB interface implementation used by RH */
-static usb_iface_t usb_iface = {
-	.get_hc_handle = usb_iface_get_hc_handle,
-};
-
-/** Get root hub hw resources (I/O registers).
- *
- * @param[in] fun Root hub function.
- * @return Pointer to the resource list used by the root hub.
- */
-static hw_resource_list_t *get_resource_list(ddf_fun_t *fun)
-{
-	rh_t *rh = ddf_fun_data_get(fun);
-	assert(rh);
-	return &rh->resource_list;
-}
-
-/** Interface to provide the root hub driver with hw info */
-static hw_res_ops_t hw_res_iface = {
-	.get_resource_list = get_resource_list,
-	.enable_interrupt = NULL,
-};
-
-static pio_window_t *get_pio_window(ddf_fun_t *fun)
-{
-	rh_t *rh = ddf_fun_data_get(fun);
-	
-	if (rh == NULL)
-		return NULL;
-	return &rh->pio_window;
-}
-
-static pio_window_ops_t pio_window_iface = {
-	.get_pio_window = get_pio_window
-};
-
-/** RH function support for uhci_rhd */
-static ddf_dev_ops_t rh_ops = {
-	.interfaces[USB_DEV_IFACE] = &usb_iface,
-	.interfaces[HW_RES_DEV_IFACE] = &hw_res_iface,
-	.interfaces[PIO_WINDOW_DEV_IFACE] = &pio_window_iface
-};
 
 /** Initialize hc and rh DDF structures and their respective drivers.
@@ -164,71 +109,42 @@
 int device_setup_uhci(ddf_dev_t *device)
 {
-	bool ih_registered = false;
-	bool hc_inited = false;
-	bool fun_bound = false;
-	int rc;
+	assert(device);
 
-	if (!device)
-		return EBADMEM;
+	hw_res_list_parsed_t hw_res;
+	int ret = hcd_ddf_get_registers(device, &hw_res);
+	if (ret != EOK ||
+	    hw_res.irqs.count != 1 || hw_res.io_ranges.count != 1) {
+		usb_log_error("Failed to get register memory addresses "
+		    "for %" PRIun ": %s.\n", ddf_dev_get_handle(device),
+		    str_error(ret));
+		return ret;
+	}
+	addr_range_t regs = hw_res.io_ranges.ranges[0];
+	const int irq = hw_res.irqs.irqs[0];
+	hw_res_list_parsed_clean(&hw_res);
 
-	uhci_t *instance = ddf_dev_data_alloc(device, sizeof(uhci_t));
-	if (instance == NULL) {
-		usb_log_error("Failed to allocate OHCI driver.\n");
-		return ENOMEM;
-	}
-
-	instance->hc_fun = ddf_fun_create(device, fun_exposed, "uhci_hc");
-	if (instance->hc_fun == NULL) {
-		usb_log_error("Failed to create UHCI HC function.\n");
-		rc = ENOMEM;
-		goto error;
-	}
-
-	ddf_fun_set_ops(instance->hc_fun, &hc_ops);
-	ddf_fun_data_implant(instance->hc_fun, &instance->hc.generic);
-
-	instance->rh_fun = ddf_fun_create(device, fun_inner, "uhci_rh");
-	if (instance->rh_fun == NULL) {
-		usb_log_error("Failed to create UHCI RH function.\n");
-		rc = ENOMEM;
-		goto error;
-	}
-
-	ddf_fun_set_ops(instance->rh_fun, &rh_ops);
-	ddf_fun_data_implant(instance->rh_fun, &instance->rh);
-
-	addr_range_t regs;
-	int irq = 0;
-
-	rc = get_my_registers(device, &regs, &irq);
-	if (rc != EOK) {
-		usb_log_error("Failed to get I/O addresses for %" PRIun ": %s.\n",
-		    ddf_dev_get_handle(device), str_error(rc));
-		goto error;
-	}
 	usb_log_debug("I/O regs at %p (size %zu), IRQ %d.\n",
 	    RNGABSPTR(regs), RNGSZ(regs), irq);
 
-	rc = disable_legacy(device);
-	if (rc != EOK) {
-		usb_log_error("Failed to disable legacy USB: %s.\n",
-		    str_error(rc));
-		goto error;
+	ret = hcd_ddf_setup_hc(device, USB_SPEED_FULL,
+	    BANDWIDTH_AVAILABLE_USB11, bandwidth_count_usb11);
+	if (ret != EOK) {
+		usb_log_error("Failed to setup generic HCD.\n");
+		return ret;
 	}
 
-	rc = hc_register_irq_handler(device, &regs, irq, irq_handler);
-	if (rc != EOK) {
-		usb_log_error("Failed to register interrupt handler: %s.\n",
-		    str_error(rc));
-		goto error;
+	hc_t *hc = malloc(sizeof(hc_t));
+	if (!hc) {
+		usb_log_error("Failed to allocate UHCI HC structure.\n");
+		ret = ENOMEM;
+		goto ddf_hc_clean;
 	}
 
-	ih_registered = true;
-
 	bool interrupts = false;
-	rc = enable_interrupts(device);
-	if (rc != EOK) {
+	ret = hcd_ddf_setup_interrupts(device, &regs, irq, irq_handler,
+	    hc_gen_irq_code);
+	if (ret != EOK) {
 		usb_log_warning("Failed to enable interrupts: %s."
-		    " Falling back to polling.\n", str_error(rc));
+		    " Falling back to polling.\n", str_error(ret));
 	} else {
 		usb_log_debug("Hw interrupts enabled.\n");
@@ -236,57 +152,36 @@
 	}
 
-	rc = hc_init(&instance->hc, &regs, interrupts);
-	if (rc != EOK) {
-		usb_log_error("Failed to init uhci_hcd: %s.\n", str_error(rc));
-		goto error;
+	ret = disable_legacy(device);
+	if (ret != EOK) {
+		usb_log_error("Failed to disable legacy USB: %s.\n",
+		    str_error(ret));
+		goto irq_unregister;
 	}
 
-	hc_inited = true;
-
-	rc = ddf_fun_bind(instance->hc_fun);
-	if (rc != EOK) {
-		usb_log_error("Failed to bind UHCI device function: %s.\n",
-		    str_error(rc));
-		goto error;
+	ret = hc_init(hc, &regs, interrupts);
+	if (ret != EOK) {
+		usb_log_error("Failed to init uhci_hcd: %s.\n", str_error(ret));
+		goto irq_unregister;
+		// TODO This is unfortunate, we have neither legacy nor real USB
 	}
 
-	fun_bound = true;
+	hcd_set_implementation(dev_to_hcd(device), hc, hc_schedule, NULL, NULL);
 
-	rc = ddf_fun_add_to_category(instance->hc_fun, USB_HC_CATEGORY);
-	if (rc != EOK) {
-		usb_log_error("Failed to add UHCI to HC class: %s.\n",
-		    str_error(rc));
-		goto error;
+	/*
+	 * Creating root hub registers a new USB device so HC
+	 * needs to be ready at this time.
+	 */
+	ret = hcd_ddf_setup_root_hub(device);
+	if (ret != EOK) {
+		usb_log_error("Failed to setup UHCI root hub: %s.\n",
+		    str_error(ret));
+		hc_fini(hc);
+irq_unregister:
+		unregister_interrupt_handler(device, irq);
+		free(hc);
+ddf_hc_clean:
+		hcd_ddf_clean_hc(device);
 	}
-
-	rc = rh_init(&instance->rh, instance->rh_fun, &regs, 0x10, 4);
-	if (rc != EOK) {
-		usb_log_error("Failed to setup UHCI root hub: %s.\n",
-		    str_error(rc));
-		goto error;
-	}
-
-	rc = ddf_fun_bind(instance->rh_fun);
-	if (rc != EOK) {
-		usb_log_error("Failed to register UHCI root hub: %s.\n",
-		    str_error(rc));
-		goto error;
-	}
-
-	return EOK;
-
-error:
-	if (fun_bound)
-		ddf_fun_unbind(instance->hc_fun);
-	if (hc_inited)
-		hc_fini(&instance->hc);
-	if (ih_registered)
-		unregister_interrupt_handler(device, irq);
-	if (instance->hc_fun != NULL)
-		ddf_fun_destroy(instance->hc_fun);
-	if (instance->rh_fun != NULL) {
-		ddf_fun_destroy(instance->rh_fun);
-	}
-	return rc;
+	return ret;
 }
 /**
Index: uspace/drv/bus/usb/uhci/uhci_batch.c
===================================================================
--- uspace/drv/bus/usb/uhci/uhci_batch.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/uhci/uhci_batch.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -32,13 +32,16 @@
  * @brief UHCI driver USB transfer structure
  */
+
+#include <assert.h>
 #include <errno.h>
-#include <str_error.h>
 #include <macros.h>
+#include <mem.h>
+#include <stdlib.h>
 
 #include <usb/usb.h>
 #include <usb/debug.h>
+#include <usb/host/endpoint.h>
 
 #include "uhci_batch.h"
-#include "transfer_list.h"
 #include "hw_struct/transfer_descriptor.h"
 #include "utils/malloc32.h"
@@ -67,4 +70,5 @@
 	assert(uhci_batch);
 	assert(uhci_batch->usb_batch);
+	assert(!link_in_use(&uhci_batch->link));
 	usb_transfer_batch_finish(uhci_batch->usb_batch,
 	    uhci_transfer_batch_data_buffer(uhci_batch));
Index: uspace/drv/bus/usb/uhci/uhci_batch.h
===================================================================
--- uspace/drv/bus/usb/uhci/uhci_batch.h	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/uhci/uhci_batch.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -35,6 +35,10 @@
 #define DRV_UHCI_BATCH_H
 
+#include <adt/list.h>
+#include <assert.h>
+#include <errno.h>
+#include <stdbool.h>
+#include <sys/types.h>
 #include <usb/host/usb_transfer_batch.h>
-#include <adt/list.h>
 
 #include "hw_struct/queue_head.h"
Index: uspace/drv/bus/usb/uhci/uhci_rh.c
===================================================================
--- uspace/drv/bus/usb/uhci/uhci_rh.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
+++ uspace/drv/bus/usb/uhci/uhci_rh.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -0,0 +1,495 @@
+/*
+ * Copyright (c) 2013 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.
+ */
+
+#include <assert.h>
+#include <async.h>
+#include <ddi.h>
+#include <errno.h>
+#include <macros.h>
+#include <mem.h>
+#include <sys/time.h>
+
+#include <usb/debug.h>
+#include <usb/descriptor.h>
+#include <usb/classes/hub.h>
+#include <usb/request.h>
+#include <usb/usb.h>
+
+#include "uhci_rh.h"
+
+enum {
+	UHCI_RH_PORT_COUNT = 2,
+	UHCI_PORT_BYTES = STATUS_BYTES(UHCI_RH_PORT_COUNT),
+};
+
+/** Hub descriptor. */
+static const struct {
+	/** Common hub descriptor header */
+	usb_hub_descriptor_header_t header;
+	/** Port removable status bits */
+	uint8_t removable[UHCI_PORT_BYTES];
+	/** Port powered status bits */
+	uint8_t powered[UHCI_PORT_BYTES];
+} __attribute__((packed)) hub_descriptor = {
+	.header = {
+		.length = sizeof(hub_descriptor),
+		.descriptor_type = USB_DESCTYPE_HUB,
+		.port_count = UHCI_RH_PORT_COUNT,
+		.characteristics =
+		    HUB_CHAR_NO_POWER_SWITCH_FLAG | HUB_CHAR_NO_OC_FLAG,
+		.power_good_time = 50,
+		.max_current = 0,
+	},
+	.removable = { 0 },
+	.powered = { 0xFF },
+};
+
+static usbvirt_device_ops_t ops;
+
+/** Initialize uhci rh structure.
+ * @param instance Memory place to initialize.
+ * @param ports Pointer to TWO UHCI RH port registers.
+ * @param name device name, passed to virthub init
+ * @return Error code, EOK on success.
+ */
+int uhci_rh_init(uhci_rh_t *instance, ioport16_t *ports, const char *name)
+{
+	assert(instance);
+	instance->ports[0] = ports;
+	instance->ports[1] = ports + 1;
+	instance->reset_changed[0] = false;
+	instance->reset_changed[1] = false;
+	return virthub_base_init(&instance->base, name, &ops, instance,
+	    NULL, &hub_descriptor.header, HUB_STATUS_CHANGE_PIPE);
+}
+
+/** Schedule USB batch for the root hub.
+ *
+ * @param instance UHCI rh instance
+ * @param batch USB communication batch
+ * @return EOK.
+ *
+ * The result of scheduling is always EOK. The result of communication does
+ * not have to be.
+ */
+int uhci_rh_schedule(uhci_rh_t *instance, usb_transfer_batch_t *batch)
+{
+	assert(instance);
+	assert(batch);
+
+	const usb_target_t target = {{
+		.address = batch->ep->address,
+		.endpoint = batch->ep->endpoint
+	}};
+	batch->error = virthub_base_request(&instance->base, target,
+	    usb_transfer_batch_direction(batch), (void*)batch->setup_buffer,
+	    batch->buffer, batch->buffer_size, &batch->transfered_size);
+	usb_transfer_batch_finish(batch, NULL);
+	usb_transfer_batch_destroy(batch);
+	return EOK;
+}
+
+/** UHCI port register bits */
+enum {
+	STATUS_CONNECTED         = (1 << 0),
+	STATUS_CONNECTED_CHANGED = (1 << 1),
+	STATUS_ENABLED           = (1 << 2),
+	STATUS_ENABLED_CHANGED   = (1 << 3),
+	STATUS_LINE_D_PLUS       = (1 << 4),
+	STATUS_LINE_D_MINUS      = (1 << 5),
+	STATUS_RESUME            = (1 << 6),
+	STATUS_ALWAYS_ONE        = (1 << 7),
+
+	STATUS_LOW_SPEED = (1 <<  8),
+	STATUS_IN_RESET  = (1 <<  9),
+	STATUS_SUSPEND   = (1 << 12),
+
+	STATUS_CHANGE_BITS = STATUS_CONNECTED_CHANGED | STATUS_ENABLED_CHANGED,
+	STATUS_WC_BITS = STATUS_CHANGE_BITS,
+};
+
+/* HUB ROUTINES IMPLEMENTATION */
+
+static void uhci_port_reset_enable(ioport16_t *port)
+{
+	assert(port);
+	uint16_t port_status = pio_read_16(port);
+	/* We don't wan to remove changes, that's hub drivers work */
+	port_status &= ~STATUS_WC_BITS;
+	port_status |= STATUS_IN_RESET;
+	pio_write_16(port, port_status);
+	async_usleep(50000);
+	port_status = pio_read_16(port);
+	port_status &= ~STATUS_IN_RESET;
+	pio_write_16(port, port_status);
+	while ((port_status = pio_read_16(port)) & STATUS_IN_RESET);
+	/* PIO delay, should not be longer than 3ms as the device might
+	 * enter suspend state. */
+	udelay(10);
+	/* Drop ConnectionChange as some UHCI hw
+	 * sets this bit after reset, that is incorrect */
+	port_status &= ~STATUS_WC_BITS;
+	pio_write_16(port, port_status | STATUS_ENABLED | STATUS_CONNECTED_CHANGED);
+}
+#define TEST_SIZE_INIT(size, port, hub) \
+do { \
+	if (uint16_usb2host(setup_packet->length) != size) \
+		return ESTALL; \
+	port = uint16_usb2host(setup_packet->index) - 1; \
+	if (port != 0 && port != 1) \
+		return EINVAL; \
+	hub = virthub_get_data(device); \
+	assert(hub);\
+} while (0)
+
+#define RH_DEBUG(d, port, msg, ...) \
+	if ((int)port >= 0) \
+		usb_log_debug("%s: rh-%d: " msg, d->name, port, ##__VA_ARGS__); \
+	else \
+		usb_log_debug("%s: rh: " msg, d->name, ##__VA_ARGS__) \
+
+/** USB HUB port state request handler.
+ * @param device Virtual hub device
+ * @param setup_packet USB setup stage data.
+ * @param[out] data destination data buffer, size must be at least
+ *             setup_packet->length bytes
+ * @param[out] act_size Sized of the valid response part of the buffer.
+ * @return Error code.
+ *
+ * Do not confuse with port status. Port state reports data line states,
+ * it is usefull for debuging purposes only.
+ */
+static int req_get_port_state(usbvirt_device_t *device,
+    const usb_device_request_setup_packet_t *setup_packet,
+    uint8_t *data, size_t *act_size)
+{
+	uhci_rh_t *hub;
+	unsigned port;
+	TEST_SIZE_INIT(1, port, hub);
+	if (setup_packet->value != 0)
+		return EINVAL;
+
+	const uint16_t value = pio_read_16(hub->ports[port]);
+	data[0] = ((value & STATUS_LINE_D_MINUS) ? 1 : 0)
+	    | ((value & STATUS_LINE_D_PLUS) ? 2 : 0);
+	RH_DEBUG(device, port, "Bus state %" PRIx8 "(source %" PRIx16")\n",
+	    data[0], value);
+	*act_size = 1;
+	return EOK;
+}
+
+#define BIT_VAL(val, bit) \
+	((val & bit) ? 1 : 0)
+#define UHCI2USB(val, bit, feat) \
+	(BIT_VAL(val, bit) << feat)
+
+/** Port status request handler.
+ * @param device Virtual hub device
+ * @param setup_packet USB setup stage data.
+ * @param[out] data destination data buffer, size must be at least
+ *             setup_packet->length bytes
+ * @param[out] act_size Sized of the valid response part of the buffer.
+ * @return Error code.
+ *
+ * Converts status reported via ioport to USB format.
+ * @note: reset change status needs to be handled in sw.
+ */
+static int req_get_port_status(usbvirt_device_t *device,
+    const usb_device_request_setup_packet_t *setup_packet,
+    uint8_t *data, size_t *act_size)
+{
+	uhci_rh_t *hub;
+	unsigned port;
+	TEST_SIZE_INIT(4, port, hub);
+	if (setup_packet->value != 0)
+		return EINVAL;
+
+	const uint16_t val = pio_read_16(hub->ports[port]);
+	const uint32_t status = uint32_host2usb(
+	    UHCI2USB(val, STATUS_CONNECTED, USB_HUB_FEATURE_PORT_CONNECTION) |
+	    UHCI2USB(val, STATUS_ENABLED, USB_HUB_FEATURE_PORT_ENABLE) |
+	    UHCI2USB(val, STATUS_SUSPEND, USB_HUB_FEATURE_PORT_SUSPEND) |
+	    UHCI2USB(val, STATUS_IN_RESET, USB_HUB_FEATURE_PORT_RESET) |
+	    UHCI2USB(val, STATUS_ALWAYS_ONE, USB_HUB_FEATURE_PORT_POWER) |
+	    UHCI2USB(val, STATUS_LOW_SPEED, USB_HUB_FEATURE_PORT_LOW_SPEED) |
+	    UHCI2USB(val, STATUS_CONNECTED_CHANGED, USB_HUB_FEATURE_C_PORT_CONNECTION) |
+	    UHCI2USB(val, STATUS_ENABLED_CHANGED, USB_HUB_FEATURE_C_PORT_ENABLE) |
+//	    UHCI2USB(val, STATUS_SUSPEND, USB_HUB_FEATURE_C_PORT_SUSPEND) |
+	    ((hub->reset_changed[port] ? 1 : 0) << USB_HUB_FEATURE_C_PORT_RESET)
+	);
+	RH_DEBUG(device, port, "Port status %" PRIx32 " (source %" PRIx16
+	    "%s)\n", uint32_usb2host(status), val,
+	    hub->reset_changed[port] ? "-reset" : "");
+	memcpy(data, &status, sizeof(status));
+	*act_size = sizeof(status);;
+	return EOK;
+}
+
+/** Port clear feature request handler.
+ * @param device Virtual hub device
+ * @param setup_packet USB setup stage data.
+ * @param[out] data destination data buffer, size must be at least
+ *             setup_packet->length bytes
+ * @param[out] act_size Sized of the valid response part of the buffer.
+ * @return Error code.
+ */
+static int req_clear_port_feature(usbvirt_device_t *device,
+    const usb_device_request_setup_packet_t *setup_packet,
+    uint8_t *data, size_t *act_size)
+{
+	uhci_rh_t *hub;
+	unsigned port;
+	TEST_SIZE_INIT(0, port, hub);
+	const unsigned feature = uint16_usb2host(setup_packet->value);
+	const uint16_t status = pio_read_16(hub->ports[port]);
+	const uint16_t val = status & (~STATUS_WC_BITS);
+	switch (feature) {
+	case USB_HUB_FEATURE_PORT_ENABLE:
+		RH_DEBUG(device, port, "Clear port enable (status %"
+		    PRIx16 ")\n", status);
+		pio_write_16(hub->ports[port], val & ~STATUS_ENABLED);
+		break;
+	case USB_HUB_FEATURE_PORT_SUSPEND:
+		RH_DEBUG(device, port, "Clear port suspend (status %"
+		    PRIx16 ")\n", status);
+		pio_write_16(hub->ports[port], val & ~STATUS_SUSPEND);
+		// TODO we should do resume magic
+		usb_log_warning("Resume is not implemented on port %u\n", port);
+		break;
+	case USB_HUB_FEATURE_PORT_POWER:
+		RH_DEBUG(device, port, "Clear port power (status %" PRIx16 ")\n",
+		    status);
+		/* We are always powered */
+		usb_log_warning("Tried to power off port %u\n", port);
+		break;
+	case USB_HUB_FEATURE_C_PORT_CONNECTION:
+		RH_DEBUG(device, port, "Clear port conn change (status %"
+		    PRIx16 ")\n", status);
+		pio_write_16(hub->ports[port], val | STATUS_CONNECTED_CHANGED);
+		break;
+	case USB_HUB_FEATURE_C_PORT_RESET:
+		RH_DEBUG(device, port, "Clear port reset change (status %"
+		    PRIx16 ")\n", status);
+		hub->reset_changed[port] = false;
+		break;
+	case USB_HUB_FEATURE_C_PORT_ENABLE:
+		RH_DEBUG(device, port, "Clear port enable change (status %"
+		    PRIx16 ")\n", status);
+		pio_write_16(hub->ports[port], status | STATUS_ENABLED_CHANGED);
+		break;
+	case USB_HUB_FEATURE_C_PORT_SUSPEND:
+		RH_DEBUG(device, port, "Clear port suspend change (status %"
+		    PRIx16 ")\n", status);
+		//TODO
+		return ENOTSUP;
+	case USB_HUB_FEATURE_C_PORT_OVER_CURRENT:
+		RH_DEBUG(device, port, "Clear port OC change (status %"
+		    PRIx16 ")\n", status);
+		/* UHCI Does not report over current */
+		//TODO: newer chips do, but some have broken wiring 
+		break;
+	default:
+		RH_DEBUG(device, port, "Clear unknown feature %d (status %"
+		    PRIx16 ")\n", feature, status);
+		usb_log_warning("Clearing feature %d is unsupported\n",
+		    feature);
+		return ESTALL;
+	}
+	return EOK;
+}
+
+/** Port set feature request handler.
+ * @param device Virtual hub device
+ * @param setup_packet USB setup stage data.
+ * @param[out] data destination data buffer, size must be at least
+ *             setup_packet->length bytes
+ * @param[out] act_size Sized of the valid response part of the buffer.
+ * @return Error code.
+ */
+static int req_set_port_feature(usbvirt_device_t *device,
+    const usb_device_request_setup_packet_t *setup_packet,
+    uint8_t *data, size_t *act_size)
+{
+	uhci_rh_t *hub;
+	unsigned port;
+	TEST_SIZE_INIT(0, port, hub);
+	const unsigned feature = uint16_usb2host(setup_packet->value);
+	const uint16_t status = pio_read_16(hub->ports[port]);
+	switch (feature) {
+	case USB_HUB_FEATURE_PORT_RESET:
+		RH_DEBUG(device, port, "Set port reset before (status %" PRIx16
+		    ")\n", status);
+		uhci_port_reset_enable(hub->ports[port]);
+		hub->reset_changed[port] = true;
+		RH_DEBUG(device, port, "Set port reset after (status %" PRIx16
+		    ")\n", pio_read_16(hub->ports[port]));
+		break;
+	case USB_HUB_FEATURE_PORT_SUSPEND:
+		RH_DEBUG(device, port, "Set port suspend (status %" PRIx16
+		    ")\n", status);
+		pio_write_16(hub->ports[port],
+		    (status & ~STATUS_WC_BITS) | STATUS_SUSPEND);
+		usb_log_warning("Suspend is not implemented on port %u\n", port);
+		break;
+	case USB_HUB_FEATURE_PORT_POWER:
+		RH_DEBUG(device, port, "Set port power (status %" PRIx16
+		    ")\n", status);
+		/* We are always powered */
+		usb_log_warning("Tried to power port %u\n", port);
+		break;
+	case USB_HUB_FEATURE_C_PORT_CONNECTION:
+	case USB_HUB_FEATURE_C_PORT_ENABLE:
+	case USB_HUB_FEATURE_C_PORT_SUSPEND:
+	case USB_HUB_FEATURE_C_PORT_OVER_CURRENT:
+		RH_DEBUG(device, port, "Set port change flag (status %" PRIx16
+		    ")\n", status);
+		/* These are voluntary and don't have to be set
+		 * there is no way we could do it on UHCI anyway */
+		break;
+	default:
+		RH_DEBUG(device, port, "Set unknown feature %d (status %" PRIx16
+		    ")\n", feature, status);
+		usb_log_warning("Setting feature %d is unsupported\n",
+		    feature);
+		return ESTALL;
+	}
+	return EOK;
+}
+
+/** Status change handler.
+ * @param device Virtual hub device
+ * @param endpoint Endpoint number
+ * @param tr_type Transfer type
+ * @param buffer Response destination
+ * @param buffer_size Bytes available in buffer
+ * @param actual_size Size us the used part of the dest buffer.
+ *
+ * Produces status mask. Bit 0 indicates hub status change the other bits
+ * represent port status change. Endian does not matter as UHCI root hubs
+ * only need 1 byte.
+ */
+static int req_status_change_handler(usbvirt_device_t *device,
+    usb_endpoint_t endpoint, usb_transfer_type_t tr_type,
+    void *buffer, size_t buffer_size, size_t *actual_size)
+{
+	uhci_rh_t *hub = virthub_get_data(device);
+	assert(hub);
+
+	if (buffer_size < 1)
+		return ESTALL;
+
+	const uint16_t status_a = pio_read_16(hub->ports[0]);
+	const uint16_t status_b = pio_read_16(hub->ports[1]);
+	const uint8_t status =
+	    ((((status_a & STATUS_CHANGE_BITS) != 0) || hub->reset_changed[0]) ?
+	        0x2 : 0) |
+	    ((((status_b & STATUS_CHANGE_BITS) != 0) || hub->reset_changed[1]) ?
+	        0x4 : 0);
+
+	RH_DEBUG(device, -1, "Event mask %" PRIx8
+	    " (status_a %" PRIx16 "%s),"
+	    " (status_b %" PRIx16 "%s)\n", status,
+	    status_a, hub->reset_changed[0] ? "-reset" : "",
+	    status_b, hub->reset_changed[1] ? "-reset" : "" );
+	((uint8_t *)buffer)[0] = status;
+	*actual_size = 1;
+	return EOK;
+}
+
+/** UHCI root hub request handlers */
+static const usbvirt_control_request_handler_t control_transfer_handlers[] = {
+	{
+		STD_REQ_IN(USB_REQUEST_RECIPIENT_DEVICE, USB_DEVREQ_GET_DESCRIPTOR),
+		.name = "GetDescriptor",
+		.callback = virthub_base_get_hub_descriptor,
+	},
+	{
+		CLASS_REQ_IN(USB_REQUEST_RECIPIENT_DEVICE, USB_DEVREQ_GET_DESCRIPTOR),
+		.name = "GetDescriptor",
+		.callback = virthub_base_get_hub_descriptor,
+	},
+	{
+		CLASS_REQ_IN(USB_REQUEST_RECIPIENT_DEVICE, USB_HUB_REQUEST_GET_DESCRIPTOR),
+		.name = "GetHubDescriptor",
+		.callback = virthub_base_get_hub_descriptor,
+	},
+	{
+		CLASS_REQ_IN(USB_REQUEST_RECIPIENT_OTHER, USB_HUB_REQUEST_GET_STATE),
+		.name = "GetBusState",
+		.callback = req_get_port_state,
+	},
+	{
+		CLASS_REQ_IN(USB_REQUEST_RECIPIENT_OTHER, USB_HUB_REQUEST_GET_STATUS),
+		.name = "GetPortStatus",
+		.callback = req_get_port_status
+	},
+	{
+		CLASS_REQ_OUT(USB_REQUEST_RECIPIENT_DEVICE, USB_HUB_REQUEST_CLEAR_FEATURE),
+		.name = "ClearHubFeature",
+		/* Hub features are overcurrent and supply good,
+		 * this request may only clear changes that we never report*/
+		.callback = req_nop,
+	},
+	{
+		CLASS_REQ_OUT(USB_REQUEST_RECIPIENT_OTHER, USB_HUB_REQUEST_CLEAR_FEATURE),
+		.name = "ClearPortFeature",
+		.callback = req_clear_port_feature
+	},
+	{
+		CLASS_REQ_IN(USB_REQUEST_RECIPIENT_DEVICE, USB_HUB_REQUEST_GET_STATUS),
+		.name = "GetHubStatus",
+		/* UHCI can't report OC condition or,
+		 * lose power source */
+		.callback = virthub_base_get_null_status,
+	},
+	{
+		CLASS_REQ_IN(USB_REQUEST_RECIPIENT_OTHER, USB_HUB_REQUEST_GET_STATUS),
+		.name = "GetPortStatus",
+		.callback = req_get_port_status
+	},
+	{
+		CLASS_REQ_OUT(USB_REQUEST_RECIPIENT_DEVICE, USB_HUB_REQUEST_SET_FEATURE),
+		.name = "SetHubFeature",
+		/* Hub features are overcurrent and supply good,
+		 * this request may only set changes that we never report*/
+		.callback = req_nop,
+	},
+	{
+		CLASS_REQ_OUT(USB_REQUEST_RECIPIENT_OTHER, USB_HUB_REQUEST_SET_FEATURE),
+		.name = "SetPortFeature",
+		.callback = req_set_port_feature
+	},
+	{
+		.callback = NULL
+	}
+};
+
+static usbvirt_device_ops_t ops = {
+        .control = control_transfer_handlers,
+        .data_in[HUB_STATUS_CHANGE_PIPE] = req_status_change_handler,
+};
Index: uspace/drv/bus/usb/uhci/uhci_rh.h
===================================================================
--- uspace/drv/bus/usb/uhci/uhci_rh.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
+++ uspace/drv/bus/usb/uhci/uhci_rh.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2013 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 drvusbuhci
+ * @{
+ */
+/** @file
+ * @brief UHCI host controller driver structure
+ */
+#ifndef DRV_UHCI_UHCI_RH_H
+#define DRV_UHCI_UHCI_RH_H
+
+#include <usbvirt/virthub_base.h>
+#include <usb/host/usb_transfer_batch.h>
+#include <usb/usb.h>
+
+#include <stdbool.h>
+#include <sys/types.h>
+
+/** Endpoint number for status change pipe. */
+#define HUB_STATUS_CHANGE_PIPE   1
+
+/** Virtual to UHCI hub connector */
+typedef struct {
+	/** Virtual hub software implementation */
+	virthub_base_t base;
+	/** UHCI root hub port io registers */
+	ioport16_t *ports[2];
+	/** Reset change indicator, it is not reported by regs */
+	bool reset_changed[2];
+} uhci_rh_t;
+
+int uhci_rh_init(uhci_rh_t *instance, ioport16_t *ports, const char *name);
+int uhci_rh_schedule(uhci_rh_t *instance, usb_transfer_batch_t *batch);
+
+/** Get UHCI rh address.
+ *
+ * @param instance UHCI rh instance.
+ * @return USB address assigned to the hub.
+ * Wrapper for virtual hub address
+ */
+static inline usb_address_t uhci_rh_get_address(uhci_rh_t *instance)
+{
+	return virthub_base_get_address(&instance->base);
+}
+
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/bus/usb/uhci/utils/malloc32.h
===================================================================
--- uspace/drv/bus/usb/uhci/utils/malloc32.h	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/uhci/utils/malloc32.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -36,12 +36,10 @@
 
 #include <as.h>
-#include <assert.h>
 #include <ddi.h>
 #include <errno.h>
 #include <malloc.h>
-#include <mem.h>
-#include <unistd.h>
+#include <sys/types.h>
 
-#define UHCI_STRCUTURES_ALIGNMENT 16
+#define UHCI_STRUCTURES_ALIGNMENT 16
 #define UHCI_REQUIRED_PAGE_SIZE 4096
 
@@ -56,10 +54,10 @@
 	if (addr == NULL)
 		return 0;
-	
+
 	uintptr_t result;
 	const int ret = as_get_physical_mapping(addr, &result);
 	if (ret != EOK)
 		return 0;
-	
+
 	return result;
 }
@@ -81,5 +79,5 @@
 	/* Calculate alignment to make sure the block won't cross page
 	 * boundary */
-	size_t alignment = UHCI_STRCUTURES_ALIGNMENT;
+	size_t alignment = UHCI_STRUCTURES_ALIGNMENT;
 	while (alignment < size)
 		alignment *= 2;
@@ -104,9 +102,9 @@
 	uintptr_t phys;
 	void *address;
-	
+
 	const int ret = dmamem_map_anonymous(UHCI_REQUIRED_PAGE_SIZE,
 	    DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE, 0, &phys,
 	    &address);
-	
+
 	return ((ret == EOK) ? address : NULL);
 }
Index: uspace/drv/bus/usb/uhcirh/Makefile
===================================================================
--- uspace/drv/bus/usb/uhcirh/Makefile	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ 	(revision )
@@ -1,48 +1,0 @@
-#
-# Copyright (c) 2010 Jan Vesely
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# - Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# - Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the distribution.
-# - The name of the author may not be used to endorse or promote products
-#   derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-USPACE_PREFIX = ../../../..
-
-LIBS = \
-	$(LIBUSBDEV_PREFIX)/libusbdev.a \
-	$(LIBUSB_PREFIX)/libusb.a \
-	$(LIBDRV_PREFIX)/libdrv.a
-
-EXTRA_CFLAGS += \
-	-I$(LIBUSB_PREFIX)/include \
-	-I$(LIBUSBDEV_PREFIX)/include \
-	-I$(LIBDRV_PREFIX)/include
-
-BINARY = uhcirh
-
-SOURCES = \
-	main.c \
-	port.c \
-	root_hub.c
-
-include $(USPACE_PREFIX)/Makefile.common
Index: uspace/drv/bus/usb/uhcirh/main.c
===================================================================
--- uspace/drv/bus/usb/uhcirh/main.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ 	(revision )
@@ -1,160 +1,0 @@
-/*
- * Copyright (c) 2011 Jan Vesely
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup drvusbuhcirh
- * @{
- */
-/** @file
- * @brief UHCI root hub initialization routines
- */
-
-#include <ddf/driver.h>
-#include <devman.h>
-#include <device/hw_res_parsed.h>
-#include <errno.h>
-#include <str_error.h>
-
-#include <usb_iface.h>
-#include <usb/ddfiface.h>
-#include <usb/debug.h>
-
-#include "root_hub.h"
-
-#define NAME "uhcirh"
-
-static int hc_get_my_registers(ddf_dev_t *dev, addr_range_t *io_regs);
-
-static int uhci_rh_dev_add(ddf_dev_t *device);
-
-static driver_ops_t uhci_rh_driver_ops = {
-	.dev_add = uhci_rh_dev_add,
-};
-
-static driver_t uhci_rh_driver = {
-	.name = NAME,
-	.driver_ops = &uhci_rh_driver_ops
-};
-
-/** Initialize global driver structures (NONE).
- *
- * @param[in] argc Nmber of arguments in argv vector (ignored).
- * @param[in] argv Cmdline argument vector (ignored).
- * @return Error code.
- *
- * Driver debug level is set here.
- */
-int main(int argc, char *argv[])
-{
-	printf(NAME ": HelenOS UHCI root hub driver.\n");
-	log_init(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_dev_add(ddf_dev_t *device)
-{
-	if (!device)
-		return EINVAL;
-
-	usb_log_debug2("uhci_rh_dev_add(handle=%" PRIun ")\n",
-	    ddf_dev_get_handle(device));
-
-	addr_range_t regs;
-	uhci_root_hub_t *rh = NULL;
-	int rc;
-
-	rc = hc_get_my_registers(device, &regs);
-	if (rc != EOK) {
-		usb_log_error( "Failed to get registers from HC: %s.\n",
-		    str_error(rc));
-		return rc;
-	}
-
-	usb_log_debug("I/O regs at %p (size %zuB).\n",
-	    RNGABSPTR(regs), RNGSZ(regs));
-
-	rh = ddf_dev_data_alloc(device, sizeof(uhci_root_hub_t));
-	if (rh == NULL) {
-		usb_log_error("Failed to allocate rh driver instance.\n");
-		return ENOMEM;
-	}
-
-	rc = uhci_root_hub_init(rh, &regs, device);
-	if (rc != EOK) {
-		usb_log_error("Failed(%d) to initialize rh driver instance: "
-		    "%s.\n", rc, str_error(rc));
-		return rc;
-	}
-
-	usb_log_info("Controlling root hub '%s' (%" PRIun ").\n",
-	    ddf_dev_get_name(device), ddf_dev_get_handle(device));
-
-	return EOK;
-}
-
-/** Get address of I/O registers.
- *
- * @param[in] dev Device asking for the addresses.
- * @param[out] io_regs_p Pointer to the device's register range.
- * @return Error code.
- */
-int hc_get_my_registers(ddf_dev_t *dev, addr_range_t *io_regs_p)
-{
-	async_sess_t *parent_sess =
-	    devman_parent_device_connect(EXCHANGE_SERIALIZE,
-	    ddf_dev_get_handle(dev), IPC_FLAG_BLOCKING);
-	if (!parent_sess)
-		return ENOMEM;
-
-	hw_res_list_parsed_t hw_res;
-	hw_res_list_parsed_init(&hw_res);
-	const int ret = hw_res_get_list_parsed(parent_sess, &hw_res, 0);
-	async_hangup(parent_sess);
-	if (ret != EOK) {
-		return ret;
-	}
-
-	if (hw_res.io_ranges.count != 1) {
-		hw_res_list_parsed_clean(&hw_res);
-		return EINVAL;
-	}
-
-	if (io_regs_p != NULL)
-		*io_regs_p = hw_res.io_ranges.ranges[0];
-
-	hw_res_list_parsed_clean(&hw_res);
-	return EOK;
-}
-
-/**
- * @}
- */
Index: uspace/drv/bus/usb/uhcirh/port.c
===================================================================
--- uspace/drv/bus/usb/uhcirh/port.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ 	(revision )
@@ -1,392 +1,0 @@
-/*
- * Copyright (c) 2011 Jan Vesely
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/** @addtogroup drvusbuhcirh
- * @{
- */
-/** @file
- * @brief UHCI root hub port routines
- */
-#include <ddi.h>
-#include <fibril_synch.h> /* async_usleep */
-#include <errno.h>
-#include <str_error.h>
-#include <async.h>
-
-#include <usb/usb.h>    /* usb_address_t */
-#include <usb/debug.h>
-
-#include "port.h"
-
-#define MAX_ERROR_COUNT 5
-
-static int uhci_port_check(void *port);
-static int uhci_port_reset_enable(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 void uhci_port_print_status(
-    uhci_port_t *port, const port_status_t value);
-
-/** Register reading helper function.
- *
- * @param[in] port Structure to use.
- * @return Error code. (Always EOK)
- */
-static inline port_status_t uhci_port_read_status(uhci_port_t *port)
-{
-	assert(port);
-	return pio_read_16(port->address);
-}
-
-/** Register writing helper function.
- *
- * @param[in] port Structure to use.
- * @param[in] val New register value.
- * @return Error code. (Always EOK)
- */
-static inline void uhci_port_write_status(uhci_port_t *port, port_status_t val)
-{
-	assert(port);
-	pio_write_16(port->address, val);
-}
-
-/** Initialize UHCI root hub port instance.
- *
- * @param[in] port Memory structure to use.
- * @param[in] address Address of I/O register.
- * @param[in] number Port number.
- * @param[in] usec Polling interval.
- * @param[in] rh Pointer to ddf instance of the root hub driver.
- * @return Error code.
- *
- * Creates and starts the polling fibril.
- */
-int uhci_port_init(uhci_port_t *port,
-    port_status_t *address, unsigned number, unsigned usec, ddf_dev_t *rh)
-{
-	assert(port);
-	char *id_string;
-	asprintf(&id_string, "Port (%p - %u)", port, number);
-	if (id_string == NULL) {
-		return ENOMEM;
-	}
-
-	port->id_string = id_string;
-	port->address = address;
-	port->number = number;
-	port->wait_period_usec = usec;
-	port->attached_device.fun = NULL;
-	port->attached_device.address = -1;
-	port->rh = rh;
-
-	int ret =
-	    usb_hc_connection_initialize_from_device(&port->hc_connection, rh);
-	if (ret != EOK) {
-		usb_log_error("%s: failed to initialize connection to HC.",
-		    port->id_string);
-		free(id_string);
-		return ret;
-	}
-
-	port->checker = fibril_create(uhci_port_check, port);
-	if (port->checker == 0) {
-		usb_log_error("%s: failed to create polling fibril.",
-		    port->id_string);
-		free(id_string);
-		return ENOMEM;
-	}
-
-	fibril_add_ready(port->checker);
-	usb_log_debug("%s: Started polling fibril (%" PRIun ").\n",
-	    port->id_string, port->checker);
-	return EOK;
-}
-
-/** Cleanup UHCI root hub port instance.
- *
- * @param[in] port Memory structure to use.
- *
- * Stops the polling fibril.
- */
-void uhci_port_fini(uhci_port_t *port)
-{
-	assert(port);
-	free(port->id_string);
-	// TODO: Kill fibril here
-	return;
-}
-
-/** Periodically checks port status and reports new devices.
- *
- * @param[in] port Port structure to use.
- * @return Error code.
- */
-int uhci_port_check(void *port)
-{
-	uhci_port_t *instance = port;
-	int rc;
-	assert(instance);
-
-	unsigned allowed_failures = MAX_ERROR_COUNT;
-
-	while (1) {
-		async_usleep(instance->wait_period_usec);
-
-		/* Read register value */
-		const port_status_t port_status =
-		    uhci_port_read_status(instance);
-
-		/* Print the value if it's interesting */
-		if (port_status & ~STATUS_ALWAYS_ONE)
-			uhci_port_print_status(instance, port_status);
-
-		if ((port_status & STATUS_CONNECTED_CHANGED) == 0)
-			continue;
-
-		usb_log_debug("%s: Connected change detected: %x.\n",
-		    instance->id_string, port_status);
-
-		rc = usb_hc_connection_open(&instance->hc_connection);
-		if (rc != EOK) {
-			usb_log_error("%s: Failed to connect to HC %s.\n",
-			    instance->id_string, str_error(rc));
-			if (!(allowed_failures-- > 0))
-				goto fatal_error;
-			continue;
-		}
-
-		/* Remove any old device */
-		if (instance->attached_device.fun) {
-			uhci_port_remove_device(instance);
-		}
-
-		if ((port_status & STATUS_CONNECTED) != 0) {
-			/* New device, this will take care of WC bits */
-			const usb_speed_t speed =
-			    ((port_status & STATUS_LOW_SPEED) != 0) ?
-			    USB_SPEED_LOW : USB_SPEED_FULL;
-			uhci_port_new_device(instance, speed);
-		} else {
-			/* Write one to WC bits, to ack changes */
-			uhci_port_write_status(instance, port_status);
-			usb_log_debug("%s: status change ACK.\n",
-			    instance->id_string);
-		}
-
-		rc = usb_hc_connection_close(&instance->hc_connection);
-		if (rc != EOK) {
-			usb_log_error("%s: Failed to disconnect from HC %s.\n",
-			    instance->id_string, str_error(rc));
-			if (!(allowed_failures-- > 0))
-				goto fatal_error;
-			continue;
-		}
-	}
-
-	return EOK;
-
-fatal_error:
-	usb_log_fatal("Maximum number of failures reached, bailing out.\n");
-	return rc;
-}
-
-/** Callback for enabling port during adding a new device.
- *
- * @param portno Port number (unused).
- * @param arg Pointer to uhci_port_t of port with the new device.
- * @return Error code.
- *
- * Resets and enables the ub port.
- */
-int uhci_port_reset_enable(void *arg)
-{
-	uhci_port_t *port = arg;
-	assert(port);
-
-	usb_log_debug2("%s: new_device_enable_port.\n", port->id_string);
-
-	/*
-	 * Resets from root ports should be nominally 50ms (USB spec 7.1.7.3)
-	 */
-	{
-		usb_log_debug("%s: Reset Signal start.\n", port->id_string);
-		port_status_t port_status = uhci_port_read_status(port);
-		port_status |= STATUS_IN_RESET;
-		uhci_port_write_status(port, port_status);
-		async_usleep(50000);
-		port_status = uhci_port_read_status(port);
-		port_status &= ~STATUS_IN_RESET;
-		uhci_port_write_status(port, port_status);
-		while (uhci_port_read_status(port) & STATUS_IN_RESET);
-	}
-	/* PIO delay, should not be longer than 3ms as the device might
-	 * enter suspend state. */
-	udelay(10);
-	/* Enable the port. */
-	uhci_port_set_enabled(port, true);
-	return EOK;
-}
-
-/** Initialize and report connected device.
- *
- * @param[in] port Port structure to use.
- * @param[in] speed Detected speed.
- * @return Error code.
- *
- * Uses libUSB function to do the actual work.
- */
-int uhci_port_new_device(uhci_port_t *port, usb_speed_t speed)
-{
-	assert(port);
-
-	usb_log_debug("%s: Detected new device.\n", port->id_string);
-
-	int ret, count = MAX_ERROR_COUNT;
-	do {
-		ret = usb_hc_new_device_wrapper(port->rh, &port->hc_connection,
-		    speed, uhci_port_reset_enable, port,
-		    &port->attached_device.address, NULL, NULL,
-		    &port->attached_device.fun);
-	} while (ret != EOK && count-- > 0);
-
-	if (ret != EOK) {
-		usb_log_error("%s: Failed(%d) to add device: %s.\n",
-		    port->id_string, ret, str_error(ret));
-		uhci_port_set_enabled(port, false);
-		return ret;
-	}
-
-	usb_log_info("%s: New device, address %d (handle %" PRIun ").\n",
-	    port->id_string, port->attached_device.address,
-	    ddf_fun_get_handle(port->attached_device.fun));
-	return EOK;
-}
-
-/** Remove device.
- *
- * @param[in] port Port instance to use.
- * @return Error code.
- */
-int uhci_port_remove_device(uhci_port_t *port)
-{
-	assert(port);
-	/* There is nothing to remove. */
-	if (port->attached_device.fun == NULL) {
-		usb_log_warning("%s: Removed a ghost device.\n",
-		    port->id_string);
-		assert(port->attached_device.address == -1);
-		return EOK;
-	}
-
-	usb_log_debug("%s: Removing device.\n", port->id_string);
-
-	/* Stop driver first */
-	int ret = ddf_fun_unbind(port->attached_device.fun);
-	if (ret != EOK) {
-		usb_log_error("%s: Failed to remove child function: %s.\n",
-		   port->id_string, str_error(ret));
-		return ret;
-	}
-	ddf_fun_destroy(port->attached_device.fun);
-	port->attached_device.fun = NULL;
-
-	/* Driver stopped, free used address */
-	ret = usb_hub_unregister_device(&port->hc_connection,
-	    &port->attached_device);
-	if (ret != EOK) {
-		usb_log_error("%s: Failed to unregister address of removed "
-		    "device: %s.\n", port->id_string, str_error(ret));
-		return ret;
-	}
-	port->attached_device.address = -1;
-
-	usb_log_info("%s: Removed attached device.\n", port->id_string);
-	return EOK;
-}
-
-/** Enable or disable root hub port.
- *
- * @param[in] port Port structure to use.
- * @param[in] enabled Port status to set.
- * @return Error code. (Always EOK)
- */
-int uhci_port_set_enabled(uhci_port_t *port, bool enabled)
-{
-	assert(port);
-
-	/* Read register value */
-	port_status_t port_status = uhci_port_read_status(port);
-
-	/* Set enabled bit */
-	if (enabled) {
-		port_status |= STATUS_ENABLED;
-	} else {
-		port_status &= ~STATUS_ENABLED;
-	}
-
-	/* Write new value. */
-	uhci_port_write_status(port, port_status);
-
-	/* Wait for port to become enabled */
-	do {
-		port_status = uhci_port_read_status(port);
-	} while ((port_status & STATUS_CONNECTED) &&
-	    !(port_status & STATUS_ENABLED));
-
-	usb_log_debug("%s: %sabled port.\n",
-		port->id_string, enabled ? "En" : "Dis");
-	return EOK;
-}
-
-/** Print the port status value in a human friendly way
- *
- * @param[in] port Port structure to use.
- * @param[in] value Port register value to print.
- * @return Error code. (Always EOK)
- */
-void uhci_port_print_status(uhci_port_t *port, const port_status_t value)
-{
-	assert(port);
-	usb_log_debug2("%s Port status(%#x):%s%s%s%s%s%s%s%s%s%s%s.\n",
-	    port->id_string, value,
-	    (value & STATUS_SUSPEND) ? " SUSPENDED," : "",
-	    (value & STATUS_RESUME) ? " IN RESUME," : "",
-	    (value & STATUS_IN_RESET) ? " IN RESET," : "",
-	    (value & STATUS_LINE_D_MINUS) ? " VD-," : "",
-	    (value & STATUS_LINE_D_PLUS) ? " VD+," : "",
-	    (value & STATUS_LOW_SPEED) ? " LOWSPEED," : "",
-	    (value & STATUS_ENABLED_CHANGED) ? " ENABLED-CHANGE," : "",
-	    (value & STATUS_ENABLED) ? " ENABLED," : "",
-	    (value & STATUS_CONNECTED_CHANGED) ? " CONNECTED-CHANGE," : "",
-	    (value & STATUS_CONNECTED) ? " CONNECTED," : "",
-	    (value & STATUS_ALWAYS_ONE) ? " ALWAYS ONE" : " ERR: NO ALWAYS ONE"
-	);
-}
-/**
- * @}
- */
Index: uspace/drv/bus/usb/uhcirh/port.h
===================================================================
--- uspace/drv/bus/usb/uhcirh/port.h	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ 	(revision )
@@ -1,78 +1,0 @@
-/*
- * Copyright (c) 2011 Jan Vesely
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/** @addtogroup drvusbuhcirh
- * @{
- */
-/** @file
- * @brief UHCI root hub port routines
- */
-#ifndef DRV_UHCI_PORT_H
-#define DRV_UHCI_PORT_H
-
-#include <stdint.h>
-#include <fibril.h>
-#include <ddf/driver.h>
-#include <usb/hc.h> /* usb_hc_connection_t */
-#include <usb/dev/hub.h>
-
-typedef uint16_t port_status_t;
-#define STATUS_CONNECTED         (1 << 0)
-#define STATUS_CONNECTED_CHANGED (1 << 1)
-#define STATUS_ENABLED           (1 << 2)
-#define STATUS_ENABLED_CHANGED   (1 << 3)
-#define STATUS_LINE_D_PLUS       (1 << 4)
-#define STATUS_LINE_D_MINUS      (1 << 5)
-#define STATUS_RESUME            (1 << 6)
-#define STATUS_ALWAYS_ONE        (1 << 7)
-
-#define STATUS_LOW_SPEED (1 <<  8)
-#define STATUS_IN_RESET  (1 <<  9)
-#define STATUS_SUSPEND   (1 << 12)
-
-/** UHCI port structure */
-typedef struct uhci_port {
-	const char *id_string;
-	port_status_t *address;
-	unsigned number;
-	unsigned wait_period_usec;
-	usb_hc_connection_t hc_connection;
-	ddf_dev_t *rh;
-	usb_hub_attached_device_t attached_device;
-	fid_t checker;
-} uhci_port_t;
-
-int uhci_port_init(
-    uhci_port_t *port, port_status_t *address, unsigned number,
-    unsigned usec, ddf_dev_t *rh);
-
-void uhci_port_fini(uhci_port_t *port);
-
-#endif
-/**
- * @}
- */
Index: uspace/drv/bus/usb/uhcirh/root_hub.c
===================================================================
--- uspace/drv/bus/usb/uhcirh/root_hub.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ 	(revision )
@@ -1,99 +1,0 @@
-/*
- * Copyright (c) 2011 Jan Vesely
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/** @addtogroup drvusbuhcirh
- * @{
- */
-/** @file
- * @brief UHCI root hub driver
- */
-#include <errno.h>
-#include <str_error.h>
-#include <ddi.h>
-#include <usb/debug.h>
-#include <device/hw_res_parsed.h>
-
-#include "root_hub.h"
-
-/** Initialize UHCI root hub instance.
- *
- * @param[in] instance Driver memory structure to use.
- * @param[in] io_regs Range of I/O registers.
- * @param[in] rh Pointer to DDF instance of the root hub driver.
- * @return Error code.
- */
-int uhci_root_hub_init(uhci_root_hub_t *instance, addr_range_t *io_regs,
-    ddf_dev_t *rh)
-{
-	port_status_t *regs;
-
-	assert(instance);
-	assert(rh);
-
-	/* Allow access to root hub port registers */
-	assert(sizeof(*regs) * UHCI_ROOT_HUB_PORT_COUNT <= io_regs->size);
-
-	int ret = pio_enable_range(io_regs, (void **) &regs);
-	if (ret < 0) {
-		usb_log_error(
-		    "Failed(%d) to gain access to port registers at %p: %s.\n",
-		    ret, RNGABSPTR(*io_regs), str_error(ret));
-		return ret;
-	}
-
-	/* Initialize root hub ports */
-	unsigned i = 0;
-	for (; i < UHCI_ROOT_HUB_PORT_COUNT; ++i) {
-		ret = uhci_port_init(
-		    &instance->ports[i], &regs[i], i, ROOT_HUB_WAIT_USEC, rh);
-		if (ret != EOK) {
-			unsigned j = 0;
-			for (;j < i; ++j)
-				uhci_port_fini(&instance->ports[j]);
-			return ret;
-		}
-	}
-
-	return EOK;
-}
-
-/** Cleanup UHCI root hub instance.
- *
- * @param[in] instance Root hub structure to use.
- */
-void uhci_root_hub_fini(uhci_root_hub_t* instance)
-{
-	assert(instance);
-	unsigned i = 0;
-	for (; i < UHCI_ROOT_HUB_PORT_COUNT; ++i) {
-		uhci_port_fini(&instance->ports[i]);
-	}
-}
-
-/**
- * @}
- */
Index: uspace/drv/bus/usb/uhcirh/root_hub.h
===================================================================
--- uspace/drv/bus/usb/uhcirh/root_hub.h	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ 	(revision )
@@ -1,58 +1,0 @@
-/*
- * Copyright (c) 2011 Jan Vesely
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/** @addtogroup drvusbuhcirh
- * @{
- */
-/** @file
- * @brief UHCI driver
- */
-#ifndef DRV_UHCI_ROOT_HUB_H
-#define DRV_UHCI_ROOT_HUB_H
-
-#include <ddf/driver.h>
-#include <device/hw_res_parsed.h>
-
-#include "port.h"
-
-#define UHCI_ROOT_HUB_PORT_COUNT 2
-#define ROOT_HUB_WAIT_USEC 250000 /* 250 miliseconds */
-
-/** UHCI root hub drvier structure */
-typedef struct root_hub {
-	/** Ports provided by the hub */
-	uhci_port_t ports[UHCI_ROOT_HUB_PORT_COUNT];
-} uhci_root_hub_t;
-
-int uhci_root_hub_init(uhci_root_hub_t *instance, addr_range_t *regs,
-    ddf_dev_t *rh);
-
-void uhci_root_hub_fini(uhci_root_hub_t *instance);
-#endif
-/**
- * @}
- */
Index: uspace/drv/bus/usb/uhcirh/uhcirh.ma
===================================================================
--- uspace/drv/bus/usb/uhcirh/uhcirh.ma	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ 	(revision )
@@ -1,1 +1,0 @@
-10 usb&uhci&root-hub
Index: uspace/drv/bus/usb/usbflbk/main.c
===================================================================
--- uspace/drv/bus/usb/usbflbk/main.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/usbflbk/main.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -48,27 +48,7 @@
 static int usbfallback_device_add(usb_device_t *dev)
 {
-	int rc;
-	const char *fun_name = "ctl";
-
-	ddf_fun_t *ctl_fun = ddf_fun_create(dev->ddf_dev, fun_exposed,
-	    fun_name);
-	if (ctl_fun == NULL) {
-		usb_log_error("Failed to create control function.\n");
-		return ENOMEM;
-	}
-	rc = ddf_fun_bind(ctl_fun);
-	if (rc != EOK) {
-		usb_log_error("Failed to bind control function: %s.\n",
-		    str_error(rc));
-		return rc;
-	}
-
-	dev->driver_data = ctl_fun;
-
-	usb_log_info("Pretending to control %s `%s'" \
-	    " (node `%s', handle %" PRIun ").\n",
-	    dev->interface_no < 0 ? "device" : "interface",
-	    ddf_dev_get_name(dev->ddf_dev), fun_name, ddf_dev_get_handle(dev->ddf_dev));
-
+	usb_log_info("Pretending to control %s `%s'.\n",
+	    usb_device_get_iface_number(dev) < 0 ? "device" : "interface",
+	    usb_device_get_name(dev));
 	return EOK;
 }
@@ -82,13 +62,4 @@
 {
 	assert(dev);
-	ddf_fun_t *ctl_fun = dev->driver_data;
-	const int ret = ddf_fun_unbind(ctl_fun);
-	if (ret != EOK) {
-		usb_log_error("Failed to unbind %s.\n", ddf_fun_get_name(ctl_fun));
-		return ret;
-	}
-	ddf_fun_destroy(ctl_fun);
-	dev->driver_data = NULL;
-
 	return EOK;
 }
Index: uspace/drv/bus/usb/usbhid/generic/hiddev.c
===================================================================
--- uspace/drv/bus/usb/usbhid/generic/hiddev.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/usbhid/generic/hiddev.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -35,7 +35,4 @@
  */
 
-/* XXX Fix this */
-#define _DDF_DATA_IMPLANT
-
 #include <usb/debug.h>
 #include <usb/classes/classes.h>
@@ -195,6 +192,6 @@
 	/* Create the exposed function. */
 	usb_log_debug("Creating DDF function %s...\n", HID_GENERIC_FUN_NAME);
-	ddf_fun_t *fun = ddf_fun_create(hid_dev->usb_dev->ddf_dev, fun_exposed, 
-	    HID_GENERIC_FUN_NAME);
+	ddf_fun_t *fun = usb_device_ddf_fun_create(hid_dev->usb_dev,
+	    fun_exposed, HID_GENERIC_FUN_NAME);
 	if (fun == NULL) {
 		usb_log_error("Could not create DDF function node.\n");
Index: uspace/drv/bus/usb/usbhid/kbd/kbddev.c
===================================================================
--- uspace/drv/bus/usb/usbhid/kbd/kbddev.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/usbhid/kbd/kbddev.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -34,7 +34,4 @@
  * USB HID keyboard device structure and API.
  */
-
-/* XXX Fix this */
-#define _DDF_DATA_IMPLANT
 
 #include <errno.h>
@@ -264,6 +261,6 @@
 
 	if (rc != EOK) {
-		usb_log_warning("Error translating LED output to output report"
-		    ".\n");
+		usb_log_warning("Could not translate LED output to output"
+		    "report.\n");
 		return;
 	}
@@ -273,6 +270,8 @@
 	        0));
 
-	rc = usbhid_req_set_report(&hid_dev->usb_dev->ctrl_pipe,
-	    hid_dev->usb_dev->interface_no, USB_HID_REPORT_TYPE_OUTPUT,
+	rc = usbhid_req_set_report(
+	    usb_device_get_default_pipe(hid_dev->usb_dev),
+	    usb_device_get_iface_number(hid_dev->usb_dev),
+	    USB_HID_REPORT_TYPE_OUTPUT,
 	    kbd_dev->output_buffer, kbd_dev->output_size);
 	if (rc != EOK) {
@@ -481,13 +480,153 @@
 /* HID/KBD structure manipulation                                             */
 
-static int usb_kbd_create_function(usb_kbd_t *kbd_dev)
-{
-	assert(kbd_dev != NULL);
-	assert(kbd_dev->hid_dev != NULL);
-	assert(kbd_dev->hid_dev->usb_dev != NULL);
+static int kbd_dev_init(usb_kbd_t *kbd_dev, usb_hid_dev_t *hid_dev)
+{
+	assert(kbd_dev);
+	assert(hid_dev);
+
+	/* Default values */
+	fibril_mutex_initialize(&kbd_dev->repeat_mtx);
+	kbd_dev->initialized = USB_KBD_STATUS_UNINITIALIZED;
+
+	/* Store link to HID device */
+	kbd_dev->hid_dev = hid_dev;
+
+	/* Modifiers and locks */
+	kbd_dev->mods = DEFAULT_ACTIVE_MODS;
+
+	/* Autorepeat */
+	kbd_dev->repeat.delay_before = DEFAULT_DELAY_BEFORE_FIRST_REPEAT;
+	kbd_dev->repeat.delay_between = DEFAULT_REPEAT_DELAY;
+
+	// TODO: make more general
+	usb_hid_report_path_t *path = usb_hid_report_path();
+	if (path == NULL) {
+		usb_log_error("Failed to create kbd report path.\n");
+		usb_kbd_destroy(kbd_dev);
+		return ENOMEM;
+	}
+
+	int ret =
+	    usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_KEYBOARD, 0);
+	if (ret != EOK) {
+		usb_log_error("Failed to append item to kbd report path.\n");
+		usb_hid_report_path_free(path);
+		usb_kbd_destroy(kbd_dev);
+		return ret;
+	}
+
+	usb_hid_report_path_set_report_id(path, 0);
+
+	kbd_dev->key_count =
+	    usb_hid_report_size(&hid_dev->report, 0, USB_HID_REPORT_TYPE_INPUT);
+
+	usb_hid_report_path_free(path);
+
+	usb_log_debug("Size of the input report: %zu\n", kbd_dev->key_count);
+
+	kbd_dev->keys = calloc(kbd_dev->key_count, sizeof(int32_t));
+	if (kbd_dev->keys == NULL) {
+		usb_log_error("Failed to allocate key buffer.\n");
+		usb_kbd_destroy(kbd_dev);
+		return ENOMEM;
+	}
+
+	kbd_dev->keys_old = calloc(kbd_dev->key_count, sizeof(int32_t));
+	if (kbd_dev->keys_old == NULL) {
+		usb_log_error("Failed to allocate old_key buffer.\n");
+		usb_kbd_destroy(kbd_dev);
+		return ENOMEM;
+	}
+
+	/* Output report */
+	kbd_dev->output_size = 0;
+	kbd_dev->output_buffer = usb_hid_report_output(&hid_dev->report,
+	    &kbd_dev->output_size, 0);
+	if (kbd_dev->output_buffer == NULL) {
+		usb_log_error("Error creating output report buffer.\n");
+		usb_kbd_destroy(kbd_dev);
+		return ENOMEM;
+	}
+
+	usb_log_debug("Output buffer size: %zu\n", kbd_dev->output_size);
+
+	kbd_dev->led_path = usb_hid_report_path();
+	if (kbd_dev->led_path == NULL) {
+		usb_log_error("Failed to create kbd led report path.\n");
+		usb_kbd_destroy(kbd_dev);
+		return ENOMEM;
+	}
+
+	ret = usb_hid_report_path_append_item(
+	    kbd_dev->led_path, USB_HIDUT_PAGE_LED, 0);
+	if (ret != EOK) {
+		usb_log_error("Failed to append to kbd/led report path.\n");
+		usb_kbd_destroy(kbd_dev);
+		return ret;
+	}
+
+	kbd_dev->led_output_size = usb_hid_report_size(
+	    &hid_dev->report, 0, USB_HID_REPORT_TYPE_OUTPUT);
+
+	usb_log_debug("Output report size (in items): %zu\n",
+	    kbd_dev->led_output_size);
+
+	kbd_dev->led_data = calloc(kbd_dev->led_output_size, sizeof(int32_t));
+	if (kbd_dev->led_data == NULL) {
+		usb_log_error("Error creating buffer for LED output report.\n");
+		usb_kbd_destroy(kbd_dev);
+		return ENOMEM;
+	}
+
+	/* Set LEDs according to initial setup.
+	 * Set Idle rate */
+	usb_kbd_set_led(hid_dev, kbd_dev);
+
+	usbhid_req_set_idle(usb_device_get_default_pipe(hid_dev->usb_dev),
+	    usb_device_get_iface_number(hid_dev->usb_dev), IDLE_RATE);
+
+
+	kbd_dev->initialized = USB_KBD_STATUS_INITIALIZED;
+	usb_log_debug("HID/KBD device structure initialized.\n");
+
+	return EOK;
+}
+
+
+/* API functions                                                              */
+
+/**
+ * Initialization of the USB/HID keyboard structure.
+ *
+ * This functions initializes required structures from the device's descriptors.
+ *
+ * During initialization, the keyboard is switched into boot protocol, the idle
+ * rate is set to 0 (infinity), resulting in the keyboard only reporting event
+ * when a key is pressed or released. Finally, the LED lights are turned on
+ * according to the default setup of lock keys.
+ *
+ * @note By default, the keyboards is initialized with Num Lock turned on and
+ *       other locks turned off.
+ *
+ * @param kbd_dev Keyboard device structure to be initialized.
+ * @param dev DDF device structure of the keyboard.
+ *
+ * @retval EOK if successful.
+ * @retval EINVAL if some parameter is not given.
+ * @return Other value inherited from function usbhid_dev_init().
+ */
+int usb_kbd_init(usb_hid_dev_t *hid_dev, void **data)
+{
+	usb_log_debug("Initializing HID/KBD structure...\n");
+
+	if (hid_dev == NULL) {
+		usb_log_error(
+		    "Failed to init keyboard structure: no structure given.\n");
+		return EINVAL;
+	}
 
 	/* Create the exposed function. */
 	usb_log_debug("Creating DDF function %s...\n", HID_KBD_FUN_NAME);
-	ddf_fun_t *fun = ddf_fun_create(kbd_dev->hid_dev->usb_dev->ddf_dev,
+	ddf_fun_t *fun = usb_device_ddf_fun_create(hid_dev->usb_dev,
 	    fun_exposed, HID_KBD_FUN_NAME);
 	if (fun == NULL) {
@@ -496,15 +635,29 @@
 	}
 
+	usb_kbd_t *kbd_dev = ddf_fun_data_alloc(fun, sizeof(usb_kbd_t));
+	if (kbd_dev == NULL) {
+		usb_log_error("Failed to allocate KBD device structure.\n");
+		ddf_fun_destroy(fun);
+		return ENOMEM;
+	}
+
+	int ret = kbd_dev_init(kbd_dev, hid_dev);
+	if (ret != EOK) {
+		usb_log_error("Failed to initialize KBD device  structure.\n");
+		ddf_fun_destroy(fun);
+		return ret;
+	}
+
 	/* Store the initialized HID device and HID ops
 	 * to the DDF function. */
 	ddf_fun_set_ops(fun, &kbdops);
-	ddf_fun_data_implant(fun, kbd_dev);
-
-	int rc = ddf_fun_bind(fun);
-	if (rc != EOK) {
+
+	ret = ddf_fun_bind(fun);
+	if (ret != EOK) {
 		usb_log_error("Could not bind DDF function: %s.\n",
-		    str_error(rc));
+		    str_error(ret));
+		usb_kbd_destroy(kbd_dev);
 		ddf_fun_destroy(fun);
-		return rc;
+		return ret;
 	}
 
@@ -514,9 +667,10 @@
 	usb_log_debug("Adding DDF function to category %s...\n",
 	    HID_KBD_CLASS_NAME);
-	rc = ddf_fun_add_to_category(fun, HID_KBD_CATEGORY_NAME);
-	if (rc != EOK) {
+	ret = ddf_fun_add_to_category(fun, HID_KBD_CATEGORY_NAME);
+	if (ret != EOK) {
 		usb_log_error(
 		    "Could not add DDF function to category %s: %s.\n",
-		    HID_KBD_CLASS_NAME, str_error(rc));
+		    HID_KBD_CLASS_NAME, str_error(ret));
+		usb_kbd_destroy(kbd_dev);
 		if (ddf_fun_unbind(fun) == EOK) {
 			ddf_fun_destroy(fun);
@@ -526,160 +680,4 @@
 			    ddf_fun_get_name(fun));
 		}
-		return rc;
-	}
-	kbd_dev->fun = fun;
-
-	return EOK;
-}
-
-/* API functions                                                              */
-
-/**
- * Initialization of the USB/HID keyboard structure.
- *
- * This functions initializes required structures from the device's descriptors.
- *
- * During initialization, the keyboard is switched into boot protocol, the idle
- * rate is set to 0 (infinity), resulting in the keyboard only reporting event
- * when a key is pressed or released. Finally, the LED lights are turned on 
- * according to the default setup of lock keys.
- *
- * @note By default, the keyboards is initialized with Num Lock turned on and 
- *       other locks turned off.
- *
- * @param kbd_dev Keyboard device structure to be initialized.
- * @param dev DDF device structure of the keyboard.
- *
- * @retval EOK if successful.
- * @retval EINVAL if some parameter is not given.
- * @return Other value inherited from function usbhid_dev_init().
- */
-int usb_kbd_init(usb_hid_dev_t *hid_dev, void **data)
-{
-	usb_log_debug("Initializing HID/KBD structure...\n");
-
-	if (hid_dev == NULL) {
-		usb_log_error(
-		    "Failed to init keyboard structure: no structure given.\n");
-		return EINVAL;
-	}
-
-	usb_kbd_t *kbd_dev = calloc(1, sizeof(usb_kbd_t));
-	if (kbd_dev == NULL) {
-		usb_log_error("Failed to allocate KBD device structure.\n");
-		return ENOMEM;
-	}
-	/* Default values */
-	fibril_mutex_initialize(&kbd_dev->repeat_mtx);
-	kbd_dev->initialized = USB_KBD_STATUS_UNINITIALIZED;
-
-	/* Store link to HID device */
-	kbd_dev->hid_dev = hid_dev;
-
-	/* Modifiers and locks */
-	kbd_dev->mods = DEFAULT_ACTIVE_MODS;
-
-	/* Autorepeat */
-	kbd_dev->repeat.delay_before = DEFAULT_DELAY_BEFORE_FIRST_REPEAT;
-	kbd_dev->repeat.delay_between = DEFAULT_REPEAT_DELAY;
-
-
-	// TODO: make more general
-	usb_hid_report_path_t *path = usb_hid_report_path();
-	if (path == NULL) {
-		usb_log_error("Failed to create kbd report path.\n");
-		usb_kbd_destroy(kbd_dev);
-		return ENOMEM;
-	}
-
-	int ret =
-	    usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_KEYBOARD, 0);
-	if (ret != EOK) {
-		usb_log_error("Failed to append item to kbd report path.\n");
-		usb_hid_report_path_free(path);
-		usb_kbd_destroy(kbd_dev);
-		return ret;
-	}
-
-	usb_hid_report_path_set_report_id(path, 0);
-
-	kbd_dev->key_count =
-	    usb_hid_report_size(&hid_dev->report, 0, USB_HID_REPORT_TYPE_INPUT);
-
-	usb_hid_report_path_free(path);
-
-	usb_log_debug("Size of the input report: %zu\n", kbd_dev->key_count);
-
-	kbd_dev->keys = calloc(kbd_dev->key_count, sizeof(int32_t));
-	if (kbd_dev->keys == NULL) {
-		usb_log_error("Failed to allocate key buffer.\n");
-		usb_kbd_destroy(kbd_dev);
-		return ENOMEM;
-	}
-
-	kbd_dev->keys_old = calloc(kbd_dev->key_count, sizeof(int32_t));
-	if (kbd_dev->keys_old == NULL) {
-		usb_log_error("Failed to allocate old_key buffer.\n");
-		usb_kbd_destroy(kbd_dev);
-		return ENOMEM;
-	}
-
-	/* Output report */
-	kbd_dev->output_size = 0;
-	kbd_dev->output_buffer = usb_hid_report_output(&hid_dev->report,
-	    &kbd_dev->output_size, 0);
-	if (kbd_dev->output_buffer == NULL) {
-		usb_log_error("Error creating output report buffer.\n");
-		usb_kbd_destroy(kbd_dev);
-		return ENOMEM;
-	}
-
-	usb_log_debug("Output buffer size: %zu\n", kbd_dev->output_size);
-
-	kbd_dev->led_path = usb_hid_report_path();
-	if (kbd_dev->led_path == NULL) {
-		usb_log_error("Failed to create kbd led report path.\n");
-		usb_kbd_destroy(kbd_dev);
-		return ENOMEM;
-	}
-
-	ret = usb_hid_report_path_append_item(
-	    kbd_dev->led_path, USB_HIDUT_PAGE_LED, 0);
-	if (ret != EOK) {
-		usb_log_error("Failed to append to kbd/led report path.\n");
-		usb_kbd_destroy(kbd_dev);
-		return ret;
-	}
-
-	kbd_dev->led_output_size = usb_hid_report_size(
-	    &hid_dev->report, 0, USB_HID_REPORT_TYPE_OUTPUT);
-
-	usb_log_debug("Output report size (in items): %zu\n",
-	    kbd_dev->led_output_size);
-
-	kbd_dev->led_data = calloc(kbd_dev->led_output_size, sizeof(int32_t));
-	if (kbd_dev->led_data == NULL) {
-		usb_log_error("Error creating buffer for LED output report.\n");
-		usb_kbd_destroy(kbd_dev);
-		return ENOMEM;
-	}
-
-	/* Set LEDs according to initial setup.
-	 * Set Idle rate */
-	usb_kbd_set_led(hid_dev, kbd_dev);
-
-	usbhid_req_set_idle(&hid_dev->usb_dev->ctrl_pipe,
-	    hid_dev->usb_dev->interface_no, IDLE_RATE);
-
-	/* Save the KBD device structure into the HID device structure. */
-	*data = kbd_dev;
-
-	kbd_dev->initialized = USB_KBD_STATUS_INITIALIZED;
-	usb_log_debug("HID/KBD device structure initialized.\n");
-
-	usb_log_debug("Creating KBD function...\n");
-	ret = usb_kbd_create_function(kbd_dev);
-	if (ret != EOK) {
-		usb_kbd_destroy(kbd_dev);
 		return ret;
 	}
@@ -693,4 +691,7 @@
 	}
 	fibril_add_ready(fid);
+	kbd_dev->fun = fun;
+	/* Save the KBD device structure into the HID device structure. */
+	*data = kbd_dev;
 
 	return EOK;
@@ -787,6 +788,8 @@
 	}
 
-	rc = usbhid_req_set_protocol(&hid_dev->usb_dev->ctrl_pipe,
-	    hid_dev->usb_dev->interface_no, USB_HID_PROTOCOL_BOOT);
+	rc = usbhid_req_set_protocol(
+	    usb_device_get_default_pipe(hid_dev->usb_dev),
+	    usb_device_get_iface_number(hid_dev->usb_dev),
+	    USB_HID_PROTOCOL_BOOT);
 
 	if (rc != EOK) {
Index: uspace/drv/bus/usb/usbhid/main.c
===================================================================
--- uspace/drv/bus/usb/usbhid/main.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/usbhid/main.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -65,5 +65,5 @@
 	}
 
-	if (dev->interface_no < 0) {
+	if (usb_device_get_iface_number(dev) < 0) {
 		usb_log_error("Failed to add HID device: endpoints not found."
 		    "\n");
@@ -89,11 +89,13 @@
 	 * This will create a separate fibril that will query the device
 	 * for the data continuously. */
-       rc = usb_device_auto_poll(dev,
+	rc = usb_device_auto_poll_desc(dev,
 	   /* Index of the polling pipe. */
-	   hid_dev->poll_pipe_index,
+	   hid_dev->poll_pipe_mapping->description,
 	   /* Callback when data arrives. */
 	   usb_hid_polling_callback,
 	   /* How much data to request. */
-	   dev->pipes[hid_dev->poll_pipe_index].pipe.max_packet_size,
+	   hid_dev->poll_pipe_mapping->pipe.max_packet_size,
+	   /* Delay */
+	   -1,
 	   /* Callback when the polling ends. */
 	   usb_hid_polling_ended_callback,
@@ -103,5 +105,5 @@
 	if (rc != EOK) {
 		usb_log_error("Failed to start polling fibril for `%s'.\n",
-		    ddf_dev_get_name(dev->ddf_dev));
+		    usb_device_get_name(dev));
 		usb_hid_deinit(hid_dev);
 		return rc;
@@ -109,6 +111,5 @@
 	hid_dev->running = true;
 
-	usb_log_info("HID device `%s' ready to use.\n",
-	    ddf_dev_get_name(dev->ddf_dev));
+	usb_log_info("HID device `%s' ready.\n", usb_device_get_name(dev));
 
 	return EOK;
@@ -137,6 +138,6 @@
 {
 	assert(dev);
-	assert(dev->driver_data);
-	usb_hid_dev_t *hid_dev = dev->driver_data;
+	usb_hid_dev_t *hid_dev = usb_device_data_get(dev);
+	assert(hid_dev);
 	unsigned tries = 100;
 	/* Wait for fail. */
@@ -150,5 +151,5 @@
 
 	usb_hid_deinit(hid_dev);
-	usb_log_debug2("%s destruction complete.\n", ddf_dev_get_name(dev->ddf_dev));
+	usb_log_debug2("%s destruction complete.\n", usb_device_get_name(dev));
 	return EOK;
 }
Index: uspace/drv/bus/usb/usbhid/mouse/mousedev.c
===================================================================
--- uspace/drv/bus/usb/usbhid/mouse/mousedev.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/usbhid/mouse/mousedev.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -34,7 +34,4 @@
  * USB Mouse driver API.
  */
-
-/* XXX Fix this */
-#define _DDF_DATA_IMPLANT
 
 #include <usb/debug.h>
@@ -259,44 +256,4 @@
 } else (void)0
 
-static int usb_mouse_create_function(usb_hid_dev_t *hid_dev, usb_mouse_t *mouse)
-{
-	assert(hid_dev != NULL);
-	assert(mouse != NULL);
-
-	/* Create the exposed function. */
-	usb_log_debug("Creating DDF function %s...\n", HID_MOUSE_FUN_NAME);
-	ddf_fun_t *fun = ddf_fun_create(hid_dev->usb_dev->ddf_dev, fun_exposed,
-	    HID_MOUSE_FUN_NAME);
-	if (fun == NULL) {
-		usb_log_error("Could not create DDF function node `%s'.\n",
-		    HID_MOUSE_FUN_NAME);
-		return ENOMEM;
-	}
-
-	ddf_fun_set_ops(fun, &ops);
-	ddf_fun_data_implant(fun, mouse);
-
-	int rc = ddf_fun_bind(fun);
-	if (rc != EOK) {
-		usb_log_error("Could not bind DDF function `%s': %s.\n",
-		    ddf_fun_get_name(fun), str_error(rc));
-		ddf_fun_destroy(fun);
-		return rc;
-	}
-
-	usb_log_debug("Adding DDF function `%s' to category %s...\n",
-	    ddf_fun_get_name(fun), HID_MOUSE_CATEGORY);
-	rc = ddf_fun_add_to_category(fun, HID_MOUSE_CATEGORY);
-	if (rc != EOK) {
-		usb_log_error(
-		    "Could not add DDF function to category %s: %s.\n",
-		    HID_MOUSE_CATEGORY, str_error(rc));
-		FUN_UNBIND_DESTROY(fun);
-		return rc;
-	}
-	mouse->mouse_fun = fun;
-	return EOK;
-}
-
 /** Get highest index of a button mentioned in given report.
  *
@@ -339,21 +296,6 @@
 }
 
-int usb_mouse_init(usb_hid_dev_t *hid_dev, void **data)
-{
-	usb_log_debug("Initializing HID/Mouse structure...\n");
-
-	if (hid_dev == NULL) {
-		usb_log_error("Failed to init keyboard structure: no structure"
-		    " given.\n");
-		return EINVAL;
-	}
-
-	usb_mouse_t *mouse_dev = calloc(1, sizeof(usb_mouse_t));
-	if (mouse_dev == NULL) {
-		usb_log_error("Error while creating USB/HID Mouse device "
-		    "structure.\n");
-		return ENOMEM;
-	}
-
+static int mouse_dev_init(usb_mouse_t *mouse_dev, usb_hid_dev_t *hid_dev)
+{
 	// FIXME: This may not be optimal since stupid hardware vendor may
 	// use buttons 1, 2, 3 and 6000 and we would allocate array of
@@ -373,13 +315,63 @@
 
 	// TODO: how to know if the device supports the request???
-	usbhid_req_set_idle(&hid_dev->usb_dev->ctrl_pipe,
-	    hid_dev->usb_dev->interface_no, IDLE_RATE);
-
-	int rc = usb_mouse_create_function(hid_dev, mouse_dev);
-	if (rc != EOK) {
-		free(mouse_dev->buttons);
-		free(mouse_dev);
-		return rc;
-	}
+	usbhid_req_set_idle(usb_device_get_default_pipe(hid_dev->usb_dev),
+	    usb_device_get_iface_number(hid_dev->usb_dev), IDLE_RATE);
+	return EOK;
+}
+
+int usb_mouse_init(usb_hid_dev_t *hid_dev, void **data)
+{
+	usb_log_debug("Initializing HID/Mouse structure...\n");
+
+	if (hid_dev == NULL) {
+		usb_log_error("Failed to init keyboard structure: no structure"
+		    " given.\n");
+		return EINVAL;
+	}
+
+	/* Create the exposed function. */
+	usb_log_debug("Creating DDF function %s...\n", HID_MOUSE_FUN_NAME);
+	ddf_fun_t *fun = usb_device_ddf_fun_create(hid_dev->usb_dev,
+	    fun_exposed, HID_MOUSE_FUN_NAME);
+	if (fun == NULL) {
+		usb_log_error("Could not create DDF function node `%s'.\n",
+		    HID_MOUSE_FUN_NAME);
+		return ENOMEM;
+	}
+
+	usb_mouse_t *mouse_dev = ddf_fun_data_alloc(fun, sizeof(usb_mouse_t));
+	if (mouse_dev == NULL) {
+		usb_log_error("Failed to alloc HID mouse device structure.\n");
+		ddf_fun_destroy(fun);
+		return ENOMEM;
+	}
+
+	int ret = mouse_dev_init(mouse_dev, hid_dev);
+	if (ret != EOK) {
+		usb_log_error("Failed to init HID mouse device structure.\n");
+		return ret;
+	}
+
+	ddf_fun_set_ops(fun, &ops);
+
+	ret = ddf_fun_bind(fun);
+	if (ret != EOK) {
+		usb_log_error("Could not bind DDF function `%s': %s.\n",
+		    ddf_fun_get_name(fun), str_error(ret));
+		ddf_fun_destroy(fun);
+		return ret;
+	}
+
+	usb_log_debug("Adding DDF function `%s' to category %s...\n",
+	    ddf_fun_get_name(fun), HID_MOUSE_CATEGORY);
+	ret = ddf_fun_add_to_category(fun, HID_MOUSE_CATEGORY);
+	if (ret != EOK) {
+		usb_log_error(
+		    "Could not add DDF function to category %s: %s.\n",
+		    HID_MOUSE_CATEGORY, str_error(ret));
+		FUN_UNBIND_DESTROY(fun);
+		return ret;
+	}
+	mouse_dev->mouse_fun = fun;
 
 	/* Save the Mouse device structure into the HID device structure. */
@@ -417,7 +409,6 @@
 	}
 
+	free(mouse_dev->buttons);
 	FUN_UNBIND_DESTROY(mouse_dev->mouse_fun);
-
-	free(mouse_dev->buttons);
 }
 
@@ -434,6 +425,8 @@
 	}
 
-	rc = usbhid_req_set_protocol(&hid_dev->usb_dev->ctrl_pipe,
-	    hid_dev->usb_dev->interface_no, USB_HID_PROTOCOL_BOOT);
+	rc = usbhid_req_set_protocol(
+	    usb_device_get_default_pipe(hid_dev->usb_dev),
+	    usb_device_get_iface_number(hid_dev->usb_dev),
+	    USB_HID_PROTOCOL_BOOT);
 
 	if (rc != EOK) {
Index: uspace/drv/bus/usb/usbhid/multimedia/multimedia.c
===================================================================
--- uspace/drv/bus/usb/usbhid/multimedia/multimedia.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/usbhid/multimedia/multimedia.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -161,6 +161,6 @@
 
 	/* Create the exposed function. */
-	ddf_fun_t *fun = ddf_fun_create(
-	    hid_dev->usb_dev->ddf_dev, fun_exposed, NAME);
+	ddf_fun_t *fun = usb_device_ddf_fun_create(
+	    hid_dev->usb_dev, fun_exposed, NAME);
 	if (fun == NULL) {
 		usb_log_error("Could not create DDF function node.\n");
Index: uspace/drv/bus/usb/usbhid/usbhid.c
===================================================================
--- uspace/drv/bus/usb/usbhid/usbhid.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/usbhid/usbhid.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -41,5 +41,7 @@
 #include <usb/hid/hidreport.h>
 #include <usb/hid/request.h>
+
 #include <errno.h>
+#include <macros.h>
 #include <str_error.h>
 
@@ -114,11 +116,12 @@
     const usb_hid_subdriver_mapping_t *mapping)
 {
-	assert(hid_dev != NULL);
-	assert(hid_dev->usb_dev != NULL);
-
-	return (hid_dev->usb_dev->descriptors.device.vendor_id
-	    == mapping->vendor_id
-	    && hid_dev->usb_dev->descriptors.device.product_id
-	    == mapping->product_id);
+	assert(hid_dev);
+	assert(hid_dev->usb_dev);
+	assert(mapping);
+	const usb_standard_device_descriptor_t *d =
+	    &usb_device_descriptors(hid_dev->usb_dev)->device;
+
+	return (d->vendor_id == mapping->vendor_id)
+	    && (d->product_id == mapping->product_id);
 }
 
@@ -264,5 +267,5 @@
 }
 
-static int usb_hid_check_pipes(usb_hid_dev_t *hid_dev, const usb_device_t *dev)
+static int usb_hid_check_pipes(usb_hid_dev_t *hid_dev, usb_device_t *dev)
 {
 	assert(hid_dev);
@@ -270,19 +273,18 @@
 
 	static const struct {
-		unsigned ep_number;
+		const usb_endpoint_description_t *desc;
 		const char* description;
 	} endpoints[] = {
-		{USB_HID_KBD_POLL_EP_NO, "Keyboard endpoint"},
-		{USB_HID_MOUSE_POLL_EP_NO, "Mouse endpoint"},
-		{USB_HID_GENERIC_POLL_EP_NO, "Generic HID endpoint"},
+		{&usb_hid_kbd_poll_endpoint_description, "Keyboard endpoint"},
+		{&usb_hid_mouse_poll_endpoint_description, "Mouse endpoint"},
+		{&usb_hid_generic_poll_endpoint_description, "Generic HID endpoint"},
 	};
 
-	for (unsigned i = 0; i < sizeof(endpoints)/sizeof(endpoints[0]); ++i) {
-		if (endpoints[i].ep_number >= dev->pipes_count) {
-			return EINVAL;
-		}
-		if (dev->pipes[endpoints[i].ep_number].present) {
+	for (unsigned i = 0; i < ARRAY_SIZE(endpoints); ++i) {
+		usb_endpoint_mapping_t *epm =
+		    usb_device_get_mapped_ep_desc(dev, endpoints[i].desc);
+		if (epm && epm->present) {
 			usb_log_debug("Found: %s.\n", endpoints[i].description);
-			hid_dev->poll_pipe_index = endpoints[i].ep_number;
+			hid_dev->poll_pipe_mapping = epm;
 			return EOK;
 		}
@@ -351,5 +353,5 @@
 	/* The USB device should already be initialized, save it in structure */
 	hid_dev->usb_dev = dev;
-	hid_dev->poll_pipe_index = -1;
+	hid_dev->poll_pipe_mapping = NULL;
 
 	int rc = usb_hid_check_pipes(hid_dev, dev);
@@ -381,6 +383,6 @@
 		    "boot protocol.\n");
 
-		switch (hid_dev->poll_pipe_index) {
-		case USB_HID_KBD_POLL_EP_NO:
+		switch (hid_dev->poll_pipe_mapping->interface->interface_protocol) {
+		case USB_HID_PROTOCOL_KEYBOARD:
 			usb_log_info("Falling back to kbd boot protocol.\n");
 			rc = usb_kbd_set_boot_protocol(hid_dev);
@@ -389,5 +391,5 @@
 			}
 			break;
-		case USB_HID_MOUSE_POLL_EP_NO:
+		case USB_HID_PROTOCOL_MOUSE:
 			usb_log_info("Falling back to mouse boot protocol.\n");
 			rc = usb_mouse_set_boot_protocol(hid_dev);
@@ -397,6 +399,4 @@
 			break;
 		default:
-			assert(hid_dev->poll_pipe_index
-			    == USB_HID_GENERIC_POLL_EP_NO);
 			usb_log_info("Falling back to generic HID driver.\n");
 			usb_hid_set_generic_hid_subdriver(hid_dev);
@@ -485,5 +485,5 @@
 	    &hid_dev->report, buffer, buffer_size, &hid_dev->report_id);
 	if (rc != EOK) {
-		usb_log_warning("Error in usb_hid_parse_report():"
+		usb_log_warning("Failure in usb_hid_parse_report():"
 		    "%s\n", str_error(rc));
 	}
Index: uspace/drv/bus/usb/usbhid/usbhid.h
===================================================================
--- uspace/drv/bus/usb/usbhid/usbhid.h	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/usbhid/usbhid.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -103,6 +103,6 @@
 	usb_device_t *usb_dev;
 
-	/** Index of the polling pipe in usb_hid_endpoints array. */
-	unsigned poll_pipe_index;
+	/** Endpont mapping of the polling pipe. */
+	usb_endpoint_mapping_t *poll_pipe_mapping;
 
 	/** Subdrivers. */
@@ -132,16 +132,5 @@
 };
 
-
-
-enum {
-	USB_HID_KBD_POLL_EP_NO = 0,
-	USB_HID_MOUSE_POLL_EP_NO = 1,
-	USB_HID_GENERIC_POLL_EP_NO = 2,
-	USB_HID_POLL_EP_COUNT = 3
-};
-
 extern const usb_endpoint_description_t *usb_hid_endpoints[];
-
-
 
 int usb_hid_init(usb_hid_dev_t *hid_dev, usb_device_t *dev);
Index: uspace/drv/bus/usb/usbhub/main.c
===================================================================
--- uspace/drv/bus/usb/usbhub/main.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/usbhub/main.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -43,17 +43,4 @@
 #include "usbhub.h"
 
-/** Hub status-change endpoint description.
- *
- * For more information see section 11.15.1 of USB 1.1 specification.
- */
-static const usb_endpoint_description_t hub_status_change_endpoint_description =
-{
-	.transfer_type = USB_TRANSFER_INTERRUPT,
-	.direction = USB_DIRECTION_IN,
-	.interface_class = USB_CLASS_HUB,
-	.interface_subclass = 0,
-	.interface_protocol = 0,
-	.flags = 0
-};
 
 /** USB hub driver operations. */
Index: uspace/drv/bus/usb/usbhub/port.c
===================================================================
--- uspace/drv/bus/usb/usbhub/port.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/usbhub/port.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -41,5 +41,4 @@
 
 #include <usb/debug.h>
-#include <usb/dev/hub.h>
 
 #include "port.h"
@@ -58,5 +57,4 @@
     usb_port_status_t status);
 static int get_port_status(usb_hub_port_t *port, usb_port_status_t *status);
-static int enable_port_callback(void *arg);
 static int add_device_phase1_worker_fibril(void *arg);
 static int create_add_device_fibril(usb_hub_port_t *port, usb_hub_dev_t *hub,
@@ -66,5 +64,5 @@
 {
 	assert(port);
-	if (port->attached_device.fun)
+	if (port->device_attached)
 		return usb_hub_port_device_gone(port, hub);
 	return EOK;
@@ -141,10 +139,10 @@
 	assert(port);
 	assert(hub);
-	usb_log_debug("Interrupt at port %zu\n", port->port_number);
+	usb_log_debug("Interrupt at port %u\n", port->port_number);
 
 	usb_port_status_t status = 0;
 	const int opResult = get_port_status(port, &status);
 	if (opResult != EOK) {
-		usb_log_error("Failed to get port %zu status: %s.\n",
+		usb_log_error("Failed to get port %u status: %s.\n",
 		    port->port_number, str_error(opResult));
 		return;
@@ -155,5 +153,5 @@
 		const bool connected =
 		    (status & USB_HUB_PORT_STATUS_CONNECTION) != 0;
-		usb_log_debug("Connection change on port %zu: device %s.\n",
+		usb_log_debug("Connection change on port %u: device %s.\n",
 		    port->port_number, connected ? "attached" : "removed");
 
@@ -171,5 +169,5 @@
 			if (opResult != EOK) {
 				usb_log_error(
-				    "Cannot handle change on port %zu: %s.\n",
+				    "Cannot handle change on port %u: %s.\n",
 				    port->port_number, str_error(opResult));
 			}
@@ -185,5 +183,5 @@
 	/* Enable change, ports are automatically disabled on errors. */
 	if (status & USB_HUB_PORT_C_STATUS_ENABLED) {
-		usb_log_info("Port %zu, disabled because of errors.\n",
+		usb_log_info("Port %u, disabled because of errors.\n",
 		   port->port_number);
 		usb_hub_port_device_gone(port, hub);
@@ -192,5 +190,5 @@
 		if (rc != EOK) {
 			usb_log_error(
-			    "Failed to clear port %zu enable change feature: "
+			    "Failed to clear port %u enable change feature: "
 			    "%s.\n", port->port_number, str_error(rc));
 		}
@@ -200,5 +198,5 @@
 	/* Suspend change */
 	if (status & USB_HUB_PORT_C_STATUS_SUSPEND) {
-		usb_log_error("Port %zu went to suspend state, this should"
+		usb_log_error("Port %u went to suspend state, this should"
 		    "NOT happen as we do not support suspend state!",
 		    port->port_number);
@@ -207,5 +205,5 @@
 		if (rc != EOK) {
 			usb_log_error(
-			    "Failed to clear port %zu suspend change feature: "
+			    "Failed to clear port %u suspend change feature: "
 			    "%s.\n", port->port_number, str_error(rc));
 		}
@@ -223,5 +221,5 @@
 		if (rc != EOK) {
 			usb_log_error(
-			    "Failed to clear port %zu OC change feature: %s.\n",
+			    "Failed to clear port %u OC change feature: %s.\n",
 			    port->port_number, str_error(rc));
 		}
@@ -231,5 +229,5 @@
 			if (rc != EOK) {
 				usb_log_error(
-				    "Failed to set port %zu power after OC:"
+				    "Failed to set port %u power after OC:"
 				    " %s.\n", port->port_number, str_error(rc));
 			}
@@ -242,5 +240,5 @@
 	}
 
-	usb_log_debug("Port %zu status 0x%08" PRIx32 "\n",
+	usb_log_debug("Port %u status %#08" PRIx32 "\n",
 	    port->port_number, status);
 }
@@ -259,43 +257,13 @@
 	assert(port);
 	assert(hub);
-	if (port->attached_device.address < 0) {
-		usb_log_warning(
-		    "Device on port %zu removed before being registered.\n",
-		    port->port_number);
-
-		/*
-		 * Device was removed before port reset completed.
-		 * We will announce a failed port reset to unblock the
-		 * port reset callback from new device wrapper.
-		 */
-		usb_hub_port_reset_fail(port);
-		return EOK;
-	}
-
-	fibril_mutex_lock(&port->mutex);
-	assert(port->attached_device.fun);
-	usb_log_debug("Removing device on port %zu.\n", port->port_number);
-	int ret = ddf_fun_unbind(port->attached_device.fun);
-	if (ret != EOK) {
-		usb_log_error("Failed to unbind child function on port"
-		    " %zu: %s.\n", port->port_number, str_error(ret));
-		fibril_mutex_unlock(&port->mutex);
-		return ret;
-	}
-
-	ddf_fun_destroy(port->attached_device.fun);
-	port->attached_device.fun = NULL;
-
-	ret = usb_hub_unregister_device(&hub->usb_device->hc_conn,
-	    &port->attached_device);
-	if (ret != EOK) {
-		usb_log_warning("Failed to unregister address of the "
-		    "removed device: %s.\n", str_error(ret));
-	}
-
-	port->attached_device.address = -1;
-	fibril_mutex_unlock(&port->mutex);
-	usb_log_info("Removed device on port %zu.\n", port->port_number);
-	return EOK;
+	async_exch_t *exch = usb_device_bus_exchange_begin(hub->usb_device);
+	if (!exch)
+		return ENOMEM;
+	const int rc = usb_device_remove(exch, port->port_number);
+	usb_device_bus_exchange_end(exch);
+	if (rc == EOK)
+		port->device_attached = false;
+	return rc;
+
 }
 
@@ -318,8 +286,8 @@
 
 	if (port->reset_okay) {
-		usb_log_debug("Port %zu reset complete.\n", port->port_number);
+		usb_log_debug("Port %u reset complete.\n", port->port_number);
 	} else {
 		usb_log_warning(
-		    "Port %zu reset complete but port not enabled.\n",
+		    "Port %u reset complete but port not enabled.\n",
 		    port->port_number);
 	}
@@ -331,5 +299,5 @@
 	if (rc != EOK) {
 		usb_log_error(
-		    "Failed to clear port %zu reset change feature: %s.\n",
+		    "Failed to clear port %u reset change feature: %s.\n",
 		    port->port_number, str_error(rc));
 	}
@@ -376,34 +344,26 @@
 }
 
-/** 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_dev_t.
- * @return Error code.
- */
-static int enable_port_callback(void *arg)
-{
-	usb_hub_port_t *port = arg;
-	assert(port);
-	const int rc =
-	    usb_hub_port_set_feature(port, USB_HUB_FEATURE_PORT_RESET);
-	if (rc != EOK) {
-		usb_log_warning("Port reset failed: %s.\n", str_error(rc));
-		return rc;
-	}
-
-	/*
-	 * Wait until reset completes.
-	 */
-	fibril_mutex_lock(&port->mutex);
-	while (!port->reset_completed) {
-		fibril_condvar_wait(&port->reset_cv, &port->mutex);
-	}
-	fibril_mutex_unlock(&port->mutex);
-
-	return port->reset_okay ? EOK : ESTALL;
+static int port_enable(usb_hub_port_t *port, bool enable)
+{
+	if (enable) {
+		const int rc =
+		    usb_hub_port_set_feature(port, USB_HUB_FEATURE_PORT_RESET);
+		if (rc != EOK) {
+			usb_log_error("Port reset failed: %s.\n",
+			    str_error(rc));
+		} else {
+			/* Wait until reset completes. */
+			fibril_mutex_lock(&port->mutex);
+			while (!port->reset_completed) {
+				fibril_condvar_wait(&port->reset_cv,
+				    &port->mutex);
+			}
+			fibril_mutex_unlock(&port->mutex);
+		}
+		return port->reset_okay ? EOK : ESTALL;
+	} else {
+		return usb_hub_port_clear_feature(port,
+				USB_HUB_FEATURE_PORT_ENABLE);
+	}
 }
 
@@ -418,40 +378,67 @@
 int add_device_phase1_worker_fibril(void *arg)
 {
-	struct add_device_phase1 *data = arg;
-	assert(data);
-
-	usb_address_t new_address;
-	ddf_fun_t *child_fun;
-
-	const int rc = usb_hc_new_device_wrapper(data->hub->usb_device->ddf_dev,
-	    &data->hub->usb_device->hc_conn, data->speed, enable_port_callback,
-	    data->port, &new_address, NULL, NULL, &child_fun);
-
-	if (rc == EOK) {
-		fibril_mutex_lock(&data->port->mutex);
-		data->port->attached_device.fun = child_fun;
-		data->port->attached_device.address = new_address;
-		fibril_mutex_unlock(&data->port->mutex);
-
-		usb_log_info("Detected new device on `%s' (port %zu), "
-		    "address %d (handle %" PRIun ").\n",
-		    ddf_dev_get_name(data->hub->usb_device->ddf_dev),
-		    data->port->port_number, new_address,
-		    ddf_fun_get_handle(child_fun));
+	struct add_device_phase1 *params = arg;
+	assert(params);
+
+	int ret = EOK;
+	usb_hub_dev_t *hub = params->hub;
+	usb_hub_port_t *port = params->port;
+	const usb_speed_t speed = params->speed;
+	free(arg);
+
+	async_exch_t *exch = usb_device_bus_exchange_begin(hub->usb_device);
+	if (!exch) {
+		usb_log_error("Failed to begin bus exchange\n");
+		ret = ENOMEM;
+		goto out;
+	}
+
+	/* Reserve default address */
+	while ((ret = usb_reserve_default_address(exch, speed)) == ENOENT) {
+		async_usleep(1000000);
+	}
+	if (ret != EOK) {
+		usb_log_error("Failed to reserve default address: %s\n",
+		    str_error(ret));
+		goto out;
+	}
+
+	/* Reset port */
+	port_enable(port, true);
+	if (!port->reset_completed || !port->reset_okay) {
+		usb_log_error("Failed to reset port %u\n", port->port_number);
+		if (usb_release_default_address(exch) != EOK)
+			usb_log_warning("Failed to release default address\n");
+		ret = EIO;
+		goto out;
+	}
+
+	ret = usb_device_enumerate(exch, port->port_number);
+	if (ret != EOK) {
+		usb_log_error("Failed to enumerate device on port %u\n",
+		    port->port_number);
+		if (port_enable(port, false) != EOK) {
+			usb_log_warning("Failed to disable port %u, NOT "
+			    "releasing default address.\n", port->port_number);
+		} else {
+			if (usb_release_default_address(exch) != EOK)
+				usb_log_warning(
+				    "Failed to release default address\n");
+		}
 	} else {
-		usb_log_error("Failed registering device on port %zu: %s.\n",
-		    data->port->port_number, str_error(rc));
-	}
-
-
-	fibril_mutex_lock(&data->hub->pending_ops_mutex);
-	assert(data->hub->pending_ops_count > 0);
-	--data->hub->pending_ops_count;
-	fibril_condvar_signal(&data->hub->pending_ops_cv);
-	fibril_mutex_unlock(&data->hub->pending_ops_mutex);
-
-	free(arg);
-
-	return rc;
+		port->device_attached = true;
+		if (usb_release_default_address(exch) != EOK)
+			usb_log_warning("Failed to release default address\n");
+	}
+out:
+	usb_device_bus_exchange_end(exch);
+
+	fibril_mutex_lock(&hub->pending_ops_mutex);
+	assert(hub->pending_ops_count > 0);
+	--hub->pending_ops_count;
+	fibril_condvar_signal(&hub->pending_ops_cv);
+	fibril_mutex_unlock(&hub->pending_ops_mutex);
+
+	return ret;
 }
 
Index: uspace/drv/bus/usb/usbhub/port.h
===================================================================
--- uspace/drv/bus/usb/usbhub/port.h	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/usbhub/port.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -37,6 +37,6 @@
 
 #include <usb/dev/driver.h>
-#include <usb/dev/hub.h>
 #include <usb/classes/hub.h>
+#include <usb_iface.h>
 
 typedef struct usb_hub_dev usb_hub_dev_t;
@@ -44,6 +44,6 @@
 /** Information about single port on a hub. */
 typedef struct {
-	/* Port number as reported in descriptors. */
-	size_t port_number;
+	/** Port number as reported in descriptors. */
+	unsigned port_number;
 	/** Device communication pipe. */
 	usb_pipe_t *control_pipe;
@@ -58,7 +58,6 @@
 	/** Whether to announce the port reset as successful. */
 	bool reset_okay;
-
-	/** Information about attached device. */
-	usb_hub_attached_device_t attached_device;
+	/** Device reported to USB bus driver */
+	bool device_attached;
 } usb_hub_port_t;
 
@@ -67,12 +66,13 @@
  * @param port Port to be initialized.
  */
-static inline void usb_hub_port_init(usb_hub_port_t *port, size_t port_number,
+static inline void usb_hub_port_init(usb_hub_port_t *port, unsigned port_number,
     usb_pipe_t *control_pipe)
 {
 	assert(port);
-	port->attached_device.address = -1;
-	port->attached_device.fun = NULL;
 	port->port_number = port_number;
 	port->control_pipe = control_pipe;
+	port->reset_completed = false;
+	port->reset_okay = false;
+	port->device_attached = false;
 	fibril_mutex_initialize(&port->mutex);
 	fibril_condvar_initialize(&port->reset_cv);
Index: uspace/drv/bus/usb/usbhub/usbhub.c
===================================================================
--- uspace/drv/bus/usb/usbhub/usbhub.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/usbhub/usbhub.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -45,5 +45,4 @@
 #include <usb/dev/pipes.h>
 #include <usb/classes/classes.h>
-#include <usb/ddfiface.h>
 #include <usb/descriptor.h>
 #include <usb/dev/recognise.h>
@@ -57,4 +56,17 @@
 
 #define HUB_FNC_NAME "hub"
+/** Hub status-change endpoint description.
+ *
+ * For more information see section 11.15.1 of USB 1.1 specification.
+ */
+const usb_endpoint_description_t hub_status_change_endpoint_description =
+{
+	.transfer_type = USB_TRANSFER_INTERRUPT,
+	.direction = USB_DIRECTION_IN,
+	.interface_class = USB_CLASS_HUB,
+	.interface_subclass = 0,
+	.interface_protocol = 0,
+	.flags = 0
+};
 
 /** Standard get hub global status request */
@@ -99,16 +111,7 @@
 	fibril_condvar_initialize(&hub_dev->pending_ops_cv);
 
-
-	int opResult = usb_pipe_start_long_transfer(&usb_dev->ctrl_pipe);
-	if (opResult != EOK) {
-		usb_log_error("Failed to start long ctrl pipe transfer: %s\n",
-		    str_error(opResult));
-		return opResult;
-	}
-
 	/* Set hub's first configuration. (There should be only one) */
-	opResult = usb_set_first_configuration(usb_dev);
-	if (opResult != EOK) {
-		usb_pipe_end_long_transfer(&usb_dev->ctrl_pipe);
+	int opResult = usb_set_first_configuration(usb_dev);
+	if (opResult != EOK) {
 		usb_log_error("Could not set hub configuration: %s\n",
 		    str_error(opResult));
@@ -119,5 +122,4 @@
 	opResult = usb_hub_process_hub_specific_info(hub_dev);
 	if (opResult != EOK) {
-		usb_pipe_end_long_transfer(&usb_dev->ctrl_pipe);
 		usb_log_error("Could process hub specific info, %s\n",
 		    str_error(opResult));
@@ -127,8 +129,7 @@
 	/* Create hub control function. */
 	usb_log_debug("Creating DDF function '" HUB_FNC_NAME "'.\n");
-	hub_dev->hub_fun = ddf_fun_create(hub_dev->usb_device->ddf_dev,
+	hub_dev->hub_fun = usb_device_ddf_fun_create(hub_dev->usb_device,
 	    fun_exposed, HUB_FNC_NAME);
 	if (hub_dev->hub_fun == NULL) {
-		usb_pipe_end_long_transfer(&usb_dev->ctrl_pipe);
 		usb_log_error("Failed to create hub function.\n");
 		return ENOMEM;
@@ -138,5 +139,4 @@
 	opResult = ddf_fun_bind(hub_dev->hub_fun);
 	if (opResult != EOK) {
-		usb_pipe_end_long_transfer(&usb_dev->ctrl_pipe);
 		usb_log_error("Failed to bind hub function: %s.\n",
 		   str_error(opResult));
@@ -146,9 +146,9 @@
 
 	/* Start hub operation. */
-	opResult = usb_device_auto_poll(hub_dev->usb_device, 0,
-	    hub_port_changes_callback, ((hub_dev->port_count + 1 + 8) / 8),
-	    usb_hub_polling_terminated_callback, hub_dev);
-	if (opResult != EOK) {
-		usb_pipe_end_long_transfer(&usb_dev->ctrl_pipe);
+	opResult = usb_device_auto_poll_desc(hub_dev->usb_device,
+	    &hub_status_change_endpoint_description,
+	    hub_port_changes_callback, ((hub_dev->port_count + 1 + 7) / 8),
+	    -1, usb_hub_polling_terminated_callback, hub_dev);
+	if (opResult != EOK) {
 		/* Function is already bound */
 		ddf_fun_unbind(hub_dev->hub_fun);
@@ -160,7 +160,6 @@
 	hub_dev->running = true;
 	usb_log_info("Controlling hub '%s' (%zu ports).\n",
-	    ddf_dev_get_name(hub_dev->usb_device->ddf_dev), hub_dev->port_count);
-
-	usb_pipe_end_long_transfer(&usb_dev->ctrl_pipe);
+	    usb_device_get_name(hub_dev->usb_device), hub_dev->port_count);
+
 	return EOK;
 }
@@ -185,5 +184,5 @@
 {
 	assert(usb_dev);
-	usb_hub_dev_t *hub = usb_dev->driver_data;
+	usb_hub_dev_t *hub = usb_device_data_get(usb_dev);
 	assert(hub);
 	unsigned tries = 10;
@@ -199,10 +198,7 @@
 
 	for (size_t port = 0; port < hub->port_count; ++port) {
-		if (hub->ports[port].attached_device.fun) {
-			const int ret =
-			    usb_hub_port_fini(&hub->ports[port], hub);
-			if (ret != EOK)
-				return ret;
-		}
+		const int ret = usb_hub_port_fini(&hub->ports[port], hub);
+		if (ret != EOK)
+			return ret;
 	}
 	free(hub->ports);
@@ -247,5 +243,5 @@
 
 	/* N + 1 bit indicates change on port N */
-	for (size_t port = 0; port < hub->port_count + 1; port++) {
+	for (size_t port = 0; port < hub->port_count; ++port) {
 		const size_t bit = port + 1;
 		const bool change = (change_bitmap[bit / 8] >> (bit % 8)) & 1;
@@ -273,5 +269,6 @@
 	/* Get hub descriptor. */
 	usb_log_debug("Retrieving descriptor\n");
-	usb_pipe_t *control_pipe = &hub_dev->usb_device->ctrl_pipe;
+	usb_pipe_t *control_pipe =
+	    usb_device_get_default_pipe(hub_dev->usb_device);
 
 	usb_hub_descriptor_header_t descriptor;
@@ -311,5 +308,6 @@
 	}
 
-	usb_log_info("Hub port power switching enabled.\n");
+	usb_log_info("Hub port power switching enabled (%s).\n",
+	    hub_dev->per_port_power ? "per port" : "ganged");
 
 	for (size_t port = 0; port < hub_dev->port_count; ++port) {
@@ -319,5 +317,5 @@
 
 		if (ret != EOK) {
-			usb_log_error("Cannot power on port %zu: %s.\n",
+			usb_log_error("Cannot power on port %u: %s.\n",
 			    hub_dev->ports[port].port_number, str_error(ret));
 		} else {
@@ -345,5 +343,5 @@
 	/* Get number of possible configurations from device descriptor */
 	const size_t configuration_count =
-	    usb_device->descriptors.device.configuration_count;
+	    usb_device_descriptors(usb_device)->device.configuration_count;
 	usb_log_debug("Hub has %zu configurations.\n", configuration_count);
 
@@ -353,6 +351,11 @@
 	}
 
-	if (usb_device->descriptors.configuration_size
-	    < sizeof(usb_standard_configuration_descriptor_t)) {
+	// TODO: Make sure that the cast is correct
+	const size_t config_size =
+	    usb_device_descriptors(usb_device)->full_config_size;
+	const usb_standard_configuration_descriptor_t *config_descriptor =
+	    usb_device_descriptors(usb_device)->full_config;
+
+	if (config_size < sizeof(usb_standard_configuration_descriptor_t)) {
 	    usb_log_error("Configuration descriptor is not big enough"
 	        " to fit standard configuration descriptor.\n");
@@ -360,13 +363,9 @@
 	}
 
-	// TODO: Make sure that the cast is correct
-	usb_standard_configuration_descriptor_t *config_descriptor
-	    = (usb_standard_configuration_descriptor_t *)
-	    usb_device->descriptors.configuration;
-
 	/* Set configuration. Use the configuration that was in
 	 * usb_device->descriptors.configuration i.e. The first one. */
 	const int opResult = usb_request_set_configuration(
-	    &usb_device->ctrl_pipe, config_descriptor->configuration_number);
+	    usb_device_get_default_pipe(usb_device),
+	    config_descriptor->configuration_number);
 	if (opResult != EOK) {
 		usb_log_error("Failed to set hub configuration: %s.\n",
@@ -407,5 +406,5 @@
 		if (ret != EOK) {
 			usb_log_warning("HUB OVER-CURRENT GONE: Cannot power on"
-			    " port %zu: %s\n", hub_dev->ports[port].port_number,
+			    " port %u: %s\n", hub_dev->ports[port].port_number,
 			    str_error(ret));
 		} else {
@@ -428,5 +427,6 @@
 	assert(hub_dev->usb_device);
 	usb_log_debug("Global interrupt on a hub\n");
-	usb_pipe_t *control_pipe = &hub_dev->usb_device->ctrl_pipe;
+	usb_pipe_t *control_pipe =
+	    usb_device_get_default_pipe(hub_dev->usb_device);
 
 	usb_hub_status_t status;
@@ -452,5 +452,5 @@
 		/* Ack change in hub OC flag */
 		const int ret = usb_request_clear_feature(
-		    &hub_dev->usb_device->ctrl_pipe, USB_REQUEST_TYPE_CLASS,
+		    control_pipe, USB_REQUEST_TYPE_CLASS,
 		    USB_REQUEST_RECIPIENT_DEVICE,
 		    USB_HUB_FEATURE_C_HUB_OVER_CURRENT, 0);
Index: uspace/drv/bus/usb/usbhub/usbhub.h
===================================================================
--- uspace/drv/bus/usb/usbhub/usbhub.h	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/usbhub/usbhub.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -39,5 +39,4 @@
 #include <ddf/driver.h>
 
-#include <usb/dev/hub.h>
 #include <usb/classes/hub.h>
 
@@ -81,4 +80,6 @@
 };
 
+extern const usb_endpoint_description_t hub_status_change_endpoint_description;
+
 int usb_hub_device_add(usb_device_t *usb_dev);
 int usb_hub_device_remove(usb_device_t *usb_dev);
Index: uspace/drv/bus/usb/usbmast/bo_trans.c
===================================================================
--- uspace/drv/bus/usb/usbmast/bo_trans.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/usbmast/bo_trans.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -67,6 +67,6 @@
 	int retval = EOK;
 	size_t act_size;
-	usb_pipe_t *bulk_in_pipe = &mfun->mdev->usb_dev->pipes[BULK_IN_EP].pipe;
-	usb_pipe_t *bulk_out_pipe = &mfun->mdev->usb_dev->pipes[BULK_OUT_EP].pipe;
+	usb_pipe_t *bulk_in_pipe = mfun->mdev->bulk_in_pipe;
+	usb_pipe_t *bulk_out_pipe = mfun->mdev->bulk_out_pipe;
 	usb_direction_t ddir;
 	void *dbuf;
@@ -117,9 +117,11 @@
 		/* Clear stall condition and continue below to read CSW. */
 		if (ddir == USB_DIRECTION_IN) {
-			usb_pipe_clear_halt(&mfun->mdev->usb_dev->ctrl_pipe,
-			    &mfun->mdev->usb_dev->pipes[BULK_IN_EP].pipe);
+			usb_pipe_clear_halt(
+			    usb_device_get_default_pipe(mfun->mdev->usb_dev),
+			    bulk_in_pipe);
 		} else {
-			usb_pipe_clear_halt(&mfun->mdev->usb_dev->ctrl_pipe,
-			    &mfun->mdev->usb_dev->pipes[BULK_OUT_EP].pipe);
+			usb_pipe_clear_halt(
+			    usb_device_get_default_pipe(mfun->mdev->usb_dev),
+			    bulk_out_pipe);
 		}
         } else if (rc != EOK) {
@@ -197,7 +199,8 @@
 int usb_massstor_reset(usbmast_dev_t *mdev)
 {
-	return usb_control_request_set(&mdev->usb_dev->ctrl_pipe,
+	return usb_control_request_set(
+	    usb_device_get_default_pipe(mdev->usb_dev),
 	    USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE,
-	    0xFF, 0, mdev->usb_dev->interface_no, NULL, 0);
+	    0xFF, 0, usb_device_get_iface_number(mdev->usb_dev), NULL, 0);
 }
 
@@ -215,8 +218,8 @@
 	 */
 	usb_massstor_reset(mdev);
-	usb_pipe_clear_halt(&mdev->usb_dev->ctrl_pipe,
-	    &mdev->usb_dev->pipes[BULK_IN_EP].pipe);
-	usb_pipe_clear_halt(&mdev->usb_dev->ctrl_pipe,
-	    &mdev->usb_dev->pipes[BULK_OUT_EP].pipe);
+	usb_pipe_clear_halt(usb_device_get_default_pipe(mdev->usb_dev),
+	    mdev->bulk_in_pipe);
+	usb_pipe_clear_halt(usb_device_get_default_pipe(mdev->usb_dev),
+	    mdev->bulk_out_pipe);
 }
 
@@ -236,7 +239,9 @@
 	uint8_t max_lun;
 	size_t data_recv_len;
-	int rc = usb_control_request_get(&mdev->usb_dev->ctrl_pipe,
+	int rc = usb_control_request_get(
+	    usb_device_get_default_pipe(mdev->usb_dev),
 	    USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE,
-	    0xFE, 0, mdev->usb_dev->interface_no, &max_lun, 1, &data_recv_len);
+	    0xFE, 0, usb_device_get_iface_number(mdev->usb_dev), &max_lun, 1,
+	    &data_recv_len);
 	if (rc != EOK) {
 		return rc;
Index: uspace/drv/bus/usb/usbmast/main.c
===================================================================
--- uspace/drv/bus/usb/usbmast/main.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/usbmast/main.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -52,7 +52,4 @@
 #define NAME "usbmast"
 
-#define GET_BULK_IN(dev) ((dev)->pipes[BULK_IN_EP].pipe)
-#define GET_BULK_OUT(dev) ((dev)->pipes[BULK_OUT_EP].pipe)
-
 static const usb_endpoint_description_t bulk_in_ep = {
 	.transfer_type = USB_TRANSFER_BULK,
@@ -110,5 +107,5 @@
 static int usbmast_device_gone(usb_device_t *dev)
 {
-	usbmast_dev_t *mdev = dev->driver_data;
+	usbmast_dev_t *mdev = usb_device_data_get(dev);
 	assert(mdev);
 
@@ -150,4 +147,13 @@
 	unsigned i;
 
+	usb_endpoint_mapping_t *epm_in =
+	    usb_device_get_mapped_ep_desc(dev, &bulk_in_ep);
+	usb_endpoint_mapping_t *epm_out =
+	    usb_device_get_mapped_ep_desc(dev, &bulk_out_ep);
+	if (!epm_in || !epm_out || !epm_in->present || !epm_out->present) {
+		usb_log_error("Required EPs were not mapped.\n");
+		return ENOENT;
+	}
+
 	/* Allocate softstate */
 	mdev = usb_device_data_alloc(dev, sizeof(usbmast_dev_t));
@@ -157,14 +163,12 @@
 	}
 
-	mdev->ddf_dev = dev->ddf_dev;
 	mdev->usb_dev = dev;
 
-	usb_log_info("Initializing mass storage `%s'.\n", ddf_dev_get_name(dev->ddf_dev));
+	usb_log_info("Initializing mass storage `%s'.\n",
+	    usb_device_get_name(dev));
 	usb_log_debug("Bulk in endpoint: %d [%zuB].\n",
-	    dev->pipes[BULK_IN_EP].pipe.endpoint_no,
-	    dev->pipes[BULK_IN_EP].pipe.max_packet_size);
+	    epm_in->pipe.endpoint_no, epm_in->pipe.max_packet_size);
 	usb_log_debug("Bulk out endpoint: %d [%zuB].\n",
-	    dev->pipes[BULK_OUT_EP].pipe.endpoint_no,
-	    dev->pipes[BULK_OUT_EP].pipe.max_packet_size);
+	    epm_out->pipe.endpoint_no, epm_out->pipe.max_packet_size);
 
 	usb_log_debug("Get LUN count...\n");
@@ -177,4 +181,6 @@
 	}
 
+	mdev->bulk_in_pipe = &epm_in->pipe;
+	mdev->bulk_out_pipe = &epm_out->pipe;
 	for (i = 0; i < mdev->lun_count; i++) {
 		rc = usbmast_fun_create(mdev, i);
@@ -221,5 +227,5 @@
 	}
 
-	fun = ddf_fun_create(mdev->ddf_dev, fun_exposed, fun_name);
+	fun = usb_device_ddf_fun_create(mdev->usb_dev, fun_exposed, fun_name);
 	if (fun == NULL) {
 		usb_log_error("Failed to create DDF function %s.\n", fun_name);
@@ -252,5 +258,5 @@
 	if (rc != EOK) {
 		usb_log_warning("Failed to inquire device `%s': %s.\n",
-		    ddf_dev_get_name(mdev->ddf_dev), str_error(rc));
+		    usb_device_get_name(mdev->usb_dev), str_error(rc));
 		rc = EIO;
 		goto error;
@@ -259,5 +265,5 @@
 	usb_log_info("Mass storage `%s' LUN %u: " \
 	    "%s by %s rev. %s is %s (%s).\n",
-	    ddf_dev_get_name(mdev->ddf_dev),
+	    usb_device_get_name(mdev->usb_dev),
 	    lun,
 	    inquiry.product,
@@ -272,5 +278,5 @@
 	if (rc != EOK) {
 		usb_log_warning("Failed to read capacity, device `%s': %s.\n",
-		    ddf_dev_get_name(mdev->ddf_dev), str_error(rc));
+		    usb_device_get_name(mdev->usb_dev), str_error(rc));
 		rc = EIO;
 		goto error;
Index: uspace/drv/bus/usb/usbmast/scsi_ms.c
===================================================================
--- uspace/drv/bus/usb/usbmast/scsi_ms.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/usbmast/scsi_ms.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -88,5 +88,5 @@
 		if (rc != EOK) {
 			usb_log_error("Inquiry transport failed, device %s: %s.\n",
-			   ddf_dev_get_name(mfun->mdev->ddf_dev), str_error(rc));
+			   usb_device_get_name(mfun->mdev->usb_dev), str_error(rc));
 			return rc;
 		}
@@ -96,5 +96,5 @@
 
 		usb_log_error("SCSI command failed, device %s.\n",
-		    ddf_dev_get_name(mfun->mdev->ddf_dev));
+		    usb_device_get_name(mfun->mdev->usb_dev));
 
 		rc = usbmast_request_sense(mfun, &sense_buf, sizeof(sense_buf));
@@ -147,5 +147,5 @@
 	if (rc != EOK) {
 		usb_log_error("Inquiry transport failed, device %s: %s.\n",
-		   ddf_dev_get_name(mfun->mdev->ddf_dev), str_error(rc));
+		   usb_device_get_name(mfun->mdev->usb_dev), str_error(rc));
 		return rc;
 	}
@@ -153,5 +153,5 @@
 	if (cmd.status != CMDS_GOOD) {
 		usb_log_error("Inquiry command failed, device %s.\n",
-		   ddf_dev_get_name(mfun->mdev->ddf_dev));
+		   usb_device_get_name(mfun->mdev->usb_dev));
 		return EIO;
 	}
@@ -215,5 +215,5 @@
         if (rc != EOK || cmd.status != CMDS_GOOD) {
 		usb_log_error("Request Sense failed, device %s: %s.\n",
-		   ddf_dev_get_name(mfun->mdev->ddf_dev), str_error(rc));
+		   usb_device_get_name(mfun->mdev->usb_dev), str_error(rc));
 		return rc;
 	}
@@ -257,5 +257,5 @@
         if (rc != EOK) {
 		usb_log_error("Read Capacity (10) transport failed, device %s: %s.\n",
-		   ddf_dev_get_name(mfun->mdev->ddf_dev), str_error(rc));
+		   usb_device_get_name(mfun->mdev->usb_dev), str_error(rc));
 		return rc;
 	}
@@ -263,5 +263,5 @@
 	if (cmd.status != CMDS_GOOD) {
 		usb_log_error("Read Capacity (10) command failed, device %s.\n",
-		   ddf_dev_get_name(mfun->mdev->ddf_dev));
+		   usb_device_get_name(mfun->mdev->usb_dev));
 		return EIO;
 	}
@@ -314,5 +314,5 @@
         if (rc != EOK) {
 		usb_log_error("Read (10) transport failed, device %s: %s.\n",
-		   ddf_dev_get_name(mfun->mdev->ddf_dev), str_error(rc));
+		   usb_device_get_name(mfun->mdev->usb_dev), str_error(rc));
 		return rc;
 	}
@@ -320,5 +320,5 @@
 	if (cmd.status != CMDS_GOOD) {
 		usb_log_error("Read (10) command failed, device %s.\n",
-		   ddf_dev_get_name(mfun->mdev->ddf_dev));
+		   usb_device_get_name(mfun->mdev->usb_dev));
 		return EIO;
 	}
@@ -370,5 +370,5 @@
         if (rc != EOK) {
 		usb_log_error("Write (10) transport failed, device %s: %s.\n",
-		   ddf_dev_get_name(mfun->mdev->ddf_dev), str_error(rc));
+		   usb_device_get_name(mfun->mdev->usb_dev), str_error(rc));
 		return rc;
 	}
@@ -376,5 +376,5 @@
 	if (cmd.status != CMDS_GOOD) {
 		usb_log_error("Write (10) command failed, device %s.\n",
-		   ddf_dev_get_name(mfun->mdev->ddf_dev));
+		   usb_device_get_name(mfun->mdev->usb_dev));
 		return EIO;
 	}
Index: uspace/drv/bus/usb/usbmast/usbmast.h
===================================================================
--- uspace/drv/bus/usb/usbmast/usbmast.h	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/usbmast/usbmast.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -43,6 +43,4 @@
 /** Mass storage device. */
 typedef struct usbmast_dev {
-	/** DDF device */
-	ddf_dev_t *ddf_dev;
 	/** USB device */
 	usb_device_t *usb_dev;
@@ -51,4 +49,8 @@
 	/** LUN functions */
 	ddf_fun_t **luns;
+	/** Data read pipe */
+	usb_pipe_t *bulk_in_pipe;
+	/** Data write pipe */
+	usb_pipe_t *bulk_out_pipe;
 } usbmast_dev_t;
 
Index: uspace/drv/bus/usb/usbmid/explore.c
===================================================================
--- uspace/drv/bus/usb/usbmid/explore.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/usbmid/explore.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -40,11 +40,5 @@
 #include <usb/dev/request.h>
 #include <usb/dev/dp.h>
-#include <usb/ddfiface.h>
 #include "usbmid.h"
-
-/** Operations of the device itself. */
-static ddf_dev_ops_t mid_device_ops = {
-	.interfaces[USB_DEV_IFACE] = &usb_iface_hub_impl
-};
 
 /** Tell whether given interface is already in the list.
@@ -56,5 +50,5 @@
 static bool interface_in_list(const list_t *list, int interface_no)
 {
-	list_foreach(*list, link, usbmid_interface_t, iface) {
+	list_foreach(*list, link, const usbmid_interface_t, iface) {
 		if (iface->interface_no == interface_no) {
 			return true;
@@ -71,7 +65,10 @@
  * @param list List where to add the interfaces.
  */
-static void create_interfaces(const uint8_t *config_descriptor,
-    size_t config_descriptor_size, list_t *list)
+static int create_interfaces(const uint8_t *config_descriptor,
+    size_t config_descriptor_size, list_t *list, usb_device_t *usb_dev)
 {
+	assert(config_descriptor);
+	assert(usb_dev);
+
 	const usb_dp_parser_data_t data = {
 		.data = config_descriptor,
@@ -89,5 +86,5 @@
 	/* Walk all descriptors nested in the current configuration decriptor;
 	 * i.e. all interface descriptors. */
-	for (;interface_ptr != NULL;
+	for (; interface_ptr != NULL;
 	    interface_ptr = usb_dp_get_sibling_descriptor(
 	        &parser, &data, config_descriptor, interface_ptr))
@@ -106,17 +103,24 @@
 			continue;
 		}
-		usbmid_interface_t *iface = malloc(sizeof(usbmid_interface_t));
-		if (iface == NULL) {
+
+
+		usb_log_info("Creating child for interface %d (%s).\n",
+		    interface->interface_number,
+		    usb_str_class(interface->interface_class));
+
+		usbmid_interface_t *iface = NULL;
+		const int rc = usbmid_spawn_interface_child(usb_dev, &iface,
+			&usb_device_descriptors(usb_dev)->device, interface);
+		if (rc != EOK) {
 			//TODO: Do something about that failure.
-			break;
+			usb_log_error("Failed to create interface child for "
+			    "%d (%s): %s.\n", interface->interface_number,
+			    usb_str_class(interface->interface_class),
+			    str_error(rc));
+		} else {
+			list_append(&iface->link, list);
 		}
-
-		link_initialize(&iface->link);
-		iface->fun = NULL;
-		iface->interface_no = interface->interface_number;
-		iface->interface = interface;
-
-		list_append(&iface->link, list);
 	}
+	return EOK;
 }
 
@@ -129,9 +133,9 @@
  * @return Whether to accept this device from devman.
  */
-bool usbmid_explore_device(usb_device_t *dev)
+int usbmid_explore_device(usb_device_t *dev)
 {
-	int rc;
-
-	unsigned dev_class = dev->descriptors.device.device_class;
+	assert(dev);
+	const unsigned dev_class =
+	    usb_device_descriptors(dev)->device.device_class;
 	if (dev_class != USB_CLASS_USE_INTERFACE) {
 		usb_log_warning(
@@ -139,37 +143,38 @@
 		    dev_class, usb_str_class(dev_class),
 		    USB_CLASS_USE_INTERFACE);
-		usb_log_error("Not multi interface device, refusing.\n");
-		return false;
+		usb_log_error("Not a multi-interface device, refusing.\n");
+		return ENOTSUP;
 	}
 
-	/* Shortcuts to save on typing ;-). */
-	const void *config_descriptor_raw = dev->descriptors.configuration;
-	size_t config_descriptor_size = dev->descriptors.configuration_size;
+	/* Get coonfiguration descriptor. */
+	const size_t config_descriptor_size =
+	    usb_device_descriptors(dev)->full_config_size;
+	const void *config_descriptor_raw =
+	    usb_device_descriptors(dev)->full_config;
 	const usb_standard_configuration_descriptor_t *config_descriptor =
 	    config_descriptor_raw;
 
 	/* Select the first configuration */
-	rc = usb_request_set_configuration(&dev->ctrl_pipe,
+	int rc = usb_request_set_configuration(usb_device_get_default_pipe(dev),
 	    config_descriptor->configuration_number);
 	if (rc != EOK) {
 		usb_log_error("Failed to set device configuration: %s.\n",
 		    str_error(rc));
-		return false;
+		return rc;
 	}
-
+	
 	/* Create driver soft-state. */
 	usb_mid_t *usb_mid = usb_device_data_alloc(dev, sizeof(usb_mid_t));
 	if (!usb_mid) {
 		usb_log_error("Failed to create USB MID structure.\n");
-		return false;
+		return ENOMEM;
 	}
 
 	/* Create control function. */
-	usb_mid->ctl_fun = ddf_fun_create(dev->ddf_dev, fun_exposed, "ctl");
+	usb_mid->ctl_fun = usb_device_ddf_fun_create(dev, fun_exposed, "ctl");
 	if (usb_mid->ctl_fun == NULL) {
 		usb_log_error("Failed to create control function.\n");
-		return false;
+		return ENOMEM;
 	}
-	ddf_fun_set_ops(usb_mid->ctl_fun, &mid_device_ops);
 
 	/* Bind control function. */
@@ -179,28 +184,13 @@
 		    str_error(rc));
 		ddf_fun_destroy(usb_mid->ctl_fun);
-		return false;
+		return rc;
 	}
-
 
 	/* Create interface children. */
 	list_initialize(&usb_mid->interface_list);
 	create_interfaces(config_descriptor_raw, config_descriptor_size,
-	    &usb_mid->interface_list);
+	    &usb_mid->interface_list, dev);
 
-	/* Start child function for every interface. */
-	list_foreach(usb_mid->interface_list, link, usbmid_interface_t, iface) {
-		usb_log_info("Creating child for interface %d (%s).\n",
-		    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",
-			    str_error(rc));
-		}
-	}
-
-	return true;
+	return EOK;
 }
 
Index: uspace/drv/bus/usb/usbmid/main.c
===================================================================
--- uspace/drv/bus/usb/usbmid/main.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/usbmid/main.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -51,13 +51,7 @@
 static int usbmid_device_add(usb_device_t *dev)
 {
-	usb_log_info("Taking care of new MID `%s'.\n", ddf_dev_get_name(dev->ddf_dev));
+	usb_log_info("Taking care of new MID `%s'.\n", usb_device_get_name(dev));
 
-	const bool accept = usbmid_explore_device(dev);
-
-	if (!accept) {
-		return ENOTSUP;
-	}
-
-	return EOK;
+	return usbmid_explore_device(dev);
 }
 
@@ -70,5 +64,5 @@
 {
 	assert(dev);
-	usb_mid_t *usb_mid = dev->driver_data;
+	usb_mid_t *usb_mid = usb_device_data_get(dev);
 	assert(usb_mid);
 
@@ -89,15 +83,12 @@
 		usbmid_interface_t *iface = usbmid_interface_from_link(item);
 
-		usb_log_info("Removing child for interface %d (%s).\n",
-		    iface->interface_no,
-		    usb_str_class(iface->interface->interface_class));
+		usb_log_info("Removing child `%s'.\n",
+		    ddf_fun_get_name(iface->fun));
 
 		/* Tell the child to go off-line. */
 		int pret = ddf_fun_offline(iface->fun);
 		if (pret != EOK) {
-			usb_log_warning("Failed to turn off child for interface"
-			    " %d (%s): %s\n", iface->interface_no,
-			    usb_str_class(iface->interface->interface_class),
-			    str_error(pret));
+			usb_log_warning("Failed to turn off child `%s': %s\n",
+			    ddf_fun_get_name(iface->fun), str_error(pret));
 			ret = pret;
 		}
@@ -106,8 +97,6 @@
 		pret = usbmid_interface_destroy(iface);
 		if (pret != EOK) {
-			usb_log_error("Failed to destroy child for interface "
-			    "%d (%s): %s\n", iface->interface_no,
-			    usb_str_class(iface->interface->interface_class),
-			    str_error(pret));
+			usb_log_error("Failed to destroy child `%s': %s\n",
+			    ddf_fun_get_name(iface->fun), str_error(pret));
 			ret = pret;
 		}
@@ -124,8 +113,8 @@
 {
 	assert(dev);
-	usb_mid_t *usb_mid = dev->driver_data;
+	usb_mid_t *usb_mid = usb_device_data_get(dev);
 	assert(usb_mid);
 
-	usb_log_info("USB MID gone: `%s'.\n", ddf_dev_get_name(dev->ddf_dev));
+	usb_log_info("USB MID gone: `%s'.\n", usb_device_get_name(dev));
 
 	/* Remove ctl function */
@@ -145,15 +134,11 @@
 		usbmid_interface_t *iface = usbmid_interface_from_link(item);
 
-		usb_log_info("Child for interface %d (%s) gone.\n",
-		    iface->interface_no,
-		    usb_str_class(iface->interface->interface_class));
+		usb_log_info("Child `%s' is gone.\n",
+		    ddf_fun_get_name(iface->fun));
 
 		const int pret = usbmid_interface_destroy(iface);
 		if (pret != EOK) {
-			usb_log_error("Failed to remove child for interface "
-			    "%d (%s): %s\n",
-			    iface->interface_no,
-			    usb_str_class(iface->interface->interface_class),
-			    str_error(pret));
+			usb_log_error("Failed to remove child `%s': %s\n",
+			    ddf_fun_get_name(iface->fun), str_error(pret));
 			ret = pret;
 		}
Index: uspace/drv/bus/usb/usbmid/usbmid.c
===================================================================
--- uspace/drv/bus/usb/usbmid/usbmid.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/usbmid/usbmid.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -31,7 +31,4 @@
  */
 
-/* XXX Fix this */
-#define _DDF_DATA_IMPLANT
-
 /**
  * @file
@@ -42,5 +39,4 @@
 #include <stdlib.h>
 #include <usb_iface.h>
-#include <usb/ddfiface.h>
 #include <usb/dev/pipes.h>
 #include <usb/classes/classes.h>
@@ -48,22 +44,35 @@
 #include "usbmid.h"
 
-/** Callback for DDF USB interface. */
-static int usb_iface_get_interface_impl(ddf_fun_t *fun, int *iface_no)
+/** Get USB device handle by calling the parent usb_device_t.
+ *
+ * @param[in] fun Device function the operation is running on.
+ * @param[out] handle Device handle.
+ * @return Error code.
+ */
+static int usb_iface_device_handle(ddf_fun_t *fun, devman_handle_t *handle)
+{
+	assert(fun);
+	assert(handle);
+	usb_device_t *usb_dev = usb_device_get(ddf_fun_get_dev(fun));
+	*handle = usb_device_get_devman_handle(usb_dev);
+	return EOK;
+}
+
+/** Callback for DDF USB get interface. */
+static int usb_iface_iface_no(ddf_fun_t *fun, int *iface_no)
 {
 	usbmid_interface_t *iface = ddf_fun_data_get(fun);
 	assert(iface);
 
-	if (iface_no != NULL) {
+	if (iface_no)
 		*iface_no = iface->interface_no;
-	}
 
 	return EOK;
 }
 
-/** DDF interface of the child - interface function. */
+/** DDF interface of the child - USB functions. */
 static usb_iface_t child_usb_iface = {
-	.get_hc_handle = usb_iface_get_hc_handle_device_impl,
-	.get_my_address = usb_iface_get_my_address_forward_impl,
-	.get_my_interface = usb_iface_get_interface_impl,
+	.get_my_device_handle = usb_iface_device_handle,
+	.get_my_interface = usb_iface_iface_no,
 };
 
@@ -81,9 +90,5 @@
 		return ret;
 	}
-	/* NOTE: usbmid->interface points somewhere, but we did not
-	 * allocate that space, so don't touch */
 	ddf_fun_destroy(mid_iface->fun);
-	/* NOTE: mid_iface is invalid at this point, it was assigned to
-	 * mid_iface->fun->driver_data and freed in ddf_fun_destroy */
 	return EOK;
 }
@@ -98,5 +103,5 @@
  */
 int usbmid_spawn_interface_child(usb_device_t *parent,
-    usbmid_interface_t *iface,
+    usbmid_interface_t **iface_ret,
     const usb_standard_device_descriptor_t *device_descriptor,
     const usb_standard_interface_descriptor_t *interface_descriptor)
@@ -119,5 +124,5 @@
 
 	/* Create the device. */
-	child = ddf_fun_create(parent->ddf_dev, fun_inner, child_name);
+	child = usb_device_ddf_fun_create(parent, fun_inner, child_name);
 	free(child_name);
 	if (child == NULL) {
@@ -144,4 +149,11 @@
 	}
 	clean_match_ids(&match_ids);
+	ddf_fun_set_ops(child, &child_device_ops);
+
+	usbmid_interface_t *iface = ddf_fun_data_alloc(child, sizeof(*iface));
+
+	iface->fun = child;
+	iface->interface_no = interface_descriptor->interface_number;
+	link_initialize(&iface->link);
 
 	rc = ddf_fun_bind(child);
@@ -151,8 +163,5 @@
 		return rc;
 	}
-
-	iface->fun = child;
-	ddf_fun_data_implant(child, iface);
-	ddf_fun_set_ops(child, &child_device_ops);
+	*iface_ret = iface;
 
 	return EOK;
Index: uspace/drv/bus/usb/usbmid/usbmid.h
===================================================================
--- uspace/drv/bus/usb/usbmid/usbmid.h	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/usbmid/usbmid.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -50,6 +50,4 @@
 	/** Function container. */
 	ddf_fun_t *fun;
-	/** Interface descriptor. */
-	const usb_standard_interface_descriptor_t *interface;
 	/** Interface number. */
 	int interface_no;
@@ -64,6 +62,6 @@
 } usb_mid_t;
 
-bool usbmid_explore_device(usb_device_t *);
-int usbmid_spawn_interface_child(usb_device_t *, usbmid_interface_t *,
+int usbmid_explore_device(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 *);
Index: uspace/drv/bus/usb/usbmid/usbmid.ma
===================================================================
--- uspace/drv/bus/usb/usbmid/usbmid.ma	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/usbmid/usbmid.ma	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -1,1 +1,2 @@
+100 usb&class=use-interface
 100 usb&mid
Index: uspace/drv/bus/usb/vhc/Makefile
===================================================================
--- uspace/drv/bus/usb/vhc/Makefile	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/vhc/Makefile	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -49,7 +49,5 @@
 	hub/virthubops.c \
 	conndev.c \
-	connhost.c \
 	devconn.c \
-	hub.c \
 	main.c \
 	transfer.c
Index: uspace/drv/bus/usb/vhc/conn.h
===================================================================
--- uspace/drv/bus/usb/vhc/conn.h	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ 	(revision )
@@ -1,54 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup drvusbvhc
- * @{
- */
-/** @file
- * @brief Connection handling of incoming calls.
- */
-#ifndef VHCD_CONN_H_
-#define VHCD_CONN_H_
-
-#include <usb/usb.h>
-#include <usbhc_iface.h>
-#include <usb_iface.h>
-#include "vhcd.h"
-
-extern usbhc_iface_t vhc_iface;
-extern usb_iface_t vhc_usb_iface;
-extern usb_iface_t rh_usb_iface;
-
-void default_connection_handler(ddf_fun_t *, ipc_callid_t, ipc_call_t *);
-void on_client_close(ddf_fun_t *);
-
-
-#endif
-/**
- * @}
- */
Index: uspace/drv/bus/usb/vhc/conndev.c
===================================================================
--- uspace/drv/bus/usb/vhc/conndev.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/vhc/conndev.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -38,6 +38,8 @@
 #include <ddf/driver.h>
 #include <usbvirt/ipc.h>
+#include <usb/debug.h>
 #include <async.h>
-#include "conn.h"
+
+#include "vhcd.h"
 
 static fibril_local uintptr_t plugged_device_handle = 0;
@@ -94,5 +96,5 @@
     ipc_call_t *icall)
 {
-	vhc_data_t *vhc = ddf_dev_data_get(ddf_fun_get_dev(fun));
+	vhc_data_t *vhc = ddf_fun_data_get(fun);
 	
 	async_sess_t *callback =
@@ -125,5 +127,5 @@
 void on_client_close(ddf_fun_t *fun)
 {
-	vhc_data_t *vhc = ddf_dev_data_get(ddf_fun_get_dev(fun));
+	vhc_data_t *vhc = ddf_fun_data_get(fun);
 
 	if (plugged_device_handle != 0) {
Index: uspace/drv/bus/usb/vhc/connhost.c
===================================================================
--- uspace/drv/bus/usb/vhc/connhost.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ 	(revision )
@@ -1,533 +1,0 @@
-/*
- * 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 drvusbvhc
- * @{
- */
-/** @file
- * Host controller interface implementation.
- */
-#include <assert.h>
-#include <errno.h>
-#include <usb/usb.h>
-#include <usb/ddfiface.h>
-#include <usb/debug.h>
-#include <usbhc_iface.h>
-#include "vhcd.h"
-
-#define GET_VHC_DATA(fun) \
-	((vhc_data_t *)ddf_dev_data_get(ddf_fun_get_dev(fun)))
-#define VHC_DATA(vhc, fun) \
-	vhc_data_t *vhc = GET_VHC_DATA(fun); assert(vhc->magic == 0xdeadbeef)
-
-#define UNSUPPORTED(methodname) \
-	usb_log_warning("Unsupported interface method `%s()' in %s:%d.\n", \
-	    methodname, __FILE__, __LINE__)
-
-/** Found free USB address.
- *
- * @param[in] fun Device function the action was invoked on.
- * @param[in] speed Speed of the device that will get this address.
- * @param[out] address Non-null pointer where to store the free address.
- * @return Error code.
- */
-static int request_address(ddf_fun_t *fun, usb_address_t *address, bool strict,
-    usb_speed_t speed)
-{
-	VHC_DATA(vhc, fun);
-
-	assert(address);
-	return usb_device_manager_request_address(
-	    &vhc->dev_manager, address, strict, speed);
-}
-
-/** Bind USB address with device devman handle.
- *
- * @param[in] fun Device function the action was invoked on.
- * @param[in] address USB address of the device.
- * @param[in] handle Devman handle of the device.
- * @return Error code.
- */
-static int bind_address(ddf_fun_t *fun,
-    usb_address_t address, devman_handle_t handle)
-{
-	VHC_DATA(vhc, fun);
-	usb_log_debug("Binding handle %" PRIun " to address %d.\n",
-	    handle, address);
-	usb_device_manager_bind_address(&vhc->dev_manager, address, handle);
-
-	return EOK;
-}
-
-/** Find device handle by address interface function.
- *
- * @param[in] fun DDF function that was called.
- * @param[in] address Address in question.
- * @param[out] handle Where to store device handle if found.
- * @return Error code.
- */
-static int find_by_address(ddf_fun_t *fun, usb_address_t address,
-    devman_handle_t *handle)
-{
-	VHC_DATA(vhc, fun);
-	return usb_device_manager_get_info_by_address(
-	    &vhc->dev_manager, address, handle, NULL);
-}
-
-/** Release previously requested address.
- *
- * @param[in] fun Device function the action was invoked on.
- * @param[in] address USB address to be released.
- * @return Error code.
- */
-static int release_address(ddf_fun_t *fun, usb_address_t address)
-{
-	VHC_DATA(vhc, fun);
-	usb_log_debug("Releasing address %d...\n", address);
-	usb_device_manager_release_address(&vhc->dev_manager, address);
-
-	return ENOTSUP;
-}
-
-/** Register endpoint for bandwidth reservation.
- *
- * @param[in] fun Device function the action was invoked on.
- * @param[in] address USB address of the device.
- * @param[in] speed Endpoint speed (invalid means to use device one).
- * @param[in] endpoint Endpoint number.
- * @param[in] transfer_type USB transfer type.
- * @param[in] direction Endpoint data direction.
- * @param[in] max_packet_size Max packet size of the endpoint.
- * @param[in] interval Polling interval.
- * @return Error code.
- */
-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)
-{
-	VHC_DATA(vhc, fun);
-
-	return usb_endpoint_manager_add_ep(&vhc->ep_manager,
-	    address, endpoint, direction, transfer_type, USB_SPEED_FULL, 1, 0,
-	    NULL, NULL);
-
-}
-
-/** Unregister endpoint (free some bandwidth reservation).
- *
- * @param[in] fun Device function the action was invoked on.
- * @param[in] address USB address of the device.
- * @param[in] endpoint Endpoint number.
- * @param[in] direction Endpoint data direction.
- * @return Error code.
- */
-static int unregister_endpoint(ddf_fun_t *fun, usb_address_t address,
-    usb_endpoint_t endpoint, usb_direction_t direction)
-{
-	VHC_DATA(vhc, fun);
-
-	int rc = usb_endpoint_manager_remove_ep(&vhc->ep_manager,
-	    address, endpoint, direction, NULL, NULL);
-
-	return rc;
-}
-#if 0
-/** Schedule interrupt out transfer.
- *
- * The callback is supposed to be called once the transfer (on the wire) is
- * complete regardless of the outcome.
- * However, the callback could be called only when this function returns
- * with success status (i.e. returns EOK).
- *
- * @param[in] fun Device function the action was invoked on.
- * @param[in] target Target pipe (address and endpoint number) specification.
- * @param[in] data Data to be sent (in USB endianess, allocated and deallocated
- *	by the caller).
- * @param[in] size Size of the @p data buffer in bytes.
- * @param[in] callback Callback to be issued once the transfer is complete.
- * @param[in] arg Pass-through argument to the callback.
- * @return Error code.
- */
-static int interrupt_out(ddf_fun_t *fun, usb_target_t target,
-    void *data, size_t size,
-    usbhc_iface_transfer_out_callback_t callback, void *arg)
-{
-	VHC_DATA(vhc, fun);
-
-	vhc_transfer_t *transfer = vhc_transfer_create(target.address,
-	    target.endpoint, USB_DIRECTION_OUT, USB_TRANSFER_INTERRUPT,
-	    fun, arg);
-	if (transfer == NULL) {
-		return ENOMEM;
-	}
-
-	transfer->data_buffer = data;
-	transfer->data_buffer_size = size;
-	transfer->callback_out = callback;
-
-	int rc = vhc_virtdev_add_transfer(vhc, transfer);
-	if (rc != EOK) {
-		free(transfer);
-		return rc;
-	}
-
-	return EOK;
-}
-
-/** Schedule interrupt in transfer.
- *
- * The callback is supposed to be called once the transfer (on the wire) is
- * complete regardless of the outcome.
- * However, the callback could be called only when this function returns
- * with success status (i.e. returns EOK).
- *
- * @param[in] fun Device function the action was invoked on.
- * @param[in] target Target pipe (address and endpoint number) specification.
- * @param[in] data Buffer where to store the data (in USB endianess,
- *	allocated and deallocated by the caller).
- * @param[in] size Size of the @p data buffer in bytes.
- * @param[in] callback Callback to be issued once the transfer is complete.
- * @param[in] arg Pass-through argument to the callback.
- * @return Error code.
- */
-static int interrupt_in(ddf_fun_t *fun, usb_target_t target,
-    void *data, size_t size,
-    usbhc_iface_transfer_in_callback_t callback, void *arg)
-{
-	VHC_DATA(vhc, fun);
-
-	vhc_transfer_t *transfer = vhc_transfer_create(target.address,
-	    target.endpoint, USB_DIRECTION_IN, USB_TRANSFER_INTERRUPT,
-	    fun, arg);
-	if (transfer == NULL) {
-		return ENOMEM;
-	}
-
-	transfer->data_buffer = data;
-	transfer->data_buffer_size = size;
-	transfer->callback_in = callback;
-
-	int rc = vhc_virtdev_add_transfer(vhc, transfer);
-	if (rc != EOK) {
-		free(transfer);
-		return rc;
-	}
-
-	return EOK;
-}
-
-/** Schedule bulk out transfer.
- *
- * The callback is supposed to be called once the transfer (on the wire) is
- * complete regardless of the outcome.
- * However, the callback could be called only when this function returns
- * with success status (i.e. returns EOK).
- *
- * @param[in] fun Device function the action was invoked on.
- * @param[in] target Target pipe (address and endpoint number) specification.
- * @param[in] data Data to be sent (in USB endianess, allocated and deallocated
- *	by the caller).
- * @param[in] size Size of the @p data buffer in bytes.
- * @param[in] callback Callback to be issued once the transfer is complete.
- * @param[in] arg Pass-through argument to the callback.
- * @return Error code.
- */
-static int bulk_out(ddf_fun_t *fun, usb_target_t target,
-    void *data, size_t size,
-    usbhc_iface_transfer_out_callback_t callback, void *arg)
-{
-	UNSUPPORTED("bulk_out");
-
-	return ENOTSUP;
-}
-
-/** Schedule bulk in transfer.
- *
- * The callback is supposed to be called once the transfer (on the wire) is
- * complete regardless of the outcome.
- * However, the callback could be called only when this function returns
- * with success status (i.e. returns EOK).
- *
- * @param[in] fun Device function the action was invoked on.
- * @param[in] target Target pipe (address and endpoint number) specification.
- * @param[in] data Buffer where to store the data (in USB endianess,
- *	allocated and deallocated by the caller).
- * @param[in] size Size of the @p data buffer in bytes.
- * @param[in] callback Callback to be issued once the transfer is complete.
- * @param[in] arg Pass-through argument to the callback.
- * @return Error code.
- */
-static int bulk_in(ddf_fun_t *fun, usb_target_t target,
-    void *data, size_t size,
-    usbhc_iface_transfer_in_callback_t callback, void *arg)
-{
-	UNSUPPORTED("bulk_in");
-
-	return ENOTSUP;
-}
-
-/** Schedule control write transfer.
- *
- * The callback is supposed to be called once the transfer (on the wire) is
- * complete regardless of the outcome.
- * However, the callback could be called only when this function returns
- * with success status (i.e. returns EOK).
- *
- * @param[in] fun Device function the action was invoked on.
- * @param[in] target Target pipe (address and endpoint number) specification.
- * @param[in] setup_packet Setup packet buffer (in USB endianess, allocated
- *	and deallocated by the caller).
- * @param[in] setup_packet_size Size of @p setup_packet buffer in bytes.
- * @param[in] data_buffer Data buffer (in USB endianess, allocated and
- *	deallocated by the caller).
- * @param[in] data_buffer_size Size of @p data_buffer buffer in bytes.
- * @param[in] callback Callback to be issued once the transfer is complete.
- * @param[in] arg Pass-through argument to the callback.
- * @return Error code.
- */
-static int control_write(ddf_fun_t *fun, usb_target_t target,
-    void *setup_packet, size_t setup_packet_size,
-    void *data_buffer, size_t data_buffer_size,
-    usbhc_iface_transfer_out_callback_t callback, void *arg)
-{
-	VHC_DATA(vhc, fun);
-
-	vhc_transfer_t *transfer = vhc_transfer_create(target.address,
-	    target.endpoint, USB_DIRECTION_OUT, USB_TRANSFER_CONTROL,
-	    fun, arg);
-	if (transfer == NULL) {
-		return ENOMEM;
-	}
-
-	transfer->setup_buffer = setup_packet;
-	transfer->setup_buffer_size = setup_packet_size;
-	transfer->data_buffer = data_buffer;
-	transfer->data_buffer_size = data_buffer_size;
-	transfer->callback_out = callback;
-
-	int rc = vhc_virtdev_add_transfer(vhc, transfer);
-	if (rc != EOK) {
-		free(transfer);
-		return rc;
-	}
-
-	return EOK;
-}
-
-/** Schedule control read transfer.
- *
- * The callback is supposed to be called once the transfer (on the wire) is
- * complete regardless of the outcome.
- * However, the callback could be called only when this function returns
- * with success status (i.e. returns EOK).
- *
- * @param[in] fun Device function the action was invoked on.
- * @param[in] target Target pipe (address and endpoint number) specification.
- * @param[in] setup_packet Setup packet buffer (in USB endianess, allocated
- *	and deallocated by the caller).
- * @param[in] setup_packet_size Size of @p setup_packet buffer in bytes.
- * @param[in] data_buffer Buffer where to store the data (in USB endianess,
- *	allocated and deallocated by the caller).
- * @param[in] data_buffer_size Size of @p data_buffer buffer in bytes.
- * @param[in] callback Callback to be issued once the transfer is complete.
- * @param[in] arg Pass-through argument to the callback.
- * @return Error code.
- */
-static int control_read(ddf_fun_t *fun, usb_target_t target,
-    void *setup_packet, size_t setup_packet_size,
-    void *data_buffer, size_t data_buffer_size,
-    usbhc_iface_transfer_in_callback_t callback, void *arg)
-{
-	VHC_DATA(vhc, fun);
-
-	vhc_transfer_t *transfer = vhc_transfer_create(target.address,
-	    target.endpoint, USB_DIRECTION_IN, USB_TRANSFER_CONTROL,
-	    fun, arg);
-	if (transfer == NULL) {
-		return ENOMEM;
-	}
-
-	transfer->setup_buffer = setup_packet;
-	transfer->setup_buffer_size = setup_packet_size;
-	transfer->data_buffer = data_buffer;
-	transfer->data_buffer_size = data_buffer_size;
-	transfer->callback_in = callback;
-
-	int rc = vhc_virtdev_add_transfer(vhc, transfer);
-	if (rc != EOK) {
-		free(transfer);
-		return rc;
-	}
-
-	return EOK;
-}
-#endif
-static int usb_read(ddf_fun_t *fun, usb_target_t target, uint64_t setup_buffer,
-    uint8_t *data_buffer, size_t data_buffer_size,
-    usbhc_iface_transfer_in_callback_t callback, void *arg)
-{
-	VHC_DATA(vhc, fun);
-
-	endpoint_t *ep = usb_endpoint_manager_find_ep(&vhc->ep_manager,
-	    target.address, target.endpoint, USB_DIRECTION_IN);
-	if (ep == NULL) {
-		return ENOENT;
-	}
-	const usb_transfer_type_t transfer_type = ep->transfer_type;
-
-
-	vhc_transfer_t *transfer = vhc_transfer_create(target.address,
-	    target.endpoint, USB_DIRECTION_IN, transfer_type,
-	    fun, arg);
-	if (transfer == NULL) {
-		return ENOMEM;
-	}
-	if (transfer_type == USB_TRANSFER_CONTROL) {
-		transfer->setup_buffer = malloc(sizeof(uint64_t));
-		assert(transfer->setup_buffer);
-		memcpy(transfer->setup_buffer, &setup_buffer, sizeof(uint64_t));
-		transfer->setup_buffer_size = sizeof(uint64_t);
-	}
-	transfer->data_buffer = data_buffer;
-	transfer->data_buffer_size = data_buffer_size;
-	transfer->callback_in = callback;
-
-	int rc = vhc_virtdev_add_transfer(vhc, transfer);
-	if (rc != EOK) {
-		if (transfer->setup_buffer != NULL) {
-			free(transfer->setup_buffer);
-		}
-		free(transfer);
-		return rc;
-	}
-
-	return EOK;
-}
-
-static int usb_write(ddf_fun_t *fun, usb_target_t target, uint64_t setup_buffer,
-    const uint8_t *data_buffer, size_t data_buffer_size,
-    usbhc_iface_transfer_out_callback_t callback, void *arg)
-{
-	VHC_DATA(vhc, fun);
-
-	endpoint_t *ep = usb_endpoint_manager_find_ep(&vhc->ep_manager,
-	    target.address, target.endpoint, USB_DIRECTION_OUT);
-	if (ep == NULL) {
-		return ENOENT;
-	}
-	const usb_transfer_type_t transfer_type = ep->transfer_type;
-
-
-	vhc_transfer_t *transfer = vhc_transfer_create(target.address,
-	    target.endpoint, USB_DIRECTION_OUT, transfer_type,
-	    fun, arg);
-	if (transfer == NULL) {
-		return ENOMEM;
-	}
-	if (transfer_type == USB_TRANSFER_CONTROL) {
-		transfer->setup_buffer = malloc(sizeof(uint64_t));
-		assert(transfer->setup_buffer);
-		memcpy(transfer->setup_buffer, &setup_buffer, sizeof(uint64_t));
-		transfer->setup_buffer_size = sizeof(uint64_t);
-	}
-	transfer->data_buffer = (void*)data_buffer;
-	transfer->data_buffer_size = data_buffer_size;
-	transfer->callback_out = callback;
-
-	int rc = vhc_virtdev_add_transfer(vhc, transfer);
-	if (rc != EOK) {
-		free(transfer->setup_buffer);
-		free(transfer);
-		return rc;
-	}
-
-	return EOK;
-}
-
-static int tell_address(ddf_fun_t *fun, usb_address_t *address)
-{
-	UNSUPPORTED("tell_address");
-
-	return ENOTSUP;
-}
-
-static int usb_iface_get_hc_handle_rh_impl(ddf_fun_t *root_hub_fun,
-    devman_handle_t *handle)
-{
-	VHC_DATA(vhc, root_hub_fun);
-
-	*handle = ddf_fun_get_handle(vhc->hc_fun);
-
-	return EOK;
-}
-
-static int tell_address_rh(ddf_fun_t *root_hub_fun, usb_address_t *address)
-{
-	VHC_DATA(vhc, root_hub_fun);
-
-	devman_handle_t handle = ddf_fun_get_handle(root_hub_fun);
-
-	usb_log_debug("tell_address_rh(handle=%" PRIun ")\n", handle);
-	const usb_address_t addr =
-	    usb_device_manager_find_address(&vhc->dev_manager, handle);
-	if (addr < 0) {
-		return addr;
-	} else {
-		*address = addr;
-		return EOK;
-	}
-}
-
-usbhc_iface_t vhc_iface = {
-	.request_address = request_address,
-	.bind_address = bind_address,
-	.get_handle = find_by_address,
-	.release_address = release_address,
-
-	.register_endpoint = register_endpoint,
-	.unregister_endpoint = unregister_endpoint,
-
-	.write = usb_write,
-	.read = usb_read,
-};
-
-usb_iface_t vhc_usb_iface = {
-	.get_hc_handle = usb_iface_get_hc_handle_hc_impl,
-	.get_my_address = tell_address
-};
-
-usb_iface_t rh_usb_iface = {
-	.get_hc_handle = usb_iface_get_hc_handle_rh_impl,
-	.get_my_address = tell_address_rh
-};
-
-
-/**
- * @}
- */
Index: uspace/drv/bus/usb/vhc/devconn.c
===================================================================
--- uspace/drv/bus/usb/vhc/devconn.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/vhc/devconn.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -51,5 +51,5 @@
 static int vhc_virtdev_plug_generic(vhc_data_t *vhc,
     async_sess_t *sess, usbvirt_device_t *virtdev,
-    uintptr_t *handle, bool connect)
+    uintptr_t *handle, bool connect, usb_address_t address)
 {
 	vhc_virtdev_t *dev = vhc_virtdev_create();
@@ -60,4 +60,5 @@
 	dev->dev_sess = sess;
 	dev->dev_local = virtdev;
+	dev->address = address;
 
 	fibril_mutex_lock(&vhc->guard);
@@ -78,5 +79,5 @@
 	if (connect) {
 		// FIXME: check status
-		(void) virthub_connect_device(vhc->hub, dev);
+		(void) virthub_connect_device(&vhc->hub, dev);
 	}
 
@@ -86,15 +87,15 @@
 int vhc_virtdev_plug(vhc_data_t *vhc, async_sess_t *sess, uintptr_t *handle)
 {
-	return vhc_virtdev_plug_generic(vhc, sess, NULL, handle, true);
+	return vhc_virtdev_plug_generic(vhc, sess, NULL, handle, true, 0);
 }
 
 int vhc_virtdev_plug_local(vhc_data_t *vhc, usbvirt_device_t *dev, uintptr_t *handle)
 {
-	return vhc_virtdev_plug_generic(vhc, NULL, dev, handle, true);
+	return vhc_virtdev_plug_generic(vhc, NULL, dev, handle, true, 0);
 }
 
-int vhc_virtdev_plug_hub(vhc_data_t *vhc, usbvirt_device_t *dev, uintptr_t *handle)
+int vhc_virtdev_plug_hub(vhc_data_t *vhc, usbvirt_device_t *dev, uintptr_t *handle, usb_address_t address)
 {
-	return vhc_virtdev_plug_generic(vhc, NULL, dev, handle, false);
+	return vhc_virtdev_plug_generic(vhc, NULL, dev, handle, false, address);
 }
 
@@ -104,5 +105,5 @@
 
 	// FIXME: check status
-	(void) virthub_disconnect_device(vhc->hub, dev);
+	(void) virthub_disconnect_device(&vhc->hub, dev);
 
 	fibril_mutex_lock(&vhc->guard);
Index: uspace/drv/bus/usb/vhc/hub.c
===================================================================
--- uspace/drv/bus/usb/vhc/hub.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ 	(revision )
@@ -1,133 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup drvusbvhc
- * @{
- */
-/** @file
- * @brief Virtual USB hub.
- */
-
-#include <usb/classes/classes.h>
-#include <usbvirt/device.h>
-#include <errno.h>
-#include <async.h>
-#include <str_error.h>
-#include <stdlib.h>
-#include <ddf/driver.h>
-#include <devman.h>
-#include <usb/dev/hub.h>
-#include <usb/dev/recognise.h>
-
-#include "hub.h"
-#include "vhcd.h"
-#include "conn.h"
-
-usbvirt_device_t virtual_hub_device = {
-	.name = "root hub",
-	.ops = &hub_ops,
-	.address = 0
-};
-
-static ddf_dev_ops_t rh_ops = {
-	.interfaces[USB_DEV_IFACE] = &rh_usb_iface,
-};
-
-static int hub_register_in_devman_fibril(void *arg);
-
-void virtual_hub_device_init(ddf_fun_t *hc_dev)
-{
-	virthub_init(&virtual_hub_device);
-
-	/*
-	 * We need to register the root hub.
-	 * This must be done in separate fibril because the device
-	 * we are connecting to are ourselves and we cannot connect
-	 * before leaving the add_device() function.
-	 */
-	fid_t root_hub_registration
-	    = fibril_create(hub_register_in_devman_fibril, hc_dev);
-	if (root_hub_registration == 0) {
-		usb_log_fatal("Failed to create hub registration fibril.\n");
-		return;
-	}
-
-	fibril_add_ready(root_hub_registration);
-}
-
-static int pretend_port_rest(void *unused2)
-{
-	return EOK;
-}
-
-/** Register root hub in devman.
- *
- * @param arg Host controller device (type <code>device_t *</code>).
- * @return Error code.
- */
-int hub_register_in_devman_fibril(void *arg)
-{
-	ddf_fun_t *hc_dev = (ddf_fun_t *) arg;
-
-	/*
-	 * Wait until parent device is properly initialized.
-	 */
-	async_sess_t *sess;
-	do {
-		sess = devman_device_connect(EXCHANGE_SERIALIZE,
-		    ddf_fun_get_handle(hc_dev), 0);
-	} while (!sess);
-	async_hangup(sess);
-
-	int rc;
-
-	usb_hc_connection_t hc_conn;
-	usb_hc_connection_initialize(&hc_conn, ddf_fun_get_handle(hc_dev));
-
-	rc = usb_hc_connection_open(&hc_conn);
-	assert(rc == EOK);
-
-	ddf_fun_t *hub_dev;
-	rc = usb_hc_new_device_wrapper(ddf_fun_get_dev(hc_dev), &hc_conn, USB_SPEED_FULL,
-	    pretend_port_rest, NULL, NULL, &rh_ops, hc_dev, &hub_dev);
-	if (rc != EOK) {
-		usb_log_fatal("Failed to create root hub: %s.\n",
-		    str_error(rc));
-	}
-
-	usb_hc_connection_close(&hc_conn);
-
-	usb_log_info("Created root hub function (handle %zu).\n",
-	    (size_t) ddf_fun_get_handle(hub_dev));
-
-	return 0;
-}
-
-/**
- * @}
- */
Index: uspace/drv/bus/usb/vhc/hub.h
===================================================================
--- uspace/drv/bus/usb/vhc/hub.h	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ 	(revision )
@@ -1,52 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup drvusbvhc
- * @{
- */
-/** @file
- * @brief Virtual USB hub.
- */
-
-#ifndef VHCD_HUB_H_
-#define VHCD_HUB_H_
-
-#include <usbvirt/device.h>
-#include <ddf/driver.h>
-
-#include "hub/hub.h"
-#include "hub/virthub.h"
-
-extern usbvirt_device_t virtual_hub_device;
-
-void virtual_hub_device_init(ddf_fun_t *);
-
-#endif
-/**
- * @}
- */
Index: uspace/drv/bus/usb/vhc/hub/virthub.c
===================================================================
--- uspace/drv/bus/usb/vhc/hub/virthub.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/vhc/hub/virthub.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -34,8 +34,10 @@
  */
 #include <usb/classes/classes.h>
+#include <usb/classes/hub.h>
 #include <usbvirt/device.h>
 #include <assert.h>
 #include <errno.h>
 #include <str_error.h>
+#include <stdio.h>
 #include <assert.h>
 #include <stdlib.h>
@@ -76,5 +78,5 @@
 	.type = USB_DESCTYPE_HUB,
 	.port_count = HUB_PORT_COUNT,
-	.characteristics = 0, 
+	.characteristics = HUB_CHAR_NO_POWER_SWITCH_FLAG | HUB_CHAR_NO_OC_FLAG,
 	.power_on_warm_up = 50, /* Huh? */
 	.max_current = 100, /* Huh again. */
@@ -97,5 +99,5 @@
 	.length = sizeof(usb_standard_configuration_descriptor_t),
 	.descriptor_type = USB_DESCTYPE_CONFIGURATION,
-	.total_length = 
+	.total_length =
 		sizeof(usb_standard_configuration_descriptor_t)
 		+ sizeof(std_interface_descriptor)
@@ -145,5 +147,5 @@
  * @return Error code.
  */
-int virthub_init(usbvirt_device_t *dev)
+int virthub_init(usbvirt_device_t *dev, const char* name)
 {
 	if (dev == NULL) {
@@ -152,7 +154,12 @@
 	dev->ops = &hub_ops;
 	dev->descriptors = &descriptors;
+	dev->address = 0;
+	dev->name = str_dup(name);
+	if (!dev->name)
+		return ENOMEM;
 
 	hub_t *hub = malloc(sizeof(hub_t));
 	if (hub == NULL) {
+		free(dev->name);
 		return ENOMEM;
 	}
Index: uspace/drv/bus/usb/vhc/hub/virthub.h
===================================================================
--- uspace/drv/bus/usb/vhc/hub/virthub.h	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/vhc/hub/virthub.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -79,5 +79,5 @@
 extern hub_descriptor_t hub_descriptor;
 
-int virthub_init(usbvirt_device_t *);
+int virthub_init(usbvirt_device_t *, const char *name);
 int virthub_connect_device(usbvirt_device_t *, vhc_virtdev_t *);
 int virthub_disconnect_device(usbvirt_device_t *, vhc_virtdev_t *);
Index: uspace/drv/bus/usb/vhc/hub/virthubops.c
===================================================================
--- uspace/drv/bus/usb/vhc/hub/virthubops.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/vhc/hub/virthubops.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -340,12 +340,4 @@
 
 
-/** IN class request. */
-#define CLASS_REQ_IN(recipient) \
-	USBVIRT_MAKE_CONTROL_REQUEST_TYPE(USB_DIRECTION_IN, \
-	USBVIRT_REQUEST_TYPE_CLASS, recipient)
-/** OUT class request. */
-#define CLASS_REQ_OUT(recipient) \
-	USBVIRT_MAKE_CONTROL_REQUEST_TYPE(USB_DIRECTION_OUT, \
-	USBVIRT_REQUEST_TYPE_CLASS, recipient)
 
 /** Recipient: other. */
@@ -353,88 +345,60 @@
 /** Recipient: device. */
 #define REC_DEVICE USB_REQUEST_RECIPIENT_DEVICE
-/** Direction: in. */
-#define DIR_IN USB_DIRECTION_IN
-/** Direction: out. */
-#define DIR_OUT USB_DIRECTION_OUT
-
-
-/** Create a class request.
- *
- * @param direction Request direction.
- * @param recipient Request recipient.
- * @param req Request code.
- */
-#define CLASS_REQ(direction, recipient, req) \
-	.req_direction = direction, \
-	.req_recipient = recipient, \
-	.req_type = USB_REQUEST_TYPE_CLASS, \
-	.request = req
-
-/** Create a standard request.
- *
- * @param direction Request direction.
- * @param recipient Request recipient.
- * @param req Request code.
- */
-#define STD_REQ(direction, recipient, req) \
-	.req_direction = direction, \
-	.req_recipient = recipient, \
-	.req_type = USB_REQUEST_TYPE_STANDARD, \
-	.request = req
+
 
 /** Hub operations on control endpoint zero. */
 static usbvirt_control_request_handler_t endpoint_zero_handlers[] = {
 	{
-		STD_REQ(DIR_IN, REC_DEVICE, USB_DEVREQ_GET_DESCRIPTOR),
+		STD_REQ_IN(USB_REQUEST_RECIPIENT_DEVICE, USB_DEVREQ_GET_DESCRIPTOR),
 		.name = "GetDescriptor",
 		.callback = req_get_descriptor
 	},
 	{
-		CLASS_REQ(DIR_IN, REC_DEVICE, USB_DEVREQ_GET_DESCRIPTOR),
+		CLASS_REQ_IN(REC_DEVICE, USB_DEVREQ_GET_DESCRIPTOR),
 		.name = "GetDescriptor",
 		.callback = req_get_descriptor
 	},
 	{
-		CLASS_REQ(DIR_IN, REC_OTHER, USB_HUB_REQUEST_GET_STATUS),
+		CLASS_REQ_IN(REC_OTHER, USB_HUB_REQUEST_GET_STATUS),
 		.name = "GetPortStatus",
 		.callback = req_get_port_status
 	},
 	{
-		CLASS_REQ(DIR_OUT, REC_DEVICE, USB_HUB_REQUEST_CLEAR_FEATURE),
+		CLASS_REQ_OUT(REC_DEVICE, USB_HUB_REQUEST_CLEAR_FEATURE),
 		.name = "ClearHubFeature",
 		.callback = req_clear_hub_feature
 	},
 	{
-		CLASS_REQ(DIR_OUT, REC_OTHER, USB_HUB_REQUEST_CLEAR_FEATURE),
+		CLASS_REQ_OUT(REC_OTHER, USB_HUB_REQUEST_CLEAR_FEATURE),
 		.name = "ClearPortFeature",
 		.callback = req_clear_port_feature
 	},
 	{
-		CLASS_REQ(DIR_IN, REC_OTHER, USB_HUB_REQUEST_GET_STATE),
+		CLASS_REQ_IN(REC_OTHER, USB_HUB_REQUEST_GET_STATE),
 		.name = "GetBusState",
 		.callback = req_get_bus_state
 	},
 	{
-		CLASS_REQ(DIR_IN, REC_DEVICE, USB_HUB_REQUEST_GET_DESCRIPTOR),
+		CLASS_REQ_IN(REC_DEVICE, USB_HUB_REQUEST_GET_DESCRIPTOR),
 		.name = "GetHubDescriptor",
 		.callback = req_get_descriptor
 	},
 	{
-		CLASS_REQ(DIR_IN, REC_DEVICE, USB_HUB_REQUEST_GET_STATUS),
+		CLASS_REQ_IN(REC_DEVICE, USB_HUB_REQUEST_GET_STATUS),
 		.name = "GetHubStatus",
 		.callback = req_get_hub_status
 	},
 	{
-		CLASS_REQ(DIR_IN, REC_OTHER, USB_HUB_REQUEST_GET_STATUS),
+		CLASS_REQ_IN(REC_OTHER, USB_HUB_REQUEST_GET_STATUS),
 		.name = "GetPortStatus",
 		.callback = req_get_port_status
 	},
 	{
-		CLASS_REQ(DIR_OUT, REC_DEVICE, USB_HUB_REQUEST_SET_FEATURE),
+		CLASS_REQ_OUT(REC_DEVICE, USB_HUB_REQUEST_SET_FEATURE),
 		.name = "SetHubFeature",
 		.callback = req_set_hub_feature
 	},
 	{
-		CLASS_REQ(DIR_OUT, REC_OTHER, USB_HUB_REQUEST_SET_FEATURE),
+		CLASS_REQ_OUT(REC_OTHER, USB_HUB_REQUEST_SET_FEATURE),
 		.name = "SetPortFeature",
 		.callback = req_set_port_feature
Index: uspace/drv/bus/usb/vhc/main.c
===================================================================
--- uspace/drv/bus/usb/vhc/main.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/vhc/main.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -34,9 +34,4 @@
  */
 
-#include <loc.h>
-#include <async.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <sysinfo.h>
 #include <stdio.h>
 #include <errno.h>
@@ -44,84 +39,82 @@
 #include <ddf/driver.h>
 
-#include <usb/usb.h>
-#include <usb/ddfiface.h>
-#include <usb_iface.h>
+#include <usb/host/ddf_helpers.h>
+
+#include <usb/debug.h>
 #include "vhcd.h"
-#include "hub.h"
-#include "conn.h"
+
 
 static ddf_dev_ops_t vhc_ops = {
-	.interfaces[USBHC_DEV_IFACE] = &vhc_iface,
-	.interfaces[USB_DEV_IFACE] = &vhc_usb_iface,
 	.close = on_client_close,
 	.default_handler = default_connection_handler
 };
 
+static int vhc_control_node(ddf_dev_t *dev, ddf_fun_t **fun)
+{
+	assert(dev);
+	assert(fun);
+
+	*fun = ddf_fun_create(dev, fun_exposed, "ctl");
+	if (!*fun)
+		return ENOMEM;
+
+	vhc_data_t *vhc = ddf_fun_data_alloc(*fun, sizeof(vhc_data_t));
+	if (!vhc) {
+		ddf_fun_destroy(*fun);
+	}
+	ddf_fun_set_ops(*fun, &vhc_ops);
+	const int ret = ddf_fun_bind(*fun);
+	if (ret != EOK) {
+		ddf_fun_destroy(*fun);
+		*fun = NULL;
+		return ret;
+	}
+	vhc_init(vhc);
+	return EOK;
+}
+
 static int vhc_dev_add(ddf_dev_t *dev)
 {
-	static int vhc_count = 0;
-	int rc;
+	/* Initialize virtual structure */
+	ddf_fun_t *ctl_fun = NULL;
+	int ret = vhc_control_node(dev, &ctl_fun);
+	if (ret != EOK) {
+		usb_log_error("Failed to setup control node.\n");
+		return ret;
+	}
+	vhc_data_t *data = ddf_fun_data_get(ctl_fun);
 
-	if (vhc_count > 0) {
-		return ELIMIT;
+	/* Initialize generic structures */
+	ret = hcd_ddf_setup_hc(dev, USB_SPEED_FULL,
+	    BANDWIDTH_AVAILABLE_USB11, bandwidth_count_usb11);
+	if (ret != EOK) {
+		usb_log_error("Failed to init HCD structures: %s.\n",
+		   str_error(ret));
+		ddf_fun_destroy(ctl_fun);
+		return ret;
 	}
 
-	vhc_data_t *data = ddf_dev_data_alloc(dev, sizeof(vhc_data_t));
-	if (data == NULL) {
-		usb_log_fatal("Failed to allocate memory.\n");
-		return ENOMEM;
-	}
-	data->magic = 0xDEADBEEF;
-	rc = usb_endpoint_manager_init(&data->ep_manager, (size_t) -1,
-	    bandwidth_count_usb11);
-	if (rc != EOK) {
-		usb_log_fatal("Failed to initialize endpoint manager.\n");
-		free(data);
-		return rc;
-	}
-	usb_device_manager_init(&data->dev_manager, USB_SPEED_MAX);
+	hcd_set_implementation(dev_to_hcd(dev), data, vhc_schedule, NULL, NULL);
 
-	ddf_fun_t *hc = ddf_fun_create(dev, fun_exposed, "hc");
-	if (hc == NULL) {
-		usb_log_fatal("Failed to create device function.\n");
-		free(data);
-		return ENOMEM;
+	/* Add virtual hub device */
+	ret = vhc_virtdev_plug_hub(data, &data->hub, NULL, 0);
+	if (ret != EOK) {
+		usb_log_error("Failed to plug root hub: %s.\n", str_error(ret));
+		ddf_fun_destroy(ctl_fun);
+		return ret;
 	}
 
-	ddf_fun_set_ops(hc, &vhc_ops);
-	list_initialize(&data->devices);
-	fibril_mutex_initialize(&data->guard);
-	data->hub = &virtual_hub_device;
-	data->hc_fun = hc;
-
-	rc = ddf_fun_bind(hc);
-	if (rc != EOK) {
-		usb_log_fatal("Failed to bind HC function: %s.\n",
-		    str_error(rc));
-		free(data);
-		return rc;
+	/*
+	 * Creating root hub registers a new USB device so HC
+	 * needs to be ready at this time.
+	 */
+	ret = hcd_ddf_setup_root_hub(dev);
+	if (ret != EOK) {
+		usb_log_error("Failed to init VHC root hub: %s\n",
+			str_error(ret));
+		// TODO do something here...
 	}
 
-	rc = ddf_fun_add_to_category(hc, USB_HC_CATEGORY);
-	if (rc != EOK) {
-		usb_log_fatal("Failed to add function to HC class: %s.\n",
-		    str_error(rc));
-		free(data);
-		return rc;
-	}
-
-	virtual_hub_device_init(hc);
-
-	usb_log_info("Virtual USB host controller ready (dev %zu, hc %zu).\n",
-	    (size_t) ddf_dev_get_handle(dev), (size_t) ddf_fun_get_handle(hc));
-
-	rc = vhc_virtdev_plug_hub(data, data->hub, NULL);
-	if (rc != EOK) {
-		usb_log_fatal("Failed to plug root hub: %s.\n", str_error(rc));
-		free(data);
-		return rc;
-	}
-
-	return EOK;
+	return ret;
 }
 
@@ -135,9 +128,7 @@
 };
 
-
 int main(int argc, char * argv[])
-{	
+{
 	log_init(NAME);
-
 	printf(NAME ": virtual USB host controller driver.\n");
 
@@ -145,5 +136,4 @@
 }
 
-
 /**
  * @}
Index: uspace/drv/bus/usb/vhc/transfer.c
===================================================================
--- uspace/drv/bus/usb/vhc/transfer.c	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/vhc/transfer.c	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -29,52 +29,23 @@
 #include <errno.h>
 #include <str_error.h>
+#include <usb/debug.h>
 #include <usbvirt/device.h>
 #include <usbvirt/ipc.h>
 #include "vhcd.h"
-
-vhc_transfer_t *vhc_transfer_create(usb_address_t address, usb_endpoint_t ep,
-    usb_direction_t dir, usb_transfer_type_t tr_type,
-    ddf_fun_t *fun, void *callback_arg)
-{
-	vhc_transfer_t *result = malloc(sizeof(vhc_transfer_t));
-	if (result == NULL) {
-		return NULL;
-	}
-	link_initialize(&result->link);
-	result->address = address;
-	result->endpoint = ep;
-	result->direction = dir;
-	result->transfer_type = tr_type;
-	result->setup_buffer = NULL;
-	result->setup_buffer_size = 0;
-	result->data_buffer = NULL;
-	result->data_buffer_size = 0;
-	result->ddf_fun = fun;
-	result->callback_arg = callback_arg;
-	result->callback_in = NULL;
-	result->callback_out = NULL;
-
-	usb_log_debug2("Created transfer %p (%d.%d %s %s)\n", result,
-	    address, ep, usb_str_transfer_type_short(tr_type),
-	    dir == USB_DIRECTION_IN ? "in" : "out");
-
-	return result;
-}
+#include "hub/virthub.h"
 
 static bool is_set_address_transfer(vhc_transfer_t *transfer)
 {
-	if (transfer->endpoint != 0) {
-		return false;
-	}
-	if (transfer->transfer_type != USB_TRANSFER_CONTROL) {
-		return false;
-	}
-	if (transfer->direction != USB_DIRECTION_OUT) {
-		return false;
-	}
-	if (transfer->setup_buffer_size != sizeof(usb_device_request_setup_packet_t)) {
-		return false;
-	}
-	usb_device_request_setup_packet_t *setup = transfer->setup_buffer;
+	if (transfer->batch->ep->endpoint != 0) {
+		return false;
+	}
+	if (transfer->batch->ep->transfer_type != USB_TRANSFER_CONTROL) {
+		return false;
+	}
+	if (usb_transfer_batch_direction(transfer->batch) != USB_DIRECTION_OUT) {
+		return false;
+	}
+	const usb_device_request_setup_packet_t *setup =
+	    (void*)transfer->batch->setup_buffer;
 	if (setup->request_type != 0) {
 		return false;
@@ -87,94 +58,70 @@
 }
 
-int vhc_virtdev_add_transfer(vhc_data_t *vhc, vhc_transfer_t *transfer)
-{
-	fibril_mutex_lock(&vhc->guard);
-
-	bool target_found = false;
-	list_foreach(vhc->devices, link, vhc_virtdev_t, dev) {
-		fibril_mutex_lock(&dev->guard);
-		if (dev->address == transfer->address) {
-			if (target_found) {
-				usb_log_warning("Transfer would be accepted by more devices!\n");
-				goto next;
-			}
-			target_found = true;
-			list_append(&transfer->link, &dev->transfer_queue);
-		}
-next:
-		fibril_mutex_unlock(&dev->guard);
-	}
-
-	fibril_mutex_unlock(&vhc->guard);
-
-	if (target_found) {
-		return EOK;
+static int process_transfer_local(usb_transfer_batch_t *batch,
+    usbvirt_device_t *dev, size_t *actual_data_size)
+{
+	int rc;
+	
+	const usb_direction_t dir = usb_transfer_batch_direction(batch);
+
+	if (batch->ep->transfer_type == USB_TRANSFER_CONTROL) {
+		if (dir == USB_DIRECTION_IN) {
+			rc = usbvirt_control_read(dev,
+			    batch->setup_buffer, batch->setup_size,
+			    batch->buffer, batch->buffer_size,
+			    actual_data_size);
+		} else {
+			assert(dir == USB_DIRECTION_OUT);
+			rc = usbvirt_control_write(dev,
+			    batch->setup_buffer, batch->setup_size,
+			    batch->buffer, batch->buffer_size);
+		}
 	} else {
-		return ENOENT;
-	}
-}
-
-static int process_transfer_local(vhc_transfer_t *transfer,
-    usbvirt_device_t *dev, size_t *actual_data_size)
+		if (dir == USB_DIRECTION_IN) {
+			rc = usbvirt_data_in(dev, batch->ep->transfer_type,
+			    batch->ep->endpoint,
+			    batch->buffer, batch->buffer_size,
+			    actual_data_size);
+		} else {
+			assert(dir == USB_DIRECTION_OUT);
+			rc = usbvirt_data_out(dev, batch->ep->transfer_type,
+			    batch->ep->endpoint,
+			    batch->buffer, batch->buffer_size);
+		}
+	}
+
+	return rc;
+}
+
+static int process_transfer_remote(usb_transfer_batch_t *batch,
+    async_sess_t *sess, size_t *actual_data_size)
 {
 	int rc;
 
-	if (transfer->transfer_type == USB_TRANSFER_CONTROL) {
-		if (transfer->direction == USB_DIRECTION_IN) {
-			rc = usbvirt_control_read(dev,
-			    transfer->setup_buffer, transfer->setup_buffer_size,
-			    transfer->data_buffer, transfer->data_buffer_size,
-			    actual_data_size);
-		} else {
-			assert(transfer->direction == USB_DIRECTION_OUT);
-			rc = usbvirt_control_write(dev,
-			    transfer->setup_buffer, transfer->setup_buffer_size,
-			    transfer->data_buffer, transfer->data_buffer_size);
+	const usb_direction_t dir = usb_transfer_batch_direction(batch);
+
+	if (batch->ep->transfer_type == USB_TRANSFER_CONTROL) {
+		if (dir == USB_DIRECTION_IN) {
+			rc = usbvirt_ipc_send_control_read(sess,
+			    batch->setup_buffer, batch->setup_size,
+			    batch->buffer, batch->buffer_size,
+			    actual_data_size);
+		} else {
+			assert(dir == USB_DIRECTION_OUT);
+			rc = usbvirt_ipc_send_control_write(sess,
+			    batch->setup_buffer, batch->setup_size,
+			    batch->buffer, batch->buffer_size);
 		}
 	} else {
-		if (transfer->direction == USB_DIRECTION_IN) {
-			rc = usbvirt_data_in(dev, transfer->transfer_type,
-			    transfer->endpoint,
-			    transfer->data_buffer, transfer->data_buffer_size,
-			    actual_data_size);
-		} else {
-			assert(transfer->direction == USB_DIRECTION_OUT);
-			rc = usbvirt_data_out(dev, transfer->transfer_type,
-			    transfer->endpoint,
-			    transfer->data_buffer, transfer->data_buffer_size);
-		}
-	}
-
-	return rc;
-}
-
-static int process_transfer_remote(vhc_transfer_t *transfer,
-    async_sess_t *sess, size_t *actual_data_size)
-{
-	int rc;
-
-	if (transfer->transfer_type == USB_TRANSFER_CONTROL) {
-		if (transfer->direction == USB_DIRECTION_IN) {
-			rc = usbvirt_ipc_send_control_read(sess,
-			    transfer->setup_buffer, transfer->setup_buffer_size,
-			    transfer->data_buffer, transfer->data_buffer_size,
-			    actual_data_size);
-		} else {
-			assert(transfer->direction == USB_DIRECTION_OUT);
-			rc = usbvirt_ipc_send_control_write(sess,
-			    transfer->setup_buffer, transfer->setup_buffer_size,
-			    transfer->data_buffer, transfer->data_buffer_size);
-		}
-	} else {
-		if (transfer->direction == USB_DIRECTION_IN) {
-			rc = usbvirt_ipc_send_data_in(sess, transfer->endpoint,
-			    transfer->transfer_type,
-			    transfer->data_buffer, transfer->data_buffer_size,
-			    actual_data_size);
-		} else {
-			assert(transfer->direction == USB_DIRECTION_OUT);
-			rc = usbvirt_ipc_send_data_out(sess, transfer->endpoint,
-			    transfer->transfer_type,
-			    transfer->data_buffer, transfer->data_buffer_size);
+		if (dir == USB_DIRECTION_IN) {
+			rc = usbvirt_ipc_send_data_in(sess, batch->ep->endpoint,
+			    batch->ep->transfer_type,
+			    batch->buffer, batch->buffer_size,
+			    actual_data_size);
+		} else {
+			assert(dir == USB_DIRECTION_OUT);
+			rc = usbvirt_ipc_send_data_out(sess, batch->ep->endpoint,
+			    batch->ep->transfer_type,
+			    batch->buffer, batch->buffer_size);
 		}
 	}
@@ -195,23 +142,59 @@
 }
 
-
 static void execute_transfer_callback_and_free(vhc_transfer_t *transfer,
     size_t data_transfer_size, int outcome)
 {
 	assert(outcome != ENAK);
-
-	usb_log_debug2("Transfer %p ended: %s.\n",
-	    transfer, str_error(outcome));
-
-	if (transfer->direction == USB_DIRECTION_IN) {
-		transfer->callback_in(transfer->ddf_fun, outcome,
-		    data_transfer_size, transfer->callback_arg);
-	} else {
-		assert(transfer->direction == USB_DIRECTION_OUT);
-		transfer->callback_out(transfer->ddf_fun, outcome,
-		    transfer->callback_arg);
-	}
-
+	assert(transfer);
+	assert(transfer->batch);
+	usb_transfer_batch_finish_error(transfer->batch, NULL,
+	    data_transfer_size, outcome);
+	usb_transfer_batch_destroy(transfer->batch);
 	free(transfer);
+}
+
+int vhc_init(vhc_data_t *instance)
+{
+	assert(instance);
+	list_initialize(&instance->devices);
+	fibril_mutex_initialize(&instance->guard);
+	instance->magic = 0xDEADBEEF;
+	return virthub_init(&instance->hub, "root hub");
+}
+
+int vhc_schedule(hcd_t *hcd, usb_transfer_batch_t *batch)
+{
+	assert(hcd);
+	assert(batch);
+	vhc_data_t *vhc = hcd->driver.data;
+	assert(vhc);
+
+	vhc_transfer_t *transfer = malloc(sizeof(vhc_transfer_t));
+	if (!transfer)
+		return ENOMEM;
+	link_initialize(&transfer->link);
+	transfer->batch = batch;
+
+	fibril_mutex_lock(&vhc->guard);
+
+	int targets = 0;
+
+	list_foreach(vhc->devices, link, vhc_virtdev_t, dev) {
+		fibril_mutex_lock(&dev->guard);
+		if (dev->address == transfer->batch->ep->address) {
+			if (!targets) {
+				list_append(&transfer->link, &dev->transfer_queue);
+			}
+			++targets;
+		}
+		fibril_mutex_unlock(&dev->guard);
+	}
+
+	fibril_mutex_unlock(&vhc->guard);
+	
+	if (targets > 1)
+		usb_log_warning("Transfer would be accepted by more devices!\n");
+
+	return targets ? EOK : ENOENT;
 }
 
@@ -234,9 +217,9 @@
 		size_t data_transfer_size = 0;
 		if (dev->dev_sess) {
-			rc = process_transfer_remote(transfer, dev->dev_sess,
-			    &data_transfer_size);
+			rc = process_transfer_remote(transfer->batch,
+			    dev->dev_sess, &data_transfer_size);
 		} else if (dev->dev_local != NULL) {
-			rc = process_transfer_local(transfer, dev->dev_local,
-			    &data_transfer_size);
+			rc = process_transfer_local(transfer->batch,
+			    dev->dev_local, &data_transfer_size);
 		} else {
 			usb_log_warning("Device has no remote phone nor local node.\n");
@@ -251,5 +234,5 @@
 			if (is_set_address_transfer(transfer)) {
 				usb_device_request_setup_packet_t *setup
-				    = transfer->setup_buffer;
+				    = (void*)transfer->batch->setup_buffer;
 				dev->address = setup->value;
 				usb_log_debug2("Address changed to %d\n",
@@ -284,3 +267,2 @@
 	return EOK;
 }
-
Index: uspace/drv/bus/usb/vhc/vhcd.h
===================================================================
--- uspace/drv/bus/usb/vhc/vhcd.h	(revision 99e8fb7bd498e63f4a9fb1eb4573407fd0186f0d)
+++ uspace/drv/bus/usb/vhc/vhcd.h	(revision 1b973dca1487a453c533a0c9100b69142d3ea171)
@@ -36,10 +36,10 @@
 #define VHCD_VHCD_H_
 
-#include <usb/debug.h>
 #include <usbvirt/device.h>
-#include <usb/host/usb_endpoint_manager.h>
-#include <usb/host/usb_device_manager.h>
 #include <usbhc_iface.h>
 #include <async.h>
+
+#include <usb/host/hcd.h>
+
 
 #define NAME "vhc"
@@ -59,36 +59,25 @@
 	list_t devices;
 	fibril_mutex_t guard;
-	usb_endpoint_manager_t ep_manager;
-	usb_device_manager_t dev_manager;
-	usbvirt_device_t *hub;
-	ddf_fun_t *hc_fun;
+	usbvirt_device_t hub;
 } vhc_data_t;
 
 typedef struct {
 	link_t link;
-	usb_address_t address;
-	usb_endpoint_t endpoint;
-	usb_direction_t direction;
-	usb_transfer_type_t transfer_type;
-	void *setup_buffer;
-	size_t setup_buffer_size;
-	void *data_buffer;
-	size_t data_buffer_size;
-	ddf_fun_t *ddf_fun;
-	void *callback_arg;
-	usbhc_iface_transfer_in_callback_t callback_in;
-	usbhc_iface_transfer_out_callback_t callback_out;
+	usb_transfer_batch_t *batch;
 } vhc_transfer_t;
 
-vhc_transfer_t *vhc_transfer_create(usb_address_t, usb_endpoint_t,
-    usb_direction_t, usb_transfer_type_t, ddf_fun_t *, void *);
+
+void on_client_close(ddf_fun_t *fun);
+void default_connection_handler(ddf_fun_t *fun, ipc_callid_t icallid,
+    ipc_call_t *icall);
+
 int vhc_virtdev_plug(vhc_data_t *, async_sess_t *, uintptr_t *);
 int vhc_virtdev_plug_local(vhc_data_t *, usbvirt_device_t *, uintptr_t *);
-int vhc_virtdev_plug_hub(vhc_data_t *, usbvirt_device_t *, uintptr_t *);
+int vhc_virtdev_plug_hub(vhc_data_t *, usbvirt_device_t *, uintptr_t *, usb_address_t address);
 void vhc_virtdev_unplug(vhc_data_t *, uintptr_t);
-int vhc_virtdev_add_transfer(vhc_data_t *, vhc_transfer_t *);
 
+int vhc_init(vhc_data_t *instance);
+int vhc_schedule(hcd_t *hcd, usb_transfer_batch_t *batch);
 int vhc_transfer_queue_processor(void *arg);
-
 
 #endif
