Index: uspace/app/usbinfo/info.c
===================================================================
--- uspace/app/usbinfo/info.c	(revision e0df6c2d7a704b8e474264f04947e3eadfc936c2)
+++ uspace/app/usbinfo/info.c	(revision 67b6fc5853a7bb19dd26cf0e0035db90c42d1bfe)
@@ -39,4 +39,5 @@
 #include <usb/usbdrv.h>
 #include <usb/pipes.h>
+#include <usb/recognise.h>
 #include <usb/request.h>
 #include "usbinfo.h"
@@ -47,27 +48,4 @@
 	usb_device_connection_t wire;
 	usb_endpoint_pipe_t ctrl_pipe;
-	ctrl_pipe.hc_phone = -1;
-
-	int hc_phone = devman_device_connect(hc_handle, 0);
-	if (hc_phone < 0) {
-		fprintf(stderr,
-		    NAME ": failed to connect to host controller (%zu): %s.\n",
-		        (size_t) hc_handle, str_error(hc_phone));
-		return hc_phone;
-	}
-
-	/*
-	 * Dump information about possible match ids.
-	 */
-	match_id_list_t match_id_list;
-	init_match_ids(&match_id_list);
-	rc = usb_drv_create_device_match_ids(hc_phone, &match_id_list, address);
-	if (rc != EOK) {
-		fprintf(stderr,
-		    NAME ": failed to fetch match ids of the device: %s.\n",
-		    str_error(rc));
-		goto leave;
-	}
-	dump_match_ids(&match_id_list);
 
 	/*
@@ -95,4 +73,18 @@
 		goto leave;
 	}
+
+	/*
+	 * Dump information about possible match ids.
+	 */
+	match_id_list_t match_id_list;
+	init_match_ids(&match_id_list);
+	rc = usb_device_create_match_ids(&ctrl_pipe, &match_id_list);
+	if (rc != EOK) {
+		fprintf(stderr,
+		    NAME ": failed to fetch match ids of the device: %s.\n",
+		    str_error(rc));
+		goto leave;
+	}
+	dump_match_ids(&match_id_list);
 
 	/*
@@ -141,5 +133,4 @@
 leave:
 	/* Ignoring errors here. */
-	async_hangup(hc_phone);
 	usb_endpoint_pipe_end_session(&ctrl_pipe);
 
Index: uspace/drv/uhci-hcd/uhci.h
===================================================================
--- uspace/drv/uhci-hcd/uhci.h	(revision e0df6c2d7a704b8e474264f04947e3eadfc936c2)
+++ uspace/drv/uhci-hcd/uhci.h	(revision 67b6fc5853a7bb19dd26cf0e0035db90c42d1bfe)
@@ -72,5 +72,5 @@
 
 #define UHCI_FRAME_LIST_COUNT 1024
-#define UHCI_CLEANER_TIMEOUT 1000000
+#define UHCI_CLEANER_TIMEOUT 10000
 #define UHCI_DEBUGER_TIMEOUT 5000000
 
Index: uspace/drv/uhci-rhd/port.c
===================================================================
--- uspace/drv/uhci-rhd/port.c	(revision e0df6c2d7a704b8e474264f04947e3eadfc936c2)
+++ uspace/drv/uhci-rhd/port.c	(revision 67b6fc5853a7bb19dd26cf0e0035db90c42d1bfe)
@@ -33,8 +33,10 @@
  */
 #include <errno.h>
+#include <str_error.h>
 
 #include <usb/usb.h>    /* usb_address_t */
 #include <usb/usbdrv.h> /* usb_drv_*     */
 #include <usb/debug.h>
+#include <usb/recognise.h>
 
 #include "port.h"
@@ -204,7 +206,15 @@
 	assert(port->attached_device == 0);
 
