Index: uspace/lib/libc/generic/device/hw_res.c
===================================================================
--- uspace/lib/libc/generic/device/hw_res.c	(revision 3a5909fe4bb88de08b53e63b8b853f35876cd30c)
+++ uspace/lib/libc/generic/device/hw_res.c	(revision 3843ecb7d7c7992f743d7917e8f23cddd7c7b5c9)
@@ -37,10 +37,9 @@
 #include <async.h>
 #include <malloc.h>
- 
 
 bool get_hw_resources(int dev_phone, hw_resource_list_t *hw_resources)
 {
 	ipcarg_t count = 0;
-	int rc = async_req_1_1(dev_phone, HW_RES_DEV_IFACE, GET_RESOURCE_LIST, &count);
+	int rc = async_req_1_1(dev_phone, DEV_IFACE_ID(HW_RES_DEV_IFACE), GET_RESOURCE_LIST, &count);
 	hw_resources->count = count;
 	if (EOK != rc) {
@@ -66,5 +65,5 @@
 bool enable_interrupt(int dev_phone)
 {
-	int rc = async_req_1_0(dev_phone, HW_RES_DEV_IFACE, ENABLE_INTERRUPT);
+	int rc = async_req_1_0(dev_phone, DEV_IFACE_ID(HW_RES_DEV_IFACE), ENABLE_INTERRUPT);
 	return rc == EOK;
 }
Index: uspace/lib/libc/include/device/hw_res.h
===================================================================
--- uspace/lib/libc/include/device/hw_res.h	(revision 3a5909fe4bb88de08b53e63b8b853f35876cd30c)
+++ uspace/lib/libc/include/device/hw_res.h	(revision 3843ecb7d7c7992f743d7917e8f23cddd7c7b5c9)
@@ -39,4 +39,38 @@
 #include <bool.h>
 
+/** HW resource (e.g. interrupt, memory register, i/o register etc.). */
+typedef struct hw_resource {
+	hw_res_type_t type;
+	union {
+		struct {
+			uint64_t address;
+			endianness_t endianness;			
+			size_t size;			
+		} mem_range;
+		struct {
+			uint64_t address;
+			endianness_t endianness;			
+			size_t size;			
+		} io_range;
+		struct {
+			int irq;			
+		} interrupt;		
+	} res;	
+} hw_resource_t;
+
+typedef struct hw_resource_list {
+	size_t count;
+	hw_resource_t *resources;	
+} hw_resource_list_t;
+
+static inline void clean_hw_resource_list(hw_resource_list_t *hw_res)
+{
+	if(NULL != hw_res->resources) {
+		free(hw_res->resources);
+		hw_res->resources = NULL;
+	}
+	hw_res->count = 0;	
+}
+
 
 bool get_hw_resources(int dev_phone, hw_resource_list_t *hw_resources);
Index: uspace/lib/libc/include/ipc/dev_iface.h
===================================================================
--- uspace/lib/libc/include/ipc/dev_iface.h	(revision 3a5909fe4bb88de08b53e63b8b853f35876cd30c)
+++ uspace/lib/libc/include/ipc/dev_iface.h	(revision 3843ecb7d7c7992f743d7917e8f23cddd7c7b5c9)
@@ -35,17 +35,15 @@
 #include <libarch/types.h>
 
-#define DEV_IFACE_FIRST IPC_FIRST_USER_METHOD
-
 typedef enum {	
-	HW_RES_DEV_IFACE = DEV_IFACE_FIRST,	
+	HW_RES_DEV_IFACE = 0,	
 	// TODO add more interfaces
 	DEV_IFACE_MAX
-} dev_inferface_id_t;
+} dev_inferface_idx_t;
 
+#define DEV_IFACE_ID(idx) ((idx) + IPC_FIRST_USER_METHOD)
+#define DEV_IFACE_IDX(id) ((id) - IPC_FIRST_USER_METHOD)
 
-#define DEV_IFACE_COUNT (DEV_IFACE_MAX - DEV_IFACE_FIRST)
+#define DEV_IFACE_COUNT DEV_IFACE_MAX
 
-
-// data types related to some interface - TODO move this to separate header files
 
 
@@ -69,37 +67,3 @@
 } endianness_t;
 
