Index: boot/arch/amd64/Makefile.inc
===================================================================
--- boot/arch/amd64/Makefile.inc	(revision 5cd136abc29be1860cb1f40730725d7f1d76a017)
+++ boot/arch/amd64/Makefile.inc	(revision 9a66bc2ed74a9425386a5a8717ee6155578308a0)
@@ -38,5 +38,6 @@
 RD_DRVS = \
 	root \
-	rootia32
+	rootia32 \
+	pciintel
 
 MODULES := $(notdir $(COMPONENTS))
Index: uspace/Makefile
===================================================================
--- uspace/Makefile	(revision 5cd136abc29be1860cb1f40730725d7f1d76a017)
+++ uspace/Makefile	(revision 9a66bc2ed74a9425386a5a8717ee6155578308a0)
@@ -78,4 +78,5 @@
 	DIRS += srv/dd
 	DIRS += srv/drivers/rootia32
+	DIRS += srv/drivers/pciintel
 #	DIRS += srv/hw/bus/pci
 endif
Index: uspace/lib/libc/generic/device/hw_res.c
===================================================================
--- uspace/lib/libc/generic/device/hw_res.c	(revision 5cd136abc29be1860cb1f40730725d7f1d76a017)
+++ uspace/lib/libc/generic/device/hw_res.c	(revision 9a66bc2ed74a9425386a5a8717ee6155578308a0)
@@ -52,6 +52,5 @@
 	hw_resources->resources = (hw_resource_t *)malloc(size);
 	if (NULL == hw_resources->resources) {
-		size = 0;
-		ret = false;
+		return false;
 	}
 	
@@ -60,8 +59,8 @@
 		free(hw_resources->resources);
 		hw_resources->resources = NULL;
-		ret = false;
+		return false;
 	}
 	 	 
-	return ret;	 
+	return true;	 
 }
 
Index: uspace/lib/libdrv/generic/driver.c
===================================================================
--- uspace/lib/libdrv/generic/driver.c	(revision 5cd136abc29be1860cb1f40730725d7f1d76a017)
+++ uspace/lib/libdrv/generic/driver.c	(revision 9a66bc2ed74a9425386a5a8717ee6155578308a0)
@@ -57,4 +57,5 @@
 static driver_t *driver;
 LIST_INITIALIZE(devices);
+FIBRIL_MUTEX_INITIALIZE(devices_mutex);
 
 static device_t * driver_create_device()
@@ -67,15 +68,33 @@
 }
 
+static void add_to_devices_list(device_t *dev)
+{
+	fibril_mutex_lock(&devices_mutex);
+	list_append(&dev->link, &devices);
+	fibril_mutex_unlock(&devices_mutex);
+}
+
+static void remove_from_devices_list(device_t *dev)
+{
+	fibril_mutex_lock(&devices_mutex);
+	list_append(&dev->link, &devices);
+	fibril_mutex_unlock(&devices_mutex);
+}
+
 static device_t * driver_get_device(link_t *devices, device_handle_t handle)
 {
 	device_t *dev = NULL;
+	
+	fibril_mutex_lock(&devices_mutex);	
 	link_t *link = devices->next;
-
 	while (link != devices) {
 		dev = list_get_instance(link, device_t, link);
 		if (handle == dev->handle) {
+			fibril_mutex_unlock(&devices_mutex);
 			return dev;
 		}
-	}
+		link = link->next;
+	}
+	fibril_mutex_unlock(&devices_mutex);
 
 	return NULL;
@@ -86,15 +105,22 @@
 	printf("%s: driver_add_device\n", driver->name);
 
-	// result of the operation - device was added, device is not present etc.
-	ipcarg_t ret = 0;
+	// TODO device state - the driver may detect the device is not actually present 
+	// (old non PnP devices) or is not working properly. 
+	// We should send such information to device manager.
+	
+	ipcarg_t ret;
 	device_handle_t dev_handle =  IPC_GET_ARG1(*icall);
 	device_t *dev = driver_create_device();
 	dev->handle = dev_handle;