-	ret = usb_drv_register_child_in_devman(port->hc_phone, port->rh,
-	  usb_address, &port->attached_device);
-
+	devman_handle_t hc_handle;
+	ret = usb_drv_find_hc(port->rh, &hc_handle);
+	if (ret != EOK) {
+		usb_log_error("Failed to get handle of host controller: %s.\n",
+		    str_error(ret));
+		uhci_port_set_enabled(port, false);
+		return ENOMEM;
+	}
+
+	ret = usb_device_register_child_in_devman(usb_address, hc_handle,
+	    port->rh, &port->attached_device);
 	if (ret != EOK) { /* something went wrong */
 		usb_log_error("Failed(%d) in usb_drv_register_child.\n", ret);
Index: uspace/drv/usbhid/main.c
===================================================================
--- uspace/drv/usbhid/main.c	(revision e0df6c2d7a704b8e474264f04947e3eadfc936c2)
+++ uspace/drv/usbhid/main.c	(revision 67b6fc5853a7bb19dd26cf0e0035db90c42d1bfe)
@@ -45,4 +45,6 @@
 #include <str_error.h>
 #include <fibril.h>
+#include <usb/debug.h>
+#include <usb/classes/classes.h>
 #include <usb/classes/hid.h>
 #include <usb/classes/hidparser.h>
@@ -61,4 +63,14 @@
 #define GUESSED_POLL_ENDPOINT 1
 
+/** Keyboard polling endpoint description for boot protocol class. */
+static usb_endpoint_description_t poll_endpoint_description = {
+	.transfer_type = USB_TRANSFER_INTERRUPT,
+	.direction = USB_DIRECTION_IN,
+	.interface_class = USB_CLASS_HID,
+	.interface_subclass = USB_HID_SUBCLASS_BOOT,
+	.interface_protocol = USB_HID_PROTOCOL_KEYBOARD,
+	.flags = 0
+};
+
 static void default_connection_handler(device_t *, ipc_callid_t, ipc_call_t *);
 static device_ops_t keyboard_ops = {
@@ -330,4 +342,31 @@
 	}
 	
+	/*
+	 * Initialize the interrupt in endpoint.
+	 */
+	usb_endpoint_mapping_t endpoint_mapping[1] = {
+		{
+			.pipe = &kbd_dev->poll_pipe,
+			.description = &poll_endpoint_description
+		}
+	};
+	rc = usb_endpoint_pipe_initialize_from_configuration(
+	    endpoint_mapping, 1,
+	    descriptors, config_desc.total_length,
+	    &kbd_dev->wire);
+	if (rc != EOK) {
+		usb_log_error("Failed to initialize poll pipe: %s.\n",
+		    str_error(rc));
+		return rc;
+	}
+	if (!endpoint_mapping[0].present) {
+		usb_log_warning("Not accepting device, " \
+		    "not boot-protocol keyboard.\n");
+		return EREFUSED;
+	}
+
+
+
+
 	kbd_dev->conf = (usb_hid_configuration_t *)calloc(1, 
 	    sizeof(usb_hid_configuration_t));
@@ -337,5 +376,5 @@
 	}
 	
-	rc = usbkbd_parse_descriptors(descriptors, transferred, kbd_dev->conf);
+	/*rc = usbkbd_parse_descriptors(descriptors, transferred, kbd_dev->conf);
 	free(descriptors);
 	if (rc != EOK) {
@@ -344,5 +383,5 @@
 	}
 
-	// get and report descriptors
+	// get and report descriptors*/
 	rc = usbkbd_get_report_descriptor(kbd_dev);
 	if (rc != EOK) {
@@ -361,5 +400,5 @@
      *    as the endpoint for polling
 	 */
-	
+
 	return EOK;
 }
@@ -396,12 +435,4 @@
 	if (rc != EOK) {
 		printf("Failed to initialize default control pipe: %s.\n",
-		    str_error(rc));
-		goto error_leave;
-	}
-
-	rc = usb_endpoint_pipe_initialize(&kbd_dev->poll_pipe, &kbd_dev->wire,
-	    GUESSED_POLL_ENDPOINT, USB_TRANSFER_INTERRUPT, USB_DIRECTION_IN);
-	if (rc != EOK) {
-		printf("Failed to initialize interrupt in pipe: %s.\n",
 		    str_error(rc));
 		goto error_leave;
@@ -418,6 +449,9 @@
 	usb_endpoint_pipe_start_session(&kbd_dev->ctrl_pipe);
 	//usb_request_set_configuration(&kbd_dev->ctrl_pipe, 1);
-	usbkbd_process_descriptors(kbd_dev);
+	rc = usbkbd_process_descriptors(kbd_dev);
 	usb_endpoint_pipe_end_session(&kbd_dev->ctrl_pipe);
+	if (rc != EOK) {
+		goto error_leave;
+	}
 
 	return kbd_dev;
@@ -577,4 +611,5 @@
 int main(int argc, char *argv[])
 {
+	usb_log_enable(USB_LOG_LEVEL_INFO, "usbhid");
 	return driver_main(&kbd_driver);
 }
Index: uspace/drv/usbhub/usbhub.c
===================================================================
--- uspace/drv/usbhub/usbhub.c	(revision e0df6c2d7a704b8e474264f04947e3eadfc936c2)
+++ uspace/drv/usbhub/usbhub.c	(revision 67b6fc5853a7bb19dd26cf0e0035db90c42d1bfe)
@@ -36,8 +36,10 @@
 #include <bool.h>
 #include <errno.h>
+#include <str_error.h>
 
 #include <usb_iface.h>
 #include <usb/usbdrv.h>
 #include <usb/descriptor.h>
+#include <usb/recognise.h>
 #include <usb/devreq.h>
 #include <usb/classes/hub.h>
@@ -317,7 +319,15 @@
 	}
 
