Index: uspace/drv/usbhub/port_status.h
===================================================================
--- uspace/drv/usbhub/port_status.h	(revision 16ecc283caf75ca1f4e0a68908d8dd5c7d24bd3b)
+++ uspace/drv/usbhub/port_status.h	(revision 39c3d95d4e176ba6534698cbda1809c2c71dc3ed)
@@ -55,5 +55,5 @@
 	request->index = port;
 	request->request_type = USB_HUB_REQ_TYPE_GET_PORT_STATUS;
-	request->request = USB_HUB_REQUEST_GET_STATE;
+	request->request = USB_HUB_REQUEST_GET_STATUS;
 	request->value = 0;
 	request->length = 4;
Index: uspace/drv/usbhub/usbhub.h
===================================================================
--- uspace/drv/usbhub/usbhub.h	(revision 16ecc283caf75ca1f4e0a68908d8dd5c7d24bd3b)
+++ uspace/drv/usbhub/usbhub.h	(revision 39c3d95d4e176ba6534698cbda1809c2c71dc3ed)
@@ -40,5 +40,9 @@
 #include "usb/hcdhubd.h"
 
-
+/** basic information about device attached to hub */
+typedef struct{
+	usb_address_t address;
+	devman_handle_t devman_handle;
+}usb_hub_attached_device_t;
 
 /** Information about attached hub. */
@@ -46,4 +50,6 @@
 	/** Number of ports. */
 	int port_count;
+	/** attached device handles */
+	usb_hub_attached_device_t * attached_devs;
 	/** General usb device info. */
 	usb_hcd_attached_device_info_t * usb_device;
Index: uspace/drv/usbhub/utils.c
===================================================================
--- uspace/drv/usbhub/utils.c	(revision 16ecc283caf75ca1f4e0a68908d8dd5c7d24bd3b)
+++ uspace/drv/usbhub/utils.c	(revision 39c3d95d4e176ba6534698cbda1809c2c71dc3ed)
@@ -351,4 +351,11 @@
 	//printf("[usb_hub] setting port count to %d\n",descriptor->ports_count);
 	result->port_count = descriptor->ports_count;
+	result->attached_devs = (usb_hub_attached_device_t*)
+	    malloc(result->port_count * sizeof(usb_hub_attached_device_t));
+	int i;
+	for(i=0;i<result->port_count;++i){
+		result->attached_devs[i].devman_handle=0;
+		result->attached_devs[i].address=0;
+	}
 	//printf("[usb_hub] freeing data\n");
 	free(serialized_descriptor);
@@ -385,4 +392,40 @@
 	target.address = hub_info->usb_device->address;
 	target.endpoint = 0;
+
+	//get configuration descriptor
+	// this is not fully correct - there are more configurations
+	// and all should be checked
+	usb_standard_device_descriptor_t std_descriptor;
+	opResult = usb_drv_req_get_device_descriptor(hc, target.address,
+    &std_descriptor);
+	if(opResult!=EOK){
+		printf("[usb_hub] could not get device descriptor, %d\n",opResult);
+		return 1;///\TODO some proper error code needed
+	}
+	printf("[usb_hub] hub has %d configurations\n",std_descriptor.configuration_count);
+	if(std_descriptor.configuration_count<1){
+		printf("[usb_hub] THERE ARE NO CONFIGURATIONS AVAILABLE\n");
+	}
+	usb_standard_configuration_descriptor_t config_descriptor;
+	opResult = usb_drv_req_get_bare_configuration_descriptor(hc,
+        target.address, 0,
+        &config_descriptor);
+	if(opResult!=EOK){
+		printf("[usb_hub] could not get configuration descriptor, %d\n",opResult);
+		return 1;///\TODO some proper error code needed
+	}
+	//set configuration
+	request.request_type = 0;
+	request.request = USB_DEVREQ_SET_CONFIGURATION;
+	request.index=0;
+	request.length=0;
+	request.value_high=0;
+	request.value_low = config_descriptor.configuration_number;
+	opResult = usb_drv_sync_control_write(hc, target, &request, NULL, 0);
+	if (opResult != EOK) {
+		printf("[usb_hub]something went wrong when setting hub`s configuration, %d\n", opResult);
+	}
+
+
 	for (port = 0; port < hub_info->port_count; ++port) {
 		usb_hub_set_power_port_request(&request, port);
@@ -393,4 +436,5 @@
 	}
 	//ports powered, hub seems to be enabled
