Index: uspace/lib/usb/Makefile
===================================================================
--- uspace/lib/usb/Makefile	(revision 436300063cf897d3a8d003c018a42e184f48d928)
+++ uspace/lib/usb/Makefile	(revision b4b534ac1d1515633baff0d563e9c16938bfe19f)
@@ -36,9 +36,7 @@
 SOURCES = \
 	src/class.c \
-	src/ddfiface.c \
 	src/dev.c \
 	src/debug.c \
 	src/dump.c \
-	src/hc.c \
 	src/usb.c
 
Index: uspace/lib/usb/include/usb/classes/hub.h
===================================================================
--- uspace/lib/usb/include/usb/classes/hub.h	(revision 436300063cf897d3a8d003c018a42e184f48d928)
+++ uspace/lib/usb/include/usb/classes/hub.h	(revision b4b534ac1d1515633baff0d563e9c16938bfe19f)
@@ -43,8 +43,8 @@
  */
 typedef enum {
+	USB_HUB_FEATURE_C_HUB_LOCAL_POWER = 0,
+	USB_HUB_FEATURE_C_HUB_OVER_CURRENT = 1,
 	USB_HUB_FEATURE_HUB_LOCAL_POWER = 0,
 	USB_HUB_FEATURE_HUB_OVER_CURRENT = 1,
-	USB_HUB_FEATURE_C_HUB_LOCAL_POWER = 0,
-	USB_HUB_FEATURE_C_HUB_OVER_CURRENT = 1,
 	USB_HUB_FEATURE_PORT_CONNECTION = 0,
 	USB_HUB_FEATURE_PORT_ENABLE = 1,
@@ -54,4 +54,5 @@
 	USB_HUB_FEATURE_PORT_POWER = 8,
 	USB_HUB_FEATURE_PORT_LOW_SPEED = 9,
+	USB_HUB_FEATURE_PORT_HIGH_SPEED = 10,
 	USB_HUB_FEATURE_C_PORT_CONNECTION = 16,
 	USB_HUB_FEATURE_C_PORT_ENABLE = 17,
@@ -59,4 +60,6 @@
 	USB_HUB_FEATURE_C_PORT_OVER_CURRENT = 19,
 	USB_HUB_FEATURE_C_PORT_RESET = 20,
+	USB_HUB_FEATURE_PORT_TEST = 21,
+	USB_HUB_FEATURE_PORT_INDICATOR = 22
 	/* USB_HUB_FEATURE_ = , */
 } usb_hub_class_feature_t;
@@ -67,108 +70,75 @@
 	/** Descriptor length. */
 	uint8_t length;
+
 	/** Descriptor type (0x29). */
 	uint8_t descriptor_type;
+
 	/** Number of downstream ports. */
 	uint8_t port_count;
-	/** Characteristics bitmask. */
+
+	/** Characteristics bitmask.
+	 *
+	 *  D1..D0: Logical Power Switching Mode
+	 *  00: Ganged power switching (all ports power at
+	 *  once)
+	 *  01: Individual port power switching
+	 *  1X: Reserved. Used only on 1.0 compliant hubs
+	 *  that implement no power switching.
+	 *  D2: Identifies a Compound Device
+	 *  0: Hub is not part of a compound device
+	 *  1: Hub is part of a compound device
+	 *  D4..D3: Over-current Protection Mode
+	 *  00: Global Over-current Protection. The hub
+	 *  reports over-current as a summation of all
+	 *  ports current draw, without a breakdown of
+	 *  individual port over-current status.
+	 *  01: Individual Port Over-current Protection. The
+	 *  hub reports over-current on a per-port basis.
+	 *  Each port has an over-current indicator.
+	 *  1X: No Over-current Protection. This option is
+	 *  allowed only for bus-powered hubs that do not
+	 *  implement over-current protection.
+	 *  D6..D5: TT think time
+	 *  00: At most 8 FS bit times
+	 *  01: At most 16 FS bit times
+	 *  10: At most 24 FS bit times
+	 *  11: At most 32 FS bit times
+	 *  D7: Port indicators
+	 *  0: Not supported
+	 *  1: Supported
+	 *  D15...D8: Reserved
+	 */
 	uint8_t characteristics;
-#define HUB_CHAR_POWER_PER_PORT_FLAG  (1 << 0)
-#define HUB_CHAR_NO_POWER_SWITCH_FLAG (1 << 1)
-	/* Unused part of characteristics field */
+#define HUB_CHAR_POWER_PER_PORT_FLAG    (1 << 0)
+#define HUB_CHAR_NO_POWER_SWITCH_FLAG   (1 << 1)
+#define HUB_CHAR_COMPOUND_DEVICE        (1 << 2)
+#define HUB_CHAR_OC_PER_PORT_FLAG       (1 << 3)
+#define HUB_CHAR_NO_OC_FLAG             (1 << 4)
+#define HUB_CHAR_TT_THINK_16            (1 << 5)
+#define HUB_CHAR_TT_THINK_8             (1 << 6)
+#define HUB_CHAR_INDICATORS_FLAG        (1 << 7)
+
+	/** Unused part of characteristics field */
 	uint8_t characteristics_reserved;
-	/** Time from power-on to stabilization of current on the port. */
+
+	/** Time from power-on to stabilization of current on the port.
+	 *
+	 *  Time (in 2ms intervals) from the time the power-on
+	 *  sequence begins on a port until power is good on that
+	 *  port. The USB System Software uses this value to
+	 *  determine how long to wait before accessing a
+	 *  powered-on port.
+	 */
 	uint8_t power_good_time;
-	/** Maximum current requirements in mA. */
+	/** Maximum current requirements in mA.
+	 *
+	 *  Maximum current requirements of the Hub Controller
+	 *  electronics in mA.
+	 */
 	uint8_t max_current;
 } __attribute__ ((packed)) usb_hub_descriptor_header_t;
 
