Index: uspace/lib/c/Makefile
===================================================================
--- uspace/lib/c/Makefile	(revision a7a85d16a8c965959d2a721c191833e692d098ed)
+++ uspace/lib/c/Makefile	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
@@ -57,4 +57,7 @@
 	generic/clipboard.c \
 	generic/devmap.c \
+	generic/devman.c \
+	generic/device/hw_res.c \
+	generic/device/char.c \
 	generic/event.c \
 	generic/errno.c \
Index: uspace/lib/c/generic/ddi.c
===================================================================
--- uspace/lib/c/generic/ddi.c	(revision a7a85d16a8c965959d2a721c191833e692d098ed)
+++ uspace/lib/c/generic/ddi.c	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
@@ -96,4 +96,26 @@
 }
 
+/** Enable an interrupt.
+ * 
+ * @param irq the interrupt.
+ * 
+ * @return Zero on success, negative error code otherwise. 
+ */
+int interrupt_enable(int irq) 
+{
+	return __SYSCALL2(SYS_INTERRUPT_ENABLE, (sysarg_t) irq, 1);
+}
+
+/** Disable an interrupt.
+ * 
+ * @param irq the interrupt.
+ * 
+ * @return Zero on success, negative error code otherwise. 
+ */
+int interrupt_disable(int irq) 
+{
+	return __SYSCALL2(SYS_INTERRUPT_ENABLE, (sysarg_t) irq, 0);
+}
+
 /** Enable PIO for specified I/O range.
  *
Index: uspace/lib/c/generic/device/char.c
===================================================================
--- uspace/lib/c/generic/device/char.c	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
+++ uspace/lib/c/generic/device/char.c	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2010 Lenka Trochtova
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+ 
+ /** @addtogroup libc
+ * @{
+ */
+/** @file
+ */
+
+#include <ipc/dev_iface.h>
+#include <device/char.h>
+#include <errno.h>
+#include <async.h>
+#include <malloc.h>
+#include <stdio.h>
+
+/** Read to or write from the device using its character interface.
+ * 
+ * Helper function.
+ * 
+ * @param dev_phone phone to the device.
+ * @param buf the buffer for the data read from or written to the device.
+ * @param len the maximum length of the data to be read or written.
+ * @param read read from the device if true, write to it otherwise.
+ * 
+ * @return non-negative number of bytes actually read from or written to the device on success,
+ * negative error number otherwise.
+ * 
+ */
+static int rw_dev(int dev_phone, void *buf, size_t len, bool read) 
+{
+	ipc_call_t answer;
+	
+	async_serialize_start();
+	
+	aid_t req;
+	int ret;
+	
+	if (read) {
+		req = async_send_1(dev_phone, DEV_IFACE_ID(CHAR_DEV_IFACE), CHAR_READ_DEV, &answer);
+		ret = async_data_read_start(dev_phone, buf, len);		
+	} else {
+		req = async_send_1(dev_phone, DEV_IFACE_ID(CHAR_DEV_IFACE), CHAR_WRITE_DEV, &answer);
+		ret = async_data_write_start(dev_phone, buf, len);
+	}
+	
+	ipcarg_t rc;
+	if (ret != EOK) {		
+		async_wait_for(req, &rc);
+		async_serialize_end();
+		if (rc == EOK) {
+			return ret;
+		}
+		else {
+			return (int) rc;
+		}
+	}
+	
+	async_wait_for(req, &rc);
+	async_serialize_end();
+	
+	ret = (int)rc;
+	if (EOK != ret) {
+		return ret;
+	}
+	
+	return IPC_GET_ARG1(answer);	
+}
+
+/** Read from the device using its character interface.
+ * 
+ * @param dev_phone phone to the device.
+ * @param buf the output buffer for the data read from the device.
+ * @param len the maximum length of the data to be read.
+ * 
+ * @return non-negative number of bytes actually read from the device on success, negative error number otherwise.
+ */
+int read_dev(int dev_phone, void *buf, size_t len)
+{	
+	return rw_dev(dev_phone, buf, len, true);
+}
+
+/** Write to the device using its character interface.
+ * 
+ * @param dev_phone phone to the device.
+ * @param buf the input buffer containg the data to be written to the device.
+ * @param len the maximum length of the data to be written.
+ * 
+ * @return non-negative number of bytes actually written to the device on success, negative error number otherwise.
+ */
+int write_dev(int dev_phone, void *buf, size_t len)
+{
+	return rw_dev(dev_phone, buf, len, false);
+}
+
+  
+ /** @}
+ */
Index: uspace/lib/c/generic/device/hw_res.c
===================================================================
--- uspace/lib/c/generic/device/hw_res.c	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
+++ uspace/lib/c/generic/device/hw_res.c	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2010 Lenka Trochtova
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+ 
+ /** @addtogroup libc
+ * @{
+ */
+/** @file
+ */
+ 
+#include <device/hw_res.h>
+#include <errno.h>
+#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, DEV_IFACE_ID(HW_RES_DEV_IFACE), GET_RESOURCE_LIST, &count);
+	hw_resources->count = count;
+	if (EOK != rc) {
+		return false;
+	}
+	
+	size_t size = count * sizeof(hw_resource_t);
+	hw_resources->resources = (hw_resource_t *)malloc(size);
+	if (NULL == hw_resources->resources) {
+		return false;
+	}
+	
+	rc = async_data_read_start(dev_phone, hw_resources->resources, size);
+	if (EOK != rc) {
+		free(hw_resources->resources);
+		hw_resources->resources = NULL;
+		return false;
+	}
+	 	 
+	return true;	 
+}
+
+bool enable_interrupt(int dev_phone)
+{
+	int rc = async_req_1_0(dev_phone, DEV_IFACE_ID(HW_RES_DEV_IFACE), ENABLE_INTERRUPT);
+	return rc == EOK;
+}
+ 
+ 
+ 
+ /** @}
+ */
Index: uspace/lib/c/generic/devman.c
===================================================================
--- uspace/lib/c/generic/devman.c	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
+++ uspace/lib/c/generic/devman.c	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
@@ -0,0 +1,294 @@
+/*
+ * Copyright (c) 2007 Josef Cejka
+ * Copyright (c) 2009 Jiri Svoboda
+ * Copyright (c) 2010 Lenka Trochtova
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+ 
+ /** @addtogroup libc
+ * @{
+ */
+/** @file
+ */
+
+#include <str.h>
+#include <stdio.h>
+#include <ipc/ipc.h>
+#include <ipc/services.h>
+#include <ipc/devman.h>
+#include <devman.h>
+#include <async.h>
+#include <errno.h>
+#include <malloc.h>
+#include <bool.h>
+#include <adt/list.h>
+
+static int devman_phone_driver = -1;
+static int devman_phone_client = -1;
+
+int devman_get_phone(devman_interface_t iface, unsigned int flags)
+{
+	switch (iface) {
+	case DEVMAN_DRIVER:
+		if (devman_phone_driver >= 0)
+			return devman_phone_driver;
+		
+		if (flags & IPC_FLAG_BLOCKING)
+			devman_phone_driver = ipc_connect_me_to_blocking(PHONE_NS,
+			    SERVICE_DEVMAN, DEVMAN_DRIVER, 0);
+		else
+			devman_phone_driver = ipc_connect_me_to(PHONE_NS,
+			    SERVICE_DEVMAN, DEVMAN_DRIVER, 0);
+		
+		return devman_phone_driver;
+	case DEVMAN_CLIENT:
+		if (devman_phone_client >= 0)
+			return devman_phone_client;
+		
+		if (flags & IPC_FLAG_BLOCKING)
+			devman_phone_client = ipc_connect_me_to_blocking(PHONE_NS,
+			    SERVICE_DEVMAN, DEVMAN_CLIENT, 0);
+		else
+			devman_phone_client = ipc_connect_me_to(PHONE_NS,
+			    SERVICE_DEVMAN, DEVMAN_CLIENT, 0);
+		
+		return devman_phone_client;
+	default:
+		return -1;
+	}
+}
+
+/** Register running driver with device manager. */
+int devman_driver_register(const char *name, async_client_conn_t conn)
+{
+	int phone = devman_get_phone(DEVMAN_DRIVER, IPC_FLAG_BLOCKING);
+	
+	if (phone < 0)
+		return phone;
+	
+	async_serialize_start();
+	
+	ipc_call_t answer;
+	aid_t req = async_send_2(phone, DEVMAN_DRIVER_REGISTER, 0, 0, &answer);
+	
+	ipcarg_t retval = async_data_write_start(phone, name, str_size(name));
+	if (retval != EOK) {
+		async_wait_for(req, NULL);
+		async_serialize_end();
+		return -1;
+	}
+	
+	async_set_client_connection(conn);
+	
+	ipcarg_t callback_phonehash;
+	ipc_connect_to_me(phone, 0, 0, 0, &callback_phonehash);
+	async_wait_for(req, &retval);
+	
+	async_serialize_end();
+	
+	return retval;
+}
+
+static int devman_send_match_id(int phone, match_id_t *match_id) \
+{
+	ipc_call_t answer;
+	async_send_1(phone, DEVMAN_ADD_MATCH_ID, match_id->score, &answer);
+	int retval = async_data_write_start(phone, match_id->id, str_size(match_id->id));
+	return retval;	
+}
+
+
+static int devman_send_match_ids(int phone, match_id_list_t *match_ids) 
+{
+	link_t *link = match_ids->ids.next;
+	match_id_t *match_id = NULL;
+	int ret = EOK;
+	
+	while (link != &match_ids->ids) {
+		match_id = list_get_instance(link, match_id_t, link); 
+		if (EOK != (ret = devman_send_match_id(phone, match_id))) 
+		{
+			printf("Driver failed to send match id, error number = %d\n", ret);
+			return ret;			
+		}
+		link = link->next;
+	}
+	return ret;	
+}
+
+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);
+	
+	if (phone < 0)
+		return phone;
+	
+	async_serialize_start();
+	
+	int match_count = list_count(&match_ids->ids);	
+	ipc_call_t answer;
+	aid_t req = async_send_2(phone, DEVMAN_ADD_CHILD_DEVICE, parent_handle, match_count, &answer);
+
+	ipcarg_t retval = async_data_write_start(phone, name, str_size(name));
+	if (retval != EOK) {
+		async_wait_for(req, NULL);
+		async_serialize_end();
+		return retval;
+	}
+	
+	devman_send_match_ids(phone, match_ids);
+	
+	async_wait_for(req, &retval);
+	
+	async_serialize_end();
+	
+	if (retval != EOK) {
+		if (handle != NULL) {
+			*handle = -1;
+		}
+		return retval;
+	}	
+	
+	if (handle != NULL)
+		*handle = (int) IPC_GET_ARG1(answer);	
+		
+	return retval;
+}
+
+int devman_add_device_to_class(device_handle_t dev_handle, const char *class_name)
+{
+	int phone = devman_get_phone(DEVMAN_DRIVER, IPC_FLAG_BLOCKING);
+	
+	if (phone < 0)
+		return phone;
+	
+	async_serialize_start();
+	ipc_call_t answer;
+	aid_t req = async_send_1(phone, DEVMAN_ADD_DEVICE_TO_CLASS, dev_handle, &answer);
+	
+	ipcarg_t retval = async_data_write_start(phone, class_name, str_size(class_name));
+	if (retval != EOK) {
+		async_wait_for(req, NULL);
+		async_serialize_end();
+		return retval;
+	}
+	
+	async_wait_for(req, &retval);
+	async_serialize_end();
+	
+	return retval;	
+}
+
+void devman_hangup_phone(devman_interface_t iface)
+{
+	switch (iface) {
+	case DEVMAN_DRIVER:
+		if (devman_phone_driver >= 0) {
+			ipc_hangup(devman_phone_driver);
+			devman_phone_driver = -1;
+		}
+		break;
+	case DEVMAN_CLIENT:
+		if (devman_phone_client >= 0) {
+			ipc_hangup(devman_phone_client);
+			devman_phone_client = -1;
+		}
+		break;
+	default:
+		break;
+	}
+}
+
+int devman_device_connect(device_handle_t handle, unsigned int flags)
+{
+	int phone;
+	
+	if (flags & IPC_FLAG_BLOCKING) {
+		phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_DEVMAN,
+		    DEVMAN_CONNECT_TO_DEVICE, handle);
+	} else {
+		phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAN,
+		    DEVMAN_CONNECT_TO_DEVICE, handle);
+	}
+	
+	return phone;
+}
+
+int devman_parent_device_connect(device_handle_t handle, unsigned int flags)
+{
+	int phone;
+	
+	if (flags & IPC_FLAG_BLOCKING) {
+		phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_DEVMAN,
+		    DEVMAN_CONNECT_TO_PARENTS_DEVICE, handle);
+	} else {
+		phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAN,
+		    DEVMAN_CONNECT_TO_PARENTS_DEVICE, handle);
+	}
+	
+	return phone;
+}
+
+int devman_device_get_handle(const char *pathname, device_handle_t *handle, unsigned int flags)
+{
+	int phone = devman_get_phone(DEVMAN_CLIENT, flags);
+	
+	if (phone < 0)
+		return phone;
+	
+	async_serialize_start();
+	
+	ipc_call_t answer;
+	aid_t req = async_send_2(phone, DEVMAN_DEVICE_GET_HANDLE, flags, 0,
+	    &answer);
+	
+	ipcarg_t retval = async_data_write_start(phone, pathname, str_size(pathname));
+	if (retval != EOK) {
+		async_wait_for(req, NULL);
+		async_serialize_end();
+		return retval;
+	}
+	
+	async_wait_for(req, &retval);
+	
+	async_serialize_end();
+	
+	if (retval != EOK) {
+		if (handle != NULL)
+			*handle = (device_handle_t) -1;
+		return retval;
+	}
+	
+	if (handle != NULL)
+		*handle = (device_handle_t) IPC_GET_ARG1(answer);
+	
+	return retval;
+}
+
+
+/** @}
+ */
Index: uspace/lib/c/include/ddi.h
===================================================================
--- uspace/lib/c/include/ddi.h	(revision a7a85d16a8c965959d2a721c191833e692d098ed)
+++ uspace/lib/c/include/ddi.h	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
@@ -42,4 +42,6 @@
 extern int iospace_enable(task_id_t, void *, unsigned long);
 extern int pio_enable(void *, size_t, void **);
