Index: uspace/drv/usbhub/usbhub.c
===================================================================
--- uspace/drv/usbhub/usbhub.c	(revision 5d4193cde5cfa457e7aa6d03be8b3d95babc10cf)
+++ uspace/drv/usbhub/usbhub.c	(revision d81ef61cee954e3114d2e6b6bce5b1033605c7c8)
@@ -41,4 +41,5 @@
 #include <usb/descriptor.h>
 #include <usb/devreq.h>
+#include <usb/request.h>
 #include <usb/classes/hub.h>
 
@@ -47,4 +48,5 @@
 #include "port_status.h"
 #include "usb/usb.h"
+#include "usb/pipes.h"
 
 static usb_iface_t hub_usb_iface = {
@@ -62,6 +64,11 @@
 //*********************************************
 
-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->connection, device);
+	usb_endpoint_pipe_initialize_default_control(&result->endpoints.control,
+            &result->connection);
+	
+
 	//result->device = device;
 	result->port_count = -1;
@@ -69,20 +76,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->usb_device = usb_new(usb_hcd_attached_device_info_t);
-	result->usb_device->address = addr;
-
+	
 	// get hub descriptor
 
@@ -93,9 +86,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) {
@@ -142,17 +143,12 @@
 	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->usb_device->address;
-	target.endpoint = 0;
+	//usb_target_t target;
+	//target.address = hub_info->usb_device->address;
+	//target.endpoint = 0;
 
 	//get configuration descriptor
@@ -160,5 +156,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){
@@ -173,6 +169,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){
@@ -181,5 +177,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);
 
@@ -191,5 +187,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) {
@@ -199,5 +196,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
@@ -251,9 +249,11 @@
  * @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");
 	//get default address
+	///////////////here ended pipe api upgrading
+	gfdl;gfdgldglglkfgklfjfkld;sjgk;fgklsjgld
 	opResult = usb_drv_reserve_default_address(hc);
 	if (opResult != EOK) {
@@ -374,21 +374,30 @@
  * @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
+	int opResult = usb_endpoint_pipe_start_session(&hub->endpoints.control);
+	usb_endpoint_pipe_t *pipe = &hub->endpoints.control;
+	if(opResult != EOK){
+		continue;
+	}
+
+	/*
 	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
 			);
@@ -403,12 +412,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(&hub->endpoints.control,
 		    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);
 		}
 	}
@@ -417,5 +426,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");
@@ -433,4 +442,6 @@
 	/// \TODO handle other changes
 	/// \TODO debug log for various situations
+	usb_endpoint_pipe_end_session(&hub->endpoints.control);
+
 
 }
@@ -450,8 +461,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->usb_device->address;
@@ -459,14 +476,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
@@ -480,7 +497,8 @@
 		 * Send the request.
 		 */
-		int opResult = usb_drv_async_interrupt_in(hc, target,
+		opResult = usb_endpoint_pipe_read(
+				&hub_info->endpoints.status_change,
 				change_bitmap, byte_length, &actual_size,
-				&handle);
+				);
 
 		usb_drv_async_wait_for(handle);
@@ -497,10 +515,12 @@
 			if (interrupt) {
 				usb_hub_process_interrupt(
-				        hub_info, hc, port, hub_info->usb_device->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 5d4193cde5cfa457e7aa6d03be8b3d95babc10cf)
+++ uspace/drv/usbhub/usbhub.h	(revision d81ef61cee954e3114d2e6b6bce5b1033605c7c8)
@@ -40,4 +40,6 @@
 #include "usb/hcdhubd.h"
 
+#include <usb/pipes.h>
+
 /** basic information about device attached to hub */
 typedef struct{
@@ -46,9 +48,17 @@
 }usb_hub_attached_device_t;
 
+/* Hub endpoints. */
+typedef struct {
+        usb_endpoint_pipe_t control;
+        usb_endpoint_pipe_t status_change;
+} usb_hub_endpoints_t;
+
+
+
 /** Information about attached hub. */
 typedef struct {
 	/** Number of ports. */
 	int port_count;
-	/** attached device handles */
+	/** attached device handles, for each port one */
 	usb_hub_attached_device_t * attached_devs;
 	/** General usb device info. */
@@ -56,4 +66,8 @@
 	/** General device info*/
 	device_t * device;
+	/** connection to hcd */
+	usb_device_connection_t 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 5d4193cde5cfa457e7aa6d03be8b3d95babc10cf)
+++ uspace/drv/usbhub/usbhub_private.h	(revision d81ef61cee954e3114d2e6b6bce5b1033605c7c8)
@@ -77,5 +77,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 +98,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 +116,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 +148,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 +159,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);
 }
