Index: uspace/lib/usb/include/usb/classes/hub.h
===================================================================
--- uspace/lib/usb/include/usb/classes/hub.h	(revision b12d3cc3ff8f0ff3656ec8964938909a8bb0ad7a)
+++ uspace/lib/usb/include/usb/classes/hub.h	(revision da55d5bda3670c3ce6e950da9d75291d0635e5a7)
@@ -37,4 +37,5 @@
 
 #include <sys/types.h>
+#include <usb/hcdhubd.h>
 
 
@@ -148,29 +149,5 @@
 } 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.
@@ -215,4 +192,33 @@
 } usb_hub_request_t;
 
+/**
+ *	Maximum size of usb hub descriptor in bytes
+ */
+extern size_t USB_HUB_MAX_DESCRIPTOR_SIZE;
+
+/**
+ * @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 create hub structure instance
+ * 
+ * @param device
+ * @return
+ */
+usb_hcd_hub_info_t * usb_create_hub_info(device_t * device);
+
 
 
Index: uspace/lib/usb/src/hcdhubd.c
===================================================================
--- uspace/lib/usb/src/hcdhubd.c	(revision b12d3cc3ff8f0ff3656ec8964938909a8bb0ad7a)
+++ uspace/lib/usb/src/hcdhubd.c	(revision da55d5bda3670c3ce6e950da9d75291d0635e5a7)
@@ -36,4 +36,5 @@
 #include <usb/devreq.h>
 #include <usbhc_iface.h>
+#include <usb/descriptor.h>
 #include <driver.h>
 #include <bool.h>
@@ -42,4 +43,9 @@
 
 #define USB_HUB_DEVICE_NAME "usbhub"
+
+#define USB_KBD_DEVICE_NAME "hid"
+
+
+
 
 /** List of handled host controllers. */
@@ -68,49 +74,48 @@
 //*********************************************
 
-
-void * usb_serialize_hub_descriptor(usb_hub_descriptor_t * descriptor){
+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_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;
+	result[0] = size;
 	//descriptor type
-	result[1]=USB_HUB_DESCRIPTOR_TYPE;
-	result[2]=descriptor->ports_count;
+	result[1] = USB_DESCTYPE_HUB;
+	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;
+	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));
+usb_hub_descriptor_t * usb_deserialize_hub_desriptor(void * serialized_descriptor) {
+	uint8_t * sdescriptor = (uint8_t*) serialized_descriptor;
+	if (sdescriptor[1] != USB_DESCTYPE_HUB) 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];
+	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;
@@ -124,7 +129,24 @@
 //*********************************************
 
-
-
 static void set_hub_address(usb_hc_device_t *hc, usb_address_t address);
+
+usb_hcd_hub_info_t * usb_create_hub_info(device_t * device) {
+	usb_hcd_hub_info_t* result = (usb_hcd_hub_info_t*) malloc(sizeof (usb_hcd_hub_info_t));
+	//get parent device
+	/// @TODO this code is not correct
+	device_t * my_hcd = device;
+	while (my_hcd->parent)
+		my_hcd = my_hcd->parent;
+	//dev->
+	printf("%s: owner hcd found: %s\n", hc_driver->name, my_hcd->name);
+	//we add the hub into the first hc
+	//link_t *link_hc = hc_list.next;
+	//usb_hc_device_t *hc = list_get_instance(link_hc,
+	//		usb_hc_device_t, link);
+	//must get generic device info
+
+
+	return result;
+}
 
 /** Callback when new device is detected and must be handled by this driver.
@@ -133,6 +155,5 @@
  * @return Error code.hub added, hurrah!\n"
  */