-	if (driver->driver_ops->add_device(dev)) {
-		list_append(&dev->link, &devices);
-		// TODO set return value
-	}
-	printf("%s: new device with handle = %x was added.\n", driver->name, dev_handle);
-
+	add_to_devices_list(dev);
+	if (driver->driver_ops->add_device(dev)) {		
+		printf("%s: new device with handle = %x was added.\n", driver->name, dev_handle);
+		ret = 1;
+	} else {
+		printf("%s: failed to add a new device with handle = %x.\n", driver->name, dev_handle);	
+		remove_from_devices_list(dev);
+		// TODO delete device		
+		ret = 0;
+	}
 	ipc_answer_1(iid, EOK, ret);
 }
@@ -129,13 +155,14 @@
  * Generic client connection handler both for applications and drivers.
  *
- * @param driver true for driver client, false for other clients (applications, services etc.).
- */
-static void driver_connection_gen(ipc_callid_t iid, ipc_call_t *icall, bool driver)
+ * @param drv true for driver client, false for other clients (applications, services etc.).
+ */
+static void driver_connection_gen(ipc_callid_t iid, ipc_call_t *icall, bool drv)
 {
 	// Answer the first IPC_M_CONNECT_ME_TO call and remember the handle of the device to which the client connected.
-	device_handle_t handle = IPC_GET_ARG1(*icall);
+	device_handle_t handle = IPC_GET_ARG2(*icall);
 	device_t *dev = driver_get_device(&devices, handle);
 
 	if (dev == NULL) {
+		printf("%s: driver_connection_gen error - no device with handle %x was found.\n", driver->name, handle);
 		ipc_answer_0(iid, ENOENT);
 		return;
@@ -147,5 +174,6 @@
 	// TODO open the device (introduce some callbacks for opening and closing devices registered by the driver)
 	
-	ipc_answer_0(iid, EOK);
+	printf("%s: driver_connection_gen: accepting connection.\n", driver->name);
+	ipc_answer_0(iid, EOK);	
 
 	while (1) {
@@ -153,4 +181,5 @@
 		ipc_call_t call;
 
+		printf("%s: driver_connection_gen: waiting for call.\n", driver->name);
 		callid = async_get_call(&call);
 		ipcarg_t method = IPC_GET_METHOD(call);
@@ -166,4 +195,5 @@
 			if (!is_valid_iface_id(method)) {
 				// this is not device's interface
+				printf("%s: driver_connection_gen error - invalid interface id %x.", driver->name, method);
 				ipc_answer_0(callid, ENOTSUP);
 				break;
@@ -175,4 +205,6 @@
 			void *iface = device_get_iface(dev, method);
 			if (NULL == iface) {
+				printf("%s: driver_connection_gen error - ", driver->name);
+				printf("device with handle %x has no interface with id %x.\n", handle, method);
 				ipc_answer_0(callid, ENOTSUP);
 				break;
@@ -188,4 +220,5 @@
 			if (NULL == iface_method_ptr) {
 				// the interface has not such method
+				printf("%s: driver_connection_gen error - invalid interface method.", driver->name);
 				ipc_answer_0(callid, ENOTSUP);
 				break;
@@ -203,4 +236,5 @@
 static void driver_connection_driver(ipc_callid_t iid, ipc_call_t *icall)
 {
+	printf("%s: driver_connection_driver\n", driver->name);
 	driver_connection_gen(iid, icall, true);
 }
@@ -208,4 +242,5 @@
 static void driver_connection_client(ipc_callid_t iid, ipc_call_t *icall)
 {
+	printf("%s: driver_connection_client\n", driver->name);
 	driver_connection_gen(iid, icall, false);
 }
@@ -244,7 +279,9 @@
 	assert(NULL != child->name);
 
+	add_to_devices_list(child);
 	if (EOK == devman_child_device_register(child->name, &child->match_ids, parent->handle, &child->handle)) {
 		return true;
 	}
+	remove_from_devices_list(child);	
 	return false;
 }
Index: uspace/lib/libdrv/include/driver.h
===================================================================
--- uspace/lib/libdrv/include/driver.h	(revision 5cd136abc29be1860cb1f40730725d7f1d76a017)
+++ uspace/lib/libdrv/include/driver.h	(revision 9a66bc2ed74a9425386a5a8717ee6155578308a0)
@@ -80,5 +80,5 @@
 	device_handle_t handle;
 	/** The phone to the parent device driver.*/
-	ipcarg_t parent_phone;
+	int parent_phone;
 	/** The device's name.*/
 	const char *name;
Index: uspace/srv/devman/main.c
===================================================================
--- uspace/srv/devman/main.c	(revision 5cd136abc29be1860cb1f40730725d7f1d76a017)
+++ uspace/srv/devman/main.c	(revision 9a66bc2ed74a9425386a5a8717ee6155578308a0)
@@ -258,8 +258,12 @@
 }
 
-static void devman_forward(ipc_callid_t iid, ipc_call_t *icall, bool drv_to_parent) {
-	device_handle_t handle;
+static void devman_forward(ipc_callid_t iid, ipc_call_t *icall, bool drv_to_parent) {	
+	
+	device_handle_t handle = IPC_GET_ARG2(*icall);
+	printf(NAME ": devman_forward - trying to forward connection to device with handle %x.\n", handle);
+	
 	node_t *dev = find_dev_node(&device_tree, handle);
 	if (NULL == dev) {
+		printf(NAME ": devman_forward error - no device with handle %x was found.\n", handle);
 		ipc_answer_0(iid, ENOENT);
 		return;
@@ -269,10 +273,13 @@
 	
 	if (drv_to_parent) {
-		driver = dev->parent->drv;
+		if (NULL != dev->parent) {
+			driver = dev->parent->drv;		
+		}
 	} else {
 		driver = dev->drv;		
 	}
 	
-	if (NULL == driver) {		
+	if (NULL == driver) {	
+		printf(NAME ": devman_forward error - no driver to connect to.\n", handle);
 		ipc_answer_0(iid, ENOENT);
 		return;	
@@ -286,4 +293,9 @@
 	}
 	
+	if (driver->phone <= 0) {
+		printf(NAME ": devman_forward: cound not forward to driver %s (the driver's phone is %x).\n", driver->name, driver->phone);
+		return;
+	}
+	printf(NAME ": devman_forward: forward to driver %s with phone %d.\n", driver->name, driver->phone);
 	ipc_forward_fast(iid, driver->phone, method, dev->handle, 0, IPC_FF_NONE);	
 }
Index: uspace/srv/drivers/rootia32/rootia32.c
===================================================================
--- uspace/srv/drivers/rootia32/rootia32.c	(revision 5cd136abc29be1860cb1f40730725d7f1d76a017)
+++ uspace/srv/drivers/rootia32/rootia32.c	(revision 9a66bc2ed74a9425386a5a8717ee6155578308a0)
@@ -50,10 +50,11 @@
 #include <ipc/devman.h>
 #include <ipc/dev_iface.h>
+#include <resource.h>
 
 #define NAME "rootia32"
 
-typedef struct rootia32_dev_data {
+typedef struct rootia32_child_dev_data {
 	hw_resource_list_t hw_resources;	
-} rootia32_dev_data_t;
+} rootia32_child_dev_data_t;
 
 static bool rootia32_add_device(device_t *dev);
@@ -82,5 +83,5 @@
 };
 
-static rootia32_dev_data_t pci_data = {
+static rootia32_child_dev_data_t pci_data = {
 	.hw_resources = {
 		1, 
@@ -89,7 +90,28 @@
 };
 
+static hw_resource_list_t * rootia32_get_child_resources(device_t *dev)
+{
+	rootia32_child_dev_data_t *data = (rootia32_child_dev_data_t *)dev->driver_data;
+	if (NULL == data) {
+		return NULL;
+	}
+	return &data->hw_resources;
+}
+
+static bool rootia32_enable_child_interrupt(device_t *dev) 
+{
+	// TODO
+	
+	return false;
+}
+
+static resource_iface_t child_res_iface = {
+	&rootia32_get_child_resources,
+	&rootia32_enable_child_interrupt	
+};
+
 static bool rootia32_add_child(
 	device_t *parent, const char *name, const char *str_match_id, 
-	rootia32_dev_data_t *drv_data) 
+	rootia32_child_dev_data_t *drv_data) 
 {
 	printf(NAME ": adding new child device '%s'.\n", name);
@@ -113,4 +135,7 @@
 	match_id->score = 100;
 	add_match_id(&child->match_ids, match_id);	
+	
+	// add an interface to the device
+	device_set_iface(child, HW_RES_DEV_IFACE, &child_res_iface);
 	
 	// register child  device
@@ -151,5 +176,4 @@
 	if (!rootia32_add_children(dev)) {
 		printf(NAME ": failed to add child devices for platform ia32.\n");
-		return false;
 	}
 	