+	devman_handle_t hc_handle;
+	opResult = usb_drv_find_hc(hub->device, &hc_handle);
+	if (opResult != EOK) {
+		usb_log_error("Failed to get handle of host controller: %s.\n",
+		    str_error(opResult));
+		return;
+	}
+
 	devman_handle_t child_handle;
-	opResult = usb_drv_register_child_in_devman(hc, hub->device,
-            new_device_address, &child_handle);
+        opResult = usb_device_register_child_in_devman(new_device_address,
+            hc_handle, hub->device, &child_handle);
 	if (opResult != EOK) {
 		dprintf(USB_LOG_LEVEL_ERROR, "could not start driver for new device");
Index: uspace/drv/vhc/hub.c
===================================================================
--- uspace/drv/vhc/hub.c	(revision e0df6c2d7a704b8e474264f04947e3eadfc936c2)
+++ uspace/drv/vhc/hub.c	(revision 67b6fc5853a7bb19dd26cf0e0035db90c42d1bfe)
@@ -41,4 +41,5 @@
 #include <driver.h>
 #include <usb/usbdrv.h>
+#include <usb/recognise.h>
 
 #include "hub.h"
@@ -93,5 +94,7 @@
 
 	devman_handle_t hub_handle;
-	usb_drv_register_child_in_devman(hc, hc_dev, hub_address, &hub_handle);
+	usb_device_register_child_in_devman(hub_address, hc_dev->handle,
+	    hc_dev, &hub_handle);
+	//usb_drv_register_child_in_devman(hc, hc_dev, hub_address, &hub_handle);
 	usb_drv_bind_address(hc, hub_address, hub_handle);
 
Index: uspace/lib/usb/Makefile
===================================================================
--- uspace/lib/usb/Makefile	(revision e0df6c2d7a704b8e474264f04947e3eadfc936c2)
+++ uspace/lib/usb/Makefile	(revision 67b6fc5853a7bb19dd26cf0e0035db90c42d1bfe)
@@ -44,4 +44,5 @@
 	src/localdrv.c \
 	src/pipes.c \
+	src/pipesinit.c \
 	src/recognise.c \
 	src/remotedrv.c \
Index: uspace/lib/usb/include/usb/classes/hid.h
===================================================================
--- uspace/lib/usb/include/usb/classes/hid.h	(revision e0df6c2d7a704b8e474264f04947e3eadfc936c2)
+++ uspace/lib/usb/include/usb/classes/hid.h	(revision 67b6fc5853a7bb19dd26cf0e0035db90c42d1bfe)
@@ -50,4 +50,10 @@
 	USB_HIDREQ_SET_PROTOCOL = 11
 } usb_hid_request_t;
+
+/** USB/HID subclass constants. */
+typedef enum {
+	USB_HID_SUBCLASS_NONE = 0,
+	USB_HID_SUBCLASS_BOOT = 1
+} usb_hid_subclass_t;
 
 /** USB/HID interface protocols. */
Index: uspace/lib/usb/include/usb/pipes.h
===================================================================
--- uspace/lib/usb/include/usb/pipes.h	(revision e0df6c2d7a704b8e474264f04947e3eadfc936c2)
+++ uspace/lib/usb/include/usb/pipes.h	(revision 67b6fc5853a7bb19dd26cf0e0035db90c42d1bfe)
@@ -38,4 +38,5 @@
 #include <sys/types.h>
 #include <usb/usb.h>
+#include <usb/descriptor.h>
 #include <ipc/devman.h>
 #include <driver.h>
@@ -73,4 +74,7 @@
 	usb_direction_t direction;
 
