Index: uspace/drv/usbhub/usbhub.c
===================================================================
--- uspace/drv/usbhub/usbhub.c	(revision 063ead6f8f7011ea1895467b62663e88d0abb573)
+++ uspace/drv/usbhub/usbhub.c	(revision 070f11ed65fc67c7ab58ee2c666e3180c4dbe713)
@@ -44,4 +44,5 @@
 #include <usb/recognise.h>
 #include <usb/devreq.h>
+#include <usb/request.h>
 #include <usb/classes/hub.h>
 
@@ -50,4 +51,5 @@
 #include "port_status.h"
 #include "usb/usb.h"
+#include "usb/pipes.h"
 
 static device_ops_t hub_device_ops = {
@@ -61,6 +63,14 @@
 //*********************************************
 
-usb_hub_info_t * usb_create_hub_info(device_t * device, int hc) {
+usb_hub_info_t * usb_create_hub_info(device_t * device) {
 	usb_hub_info_t* result = usb_new(usb_hub_info_t);
+	usb_device_connection_initialize_from_device(&result->device_connection,
+			device);
+	usb_hc_connection_initialize_from_device(&result->connection,
+			device);
+	usb_endpoint_pipe_initialize_default_control(&result->endpoints.control,
+            &result->device_connection);
+	
+
 	//result->device = device;
 	result->port_count = -1;
@@ -68,19 +78,6 @@
 	result->device = device;
 
-
-	dprintf(USB_LOG_LEVEL_DEBUG, "phone to hc = %d", hc);
-	if (hc < 0) {
-		return result;
-	}
-	//get some hub info
-	usb_address_t addr = usb_drv_get_my_address(hc, device);
-	dprintf(USB_LOG_LEVEL_DEBUG, "address of newly created hub = %d", addr);
-	/*if(addr<0){
-		//return result;
-
-	}*/
-
-	result->address = addr;
-
+	//result->usb_device = usb_new(usb_hcd_attached_device_info_t);
+	
 	// get hub descriptor
 
@@ -91,9 +88,17 @@
 	int opResult;
 	dprintf(USB_LOG_LEVEL_DEBUG, "starting control transaction");
-	
-	opResult = usb_drv_req_get_descriptor(hc, addr,
+	usb_endpoint_pipe_start_session(&result->endpoints.control);
+	opResult = usb_request_get_descriptor(&result->endpoints.control,
 			USB_REQUEST_TYPE_CLASS,
 			USB_DESCTYPE_HUB, 0, 0, serialized_descriptor,
 			USB_HUB_MAX_DESCRIPTOR_SIZE, &received_size);
+	usb_endpoint_pipe_end_session(&result->endpoints.control);
+
+	/* Initialize the interrupt endpoint. 
+	usb_endpoint_pipe_initalize(
+		&hub_data->endpoints->status_change,
+		&endpiont_descriptor, &hub_data->connection);
+
+	 */ /// \TODO add this call
 
 	if (opResult != EOK) {
@@ -111,9 +116,9 @@
 	dprintf(USB_LOG_LEVEL_INFO, "setting port count to %d",descriptor->ports_count);
 	result->port_count = descriptor->ports_count;
-	result->attached_devs = (usb_hub_attached_device_t*)
-	    malloc((result->port_count+1) * sizeof(usb_hub_attached_device_t));
+	result->attached_devs = (usb_hc_attached_device_t*)
+	    malloc((result->port_count+1) * sizeof(usb_hc_attached_device_t));
 	int i;
 	for(i=0;i<result->port_count+1;++i){
-		result->attached_devs[i].devman_handle=0;
+		result->attached_devs[i].handle=0;
 		result->attached_devs[i].address=0;
 	}
@@ -140,17 +145,13 @@
 	dev->ops = &hub_device_ops;
 
-	//create the hub structure
-	//get hc connection
-	int hc = usb_drv_hc_connect_auto(dev, 0);
-	if (hc < 0) {
-		return hc;
-	}
-
-	usb_hub_info_t * hub_info = usb_create_hub_info(dev, hc);
+
+	usb_hub_info_t * hub_info = usb_create_hub_info(dev);
+	usb_endpoint_pipe_start_session(&hub_info->endpoints.control);
+
 	int port;
 	int opResult;
-	usb_target_t target;
-	target.address = hub_info->address;
-	target.endpoint = 0;
+	//usb_target_t target;
+	//target.address = hub_info->usb_device->address;
+	//target.endpoint = 0;
 
 	//get configuration descriptor
@@ -158,5 +159,5 @@
 	// and all should be checked
 	usb_standard_device_descriptor_t std_descriptor;
-	opResult = usb_drv_req_get_device_descriptor(hc, target.address,
+	opResult = usb_request_get_device_descriptor(&hub_info->endpoints.control,
 	    &std_descriptor);
 	if(opResult!=EOK){
@@ -171,6 +172,6 @@
 	/// \TODO check other configurations
 	usb_standard_configuration_descriptor_t config_descriptor;
-	opResult = usb_drv_req_get_bare_configuration_descriptor(hc,
-        target.address, 0,
+	opResult = usb_request_get_bare_configuration_descriptor(
+	    &hub_info->endpoints.control, 0,
         &config_descriptor);
 	if(opResult!=EOK){
@@ -179,5 +180,5 @@
 	}
 	//set configuration
-	opResult = usb_drv_req_set_configuration(hc, target.address,
+	opResult = usb_request_set_configuration(&hub_info->endpoints.control,
     config_descriptor.configuration_number);
 
@@ -189,5 +190,6 @@
 	for (port = 1; port < hub_info->port_count+1; ++port) {
 		usb_hub_set_power_port_request(&request, port);
-		opResult = usb_drv_sync_control_write(hc, target, &request, NULL, 0);
+		opResult = usb_endpoint_pipe_control_write(&hub_info->endpoints.control,
+				&request,sizeof(usb_device_request_setup_packet_t), NULL, 0);
 		dprintf(USB_LOG_LEVEL_INFO, "powering port %d",port);
 		if (opResult != EOK) {
@@ -197,5 +199,6 @@
 	//ports powered, hub seems to be enabled
 
-	async_hangup(hc);
+	usb_endpoint_pipe_end_session(&hub_info->endpoints.control);
+	//async_hangup(hc);
 
 	//add the hub to list
@@ -211,6 +214,7 @@
 
 	dprintf(USB_LOG_LEVEL_INFO, "hub dev added");
+	//address is lost...
 	dprintf(USB_LOG_LEVEL_DEBUG, "\taddress %d, has %d ports ",
-			hub_info->address,
+			//hub_info->endpoints.control.,
 			hub_info->port_count);
 	dprintf(USB_LOG_LEVEL_DEBUG, "\tused configuration %d",config_descriptor.configuration_number);
@@ -249,10 +253,12 @@
  * @param target
  */
-static void usb_hub_init_add_device(int hc, uint16_t port, usb_target_t target) {
+static void usb_hub_init_add_device(usb_hub_info_t * hub, uint16_t port) {
 	usb_device_request_setup_packet_t request;
 	int opResult;
 	dprintf(USB_LOG_LEVEL_INFO, "some connection changed");
+	assert(hub->endpoints.control.hc_phone);
 	//get default address
-	opResult = usb_drv_reserve_default_address(hc);
+	//opResult = usb_drv_reserve_default_address(hc);
+	opResult = usb_hc_reserve_default_address(&hub->connection, false);
 	if (opResult != EOK) {
 		dprintf(USB_LOG_LEVEL_WARNING, "cannot assign default address, it is probably used");
@@ -261,12 +267,13 @@
 	//reset port
 	usb_hub_set_reset_port_request(&request, port);
-	opResult = usb_drv_sync_control_write(
-			hc, target,
-			&request,
+	opResult = usb_endpoint_pipe_control_write(
+			&hub->endpoints.control,
+			&request,sizeof(usb_device_request_setup_packet_t),
 			NULL, 0
 			);
 	if (opResult != EOK) {
 		dprintf(USB_LOG_LEVEL_ERROR, "something went wrong when reseting a port");
-		usb_hub_release_default_address(hc);
+		//usb_hub_release_default_address(hc);
+		usb_hc_release_default_address(&hub->connection);
 	}
 }
@@ -279,59 +286,77 @@
  */
 static void usb_hub_finalize_add_device( usb_hub_info_t * hub,
-		int hc, uint16_t port, usb_target_t target) {
+		uint16_t port) {
 
 	int opResult;
 	dprintf(USB_LOG_LEVEL_INFO, "finalizing add device");
-	opResult = usb_hub_clear_port_feature(hc, target.address,
+	opResult = usb_hub_clear_port_feature(&hub->endpoints.control,
 	    port, USB_HUB_FEATURE_C_PORT_RESET);
+
 	if (opResult != EOK) {
 		dprintf(USB_LOG_LEVEL_ERROR, "failed to clear port reset feature");
-		usb_hub_release_default_address(hc);
-		return;
-	}
-
-	/* Request address at from host controller. */
-	usb_address_t new_device_address = usb_drv_request_address(hc);
+		usb_hc_release_default_address(&hub->connection);
+		return;
+	}
+	//create connection to device
+	usb_endpoint_pipe_t new_device_pipe;
+	usb_device_connection_t new_device_connection;
+	usb_device_connection_initialize_on_default_address(
+			&new_device_connection,
+			&hub->connection
+			);
+	usb_endpoint_pipe_initialize_default_control(
+			&new_device_pipe,
+			&new_device_connection);
+	/// \TODO get highspeed info
+
+
+
+
+
+	/* Request address from host controller. */
+	usb_address_t new_device_address = usb_hc_request_address(
+			&hub->connection,
+			false/// \TODO fullspeed??
+			);
 	if (new_device_address < 0) {
 		dprintf(USB_LOG_LEVEL_ERROR, "failed to get free USB address");
 		opResult = new_device_address;
-		usb_hub_release_default_address(hc);
+		usb_hc_release_default_address(&hub->connection);
 		return;
 	}
 	dprintf(USB_LOG_LEVEL_INFO, "setting new address %d",new_device_address);
-	opResult = usb_drv_req_set_address(hc, USB_ADDRESS_DEFAULT,
-	    new_device_address);
+	//opResult = usb_drv_req_set_address(hc, USB_ADDRESS_DEFAULT,
+	//    new_device_address);
+	opResult = usb_request_set_address(&new_device_pipe,new_device_address);
 
 	if (opResult != EOK) {
 		dprintf(USB_LOG_LEVEL_ERROR, "could not set address for new device");
-		usb_hub_release_default_address(hc);
-		return;
-	}
-
-
-	opResult = usb_hub_release_default_address(hc);
+		usb_hc_release_default_address(&hub->connection);
+		return;
+	}
+
+
+	//opResult = usb_hub_release_default_address(hc);
+	opResult = usb_hc_release_default_address(&hub->connection);
 	if(opResult!=EOK){
 		return;
 	}
 
-	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_device_register_child_in_devman(new_device_address,
-            hc_handle, hub->device, &child_handle);
+	//??
+    opResult = usb_device_register_child_in_devman(new_device_address,
+            hub->connection.hc_handle, hub->device, &child_handle);
+
 	if (opResult != EOK) {
 		dprintf(USB_LOG_LEVEL_ERROR, "could not start driver for new device");
 		return;
 	}
-	hub->attached_devs[port].devman_handle = child_handle;
+	hub->attached_devs[port].handle = child_handle;
 	hub->attached_devs[port].address = new_device_address;
 
-	opResult = usb_drv_bind_address(hc, new_device_address, child_handle);
+	//opResult = usb_drv_bind_address(hc, new_device_address, child_handle);
+	opResult = usb_hc_register_device(
+			&hub->connection,
+			&hub->attached_devs[port]);
 	if (opResult != EOK) {
 		dprintf(USB_LOG_LEVEL_ERROR, "could not assign address of device in hcd");
@@ -350,5 +375,5 @@
  */
 static void usb_hub_removed_device(
-    usb_hub_info_t * hub, int hc, uint16_t port, usb_target_t target) {
+    usb_hub_info_t * hub,uint16_t port) {
 	//usb_device_request_setup_packet_t request;
 	int opResult;
@@ -357,9 +382,10 @@
 	 * devide manager
 	 */
-
-	hub->attached_devs[port].devman_handle=0;
+	
 	//close address
 	if(hub->attached_devs[port].address!=0){
-		opResult = usb_drv_release_address(hc,hub->attached_devs[port].address);
+		//opResult = usb_drv_release_address(hc,hub->attached_devs[port].address);
+		opResult = usb_hc_unregister_device(
+				&hub->connection, hub->attached_devs[port].address);
 		if(opResult != EOK) {
 			dprintf(USB_LOG_LEVEL_WARNING, "could not release address of " \
@@ -367,8 +393,10 @@
 		}
 		hub->attached_devs[port].address = 0;
+		hub->attached_devs[port].handle = 0;
 	}else{
 		dprintf(USB_LOG_LEVEL_WARNING, "this is strange, disconnected device had no address");
 		//device was disconnected before it`s port was reset - return default address
-		usb_drv_release_default_address(hc);
+		//usb_drv_release_default_address(hc);
+		usb_hc_release_default_address(&hub->connection);
 	}
 }
@@ -380,21 +408,31 @@
  * @param target
  */
-static void usb_hub_process_interrupt(usb_hub_info_t * hub, int hc,
-        uint16_t port, usb_address_t address) {
+static void usb_hub_process_interrupt(usb_hub_info_t * hub, 
+        uint16_t port) {
 	dprintf(USB_LOG_LEVEL_DEBUG, "interrupt at port %d", port);
 	//determine type of change
+	usb_endpoint_pipe_t *pipe = &hub->endpoints.control;
+	int opResult = usb_endpoint_pipe_start_session(pipe);
+	
+	if(opResult != EOK){
+		dprintf(USB_LOG_LEVEL_ERROR, "cannot open pipe %d", opResult);
+	}
+
+	/*
 	usb_target_t target;
 	target.address=address;
 	target.endpoint=0;
+	*/
+
 	usb_port_status_t status;
 	size_t rcvd_size;
 	usb_device_request_setup_packet_t request;
-	int opResult;
+	//int opResult;
 	usb_hub_set_port_status_request(&request, port);
 	//endpoint 0
 
-	opResult = usb_drv_sync_control_read(
-			hc, target,
-			&request,
+	opResult = usb_endpoint_pipe_control_read(
+			pipe,
+			&request, sizeof(usb_device_request_setup_packet_t),
 			&status, 4, &rcvd_size
 			);
@@ -409,12 +447,12 @@
 	//something connected/disconnected
 	if (usb_port_connect_change(&status)) {
-		opResult = usb_hub_clear_port_feature(hc, target.address,
+		opResult = usb_hub_clear_port_feature(pipe,
 		    port, USB_HUB_FEATURE_C_PORT_CONNECTION);
 		// TODO: check opResult
 		if (usb_port_dev_connected(&status)) {
 			dprintf(USB_LOG_LEVEL_INFO, "some connection changed");
-			usb_hub_init_add_device(hc, port, target);
+			usb_hub_init_add_device(hub, port);
 		} else {
-			usb_hub_removed_device(hub, hc, port, target);
+			usb_hub_removed_device(hub, port);
 		}
 	}
@@ -423,5 +461,5 @@
 		dprintf(USB_LOG_LEVEL_INFO, "port reset complete");
 		if (usb_port_enabled(&status)) {
-			usb_hub_finalize_add_device(hub, hc, port, target);
+			usb_hub_finalize_add_device(hub, port);
 		} else {
 			dprintf(USB_LOG_LEVEL_WARNING, "ERROR: port reset, but port still not enabled");
@@ -439,4 +477,6 @@
 	/// \TODO handle other changes
 	/// \TODO debug log for various situations
+	usb_endpoint_pipe_end_session(pipe);
+
 
 }
@@ -456,8 +496,14 @@
 		fibril_mutex_unlock(&usb_hub_list_lock);
 		usb_hub_info_t * hub_info = ((usb_hub_info_t*)lst_item->data);
+		int opResult;
+
+		opResult = usb_endpoint_pipe_start_session(&hub_info->endpoints.status_change);
+		if(opResult != EOK){
+			continue;
+		}
 		/*
 		 * Check status change pipe of this hub.
 		 */
-
+		/*
 		usb_target_t target;
 		target.address = hub_info->address;
@@ -465,14 +511,14 @@
 		dprintf(USB_LOG_LEVEL_INFO, "checking changes for hub at addr %d",
 		    target.address);
-
+		*/
 		size_t port_count = hub_info->port_count;
 
 		/*
 		 * Connect to respective HC.
-		 */
+		 *
 		int hc = usb_drv_hc_connect_auto(hub_info->device, 0);
 		if (hc < 0) {
 			continue;
-		}
+		}*/
 
 		/// FIXME: count properly
@@ -481,14 +527,15 @@
 		void *change_bitmap = malloc(byte_length);
 		size_t actual_size;
-		usb_handle_t handle;
+		//usb_handle_t handle;
 
 		/*
 		 * Send the request.
 		 */
-		int opResult = usb_drv_async_interrupt_in(hc, target,
-				change_bitmap, byte_length, &actual_size,
-				&handle);
-
-		usb_drv_async_wait_for(handle);
+		opResult = usb_endpoint_pipe_read(
+				&hub_info->endpoints.status_change,
+				change_bitmap, byte_length, &actual_size
+				);
+
+		//usb_drv_async_wait_for(handle);
 
 		if (opResult != EOK) {
@@ -503,10 +550,12 @@
 			if (interrupt) {
 				usb_hub_process_interrupt(
-				        hub_info, hc, port, hub_info->address);
+				        hub_info, port);
 			}
 		}
+		usb_endpoint_pipe_end_session(&hub_info->endpoints.status_change);
 		free(change_bitmap);
-
-		async_hangup(hc);
+		
+
+		//async_hangup(hc);
 		fibril_mutex_lock(&usb_hub_list_lock);
 	}
Index: uspace/drv/usbhub/usbhub.h
===================================================================
--- uspace/drv/usbhub/usbhub.h	(revision 063ead6f8f7011ea1895467b62663e88d0abb573)
+++ uspace/drv/usbhub/usbhub.h	(revision 070f11ed65fc67c7ab58ee2c666e3180c4dbe713)
@@ -42,9 +42,17 @@
 #define NAME "usbhub"
 
-/** basic information about device attached to hub */
-typedef struct{
-	usb_address_t address;
-	devman_handle_t devman_handle;
-}usb_hub_attached_device_t;
+//#include "usb/hcdhubd.h"
+#include <usb/usbdrv.h>
+#include <usb/hub.h>
+
+#include <usb/pipes.h>
+
+/* Hub endpoints. */
+typedef struct {
+        usb_endpoint_pipe_t control;
+        usb_endpoint_pipe_t status_change;
+} usb_hub_endpoints_t;
+
+
 
 /** Information about attached hub. */
@@ -52,10 +60,17 @@
 	/** Number of ports. */
 	int port_count;
-	/** attached device handles */
-	usb_hub_attached_device_t * attached_devs;
-	/** USB address of the hub. */
-	usb_address_t address;
+	/** attached device handles, for each port one */
+	usb_hc_attached_device_t * attached_devs;
+	/** General usb device info. */
+	//usb_hcd_attached_device_info_t * usb_device;
 	/** General device info*/
 	device_t * device;
+	/** connection to hcd */
+	//usb_device_connection_t connection;
+	usb_hc_connection_t connection;
+	/** */
+	usb_device_connection_t device_connection;
+	/** hub endpoints */
+	usb_hub_endpoints_t endpoints;
 } usb_hub_info_t;
 
Index: uspace/drv/usbhub/usbhub_private.h
===================================================================
--- uspace/drv/usbhub/usbhub_private.h	(revision 063ead6f8f7011ea1895467b62663e88d0abb573)
+++ uspace/drv/usbhub/usbhub_private.h	(revision 070f11ed65fc67c7ab58ee2c666e3180c4dbe713)
@@ -45,8 +45,9 @@
 #include <fibril_synch.h>
 
+#include <usb/classes/hub.h>
 #include <usb/usb.h>
 #include <usb/usbdrv.h>
-#include <usb/classes/hub.h>
-#include <usb/devreq.h>
+
+//#include <usb/devreq.h>
 #include <usb/debug.h>
 
@@ -77,5 +78,5 @@
  * @return
  */
-usb_hub_info_t * usb_create_hub_info(device_t * device, int hc);
+usb_hub_info_t * usb_create_hub_info(device_t * device);
 
 /** List of hubs maanged by this driver */
@@ -98,9 +99,10 @@
  * @return error code
  */
+/*
 int usb_drv_sync_control_read(
-    int phone, usb_target_t target,
+    usb_endpoint_pipe_t *pipe,
     usb_device_request_setup_packet_t * request,
     void * rcvd_buffer, size_t rcvd_size, size_t * actual_size
-);
+);*/
 
 /**
@@ -115,9 +117,9 @@
  * @return error code
  */
-int usb_drv_sync_control_write(
-    int phone, usb_target_t target,
+/*int usb_drv_sync_control_write(
+    usb_endpoint_pipe_t *pipe,
     usb_device_request_setup_packet_t * request,
     void * sent_buffer, size_t sent_size
-);
+);*/
 
 /**
@@ -147,11 +149,8 @@
  * @return Operation result
  */
-static inline int usb_hub_clear_port_feature(int hc, usb_address_t address,
+static inline int usb_hub_clear_port_feature(usb_endpoint_pipe_t *pipe,
     int port_index,
     usb_hub_class_feature_t feature) {
-	usb_target_t target = {
-		.address = address,
-		.endpoint = 0
-	};
+	
 	usb_device_request_setup_packet_t clear_request = {
 		.request_type = USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE,
@@ -161,5 +160,5 @@
 	};
 	clear_request.value = feature;
-	return usb_drv_psync_control_write(hc, target, &clear_request,
+	return usb_endpoint_pipe_control_write(pipe, &clear_request,
 	    sizeof(clear_request), NULL, 0);
 }
Index: uspace/drv/usbhub/utils.c
===================================================================
--- uspace/drv/usbhub/utils.c	(revision 063ead6f8f7011ea1895467b62663e88d0abb573)
+++ uspace/drv/usbhub/utils.c	(revision 070f11ed65fc67c7ab58ee2c666e3180c4dbe713)
@@ -114,5 +114,5 @@
 
 //control transactions
-
+/*
 int usb_drv_sync_control_read(
     int phone, usb_target_t target,
@@ -199,5 +199,5 @@
 }
 
-
+*/
 
 
