Index: .bzrignore
===================================================================
--- .bzrignore	(revision bda60d956a93a1fe2c05dbb02aabd00c3d081874)
+++ .bzrignore	(revision d347b53724c4a93926208e7fb3b0f34111cebc47)
@@ -1,1 +1,2 @@
 HelenOS.sparc64.simics
+make_settings
Index: uspace/lib/libc/generic/devman.c
===================================================================
--- uspace/lib/libc/generic/devman.c	(revision bda60d956a93a1fe2c05dbb02aabd00c3d081874)
+++ uspace/lib/libc/generic/devman.c	(revision d347b53724c4a93926208e7fb3b0f34111cebc47)
@@ -108,5 +108,5 @@
 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);
 	
Index: uspace/lib/libdrv/generic/driver.c
===================================================================
--- uspace/lib/libdrv/generic/driver.c	(revision bda60d956a93a1fe2c05dbb02aabd00c3d081874)
+++ uspace/lib/libdrv/generic/driver.c	(revision d347b53724c4a93926208e7fb3b0f34111cebc47)
@@ -72,8 +72,5 @@
 	// result of the operation - device was added, device is not present etc.
 	ipcarg_t ret = 0;	
-	device_handle_t dev_handle =  IPC_GET_ARG1(*icall);
-	
-	printf("%s: adding device with handle = %x \n", driver->name, dev_handle);
-	
+	device_handle_t dev_handle =  IPC_GET_ARG1(*icall);	
 	device_t *dev = driver_create_device();
 	dev->handle = dev_handle;
@@ -82,6 +79,7 @@
 		// TODO set return value
 	}
+	printf("%s: new device with handle = %x was added.\n", driver->name, dev_handle);
 	
-	ipc_answer_1(iid, EOK, ret);
+	ipcarg_t r = ipc_answer_1(iid, EOK, ret);
 }
 
@@ -168,5 +166,4 @@
 	
 	// register driver by device manager with generic handler for incoming connections
-	printf("%s: sending registration request to devman.\n", driver->name);
 	devman_driver_register(driver->name, driver_connection);		
 
Index: uspace/srv/devman/devman.c
===================================================================
--- uspace/srv/devman/devman.c	(revision bda60d956a93a1fe2c05dbb02aabd00c3d081874)
+++ uspace/srv/devman/devman.c	(revision d347b53724c4a93926208e7fb3b0f34111cebc47)
@@ -233,6 +233,4 @@
 	}	
 	