+	/** Maximum packet size for the endpoint. */
+	size_t max_packet_size;
+
 	/** Phone to the host controller.
 	 * Negative when no session is active.
@@ -79,4 +83,34 @@
 } usb_endpoint_pipe_t;
 
+
+/** Description of endpoint characteristics. */
+typedef struct {
+	/** Transfer type (e.g. control or interrupt). */
+	usb_transfer_type_t transfer_type;
+	/** Transfer direction (to or from a device). */
+	usb_direction_t direction;
+	/** Interface class this endpoint belongs to (-1 for any). */
+	int interface_class;
+	/** Interface subclass this endpoint belongs to (-1 for any). */
+	int interface_subclass;
+	/** Interface protocol this endpoint belongs to (-1 for any). */
+	int interface_protocol;
+	/** Extra endpoint flags. */
+	unsigned int flags;
+} usb_endpoint_description_t;
+
+/** Mapping of endpoint pipes and endpoint descriptions. */
+typedef struct {
+	/** Endpoint pipe. */
+	usb_endpoint_pipe_t *pipe;
+	/** Endpoint description. */
+	const usb_endpoint_description_t *description;
+	/** Found descriptor fitting the description. */
+	usb_standard_endpoint_descriptor_t *descriptor;
+	/** Interface the endpoint belongs to. */
+	usb_standard_interface_descriptor_t *interface;
+	/** Whether the endpoint was actually found. */
+	bool present;
+} usb_endpoint_mapping_t;
 
 int usb_device_connection_initialize_from_device(usb_device_connection_t *,
@@ -87,7 +121,9 @@
 int usb_endpoint_pipe_initialize(usb_endpoint_pipe_t *,
     usb_device_connection_t *,
-    usb_endpoint_t, usb_transfer_type_t, usb_direction_t);
+    usb_endpoint_t, usb_transfer_type_t, size_t, usb_direction_t);
 int usb_endpoint_pipe_initialize_default_control(usb_endpoint_pipe_t *,
     usb_device_connection_t *);
+int usb_endpoint_pipe_initialize_from_configuration(usb_endpoint_mapping_t *,
+    size_t, uint8_t *, size_t, usb_device_connection_t *);
 
 
Index: uspace/lib/usb/include/usb/recognise.h
===================================================================
--- uspace/lib/usb/include/usb/recognise.h	(revision 67b6fc5853a7bb19dd26cf0e0035db90c42d1bfe)
+++ uspace/lib/usb/include/usb/recognise.h	(revision 67b6fc5853a7bb19dd26cf0e0035db90c42d1bfe)
@@ -0,0 +1,50 @@
+/*
+ * 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
+ * USB device recognition.
+ */
+#ifndef LIBUSB_RECOGNISE_H_
+#define LIBUSB_RECOGNISE_H_
+
+#include <sys/types.h>
+#include <usb/usb.h>
+#include <usb/pipes.h>
+
+int usb_device_create_match_ids(usb_endpoint_pipe_t *, match_id_list_t *);
+
+int usb_device_register_child_in_devman(usb_address_t address, devman_handle_t hc_handle,
+    device_t *parent, devman_handle_t *child_handle);
+
+#endif
+/**
+ * @}
+ */
Index: uspace/lib/usb/include/usb/usbdrv.h
===================================================================
--- uspace/lib/usb/include/usb/usbdrv.h	(revision e0df6c2d7a704b8e474264f04947e3eadfc936c2)
+++ uspace/lib/usb/include/usb/usbdrv.h	(revision 67b6fc5853a7bb19dd26cf0e0035db90c42d1bfe)
@@ -106,8 +106,4 @@
     const void *, size_t);
 
-int usb_drv_create_device_match_ids(int, match_id_list_t *, usb_address_t);
-int usb_drv_register_child_in_devman(int, device_t *, usb_address_t,
-    devman_handle_t *);
-
 
 #endif
Index: uspace/lib/usb/src/pipes.c
===================================================================
--- uspace/lib/usb/src/pipes.c	(revision e0df6c2d7a704b8e474264f04947e3eadfc936c2)
+++ uspace/lib/usb/src/pipes.c	(revision 67b6fc5853a7bb19dd26cf0e0035db90c42d1bfe)
@@ -123,4 +123,5 @@
  * @param endpoint_no Endpoint number (in USB 1.1 in range 0 to 15).
  * @param transfer_type Transfer type (e.g. interrupt or bulk).
+ * @param max_packet_size Maximum packet size in bytes.
  * @param direction Endpoint direction (in/out).
  * @return Error code.
@@ -128,5 +129,6 @@
 int usb_endpoint_pipe_initialize(usb_endpoint_pipe_t *pipe,
     usb_device_connection_t *connection, usb_endpoint_t endpoint_no,
-    usb_transfer_type_t transfer_type, usb_direction_t direction)
+    usb_transfer_type_t transfer_type, size_t max_packet_size,
+    usb_direction_t direction)
 {
 	assert(pipe);
@@ -137,4 +139,5 @@
 	pipe->endpoint_no = endpoint_no;
 	pipe->transfer_type = transfer_type;
+	pipe->max_packet_size = max_packet_size;
 	pipe->direction = direction;
 
@@ -156,5 +159,5 @@
 
 	int rc = usb_endpoint_pipe_initialize(pipe, connection,
-	    0, USB_TRANSFER_CONTROL, USB_DIRECTION_BOTH);
+	    0, USB_TRANSFER_CONTROL, 8, USB_DIRECTION_BOTH);
 
 	return rc;