+	
 
 	ipc_hangup(hc);
@@ -411,4 +455,5 @@
 			hub_info->usb_device->address,
 			hub_info->port_count);
+	printf("\tused configuration %d\n",config_descriptor.configuration_number);
 
 	return EOK;
@@ -432,5 +477,5 @@
 	int opResult;
 	printf("[usb_hub] some connection changed\n");
-
+	//get default address
 	opResult = usb_drv_reserve_default_address(hc);
 	if (opResult != EOK) {
@@ -478,5 +523,4 @@
 	}
 
-
 	usb_drv_release_default_address(hc);
 
@@ -488,5 +532,12 @@
 		return;
 	}
-	usb_drv_bind_address(hc, new_device_address, child_handle);
+	hub->attached_devs[port].devman_handle = child_handle;
+	hub->attached_devs[port].address = new_device_address;
+
+	opResult = usb_drv_bind_address(hc, new_device_address, child_handle);
+	if (opResult != EOK) {
+		printf("[usb_hub] could not assign address of device in hcd \n");
+		return;
+	}
 	
 }
@@ -498,9 +549,10 @@
  * @param target
  */
-static void usb_hub_removed_device(int hc, uint16_t port, usb_target_t target) {
-	usb_device_request_setup_packet_t request;
+static void usb_hub_removed_device(
+    usb_hub_info_t * hub, int hc, uint16_t port, usb_target_t target) {
+	//usb_device_request_setup_packet_t request;
 	int opResult;
 	//disable port
-	usb_hub_set_disable_port_request(&request, port);
+	/*usb_hub_set_disable_port_request(&request, port);
 	opResult = usb_drv_sync_control_write(
 			hc, target,
@@ -511,10 +563,20 @@
 		//continue;
 		printf("[usb_hub] something went wrong when disabling a port\n");
-	}
-	//remove device
+	}*/
+	/// \TODO remove device
+
+	hub->attached_devs[port].devman_handle=0;
 	//close address
-	//
-
-	///\TODO this code is not complete
+	if(hub->attached_devs[port].address!=0){
+		opResult = usb_drv_release_address(hc,hub->attached_devs[port].address);
+		if(opResult != EOK) {
+			printf("[usb_hub] could not release address of removed device: %d\n",opResult);
+		}
+		hub->attached_devs[port].address = 0;
+	}else{
+		printf("[usb_hub] this is strange, disconnected device had no address\n");
+		//device was disconnected before it`s port was reset - return default address
+		usb_drv_release_default_address(hc);
+	}
 }
 
@@ -525,7 +587,11 @@
  * @param target
  */
-static void usb_hub_process_interrupt(usb_hub_info_t * hub, int hc, uint16_t port, usb_target_t target) {
+static void usb_hub_process_interrupt(usb_hub_info_t * hub, int hc,
+        uint16_t port, usb_address_t address) {
 	printf("[usb_hub] interrupt at port %d\n", port);
 	//determine type of change
+	usb_target_t target;
+	target.address=address;
+	target.endpoint=0;
 	usb_port_status_t status;
 	size_t rcvd_size;
@@ -533,4 +599,5 @@
 	int opResult;
 	usb_hub_set_port_status_request(&request, port);
+	//endpoint 0
 
 	opResult = usb_drv_sync_control_read(
@@ -553,5 +620,5 @@
 			usb_hub_init_add_device(hc, port, target);
 		} else {
-			usb_hub_removed_device(hc, port, target);
+			usb_hub_removed_device(hub, hc, port, target);
 		}
 	}
@@ -607,5 +674,5 @@
 		usb_target_t target;
 		target.address = hub_info->usb_device->address;
-		target.endpoint = 1;
+		target.endpoint = 1;/// \TODO get from endpoint descriptor
 
 		size_t port_count = hub_info->port_count;
@@ -643,5 +710,6 @@
 			bool interrupt = (((uint8_t*) change_bitmap)[port / 8] >> (port % 8)) % 2;
 			if (interrupt) {
-				usb_hub_process_interrupt(hub_info, hc, port, target);
+				usb_hub_process_interrupt(
+				        hub_info, hc, port, hub_info->usb_device->address);
 			}
 		}