-/**
- * @brief usb hub descriptor
- *
- * For more information see Universal Serial Bus Specification Revision 1.1
- * chapter 11.16.2
- */
-typedef struct usb_hub_descriptor_type {
-    /** Number of bytes in this descriptor, including this byte */
-    //uint8_t bDescLength;
-
-    /** Descriptor Type, value: 29H for hub descriptor */
-    //uint8_t bDescriptorType;
-
-    /** Number of downstream ports that this hub supports */
-    uint8_t port_count;
-
-    /**
-            D1...D0: Logical Power Switching Mode
-            00: Ganged power switching (all ports power at
-            once)
-            01: Individual port power switching
-            1X: Reserved. Used only on 1.0 compliant hubs
-            that implement no power switching.
-            D2: Identifies a Compound Device
-            0: Hub is not part of a compound device
-            1: Hub is part of a compound device
-            D4...D3: Over-current Protection Mode
-            00: Global Over-current Protection. The hub
-            reports over-current as a summation of all
-            ports current draw, without a breakdown of
-            individual port over-current status.
-            01: Individual Port Over-current Protection. The
-            hub reports over-current on a per-port basis.
-            Each port has an over-current indicator.
-            1X: No Over-current Protection. This option is
-            allowed only for bus-powered hubs that do not
-            implement over-current protection.
-            D15...D5:
-            Reserved
-     */
-    uint16_t hub_characteristics;
-
-    /**
-            Time (in 2ms intervals) from the time the power-on
-            sequence begins on a port until power is good on that
-            port. The USB System Software uses this value to
-            determine how long to wait before accessing a
-            powered-on port.
-     */
-    uint8_t pwr_on_2_good_time;
-
-    /**
-            Maximum current requirements of the Hub Controller
-            electronics in mA.
-     */
-    uint8_t current_requirement;
-
-    /**
-            Indicates if a port has a removable device attached.
-            This field is reported on byte-granularity. Within a
-            byte, if no port exists for a given location, the field
-            representing the port characteristics returns 0.
-            Bit value definition:
-            0B - Device is removable
-            1B - Device is non-removable
-            This is a bitmap corresponding to the individual ports
-            on the hub:
-            Bit 0: Reserved for future use
-            Bit 1: Port 1
-            Bit 2: Port 2
-            ....
-            Bit n: Port n (implementation-dependent, up to a
-            maximum of 255 ports).
-     */
-    uint8_t devices_removable[32];
-
-    /**
-            This field exists for reasons of compatibility with
-            software written for 1.0 compliant devices. All bits in
-            this field should be set to 1B. This field has one bit for
-            each port on the hub with additional pad bits, if
-            necessary, to make the number of bits in the field an
-            integer multiple of 8.
-     */
-    //uint8_t * port_pwr_ctrl_mask;
-} usb_hub_descriptor_t;
-
-
+/** One bit for the device and one bit for every port */
+#define STATUS_BYTES(ports) ((1 + ports + 7) / 8)
 
 /**	@brief usb hub specific request types.
@@ -204,5 +174,5 @@
     /** */
     USB_HUB_REQUEST_CLEAR_FEATURE = 1,
-    /** */
+    /** USB 1.0 only */
     USB_HUB_REQUEST_GET_STATE = 2,
     /** */
@@ -211,5 +181,13 @@
     USB_HUB_REQUEST_GET_DESCRIPTOR = 6,
     /** */
-    USB_HUB_REQUEST_SET_DESCRIPTOR = 7
+    USB_HUB_REQUEST_SET_DESCRIPTOR = 7,
+    /** */
+    USB_HUB_REQUEST_CLEAR_TT_BUFFER = 8,
+    /** */
+    USB_HUB_REQUEST_RESET_TT = 9,
+    /** */
+    USB_HUB_GET_TT_STATE = 10,
+    /** */
+    USB_HUB_STOP_TT = 11,
 } usb_hub_request_t;
 
@@ -218,5 +196,5 @@
  */
 /* 7 (basic size) + 2*32 (port bitmasks) */
-#define USB_HUB_MAX_DESCRIPTOR_SIZE 71
+#define USB_HUB_MAX_DESCRIPTOR_SIZE (7 + 2 * 32)
 
 #endif
Index: uspace/lib/usb/include/usb/classes/massstor.h
===================================================================
--- uspace/lib/usb/include/usb/classes/massstor.h	(revision 436300063cf897d3a8d003c018a42e184f48d928)
+++ uspace/lib/usb/include/usb/classes/massstor.h	(revision b4b534ac1d1515633baff0d563e9c16938bfe19f)
@@ -36,6 +36,4 @@
 #define LIBUSB_CLASS_MASSSTOR_H_
 