Index: uspace/lib/usb/src/pipesinit.c
===================================================================
--- uspace/lib/usb/src/pipesinit.c	(revision 67b6fc5853a7bb19dd26cf0e0035db90c42d1bfe)
+++ uspace/lib/usb/src/pipesinit.c	(revision 67b6fc5853a7bb19dd26cf0e0035db90c42d1bfe)
@@ -0,0 +1,324 @@
+/*
+ * 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
+ * Initialization of endpoint pipes.
+ *
+ */
+#include <usb/usb.h>
+#include <usb/pipes.h>
+#include <usb/dp.h>
+#include <errno.h>
+#include <assert.h>
+
+
+#define NESTING(parentname, childname) \
+	{ \
+		.child = USB_DESCTYPE_##childname, \
+		.parent = USB_DESCTYPE_##parentname, \
+	}
+#define LAST_NESTING { -1, -1 }
+
+/** Nesting pairs of standard descriptors. */
+static usb_dp_descriptor_nesting_t descriptor_nesting[] = {
+	NESTING(CONFIGURATION, INTERFACE),
+	NESTING(INTERFACE, ENDPOINT),
+	NESTING(INTERFACE, HUB),
+	NESTING(INTERFACE, HID),
+	NESTING(HID, HID_REPORT),
+	LAST_NESTING
+};
+
+/** Tells whether given descriptor is of endpoint type.
+ *
+ * @param descriptor Descriptor in question.
+ * @return Whether the given descriptor is endpoint descriptor.
+ */
+static inline bool is_endpoint_descriptor(uint8_t *descriptor)
+{
+	return descriptor[1] == USB_DESCTYPE_ENDPOINT;
+}
+
+/** Tells whether found endpoint corresponds to endpoint described by user.
+ *
+ * @param wanted Endpoint description as entered by driver author.
+ * @param found Endpoint description obtained from endpoint descriptor.
+ * @return Whether the @p found descriptor fits the @p wanted descriptor.
+ */
+static bool endpoint_fits_description(const usb_endpoint_description_t *wanted,
+    usb_endpoint_description_t *found)
+{
+#define _SAME(fieldname) ((wanted->fieldname) == (found->fieldname))
+
+	if (!_SAME(direction)) {
+		return false;
+	}
+
+	if (!_SAME(transfer_type)) {
+		return false;
+	}
+
+	if ((wanted->interface_class >= 0) && !_SAME(interface_class)) {
+		return false;
+	}
+
+	if ((wanted->interface_subclass >= 0) && !_SAME(interface_subclass)) {
+		return false;
+	}
+
+	if ((wanted->interface_protocol >= 0) && !_SAME(interface_protocol)) {
+		return false;
+	}
+
+#undef _SAME
+
+	return true;
+}
+
+/** Find endpoint mapping for a found endpoint.
+ *
+ * @param mapping Endpoint mapping list.
+ * @param mapping_count Number of endpoint mappings in @p mapping.
+ * @param found_endpoint Description of found endpoint.
+ * @return Endpoint mapping corresponding to @p found_endpoint.
+ * @retval NULL No corresponding endpoint found.
+ */
+static usb_endpoint_mapping_t *find_endpoint_mapping(
+    usb_endpoint_mapping_t *mapping, size_t mapping_count,
+    usb_endpoint_description_t *found_endpoint)
+{
+	while (mapping_count > 0) {
+		if (endpoint_fits_description(mapping->description,
+		    found_endpoint)) {
+			return mapping;
+		}
+
+		mapping++;
+		mapping_count--;
+	}
+	return NULL;
+}
+
+/** Process endpoint descriptor.
+ *
+ * @param mapping Endpoint mapping list.
+ * @param mapping_count Number of endpoint mappings in @p mapping.
+ * @param interface Interface descriptor under which belongs the @p endpoint.
+ * @param endpoint Endpoint descriptor.
+ * @param wire Connection backing the endpoint pipes.
+ * @return Error code.
+ */
+static int process_endpoint(
+    usb_endpoint_mapping_t *mapping, size_t mapping_count,
+    usb_standard_interface_descriptor_t *interface,
+    usb_standard_endpoint_descriptor_t *endpoint,
+    usb_device_connection_t *wire)
+{
+	usb_endpoint_description_t description;
+
+	/*
+	 * Get endpoint characteristics.
+	 */
+
+	/* Actual endpoint number is in bits 0..3 */
+	usb_endpoint_t ep_no = endpoint->endpoint_address & 0x0F;
+
+	/* Endpoint direction is set by bit 7 */
+	description.direction = (endpoint->endpoint_address & 128)
+	    ? USB_DIRECTION_IN : USB_DIRECTION_OUT;
+	/* Transfer type is in bits 0..2 and the enum values corresponds 1:1 */
+	description.transfer_type = endpoint->attributes & 3;
+
+	/*
+	 * Get interface characteristics.
+	 */
+	description.interface_class = interface->interface_class;
+	description.interface_subclass = interface->interface_subclass;
+	description.interface_protocol = interface->interface_protocol;
+
+	/*
+	 * Find the most fitting mapping and initialize the pipe.
+	 */
+	usb_endpoint_mapping_t *ep_mapping = find_endpoint_mapping(mapping,
+	    mapping_count, &description);
+	if (ep_mapping == NULL) {
+		return ENOENT;
+	}
+
+	if (ep_mapping->pipe == NULL) {
+		return EBADMEM;
+	}
+	if (ep_mapping->present) {
+		return EEXISTS;
+	}
+
+	int rc = usb_endpoint_pipe_initialize(ep_mapping->pipe, wire,
+	    ep_no, description.transfer_type, endpoint->max_packet_size,
+	    description.direction);
+	if (rc != EOK) {
+		return rc;
+	}
+
+	ep_mapping->present = true;
+	ep_mapping->descriptor = endpoint;
+	ep_mapping->interface = interface;
+
+	return EOK;
+}
+
+/** Process whole USB interface.
+ *
+ * @param mapping Endpoint mapping list.
+ * @param mapping_count Number of endpoint mappings in @p mapping.
+ * @param parser Descriptor parser.
+ * @param parser_data Descriptor parser data.
+ * @param interface_descriptor Interface descriptor.
+ * @return Error code.
+ */
+static int process_interface(
+    usb_endpoint_mapping_t *mapping, size_t mapping_count,
+    usb_dp_parser_t *parser, usb_dp_parser_data_t *parser_data,
+    uint8_t *interface_descriptor)
+{
+	uint8_t *descriptor = usb_dp_get_nested_descriptor(parser,
+	    parser_data, interface_descriptor);
+
+	if (descriptor == NULL) {
+		return ENOENT;
+	}
+
+	do {
+		if (is_endpoint_descriptor(descriptor)) {
+			(void) process_endpoint(mapping, mapping_count,
+			    (usb_standard_interface_descriptor_t *)
+			        interface_descriptor,
+			    (usb_standard_endpoint_descriptor_t *)
+			        descriptor,
+			    (usb_device_connection_t *) parser_data->arg);
+		}
+
+		descriptor = usb_dp_get_sibling_descriptor(parser, parser_data,
+		    interface_descriptor, descriptor);
+	} while (descriptor != NULL);
+
+	return EOK;
+}
+
+/** Initialize endpoint pipes from configuration descriptor.
+ *
+ * The mapping array is expected to conform to following rules:
+ * - @c pipe must point to already allocated structure with uninitialized pipe
+ * - @c description must point to prepared endpoint description
+ * - @c descriptor does not need to be initialized (will be overwritten)
+ * - @c interface does not need to be initialized (will be overwritten)
+ * - @c present does not need to be initialized (will be overwritten)
+ *
+ * After processing the configuration descriptor, the mapping is updated
+ * in the following fashion:
+ * - @c present will be set to @c true when the endpoint was found in the
+ *   configuration
+ * - @c descriptor will point inside the configuration descriptor to endpoint
+ *   corresponding to given description (or NULL for not found descriptor)
+ * - @c interface will point inside the configuration descriptor to interface
+ *   descriptor the endpoint @c descriptor belongs to (or NULL for not found
+ *   descriptor)
+ * - @c pipe will be initialized when found, otherwise left untouched
+ * - @c description will be untouched under all circumstances
+ *
+ * @param mapping Endpoint mapping list.
+ * @param mapping_count Number of endpoint mappings in @p mapping.
+ * @param configuration_descriptor Full configuration descriptor (is expected
+ *	to be in USB endianness: i.e. as-is after being retrieved from
+ *	the device).
+ * @param configuration_descriptor_size Size of @p configuration_descriptor
+ *	in bytes.
+ * @param connection Connection backing the endpoint pipes.
+ * @return Error code.
+ */
+int usb_endpoint_pipe_initialize_from_configuration(
+    usb_endpoint_mapping_t *mapping, size_t mapping_count,
+    uint8_t *configuration_descriptor, size_t configuration_descriptor_size,
+    usb_device_connection_t *connection)
+{
+	assert(connection);
+
+	if (configuration_descriptor == NULL) {
+		return EBADMEM;
+	}
+	if (configuration_descriptor_size
+	    < sizeof(usb_standard_configuration_descriptor_t)) {
+		return ERANGE;
+	}
+
+	/*
+	 * Go through the mapping and set all endpoints to not present.
+	 */
+	size_t i;
+	for (i = 0; i < mapping_count; i++) {
+		mapping[i].present = false;
+		mapping[i].descriptor = NULL;
+		mapping[i].interface = NULL;
+	}
+
+	/*
+	 * Prepare the descriptor parser.
+	 */
+	usb_dp_parser_t dp_parser = {
+		.nesting = descriptor_nesting
+	};
+	usb_dp_parser_data_t dp_data = {
+		.data = configuration_descriptor,
+		.size = configuration_descriptor_size,
+		.arg = connection
+	};
+
+	/*
+	 * Iterate through all interfaces.
+	 */
+	uint8_t *interface = usb_dp_get_nested_descriptor(&dp_parser,
+	    &dp_data, configuration_descriptor);
+	if (interface == NULL) {
+		return ENOENT;
+	}
+	do {
+		(void) process_interface(mapping, mapping_count,
+		    &dp_parser, &dp_data,
+		    interface);
+		interface = usb_dp_get_sibling_descriptor(&dp_parser, &dp_data,
+		    configuration_descriptor, interface);
+	} while (interface != NULL);
+
+	return EOK;
+}
+
+/**
+ * @}
+ */
Index: uspace/lib/usb/src/recognise.c
===================================================================
--- uspace/lib/usb/src/recognise.c	(revision e0df6c2d7a704b8e474264f04947e3eadfc936c2)
+++ uspace/lib/usb/src/recognise.c	(revision 67b6fc5853a7bb19dd26cf0e0035db90c42d1bfe)
@@ -36,7 +36,13 @@
 #include <usb_iface.h>
 #include <usb/usbdrv.h>