-	printf(NAME ": get_driver_info - path to match id list = %s.\n", match_path);
-	
 	if (!read_match_ids(match_path, &drv->match_ids)) {
 		goto cleanup;
@@ -284,5 +282,5 @@
 int lookup_available_drivers(driver_list_t *drivers_list, const char *dir_path)
 {
-	printf(NAME ": lookup_available_drivers \n");
+	printf(NAME ": lookup_available_drivers, dir = %s \n", dir_path);
 	
 	int drv_cnt = 0;
@@ -291,9 +289,7 @@
 
 	dir = opendir(dir_path);
-	printf(NAME ": lookup_available_drivers has opened directory %s for driver search.\n", dir_path);
 	
 	if (dir != NULL) {
 		driver_t *drv = create_driver();
-		printf(NAME ": lookup_available_drivers has created driver structure.\n");
 		while ((diren = readdir(dir))) {			
 			if (get_driver_info(dir_path, diren->d_name, drv)) {
@@ -345,5 +341,5 @@
 driver_t * find_best_match_driver(driver_list_t *drivers_list, node_t *node)
 {
-	printf(NAME ": find_best_match_driver\n");
+	printf(NAME ": find_best_match_driver for device '%s' \n", node->pathname);
 	driver_t *best_drv = NULL, *drv = NULL;
 	int best_score = 0, score = 0;
@@ -392,9 +388,7 @@
 bool start_driver(driver_t *drv)
 {
-	printf(NAME ": start_driver\n");
+	printf(NAME ": start_driver '%s'\n", drv->name);
 	
 	char *argv[2];
-	
-	printf(NAME ": spawning driver %s\n", drv->name);
 	
 	argv[0] = drv->name;
@@ -459,4 +453,5 @@
 static void pass_devices_to_driver(driver_t *driver)
 {	
+	printf(NAME ": pass_devices_to_driver\n");
 	node_t *dev;
 	link_t *link;
@@ -486,4 +481,5 @@
 void initialize_running_driver(driver_t *driver) 
 {	
+	printf(NAME ": initialize_running_driver\n");
 	fibril_mutex_lock(&driver->driver_mutex);
 	
@@ -533,5 +529,5 @@
 	driver_t *drv = find_best_match_driver(drivers_list, node);
 	if (NULL == drv) {
-		printf(NAME ": no driver found for device.\n"); 
+		printf(NAME ": no driver found for device '%s'.\n", node->pathname); 
 		return false;		
 	}
@@ -626,5 +622,5 @@
 	printf(NAME ": insert_dev_node\n");
 	
-	assert(NULL != node && NULL != tree && dev_name != NULL);
+	assert(NULL != node && NULL != tree && NULL != dev_name);
 	
 	node->name = dev_name;
Index: uspace/srv/devman/devman.h
===================================================================
--- uspace/srv/devman/devman.h	(revision bda60d956a93a1fe2c05dbb02aabd00c3d081874)
+++ uspace/srv/devman/devman.h	(revision d347b53724c4a93926208e7fb3b0f34111cebc47)
@@ -141,4 +141,10 @@
 // Drivers
 
+/** 
+ * Initialize the list of device driver's.
+ * 
+ * @param drv_list the list of device driver's.
+ * 
+ */
 static inline void init_driver_list(driver_list_t *drv_list) 
 {
@@ -165,5 +171,10 @@
 void initialize_running_driver(driver_t *driver);
 
-
+/** 
+ * Initialize device driver structure.
+ * 
+ * @param drv the device driver structure.
+ * 
+ */
 static inline void init_driver(driver_t *drv)
 {
@@ -176,4 +187,9 @@
 }
 
+/**
+ * Device driver structure clean-up.
+ * 
+ * @param drv the device driver structure. 
+ */
 static inline void clean_driver(driver_t *drv)
 {
@@ -188,4 +204,9 @@
 }
 
+/**
+ * Delete device driver structure.
+ * 
+ *  @param drv the device driver structure.* 
+ */
 static inline void delete_driver(driver_t *drv)
 {
@@ -197,5 +218,10 @@
 
 // Device nodes
-
+/**
+ * Create a new device node.
+ * 
+ * @return a device node structure.
+ * 
+ */
 static inline node_t * create_dev_node()
 {
@@ -207,8 +233,26 @@
 	list_initialize(&res->children);
 	list_initialize(&res->match_ids.ids);
+	fibril_mutex_initialize(&res->children_mutex);
 	
 	return res;
 }
 
+static inline void delete_dev_node(node_t *node)
+{
+	assert(list_empty(&node->children) && NULL == node->parent && NULL == node->drv);
+	
+	clean_match_ids(&node->match_ids);
+	free_not_null(node->name);
+	free_not_null(node->pathname);
+	free(node);	
+}
+
+/**
+ * Find the device node structure of the device witch has the specified handle.
+ * 
+ * @param tree the device tree where we look for the device node.
+ * @param handle the handle of the device.
+ * @return the device node. 
+ */
 static inline node_t * find_dev_node(dev_tree_t *tree, long handle)
 {
Index: uspace/srv/devman/main.c
===================================================================
--- uspace/srv/devman/main.c	(revision bda60d956a93a1fe2c05dbb02aabd00c3d081874)
+++ uspace/srv/devman/main.c	(revision d347b53724c4a93926208e7fb3b0f34111cebc47)
@@ -51,4 +51,5 @@
 #include <ctype.h>
 #include <ipc/devman.h>
+#include <thread.h>
 
 #include "devman.h"
@@ -96,5 +97,4 @@
 		return NULL;
 	}
-	printf(NAME ": registering the running instance of the %s driver.\n", driver->name);
 	
 	// Create connection to the driver
@@ -123,7 +123,43 @@
 {
 	printf(NAME ": devman_add_child\n");
-	
-	// TODO
-	
+
+	device_handle_t parent_handle = IPC_GET_ARG1(*call);
+	node_t *parent =  find_dev_node(&device_tree, parent_handle);
+	
+	if (NULL == parent) {
+		ipc_answer_0(callid, ENOENT);
+		return;
+	}
+	
+	char *dev_name = NULL;
+	int rc = async_string_receive(&dev_name, DEVMAN_NAME_MAXLEN, NULL);	
+	if (rc != EOK) {
+		ipc_answer_0(callid, rc);
+		return;
+	}
+	printf(NAME ": newly added child device's name is '%s'.\n", dev_name);
+	
+	node_t *node = create_dev_node();
+	if (!insert_dev_node(&device_tree, node, dev_name, parent)) {
+		delete_dev_node(node);
+		ipc_answer_0(callid, ENOMEM);
+		return;
+	}	
+	
+	// TODO match ids
+	
+	// return device handle to parent's driver
+	ipc_answer_1(callid, EOK, node->handle);
+	
+	// try to find suitable driver and assign it to the device	
+	assign_driver(node, &drivers_list);
+}
+
+static int init_running_drv(void *drv)
+{
+	driver_t *driver = (driver_t *)drv;
+	initialize_running_driver(driver);	
+	printf(NAME ": the %s driver was successfully initialized. \n", driver->name);
+	return 0;
 }
 
@@ -137,8 +173,18 @@
 	
 	driver_t *driver = devman_driver_register();
-	if (driver == NULL)
-		return;
-		
-	initialize_running_driver(driver);
+	if (NULL == driver)
+		return;
+	
+	fid_t fid = fibril_create(init_running_drv, driver);
+	if (fid == 0) {
+		printf(NAME ": Error creating fibril for the initialization of the newly registered running driver.\n");
+		exit(1);
+	}
+	fibril_add_ready(fid);
+	
+	/*thread_id_t tid;
+	if (0 != thread_create(init_running_drv, driver, "init_running_drv", &tid)) {
+		printf(NAME ": failed to start the initialization of the newly registered running driver.\n");
+	}*/
 	
 	ipc_callid_t callid;
Index: uspace/srv/drivers/root/root.c
===================================================================
--- uspace/srv/drivers/root/root.c	(revision bda60d956a93a1fe2c05dbb02aabd00c3d081874)
+++ uspace/srv/drivers/root/root.c	(revision d347b53724c4a93926208e7fb3b0f34111cebc47)
@@ -75,5 +75,5 @@
 	}
 	
-	// TODO - replace this with some better solution
+	// TODO - replace this with some better solution (sysinfo ?)
 	platform->name = STRING(UARCH);
 	printf(NAME ": the new device's name is %s.\n", platform->name);
@@ -113,4 +113,5 @@
 	// register root device's children	
 	if (!add_platform_child(dev)) {
+		printf(NAME ": failed to add child device for platform.\n");
 		return false;
 	}