-#include <sys/types.h>
-
 /** USB mass storage subclasses. */
 typedef enum {
Index: uspace/lib/usb/include/usb/ddfiface.h
===================================================================
--- uspace/lib/usb/include/usb/ddfiface.h	(revision 436300063cf897d3a8d003c018a42e184f48d928)
+++ 	(revision )
@@ -1,55 +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 libusb
- * @{
- */
-/** @file
- * Implementations of DDF interfaces functions.
- */
-
-#ifndef LIBUSB_DDFIFACE_H_
-#define LIBUSB_DDFIFACE_H_
-
-#include <sys/types.h>
-#include <usb_iface.h>
-
-extern int usb_iface_get_hc_handle_device_impl(ddf_fun_t *, devman_handle_t *);
-extern int usb_iface_get_my_address_forward_impl(ddf_fun_t *, usb_address_t *);
-extern usb_iface_t usb_iface_hub_impl;
-
-extern int usb_iface_get_my_address_from_device_data(ddf_fun_t *, usb_address_t *);
-extern usb_iface_t usb_iface_hub_child_impl;
-
-extern int usb_iface_get_hc_handle_hc_impl(ddf_fun_t *, devman_handle_t *);
-
-#endif
-
-/**
- * @}
- */
Index: uspace/lib/usb/include/usb/debug.h
===================================================================
--- uspace/lib/usb/include/usb/debug.h	(revision 436300063cf897d3a8d003c018a42e184f48d928)
+++ uspace/lib/usb/include/usb/debug.h	(revision b4b534ac1d1515633baff0d563e9c16938bfe19f)
@@ -36,8 +36,7 @@
 #define LIBUSB_DEBUG_H_
 #include <stdio.h>
-#include <inttypes.h>
-#include <usb/usb.h>
+#include <sys/types.h>
 #include <io/log.h>
-#include <assert.h>
+
 
 void usb_dump_standard_descriptor(FILE *, const char *, const char *,
Index: uspace/lib/usb/include/usb/descriptor.h
===================================================================
--- uspace/lib/usb/include/usb/descriptor.h	(revision 436300063cf897d3a8d003c018a42e184f48d928)
+++ uspace/lib/usb/include/usb/descriptor.h	(revision b4b534ac1d1515633baff0d563e9c16938bfe19f)
@@ -36,5 +36,5 @@
 #define LIBUSB_DESCRIPTOR_H_
 
-#include <async.h>
+#include <sys/types.h>
 
 /** Descriptor type. */
@@ -45,4 +45,9 @@
 	USB_DESCTYPE_INTERFACE = 4,
 	USB_DESCTYPE_ENDPOINT = 5,
+	/* New in USB2.0 */
+	USB_DESCTYPE_DEVICE_QUALIFIER = 6,
+	USB_DESCTYPE_OTHER_SPEED_CONFIGURATION = 7,
+	USB_DESCTYPE_INTERFACE_POWER = 8,
+	/* Class specific */
 	USB_DESCTYPE_HID = 0x21,
 	USB_DESCTYPE_HID_REPORT = 0x22,
@@ -89,4 +94,32 @@
 } __attribute__ ((packed)) usb_standard_device_descriptor_t;
 
+/** USB device qualifier decriptor is basically a cut down version of the device
+ * descriptor with values that would be valid if the device operated on the
+ * other speed (HIGH vs. FULL)
+ */
+typedef struct {
+	/** Size of this descriptor in bytes */
+	uint8_t length;
+	/** Descriptor type (USB_DESCTYPE_DEVICE_QUALIFIER) */
+	uint8_t descriptor_type;
+	/** USB specification release number.
+	 * The number shall be coded as binary-coded decimal (BCD).
+	 */
+	uint16_t usb_spec_version;
+	/** Device class. */
+	uint8_t device_class;
+	/** Device sub-class. */
+	uint8_t device_subclass;
+	/** Device protocol. */
+	uint8_t device_protocol;
+	/** Maximum packet size for endpoint zero.
+	 * Valid values are only 8, 16, 32, 64).
+	 */
+	uint8_t max_packet_size;
+	/** Number of possible configurations. */
+	uint8_t configuration_count;
+	uint8_t reserved;
+} __attribute__ ((packed)) usb_standard_device_qualifier_descriptor_t;
+
 /** Standard USB configuration descriptor.
  */
@@ -116,4 +149,11 @@
 } __attribute__ ((packed)) usb_standard_configuration_descriptor_t;
 
+/** USB Other Speed Configuration descriptor shows values that would change
+ * in the configuration descriptor if the device operated at its other
+ * possible speed (HIGH vs. FULL)
+ */
+typedef usb_standard_configuration_descriptor_t
+    usb_other_speed_configuration_descriptor_t;
+
 /** Standard USB interface descriptor.
  */
@@ -157,6 +197,14 @@
 	 */
 	uint8_t attributes;
-	/** Maximum packet size. */
+	/** Maximum packet size.
+	 * Lower 10 bits represent the actuall size
+	 * Bits 11,12 specify addtional transfer opportunitities for
+	 * HS INT and ISO transfers. */
 	uint16_t max_packet_size;
+#define ED_MPS_PACKET_SIZE_MASK  0x3ff
+#define ED_MPS_PACKET_SIZE_GET(value) \
+	((value) & ED_MPS_PACKET_SIZE_MASK)
+#define ED_MPS_TRANS_OPPORTUNITIES_GET(value) \
+	((((value) >> 10) & 0x3) + 1)
 	/** Polling interval in milliseconds.
 	 * Ignored for bulk and control endpoints.
Index: uspace/lib/usb/include/usb/dev.h
===================================================================
--- uspace/lib/usb/include/usb/dev.h	(revision 436300063cf897d3a8d003c018a42e184f48d928)
+++ uspace/lib/usb/include/usb/dev.h	(revision b4b534ac1d1515633baff0d563e9c16938bfe19f)
@@ -36,27 +36,6 @@
 
 #include <devman.h>
-#include <usb/usb.h>
 
-int usb_get_info_by_handle(devman_handle_t,
-    devman_handle_t *, usb_address_t *, int *);
-
-static inline int usb_get_hc_by_handle(devman_handle_t dev, devman_handle_t *hc)
-{
-	return usb_get_info_by_handle(dev, hc, NULL, NULL);
-}
-
-static inline int usb_get_address_by_handle(
-    devman_handle_t dev, usb_address_t *address)
-{
-	return usb_get_info_by_handle(dev, NULL, address, NULL);
-}
-
-static inline int usb_get_iface_by_handle(devman_handle_t dev, int *iface)
-{
-	return usb_get_info_by_handle(dev, NULL, NULL, iface);
-}
-
-int usb_resolve_device_handle(const char *, devman_handle_t *, usb_address_t *,
-    devman_handle_t *);
+int usb_resolve_device_handle(const char *, devman_handle_t *);
 #endif
 /**
Index: uspace/lib/usb/include/usb/hc.h
===================================================================
--- uspace/lib/usb/include/usb/hc.h	(revision 436300063cf897d3a8d003c018a42e184f48d928)
+++ 	(revision )
@@ -1,120 +1,0 @@
-/*
- * Copyright (c) 2011 Vojtech Horky
- * 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 libusb
- * @{
- */
-/** @file
- * General communication with host controller.
- */
-#ifndef LIBUSB_HC_H_
-#define LIBUSB_HC_H_
-
-#include <async.h>
-#include <devman.h>
-#include <ddf/driver.h>
-#include <stdbool.h>
-#include <fibril_synch.h>
-#include <usb/usb.h>
-
-/** Connection to the host controller driver.
- *
- * This is a high level IPC communication wrapper. After the structure has been
- * initialized using devman handle of an USB host controller, it
- * will manage all communication to that host controller, including session
- * creation/destruction and proper IPC protocol.
- */
-typedef struct {
-	/** Devman handle of the host controller. */
-	devman_handle_t hc_handle;
-	/** Session to the host controller. */
-	async_sess_t *hc_sess;
-	/** Session guard. */
-	fibril_mutex_t guard;
-	/** Use counter. */
-	unsigned ref_count;
-} usb_hc_connection_t;
-
-/** Initialize connection to USB host controller.
- *
- * @param connection Connection to be initialized.
- * @param hc_handle Devman handle of the host controller.
- * @return Error code.
- */
-static inline void usb_hc_connection_initialize(usb_hc_connection_t *connection,
-    devman_handle_t hc_handle)
-{
-	assert(connection);
-	connection->hc_handle = hc_handle;
-	connection->hc_sess = NULL;
-	connection->ref_count = 0;
-	fibril_mutex_initialize(&connection->guard);
-}
-
-int usb_hc_connection_initialize_from_device(usb_hc_connection_t *, ddf_dev_t *);
-
-void usb_hc_connection_deinitialize(usb_hc_connection_t *);
-
-int usb_hc_connection_open(usb_hc_connection_t *);
-int usb_hc_connection_close(usb_hc_connection_t *);
-
-usb_address_t usb_hc_request_address(usb_hc_connection_t *, usb_address_t, bool,
-    usb_speed_t);
-int usb_hc_bind_address(usb_hc_connection_t *, usb_address_t, devman_handle_t);
-int usb_hc_get_handle_by_address(usb_hc_connection_t *, usb_address_t,
-    devman_handle_t *);
-int usb_hc_release_address(usb_hc_connection_t *, usb_address_t);
-
-int usb_hc_register_endpoint(usb_hc_connection_t *, usb_address_t,
-    usb_endpoint_t, usb_transfer_type_t, usb_direction_t, size_t, unsigned int);
-int usb_hc_unregister_endpoint(usb_hc_connection_t *, usb_address_t,
-    usb_endpoint_t, usb_direction_t);
-
-int usb_hc_read(usb_hc_connection_t *, usb_address_t, usb_endpoint_t,
-    uint64_t, void *, size_t, size_t *);
-int usb_hc_write(usb_hc_connection_t *, usb_address_t, usb_endpoint_t,
-    uint64_t, const void *, size_t);
-
-/** Get host controller handle by its class index.
- *
- * @param sid Service ID of the HC function.
- * @param hc_handle Where to store the HC handle
- *	(can be NULL for existence test only).
- * @return Error code.
- */
-static inline int usb_ddf_get_hc_handle_by_sid(
-    service_id_t sid, devman_handle_t *handle)
-{
-	devman_handle_t h;
-	return devman_fun_sid_to_handle(sid, handle ? handle : &h);
-}
-
-#endif
-/**
- * @}
- */
Index: uspace/lib/usb/include/usb/request.h
===================================================================
--- uspace/lib/usb/include/usb/request.h	(revision b4b534ac1d1515633baff0d563e9c16938bfe19f)
+++ uspace/lib/usb/include/usb/request.h	(revision b4b534ac1d1515633baff0d563e9c16938bfe19f)
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2012 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 libusb
+ * @{
+ */
+/** @file
+ * Standard USB request format.
+ */
+#ifndef LIBUSB_REQUEST_H_
+#define LIBUSB_REQUEST_H_
+
+#include <sys/types.h>
+
+/** Standard device request. */
+typedef enum {
+	USB_DEVREQ_GET_STATUS = 0,
+	USB_DEVREQ_CLEAR_FEATURE = 1,
+	USB_DEVREQ_SET_FEATURE = 3,
+	USB_DEVREQ_SET_ADDRESS = 5,
+	USB_DEVREQ_GET_DESCRIPTOR = 6,
+	USB_DEVREQ_SET_DESCRIPTOR = 7,
+	USB_DEVREQ_GET_CONFIGURATION = 8,
+	USB_DEVREQ_SET_CONFIGURATION = 9,
+	USB_DEVREQ_GET_INTERFACE = 10,
+	USB_DEVREQ_SET_INTERFACE = 11,
+	USB_DEVREQ_SYNCH_FRAME = 12,
+	USB_DEVREQ_LAST_STD
+} usb_stddevreq_t;
+
+/** Standard device features */
+typedef enum {
+	USB_FEATURE_ENDPOINT_HALT = 0,
+	USB_FEATURE_DEVICE_REMOTE_WAKEUP = 1,
+	USB_FEATURE_TEST_MODE = 2
+} usb_std_feature_t;
+
+/** USB device status - device is self powered (opposed to bus powered). */
+#define USB_DEVICE_STATUS_SELF_POWERED ((uint16_t)(1 << 0))
+
+/** USB device status - remote wake-up signaling is enabled. */
+#define USB_DEVICE_STATUS_REMOTE_WAKEUP ((uint16_t)(1 << 1))
+
+/** USB endpoint status - endpoint is halted (stalled). */
+#define USB_ENDPOINT_STATUS_HALTED ((uint16_t)(1 << 0))
+
+/** Device request setup packet.
+ * The setup packet describes the request.
+ */
+typedef struct {
+	/** Request type.
+	 * The type combines transfer direction, request type and
+	 * intended recipient.
+	 */
+	uint8_t request_type;
+#define SETUP_REQUEST_TYPE_DEVICE_TO_HOST (1 << 7)
+#define SETUP_REQUEST_TYPE_HOST_TO_DEVICE (0 << 7)
+#define SETUP_REQUEST_TYPE_GET_TYPE(rt) ((rt >> 5) & 0x3)
+#define SETUP_REQUEST_TYPE_GET_RECIPIENT(rec) (rec & 0x1f)
+#define SETUP_REQUEST_TO_HOST(type, recipient) \
+    (uint8_t)((1 << 7) | ((type & 0x3) << 5) | (recipient & 0x1f))
+#define SETUP_REQUEST_TO_DEVICE(type, recipient) \
+    (uint8_t)(((type & 0x3) << 5) | (recipient & 0x1f))
+
+	/** Request identification. */
+	uint8_t request;
+	/** Main parameter to the request. */
+	union __attribute__ ((packed)) {
+		uint16_t value;
+		/* FIXME: add #ifdefs according to host endianness */
+		struct __attribute__ ((packed)) {
+			uint8_t value_low;
+			uint8_t value_high;
+		};
+	};
+	/** Auxiliary parameter to the request.
+	 * Typically, it is offset to something.
+	 */
+	uint16_t index;
+	/** Length of extra data. */
+	uint16_t length;
+} __attribute__ ((packed)) usb_device_request_setup_packet_t;
+
+int assert[(sizeof(usb_device_request_setup_packet_t) == 8) ? 1: -1];
+
+int usb_request_needs_toggle_reset(
+    const usb_device_request_setup_packet_t *request);
+
+#endif
+/**
+ * @}
+ */
Index: uspace/lib/usb/include/usb/usb.h
===================================================================
--- uspace/lib/usb/include/usb/usb.h	(revision 436300063cf897d3a8d003c018a42e184f48d928)
+++ uspace/lib/usb/include/usb/usb.h	(revision b4b534ac1d1515633baff0d563e9c16938bfe19f)
@@ -84,4 +84,9 @@
 } usb_speed_t;
 
+static inline bool usb_speed_is_11(const usb_speed_t s)
+{
+	return (s == USB_SPEED_FULL) || (s == USB_SPEED_LOW);
+}
+
 const char *usb_str_speed(usb_speed_t);
 
@@ -110,5 +115,16 @@
 #define USB_ADDRESS_DEFAULT 0
 /** Maximum address number in USB 1.1. */
-#define USB11_ADDRESS_MAX 128
+#define USB11_ADDRESS_MAX 127
+#define USB_ADDRESS_COUNT (USB11_ADDRESS_MAX + 1)
+
+/** Check USB address for allowed values.
+ *
+ * @param ep USB address.
+ * @return True, if value is wihtin limits, false otherwise.
+ */
+static inline bool usb_address_is_valid(usb_address_t a)
+{
+	return (a >= USB_ADDRESS_DEFAULT) && (a <= USB11_ADDRESS_MAX);
+}
 
 /** USB endpoint number type.
@@ -117,7 +133,19 @@
 typedef int16_t usb_endpoint_t;
 
-/** Maximum endpoint number in USB 1.1.
- */
+/** Default control endpoint */
+#define USB_ENDPOINT_DEFAULT_CONTROL 0
+/** Maximum endpoint number in USB 1.1. */
 #define USB11_ENDPOINT_MAX 16
+
+/** Check USB endpoint for allowed values.
+ *
+ * @param ep USB endpoint number.
+ * @return True, if value is wihtin limits, false otherwise.
+ */
+static inline bool usb_endpoint_is_valid(usb_endpoint_t ep)
+{
+	return (ep >= USB_ENDPOINT_DEFAULT_CONTROL) &&
+	    (ep < USB11_ENDPOINT_MAX);
+}
 
 
@@ -133,4 +161,5 @@
 } usb_target_t;
 