+#include <usb/pipes.h>
+#include <usb/recognise.h>
+#include <usb/request.h>
 #include <usb/classes/classes.h>
 #include <stdio.h>
 #include <errno.h>
+
+static size_t device_name_index = 0;
+static FIBRIL_MUTEX_INITIALIZE(device_name_index_mutex);
 
 /** Callback for getting host controller handle.
@@ -155,5 +161,5 @@
 		/* First, with release number. */
 		rc = usb_add_match_id(matches, 100,
-		    "usb&vendor=%d&product=%d&release=" BCD_FMT,
+		    "usb&vendor=0x%04x&product=0x%04x&release=" BCD_FMT,
 		    (int) device_descriptor->vendor_id,
 		    (int) device_descriptor->product_id,
@@ -164,5 +170,6 @@
 		
 		/* Next, without release number. */
-		rc = usb_add_match_id(matches, 90, "usb&vendor=%d&product=%d",
+		rc = usb_add_match_id(matches, 90,
+		    "usb&vendor=0x%04x&product=0x%04x",
 		    (int) device_descriptor->vendor_id,
 		    (int) device_descriptor->product_id);
@@ -241,13 +248,11 @@
 /** Add match ids based on configuration descriptor.
  *
- * @param hc Open phone to host controller.
+ * @param pipe Control pipe to the device.
  * @param matches Match ids list to add matches to.
- * @param address USB address of the attached device.
  * @param config_count Number of configurations the device has.
  * @return Error code.
  */
-static int usb_add_config_descriptor_match_ids(int hc,
-    match_id_list_t *matches, usb_address_t address,
-    int config_count)
+static int usb_add_config_descriptor_match_ids(usb_endpoint_pipe_t *pipe,
+    match_id_list_t *matches, int config_count)
 {
 	int final_rc = EOK;
@@ -257,6 +262,6 @@
 		int rc;
 		usb_standard_configuration_descriptor_t config_descriptor;
-		rc = usb_drv_req_get_bare_configuration_descriptor(hc,
-		    address,  config_index, &config_descriptor);
+		rc = usb_request_get_bare_configuration_descriptor(pipe,
+		    config_index, &config_descriptor);
 		if (rc != EOK) {
 			final_rc = rc;
@@ -267,6 +272,6 @@
 		void *full_config_descriptor
 		    = malloc(config_descriptor.total_length);
-		rc = usb_drv_req_get_full_configuration_descriptor(hc,
-		    address, config_index,
+		rc = usb_request_get_full_configuration_descriptor(pipe,
+		    config_index,
 		    full_config_descriptor, config_descriptor.total_length,
 		    &full_config_descriptor_size);
@@ -299,14 +304,13 @@
  * function exits with error.
  *
- * @param hc Open phone to host controller.
+ * @param ctrl_pipe Control pipe to given device (session must be already
+ *	started).
  * @param matches Initialized list of match ids.
- * @param address USB address of the attached device.
- * @return Error code.
- */
-int usb_drv_create_device_match_ids(int hc, match_id_list_t *matches,
-    usb_address_t address)
+ * @return Error code.
+ */
+int usb_device_create_match_ids(usb_endpoint_pipe_t *ctrl_pipe,
+    match_id_list_t *matches)
 {
 	int rc;
-	
 	/*
 	 * Retrieve device descriptor and add matches from it.
@@ -314,10 +318,9 @@
 	usb_standard_device_descriptor_t device_descriptor;
 
-	rc = usb_drv_req_get_device_descriptor(hc, address,
-	    &device_descriptor);
+	rc = usb_request_get_device_descriptor(ctrl_pipe, &device_descriptor);
 	if (rc != EOK) {
 		return rc;
 	}
-	
+
 	rc = usb_drv_create_match_ids_from_device_descriptor(matches,
 	    &device_descriptor);
@@ -325,11 +328,11 @@
 		return rc;
 	}
-	
+
 	/*
 	 * Go through all configurations and add matches
 	 * based on interface class.
 	 */
-	rc = usb_add_config_descriptor_match_ids(hc, matches,
-	    address, device_descriptor.configuration_count);
+	rc = usb_add_config_descriptor_match_ids(ctrl_pipe, matches,
+	    device_descriptor.configuration_count);
 	if (rc != EOK) {
 		return rc;
@@ -347,19 +350,16 @@
 }
 
-
 /** Probe for device kind and register it in devman.
  *
- * @param[in] hc Open phone to the host controller.
+ * @param[in] address Address of the (unknown) attached device.
+ * @param[in] hc_handle Handle of the host controller.
  * @param[in] parent Parent device.
- * @param[in] address Address of the (unknown) attached device.
  * @param[out] child_handle Handle of the child device.
  * @return Error code.
  */
-int usb_drv_register_child_in_devman(int hc, device_t *parent,
-    usb_address_t address, devman_handle_t *child_handle)
-{
-	static size_t device_name_index = 0;
-	static FIBRIL_MUTEX_INITIALIZE(device_name_index_mutex);
-
+int usb_device_register_child_in_devman(usb_address_t address,
+    devman_handle_t hc_handle,
+    device_t *parent, devman_handle_t *child_handle)
+{
 	size_t this_device_name_index;
 
@@ -369,8 +369,20 @@
 	fibril_mutex_unlock(&device_name_index_mutex);
 
-
 	device_t *child = NULL;
 	char *child_name = NULL;
 	int rc;
+	usb_device_connection_t dev_connection;
+	usb_endpoint_pipe_t ctrl_pipe;
+
+	rc = usb_device_connection_initialize(&dev_connection, hc_handle, address);
+	if (rc != EOK) {
+		goto failure;
+	}
+
+	rc = usb_endpoint_pipe_initialize_default_control(&ctrl_pipe,
+	    &dev_connection);
+	if (rc != EOK) {
+		goto failure;
+	}
 
 	child = create_device();
@@ -391,6 +403,16 @@
 	child->name = child_name;
 	child->ops = &child_ops;
-	
-	rc = usb_drv_create_device_match_ids(hc, &child->match_ids, address);
+
+	rc = usb_endpoint_pipe_start_session(&ctrl_pipe);
+	if (rc != EOK) {
+		goto failure;
+	}
+
+	rc = usb_device_create_match_ids(&ctrl_pipe, &child->match_ids);
+	if (rc != EOK) {
+		goto failure;
+	}
+
+	rc = usb_endpoint_pipe_end_session(&ctrl_pipe);
 	if (rc != EOK) {
 		goto failure;
@@ -405,5 +427,5 @@
 		*child_handle = child->handle;
 	}
-	
+
 	return EOK;
 
@@ -419,5 +441,4 @@
 
 	return rc;
-
 }
 
