Index: uspace/lib/usb/include/usb/classes/hub.h
===================================================================
--- uspace/lib/usb/include/usb/classes/hub.h	(revision 8cd1aa5eb727edb7e57c0b5429631ef51ff14d2e)
+++ uspace/lib/usb/include/usb/classes/hub.h	(revision 03171de3c5da5094495087ad838f0b49c4ec6188)
@@ -36,14 +36,6 @@
 #define LIBUSB_HUB_H_
 
-/** Hub class request. */
-typedef enum {
-	USB_HUB_REQUEST_GET_STATUS = 0,
-	USB_HUB_REQUEST_CLEAR_FEATURE = 1,
-	USB_HUB_REQUEST_GET_STATE = 2,
-	USB_HUB_REQUEST_SET_FEATURE = 3,
-	USB_HUB_REQUEST_GET_DESCRIPTOR = 6,
-	USB_HUB_REQUEST_SET_DESCRIPTOR = 7,
-	/* USB_HUB_REQUEST_ = , */
-} usb_hub_class_request_t;
+#include <sys/types.h>
+
 
 /** Hub class feature selector.
@@ -69,4 +61,162 @@
 } usb_hub_class_feature_t;
 
+
+/**
+ *	@brief usb hub descriptor
+ *
+ *	For more information see Universal Serial Bus Specification Revision 1.1 chapter 11.16.2
+ */
+typedef struct hub_descriptor_type{
+    /** Number of bytes in this descriptor, including this byte */
+    //uint8_t bDescLength;
+
+    /** Descriptor Type, value: 29H for hub descriptor */
+    //uint8_t bDescriptorType;
+
+    /** Number of downstream ports that this hub supports */
+    uint8_t ports_count;
+
+    /**
+            D1...D0: Logical Power Switching Mode
+            00: Ganged power switching (all ports’ power at
+            once)
+            01: Individual port power switching
+            1X: Reserved. Used only on 1.0 compliant hubs
+            that implement no power switching.
+            D2: Identifies a Compound Device
+            0: Hub is not part of a compound device
+            1: Hub is part of a compound device
+            D4...D3: Over-current Protection Mode
+            00: Global Over-current Protection. The hub
+            reports over-current as a summation of all
+            ports’ current draw, without a breakdown of
+            individual port over-current status.
+            01: Individual Port Over-current Protection. The
+            hub reports over-current on a per-port basis.
+            Each port has an over-current indicator.
+            1X: No Over-current Protection. This option is
+            allowed only for bus-powered hubs that do not
+            implement over-current protection.
+            D15...D5:
+            Reserved
+     */
+    uint16_t hub_characteristics;
+
+    /**
+            Time (in 2ms intervals) from the time the power-on
+            sequence begins on a port until power is good on that
+            port. The USB System Software uses this value to
+            determine how long to wait before accessing a
+            powered-on port.
+     */
+    uint8_t pwr_on_2_good_time;
+
+    /**
+            Maximum current requirements of the Hub Controller
+            electronics in mA.
+     */
+    uint8_t current_requirement;
+
+    /**
+            Indicates if a port has a removable device attached.
+            This field is reported on byte-granularity. Within a
+            byte, if no port exists for a given location, the field
+            representing the port characteristics returns 0.
+            Bit value definition:
+            0B - Device is removable
+            1B - Device is non-removable
+            This is a bitmap corresponding to the individual ports
+            on the hub:
+            Bit 0: Reserved for future use
+            Bit 1: Port 1
+            Bit 2: Port 2
+            ....
+            Bit n: Port n (implementation-dependent, up to a
+            maximum of 255 ports).
+     */
+    uint8_t * devices_removable;
+
+    /**
+            This field exists for reasons of compatibility with
+            software written for 1.0 compliant devices. All bits in
+            this field should be set to 1B. This field has one bit for
+            each port on the hub with additional pad bits, if
+            necessary, to make the number of bits in the field an
+            integer multiple of 8.
+     */
+    //uint8_t * port_pwr_ctrl_mask;
+} usb_hub_descriptor_t;
+
+/**
+ *	Maximum size of usb hub descriptor in bytes
+ */
+extern size_t USB_HUB_MAX_DESCRIPTOR_SIZE;
+
+/**
+ *	hub descriptor type
+ */
+extern uint8_t USB_HUB_DESCRIPTOR_TYPE;
+
+/**
+ * @brief create uint8_t array with serialized descriptor
+ *
+ * @param descriptor
+ */
+void * usb_serialize_hub_descriptor(usb_hub_descriptor_t * descriptor);
+
+/**
+ * @brief create deserialized desriptor structure out of serialized descriptor
+ *
+ * The serialized descriptor must be proper usb hub descriptor, otherwise an eerror might occur.
+ *
+ * @param sdescriptor serialized descriptor
+ */
+usb_hub_descriptor_t * usb_deserialize_hub_desriptor(void * sdescriptor);
+
+/**	@brief usb hub specific request types.
+ *
+ *	For more information see Universal Serial Bus Specification Revision 1.1 chapter 11.16.2
+ */
+typedef enum {
+    /**	This request resets a value reported in the hub status.	*/
+    USB_HUB_REQ_TYPE_CLEAR_HUB_FEATURE = 0x20,
+    /** This request resets a value reported in the port status. */
+    USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE = 0x23,
+    /** This is an optional per-port diagnostic request that returns the bus state value, as sampled at the last EOF2 point. */
+    USB_HUB_REQ_TYPE_GET_STATE = 0xA3,
+    /** This request returns the hub descriptor. */
+    USB_HUB_REQ_TYPE_GET_DESCRIPTOR = 0xA0,
+    /** This request returns the current hub status and the states that have changed since the previous acknowledgment. */
+    USB_HUB_REQ_TYPE_GET_HUB_STATUS = 0xA0,
+    /** This request returns the current port status and the current value of the port status change bits. */
+    USB_HUB_REQ_TYPE_GET_PORT_STATUS = 0xA3,
+    /** This request overwrites the hub descriptor. */
+    USB_HUB_REQ_TYPE_SET_DESCRIPTOR = 0x20,
+    /** This request sets a value reported in the hub status. */
+    USB_HUB_REQ_TYPE_SET_HUB_FEATURE = 0x20,
+    /** This request sets a value reported in the port status. */
+    USB_HUB_REQ_TYPE_SET_PORT_FEATURE = 0x23
+} usb_hub_bm_request_type_t;
+
+/** @brief hub class request codes*/
+typedef enum {
+    /**  */
+    USB_HUB_REQUEST_GET_STATUS = 0,
+    /** */
+    USB_HUB_REQUEST_CLEAR_FEATURE = 1,
+    /** */
+    USB_HUB_REQUEST_GET_STATE = 2,
+    /** */
+    USB_HUB_REQUEST_SET_FEATURE = 3,
+    /** */
+    USB_HUB_REQUEST_GET_DESCRIPTOR = 6,
+    /** */
+    USB_HUB_REQUEST_SET_DESCRIPTOR = 7
+} usb_hub_request_t;
+
+
+
+
+
 #endif
 /**
Index: uspace/lib/usb/src/hcdhubd.c
===================================================================
--- uspace/lib/usb/src/hcdhubd.c	(revision 8cd1aa5eb727edb7e57c0b5429631ef51ff14d2e)
+++ uspace/lib/usb/src/hcdhubd.c	(revision 03171de3c5da5094495087ad838f0b49c4ec6188)
@@ -39,4 +39,5 @@
 #include <bool.h>
 #include <errno.h>
+#include <usb/classes/hub.h>
 
 #define USB_HUB_DEVICE_NAME "usbhub"
@@ -57,4 +58,72 @@
 };
 
+size_t USB_HUB_MAX_DESCRIPTOR_SIZE = 71;
+
+uint8_t USB_HUB_DESCRIPTOR_TYPE = 0x29;
+
+//*********************************************
+//
+//  various utils
+//
+//*********************************************
+
+
+void * usb_serialize_hub_descriptor(usb_hub_descriptor_t * descriptor){
+	//base size
+	size_t size = 7;
+	//variable size according to port count
+	size_t var_size = descriptor->ports_count / 8 + ((descriptor->ports_count % 8>0)?1:0);
+	size += 2 * var_size;
+	uint8_t * result = (uint8_t*) malloc(size);
+	//size
+	result[0]=size;
+	//descriptor type
+	result[1]=USB_HUB_DESCRIPTOR_TYPE;
+	result[2]=descriptor->ports_count;
+	/// @fixme handling of endianness??
+	result[3]=descriptor->hub_characteristics / 256;
+	result[4]=descriptor->hub_characteristics % 256;
+	result[5]=descriptor->pwr_on_2_good_time;
+	result[6]=descriptor->current_requirement;
+
+        size_t i;
+	for(i=0;i<var_size;++i){
+		result[7+i]=descriptor->devices_removable[i];
+	}
+	for(i=0;i<var_size;++i){
+		result[7+var_size+i]=255;
+	}
+	return result;
+}
+
+usb_hub_descriptor_t * usb_deserialize_hub_desriptor(void * serialized_descriptor){
+        uint8_t * sdescriptor = (uint8_t*)serialized_descriptor;
+	if(sdescriptor[1]!=USB_HUB_DESCRIPTOR_TYPE) return NULL;
+	usb_hub_descriptor_t * result = (usb_hub_descriptor_t*) malloc(sizeof(usb_hub_descriptor_t));
+	//uint8_t size = sdescriptor[0];
+	result->ports_count = sdescriptor[2];
+	/// @fixme handling of endianness??
+	result->hub_characteristics = sdescriptor[4] + 256 * sdescriptor[3];
+	result->pwr_on_2_good_time=sdescriptor[5];
+	result->current_requirement=sdescriptor[6];
+	size_t var_size = result->ports_count / 8 + ((result->ports_count % 8>0)?1:0);
+	result->devices_removable = (uint8_t*)malloc(var_size);
+
+        size_t i;
+	for(i=0;i<var_size;++i){
+		result->devices_removable[i] = sdescriptor[7+i];
+	}
+	return result;
+}
+
+
+//*********************************************
+//
+//  hub driver code
+//
+//*********************************************
+
+
+
 static void set_hub_address(usb_hc_device_t *hc, usb_address_t address);
 
@@ -62,5 +131,5 @@
  *
  * @param dev New device.
- * @return Error code.
+ * @return Error code.hub added, hurrah!\n"
  */
 static int add_device(device_t *dev)
@@ -109,4 +178,12 @@
 		 * connected devices.
 		 */
+                //insert hub into list
+                //find owner hcd
+                device_t * my_hcd = dev;
+                while(my_hcd->parent)
+                    my_hcd = my_hcd->parent;
+                //dev->
+                printf("%s: owner hcd found: %s\n",hc_driver->name, my_hcd->name);
+
 
 		return ENOTSUP;