+
 /** Check USB target for allowed values (address and endpoint).
  *
@@ -140,6 +169,6 @@
 static inline bool usb_target_is_valid(usb_target_t target)
 {
-	return !(target.endpoint > 15 || target.endpoint < 0
-	    || target.address >= USB11_ADDRESS_MAX || target.address < 0);
+	return usb_address_is_valid(target.address) &&
+	    usb_endpoint_is_valid(target.endpoint);
 }
 
Index: uspace/lib/usb/src/class.c
===================================================================
--- uspace/lib/usb/src/class.c	(revision 436300063cf897d3a8d003c018a42e184f48d928)
+++ uspace/lib/usb/src/class.c	(revision b4b534ac1d1515633baff0d563e9c16938bfe19f)
@@ -34,5 +34,4 @@
  */
 #include <usb/classes/classes.h>
-#include <errno.h>
 
 /** Tell string representation of USB class.
Index: uspace/lib/usb/src/ddfiface.c
===================================================================
--- uspace/lib/usb/src/ddfiface.c	(revision 436300063cf897d3a8d003c018a42e184f48d928)
+++ 	(revision )
@@ -1,127 +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 libusb
- * @{
- */
-/** @file
- * Implementations of DDF interfaces functions (actual implementation).
- */
-
-#include <devman.h>
-#include <async.h>
-#include <usb_iface.h>
-#include <usb/ddfiface.h>
-#include <usb/hc.h>
-#include <usb/debug.h>
-#include <usb/dev/hub.h>
-#include <errno.h>
-#include <assert.h>
-
-#include <usb/dev.h>
-
-/** DDF interface for USB device, implementation for typical hub. */
-usb_iface_t usb_iface_hub_impl = {
-	.get_hc_handle = usb_iface_get_hc_handle_device_impl,
-	.get_my_address = usb_iface_get_my_address_forward_impl,
-};
-
-/** DDF interface for USB device, implementation for child of a typical hub. */
-usb_iface_t usb_iface_hub_child_impl = {
-	.get_hc_handle = usb_iface_get_hc_handle_device_impl,
-	.get_my_address = usb_iface_get_my_address_from_device_data,
-};
-
-
-/** Get host controller handle, interface implementation for hub driver.
- *
- * @param[in] fun Device function the operation is running on.
- * @param[out] handle Storage for the host controller handle.
- * @return Error code.
- */
-int usb_iface_get_hc_handle_device_impl(ddf_fun_t *fun, devman_handle_t *handle)
-{
-	assert(fun);
-	return usb_get_hc_by_handle(ddf_fun_get_handle(fun), handle);
-}
-
-/** Get host controller handle, interface implementation for HC driver.
- *
- * @param[in] fun Device function the operation is running on.
- * @param[out] handle Storage for the host controller handle.
- * @return Always EOK.
- */
-int usb_iface_get_hc_handle_hc_impl(ddf_fun_t *fun, devman_handle_t *handle)
-{
-	assert(fun);
-
-	if (handle != NULL) {
-		*handle = ddf_fun_get_handle(fun);
-	}
-
-	return EOK;
-}
-
-/** Get USB device address, interface implementation for hub driver.
- *
- * @param[in] fun Device function the operation is running on.
- * @param[in] handle Devman handle of USB device we want address of.
- * @param[out] address Storage for USB address of device with handle @p handle.
- * @return Error code.
- */
-int usb_iface_get_my_address_forward_impl(ddf_fun_t *fun,
-    usb_address_t *address)
-{
-	assert(fun);
-	return usb_get_address_by_handle(ddf_fun_get_handle(fun), address);
-}
-
-/** Get USB device address, interface implementation for child of
- * a hub driver.
- *
- * This implementation eccepts 0 as valid handle and replaces it with fun's
- * handle.
- *
- * @param[in] fun Device function the operation is running on.
- * @param[in] handle Devman handle of USB device we want address of.
- * @param[out] address Storage for USB address of device with handle @p handle.
- * @return Error code.
- */
-int usb_iface_get_my_address_from_device_data(ddf_fun_t *fun,
-    usb_address_t *address)
-{
-	const usb_hub_attached_device_t *device = ddf_fun_data_get(fun);
-	assert(device->fun == fun);
-	if (address)
-		*address = device->address;
-	return EOK;
-}
-
-/**
- * @}
- */
Index: uspace/lib/usb/src/debug.c
===================================================================
--- uspace/lib/usb/src/debug.c	(revision 436300063cf897d3a8d003c018a42e184f48d928)
+++ uspace/lib/usb/src/debug.c	(revision b4b534ac1d1515633baff0d563e9c16938bfe19f)
@@ -33,9 +33,5 @@
  * Debugging and logging support.
  */