-/** HW resource (e.g. interrupt, memory register, i/o register etc.). */
-typedef struct hw_resource {
-	hw_res_type_t type;
-	union {
-		struct {
-			uint64_t address;
-			endianness_t endianness;			
-			size_t size;			
-		} mem_range;
-		struct {
-			uint64_t address;
-			endianness_t endianness;			
-			size_t size;			
-		} io_range;
-		struct {
-			int irq;			
-		} interrupt;		
-	} res;	
-} hw_resource_t;
-
-typedef struct hw_resource_list {
-	size_t count;
-	hw_resource_t *resources;	
-} hw_resource_list_t;
-
-static inline void clean_hw_resource_list(hw_resource_list_t *hw_res)
-{
-	if(NULL != hw_res->resources) {
-		free(hw_res->resources);
-		hw_res->resources = NULL;
-	}
-	hw_res->count = 0;	
-}
-
 #endif
Index: uspace/lib/libdrv/generic/dev_iface.c
===================================================================
--- uspace/lib/libdrv/generic/dev_iface.c	(revision 3a5909fe4bb88de08b53e63b8b853f35876cd30c)
+++ uspace/lib/libdrv/generic/dev_iface.c	(revision 3843ecb7d7c7992f743d7917e8f23cddd7c7b5c9)
@@ -45,9 +45,7 @@
 };
 
