Index: uspace/drv/uhci/Makefile
===================================================================
--- uspace/drv/uhci/Makefile	(revision 6b5f3b0340caede59d8168afb172fdf7cae32c74)
+++ uspace/drv/uhci/Makefile	(revision 35155333e1633196384ead6b221f756629e1e10d)
@@ -33,6 +33,9 @@
 
 SOURCES = \
+	iface.c \
 	main.c \
-	transfers.c
+	root_hub/port_status.c \
+	root_hub/root_hub.c \
+	uhci.c
 
 include $(USPACE_PREFIX)/Makefile.common
Index: uspace/drv/uhci/iface.c
===================================================================
--- uspace/drv/uhci/iface.c	(revision 35155333e1633196384ead6b221f756629e1e10d)
+++ uspace/drv/uhci/iface.c	(revision 35155333e1633196384ead6b221f756629e1e10d)
@@ -0,0 +1,162 @@
+/*
+ * 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.
+ */
+#include <usb/hcdhubd.h>
+#include <errno.h>
+
+#include "iface.h"
+#include "uhci.h"
+/*
+static int enqueue_transfer_out(device_t *dev,
+    usb_target_t target, usb_transfer_type_t transfer_type,
+    void *buffer, size_t size,
+    usbhc_iface_transfer_out_callback_t callback, void *arg)
+{
+	printf(NAME ": transfer OUT [%d.%d (%s); %zu]\n",
+	    target.address, target.endpoint,
+	    usb_str_transfer_type(transfer_type),
+	    size);
+
+	return ENOTSUP;
+}
+
+static int enqueue_transfer_setup(device_t *dev,
+    usb_target_t target, usb_transfer_type_t transfer_type,
+    void *buffer, size_t size,
+    usbhc_iface_transfer_out_callback_t callback, void *arg)
+{
+	printf(NAME ": transfer SETUP [%d.%d (%s); %zu]\n",
+	    target.address, target.endpoint,
+	    usb_str_transfer_type(transfer_type),
+	    size);
+
+	return ENOTSUP;
+}
+
+static int enqueue_transfer_in(device_t *dev,
+    usb_target_t target, usb_transfer_type_t transfer_type,
+    void *buffer, size_t size,
+    usbhc_iface_transfer_in_callback_t callback, void *arg)
+{
+	printf(NAME ": transfer IN [%d.%d (%s); %zu]\n",
+	    target.address, target.endpoint,
+	    usb_str_transfer_type(transfer_type),
+	    size);
+
+	return ENOTSUP;
+}
+*/
+
+static int get_address(device_t *dev, devman_handle_t handle,
+    usb_address_t *address)
+{
+	return ENOTSUP;
+}
+/*----------------------------------------------------------------------------*/
+static int interrupt_out(device_t *dev, usb_target_t target,
+    void *data, size_t size,
+    usbhc_iface_transfer_out_callback_t callback, void *arg)
+{
+	return uhci_out(dev, target, USB_TRANSFER_INTERRUPT,
+	    data, size, callback, arg);
+}
+/*----------------------------------------------------------------------------*/
+static int interrupt_in(device_t *dev, usb_target_t target,
+    void *data, size_t size,
+    usbhc_iface_transfer_in_callback_t callback, void *arg)
+{
+	return uhci_in(dev, target, USB_TRANSFER_INTERRUPT,
+	    data, size, callback, arg);
+}
+/*----------------------------------------------------------------------------*/
+static int control_write_setup(device_t *dev, usb_target_t target,
+    void *data, size_t size,
+    usbhc_iface_transfer_out_callback_t callback, void *arg)
+{
+	return uhci_setup(dev, target, USB_TRANSFER_CONTROL,
+	    data, size, callback, arg);
+}
+/*----------------------------------------------------------------------------*/
+static int control_write_data(device_t *dev, usb_target_t target,
+    void *data, size_t size,
+    usbhc_iface_transfer_out_callback_t callback, void *arg)
+{
+	return uhci_out(dev, target, USB_TRANSFER_CONTROL,
+	    data, size, callback, arg);
+}
+/*----------------------------------------------------------------------------*/
+static int control_write_status(device_t *dev, usb_target_t target,
+    usbhc_iface_transfer_in_callback_t callback, void *arg)
+{
+	return uhci_in(dev, target, USB_TRANSFER_CONTROL,
+	    NULL, 0, callback, arg);
+}
+/*----------------------------------------------------------------------------*/
+static int control_read_setup(device_t *dev, usb_target_t target,
+    void *data, size_t size,
+    usbhc_iface_transfer_out_callback_t callback, void *arg)
+{
+	return uhci_setup(dev, target, USB_TRANSFER_CONTROL,
+	    data, size, callback, arg);
+}
+/*----------------------------------------------------------------------------*/
+static int control_read_data(device_t *dev, usb_target_t target,
+    void *data, size_t size,
+    usbhc_iface_transfer_in_callback_t callback, void *arg)
+{
+	return uhci_in(dev, target, USB_TRANSFER_CONTROL,
+	    data, size, callback, arg);
+}
+/*----------------------------------------------------------------------------*/
+static int control_read_status(device_t *dev, usb_target_t target,
+    usbhc_iface_transfer_out_callback_t callback, void *arg)
+{
+	return uhci_out(dev, target, USB_TRANSFER_CONTROL,
+	    NULL, 0, callback, arg);
+}
+
+
+usbhc_iface_t uhci_iface = {
+	.tell_address = get_address,
+
+	.reserve_default_address = NULL,
+	.release_default_address = NULL,
+	.request_address = NULL,
+	.bind_address = NULL,
+	.release_address = NULL,
+
+	.interrupt_out = interrupt_out,
+	.interrupt_in = interrupt_in,
+
+	.control_write_setup = control_write_setup,
+	.control_write_data = control_write_data,
+	.control_write_status = control_write_status,
+
+	.control_read_setup = control_read_setup,
+	.control_read_data = control_read_data,
+	.control_read_status = control_read_status
+};
Index: uspace/drv/uhci/iface.h
===================================================================
--- uspace/drv/uhci/iface.h	(revision 35155333e1633196384ead6b221f756629e1e10d)
+++ uspace/drv/uhci/iface.h	(revision 35155333e1633196384ead6b221f756629e1e10d)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup usb
+ * @{
+ */
+/** @file
+ * @brief UHCI driver
+ */
+#ifndef DRV_UHCI_IFACE_H
+#define DRV_UHCI_IFACE_H
+
+#include <usbhc_iface.h>
+
+usbhc_iface_t uhci_iface;
+
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/uhci/link_ptr.h
===================================================================
--- uspace/drv/uhci/link_ptr.h	(revision 35155333e1633196384ead6b221f756629e1e10d)
+++ uspace/drv/uhci/link_ptr.h	(revision 35155333e1633196384ead6b221f756629e1e10d)
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+/** @addtogroup usb
+ * @{
+ */
+/** @file
+ * @brief UHCI driver
+ */
+#ifndef DRV_UHCI_LINK_PTR_H
+#define DRV_UHCI_LINK_PTR_H
+
+#include "td_ptr.h"
+
+/** Links in Frame List */
+typedef td_ptr_t link_ptr_t;
+
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/uhci/main.c
===================================================================
--- uspace/drv/uhci/main.c	(revision 6b5f3b0340caede59d8168afb172fdf7cae32c74)
+++ uspace/drv/uhci/main.c	(revision 35155333e1633196384ead6b221f756629e1e10d)
@@ -1,4 +1,4 @@
 /*
- * Copyright (c) 2010 Vojtech Horky
+ * Copyright (c) 2010 Vojtech Horky, Jan Vesely
  * All rights reserved.
  *
@@ -29,6 +29,9 @@
 #include <usb/debug.h>
 #include <errno.h>
-#include <driver.h>
+
+#include "iface.h"
+#include "name.h"
 #include "uhci.h"
+
 
 static device_ops_t uhci_ops = {
@@ -41,9 +44,11 @@
 	device->ops = &uhci_ops;
 
+	uhci_init( device, (void*)0xc020 );
+
 	/*
 	 * We need to announce the presence of our root hub.
 	 */
-	usb_dprintf(NAME, 2, "adding root hub\n");
-	usb_hcd_add_root_hub(device);
+//	usb_dprintf(NAME, 2, "adding root hub\n");
+//	usb_hcd_add_root_hub(device);
 
 	return EOK;
@@ -64,5 +69,5 @@
 	 * Do some global initializations.
 	 */
-	sleep(5);
+	sleep( 5);
 	usb_dprintf_enable(NAME, 5);
 
Index: uspace/drv/uhci/name.h
===================================================================
--- uspace/drv/uhci/name.h	(revision 35155333e1633196384ead6b221f756629e1e10d)
+++ uspace/drv/uhci/name.h	(revision 35155333e1633196384ead6b221f756629e1e10d)
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+/** @addtogroup usb
+ * @{
+ */
+/** @file
+ * @brief UHCI driver
+ */
+#ifndef DRV_UHCI_TD_NAME_H
+#define DRV_UHCI_TD_NAME_H
+
+#define NAME "uhci"
+
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/uhci/qh.h
===================================================================
--- uspace/drv/uhci/qh.h	(revision 35155333e1633196384ead6b221f756629e1e10d)
+++ uspace/drv/uhci/qh.h	(revision 35155333e1633196384ead6b221f756629e1e10d)
@@ -0,0 +1,47 @@
+
+/*
+ * 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.
+ */
+/** @addtogroup usb
+ * @{
+ */
+/** @file
+ * @brief UHCI driver
+ */
+#ifndef DRV_UHCI_QH_H
+#define DRV_UHCI_QH_H
+
+#include "link_ptr.h"
+
+typedef struct qh {
+	link_ptr_t
+} __attribute__(("packed")) link_ptr_t;
+
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/uhci/root_hub/port_status.c
===================================================================
--- uspace/drv/uhci/root_hub/port_status.c	(revision 35155333e1633196384ead6b221f756629e1e10d)
+++ uspace/drv/uhci/root_hub/port_status.c	(revision 35155333e1633196384ead6b221f756629e1e10d)
@@ -0,0 +1,20 @@
+#include <assert.h>
+#include <stdio.h>
+
+#include "port_status.h"
+
+void print_port_status( port_status_t *status )
+{
+	assert( status );
+	printf( "\tsuspended: %s\n", status->suspended ? "YES" : "NO" );
+	printf( "\tin reset: %s\n", status->reset ? "YES" : "NO" );
+	printf( "\tlow speed: %s\n", status->low_speed ? "YES" : "NO" );
+	printf( "\tresume detected: %s\n", status->resume ? "YES" : "NO" );
+	printf( "\talways \"1\" reserved bit: %s\n",
+	  status->always_one ? "YES" : "NO" );
+	/* line status skipped */
+	printf( "\tenable/disable change: %s\n", status->enabled_change ? "YES" : "NO" );
+	printf( "\tport enabled: %s\n", status->enabled ? "YES" : "NO" );
+	printf( "\tconnect change: %s\n", status->connect_change ? "YES" : "NO" );
+	printf( "\tconnected: %s\n", status->connected ? "YES" : "NO" );
+}
Index: uspace/drv/uhci/root_hub/port_status.h
===================================================================
--- uspace/drv/uhci/root_hub/port_status.h	(revision 35155333e1633196384ead6b221f756629e1e10d)
+++ uspace/drv/uhci/root_hub/port_status.h	(revision 35155333e1633196384ead6b221f756629e1e10d)
@@ -0,0 +1,74 @@
+/*
+ * 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.
+ */
+/** @addtogroup usb
+ * @{
+ */
+/** @file
+ * @brief UHCI driver
+ */
+#ifndef DRV_UHCI_TD_PORT_STATUS_H
+#define DRV_UHCI_TD_PORT_STATUS_H
+
+#include <stdint.h>
+
+typedef struct port_status {
+	uint8_t connected:1;
+	uint8_t connect_change:1;
+	uint8_t enabled:1;
+	uint8_t enabled_change:1;
+	uint8_t line:2;
+	uint8_t resume:1;
+	const uint8_t always_one:1; /* reserved */
+
+	uint8_t low_speed:1;
+	uint8_t reset:1;
+	uint8_t :2; /* reserved */
+	uint8_t suspended:1;
+	uint8_t :3; /* reserved */
+	/* first byte */
+//	uint8_t :3; /* reserved */
+//	uint8_t suspended:1;
+//	uint8_t :2; /* reserved */
+//	uint8_t reset:1;
+//	uint8_t low_speed:1;
+
+	/* second byte */
+//	uint8_t :1; /* reserved */
+//	uint8_t resume:1;
+//	uint8_t line:2;
+//	uint8_t enabled_change:1;
+//	uint8_t enabled:1;
+//	uint8_t connect_change:1;
+//	uint8_t connected:1;
+} __attribute__((packed)) port_status_t;
+
+void print_port_status( port_status_t *status );
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/uhci/root_hub/root_hub.c
===================================================================
--- uspace/drv/uhci/root_hub/root_hub.c	(revision 35155333e1633196384ead6b221f756629e1e10d)
+++ uspace/drv/uhci/root_hub/root_hub.c	(revision 35155333e1633196384ead6b221f756629e1e10d)
@@ -0,0 +1,60 @@
+#include <ddi.h>
+#include <async.h>
+#include <errno.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <usb/debug.h>
+
+#include "../name.h"
+#include "../uhci.h"
+#include "port_status.h"
+#include "root_hub.h"
+
+static int uhci_root_hub_check_ports( void * device );
+/*----------------------------------------------------------------------------*/
+int uhci_root_hub_init( uhci_root_hub_t *hub, device_t *device, void *addr )
+{
+	assert( hub );
+	hub->checker = fibril_create( uhci_root_hub_check_ports, device );
+	if (hub->checker == 0) {
+		printf( NAME": Failed to launch root hub fibril." );
+		return ENOMEM;
+	}
+	fibril_add_ready( hub->checker );
+	port_regs_t *regs;
+	const int ret = pio_enable( addr, sizeof(port_regs_t), (void**)&regs);
+	if (ret < 0) {
+		printf(NAME": Failed to gain access to port registers at %p\n", regs);
+		return ret;
+	}
+	hub->registers = regs;
+
+	return EOK;
+}
+/*----------------------------------------------------------------------------*/
+int uhci_root_hub_fini( uhci_root_hub_t* instance )
+{
+	assert( instance );
+	//destroy fibril here
+	return EOK;
+}
+/*----------------------------------------------------------------------------*/
+static int uhci_root_hub_check_ports( void * device )
+{
+	assert( device );
+	uhci_t *uhci_instance = ((device_t*)device)->driver_data;
+	while (1) {
+		int i = 0;
+		for (; i < UHCI_ROOT_HUB_PORT_COUNT; ++i) {
+			volatile uint16_t * address =
+				&(uhci_instance->root_hub.registers->portsc[i]);
+
+			usb_dprintf( NAME, 1, "Port(%d) status address %p:\n", i, address );
+			uint16_t value = pio_read_16( address );
+			usb_dprintf( NAME, 1, "Port(%d) status 0x%x:\n", i, value );
+			print_port_status( (port_status_t*)&value );
+		}
+		async_usleep( 1000000 );
+	}
+	return ENOTSUP;
+}
Index: uspace/drv/uhci/root_hub/root_hub.h
===================================================================
--- uspace/drv/uhci/root_hub/root_hub.h	(revision 35155333e1633196384ead6b221f756629e1e10d)
+++ uspace/drv/uhci/root_hub/root_hub.h	(revision 35155333e1633196384ead6b221f756629e1e10d)
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+/** @addtogroup usb
+ * @{
+ */
+/** @file
+ * @brief UHCI driver
+ */
+#ifndef DRV_UHCI_TD_ROOT_HUB_H
+#define DRV_UHCI_TD_ROOT_HUB_H
+
+#include <fibril.h>
+#include <driver.h>
+
+#define UHCI_ROOT_HUB_PORT_COUNT 2
+#define UHCI_ROOT_HUB_PORT_REGISTERS_OFFSET 0x10
+
+typedef struct port_regs {
+	uint16_t portsc[UHCI_ROOT_HUB_PORT_COUNT];
+} port_regs_t;
+
+typedef struct root_hub {
+	port_regs_t *registers;
+	fid_t checker;
+} uhci_root_hub_t;
+
+int uhci_root_hub_init(
+  uhci_root_hub_t *instance, device_t *device, void *addr );
+
+int uhci_root_hub_fini( uhci_root_hub_t* instance );
+
+//int uhci_root_hub_check_ports( void * device );
+
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/uhci/td_ptr.h
===================================================================
--- uspace/drv/uhci/td_ptr.h	(revision 35155333e1633196384ead6b221f756629e1e10d)
+++ uspace/drv/uhci/td_ptr.h	(revision 35155333e1633196384ead6b221f756629e1e10d)
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+/** @addtogroup usb
+ * @{
+ */
+/** @file
+ * @brief UHCI driver
+ */
+#ifndef DRV_UHCI_TD_PTR_H
+#define DRV_UHCI_TD_PTR_H
+
+/** UHCI Transfer Descriptor pointer */
+typedef struct td_ptr {
+	uint32_t fpl:28;
+	char :2;
+	uint8_t qh:1;
+	uint8_t terminate:1;
+} __attribute__(("packed")) td_ptr_t;
+
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/uhci/transfer.h
===================================================================
--- uspace/drv/uhci/transfer.h	(revision 35155333e1633196384ead6b221f756629e1e10d)
+++ uspace/drv/uhci/transfer.h	(revision 35155333e1633196384ead6b221f756629e1e10d)
@@ -0,0 +1,81 @@
+/*
+ * 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.
+ */
+/** @addtogroup usb
+ * @{
+ */
+/** @file
+ * @brief UHCI driver
+ */
+#ifndef DRV_UHCI_TRANSFER_H
+#define DRV_UHCI_TRANSFER_H
+
+/** Status field in UHCI Transfer Descriptor (TD) */
+typedef struct status {
+	uint8_t active:1;
+	uint8_t stalled:1;
+	uint8_t data_buffer_error:1;
+	uint8_t babble:1;
+	uint8_t nak:1;
+	uint8_t crc:1;
+	uint8_t bitstuff:1;
+	uint8_t :1; /* reserved */
+} status_t
+
+/** UHCI Transfer Descriptor */
+typedef struct td {
+	uint32_t fpl:28;
+	char :1; /* reserved */
+	uint8_t depth:1;
+	uint8_t qh:1;
+	uint8_t terminate:1;
+
+	char :2; /* reserved */
+	uint8_t spd:1;
+	uint8_t error_count:2;
+	uint8_t low_speed:1;
+	uint8_t isochronous:1;
+	uint8_t ioc:1;
+	status_t status;
+	char :5; /* reserved */
+	uint16_t act_len:10;
+
+	uint16_t maxlen:11;
+	char :1; /* reserved */
+	uint8_t toggle:1;
+	uint8_t end_point:4;
+	uint8_t address:7;
+	uint8_t pid;
+
+	uint32_t buffer_ptr;
+} __attribute__(("packed")) td_t;
+
+
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/uhci/transfers.c
===================================================================
--- uspace/drv/uhci/transfers.c	(revision 6b5f3b0340caede59d8168afb172fdf7cae32c74)
+++ 	(revision )
@@ -1,160 +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.
- */
-#include <usb/hcdhubd.h>
-#include <errno.h>
-
-#include "uhci.h"
-
-static int enqueue_transfer_out(device_t *dev,
-    usb_target_t target, usb_transfer_type_t transfer_type,
-    void *buffer, size_t size,
-    usbhc_iface_transfer_out_callback_t callback, void *arg)
-{
-	printf(NAME ": transfer OUT [%d.%d (%s); %zu]\n",
-	    target.address, target.endpoint,
-	    usb_str_transfer_type(transfer_type),
-	    size);
-
-	return ENOTSUP;
-}
-
-static int enqueue_transfer_setup(device_t *dev,
-    usb_target_t target, usb_transfer_type_t transfer_type,
-    void *buffer, size_t size,
-    usbhc_iface_transfer_out_callback_t callback, void *arg)
-{
-	printf(NAME ": transfer SETUP [%d.%d (%s); %zu]\n",
-	    target.address, target.endpoint,
-	    usb_str_transfer_type(transfer_type),
-	    size);
-
-	return ENOTSUP;
-}
-
-static int enqueue_transfer_in(device_t *dev,
-    usb_target_t target, usb_transfer_type_t transfer_type,
-    void *buffer, size_t size,
-    usbhc_iface_transfer_in_callback_t callback, void *arg)
-{
-	printf(NAME ": transfer IN [%d.%d (%s); %zu]\n",
-	    target.address, target.endpoint,
-	    usb_str_transfer_type(transfer_type),
-	    size);
-
-	return ENOTSUP;
-}
-
-
-static int get_address(device_t *dev, devman_handle_t handle,
-    usb_address_t *address)
-{
-	return ENOTSUP;
-}
-
-static int interrupt_out(device_t *dev, usb_target_t target,
-    void *data, size_t size,
-    usbhc_iface_transfer_out_callback_t callback, void *arg)
-{
-	return enqueue_transfer_out(dev, target, USB_TRANSFER_INTERRUPT,
-	    data, size,
-	    callback, arg);
-}
-
-static int interrupt_in(device_t *dev, usb_target_t target,
-    void *data, size_t size,
-    usbhc_iface_transfer_in_callback_t callback, void *arg)
-{
-	return enqueue_transfer_in(dev, target, USB_TRANSFER_INTERRUPT,
-	    data, size,
-	    callback, arg);
-}
-
-static int control_write_setup(device_t *dev, usb_target_t target,
-    void *data, size_t size,
-    usbhc_iface_transfer_out_callback_t callback, void *arg)
-{
-	return enqueue_transfer_setup(dev, target, USB_TRANSFER_CONTROL,
-	    data, size,
-	    callback, arg);
-}
-
-static int control_write_data(device_t *dev, usb_target_t target,
-    void *data, size_t size,
-    usbhc_iface_transfer_out_callback_t callback, void *arg)
-{
-	return enqueue_transfer_out(dev, target, USB_TRANSFER_CONTROL,
-	    data, size,
-	    callback, arg);
-}
-
-static int control_write_status(device_t *dev, usb_target_t target,
-    usbhc_iface_transfer_in_callback_t callback, void *arg)
-{
-	return enqueue_transfer_in(dev, target, USB_TRANSFER_CONTROL,
-	    NULL, 0,
-	    callback, arg);
-}
-
-static int control_read_setup(device_t *dev, usb_target_t target,
-    void *data, size_t size,
-    usbhc_iface_transfer_out_callback_t callback, void *arg)
-{
-	return enqueue_transfer_setup(dev, target, USB_TRANSFER_CONTROL,
-	    data, size,
-	    callback, arg);
-}
-
-static int control_read_data(device_t *dev, usb_target_t target,
-    void *data, size_t size,
-    usbhc_iface_transfer_in_callback_t callback, void *arg)
-{
-	return enqueue_transfer_in(dev, target, USB_TRANSFER_CONTROL,
-	    data, size,
-	    callback, arg);
-}
-
-static int control_read_status(device_t *dev, usb_target_t target,
-    usbhc_iface_transfer_out_callback_t callback, void *arg)
-{
-	return enqueue_transfer_out(dev, target, USB_TRANSFER_CONTROL,
-	    NULL, 0,
-	    callback, arg);
-}
-
-
-usbhc_iface_t uhci_iface = {
-	.tell_address = get_address,
-	.interrupt_out = interrupt_out,
-	.interrupt_in = interrupt_in,
-	.control_write_setup = control_write_setup,
-	.control_write_data = control_write_data,
-	.control_write_status = control_write_status,
-	.control_read_setup = control_read_setup,
-	.control_read_data = control_read_data,
-	.control_read_status = control_read_status
-};
Index: uspace/drv/uhci/uhci.c
===================================================================
--- uspace/drv/uhci/uhci.c	(revision 35155333e1633196384ead6b221f756629e1e10d)
+++ uspace/drv/uhci/uhci.c	(revision 35155333e1633196384ead6b221f756629e1e10d)
@@ -0,0 +1,89 @@
+#include <errno.h>
+#include <usb/debug.h>
+
+#include "name.h"
+#include "uhci.h"
+
+
+int uhci_init(device_t *device, void *regs)
+{
+	assert( device );
+	usb_dprintf(NAME, 1, "Initializing device at address %p\n", device);
+
+	/* create instance */
+	uhci_t *instance = malloc( sizeof(uhci_t) );
+	if (!instance)
+		{ return ENOMEM; }
+	memset( instance, 0, sizeof(uhci_t) );
+
+	/* allow access to hc control registers */
+	regs_t *io;
+	int ret = pio_enable( regs, sizeof(regs_t), (void**)&io);
+	if (ret < 0) {
+		free( instance );
+		printf(NAME": Failed to gain access to registers at %p\n", io);
+		return ret;
+	}
+	instance->registers = io;
+
+	/* init root hub */
+	ret = uhci_root_hub_init( &instance->root_hub, device,
+	  (char*)regs + UHCI_ROOT_HUB_PORT_REGISTERS_OFFSET );
+	if (ret < 0) {
+		free( instance );
+		printf(NAME": Failed to initialize root hub driver.\n");
+		return ret;
+	}
+
+	device->driver_data = instance;
+	return EOK;
+}
+/*----------------------------------------------------------------------------*/
+int uhci_in(
+  device_t *dev,
+	usb_target_t target,
+	usb_transfer_type_t transfer_type,
+	void *buffer, size_t size,
+	usbhc_iface_transfer_in_callback_t callback, void *arg
+	)
+{
+	usb_dprintf(NAME, 1, "transfer IN [%d.%d (%s); %zu]\n",
+	    target.address, target.endpoint,
+	    usb_str_transfer_type(transfer_type),
+	    size);
+
+	return ENOTSUP;
+}
+/*----------------------------------------------------------------------------*/
+int uhci_out(
+  device_t *dev,
+  usb_target_t target,
+  usb_transfer_type_t transfer_type,
+  void *buffer, size_t size,
+	usbhc_iface_transfer_out_callback_t callback, void *arg
+  )
+{
+	usb_dprintf(NAME, 1, "transfer OUT [%d.%d (%s); %zu]\n",
+	    target.address, target.endpoint,
+	    usb_str_transfer_type(transfer_type),
+	    size);
+
+	return ENOTSUP;
+}
+/*----------------------------------------------------------------------------*/
+int uhci_setup(
+  device_t *dev,
+  usb_target_t target,
+  usb_transfer_type_t transfer_type,
+  void *buffer, size_t size,
+  usbhc_iface_transfer_out_callback_t callback, void *arg
+  )
+{
+	usb_dprintf(NAME, 1, "transfer SETUP [%d.%d (%s); %zu]\n",
+	    target.address, target.endpoint,
+	    usb_str_transfer_type(transfer_type),
+	    size);
+
+	return ENOTSUP;
+}
+/*----------------------------------------------------------------------------*/
Index: uspace/drv/uhci/uhci.h
===================================================================
--- uspace/drv/uhci/uhci.h	(revision 6b5f3b0340caede59d8168afb172fdf7cae32c74)
+++ uspace/drv/uhci/uhci.h	(revision 35155333e1633196384ead6b221f756629e1e10d)
@@ -1,4 +1,4 @@
 /*
- * Copyright (c) 2010 Vojtech Horky
+ * Copyright (c) 2010 Jan Vesely
  * All rights reserved.
  *
@@ -26,5 +26,4 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-
 /** @addtogroup usb
  * @{
@@ -36,9 +35,56 @@
 #define DRV_UHCI_UHCI_H
 
+#include <fibril.h>
+
+#include <usb/addrkeep.h>
+#include <usb/hcdhubd.h>
 #include <usbhc_iface.h>
 
-#define NAME "uhci"
+#include "root_hub/root_hub.h"
 
-usbhc_iface_t uhci_iface;
+typedef struct uhci_regs {
+	uint16_t usbcmd;
+	uint16_t usbsts;
+	uint16_t usbintr;
+	uint16_t frnum;
+	uint32_t flbaseadd;
+	uint8_t sofmod;
+} regs_t;
+
+typedef struct uhci {
+	usb_address_keeping_t address_manager;
+	uhci_root_hub_t root_hub;
+	volatile regs_t* registers;
+
+} uhci_t ;
+
+/* init uhci specifics in device.driver_data */
+int uhci_init( device_t *device, void *regs );
+
+int uhci_destroy( device_t *device );
+
+int uhci_in(
+  device_t *dev,
+	usb_target_t target,
+	usb_transfer_type_t transfer_type,
+	void *buffer, size_t size,
+	usbhc_iface_transfer_in_callback_t callback, void *arg
+	);
+
+int uhci_out(
+  device_t *dev,
+	usb_target_t target,
+  usb_transfer_type_t transfer_type,
+  void *buffer, size_t size,
+	usbhc_iface_transfer_out_callback_t callback, void *arg
+  );
+
+int uhci_setup(
+  device_t *dev,
+  usb_target_t target,
+  usb_transfer_type_t transfer_type,
+  void *buffer, size_t size,
+  usbhc_iface_transfer_out_callback_t callback, void *arg
+  );
 
 #endif