+extern int interrupt_enable(int);
+extern int interrupt_disable(int);
 
 #endif
Index: uspace/lib/c/include/device/char.h
===================================================================
--- uspace/lib/c/include/device/char.h	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
+++ uspace/lib/c/include/device/char.h	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2010 Lenka Trochtova
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+ 
+ /** @addtogroup libc
+ * @{
+ */
+/** @file
+ */
+ 
+#ifndef LIBC_DEVICE_HW_RES_H_
+#define LIBC_DEVICE_HW_RES_H_
+
+typedef enum {
+	CHAR_READ_DEV = 0,
+	CHAR_WRITE_DEV	
+} hw_res_funcs_t;
+
+int read_dev(int dev_phone, void *buf, size_t len);
+int write_dev(int dev_phone, void *buf, size_t len);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/include/device/hw_res.h
===================================================================
--- uspace/lib/c/include/device/hw_res.h	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
+++ uspace/lib/c/include/device/hw_res.h	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2010 Lenka Trochtova
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+ 
+ /** @addtogroup libc
+ * @{
+ */
+/** @file
+ */
+ 
+#ifndef LIBC_DEVICE_HW_RES_H_
+#define LIBC_DEVICE_HW_RES_H_
+
+#include <ipc/dev_iface.h>
+#include <bool.h>
+
+// HW resource provider interface
+
+typedef enum {
+	GET_RESOURCE_LIST = 0,
+	ENABLE_INTERRUPT	
+} hw_res_funcs_t;
+
+/** HW resource types. */
+typedef enum {
+	INTERRUPT,
+	IO_RANGE, 
+	MEM_RANGE
+} hw_res_type_t;
+
+typedef enum {
+	LITTLE_ENDIAN = 0,
+	BIG_ENDIAN
+} 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;	
+}
+
+
+
+bool get_hw_resources(int dev_phone, hw_resource_list_t *hw_resources);
+
+bool enable_interrupt(int dev_phone);
+
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/include/devman.h
===================================================================
--- uspace/lib/c/include/devman.h	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
+++ uspace/lib/c/include/devman.h	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2009 Jiri Svoboda
+ * Copyright (c) 2010 Lenka Trochtova 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libc
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_DEVMAN_H_
+#define LIBC_DEVMAN_H_
+
+#include <ipc/devman.h>
+#include <async.h>
+#include <bool.h>
+
+
+int devman_get_phone(devman_interface_t, unsigned int);
+void devman_hangup_phone(devman_interface_t iface);
+
+int devman_driver_register(const char *, async_client_conn_t);
+int devman_child_device_register(const char *, match_id_list_t *, device_handle_t, device_handle_t *);
+
+int devman_device_connect(device_handle_t handle, unsigned int flags);
+int devman_parent_device_connect(device_handle_t handle, unsigned int flags);
+
+int devman_device_get_handle(const char *pathname, device_handle_t *handle, unsigned int flags);
+
+int devman_add_device_to_class(device_handle_t dev_handle, const char *class_name);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/include/ipc/dev_iface.h
===================================================================
--- uspace/lib/c/include/ipc/dev_iface.h	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
+++ uspace/lib/c/include/ipc/dev_iface.h	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2010 Lenka Trochtova
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBC_IPC_DEV_IFACE_H_
+#define LIBC_IPC_DEV_IFACE_H_
+
+#include <ipc/ipc.h>
+#include <malloc.h>
+#include <unistd.h>
+#include <libarch/types.h>
+
+typedef enum {	
+	HW_RES_DEV_IFACE = 0,	
+	CHAR_DEV_IFACE,
+	// TODO add more interfaces
+	DEV_IFACE_MAX
+} 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
+#define DEV_FIRST_CUSTOM_METHOD_IDX 	DEV_IFACE_MAX
+#define DEV_FIRST_CUSTOM_METHOD 		DEV_IFACE_ID(DEV_FIRST_CUSTOM_METHOD_IDX)
+
+
+#endif
Index: uspace/lib/c/include/ipc/devman.h
===================================================================
--- uspace/lib/c/include/ipc/devman.h	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
+++ uspace/lib/c/include/ipc/devman.h	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2010 Lenka Trochtova
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup devman
+ * @{
+ */
+ 
+#ifndef LIBC_IPC_DEVMAN_H_
+#define LIBC_IPC_DEVMAN_H_
+
+#include <adt/list.h>
+#include <ipc/ipc.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <str.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 init_match_ids(match_id_list_t *id_list)
+{
+	list_initialize(&id_list->ids);
+}
+
+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 {
+	DEVMAN_DRIVER = 1,
+	DEVMAN_CLIENT,
+	DEVMAN_CONNECT_TO_DEVICE,
+	DEVMAN_CONNECT_TO_PARENTS_DEVICE
+} devman_interface_t;
+
+typedef enum {
+	DEVMAN_DRIVER_REGISTER = IPC_FIRST_USER_METHOD,
+	DEVMAN_ADD_CHILD_DEVICE,
+	DEVMAN_ADD_MATCH_ID,
+	DEVMAN_ADD_DEVICE_TO_CLASS
+
+} driver_to_devman_t;
+
+typedef enum {
+	DRIVER_ADD_DEVICE = IPC_FIRST_USER_METHOD
+
+} devman_to_driver_t;
+
+typedef enum {
+	DEVMAN_DEVICE_GET_HANDLE = IPC_FIRST_USER_METHOD
+} client_to_devman_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/include/ipc/driver.h
===================================================================
--- uspace/lib/c/include/ipc/driver.h	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
+++ uspace/lib/c/include/ipc/driver.h	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2010 Lenka Trochtova 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libdrv
+ * @{
+ */
+/** @file
+ */
+
+#ifndef IPC_DRIVER_H_
+#define IPC_DRIVER_H_
+
+typedef enum {
+	DRIVER_DEVMAN = 1,
+	DRIVER_CLIENT,
+	DRIVER_DRIVER
+} driver_interface_t;
+
+
+#endif
+
+
+/**
+ * @}
+ */
Index: uspace/lib/c/include/ipc/serial.h
===================================================================
--- uspace/lib/c/include/ipc/serial.h	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
+++ uspace/lib/c/include/ipc/serial.h	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
@@ -0,0 +1,14 @@
+#ifndef LIBC_FB_H_
+#define LIBC_FB_H_
+
+#include <ipc/ipc.h>
+
+typedef enum {
+	SERIAL_PUTCHAR = IPC_FIRST_USER_METHOD,
+	SERIAL_GETCHAR,
+	SERIAL_READ,
+	SERIAL_WRITE,
+} serial_request_t;
+
+
+#endif
Index: uspace/lib/c/include/ipc/serial_ctl.h
===================================================================
--- uspace/lib/c/include/ipc/serial_ctl.h	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
+++ uspace/lib/c/include/ipc/serial_ctl.h	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2010 Lenka Trochtova
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBC_IPC_SERIAL_CTL_H_
+#define LIBC_IPC_SERIAL_CTL_H_
+
+#include <ipc/dev_iface.h>
+
+/** ipc methods for getting/setting serial communication properties
+ * 	1st ipc arg: baud rate
+ * 	2nd ipc arg: parity
+ *	3rd ipc arg: number of bits in one word
+ *	4th ipc arg: number of stop bits
+ */
+typedef enum {	
+	SERIAL_GET_COM_PROPS = DEV_FIRST_CUSTOM_METHOD,
+	SERIAL_SET_COM_PROPS
+} serial_ctl_t;
+
+typedef enum {
+	SERIAL_NO_PARITY = 0,
+	SERIAL_ODD_PARITY = 1,
+	SERIAL_EVEN_PARITY = 3,
+	SERIAL_MARK_PARITY = 5,
+	SERIAL_SPACE_PARITY = 7	
+} serial_parity_t;
+
+#endif
Index: uspace/lib/c/include/ipc/services.h
===================================================================
--- uspace/lib/c/include/ipc/services.h	(revision a7a85d16a8c965959d2a721c191833e692d098ed)
+++ uspace/lib/c/include/ipc/services.h	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
@@ -45,4 +45,5 @@
 	SERVICE_VFS,
 	SERVICE_DEVMAP,
+	SERVICE_DEVMAN,
 	SERVICE_FHC,
 	SERVICE_OBIO,
Index: uspace/lib/drv/Makefile
===================================================================
--- uspace/lib/drv/Makefile	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
+++ uspace/lib/drv/Makefile	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
@@ -0,0 +1,40 @@
+#
+# Copyright (c) 2005 Martin Decky
+# Copyright (c) 2007 Jakub Jermar
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+USPACE_PREFIX = ../..
+EXTRA_CFLAGS = -Iinclude
+LIBRARY = libdrv
+
+SOURCES = \
+	generic/driver.c \
+	generic/dev_iface.c \
+	generic/remote_res.c \
+	generic/remote_char.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/lib/drv/generic/dev_iface.c
===================================================================
--- uspace/lib/drv/generic/dev_iface.c	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
+++ uspace/lib/drv/generic/dev_iface.c	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2010 Lenka Trochtova
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @defgroup libdrv generic device driver support.
+ * @brief HelenOS generic device driver support.
+ * @{
+ */
+
+/** @file
+ */
+ 
+#include "dev_iface.h"
+#include "remote_res.h"
+#include "remote_char.h"
+ 
+static iface_dipatch_table_t remote_ifaces = {
+	.ifaces = {
+		&remote_res_iface,
+		&remote_char_iface
+	}
+};
+
+remote_iface_t* get_remote_iface(int idx)
+{	
+	assert(is_valid_iface_idx(idx));	
+	return remote_ifaces.ifaces[idx];	
+}
+
+remote_iface_func_ptr_t get_remote_method(remote_iface_t *rem_iface, ipcarg_t iface_method_idx)
+{
+	if (iface_method_idx >= rem_iface->method_count) {
+		return NULL;
+	}
+	return rem_iface->methods[iface_method_idx];
+}
+ 
+ 
+ 
+/**
+ * @}
+ */
Index: uspace/lib/drv/generic/driver.c
===================================================================
--- uspace/lib/drv/generic/driver.c	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
+++ uspace/lib/drv/generic/driver.c	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
@@ -0,0 +1,376 @@
+/*
+ * Copyright (c) 2010 Lenka Trochtova
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @defgroup libdrv generic device driver support.
+ * @brief HelenOS generic device driver support.
+ * @{
+ */
+
+/** @file
+ */
+
+#include <assert.h>
+#include <ipc/services.h>
+#include <ipc/ns.h>
+#include <async.h>
+#include <stdio.h>
+#include <errno.h>
+#include <bool.h>
+#include <fibril_synch.h>
+#include <stdlib.h>
+#include <str.h>
+#include <ctype.h>
+#include <errno.h>
+
+#include <ipc/driver.h>
+
+#include "driver.h"
+
+// driver structure 
+
+static driver_t *driver;
+
+// devices
+
+LIST_INITIALIZE(devices);
+FIBRIL_MUTEX_INITIALIZE(devices_mutex);
+
+// interrupts 
+
+static interrupt_context_list_t interrupt_contexts;
+
+static irq_cmd_t default_cmds[] = {
+	{
+		.cmd = CMD_ACCEPT
+	}
+};
+
+static irq_code_t default_pseudocode = {
+	sizeof(default_cmds) / sizeof(irq_cmd_t),
+	default_cmds
+};
+
+
+static void driver_irq_handler(ipc_callid_t iid, ipc_call_t *icall)
+{	
+	int id = (int)IPC_GET_METHOD(*icall);
+	interrupt_context_t *ctx = find_interrupt_context_by_id(&interrupt_contexts, id);
+	if (NULL != ctx && NULL != ctx->handler) {
+		(*ctx->handler)(ctx->dev, iid, icall);		
+	}
+}
+
+int register_interrupt_handler(device_t *dev, int irq, interrupt_handler_t *handler, irq_code_t *pseudocode)
+{
+	interrupt_context_t *ctx = create_interrupt_context();
+	
+	ctx->dev = dev;
+	ctx->irq = irq;
+	ctx->handler = handler;
+	
+	add_interrupt_context(&interrupt_contexts, ctx);
+	
+	if (NULL == pseudocode) {
+		pseudocode = &default_pseudocode;
+	}
+	
+	int res = ipc_register_irq(irq, dev->handle, ctx->id, pseudocode);
+	if (0 != res) {
+		remove_interrupt_context(&interrupt_contexts, ctx);
+		delete_interrupt_context(ctx);
+	}
+	return res;	
+}
+
+int unregister_interrupt_handler(device_t *dev, int irq)
+{
+	interrupt_context_t *ctx = find_interrupt_context(&interrupt_contexts, dev, irq);
+	int res = ipc_unregister_irq(irq, dev->handle);
+	if (NULL != ctx) {
+		remove_interrupt_context(&interrupt_contexts, ctx);
+		delete_interrupt_context(ctx);		
+	}
+	return res;
+}
+
+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_remove(&dev->link);
+	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;
+}
+
+static void driver_add_device(ipc_callid_t iid, ipc_call_t *icall)
+{
+	char *dev_name = NULL;
+	int res = EOK;
+	
+	device_handle_t dev_handle =  IPC_GET_ARG1(*icall);
+	device_t *dev = create_device();
+	dev->handle = dev_handle;
+	
+	async_data_write_accept((void **)&dev_name, true, 0, 0, 0, 0);
+	dev->name = dev_name;
+	
+	add_to_devices_list(dev);		
+	res = driver->driver_ops->add_device(dev);
+	if (0 == res) {
+		printf("%s: new device with handle = %x was added.\n", driver->name, dev_handle);
+	} else {
+		printf("%s: failed to add a new device with handle = %d.\n", driver->name, dev_handle);	
+		remove_from_devices_list(dev);
+		delete_device(dev);	
+	}
+	
+	ipc_answer_0(iid, res);
+}
+
+static void driver_connection_devman(ipc_callid_t iid, ipc_call_t *icall)
+{
+	/* Accept connection */
+	ipc_answer_0(iid, EOK);
+
+	bool cont = true;
+	while (cont) {
+		ipc_call_t call;
+		ipc_callid_t callid = async_get_call(&call);
+
+		switch (IPC_GET_METHOD(call)) {
+		case IPC_M_PHONE_HUNGUP:
+			cont = false;
+			continue;
+		case DRIVER_ADD_DEVICE:
+			driver_add_device(callid, &call);
+			break;
+		default:
+			if (!(callid & IPC_CALLID_NOTIFICATION))
+				ipc_answer_0(callid, ENOENT);
+		}
+	}
+}
+
+/**
+ * Generic client connection handler both for applications and drivers.
+ *
+ * @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_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;
+	}
+	
+	
+	// TODO - if the client is not a driver, check whether it is allowed to use the device
+
+	int ret = EOK;
+	// open the device
+	if (NULL != dev->ops && NULL != dev->ops->open) {
+		ret = (*dev->ops->open)(dev);
+	}
+	
+	ipc_answer_0(iid, ret);	
+	if (EOK != ret) {
+		return;
+	}
+
+	while (1) {
+		ipc_callid_t callid;
+		ipc_call_t call;
+		callid = async_get_call(&call);
+		ipcarg_t method = IPC_GET_METHOD(call);
+		int iface_idx;
+		
+		switch  (method) {
+		case IPC_M_PHONE_HUNGUP:		
+			// close the device
+			if (NULL != dev->ops && NULL != dev->ops->close) {
+				(*dev->ops->close)(dev);
+			}			
+			ipc_answer_0(callid, EOK);
+			return;
+		default:		
+			// convert ipc interface id to interface index
+			
+			iface_idx = DEV_IFACE_IDX(method);
+			
+			if (!is_valid_iface_idx(iface_idx)) {
+				remote_handler_t *default_handler;
+				if (NULL != (default_handler = device_get_default_handler(dev))) {
+					(*default_handler)(dev, callid, &call);
+					break;
+				}
+				// this is not device's interface and the default handler is not provided
+				printf("%s: driver_connection_gen error - invalid interface id %d.", driver->name, iface_idx);
+				ipc_answer_0(callid, ENOTSUP);
+				break;
+			}
+
+			// calling one of the device's interfaces
+			
+			// get the device interface structure
+			void *iface = device_get_iface(dev, iface_idx);
+			if (NULL == iface) {
+				printf("%s: driver_connection_gen error - ", driver->name);
+				printf("device with handle %d has no interface with id %d.\n", handle, iface_idx);
+				ipc_answer_0(callid, ENOTSUP);
+				break;
+			}
+
+			// get the corresponding interface for remote request handling ("remote interface")
+			remote_iface_t* rem_iface = get_remote_iface(iface_idx);
+			assert(NULL != rem_iface);
+
+			// get the method of the remote interface
+			ipcarg_t iface_method_idx = IPC_GET_ARG1(call);
+			remote_iface_func_ptr_t iface_method_ptr = get_remote_method(rem_iface, iface_method_idx);
+			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;
+			}
+			
+			// call the remote interface's method, which will receive parameters from the remote client
+			// and it will pass it to the corresponding local interface method associated with the device 
+			// by its driver
+			(*iface_method_ptr)(dev, iface, callid, &call);
+			break;
+		}
+	}
+}
+
+static void driver_connection_driver(ipc_callid_t iid, ipc_call_t *icall)
+{
+	driver_connection_gen(iid, icall, true);
+}
+
+static void driver_connection_client(ipc_callid_t iid, ipc_call_t *icall)
+{
+	driver_connection_gen(iid, icall, false);
+}
+
+
+/** Function for handling connections to device driver.
+ *
+ */
+static void driver_connection(ipc_callid_t iid, ipc_call_t *icall)
+{
+	/* Select interface */
+	switch ((ipcarg_t) (IPC_GET_ARG1(*icall))) {
+	case DRIVER_DEVMAN:
+		// handle PnP events from device manager
+		driver_connection_devman(iid, icall);
+		break;
+	case DRIVER_DRIVER:
+		// handle request from drivers of child devices
+		driver_connection_driver(iid, icall);
+		break;
+	case DRIVER_CLIENT:
+		// handle requests from client applications
+		driver_connection_client(iid, icall);
+		break;
+
+	default:
+		/* No such interface */
+		ipc_answer_0(iid, ENOENT);
+	}
+}
+
+int child_device_register(device_t *child, device_t *parent)
+{
+	// printf("%s: child_device_register\n", driver->name);
+
+	assert(NULL != child->name);
+
+	int res;
+	
+	add_to_devices_list(child);
+	if (EOK == (res = devman_child_device_register(child->name, &child->match_ids, parent->handle, &child->handle))) {
+		return res;
+	}
+	remove_from_devices_list(child);	
+	return res;
+}
+
+int driver_main(driver_t *drv)
+{
+	// remember the driver structure - driver_ops will be called by generic handler for incoming connections
+	driver = drv;
+
+	// initialize the list of interrupt contexts
+	init_interrupt_context_list(&interrupt_contexts);
+	
+	// set generic interrupt handler
+	async_set_interrupt_received(driver_irq_handler);
+	
+	// register driver by device manager with generic handler for incoming connections
+	devman_driver_register(driver->name, driver_connection);
+
+	async_manager();
+
+	// Never reached
+	return 0;
+}
+
+/**
+ * @}
+ */
Index: uspace/lib/drv/generic/remote_char.c
===================================================================
--- uspace/lib/drv/generic/remote_char.c	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
+++ uspace/lib/drv/generic/remote_char.c	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
@@ -0,0 +1,151 @@
+/*
+ * Copyright (c) 2010 Lenka Trochtova 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libdrv
+ * @{
+ */
+/** @file
+ */
+
+#include <ipc/ipc.h>
+#include <async.h>
+#include <errno.h>
+
+#include "char.h"
+#include "driver.h"
+
+#define MAX_CHAR_RW_COUNT 256
+
+static void remote_char_read(device_t *dev, void *iface, ipc_callid_t callid, ipc_call_t *call);
+static void remote_char_write(device_t *dev, void *iface, ipc_callid_t callid, ipc_call_t *call);
+
+/** Remote character interface operations. 
+ */
+static remote_iface_func_ptr_t remote_char_iface_ops [] = {
+	&remote_char_read,
+	&remote_char_write	
+}; 
+ 
+/** Remote character interface structure. 
+ * Interface for processing request from remote clients addressed to the character interface.
+ */
+remote_iface_t remote_char_iface = {
+	.method_count = sizeof(remote_char_iface_ops) / sizeof(remote_iface_func_ptr_t),
+	.methods = remote_char_iface_ops
+};
+
+/** Process the read request from the remote client.
+ * 
+ * Receive the read request's parameters from the remote client and pass them to the local interface.
+ * Return the result of the operation processed by the local interface to the remote client.
+ * 
+ * @param dev the device from which the data are read.
+ * @param iface the local interface structure. 
+ */
+static void remote_char_read(device_t *dev, void *iface, ipc_callid_t callid, ipc_call_t *call)
+{	
+	char_iface_t *char_iface = (char_iface_t *)iface;
+	ipc_callid_t cid;
+	
+	size_t len;
+	if (!async_data_read_receive(&cid, &len)) {
+		// TODO handle protocol error
+		ipc_answer_0(callid, EINVAL);
+		return;
+	}
+	
+	if (!char_iface->read) {
+		async_data_read_finalize(cid, NULL, 0);
+		ipc_answer_0(callid, ENOTSUP);
+		return;
+	}
+	
+	if (len > MAX_CHAR_RW_COUNT) {
+		len = MAX_CHAR_RW_COUNT;
+	}
+	
+	char buf[MAX_CHAR_RW_COUNT];
+	int ret = (*char_iface->read)(dev, buf, len);
+	
+	if (ret < 0) { // some error occured
+		async_data_read_finalize(cid, buf, 0);
+		ipc_answer_0(callid, ret);
+		return;
+	}
+	
+	// the operation was successful, return the number of data read
+	async_data_read_finalize(cid, buf, ret);
+	ipc_answer_1(callid, EOK, ret);	
+}
+
+/** Process the write request from the remote client.
+ * 
+ * Receive the write request's parameters from the remote client and pass them to the local interface.
+ * Return the result of the operation processed by the local interface to the remote client.
+ * 
+ * @param dev the device to which the data are written.
+ * @param iface the local interface structure. 
+ */
+static void remote_char_write(device_t *dev, void *iface, ipc_callid_t callid, ipc_call_t *call)
+{
+	char_iface_t *char_iface = (char_iface_t *)iface;
+	ipc_callid_t cid;
+	size_t len;
+	
+	if (!async_data_write_receive(&cid, &len)) {
+		// TODO handle protocol error
+		ipc_answer_0(callid, EINVAL);
+		return;
+    }
+	
+	if (!char_iface->write) {
+		async_data_write_finalize(cid, NULL, 0);
+		ipc_answer_0(callid, ENOTSUP);
+		return;
+	}	
+	
+	if (len > MAX_CHAR_RW_COUNT) {
+		len = MAX_CHAR_RW_COUNT;
+	}
+	
+	char buf[MAX_CHAR_RW_COUNT];
+	
+	async_data_write_finalize(cid, buf, len);
+	
+	int ret = (*char_iface->write)(dev, buf, len);
+	if (ret < 0) { // some error occured
+		ipc_answer_0(callid, ret);
+	} else {
+		// the operation was successful, return the number of data written
+		ipc_answer_1(callid, EOK, ret);
+	}
+}
+
+ /**
+ * @}
+ */
Index: uspace/lib/drv/generic/remote_res.c
===================================================================
--- uspace/lib/drv/generic/remote_res.c	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
+++ uspace/lib/drv/generic/remote_res.c	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2010 Lenka Trochtova 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libdrv
+ * @{
+ */
+/** @file
+ */
+
+#include <ipc/ipc.h>
+#include <async.h>
+#include <errno.h>
+
+#include "driver.h"
+#include "resource.h"
+
+ 
+static void remote_res_get_resources(device_t *dev, void *iface, ipc_callid_t callid, ipc_call_t *call);
+static void remote_res_enable_interrupt(device_t *dev, void *iface, ipc_callid_t callid, ipc_call_t *call);
+
+static remote_iface_func_ptr_t remote_res_iface_ops [] = {
+	&remote_res_get_resources,
+	&remote_res_enable_interrupt	
+}; 
+ 
+remote_iface_t remote_res_iface = {
+	.method_count = sizeof(remote_res_iface_ops) / sizeof(remote_iface_func_ptr_t),
+	.methods = remote_res_iface_ops
+};
+
+static void remote_res_enable_interrupt(device_t *dev, void *iface, ipc_callid_t callid, ipc_call_t *call)
+{
+	resource_iface_t *ires = (resource_iface_t *)iface;
+	
+	if (NULL == ires->enable_interrupt) {
+		ipc_answer_0(callid, ENOTSUP);
+	} else if (ires->enable_interrupt(dev)) {
+		ipc_answer_0(callid, EOK);
+	} else {
+		ipc_answer_0(callid, EREFUSED);
+	}	
+}
+
+static void remote_res_get_resources(device_t *dev, void *iface, ipc_callid_t callid, ipc_call_t *call)
+{
+	resource_iface_t *ires = (resource_iface_t *)iface;	
+	if (NULL == ires->get_resources) {
+		ipc_answer_0(callid, ENOTSUP);
+		return;
+	}
+	
+	hw_resource_list_t *hw_resources = ires->get_resources(dev);	
+	if (NULL == hw_resources){
+		ipc_answer_0(callid, ENOENT);
+		return;
+	}	
+	
+	ipc_answer_1(callid, EOK, hw_resources->count);	
+
+	size_t len;
+	if (!async_data_read_receive(&callid, &len)) {
+		// protocol error - the recipient is not accepting data
+		return;
+	}
+	async_data_read_finalize(callid, hw_resources->resources, len);
+}
+ 
+ 
+ /**
+ * @}
+ */
Index: uspace/lib/drv/include/char.h
===================================================================
--- uspace/lib/drv/include/char.h	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
+++ uspace/lib/drv/include/char.h	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2010 Lenka Trochtova 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libdrv
+ * @{
+ */
+/** @file
+ */
+#ifndef LIBDRV_CHAR_H_
+#define LIBDRV_CHAR_H_
+
+#include "driver.h"
+
+typedef struct char_iface {
+	int (*read)(device_t *dev, char *buf, size_t count);
+	int (*write)(device_t *dev, char *buf, size_t count);	
+} char_iface_t;
+
+#endif
+
+/**
+ * @}
+ */
Index: uspace/lib/drv/include/dev_iface.h
===================================================================
--- uspace/lib/drv/include/dev_iface.h	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
+++ uspace/lib/drv/include/dev_iface.h	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2010 Lenka Trochtova 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libdrv
+ * @{
+ */
+/** @file
+ */
+#ifndef LIBDRV_DEV_IFACE_H_
+#define LIBDRV_DEV_IFACE_H_
+
+#include "driver.h"
+
+
+// TODO declare device interface structures here
+
+#endif
+
+/**
+ * @}
+ */
Index: uspace/lib/drv/include/driver.h
===================================================================
--- uspace/lib/drv/include/driver.h	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
+++ uspace/lib/drv/include/driver.h	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
@@ -0,0 +1,296 @@
+/*
+ * Copyright (c) 2010 Lenka Trochtova
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libdrv
+ * @{
+ */
+/** @file
+ */
+#ifndef LIBDRV_DRIVER_H_
+#define LIBDRV_DRIVER_H_
+
+
+#include <adt/list.h>
+#include <ipc/ipc.h>
+#include <devman.h>
+#include <ipc/devman.h>
+#include <ipc/dev_iface.h>
+#include <device/hw_res.h>
+#include <device/char.h>
+#include <assert.h>
+#include <ddi.h>
+#include <libarch/ddi.h>
+#include <fibril_synch.h>
+#include <malloc.h>
+
+struct device;
+typedef struct device device_t;
+
+// device interface
+
+// first two parameters: device and interface structure registered by the devices driver
+typedef void remote_iface_func_t(device_t*, void *, ipc_callid_t, ipc_call_t *);
+typedef remote_iface_func_t *remote_iface_func_ptr_t;
+typedef void remote_handler_t(device_t*, ipc_callid_t, ipc_call_t *);
+
+typedef struct {
+	size_t method_count;
+	remote_iface_func_ptr_t *methods;
+} remote_iface_t;
+
+typedef struct {
+	remote_iface_t * ifaces[DEV_IFACE_COUNT];
+} iface_dipatch_table_t;
+
+
+static inline bool is_valid_iface_idx(int idx)
+{
+	return 0 <= idx && idx < 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);
+
+
+// device class
+
+/** Devices operations. */
+typedef struct device_ops {
+	/** Optional callback function called when a client is connecting to the device. */
+	int (*open)(device_t *dev);
+	/** Optional callback function called when a client is disconnecting from the device. */
+	void (*close)(device_t *dev);
+	/** The table of standard interfaces implemented by the device. */
+	void *interfaces[DEV_IFACE_COUNT];	
+	/** The default handler of remote client requests. If the client's remote request cannot be handled 
+	 * by any of the standard interfaces, the default handler is used.*/
+	remote_handler_t *default_handler;
+} device_ops_t;
+
+
+// device
+
+/** The device. */
+struct device {
+	/** Globally unique device identifier (assigned to the device by the device manager). */
+	device_handle_t handle;
+	/** The phone to the parent device driver (if it is different from this driver).*/
+	int parent_phone;
+	/** Parent device if handled by this driver, NULL otherwise. */
+	device_t *parent;
+	/** The device's name.*/
+	const char *name;
+	/** The list of device ids for device-to-driver matching.*/
+	match_id_list_t match_ids;
+	/** The device driver's data associated with this device.*/
+	void *driver_data;
+	/** The implementation of operations provided by this device.*/
+	device_ops_t *ops;
+	/** Pointer to the previous and next device in the list of devices handled by the driver */
+	link_t link;
+};
+
+
+// driver
+
+/** Generic device driver operations. */
+typedef struct driver_ops {
+	/** Callback method for passing a new device to the device driver.*/
+	int (*add_device)(device_t *dev);
+	// TODO add other generic driver operations
+} driver_ops_t;
+
+/** The driver structure.*/
+typedef struct driver {
+	/** The name of the device driver. */
+	const char *name;
+	/** Generic device driver operations. */
+	driver_ops_t *driver_ops;
+} driver_t;
+
+int driver_main(driver_t *drv);
+
+/** Create new device structure. 
+ * 
+ * @return the device structure.
+ */
+static inline device_t * create_device()
+{
+	device_t *dev = malloc(sizeof(device_t));
+	if (NULL != dev) {
+		memset(dev, 0, sizeof(device_t));
+		init_match_ids(&dev->match_ids);
+	}	
+	return dev;
+}
+
+/** Delete device structure. 
+ * 
+ * @param dev the device structure.
+ */
+static inline void delete_device(device_t *dev)
+{
+	clean_match_ids(&dev->match_ids);
+	if (NULL != dev->name) {
+		free(dev->name);
+	}
+	free(dev);
+}
+
+static inline void * device_get_iface(device_t *dev, dev_inferface_idx_t idx)
+{
+	assert(is_valid_iface_idx(idx));	
+	if (NULL == dev->ops) {
+		return NULL;
+	}
+	return dev->ops->interfaces[idx];	
+}
+
+int child_device_register(device_t *child, device_t *parent);
+
+// interrupts
+
+typedef void interrupt_handler_t(device_t *dev, ipc_callid_t iid, ipc_call_t *icall);
+
+typedef struct interrupt_context {
+	int id;
+	device_t *dev;
+	int irq;
+	interrupt_handler_t *handler;
+	link_t link;
+} interrupt_context_t;
+
+typedef struct interrupt_context_list {
+	int curr_id;
+	link_t contexts;
+	fibril_mutex_t mutex;
+} interrupt_context_list_t;
+
+static inline interrupt_context_t * create_interrupt_context()
+{ 
+	interrupt_context_t *ctx = (interrupt_context_t *)malloc(sizeof(interrupt_context_t));
+	if (NULL != ctx) {
+		memset(ctx, 0, sizeof(interrupt_context_t));
+	}
+	return ctx;
+}
+
+static inline void delete_interrupt_context(interrupt_context_t *ctx)
+{
+	if (NULL != ctx) {
+		free(ctx);
+	}
+}
+
+static inline void init_interrupt_context_list(interrupt_context_list_t *list)
+{
+	memset(list, 0, sizeof(interrupt_context_list_t));
+	fibril_mutex_initialize(&list->mutex);
+	list_initialize(&list->contexts);	
+}
+
+static inline void add_interrupt_context(interrupt_context_list_t *list, interrupt_context_t *ctx)
+{
+	fibril_mutex_lock(&list->mutex);
+	
+	ctx->id = list->curr_id++;
+	list_append(&ctx->link, &list->contexts);
+	
+	fibril_mutex_unlock(&list->mutex);
+}
+
+static inline void remove_interrupt_context(interrupt_context_list_t *list, interrupt_context_t *ctx)
+{
+	fibril_mutex_lock(&list->mutex);
+	
+	list_remove(&ctx->link);
+	
+	fibril_mutex_unlock(&list->mutex);
+}
+
+static inline interrupt_context_t *find_interrupt_context_by_id(interrupt_context_list_t *list, int id) 
+{
+	fibril_mutex_lock(&list->mutex);	
+	link_t *link = list->contexts.next;
+	interrupt_context_t *ctx;
+	
+	while (link != &list->contexts) {
+		ctx = list_get_instance(link, interrupt_context_t, link);
+		if (id == ctx->id) {
+			fibril_mutex_unlock(&list->mutex);
+			return ctx;
+		}
+		link = link->next;
+	}	
+	fibril_mutex_unlock(&list->mutex);	
+	return NULL;
+}
+
+static inline interrupt_context_t *find_interrupt_context(interrupt_context_list_t *list, device_t *dev, int irq) 
+{
+	fibril_mutex_lock(&list->mutex);	
+	link_t *link = list->contexts.next;
+	interrupt_context_t *ctx;
+	
+	while (link != &list->contexts) {
+		ctx = list_get_instance(link, interrupt_context_t, link);
+		if (irq == ctx->irq && dev == ctx->dev) {
+			fibril_mutex_unlock(&list->mutex);
+			return ctx;
+		}
+		link = link->next;
+	}	
+	fibril_mutex_unlock(&list->mutex);	
+	return NULL;
+}
+
+int register_interrupt_handler(device_t *dev, int irq, interrupt_handler_t *handler, irq_code_t *pseudocode);
+int unregister_interrupt_handler(device_t *dev, int irq);
+
+
+// default handler for client requests
+
+static inline remote_handler_t * device_get_default_handler(device_t *dev)
+{
+	if (NULL == dev->ops) {
+		return NULL;
+	}
+	
+	return dev->ops->default_handler;	
+}
+
+static inline int add_device_to_class(device_t *dev, const char *class_name)
+{
+	return devman_add_device_to_class(dev->handle, class_name);
+}
+
+#endif
+
+/**
+ * @}
+ */
Index: uspace/lib/drv/include/remote_char.h
===================================================================
--- uspace/lib/drv/include/remote_char.h	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
+++ uspace/lib/drv/include/remote_char.h	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2010 Lenka Trochtova 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libdrv
+ * @{
+ */
+/** @file
+ */
+#ifndef LIBDRV_REMOTE_CHAR_H_
+#define LIBDRV_REMOTE_CHAR_H_
+
+remote_iface_t remote_char_iface;
+
+#endif
+
+/**
+ * @}
+ */
Index: uspace/lib/drv/include/remote_res.h
===================================================================
--- uspace/lib/drv/include/remote_res.h	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
+++ uspace/lib/drv/include/remote_res.h	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2010 Lenka Trochtova 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libdrv
+ * @{
+ */
+/** @file
+ */
+#ifndef LIBDRV_REMOTE_RES_H_
+#define LIBDRV_REMOTE_RES_H_
+
+remote_iface_t remote_res_iface;
+
+#endif
+
+/**
+ * @}
+ */
Index: uspace/lib/drv/include/resource.h
===================================================================
--- uspace/lib/drv/include/resource.h	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
+++ uspace/lib/drv/include/resource.h	(revision 04cb68f2d06da3440e206ec4339c4d23afa3910a)
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2010 Lenka Trochtova 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libdrv
+ * @{
+ */
+/** @file
+ */
+#ifndef LIBDRV_RESOURCE_H_
+#define LIBDRV_RESOURCE_H_
+
+#include "driver.h"
+
+typedef struct resource_iface {
+	 hw_resource_list_t * (*get_resources)(device_t *dev);
+	 bool (*enable_interrupt)(device_t *dev);	
+} resource_iface_t;
+
+
+#endif
+
+/**
+ * @}
+ */