-#include <adt/list.h>
 #include <fibril_synch.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <stdio.h>
 #include <ddf/log.h>
 #include <usb/debug.h>
Index: uspace/lib/usb/src/dev.c
===================================================================
--- uspace/lib/usb/src/dev.c	(revision 436300063cf897d3a8d003c018a42e184f48d928)
+++ uspace/lib/usb/src/dev.c	(revision b4b534ac1d1515633baff0d563e9c16938bfe19f)
@@ -29,129 +29,8 @@
 
 #include <usb/dev.h>
-#include <usb/hc.h>
 #include <errno.h>
 #include <usb_iface.h>
 #include <str.h>
 #include <stdio.h>
-
-#define MAX_DEVICE_PATH 1024
-
-/** Find host controller handle, address and iface number for the device.
- *
- * @param[in] device_handle Device devman handle.
- * @param[out] hc_handle Where to store handle of host controller
- *	controlling device with @p device_handle handle.
- * @param[out] address Place to store the device's address
- * @param[out] iface Place to stoer the assigned USB interface number.
- * @return Error code.
- */
-int usb_get_info_by_handle(devman_handle_t device_handle,
-    devman_handle_t *hc_handle, usb_address_t *address, int *iface)
-{
-	async_sess_t *parent_sess =
-	    devman_parent_device_connect(device_handle, IPC_FLAG_BLOCKING);
-	if (!parent_sess)
-		return ENOMEM;
-
-	async_exch_t *exch = async_exchange_begin(parent_sess);
-	if (!exch) {
-		async_hangup(parent_sess);
-		return ENOMEM;
-	}
-
-	usb_address_t tmp_address;
-	devman_handle_t tmp_handle;
-	int tmp_iface;
-
-	if (address) {
-		const int ret = usb_get_my_address(exch, &tmp_address);
-		if (ret != EOK) {
-			async_exchange_end(exch);
-			async_hangup(parent_sess);
-			return ret;
-		}
-	}
-
-	if (hc_handle) {
-		const int ret = usb_get_hc_handle(exch, &tmp_handle);
-		if (ret != EOK) {
-			async_exchange_end(exch);
-			async_hangup(parent_sess);
-			return ret;
-		}
-	}
-
-	if (iface) {
-		const int ret = usb_get_my_interface(exch, &tmp_iface);
-		switch (ret) {
-		case ENOTSUP:
-			/* Implementing GET_MY_INTERFACE is voluntary. */
-			tmp_iface = -1;
-		case EOK:
-			break;
-		default:
-			async_exchange_end(exch);
-			async_hangup(parent_sess);
-			return ret;
-		}
-	}
-
-	if (hc_handle)
-		*hc_handle = tmp_handle;
-
-	if (address)
-		*address = tmp_address;
-
-	if (iface)
-		*iface = tmp_iface;
-
-	async_exchange_end(exch);
-	async_hangup(parent_sess);
-
-	return EOK;
-}
-
-static bool try_parse_bus_and_address(const char *path,
-    const char **func_start,
-    devman_handle_t *out_hc_handle, usb_address_t *out_device_address)
-{
-	uint64_t sid;
-	size_t address;
-	int rc;
-	const char *ptr;
-
-	rc = str_uint64_t(path, &ptr, 10, false, &sid);
-	if (rc != EOK) {
-		return false;
-	}
-	if ((*ptr == ':') || (*ptr == '.')) {
-		ptr++;
-	} else {
-		return false;
-	}
-	rc = str_size_t(ptr, func_start, 10, false, &address);
-	if (rc != EOK) {
-		return false;
-	}
-	rc = usb_ddf_get_hc_handle_by_sid(sid, out_hc_handle);
-	if (rc != EOK) {
-		return false;
-	}
-	if (out_device_address != NULL) {
-		*out_device_address = (usb_address_t) address;
-	}
-	return true;
-}
-
-static int get_device_handle_by_address(devman_handle_t hc_handle, int addr,
-    devman_handle_t *dev_handle)
-{
-	usb_hc_connection_t conn;
-	usb_hc_connection_initialize(&conn, hc_handle);
-
-	const int rc = usb_hc_get_handle_by_address(&conn, addr, dev_handle);
-
-	return rc;
-}
 
 /** Resolve handle and address of USB device from its path.
@@ -174,127 +53,19 @@
  * @return Error code.
  */