-remote_iface_t* get_remote_iface(dev_inferface_id_t id)
-{
-	assert(is_valid_iface_id(id));
-	
-	int idx = get_iface_index(id);
+remote_iface_t* get_remote_iface(int idx)
+{	
+	assert(is_valid_iface_idx(idx));	
 	return remote_ifaces.ifaces[idx];	
 }
Index: uspace/lib/libdrv/generic/driver.c
===================================================================
--- uspace/lib/libdrv/generic/driver.c	(revision 3a5909fe4bb88de08b53e63b8b853f35876cd30c)
+++ uspace/lib/libdrv/generic/driver.c	(revision 3843ecb7d7c7992f743d7917e8f23cddd7c7b5c9)
@@ -177,4 +177,6 @@
 		callid = async_get_call(&call);
 		ipcarg_t method = IPC_GET_METHOD(call);
+		int iface_idx;
+		
 		switch  (method) {
 		case IPC_M_PHONE_HUNGUP:
@@ -184,7 +186,10 @@
 			ipc_answer_0(callid, EOK);
 			return;
-		default:
-
-			if (!is_valid_iface_id(method)) {
+		default:		
+			// convert ipc interface id to interface index
+			
+			iface_idx = DEV_IFACE_IDX(method);
+			
+			if (!is_valid_iface_idx(iface_idx)) {
 				// this is not device's interface
 				printf("%s: driver_connection_gen error - invalid interface id %x.", driver->name, method);
@@ -196,5 +201,5 @@
 			
 			// get the device interface structure
-			void *iface = device_get_iface(dev, method);
+			void *iface = device_get_iface(dev, iface_idx);
 			if (NULL == iface) {
 				printf("%s: driver_connection_gen error - ", driver->name);
@@ -205,5 +210,5 @@
 
 			// get the corresponding interface for remote request handling ("remote interface")
-			remote_iface_t* rem_iface = get_remote_iface(method);
+			remote_iface_t* rem_iface = get_remote_iface(iface_idx);
 			assert(NULL != rem_iface);
 
Index: uspace/lib/libdrv/include/driver.h
===================================================================
--- uspace/lib/libdrv/include/driver.h	(revision 3a5909fe4bb88de08b53e63b8b853f35876cd30c)
+++ uspace/lib/libdrv/include/driver.h	(revision 3843ecb7d7c7992f743d7917e8f23cddd7c7b5c9)
@@ -39,4 +39,5 @@
 #include <ipc/devman.h>
 #include <ipc/dev_iface.h>
+#include <device/hw_res.h>
 #include <assert.h>
 
@@ -59,16 +60,23 @@
 } iface_dipatch_table_t;
 
-static inline int get_iface_index(dev_inferface_id_t id)
+
+static inline bool is_valid_iface_idx(int idx)
 {
-	return id - DEV_IFACE_FIRST;
+	return 0 <= idx && idx < DEV_IFACE_MAX;
 }
 
-static inline bool is_valid_iface_id(dev_inferface_id_t id)
-{
-	return DEV_IFACE_FIRST <= id && id < DEV_IFACE_MAX;
-}
+remote_iface_t* get_remote_iface(int idx);
+remote_iface_func_ptr_t get_remote_method(remote_iface_t *rem_iface, ipcarg_t iface_method_idx);
 
-remote_iface_t* get_remote_iface(dev_inferface_id_t id);
-remote_iface_func_ptr_t get_remote_method(remote_iface_t *rem_iface, ipcarg_t iface_method_idx);
+
+// device class
+
+/** Devices belonging to the same class should implement the same set of interfaces.*/
+typedef struct device_class {
+	/** Unique identification of the class. */
+	int id;
+	/** The table of interfaces implemented by the device. */
+	void *interfaces[DEV_IFACE_COUNT];	
+} device_class_t;
 
 
@@ -89,6 +97,6 @@
 	/** The device driver's data associated with this device.*/
 	void *driver_data;
-	/** The table of interfaces exported by this device. */
-	void *interfaces[DEV_IFACE_COUNT];
+	/** Device class consist of class id and table of interfaces supported by the device.*/
+	device_class_t *class;
 	/** Pointer to the previous and next device in the list of devices handled by the driver */
 	link_t link;
@@ -146,18 +154,9 @@
 }
 
-static inline void device_set_iface (device_t *dev, dev_inferface_id_t id, void *iface)
+static inline void * device_get_iface(device_t *dev, dev_inferface_idx_t idx)
 {
-	assert(is_valid_iface_id(id));
+	assert(is_valid_iface_idx(idx));	
 
-	int idx = get_iface_index(id);
-	dev->interfaces[idx] = iface;
-}
-
-static inline void * device_get_iface(device_t *dev, dev_inferface_id_t id)
-{
-	assert(is_valid_iface_id(id));
-	
-	int idx = get_iface_index(id);
-	return dev->interfaces[idx];	
+	return dev->class->interfaces[idx];	
 }
 
Index: uspace/srv/devman/main.c
===================================================================
--- uspace/srv/devman/main.c	(revision 3a5909fe4bb88de08b53e63b8b853f35876cd30c)
+++ uspace/srv/devman/main.c	(revision 3843ecb7d7c7992f743d7917e8f23cddd7c7b5c9)
@@ -121,4 +121,11 @@
 }
 
+/**
+ * Receive device match ID from the device's parent driver and add it to the list of devices match ids.
+ * 
+ * @param match_ids the list of the device's match ids.
+ * 
+ * @return 0 on success, negative error code otherwise. 
+ */
 static int devman_receive_match_id(match_id_list_t *match_ids) {
 	
@@ -159,4 +166,13 @@
 }
 
+/**
+ * Receive device match IDs from the device's parent driver 
+ * and add them to the list of devices match ids.
+ * 
+ * @param match_count the number of device's match ids to be received.
+ * @param match_ids the list of the device's match ids.
+ * 
+ * @return 0 on success, negative error code otherwise.
+ */
 static int devman_receive_match_ids(ipcarg_t match_count, match_id_list_t *match_ids) 
 {	
@@ -171,5 +187,9 @@
 }
 
-static void devman_add_child(ipc_callid_t callid, ipc_call_t *call, driver_t *driver)
+/** Handle child device registration. 
+ * 
+ * Child devices are registered by their parent's device driver.
+ */
+static void devman_add_child(ipc_callid_t callid, ipc_call_t *call)
 {
 	// printf(NAME ": devman_add_child\n");
@@ -211,4 +231,10 @@
 }
 
+/**
+ * Initialize driver which has registered itself as running and ready.
+ * 
+ * The initialization is done in a separate fibril to avoid deadlocks 
+ * (if the driver needed to be served by devman during the driver's initialization). 
+ */
 static int init_running_drv(void *drv)
 {
@@ -219,6 +245,5 @@
 }
 
-/** Function for handling connections to device manager.
- *
+/** Function for handling connections from a driver to the device manager.
  */
 static void devman_connection_driver(ipc_callid_t iid, ipc_call_t *icall)
@@ -231,8 +256,11 @@
 		return;
 	
+	// Initialize the driver as running (e.g. pass assigned devices to it) in a separate fibril;
+	// the separate fibril is used to enable the driver 
+	// to use devman service during the driver's initialization.
 	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);
+		return;
 	}
 	fibril_add_ready(fid);
@@ -254,5 +282,5 @@
 			continue;
 		case DEVMAN_ADD_CHILD_DEVICE:
-			devman_add_child(callid, &call, driver);
+			devman_add_child(callid, &call);
 			break;
 		default:
@@ -299,5 +327,6 @@
 	
 	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);
+		printf(NAME ": devman_forward: cound not forward to driver %s ", driver->name);
+		printf("the driver's phone is %x).\n", driver->phone);
 		return;
 	}
Index: uspace/srv/drivers/pciintel/pci.c
===================================================================
--- uspace/srv/drivers/pciintel/pci.c	(revision 3a5909fe4bb88de08b53e63b8b853f35876cd30c)
+++ uspace/srv/drivers/pciintel/pci.c	(revision 3843ecb7d7c7992f743d7917e8f23cddd7c7b5c9)
@@ -58,6 +58,29 @@
 #define NAME "pciintel"
 
-
 #define CONF_ADDR(bus, dev, fn, reg)   ((1 << 31) | (bus << 16) | (dev << 11) | (fn << 8) | (reg & ~3))
+
+
+static hw_resource_list_t * pciintel_get_child_resources(device_t *dev)
+{
+	pci_dev_data_t *dev_data = (pci_dev_data_t *)dev->driver_data;
+	if (NULL == dev_data) {
+		return NULL;
+	}
+	return &dev_data->hw_resources;
+}
+
+static bool pciintel_enable_child_interrupt(device_t *dev) 
+{
+	// TODO
+	
+	return false;
+}
+
+static resource_iface_t pciintel_child_res_iface = {
+	&pciintel_get_child_resources,
+	&pciintel_enable_child_interrupt	
+};
+
+static device_class_t pci_child_class;
 
 
@@ -373,5 +396,5 @@
 			pci_read_interrupt(dev);
 			
-			// TODO initialize device interfaces			
+			dev->class = &pci_child_class;			
 			
 			printf(NAME ": adding new child device %s.\n", dev->name);
@@ -464,7 +487,14 @@
 }
 
+static void pciintel_init() 
+{
+	pci_child_class.id = 0; // TODO
+	pci_child_class.interfaces[HW_RES_DEV_IFACE] = &pciintel_child_res_iface;
+}
+
 int main(int argc, char *argv[])
 {
-	printf(NAME ": HelenOS pci bus driver (intel method 1).\n");	
+	printf(NAME ": HelenOS pci bus driver (intel method 1).\n");
+	pciintel_init();
 	return driver_main(&pci_driver);
 }
Index: uspace/srv/drivers/pciintel/pci.h
===================================================================
--- uspace/srv/drivers/pciintel/pci.h	(revision 3a5909fe4bb88de08b53e63b8b853f35876cd30c)
+++ uspace/srv/drivers/pciintel/pci.h	(revision 3843ecb7d7c7992f743d7917e8f23cddd7c7b5c9)
@@ -110,5 +110,5 @@
 }
 
-static inline bool pci_clean_resource_list(device_t *dev)
+static inline void pci_clean_resource_list(device_t *dev)
 {
 	pci_dev_data_t *dev_data = (pci_dev_data_t *)dev->driver_data;
Index: uspace/srv/drivers/rootia32/rootia32.c
===================================================================
--- uspace/srv/drivers/rootia32/rootia32.c	(revision 3a5909fe4bb88de08b53e63b8b853f35876cd30c)
+++ uspace/srv/drivers/rootia32/rootia32.c	(revision 3843ecb7d7c7992f743d7917e8f23cddd7c7b5c9)
@@ -51,4 +51,5 @@
 #include <ipc/dev_iface.h>
 #include <resource.h>
+#include <device/hw_res.h>
 
 #define NAME "rootia32"
@@ -111,4 +112,7 @@
 };
 
+// initialized in root_ia32_init() function
+static device_class_t rootia32_child_class;
+
 static bool rootia32_add_child(
 	device_t *parent, const char *name, const char *str_match_id, 
@@ -136,6 +140,6 @@
 	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);
+	// set class to the device
+	child->class = &rootia32_child_class;
 	
 	// register child  device
@@ -181,7 +185,14 @@
 }
 
+static void root_ia32_init() {
+	// initialize child device class		
+	rootia32_child_class.id = 0;	// TODO 
+	rootia32_child_class.interfaces[HW_RES_DEV_IFACE] = &child_res_iface;
+}
+
 int main(int argc, char *argv[])
 {
 	printf(NAME ": HelenOS root device driver\n");	
+	root_ia32_init();
 	return driver_main(&rootia32_driver);
 }
