Index: uspace/drv/bus/usb/ehci/Makefile
===================================================================
--- uspace/drv/bus/usb/ehci/Makefile	(revision 17605562ff9d557548e52727485de508c911f4fe)
+++ uspace/drv/bus/usb/ehci/Makefile	(revision 6297465f7d3b817f92dba0162f342c50ff988a8a)
@@ -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 6297465f7d3b817f92dba0162f342c50ff988a8a)
+++ uspace/drv/bus/usb/ehci/ehci.c	(revision 6297465f7d3b817f92dba0162f342c50ff988a8a)
@@ -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 6297465f7d3b817f92dba0162f342c50ff988a8a)
+++ uspace/drv/bus/usb/ehci/ehci.h	(revision 6297465f7d3b817f92dba0162f342c50ff988a8a)
@@ -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_rh.c
===================================================================
--- uspace/drv/bus/usb/ehci/ehci_rh.c	(revision 6297465f7d3b817f92dba0162f342c50ff988a8a)
+++ uspace/drv/bus/usb/ehci/ehci_rh.c	(revision 6297465f7d3b817f92dba0162f342c50ff988a8a)
@@ -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 6297465f7d3b817f92dba0162f342c50ff988a8a)
+++ uspace/drv/bus/usb/ehci/ehci_rh.h	(revision 6297465f7d3b817f92dba0162f342c50ff988a8a)
@@ -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 6297465f7d3b817f92dba0162f342c50ff988a8a)
+++ uspace/drv/bus/usb/ehci/hc.c	(revision 6297465f7d3b817f92dba0162f342c50ff988a8a)
@@ -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 6297465f7d3b817f92dba0162f342c50ff988a8a)
+++ uspace/drv/bus/usb/ehci/hc.h	(revision 6297465f7d3b817f92dba0162f342c50ff988a8a)
@@ -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/main.c
===================================================================
--- uspace/drv/bus/usb/ehci/main.c	(revision 17605562ff9d557548e52727485de508c911f4fe)
+++ uspace/drv/bus/usb/ehci/main.c	(revision 6297465f7d3b817f92dba0162f342c50ff988a8a)
@@ -44,4 +44,5 @@
 
 #include "res.h"
+#include "ehci.h"
 
 #define NAME "ehci"
@@ -91,7 +92,7 @@
 
 	/* High Speed, no bandwidth */
-	ret = hcd_ddf_setup_hc(device, USB_SPEED_HIGH, 0, NULL);
+	ret = device_setup_ehci(device);
 	if (ret != EOK) {
-		usb_log_error("Failed to init generci hcd driver: %s\n",
+		usb_log_error("Failed to init ehci driver: %s\n",
 		    str_error(ret));
 		return ret;
Index: uspace/drv/bus/usb/ehci/utils/malloc32.h
===================================================================
--- uspace/drv/bus/usb/ehci/utils/malloc32.h	(revision 6297465f7d3b817f92dba0162f342c50ff988a8a)
+++ uspace/drv/bus/usb/ehci/utils/malloc32.h	(revision 6297465f7d3b817f92dba0162f342c50ff988a8a)
@@ -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
+/**
+ * @}
+ */
