Index: uspace/lib/libc/generic/devman.c
===================================================================
--- uspace/lib/libc/generic/devman.c	(revision 7707954c8462caa1ddf08a7f529ad43f26141e2c)
+++ uspace/lib/libc/generic/devman.c	(revision bda60d956a93a1fe2c05dbb02aabd00c3d081874)
@@ -106,5 +106,6 @@
 }
 
-int devman_child_device_register(const char *name, long parent_handle, long *handle)
+int devman_child_device_register(
+	const char *name, match_id_list_t *match_ids, device_handle_t parent_handle, device_handle_t *handle)
 {	
 	int phone = devman_get_phone(DEVMAN_DRIVER, IPC_FLAG_BLOCKING);
@@ -124,4 +125,6 @@
 		return retval;
 	}
+	
+	// TODO match ids
 	
 	async_wait_for(req, &retval);
Index: uspace/lib/libc/include/devman.h
===================================================================
--- uspace/lib/libc/include/devman.h	(revision 7707954c8462caa1ddf08a7f529ad43f26141e2c)
+++ uspace/lib/libc/include/devman.h	(revision bda60d956a93a1fe2c05dbb02aabd00c3d081874)
@@ -46,5 +46,5 @@
 
 int devman_driver_register(const char *, async_client_conn_t);
-int devman_child_device_register(const char *name, long parent_handle, long *handle);
+int devman_child_device_register(const char *, match_id_list_t *, device_handle_t, device_handle_t *);
 
 
Index: uspace/lib/libc/include/ipc/devman.h
===================================================================
--- uspace/lib/libc/include/ipc/devman.h	(revision 7707954c8462caa1ddf08a7f529ad43f26141e2c)
+++ uspace/lib/libc/include/ipc/devman.h	(revision bda60d956a93a1fe2c05dbb02aabd00c3d081874)
@@ -34,7 +34,82 @@
 #define LIBC_IPC_DEVMAN_H_
 
+#include <adt/list.h>
 #include <ipc/ipc.h>
+#include <stdlib.h>
+#include <string.h>
 
 #define DEVMAN_NAME_MAXLEN 256
+
+typedef ipcarg_t device_handle_t;
+
+/** Ids of device models used for device-to-driver matching.
+ */
+typedef struct match_id {
+	/** Pointers to next and previous ids.
+	 */
+	link_t link;
+	/** Id of device model.
+	 */
+	const char *id;
+	/** Relevancy of device-to-driver match.
+	 * The higher is the product of scores specified for the device by the bus driver and by the leaf driver,
+	 * the more suitable is the leaf driver for handling the device.
+	 */
+	unsigned int score;
+} match_id_t;
+
+/** List of ids for matching devices to drivers sorted
+ * according to match scores in descending order.
+ */
+typedef struct match_id_list {
+	link_t ids;
+} match_id_list_t;
+
+
+static inline match_id_t * create_match_id()
+{
+	match_id_t *id = malloc(sizeof(match_id_t));
+	memset(id, 0, sizeof(match_id_t));
+	return id;
+}
+
+static inline void delete_match_id(match_id_t *id)
+{
+	if (id) {
+		if (NULL != id->id) {
+			free(id->id);
+		}
+		free(id);
+	}
+}
+
+static inline void add_match_id(match_id_list_t *ids, match_id_t *id) 
+{
+	match_id_t *mid = NULL;
+	link_t *link = ids->ids.next;	
+	
+	while (link != &ids->ids) {
+		mid = list_get_instance(link, match_id_t,link);
+		if (mid->score < id->score) {
+			break;
+		}	
+		link = link->next;
+	}
+	
+	list_insert_before(&id->link, link);	
+}
+
+static inline void clean_match_ids(match_id_list_t *ids)
+{
+	link_t *link = NULL;
+	match_id_t *id;
+	
+	while(!list_empty(&ids->ids)) {
+		link = ids->ids.next;
+		list_remove(link);		
+		id = list_get_instance(link, match_id_t, link);
+		delete_match_id(id);		
+	}	
+}
 
 typedef enum {
Index: uspace/lib/libdrv/generic/driver.c
===================================================================
--- uspace/lib/libdrv/generic/driver.c	(revision 7707954c8462caa1ddf08a7f529ad43f26141e2c)
+++ uspace/lib/libdrv/generic/driver.c	(revision bda60d956a93a1fe2c05dbb02aabd00c3d081874)
@@ -72,5 +72,5 @@
 	// result of the operation - device was added, device is not present etc.
 	ipcarg_t ret = 0;	
-	ipcarg_t dev_handle =  IPC_GET_ARG1(*icall);
+	device_handle_t dev_handle =  IPC_GET_ARG1(*icall);
 	
 	printf("%s: adding device with handle = %x \n", driver->name, dev_handle);
@@ -109,6 +109,5 @@
 				ipc_answer_0(callid, ENOENT);
 		}
