Index: uspace/drv/usbhub/usbhub.c
===================================================================
--- uspace/drv/usbhub/usbhub.c	(revision 17aca1c1f6f00b4b526e475b7eead4405501c16b)
+++ 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);
 	}