-int usb_resolve_device_handle(const char *dev_path, devman_handle_t *out_hc_handle,
-    usb_address_t *out_dev_addr, devman_handle_t *out_dev_handle)
+int usb_resolve_device_handle(const char *dev_path, devman_handle_t *dev_handle)
 {
-	if (dev_path == NULL) {
+	if (dev_path == NULL || dev_handle == NULL) {
 		return EBADMEM;
 	}
 
-	bool found_hc = false;
-	bool found_addr = false;
-	devman_handle_t hc_handle, dev_handle;
-	usb_address_t dev_addr = -1;
-	int rc;
-	bool is_bus_addr;
-	const char *func_start = NULL;
-	char *path = NULL;
+	/* First, try to get the device handle. */
+	int rc = devman_fun_get_handle(dev_path, dev_handle, 0);
 
-	/* First try the BUS.ADDR format. */
-	is_bus_addr = try_parse_bus_and_address(dev_path, &func_start,
-	    &hc_handle, &dev_addr);
-	if (is_bus_addr) {
-		found_hc = true;
-		found_addr = true;
-		/*
-		 * Now get the handle of the device. We will need that
-		 * in both cases. If there is only BUS.ADDR, it will
-		 * be the handle to be returned to the caller, otherwise
-		 * we will need it to resolve the path to which the
-		 * suffix would be appended.
-		 */
-		/* If there is nothing behind the BUS.ADDR, we will
-		 * get the device handle from the host controller.
-		 * Otherwise, we will
-		 */
-		rc = get_device_handle_by_address(hc_handle, dev_addr,
-		    &dev_handle);
-		if (rc != EOK) {
-			return rc;
-		}
-		if (str_length(func_start) > 0) {
-			char tmp_path[MAX_DEVICE_PATH];
-			rc = devman_fun_get_path(dev_handle,
-			    tmp_path, MAX_DEVICE_PATH);
-			if (rc != EOK) {
-				return rc;
-			}
-			rc = asprintf(&path, "%s%s", tmp_path, func_start);
-			if (rc < 0) {
-				return ENOMEM;
-			}
-		} else {
-			/* Everything is resolved. Get out of here. */
-			goto copy_out;
-		}
-	} else {
-		path = str_dup(dev_path);
-		if (path == NULL) {
-			return ENOMEM;
-		}
+	/* Next, try parsing dev_handle from the provided string */
+	if (rc != EOK) {
+		*dev_handle = strtoul(dev_path, NULL, 10);
+		//FIXME: check errno
+		rc = EOK;
 	}
-
-	/* First try to get the device handle. */
-	rc = devman_fun_get_handle(path, &dev_handle, 0);
-	if (rc != EOK) {
-		free(path);
-		/* Invalid path altogether. */
-		return rc;
-	}
-
-	/* Remove suffixes and hope that we will encounter device node. */
-	while (str_length(path) > 0) {
-		/* Get device handle first. */
-		devman_handle_t tmp_handle;
-		rc = devman_fun_get_handle(path, &tmp_handle, 0);
-		if (rc != EOK) {
-			free(path);
-			return rc;
-		}
-
-		/* Try to find its host controller. */
-		if (!found_hc) {
-			rc = usb_get_hc_by_handle(tmp_handle, &hc_handle);
-			if (rc == EOK) {
-				found_hc = true;
-			}
-		}
-
-		/* Try to get its address. */
-		if (!found_addr) {
-			rc = usb_get_address_by_handle(tmp_handle, &dev_addr);
-			if (rc == 0) {
-				found_addr = true;
-			}
-		}
-
-		/* Speed-up. */
-		if (found_hc && found_addr) {
-			break;
-		}
-
-		/* Remove the last suffix. */
-		char *slash_pos = str_rchr(path, '/');
-		if (slash_pos != NULL) {
-			*slash_pos = 0;
-		}
-	}
-
-	free(path);
-
-	if (!found_addr || !found_hc) {
-		return ENOENT;
-	}
-
-copy_out:
-	if (out_dev_addr != NULL) {
-		*out_dev_addr = dev_addr;
-	}
-	if (out_hc_handle != NULL) {
-		*out_hc_handle = hc_handle;
-	}
-	if (out_dev_handle != NULL) {
-		*out_dev_handle = dev_handle;
-	}
-
-	return EOK;
+	return rc;
 }
Index: uspace/lib/usb/src/dump.c
===================================================================
--- uspace/lib/usb/src/dump.c	(revision 436300063cf897d3a8d003c018a42e184f48d928)
+++ uspace/lib/usb/src/dump.c	(revision b4b534ac1d1515633baff0d563e9c16938bfe19f)
@@ -33,7 +33,4 @@
  * Descriptor dumping.
  */
-#include <adt/list.h>
-#include <fibril_synch.h>
-#include <errno.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -41,4 +38,6 @@
 #include <usb/descriptor.h>
 #include <usb/classes/classes.h>
+#include <usb/classes/hub.h>
+#include <usb/usb.h>
 
 /** Mapping between descriptor id and dumping function. */
@@ -276,5 +275,53 @@
     const uint8_t *descriptor, size_t descriptor_length)
 {
-	/* TODO */
+	usb_hub_descriptor_header_t *d =
+	    (usb_hub_descriptor_header_t *) descriptor;
+	if (descriptor_length < sizeof(d))
+		return;
+
+	PRINTLINE("bDescLength: = %d", d->length);
+	PRINTLINE("bDescriptorType = 0x%02x", d->descriptor_type);
+	PRINTLINE("bNbrPorts = %d", d->port_count);
+	PRINTLINE("bHubCharacteristics = 0x%02x%02x (%s;%s%s)",
+	    d->characteristics_reserved, d->characteristics,
+	    (d->characteristics & HUB_CHAR_NO_POWER_SWITCH_FLAG) ?
+	        "No Power Switching" :
+		((d->characteristics & HUB_CHAR_POWER_PER_PORT_FLAG) ?
+		    "Per-Port Switching" : "Ganged Power Switching"),
+	    (d->characteristics & HUB_CHAR_COMPOUND_DEVICE) ?
+	        "Compound Device;" : "",
+	    (d->characteristics & HUB_CHAR_NO_OC_FLAG) ?
+	        "No OC Protection" :
+		    ((d->characteristics & HUB_CHAR_OC_PER_PORT_FLAG) ?
+		        "Individual Port OC Protection" :
+	                    "Global OC Protection")
+	);
+	PRINTLINE("bPwrOn2PwrGood = %d (%d ms)",
+	    d->power_good_time, d->power_good_time * 2);
+	PRINTLINE("bHubContrCurrent = %d (%d mA)",
+	    d->max_current, d->max_current);
+	const size_t port_bytes = (descriptor_length - sizeof(*d)) / 2;
+	const uint8_t *removable_mask = descriptor + sizeof(*d);
+	const uint8_t *powered_mask = descriptor + sizeof(*d) + port_bytes;
+
+	if (port_bytes == 0
+	    || port_bytes > (((d->port_count / (unsigned)8) + 1) * 2)) {
+		PRINTLINE("::CORRUPTED DESCRIPTOR:: (%zu bytes remain)",
+		    port_bytes * 2);
+	}
+
+	fprintf(output, "%sDeviceRemovable = 0x",
+	    line_prefix ? line_prefix : " - ");
+	for (unsigned i = port_bytes; i > 0; --i)
+		fprintf(output, "%02x", removable_mask[i - 1]);
+	fprintf(output, " (0b1 - Device non-removable)%s",
+	    line_suffix ? line_suffix : "\n");
+
+	fprintf(output, "%sPortPwrCtrlMask = 0x",
+	    line_prefix ? line_prefix : " - ");
+	for (unsigned i = port_bytes; i > 0; --i)
+		fprintf(output, "%02x", powered_mask[i - 1]);
+	fprintf(output, " (Legacy - All should be 0b1)%s",
+	    line_suffix ? line_suffix : "\n");
 }
 
Index: uspace/lib/usb/src/hc.c
===================================================================
--- uspace/lib/usb/src/hc.c	(revision 436300063cf897d3a8d003c018a42e184f48d928)
+++ 	(revision )
@@ -1,285 +1,0 @@
-/*
- * Copyright (c) 2011 Vojtech Horky
- * 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 libusb
- * @{
- */
-/** @file
- * General communication with host controller driver (implementation).
- */
-
-#include <usb/debug.h>
-
-#include <assert.h>
-#include <errno.h>
-#include <usbhc_iface.h>
-#include <usb/dev.h>
-#include <usb/hc.h>
-
-static int usb_hc_connection_add_ref(usb_hc_connection_t *connection)
-{
-	assert(connection);
-	
-	fibril_mutex_lock(&connection->guard);
-	if (connection->ref_count == 0) {
-		assert(connection->hc_sess == NULL);
-		/* Parallel exchange for us */
-		connection->hc_sess = devman_device_connect(connection->hc_handle, 0);
-		if (!connection->hc_sess) {
-			fibril_mutex_unlock(&connection->guard);
-			return ENOMEM;
-		}
-	}
-	
-	++connection->ref_count;
-	fibril_mutex_unlock(&connection->guard);
-	return EOK;
-}
-
-static int usb_hc_connection_del_ref(usb_hc_connection_t *connection)
-{
-	assert(connection);
-	
-	fibril_mutex_lock(&connection->guard);
-	if (connection->ref_count == 0) {
-		/* Closing already closed connection... */
-		assert(connection->hc_sess == NULL);
-		fibril_mutex_unlock(&connection->guard);
-		return EOK;
-	}
-	
-	--connection->ref_count;
-	int ret = EOK;
-	if (connection->ref_count == 0) {
-		assert(connection->hc_sess);
-		ret = async_hangup(connection->hc_sess);
-		connection->hc_sess = NULL;
-	}
-	fibril_mutex_unlock(&connection->guard);
-	return ret;
-}
-
-#define EXCH_INIT(connection, exch) \
-do { \
-	exch = NULL; \
-	if (!connection) \
-		return EBADMEM; \
-	const int ret = usb_hc_connection_add_ref(connection); \
-	if (ret != EOK) \
-		return ret; \
-	exch = async_exchange_begin(connection->hc_sess); \
-	if (exch == NULL) { \
-		usb_hc_connection_del_ref(connection); \
-		return ENOMEM; \
-	} \
-} while (0)
-
-#define EXCH_FINI(connection, exch) \
-if (exch) { \
-	async_exchange_end(exch); \
-	usb_hc_connection_del_ref(connection); \
-} else (void)0
-
-/** Initialize connection to USB host controller.
- *
- * @param connection Connection to be initialized.
- * @param device Device connecting to the host controller.
- * @return Error code.
- */
-int usb_hc_connection_initialize_from_device(usb_hc_connection_t *connection,
-    ddf_dev_t *device)
-{
-	if (device == NULL)
-		return EBADMEM;
-
-	devman_handle_t hc_handle;
-	const int rc = usb_get_hc_by_handle(ddf_dev_get_handle(device), &hc_handle);
-	if (rc == EOK) {
-		usb_hc_connection_initialize(connection, hc_handle);
-	}
-
-	return rc;
-}
-
-void usb_hc_connection_deinitialize(usb_hc_connection_t *connection)
-{
-	assert(connection);
-	fibril_mutex_lock(&connection->guard);
-	if (connection->ref_count != 0) {
-		usb_log_warning("%u stale reference(s) to HC connection.\n",
-		    connection->ref_count);
-		assert(connection->hc_sess);
-		async_hangup(connection->hc_sess);
-		connection->hc_sess = NULL;
-		connection->ref_count = 0;
-	}
-	fibril_mutex_unlock(&connection->guard);
-}
-
-/** Open connection to host controller.
- *
- * @param connection Connection to the host controller.
- * @return Error code.
- */
-int usb_hc_connection_open(usb_hc_connection_t *connection)
-{
-	return usb_hc_connection_add_ref(connection);
-}
-
-/** Close connection to the host controller.
- *
- * @param connection Connection to the host controller.
- * @return Error code.
- */
-int usb_hc_connection_close(usb_hc_connection_t *connection)
-{
-	return usb_hc_connection_del_ref(connection);
-}
-
-/** Ask host controller for free address assignment.
- *
- * @param connection Opened connection to host controller.
- * @param preferred Preferred SUB address.
- * @param strict Fail if the preferred address is not avialable.
- * @param speed Speed of the new device (device that will be assigned
- *    the returned address).
- * @return Assigned USB address or negative error code.
- */
-usb_address_t usb_hc_request_address(usb_hc_connection_t *connection,
-    usb_address_t preferred, bool strict, usb_speed_t speed)
-{
-	async_exch_t *exch;
-	EXCH_INIT(connection, exch);
-
-	usb_address_t address = preferred;
-	const int ret = usbhc_request_address(exch, &address, strict, speed);
-
-	EXCH_FINI(connection, exch);
-	return ret == EOK ? address : ret;
-}
-
-int usb_hc_bind_address(usb_hc_connection_t * connection,
-    usb_address_t address, devman_handle_t handle)
-{
-	async_exch_t *exch;
-	EXCH_INIT(connection, exch);
-
-	const int ret = usbhc_bind_address(exch, address, handle);
-
-	EXCH_FINI(connection, exch);
-	return ret;
-}
-
-/** Get handle of USB device with given address.
- *
- * @param[in] connection Opened connection to host controller.
- * @param[in] address Address of device in question.
- * @param[out] handle Where to write the device handle.
- * @return Error code.
- */
-int usb_hc_get_handle_by_address(usb_hc_connection_t *connection,
-    usb_address_t address, devman_handle_t *handle)
-{
-	async_exch_t *exch;
-	EXCH_INIT(connection, exch);
-
-	const int ret = usbhc_get_handle(exch, address, handle);
-
-	EXCH_FINI(connection, exch);
-	return ret;
-}
-
-int usb_hc_release_address(usb_hc_connection_t *connection,
-    usb_address_t address)
-{
-	async_exch_t *exch;
-	EXCH_INIT(connection, exch);
-
-	const int ret = usbhc_release_address(exch, address);
-
-	EXCH_FINI(connection, exch);
-	return ret;
-}
-
-int usb_hc_register_endpoint(usb_hc_connection_t *connection,
-    usb_address_t address, usb_endpoint_t endpoint, usb_transfer_type_t type,
-    usb_direction_t direction, size_t packet_size, unsigned interval)
-{
-	async_exch_t *exch;
-	EXCH_INIT(connection, exch);
-
-	const int ret = usbhc_register_endpoint(exch, address, endpoint,
-	    type, direction, packet_size, interval);
-
-	EXCH_FINI(connection, exch);
-	return ret;
-}
-
-int usb_hc_unregister_endpoint(usb_hc_connection_t *connection,
-    usb_address_t address, usb_endpoint_t endpoint, usb_direction_t direction)
-{
-	async_exch_t *exch;
-	EXCH_INIT(connection, exch);
-
-	const int ret =
-	    usbhc_unregister_endpoint(exch, address, endpoint, direction);
-
-	EXCH_FINI(connection, exch);
-	return ret;
-}
-
-int usb_hc_read(usb_hc_connection_t *connection, usb_address_t address,
-    usb_endpoint_t endpoint, uint64_t setup, void *data, size_t size,
-    size_t *real_size)
-{
-	async_exch_t *exch;
-	EXCH_INIT(connection, exch);
-
-	const int ret =
-	    usbhc_read(exch, address, endpoint, setup, data, size, real_size);
-
-	EXCH_FINI(connection, exch);
-	return ret;
-}
-
-int usb_hc_write(usb_hc_connection_t *connection, usb_address_t address,
-    usb_endpoint_t endpoint, uint64_t setup, const void *data, size_t size)
-{
-	async_exch_t *exch;
-	EXCH_INIT(connection, exch);
-
-	const int ret = usbhc_write(exch, address, endpoint, setup, data, size);
-
-	EXCH_FINI(connection, exch);
-	return ret;
-}
-
-/**
- * @}
- */
Index: uspace/lib/usb/src/usb.c
===================================================================
--- uspace/lib/usb/src/usb.c	(revision 436300063cf897d3a8d003c018a42e184f48d928)
+++ uspace/lib/usb/src/usb.c	(revision b4b534ac1d1515633baff0d563e9c16938bfe19f)
@@ -34,7 +34,9 @@
  */
 #include <usb/usb.h>
-#include <errno.h>
+#include <usb/request.h>
 
-#define ARR_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))
+#include <assert.h>
+#include <byteorder.h>
+#include <macros.h>
 
 static const char *str_speed[] = {
@@ -71,5 +73,5 @@
 const char *usb_str_transfer_type(usb_transfer_type_t t)
 {
-	if (t >= ARR_SIZE(str_transfer_type)) {
+	if (t >= ARRAY_SIZE(str_transfer_type)) {
 		return "invalid";
 	}
@@ -84,5 +86,5 @@
 const char *usb_str_transfer_type_short(usb_transfer_type_t t)
 {
-	if (t >= ARR_SIZE(str_transfer_type_short)) {
+	if (t >= ARRAY_SIZE(str_transfer_type_short)) {
 		return "invl";
 	}
@@ -97,5 +99,5 @@
 const char *usb_str_direction(usb_direction_t d)
 {
-	if (d >= ARR_SIZE(str_direction)) {
+	if (d >= ARRAY_SIZE(str_direction)) {
 		return "invalid";
 	}
@@ -110,5 +112,5 @@
 const char *usb_str_speed(usb_speed_t s)
 {
-	if (s >= ARR_SIZE(str_speed)) {
+	if (s >= ARRAY_SIZE(str_speed)) {
 		return "invalid";
 	}
@@ -116,4 +118,40 @@
 }
 
+/** Check setup packet data for signs of toggle reset.
+ *
+ * @param[in] requst Setup requst data.
+ * @retval -1 No endpoints need reset.
+ * @retval 0 All endpoints need reset.
+ * @retval >0 Specified endpoint needs reset.
+ */
+int usb_request_needs_toggle_reset(
+    const usb_device_request_setup_packet_t *request)
+{
+	assert(request);
+	switch (request->request)
+	{
+	/* Clear Feature ENPOINT_STALL */
+	case USB_DEVREQ_CLEAR_FEATURE: /*resets only cleared ep */
+		/* 0x2 ( HOST to device | STANDART | TO ENPOINT) */
+		if ((request->request_type == 0x2) &&
+		    (request->value == USB_FEATURE_ENDPOINT_HALT))
+			return uint16_usb2host(request->index);
+		break;
+	case USB_DEVREQ_SET_CONFIGURATION:
+	case USB_DEVREQ_SET_INTERFACE:
+		/* Recipient must be device, this resets all endpoints,
+		 * In fact there should be no endpoints but EP 0 registered
+		 * as different interfaces use different endpoints,
+		 * unless you're changing configuration or alternative
+		 * interface of an already setup device. */
+		if (!(request->request_type & SETUP_REQUEST_TYPE_DEVICE_TO_HOST))
+			return 0;
+		break;
+	default:
+		break;
+	}
+	return -1;
+}
+
 /**
  * @}