-	}
-	
+	}	
 }
 
@@ -150,7 +149,11 @@
 }
 
-bool child_device_register(device_t *child, const char *child_name, device_t *parent)
+bool child_device_register(device_t *child, device_t *parent)
 {
-	if (devman_child_device_register(child_name, parent->handle, &child->handle)) {
+	printf("%s: child_device_register\n", driver->name);
+	
+	assert(NULL != child->name);
+	
+	if (devman_child_device_register(child->name, &child->match_ids, parent->handle, &child->handle)) {
 		// TODO initialize child device
 		return true;
Index: uspace/lib/libdrv/include/driver.h
===================================================================
--- uspace/lib/libdrv/include/driver.h	(revision 7707954c8462caa1ddf08a7f529ad43f26141e2c)
+++ uspace/lib/libdrv/include/driver.h	(revision bda60d956a93a1fe2c05dbb02aabd00c3d081874)
@@ -37,8 +37,11 @@
 
 #include <adt/list.h>
+#include <ipc/devman.h>
 
 typedef struct device {
-	long handle;
+	device_handle_t handle;
 	ipcarg_t parent_phone;	
+	const char *name;
+	match_id_list_t match_ids;
 	
 	// TODO add more items - parent bus type etc.
@@ -64,11 +67,18 @@
 	if (NULL != dev) {
 		memset(dev, 0, sizeof(device_t));
-	}
-	
+	}	
+	list_initialize(&dev->match_ids.ids);
 	return dev;
 }
 
-bool child_device_register(device_t *child, const char *child_name, device_t *parent);
+static inline delete_device(device_t *dev) {
+	clean_match_ids(&dev->match_ids);
+	if (NULL != dev->name) {
+		free(dev->name);
+	}
+	free(dev);
+}
 
+bool child_device_register(device_t *child, device_t *parent);
 
 
Index: uspace/srv/devman/devman.c
===================================================================
--- uspace/srv/devman/devman.c	(revision 7707954c8462caa1ddf08a7f529ad43f26141e2c)
+++ uspace/srv/devman/devman.c	(revision bda60d956a93a1fe2c05dbb02aabd00c3d081874)
@@ -320,5 +320,5 @@
 	node_t *node = create_dev_node();
 	if (node) {
-		insert_dev_node(tree, node, NULL);
+		insert_dev_node(tree, node, "", NULL);
 		match_id_t *id = create_match_id();
 		id->id = "root";
@@ -410,4 +410,10 @@
 }
 
+/** Find device driver in the list of device drivers.
+ * 
+ * @param drv_list the list of device drivers.
+ * @param drv_name the name of the device driver which is searched.
+ * @return the device driver of the specified name, if it is in the list, NULL otherwise.  
+ */
 driver_t * find_driver(driver_list_t *drv_list, const char *drv_name) 
 {	
@@ -432,4 +438,8 @@
 }
 
+/** Remember the driver's phone.
+ * @param driver the driver.
+ * @param phone the phone to the driver.
+ */
 void set_driver_phone(driver_t *driver, ipcarg_t phone)
 {		
@@ -467,5 +477,6 @@
 }
 
-/** Finish the initialization of a driver after it has succesfully started and registered itself by the device manager.
+/** Finish the initialization of a driver after it has succesfully started 
+ * and after it has registered itself by the device manager.
  * 
  * Pass devices formerly matched to the driver to the driver and remember the driver is running and fully functional now.
@@ -559,4 +570,6 @@
 	printf(NAME ": init_device_tree.\n");
 	
+	memset(tree->node_map, 0, MAX_DEV * sizeof(node_t *));
+	
 	atomic_set(&tree->current_handle, 0);
 	
@@ -570,4 +583,75 @@
 }
 
+/** Create and set device's full path in device tree.
+ * 
+ * @param node the device's device node.
+ * @param parent the parent device node.
+ * @return true on success, false otherwise (insufficient resources etc.). 
+ */
+static bool set_dev_path(node_t *node, node_t *parent)
+{	
+	assert(NULL != node->name);
+	
+	size_t pathsize = (str_size(node->name) + 1);	
+	if (NULL != parent) {		
+		pathsize += str_size(parent->name) + 1;		
+	}
+	
+	if (NULL == (node->pathname = (char *)malloc(pathsize))) {
+		printf(NAME ": failed to allocate device path.\n");
+		return false;
+	}
+	
+	if (NULL != parent) {
+		str_cpy(node->pathname, pathsize, parent->pathname);
+		str_append(node->pathname, pathsize, "/");
+		str_append(node->pathname, pathsize, node->name);
+	} else {
+		str_cpy(node->pathname, pathsize, node->name);
+	}
+	
+	return true;
+}
+
+/** Insert new device into device tree.
+ * 
+ * @param tree the device tree.
+ * @param node the newly added device node. 
+ * @param dev_name the name of the newly added device.
+ * @param parent the parent device node.
+ * @return true on success, false otherwise (insufficient resources etc.).
+ */
+bool insert_dev_node(dev_tree_t *tree, node_t *node, const char *dev_name, node_t *parent)
+{
+	printf(NAME ": insert_dev_node\n");
+	
+	assert(NULL != node && NULL != tree && dev_name != NULL);
+	
+	node->name = dev_name;
+	if (!set_dev_path(node, parent)) {
+		return false;		
+	}
+	
+	// add the node to the handle-to-node map
+	node->handle = atomic_postinc(&tree->current_handle);
+	if (node->handle >= MAX_DEV) {
+		printf(NAME ": failed to add device to device tree, because maximum number of devices was reached.\n");
+		free(node->pathname);
+		node->pathname = NULL;
+		atomic_postdec(&tree->current_handle);
+		return false;
+	}
+	tree->node_map[node->handle] = node;
+
+	// add the node to the list of its parent's children
+	node->parent = parent;
+	if (NULL != parent) {
+		fibril_mutex_lock(&parent->children_mutex);
+		list_append(&node->sibling, &parent->children);
+		fibril_mutex_unlock(&parent->children_mutex);
+	}	
+	return true;
+}
+
 /** @}
  */
Index: uspace/srv/devman/devman.h
===================================================================
--- uspace/srv/devman/devman.h	(revision 7707954c8462caa1ddf08a7f529ad43f26141e2c)
+++ uspace/srv/devman/devman.h	(revision bda60d956a93a1fe2c05dbb02aabd00c3d081874)
@@ -40,4 +40,5 @@
 #include <adt/list.h>
 #include <ipc/ipc.h>
+#include <ipc/devman.h>
 #include <fibril_synch.h>
 #include <atomic.h>
@@ -48,31 +49,9 @@
 
 #define MATCH_EXT ".ma"
+#define MAX_DEV 256
 
 struct node;
 
 typedef struct node node_t;
-
-/** Ids of device models used for device-to-driver matching.
- */
-typedef struct match_id {
-	/** Pointers to next and previous ids.
-	 */
-	link_t link;
-	/** Id of device model.
-	 */
-	const char *id;
-	/** Relevancy of device-to-driver match.
-	 * The higher is the product of scores specified for the device by the bus driver and by the leaf driver,
-	 * the more suitable is the leaf driver for handling the device.
-	 */
-	unsigned int score;
-} match_id_t;
-
-/** List of ids for matching devices to drivers sorted
- * according to match scores in descending order.
- */
-typedef struct match_id_list {
-	link_t ids;
-} match_id_list_t;
 
 typedef enum {
@@ -117,5 +96,9 @@
 struct node {
 	/** The global unique identifier of the device.*/
-	long handle;
+	device_handle_t handle;
+	/** The name of the device specified by its parent. */
+	char *name;
+	/** Full path and name of the device in device hierarchi (i. e. in full path in device tree).*/
+	char *pathname;	
 	/** The node of the parent device. */
 	node_t *parent;
@@ -140,5 +123,8 @@
 	/** Root device node. */
 	node_t *root_node;
+	/** The next available handle - handles are assigned in a sequential manner.*/
 	atomic_t current_handle;
+	/** Handle-to-node mapping. */
+	node_t * node_map[MAX_DEV];
 } dev_tree_t;
 
@@ -152,27 +138,4 @@
 bool read_match_ids(const char *conf_path, match_id_list_t *ids);
 char * read_id(const char **buf) ;
-void add_match_id(match_id_list_t *ids, match_id_t *id);
-
-void clean_match_ids(match_id_list_t *ids);
-
-
-static inline match_id_t * create_match_id()
-{
-	match_id_t *id = malloc(sizeof(match_id_t));
-	memset(id, 0, sizeof(match_id_t));
-	return id;
-}
-
-static inline void delete_match_id(match_id_t *id)
-{
-	if (id) {
-		free_not_null(id->id);
-		free(id);
-	}
-}
-
-
-
-
 
 // Drivers
@@ -248,18 +211,11 @@
 }
 
-static inline void insert_dev_node(dev_tree_t *tree, node_t *node, node_t *parent)
-{
-	assert(NULL != node && NULL != tree);
-	
-	node->handle = atomic_postinc(&tree->current_handle);
-
-	node->parent = parent;
-	if (NULL != parent) {
-		fibril_mutex_lock(&parent->children_mutex);
-		list_append(&node->sibling, &parent->children);
-		fibril_mutex_unlock(&parent->children_mutex);
+static inline node_t * find_dev_node(dev_tree_t *tree, long handle)
+{
+	if (handle < MAX_DEV) {
+		return tree->node_map[handle];
 	}
-}
-
+	return NULL;
+}
 
 // Device tree
@@ -267,5 +223,5 @@
 bool init_device_tree(dev_tree_t *tree, driver_list_t *drivers_list);
 bool create_root_node(dev_tree_t *tree);
-
+bool insert_dev_node(dev_tree_t *tree, node_t *node, const char *dev_name, node_t *parent);
 
 #endif
Index: uspace/srv/devman/main.c
===================================================================
--- uspace/srv/devman/main.c	(revision 7707954c8462caa1ddf08a7f529ad43f26141e2c)
+++ uspace/srv/devman/main.c	(revision bda60d956a93a1fe2c05dbb02aabd00c3d081874)
@@ -120,4 +120,12 @@
 }
 
+static void devman_add_child(ipc_callid_t callid, ipc_call_t *call, driver_t *driver)
+{
+	printf(NAME ": devman_add_child\n");
+	
+	// TODO
+	
+}
+
 /** Function for handling connections to device manager.
  *
@@ -145,5 +153,5 @@
 			continue;
 		case DEVMAN_ADD_CHILD_DEVICE:
-			// TODO add new device node to the device tree
+			devman_add_child(callid, &call, driver);
 			break;
 		default:
Index: uspace/srv/devman/match.c
===================================================================
--- uspace/srv/devman/match.c	(revision 7707954c8462caa1ddf08a7f529ad43f26141e2c)
+++ uspace/srv/devman/match.c	(revision bda60d956a93a1fe2c05dbb02aabd00c3d081874)
@@ -89,31 +89,4 @@
 }
 
-void add_match_id(match_id_list_t *ids, match_id_t *id) 
-{
-	match_id_t *mid = NULL;
-	link_t *link = ids->ids.next;	
-	
-	while (link != &ids->ids) {
-		mid = list_get_instance(link, match_id_t,link);
-		if (mid->score < id->score) {
-			break;
-		}	
-		link = link->next;
-	}
-	
-	list_insert_before(&id->link, link);	
-}
 
-void clean_match_ids(match_id_list_t *ids)
-{
-	link_t *link = NULL;
-	match_id_t *id;
-	
-	while(!list_empty(&ids->ids)) {
-		link = ids->ids.next;
-		list_remove(link);		
-		id = list_get_instance(link, match_id_t, link);
-		delete_match_id(id);		
-	}	
-}
 
Index: uspace/srv/drivers/root/root.c
===================================================================
--- uspace/srv/drivers/root/root.c	(revision 7707954c8462caa1ddf08a7f529ad43f26141e2c)
+++ uspace/srv/drivers/root/root.c	(revision bda60d956a93a1fe2c05dbb02aabd00c3d081874)
@@ -44,4 +44,5 @@
 #include <string.h>
 #include <ctype.h>
+#include <macros.h>
 
 #include <driver.h>
@@ -63,8 +64,56 @@
 };
 
+static bool add_platform_child(device_t *parent) {
+	printf(NAME ": adding new child for platform device.\n");
+	
+	device_t *platform = NULL;
+	match_id_t *match_id = NULL;	
+	
+	// create new device
+	if (NULL == (platform = create_device())) {
+		goto failure;
+	}
+	
+	// TODO - replace this with some better solution
+	platform->name = STRING(UARCH);
+	printf(NAME ": the new device's name is %s.\n", platform->name);
+	
+	// initialize match id list
+	if (NULL == (match_id = create_match_id())) {
+		goto failure;
+	}
+	match_id->id = platform->name;
+	match_id->score = 100;
+	add_match_id(&platform->match_ids, match_id);	
+	
+	// register child  device
+	if (!child_device_register(platform, parent)) {
+		goto failure;
+	}
+	
+	return true;
+	
+failure:
+	if (NULL != match_id) {
+		match_id->id = NULL;
+	}
+	
+	if (NULL != platform) {
+		platform->name = NULL;
+		delete_device(platform);		
+	}
+	
+	return false;	
+}
+
 static bool root_add_device(device_t *dev) 
 {
-	printf(NAME ": root_add_device, device handle = %s", dev->handle);
-	// TODO add root device and register its children
+	printf(NAME ": root_add_device, device handle = %d\n", dev->handle);
+	
+	// register root device's children	
+	if (!add_platform_child(dev)) {
+		return false;
+	}
+	
 	return true;
 }
@@ -90,2 +139,3 @@
  * @}
  */
+ 