-static int add_device(device_t *dev)
-{
+static int add_device(device_t *dev) {
 	/*
 	 * FIXME: use some magic to determine whether hub or another HC
@@ -146,5 +167,5 @@
 		 * We are the HC itself.
 		 */
-		usb_hc_device_t *hc_dev = malloc(sizeof(usb_hc_device_t));
+		usb_hc_device_t *hc_dev = malloc(sizeof (usb_hc_device_t));
 		list_initialize(&hc_dev->link);
 		hc_dev->transfer_ops = NULL;
@@ -168,5 +189,47 @@
 		list_append(&hc_dev->link, &hc_list);
 
+		//add keyboard
+		/// @TODO this is not correct code
+		
+		/*
+		 * Announce presence of child device.
+		 */
+		device_t *kbd = NULL;
+		match_id_t *match_id = NULL;
+
+		kbd = create_device();
+		if (kbd == NULL) {
+			printf("ERROR: enomem\n");
+		}
+		kbd->name = USB_KBD_DEVICE_NAME;
+
+		match_id = create_match_id();
+		if (match_id == NULL) {
+			printf("ERROR: enomem\n");
+		}
+
+		char *id;
+		rc = asprintf(&id, USB_KBD_DEVICE_NAME);
+		if (rc <= 0) {
+			printf("ERROR: enomem\n");
+			return rc;
+		}
+
+		match_id->id = id;
+		match_id->score = 30;
+
+		add_match_id(&kbd->match_ids, match_id);
+
+		rc = child_device_register(kbd, dev);
+		if (rc != EOK) {
+			printf("ERROR: cannot register kbd\n");
+			return rc;
+		}
+
+		printf("%s: registered root hub\n", dev->name);
 		return EOK;
+
+
+
 	} else {
 		usb_hc_device_t *hc = list_get_instance(hc_list.next, usb_hc_device_t, link);
@@ -178,14 +241,30 @@
 		 * 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;
+		//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);
+		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);
+		
+		//create the hub structure
+		usb_hcd_hub_info_t * hub_info = usb_create_hub_info(dev);
+
+
+		//append into the list
+		//we add the hub into the first hc
+		list_append(&hub_info->link, &hc->hubs);
+
+
+
+		return EOK;
+		//return ENOTSUP;
 	}
 }
@@ -200,6 +279,5 @@
  * @param address New hub address.
  */
-static void set_hub_address(usb_hc_device_t *hc, usb_address_t address)
-{
+static void set_hub_address(usb_hc_device_t *hc, usb_address_t address) {
 	printf("%s: setting hub address to %d\n", hc->generic->name, address);
 	usb_target_t target = {0, 0};
@@ -216,5 +294,5 @@
 
 	rc = usb_hc_async_control_write_setup(hc, target,
-	    &setup_packet, sizeof(setup_packet), &handle);
+			&setup_packet, sizeof (setup_packet), &handle);
 	if (rc != EOK) {
 		return;
@@ -241,6 +319,5 @@
 /** Check changes on all known hubs.
  */
-static void check_hub_changes(void)
-{
+static void check_hub_changes(void) {
 	/*
 	 * Iterate through all HCs.
@@ -248,8 +325,8 @@
 	link_t *link_hc;
 	for (link_hc = hc_list.next;
-	    link_hc != &hc_list;
-	    link_hc = link_hc->next) {
+			link_hc != &hc_list;
+			link_hc = link_hc->next) {
 		usb_hc_device_t *hc = list_get_instance(link_hc,
-		    usb_hc_device_t, link);
+				usb_hc_device_t, link);
 		/*
 		 * Iterate through all their hubs.
@@ -257,8 +334,8 @@
 		link_t *link_hub;
 		for (link_hub = hc->hubs.next;
-		    link_hub != &hc->hubs;
-		    link_hub = link_hub->next) {
+				link_hub != &hc->hubs;
+				link_hub = link_hub->next) {
 			usb_hcd_hub_info_t *hub = list_get_instance(link_hub,
-			    usb_hcd_hub_info_t, link);
+					usb_hcd_hub_info_t, link);
 
 			/*
@@ -282,6 +359,6 @@
 			 */
 			usb_hc_async_interrupt_in(hc, target,
-			    change_bitmap, byte_length, &actual_size,
-			    &handle);
+					change_bitmap, byte_length, &actual_size,
+					&handle);
 
 			usb_hc_async_wait_for(handle);
@@ -311,6 +388,5 @@
  * @return Error code.
  */
-int usb_hcd_main(usb_hc_driver_t *hc)
-{
+int usb_hcd_main(usb_hc_driver_t *hc) {
 	hc_driver = hc;
 	hc_driver_generic.name = hc->name;
@@ -338,6 +414,5 @@
  * @return Error code.
  */
-int usb_hcd_add_root_hub(usb_hc_device_t *dev)
-{
+int usb_hcd_add_root_hub(usb_hc_device_t *dev) {
 	int rc;
 
