Index: uspace/lib/c/Makefile
===================================================================
--- uspace/lib/c/Makefile	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/c/Makefile	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -59,5 +59,5 @@
 	generic/devman.c \
 	generic/device/hw_res.c \
-	generic/device/char.c \
+	generic/device/char_dev.c \
 	generic/event.c \
 	generic/errno.c \
Index: uspace/lib/c/generic/adt/char_map.c
===================================================================
--- uspace/lib/c/generic/adt/char_map.c	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/c/generic/adt/char_map.c	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -65,5 +65,5 @@
  */
 static int
-char_map_add_item(char_map_t *map, const char *identifier, size_t length,
+char_map_add_item(char_map_t *map, const uint8_t *identifier, size_t length,
     const int value)
 {
@@ -139,5 +139,5 @@
  */
 int
-char_map_add(char_map_t *map, const char *identifier, size_t length,
+char_map_add(char_map_t *map, const uint8_t *identifier, size_t length,
     const int value)
 {
@@ -200,5 +200,5 @@
  */
 static char_map_t *
-char_map_find_node(const char_map_t *map, const char *identifier,
+char_map_find_node(const char_map_t *map, const uint8_t *identifier,
     size_t length)
 {
@@ -241,5 +241,5 @@
  * @return		CHAR_MAP_NULL if the key is not assigned a value.
  */
-int char_map_exclude(char_map_t *map, const char *identifier, size_t length)
+int char_map_exclude(char_map_t *map, const uint8_t *identifier, size_t length)
 {
 	char_map_t *node;
@@ -269,5 +269,5 @@
  *  @return		CHAR_MAP_NULL if the key is not assigned a value.
  */
-int char_map_find(const char_map_t *map, const char *identifier, size_t length)
+int char_map_find(const char_map_t *map, const uint8_t *identifier, size_t length)
 {
 	char_map_t *node;
@@ -329,5 +329,5 @@
  */
 int
-char_map_update(char_map_t *map, const char *identifier, const size_t length,
+char_map_update(char_map_t *map, const uint8_t *identifier, const size_t length,
     const int value)
 {
Index: uspace/lib/c/generic/adt/measured_strings.c
===================================================================
--- uspace/lib/c/generic/adt/measured_strings.c	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/c/generic/adt/measured_strings.c	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -59,5 +59,5 @@
  */
 measured_string_t *
-measured_string_create_bulk(const char *string, size_t length)
+measured_string_create_bulk(const uint8_t *string, size_t length)
 {
 	measured_string_t *new;
@@ -68,10 +68,10 @@
 	}
 	new = (measured_string_t *) malloc(sizeof(measured_string_t) +
-	    (sizeof(char) * (length + 1)));
+	    (sizeof(uint8_t) * (length + 1)));
 	if (!new)
 		return NULL;
 
 	new->length = length;
-	new->value = ((char *) new) + sizeof(measured_string_t);
+	new->value = ((uint8_t *) new) + sizeof(measured_string_t);
 	// append terminating zero explicitly - to be safe
 	memcpy(new->value, string, new->length);
@@ -97,5 +97,5 @@
 	new = (measured_string_t *) malloc(sizeof(measured_string_t));
 	if (new) {
-		new->value = (char *) malloc(source->length + 1);
+		new->value = (uint8_t *) malloc(source->length + 1);
 		if (new->value) {
 			new->length = source->length;
@@ -131,5 +131,5 @@
  */
 int
-measured_strings_receive(measured_string_t **strings, char **data,
+measured_strings_receive(measured_string_t **strings, uint8_t **data,
     size_t count)
 {
@@ -137,5 +137,5 @@
 	size_t index;
 	size_t length;
-	char *next;
+	uint8_t *next;
 	ipc_callid_t callid;
 	int rc;
@@ -311,10 +311,10 @@
  */
 int
-measured_strings_return(int phone, measured_string_t **strings, char **data,
+measured_strings_return(int phone, measured_string_t **strings, uint8_t **data,
     size_t count)
 {
 	size_t *lengths;
 	size_t index;
-	char *next;
+	uint8_t *next;
 	int rc;
 
Index: uspace/lib/c/generic/async_sess.c
===================================================================
--- uspace/lib/c/generic/async_sess.c	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/c/generic/async_sess.c	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -110,10 +110,11 @@
 typedef struct {
 	link_t sess_link;	/**< Link for the session list of inactive connections. */
-	link_t global_link;	/**< Link for the global list of inactive connectinos. */
+	link_t global_link;	/**< Link for the global list of inactive connections. */
 	int data_phone;		/**< Connected data phone. */
 } conn_node_t;
 
 /**
- * Mutex protecting the inactive_conn_head list and the session list.
+ * Mutex protecting the inactive_conn_head list, the session list and the
+ * avail_phone condition variable.
  */
 static fibril_mutex_t async_sess_mutex;
@@ -128,4 +129,9 @@
  */
 static LIST_INITIALIZE(session_list_head);
+
+/**
+ * Condition variable used to wait for a phone to become available.
+ */
+static FIBRIL_CONDVAR_INITIALIZE(avail_phone_cv);
 
 /** Initialize the async_sess subsystem.
@@ -150,8 +156,13 @@
  * @param sess	Session structure provided by caller, will be filled in.
  * @param phone	Phone connected to the desired server task.
- */
-void async_session_create(async_sess_t *sess, int phone)
+ * @param arg1	Value to pass as first argument upon creating a new
+ *		connection. Typical use is to identify a resource within
+ *		the server that the caller wants to access (port ID,
+ *		interface ID, device ID, etc.).
+ */
+void async_session_create(async_sess_t *sess, int phone, sysarg_t arg1)
 {
 	sess->sess_phone = phone;
+	sess->connect_arg1 = arg1;
 	list_initialize(&sess->conn_head);
 	
@@ -192,4 +203,6 @@
 		free(conn);
 	}
+	
+	fibril_condvar_broadcast(&avail_phone_cv);
 }
 
@@ -231,5 +244,6 @@
 		 */
 retry:
-		data_phone = async_connect_me_to(sess->sess_phone, 0, 0, 0);
+		data_phone = async_connect_me_to(sess->sess_phone,
+		    sess->connect_arg1, 0, 0);
 		if (data_phone >= 0) {
 			/* success, do nothing */
@@ -250,10 +264,8 @@
 		} else {
 			/*
-			 * This is unfortunate. We failed both to find a cached
-			 * connection or to create a new one even after cleaning up
-			 * the cache. This is most likely due to too many
-			 * open sessions (connected session phones).
+			 * Wait for a phone to become available.
 			 */
-			data_phone = ELIMIT;
+			fibril_condvar_wait(&avail_phone_cv, &async_sess_mutex);
+			goto retry;
 		}
 	}
@@ -273,4 +285,5 @@
 
 	fibril_mutex_lock(&async_sess_mutex);
+	fibril_condvar_signal(&avail_phone_cv);
 	conn = (conn_node_t *) malloc(sizeof(conn_node_t));
 	if (!conn) {
@@ -279,6 +292,6 @@
 		 * means that we simply hang up.
 		 */
+		ipc_hangup(data_phone);
 		fibril_mutex_unlock(&async_sess_mutex);
-		ipc_hangup(data_phone);
 		return;
 	}
Index: uspace/lib/c/generic/device/char.c
===================================================================
--- uspace/lib/c/generic/device/char.c	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ 	(revision )
@@ -1,133 +1,0 @@
-/*
- * 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 device.
- *
- * Helper function to read to or write from a device
- * using its character interface.
- *
- * @param dev_phone Phone to the device.
- * @param buf       Buffer for the data read
- *                  from or written to the device.
- * @param len       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 ssize_t rw_dev(int dev_phone, void *buf, size_t len, bool read)
-{
-	async_serialize_start();
-	
-	ipc_call_t answer;
-	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);
-	}
-	
-	sysarg_t rc;
-	if (ret != EOK) {
-		async_wait_for(req, &rc);
-		async_serialize_end();
-		if (rc == EOK)
-			return (ssize_t) ret;
-			
-		return (ssize_t) rc;
-	}
-	
-	async_wait_for(req, &rc);
-	async_serialize_end();
-	
-	ret = (int) rc;
-	if (ret != EOK)
-		return (ssize_t) ret;
-	
-	return (ssize_t) IPC_GET_ARG1(answer);
-}
-
-/** Read from device using its character interface.
- *
- * @param dev_phone Phone to the device.
- * @param buf       Output buffer for the data
- *                  read from the device.
- * @param len       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.
- *
- */
-ssize_t read_dev(int dev_phone, void *buf, size_t len)
-{
-	return rw_dev(dev_phone, buf, len, true);
-}
-
-/** Write to device using its character interface.
- *
- * @param dev_phone Phone to the device.
- * @param buf       Input buffer containg the data
- *                  to be written to the device.
- * @param len       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.
- *
- */
-ssize_t write_dev(int dev_phone, void *buf, size_t len)
-{
-	return rw_dev(dev_phone, buf, len, false);
-}
-
-/** @}
- */
Index: uspace/lib/c/generic/device/char_dev.c
===================================================================
--- uspace/lib/c/generic/device/char_dev.c	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
+++ uspace/lib/c/generic/device/char_dev.c	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -0,0 +1,124 @@
+/*
+ * 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_dev.h>
+#include <errno.h>
+#include <async.h>
+#include <malloc.h>
+#include <stdio.h>
+
+/** Read to or write from device.
+ *
+ * Helper function to read to or write from a device
+ * using its character interface.
+ *
+ * @param dev_phone	Phone to the device.
+ * @param buf		Buffer for the data read from or written to the device.
+ * @param size		Maximum size of data (in bytes) 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 ssize_t char_dev_rw(int dev_phone, void *buf, size_t size, bool read)
+{
+	async_serialize_start();
+	
+	ipc_call_t answer;
+	aid_t req;
+	int ret;
+	
+	if (read) {
+		req = async_send_1(dev_phone, DEV_IFACE_ID(CHAR_DEV_IFACE),
+		    CHAR_DEV_READ, &answer);
+		ret = async_data_read_start(dev_phone, buf, size);
+	} else {
+		req = async_send_1(dev_phone, DEV_IFACE_ID(CHAR_DEV_IFACE),
+		    CHAR_DEV_WRITE, &answer);
+		ret = async_data_write_start(dev_phone, buf, size);
+	}
+	
+	sysarg_t rc;
+	if (ret != EOK) {
+		async_wait_for(req, &rc);
+		async_serialize_end();
+		if (rc == EOK)
+			return (ssize_t) ret;
+		
+		return (ssize_t) rc;
+	}
+	
+	async_wait_for(req, &rc);
+	async_serialize_end();
+	
+	ret = (int) rc;
+	if (ret != EOK)
+		return (ssize_t) ret;
+	
+	return (ssize_t) IPC_GET_ARG1(answer);
+}
+
+/** Read from character device.
+ *
+ * @param dev_phone	Phone to the device.
+ * @param buf		Output buffer for the data read from the device.
+ * @param size		Maximum size (in bytes) of the data to be read.
+ *
+ * @return		Non-negative number of bytes actually read from the
+ *			device on success, negative error number otherwise.
+ */
+ssize_t char_dev_read(int dev_phone, void *buf, size_t size)
+{
+	return char_dev_rw(dev_phone, buf, size, true);
+}
+
+/** Write to character device.
+ *
+ * @param dev_phone	Phone to the device.
+ * @param buf		Input buffer containg the data to be written to the
+ *			device.
+ * @param size		Maximum size (in bytes) of the data to be written.
+ *
+ * @return		Non-negative number of bytes actually written to the
+ *			device on success, negative error number otherwise.
+ */
+ssize_t char_dev_write(int dev_phone, void *buf, size_t size)
+{
+	return char_dev_rw(dev_phone, buf, size, false);
+}
+
+/** @}
+ */
Index: uspace/lib/c/generic/device/hw_res.c
===================================================================
--- uspace/lib/c/generic/device/hw_res.c	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/c/generic/device/hw_res.c	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -26,5 +26,5 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
- 
+
  /** @addtogroup libc
  * @{
@@ -32,5 +32,5 @@
 /** @file
  */
- 
+
 #include <device/hw_res.h>
 #include <errno.h>
@@ -38,8 +38,11 @@
 #include <malloc.h>
 
-int get_hw_resources(int dev_phone, hw_resource_list_t *hw_resources)
+int hw_res_get_resource_list(int dev_phone, hw_resource_list_t *hw_resources)
 {
 	sysarg_t count = 0;
-	int rc = async_req_1_1(dev_phone, DEV_IFACE_ID(HW_RES_DEV_IFACE), GET_RESOURCE_LIST, &count);
+
+	int rc = async_req_1_1(dev_phone, DEV_IFACE_ID(HW_RES_DEV_IFACE),
+	    HW_RES_GET_RESOURCE_LIST, &count);
+
 	hw_resources->count = count;
 	if (rc != EOK)
@@ -57,16 +60,16 @@
 		return rc;
 	}
-	 	 
+	
 	return EOK;
 }
 
-bool enable_interrupt(int dev_phone)
+bool hw_res_enable_interrupt(int dev_phone)
 {
-	int rc = async_req_1_0(dev_phone, DEV_IFACE_ID(HW_RES_DEV_IFACE), ENABLE_INTERRUPT);
+	int rc = async_req_1_0(dev_phone, DEV_IFACE_ID(HW_RES_DEV_IFACE),
+	    HW_RES_ENABLE_INTERRUPT);
+
 	return rc == EOK;
 }
- 
- 
- 
- /** @}
+
+/** @}
  */
Index: uspace/lib/c/generic/devman.c
===================================================================
--- uspace/lib/c/generic/devman.c	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/c/generic/devman.c	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -42,4 +42,5 @@
 #include <devman.h>
 #include <async.h>
+#include <fibril_synch.h>
 #include <errno.h>
 #include <malloc.h>
@@ -50,30 +51,40 @@
 static int devman_phone_client = -1;
 
+static FIBRIL_MUTEX_INITIALIZE(devman_phone_mutex);
+
 int devman_get_phone(devman_interface_t iface, unsigned int flags)
 {
 	switch (iface) {
 	case DEVMAN_DRIVER:
-		if (devman_phone_driver >= 0)
+		fibril_mutex_lock(&devman_phone_mutex);
+		if (devman_phone_driver >= 0) {
+			fibril_mutex_unlock(&devman_phone_mutex);
 			return devman_phone_driver;
+		}
 		
 		if (flags & IPC_FLAG_BLOCKING)
-			devman_phone_driver = ipc_connect_me_to_blocking(PHONE_NS,
+			devman_phone_driver = async_connect_me_to_blocking(
+			    PHONE_NS, SERVICE_DEVMAN, DEVMAN_DRIVER, 0);
+		else
+			devman_phone_driver = async_connect_me_to(PHONE_NS,
 			    SERVICE_DEVMAN, DEVMAN_DRIVER, 0);
-		else
-			devman_phone_driver = ipc_connect_me_to(PHONE_NS,
-			    SERVICE_DEVMAN, DEVMAN_DRIVER, 0);
-		
+		
+		fibril_mutex_unlock(&devman_phone_mutex);
 		return devman_phone_driver;
 	case DEVMAN_CLIENT:
-		if (devman_phone_client >= 0)
+		fibril_mutex_lock(&devman_phone_mutex);
+		if (devman_phone_client >= 0) {
+			fibril_mutex_unlock(&devman_phone_mutex);
 			return devman_phone_client;
+		}
 		
 		if (flags & IPC_FLAG_BLOCKING)
-			devman_phone_client = ipc_connect_me_to_blocking(PHONE_NS,
+			devman_phone_client = async_connect_me_to_blocking(
+			    PHONE_NS, SERVICE_DEVMAN, DEVMAN_CLIENT, 0);
+		else
+			devman_phone_client = async_connect_me_to(PHONE_NS,
 			    SERVICE_DEVMAN, DEVMAN_CLIENT, 0);
-		else
-			devman_phone_client = ipc_connect_me_to(PHONE_NS,
-			    SERVICE_DEVMAN, DEVMAN_CLIENT, 0);
-		
+		
+		fibril_mutex_unlock(&devman_phone_mutex);
 		return devman_phone_client;
 	default:
@@ -245,8 +256,8 @@
 	
 	if (flags & IPC_FLAG_BLOCKING) {
-		phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_DEVMAN,
+		phone = async_connect_me_to_blocking(PHONE_NS, SERVICE_DEVMAN,
 		    DEVMAN_CONNECT_TO_PARENTS_DEVICE, handle);
 	} else {
-		phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAN,
+		phone = async_connect_me_to(PHONE_NS, SERVICE_DEVMAN,
 		    DEVMAN_CONNECT_TO_PARENTS_DEVICE, handle);
 	}
Index: uspace/lib/c/generic/fibril.c
===================================================================
--- uspace/lib/c/generic/fibril.c	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/c/generic/fibril.c	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -361,4 +361,9 @@
 }
 
+int fibril_get_sercount(void)
+{
+	return serialization_count;
+}
+
 /** @}
  */
Index: uspace/lib/c/generic/fibril_synch.c
===================================================================
--- uspace/lib/c/generic/fibril_synch.c	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/c/generic/fibril_synch.c	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -104,4 +104,7 @@
 	fibril_t *f = (fibril_t *) fibril_get_id();
 
+	if (fibril_get_sercount() != 0)
+		core();
+
 	futex_down(&async_futex);
 	if (fm->counter-- <= 0) {
@@ -194,4 +197,7 @@
 	fibril_t *f = (fibril_t *) fibril_get_id();
 	
+	if (fibril_get_sercount() != 0)
+		core();
+
 	futex_down(&async_futex);
 	if (frw->writers) {
@@ -219,4 +225,7 @@
 	fibril_t *f = (fibril_t *) fibril_get_id();
 	
+	if (fibril_get_sercount() != 0)
+		core();
+
 	futex_down(&async_futex);
 	if (frw->writers || frw->readers) {
Index: uspace/lib/c/generic/io/vprintf.c
===================================================================
--- uspace/lib/c/generic/io/vprintf.c	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/c/generic/io/vprintf.c	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -37,9 +37,9 @@
 #include <unistd.h>
 #include <io/printf_core.h>
-#include <futex.h>
+#include <fibril_synch.h>
 #include <async.h>
 #include <str.h>
 
-static atomic_t printf_futex = FUTEX_INITIALIZER;
+static FIBRIL_MUTEX_INITIALIZE(printf_mutex);
 
 static int vprintf_str_write(const char *str, size_t size, void *stream)
@@ -85,16 +85,9 @@
 	 * Prevent other threads to execute printf_core()
 	 */
-	futex_down(&printf_futex);
-	
-	/*
-	 * Prevent other fibrils of the same thread
-	 * to execute printf_core()
-	 */
-	async_serialize_start();
+	fibril_mutex_lock(&printf_mutex);
 	
 	int ret = printf_core(fmt, &ps, ap);
 	
-	async_serialize_end();
-	futex_up(&printf_futex);
+	fibril_mutex_unlock(&printf_mutex);
 	
 	return ret;
Index: uspace/lib/c/generic/mem.c
===================================================================
--- uspace/lib/c/generic/mem.c	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/c/generic/mem.c	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -222,15 +222,20 @@
 /** Compare two memory areas.
  *
- * @param s1		Pointer to the first area to compare.
- * @param s2		Pointer to the second area to compare.
- * @param len		Size of the first area in bytes. Both areas must have
- * 			the same length.
- * @return		If len is 0, return zero. If the areas match, return
- * 			zero. Otherwise return non-zero.
- */
-int bcmp(const char *s1, const char *s2, size_t len)
-{
-	for (; len && *s1++ == *s2++; len--)
-		;
+ * @param s1  Pointer to the first area to compare.
+ * @param s2  Pointer to the second area to compare.
+ * @param len Size of the first area in bytes. Both areas must have
+ *            the same length.
+ *
+ * @return If len is 0, return zero. If the areas match, return
+ *         zero. Otherwise return non-zero.
+ *
+ */
+int bcmp(const void *s1, const void *s2, size_t len)
+{
+	uint8_t *u1 = (uint8_t *) s1;
+	uint8_t *u2 = (uint8_t *) s2;
+	
+	for (; (len != 0) && (*u1++ == *u2++); len--);
+	
 	return len;
 }
Index: uspace/lib/c/generic/net/modules.c
===================================================================
--- uspace/lib/c/generic/net/modules.c	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/c/generic/net/modules.c	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -32,5 +32,5 @@
 
 /** @file
- * Generic module functions implementation. 
+ * Generic module functions implementation.
  *
  * @todo MAKE IT POSSIBLE TO REMOVE THIS FILE VIA EITHER REPLACING PART OF ITS
@@ -52,18 +52,18 @@
 #define MODULE_WAIT_TIME	(10 * 1000)
 
-/** Answers the call.
- *
- * @param[in] callid	The call identifier.
- * @param[in] result	The message processing result.
- * @param[in] answer	The message processing answer.
- * @param[in] answer_count The number of answer parameters.
- */
-void
-answer_call(ipc_callid_t callid, int result, ipc_call_t *answer,
-    int answer_count)
-{
-	/* Choose the most efficient answer function */
-	if (answer || (!answer_count)) {
-		switch (answer_count) {
+/** Answer a call.
+ *
+ * @param[in] callid Call identifier.
+ * @param[in] result Message processing result.
+ * @param[in] answer Message processing answer.
+ * @param[in] count  Number of answer parameters.
+ *
+ */
+void answer_call(ipc_callid_t callid, int result, ipc_call_t *answer,
+    size_t count)
+{
+	/* Choose the most efficient function */
+	if ((answer != NULL) || (count == 0)) {
+		switch (count) {
 		case 0:
 			ipc_answer_0(callid, (sysarg_t) result);
@@ -228,19 +228,19 @@
 }
 
-/** Refreshes answer structure and parameters count.
- *
- * Erases all attributes.
- *
- * @param[in,out] answer The message processing answer structure.
- * @param[in,out] answer_count The number of answer parameters.
- */
-void refresh_answer(ipc_call_t *answer, int *answer_count)
-{
-	if (answer_count)
-		*answer_count = 0;
-
-	if (answer) {
+/** Refresh answer structure and argument count.
+ *
+ * Erase all arguments.
+ *
+ * @param[in,out] answer Message processing answer structure.
+ * @param[in,out] count  Number of answer arguments.
+ *
+ */
+void refresh_answer(ipc_call_t *answer, size_t *count)
+{
+	if (count != NULL)
+		*count = 0;
+	
+	if (answer != NULL) {
 		IPC_SET_RETVAL(*answer, 0);
-		/* Just to be precise */
 		IPC_SET_IMETHOD(*answer, 0);
 		IPC_SET_ARG1(*answer, 0);
Index: uspace/lib/c/include/adt/char_map.h
===================================================================
--- uspace/lib/c/include/adt/char_map.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/c/include/adt/char_map.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -41,10 +41,10 @@
 
 /** Invalid assigned value used also if an&nbsp;entry does not exist. */
-#define CHAR_MAP_NULL	(-1)
+#define CHAR_MAP_NULL  (-1)
 
 /** Type definition of the character string to integer map.
  *  @see char_map
  */
-typedef struct char_map	char_map_t;
+typedef struct char_map char_map_t;
 
 /** Character string to integer map item.
@@ -56,5 +56,5 @@
 struct char_map {
 	/** Actually mapped character. */
-	char c;
+	uint8_t c;
 	/** Stored integral value. */
 	int value;
@@ -71,8 +71,8 @@
 extern int char_map_initialize(char_map_t *);
 extern void char_map_destroy(char_map_t *);
-extern int char_map_exclude(char_map_t *, const char *, size_t);
-extern int char_map_add(char_map_t *, const char *, size_t, const int);
-extern int char_map_find(const char_map_t *, const char *, size_t);
-extern int char_map_update(char_map_t *, const char *, size_t, const int);
+extern int char_map_exclude(char_map_t *, const uint8_t *, size_t);
+extern int char_map_add(char_map_t *, const uint8_t *, size_t, const int);
+extern int char_map_find(const char_map_t *, const uint8_t *, size_t);
+extern int char_map_update(char_map_t *, const uint8_t *, size_t, const int);
 
 #endif
Index: uspace/lib/c/include/adt/generic_char_map.h
===================================================================
--- uspace/lib/c/include/adt/generic_char_map.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/c/include/adt/generic_char_map.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -62,9 +62,9 @@
 	}; \
 	\
-	int name##_add(name##_t *, const char *, const size_t, type *); \
+	int name##_add(name##_t *, const uint8_t *, const size_t, type *); \
 	int name##_count(name##_t *); \
 	void name##_destroy(name##_t *); \
-	void name##_exclude(name##_t *, const char *, const size_t); \
-	type *name##_find(name##_t *, const char *, const size_t); \
+	void name##_exclude(name##_t *, const uint8_t *, const size_t); \
+	type *name##_find(name##_t *, const uint8_t *, const size_t); \
 	int name##_initialize(name##_t *); \
 	int name##_is_valid(name##_t *);
@@ -74,11 +74,12 @@
  * Should follow declaration with the same parameters.
  *
- * @param[in] name	Name of the map.
- * @param[in] type	Inner object type.
+ * @param[in] name Name of the map.
+ * @param[in] type Inner object type.
+ *
  */
 #define GENERIC_CHAR_MAP_IMPLEMENT(name, type) \
 	GENERIC_FIELD_IMPLEMENT(name##_items, type) \
 	\
-	int name##_add(name##_t *map, const char *name, const size_t length, \
+	int name##_add(name##_t *map, const uint8_t *name, const size_t length, \
 	     type *value) \
 	{ \
@@ -112,5 +113,5 @@
 	} \
 	\
-	void name##_exclude(name##_t *map, const char *name, \
+	void name##_exclude(name##_t *map, const uint8_t *name, \
 	    const size_t length) \
 	{ \
@@ -124,5 +125,5 @@
 	} \
 	\
-	type *name##_find(name##_t *map, const char *name, \
+	type *name##_find(name##_t *map, const uint8_t *name, \
 	    const size_t length) \
 	{ \
Index: uspace/lib/c/include/adt/measured_strings.h
===================================================================
--- uspace/lib/c/include/adt/measured_strings.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/c/include/adt/measured_strings.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -54,14 +54,14 @@
 struct measured_string {
 	/** Character string data. */
-	char *value;
+	uint8_t *value;
 	/** Character string length. */
 	size_t length;
 };
 
-extern measured_string_t *measured_string_create_bulk(const char *, size_t);
+extern measured_string_t *measured_string_create_bulk(const uint8_t *, size_t);
 extern measured_string_t *measured_string_copy(measured_string_t *);
-extern int measured_strings_receive(measured_string_t **, char **, size_t);
+extern int measured_strings_receive(measured_string_t **, uint8_t **, size_t);
 extern int measured_strings_reply(const measured_string_t *, size_t);
-extern int measured_strings_return(int, measured_string_t **, char **, size_t);
+extern int measured_strings_return(int, measured_string_t **, uint8_t **, size_t);
 extern int measured_strings_send(int, const measured_string_t *, size_t);
 
Index: uspace/lib/c/include/assert.h
===================================================================
--- uspace/lib/c/include/assert.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/c/include/assert.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -57,4 +57,6 @@
 			printf("Assertion failed (%s) at file '%s', " \
 			    "line %d.\n", #expr, __FILE__, __LINE__); \
+			stacktrace_print(); \
+			core(); \
 			abort(); \
 		} \
Index: uspace/lib/c/include/async_sess.h
===================================================================
--- uspace/lib/c/include/async_sess.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/c/include/async_sess.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -40,4 +40,5 @@
 typedef struct {
 	int sess_phone;		/**< Phone for cloning off the connections. */
+	sysarg_t connect_arg1;  /**< Argument for CONNECT_ME_TO. */
 	link_t conn_head;	/**< List of open data connections. */
 	link_t sess_link;	/**< Link in global list of open sessions. */
@@ -45,5 +46,5 @@
 
 extern void _async_sess_init(void);
-extern void async_session_create(async_sess_t *, int);
+extern void async_session_create(async_sess_t *, int, sysarg_t);
 extern void async_session_destroy(async_sess_t *);
 extern int async_exchange_begin(async_sess_t *);
Index: uspace/lib/c/include/device/char.h
===================================================================
--- uspace/lib/c/include/device/char.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ 	(revision )
@@ -1,49 +1,0 @@
-/*
- * 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;
-
-ssize_t read_dev(int dev_phone, void *buf, size_t len);
-ssize_t write_dev(int dev_phone, void *buf, size_t len);
-
-#endif
-
-/** @}
- */
Index: uspace/lib/c/include/device/char_dev.h
===================================================================
--- uspace/lib/c/include/device/char_dev.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
+++ uspace/lib/c/include/device/char_dev.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -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_CHAR_DEV_H_
+#define LIBC_DEVICE_CHAR_DEV_H_
+
+typedef enum {
+	CHAR_DEV_READ = 0,
+	CHAR_DEV_WRITE
+} char_dev_method_t;
+
+ssize_t char_dev_read(int dev_phone, void *buf, size_t len);
+ssize_t char_dev_write(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 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/c/include/device/hw_res.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -27,5 +27,5 @@
  */
  
- /** @addtogroup libc
+/** @addtogroup libc
  * @{
  */
@@ -39,12 +39,11 @@
 #include <bool.h>
 
-// HW resource provider interface
+/** HW resource provider interface */
+typedef enum {
+	HW_RES_GET_RESOURCE_LIST = 0,
+	HW_RES_ENABLE_INTERRUPT
+} hw_res_method_t;
 
-typedef enum {
-	GET_RESOURCE_LIST = 0,
-	ENABLE_INTERRUPT	
-} hw_res_funcs_t;
-
-/** HW resource types. */
+/** HW resource types */
 typedef enum {
 	INTERRUPT,
@@ -58,44 +57,44 @@
 } endianness_t;
 
-
-/** HW resource (e.g. interrupt, memory register, i/o register etc.). */
-typedef struct hw_resource {
+/** HW resource (e.g. interrupt, memory register, i/o register etc.) */
+typedef struct {
 	hw_res_type_t type;
 	union {
 		struct {
 			uint64_t address;
-			endianness_t endianness;			
-			size_t size;			
+			endianness_t endianness;
+			size_t size;
 		} mem_range;
+
 		struct {
 			uint64_t address;
-			endianness_t endianness;			
-			size_t size;			
+			endianness_t endianness;
+			size_t size;
 		} io_range;
+
 		struct {
-			int irq;			
-		} interrupt;		
-	} res;	
+			int irq;
+		} interrupt;
+	} res;
 } hw_resource_t;
 
-typedef struct hw_resource_list {
+typedef struct {
 	size_t count;
-	hw_resource_t *resources;	
+	hw_resource_t *resources;
 } hw_resource_list_t;
 
-static inline void clean_hw_resource_list(hw_resource_list_t *hw_res)
+static inline void hw_res_clean_resource_list(hw_resource_list_t *hw_res)
 {
-	if(NULL != hw_res->resources) {
+	if (hw_res->resources != NULL) {
 		free(hw_res->resources);
+
 		hw_res->resources = NULL;
 	}
-	hw_res->count = 0;	
+
+	hw_res->count = 0;
 }
 
-
-
-extern int get_hw_resources(int, hw_resource_list_t *);
-extern bool enable_interrupt(int);
-
+extern int hw_res_get_resource_list(int, hw_resource_list_t *);
+extern bool hw_res_enable_interrupt(int);
 
 #endif
Index: uspace/lib/c/include/fibril.h
===================================================================
--- uspace/lib/c/include/fibril.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/c/include/fibril.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -94,4 +94,5 @@
 extern void fibril_inc_sercount(void);
 extern void fibril_dec_sercount(void);
+extern int fibril_get_sercount(void);
 
 static inline int fibril_yield(void)
Index: uspace/lib/c/include/ipc/arp.h
===================================================================
--- uspace/lib/c/include/ipc/arp.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/c/include/ipc/arp.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -69,12 +69,10 @@
 /*@{*/
 
-/** Returns the protocol service message parameter.
- * @param[in] call The message call structure.
+/** Return the protocol service message parameter.
+ *
+ * @param[in] call Message call structure.
+ *
  */
-#define ARP_GET_NETIF(call) \
-	({ \
-		services_t service = (services_t) IPC_GET_ARG2(*call); \
-		service; \
-	})
+#define ARP_GET_NETIF(call) ((services_t) IPC_GET_ARG2(call))
 
 /*@}*/
Index: uspace/lib/c/include/ipc/bus.h
===================================================================
--- uspace/lib/c/include/ipc/bus.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ 	(revision )
@@ -1,47 +1,0 @@
-/*
- * Copyright (c) 2009 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.
- */
-
-/** @addtogroup libcipc
- * @{
- */
-/** @file
- */ 
-
-#ifndef LIBC_BUS_H_
-#define LIBC_BUS_H_
-
-#include <ipc/ipc.h>
-
-typedef enum {
-	BUS_CLEAR_INTERRUPT = IPC_FIRST_USER_METHOD
-} bus_request_t;
-
-#endif
-
-/** @}
- */
Index: uspace/lib/c/include/ipc/dev_iface.h
===================================================================
--- uspace/lib/c/include/ipc/dev_iface.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/c/include/ipc/dev_iface.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -35,6 +35,6 @@
 #include <libarch/types.h>
 
-typedef enum {	
-	HW_RES_DEV_IFACE = 0,	
+typedef enum {
+	HW_RES_DEV_IFACE = 0,
 	CHAR_DEV_IFACE,
 
@@ -44,5 +44,4 @@
 	USBHC_DEV_IFACE,
 
-	// TODO add more interfaces
 	DEV_IFACE_MAX
 } dev_inferface_idx_t;
Index: uspace/lib/c/include/ipc/icmp.h
===================================================================
--- uspace/lib/c/include/ipc/icmp.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/c/include/ipc/icmp.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -82,83 +82,58 @@
 /*@{*/
 
-/** Returns the ICMP code message parameter.
+/** Return the ICMP code message parameter.
  *
- * @param[in] call	The message call structure.
+ * @param[in] call Message call structure.
+ *
  */
-#define ICMP_GET_CODE(call) \
-	({ \
-		icmp_code_t code = (icmp_code_t) IPC_GET_ARG1(*call); \
-		code; \
-	})
+#define ICMP_GET_CODE(call)  ((icmp_code_t) IPC_GET_ARG1(call))
 
-/** Returns the ICMP link MTU message parameter.
+/** Return the ICMP link MTU message parameter.
  *
- * @param[in] call	The message call structure.
+ * @param[in] call Message call structure.
+ *
  */
-#define ICMP_GET_MTU(call) \
-	({ \
-		icmp_param_t mtu = (icmp_param_t) IPC_GET_ARG3(*call); \
-		mtu; \
-	})
+#define ICMP_GET_MTU(call)  ((icmp_param_t) IPC_GET_ARG3(call))
 
-/** Returns the pointer message parameter.
+/** Return the pointer message parameter.
  *
- * @param[in] call	The message call structure.
+ * @param[in] call Message call structure.
+ *
  */
-#define ICMP_GET_POINTER(call) \
-	({ \
-		icmp_param_t pointer = (icmp_param_t) IPC_GET_ARG3(*call); \
-		pointer; \
-	})
+#define ICMP_GET_POINTER(call)  ((icmp_param_t) IPC_GET_ARG3(call))
 
-/** Returns the size message parameter.
+/** Return the size message parameter.
  *
- * @param[in] call	The message call structure.
+ * @param[in] call Message call structure.
+ *
  */
-#define ICMP_GET_SIZE(call) \
-	({ \
-		size_t size = (size_t) IPC_GET_ARG1(call); \
-		size; \
-	})
+#define ICMP_GET_SIZE(call)  ((size_t) IPC_GET_ARG1(call))
 
-/** Returns the timeout message parameter.
+/** Return the timeout message parameter.
  *
- * @param[in] call	The message call structure.
+ * @param[in] call Message call structure.
+ *
  */
-#define ICMP_GET_TIMEOUT(call) \
-	({ \
-		suseconds_t timeout = (suseconds_t) IPC_GET_ARG2(call); \
-		timeout; \
-	})
+#define ICMP_GET_TIMEOUT(call)  ((suseconds_t) IPC_GET_ARG2(call))
 
-/** Returns the time to live message parameter.
+/** Return the time to live message parameter.
  *
- * @param[in] call	The message call structure.
+ * @param[in] call Message call structure.
+ *
  */
-#define ICMP_GET_TTL(call) \
-	({ \
-		ip_ttl_t ttl = (ip_ttl_t) IPC_GET_ARG3(call); \
-		ttl; \
-	})
+#define ICMP_GET_TTL(call)  ((ip_ttl_t) IPC_GET_ARG3(call))
 
-/** Returns the type of service message parameter.
+/** Return the type of service message parameter.
  *
- * @param[in] call	The message call structure.
+ * @param[in] call Message call structure.
+ *
  */
-#define ICMP_GET_TOS(call) \
-	({ \
-		ip_tos_t tos = (ip_tos_t) IPC_GET_ARG4(call); \
-		tos; \
-	})
+#define ICMP_GET_TOS(call)  ((ip_tos_t) IPC_GET_ARG4(call))
 
-/** Returns the dont fragment message parameter.
+/** Return the dont fragment message parameter.
  *
- * @param[in] call	The message call structure.
+ * @param[in] call Message call structure.
  */
-#define ICMP_GET_DONT_FRAGMENT(call) \
-	({ \
-		int dont_fragment = (int) IPC_GET_ARG5(call); \
-		dont_fragment; \
-	})
+#define ICMP_GET_DONT_FRAGMENT(call)  ((int) IPC_GET_ARG5(call))
 
 /*@}*/
Index: uspace/lib/c/include/ipc/il.h
===================================================================
--- uspace/lib/c/include/ipc/il.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/c/include/ipc/il.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -75,12 +75,16 @@
 
 /** Return the protocol number message parameter.
- * @param[in] call The message call structure.
+ *
+ * @param[in] call Message call structure.
+ *
  */
-#define IL_GET_PROTO(call)	(int) IPC_GET_ARG1(*call)
+#define IL_GET_PROTO(call)  ((int) IPC_GET_ARG1(call))
 
 /** Return the registering service message parameter.
- * @param[in] call The message call structure.
+ *
+ * @param[in] call Message call structure.
+ *
  */
-#define IL_GET_SERVICE(call)	(services_t) IPC_GET_ARG2(*call)
+#define IL_GET_SERVICE(call)  ((services_t) IPC_GET_ARG2(call))
 
 /*@}*/
Index: uspace/lib/c/include/ipc/ip.h
===================================================================
--- uspace/lib/c/include/ipc/ip.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/c/include/ipc/ip.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -51,12 +51,15 @@
 	 */
 	NET_IP_ADD_ROUTE = NET_IP_FIRST,
+	
 	/** Gets the actual route information.
 	 * @see ip_get_route()
 	 */
 	NET_IP_GET_ROUTE,
+	
 	/** Processes the received error notification.
 	 * @see ip_received_error_msg()
 	 */
 	NET_IP_RECEIVED_ERROR,
+	
 	/** Sets the default gateway.
 	 * @see ip_set_default_gateway()
@@ -68,51 +71,53 @@
 /*@{*/
 
-/** Returns the address message parameter.
- * @param[in] call The message call structure.
+/** Return the address message parameter.
+ *
+ * @param[in] call Message call structure.
+ *
  */
 #define IP_GET_ADDRESS(call) \
 	({ \
 		in_addr_t addr; \
-		addr.s_addr = IPC_GET_ARG3(*call); \
+		addr.s_addr = IPC_GET_ARG3(call); \
 		addr; \
 	})
 
-/** Returns the gateway message parameter.
- * @param[in] call The message call structure.
+/** Return the gateway message parameter.
+ *
+ * @param[in] call Message call structure.
+ *
  */
 #define IP_GET_GATEWAY(call) \
 	({ \
 		in_addr_t addr; \
-		addr.s_addr = IPC_GET_ARG2(*call); \
+		addr.s_addr = IPC_GET_ARG2(call); \
 		addr; \
 	})
 
-/** Sets the header length in the message answer.
- * @param[out] answer The message answer structure.
+/** Set the header length in the message answer.
+ *
+ * @param[out] answer Message answer structure.
+ *
  */
-#define IP_SET_HEADERLEN(answer, value) \
-	do { \
-		sysarg_t argument = (sysarg_t) (value); \
-		IPC_SET_ARG2(*answer, argument); \
-	} while (0)
+#define IP_SET_HEADERLEN(answer, value)  IPC_SET_ARG2(answer, (sysarg_t) (value))
 
-/** Returns the network mask message parameter.
- * @param[in] call The message call structure.
+/** Return the network mask message parameter.
+ *
+ * @param[in] call Message call structure.
+ *
  */
 #define IP_GET_NETMASK(call) \
 	({ \
 		in_addr_t addr; \
-		addr.s_addr = IPC_GET_ARG4(*call); \
+		addr.s_addr = IPC_GET_ARG4(call); \
 		addr; \
 	})
 
-/** Returns the protocol message parameter.
- * @param[in] call The message call structure.
+/** Return the protocol message parameter.
+ *
+ * @param[in] call Message call structure.
+ *
  */
-#define IP_GET_PROTOCOL(call) \
-	({ \
-		ip_protocol_t protocol = (ip_protocol_t) IPC_GET_ARG1(*call); \
-		protocol; \
-	})
+#define IP_GET_PROTOCOL(call)  ((ip_protocol_t) IPC_GET_ARG1(call))
 
 /*@}*/
Index: uspace/lib/c/include/ipc/irc.h
===================================================================
--- uspace/lib/c/include/ipc/irc.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
+++ uspace/lib/c/include/ipc/irc.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2009 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.
+ */
+
+/** @addtogroup libcipc
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_IRC_H_
+#define LIBC_IRC_H_
+
+#include <ipc/ipc.h>
+
+typedef enum {
+	IRC_ENABLE_INTERRUPT = IPC_FIRST_USER_METHOD,
+	IRC_CLEAR_INTERRUPT
+} irc_request_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/include/ipc/net.h
===================================================================
--- uspace/lib/c/include/ipc/net.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/c/include/ipc/net.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -44,8 +44,10 @@
 #include <net/packet.h>
 
-/** Returns a value indicating whether the value is in the interval.
- * @param[in] item	The value to be checked.
- * @param[in] first_inclusive The first value in the interval inclusive.
- * @param[in] last_exclusive The first value after the interval.
+/** Return a value indicating whether the value is in the interval.
+ *
+ * @param[in] item            Value to be checked.
+ * @param[in] first_inclusive First value in the interval inclusive.
+ * @param[in] last_exclusive  First value after the interval.
+ *
  */
 #define IS_IN_INTERVAL(item, first_inclusive, last_exclusive) \
@@ -55,42 +57,17 @@
 /*@{*/
 
-/** The number of ARP messages. */
-#define NET_ARP_COUNT		5
-
-/** The number of Ethernet messages. */
-#define NET_ETH_COUNT		0
-
-/** The number of ICMP messages. */
-#define NET_ICMP_COUNT		6
-
-/** The number of inter-network messages. */
-#define NET_IL_COUNT		6
-
-/** The number of IP messages. */
-#define NET_IP_COUNT		4
-
-/** The number of general networking messages. */
-#define NET_NET_COUNT		3
-
-/** The number of network interface driver messages. */
-#define NET_NETIF_COUNT		6
-
-/** The number of network interface layer messages. */
-#define NET_NIL_COUNT		7
-
-/** The number of packet management system messages. */
-#define NET_PACKET_COUNT	5
-
-/** The number of socket messages. */
-#define NET_SOCKET_COUNT	14
-
-/** The number of TCP messages. */
-#define NET_TCP_COUNT		0
-
-/** The number of transport layer messages. */
-#define NET_TL_COUNT		1
-
-/** The number of UDP messages. */
-#define NET_UDP_COUNT		0
+#define NET_ARP_COUNT     5   /**< Number of ARP messages. */
+#define NET_ETH_COUNT     0   /**< Number of Ethernet messages. */
+#define NET_ICMP_COUNT    6   /**< Number of ICMP messages. */
+#define NET_IL_COUNT      6   /**< Number of inter-network messages. */
+#define NET_IP_COUNT      4   /**< Number of IP messages. */
+#define NET_NET_COUNT     3   /**< Number of general networking messages. */
+#define NET_NETIF_COUNT   6   /**< Number of network interface driver messages. */
+#define NET_NIL_COUNT     7   /**< Number of network interface layer messages. */
+#define NET_PACKET_COUNT  5   /**< Number of packet management system messages. */
+#define NET_SOCKET_COUNT  14  /**< Number of socket messages. */
+#define NET_TCP_COUNT     0   /**< Number of TCP messages. */
+#define NET_TL_COUNT      1   /**< Number of transport layer messages. */
+#define NET_UDP_COUNT     0   /**< Number of UDP messages. */
 
 /*@}*/
@@ -100,173 +77,195 @@
 /*@{*/
 
-/** The first networking message. */
-#define NET_FIRST		2000
-
-/** The first network interface layer message. */
-#define NET_NETIF_FIRST		NET_FIRST
-
-/** The last network interface layer message. */
-#define NET_NETIF_LAST		(NET_NETIF_FIRST + NET_NETIF_COUNT)
-
-/** The first general networking message. */
-#define NET_NET_FIRST		(NET_NETIF_LAST + 0)
-
-/** The last general networking message. */
-#define NET_NET_LAST		(NET_NET_FIRST + NET_NET_COUNT)
-
-/** The first network interface layer message. */
-#define NET_NIL_FIRST		(NET_NET_LAST + 0)
-
-/** The last network interface layer message. */
-#define NET_NIL_LAST		(NET_NIL_FIRST + NET_NIL_COUNT)
-
-/** The first Ethernet message. */
-#define NET_ETH_FIRST		(NET_NIL_LAST + 0)
-
-/** The last Ethernet message. */
-#define NET_ETH_LAST		(NET_ETH_FIRST + NET_ETH_COUNT)
-
-/** The first inter-network message. */
-#define NET_IL_FIRST		(NET_ETH_LAST + 0)
-
-/** The last inter-network message. */
-#define NET_IL_LAST		(NET_IL_FIRST + NET_IL_COUNT)
-
-/** The first IP message. */
-#define NET_IP_FIRST		(NET_IL_LAST + 0)
-
-/** The last IP message. */
-#define NET_IP_LAST		(NET_IP_FIRST + NET_IP_COUNT)
-
-/** The first ARP message. */
-#define NET_ARP_FIRST		(NET_IP_LAST + 0)
-
-/** The last ARP message. */
-#define NET_ARP_LAST		(NET_ARP_FIRST + NET_ARP_COUNT)
-
-/** The first ICMP message. */
-#define NET_ICMP_FIRST		(NET_ARP_LAST + 0)
-
-/** The last ICMP message. */
-#define NET_ICMP_LAST		(NET_ICMP_FIRST + NET_ICMP_COUNT)
-
-/** The first ICMP message. */
-#define NET_TL_FIRST		(NET_ICMP_LAST + 0)
-
-/** The last ICMP message. */
-#define NET_TL_LAST		(NET_TL_FIRST + NET_TL_COUNT)
-
-/** The first UDP message. */
-#define NET_UDP_FIRST		(NET_TL_LAST + 0)
-
-/** The last UDP message. */
-#define NET_UDP_LAST		(NET_UDP_FIRST + NET_UDP_COUNT)
-
-/** The first TCP message. */
-#define NET_TCP_FIRST		(NET_UDP_LAST + 0)
-
-/** The last TCP message. */
-#define NET_TCP_LAST		(NET_TCP_FIRST + NET_TCP_COUNT)
-
-/** The first socket message. */
-#define NET_SOCKET_FIRST	(NET_TCP_LAST + 0)
-
-/** The last socket message. */
-#define NET_SOCKET_LAST		(NET_SOCKET_FIRST + NET_SOCKET_COUNT)
-
-/** The first packet management system message. */
-#define NET_PACKET_FIRST	(NET_SOCKET_LAST + 0)
-
-/** The last packet management system message. */
-#define NET_PACKET_LAST		(NET_PACKET_FIRST + NET_PACKET_COUNT)
-
-/** The last networking message. */
-#define NET_LAST		NET_PACKET_LAST
-
-/** The number of networking messages. */
-#define NET_COUNT		(NET_LAST - NET_FIRST)
-
-/** Returns a value indicating whether the IPC call is a generic networking
- * message.
- * @param[in] call The IPC call to be checked.
+
+/** First networking message. */
+#define NET_FIRST  2000
+
+/** First network interface layer message. */
+#define NET_NETIF_FIRST  NET_FIRST
+
+/** Last network interface layer message. */
+#define NET_NETIF_LAST  (NET_NETIF_FIRST + NET_NETIF_COUNT)
+
+/** First general networking message. */
+#define NET_NET_FIRST  (NET_NETIF_LAST + 0)
+
+/** Last general networking message. */
+#define NET_NET_LAST  (NET_NET_FIRST + NET_NET_COUNT)
+
+/** First network interface layer message. */
+#define NET_NIL_FIRST  (NET_NET_LAST + 0)
+
+/** Last network interface layer message. */
+#define NET_NIL_LAST  (NET_NIL_FIRST + NET_NIL_COUNT)
+
+/** First Ethernet message. */
+#define NET_ETH_FIRST  (NET_NIL_LAST + 0)
+
+/** Last Ethernet message. */
+#define NET_ETH_LAST  (NET_ETH_FIRST + NET_ETH_COUNT)
+
+/** First inter-network message. */
+#define NET_IL_FIRST  (NET_ETH_LAST + 0)
+
+/** Last inter-network message. */
+#define NET_IL_LAST  (NET_IL_FIRST + NET_IL_COUNT)
+
+/** First IP message. */
+#define NET_IP_FIRST  (NET_IL_LAST + 0)
+
+/** Last IP message. */
+#define NET_IP_LAST  (NET_IP_FIRST + NET_IP_COUNT)
+
+/** First ARP message. */
+#define NET_ARP_FIRST  (NET_IP_LAST + 0)
+
+/** Last ARP message. */
+#define NET_ARP_LAST  (NET_ARP_FIRST + NET_ARP_COUNT)
+
+/** First ICMP message. */
+#define NET_ICMP_FIRST  (NET_ARP_LAST + 0)
+
+/** Last ICMP message. */
+#define NET_ICMP_LAST  (NET_ICMP_FIRST + NET_ICMP_COUNT)
+
+/** First ICMP message. */
+#define NET_TL_FIRST  (NET_ICMP_LAST + 0)
+
+/** Last ICMP message. */
+#define NET_TL_LAST  (NET_TL_FIRST + NET_TL_COUNT)
+
+/** First UDP message. */
+#define NET_UDP_FIRST  (NET_TL_LAST + 0)
+
+/** Last UDP message. */
+#define NET_UDP_LAST  (NET_UDP_FIRST + NET_UDP_COUNT)
+
+/** First TCP message. */
+#define NET_TCP_FIRST  (NET_UDP_LAST + 0)
+
+/** Last TCP message. */
+#define NET_TCP_LAST  (NET_TCP_FIRST + NET_TCP_COUNT)
+
+/** First socket message. */
+#define NET_SOCKET_FIRST  (NET_TCP_LAST + 0)
+
+/** Last socket message. */
+#define NET_SOCKET_LAST  (NET_SOCKET_FIRST + NET_SOCKET_COUNT)
+
+/** First packet management system message. */
+#define NET_PACKET_FIRST  (NET_SOCKET_LAST + 0)
+
+/** Last packet management system message. */
+#define NET_PACKET_LAST  (NET_PACKET_FIRST + NET_PACKET_COUNT)
+
+/** Last networking message. */
+#define NET_LAST  NET_PACKET_LAST
+
+/** Number of networking messages. */
+#define NET_COUNT  (NET_LAST - NET_FIRST)
+
+/** Check if the IPC call is a generic networking message.
+ *
+ * @param[in] call IPC call to be checked.
+ *
  */
 #define IS_NET_MESSAGE(call) \
-	IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_FIRST, NET_LAST)
-
-/** Returns a value indicating whether the IPC call is an ARP message.
- * @param[in] call The IPC call to be checked.
+	IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_FIRST, NET_LAST)
+
+/** Check if the IPC call is an ARP message.
+ *
+ * @param[in] call IPC call to be checked.
+ *
  */
 #define IS_NET_ARP_MESSAGE(call) \
-	IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_ARP_FIRST, NET_ARP_LAST)
-
-/** Returns a value indicating whether the IPC call is an Ethernet message.
- * @param[in] call The IPC call to be checked.
+	IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_ARP_FIRST, NET_ARP_LAST)
+
+/** Check if the IPC call is an Ethernet message.
+ *
+ * @param[in] call IPC call to be checked.
+ *
  */
 #define IS_NET_ETH_MESSAGE(call) \
-	IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_ETH_FIRST, NET_ETH_LAST)
-
-/** Returns a value indicating whether the IPC call is an ICMP message.
- * @param[in] call The IPC call to be checked.
+	IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_ETH_FIRST, NET_ETH_LAST)
+
+/** Check if the IPC call is an ICMP message.
+ *
+ * @param[in] call IPC call to be checked.
+ *
  */
 #define IS_NET_ICMP_MESSAGE(call) \
-	IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_ICMP_FIRST, NET_ICMP_LAST)
-
-/** Returns a value indicating whether the IPC call is an inter-network layer
- * message.
- * @param[in] call The IPC call to be checked.
+	IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_ICMP_FIRST, NET_ICMP_LAST)
+
+/** Check if the IPC call is an inter-network layer message.
+ *
+ * @param[in] call IPC call to be checked.
+ *
  */
 #define IS_NET_IL_MESSAGE(call) \
-	IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_IL_FIRST, NET_IL_LAST)
-
-/** Returns a value indicating whether the IPC call is an IP message.
- * @param[in] call The IPC call to be checked.
+	IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_IL_FIRST, NET_IL_LAST)
+
+/** Check if the IPC call is an IP message.
+ *
+ * @param[in] call IPC call to be checked.
+ *
  */
 #define IS_NET_IP_MESSAGE(call) \
-	IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_IP_FIRST, NET_IP_LAST)
-
-/** Returns a value indicating whether the IPC call is a generic networking
- * message.
- * @param[in] call The IPC call to be checked.
+	IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_IP_FIRST, NET_IP_LAST)
+
+/** Check if the IPC call is a generic networking message.
+ *
+ * @param[in] call IPC call to be checked.
+ *
  */
 #define IS_NET_NET_MESSAGE(call) \
-	IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_NET_FIRST, NET_NET_LAST)
-
-/** Returns a value indicating whether the IPC call is a network interface layer
- * message.
- * @param[in] call The IPC call to be checked.
+	IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_NET_FIRST, NET_NET_LAST)
+
+/** Check if the IPC call is a network interface layer message.
+ *
+ * @param[in] call IPC call to be checked.
+ *
  */
 #define IS_NET_NIL_MESSAGE(call) \
-	IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_NIL_FIRST, NET_NIL_LAST)
-
-/** Returns a value indicating whether the IPC call is a packet manaagement
- * system message.
- * @param[in] call The IPC call to be checked.
+	IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_NIL_FIRST, NET_NIL_LAST)
+
+/** Check if the IPC call is a packet manaagement system message.
+ *
+ * @param[in] call IPC call to be checked.
+ *
  */
 #define IS_NET_PACKET_MESSAGE(call) \
-	IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_PACKET_FIRST, NET_PACKET_LAST)
-
-/** Returns a value indicating whether the IPC call is a socket message.
- * @param[in] call The IPC call to be checked.
+	IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_PACKET_FIRST, NET_PACKET_LAST)
+
+/** Check if the IPC call is a socket message.
+ *
+ * @param[in] call IPC call to be checked.
+ *
  */
 #define IS_NET_SOCKET_MESSAGE(call) \
-	IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_SOCKET_FIRST, NET_SOCKET_LAST)
-
-/** Returns a value indicating whether the IPC call is a TCP message.
- * @param[in] call The IPC call to be checked.
+	IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_SOCKET_FIRST, NET_SOCKET_LAST)
+
+/** Check if the IPC call is a TCP message.
+ *
+ * @param[in] call IPC call to be checked.
+ *
  */
 #define IS_NET_TCP_MESSAGE(call) \
-	IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_TCP_FIRST, NET_TCP_LAST)
-
-/** Returns a value indicating whether the IPC call is a transport layer message.
- * @param[in] call The IPC call to be checked.
+	IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_TCP_FIRST, NET_TCP_LAST)
+
+/** Check if the IPC call is a transport layer message.
+ *
+ * @param[in] call IPC call to be checked.
+ *
  */
 #define IS_NET_TL_MESSAGE(call) \
-	IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_TL_FIRST, NET_TL_LAST)
-
-/** Returns a value indicating whether the IPC call is a UDP message.
- * @param[in] call The IPC call to be checked.
+	IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_TL_FIRST, NET_TL_LAST)
+
+/** Check if the IPC call is a UDP message.
+ *
+ * @param[in] call IPC call to be checked.
+ *
  */
 #define IS_NET_UDP_MESSAGE(call) \
-	IS_IN_INTERVAL(IPC_GET_IMETHOD(*call), NET_UDP_FIRST, NET_UDP_LAST)
+	IS_IN_INTERVAL(IPC_GET_IMETHOD(call), NET_UDP_FIRST, NET_UDP_LAST)
 
 /*@}*/
@@ -275,138 +274,113 @@
 /*@{*/
 
-/** Returns the device identifier message argument.
- * @param[in] call The message call structure.
- */
-#define IPC_GET_DEVICE(call) \
-	({ \
-		device_id_t device_id = (device_id_t) IPC_GET_ARG1(*call); \
-		device_id; \
-	})
-
-/** Returns the packet identifier message argument.
- * @param[in] call The message call structure.
- */
-#define IPC_GET_PACKET(call) \
-	({ \
-		packet_id_t packet_id = (packet_id_t) IPC_GET_ARG2(*call); \
-		packet_id; \
-	})
-
-/** Returns the count message argument.
- * @param[in] call The message call structure.
- */
-#define IPC_GET_COUNT(call) \
-	({ \
-		size_t size = (size_t) IPC_GET_ARG2(*call); \
-		size; \
-	})
-
-/** Returns the device state message argument.
- * @param[in] call The message call structure.
- */
-#define IPC_GET_STATE(call) \
-	({ \
-		device_state_t state = (device_state_t) IPC_GET_ARG2(*call); \
-		state; \
-	})
-
-/** Returns the maximum transmission unit message argument.
- * @param[in] call The message call structure.
- */
-#define IPC_GET_MTU(call) \
-	({ \
-		size_t size = (size_t) IPC_GET_ARG2(*call); \
-		size; \
-	})
-
-/** Returns the device driver service message argument.
- * @param[in] call The message call structure.
- */
-#define IPC_GET_SERVICE(call) \
-	({ \
-		services_t service = (services_t) IPC_GET_ARG3(*call); \
-		service; \
-	})
-
-/** Returns the target service message argument.
- * @param[in] call The message call structure.
- */
-#define IPC_GET_TARGET(call) \
-	({ \
-		services_t service = (services_t) IPC_GET_ARG3(*call); \
-		service; \
-	})
-
-/** Returns the sender service message argument.
- * @param[in] call The message call structure.
- */
-#define IPC_GET_SENDER(call) \
-	({ \
-		services_t service = (services_t) IPC_GET_ARG3(*call); \
-		service; \
-	})
-
-/** Returns the error service message argument.
- * @param[in] call The message call structure.
- */
-#define IPC_GET_ERROR(call) \
-	({ \
-		services_t service = (services_t) IPC_GET_ARG4(*call); \
-		service; \
-	})
-
-/** Returns the phone message argument.
- * @param[in] call The message call structure.
- */
-#define IPC_GET_PHONE(call) \
-	({ \
-		int phone = (int) IPC_GET_ARG5(*call); \
-		phone; \
-	})
-
-/** Sets the device identifier in the message answer.
- * @param[out] answer The message answer structure.
- */
-#define IPC_SET_DEVICE(answer, value) \
-	do { \
-		sysarg_t argument = (sysarg_t) (value); \
-		IPC_SET_ARG1(*answer, argument); \
-	} while (0)
-
-/** Sets the minimum address length in the message answer.
- * @param[out] answer The message answer structure.
- */
-#define IPC_SET_ADDR(answer, value) \
-	do { \
-		sysarg_t argument = (sysarg_t) (value); \
-		IPC_SET_ARG1(*answer, argument); \
-	} while (0)
-
-/** Sets the minimum prefix size in the message answer.
- * @param[out] answer The message answer structure.
- */
-#define IPC_SET_PREFIX(answer, value) \
-	do { \
-		sysarg_t argument = (sysarg_t) (value); \
-		IPC_SET_ARG2(*answer, argument); \
-	} while (0)
-
-/** Sets the maximum content size in the message answer.
- * @param[out] answer The message answer structure.
- */
-#define IPC_SET_CONTENT(answer, value) \
-	do { \
-		sysarg_t argument = (sysarg_t) (value); \
-		IPC_SET_ARG3(*answer, argument); \
-	} while (0)
-
-/** Sets the minimum suffix size in the message answer.
- * @param[out] answer The message answer structure.
- */
-#define IPC_SET_SUFFIX(answer, value) \
-	do { \
-		sysarg_t argument = (sysarg_t) (value); \
-		IPC_SET_ARG4(*answer, argument); \
-	} while (0)
+/** Return the device identifier message argument.
+ *
+ * @param[in] call Message call structure.
+ *
+ */
+#define IPC_GET_DEVICE(call)  ((device_id_t) IPC_GET_ARG1(call))
+
+/** Return the packet identifier message argument.
+ *
+ * @param[in] call Message call structure.
+ *
+ */
+#define IPC_GET_PACKET(call)  ((packet_id_t) IPC_GET_ARG2(call))
+
+/** Return the count message argument.
+ *
+ * @param[in] call Message call structure.
+ *
+ */
+#define IPC_GET_COUNT(call)  ((size_t) IPC_GET_ARG2(call))
+
+/** Return the device state message argument.
+ *
+ * @param[in] call Message call structure.
+ *
+ */
+#define IPC_GET_STATE(call)  ((device_state_t) IPC_GET_ARG2(call))
+
+/** Return the maximum transmission unit message argument.
+ *
+ * @param[in] call Message call structure.
+ *
+ */
+#define IPC_GET_MTU(call)  ((size_t) IPC_GET_ARG2(call))
+
+/** Return the device driver service message argument.
+ *
+ * @param[in] call Message call structure.
+ *
+ */
+#define IPC_GET_SERVICE(call)  ((services_t) IPC_GET_ARG3(call))
+
+/** Return the target service message argument.
+ *
+ * @param[in] call Message call structure.
+ *
+ */
+#define IPC_GET_TARGET(call)  ((services_t) IPC_GET_ARG3(call))
+
+/** Return the sender service message argument.
+ *
+ * @param[in] call Message call structure.
+ *
+ */
+#define IPC_GET_SENDER(call)  ((services_t) IPC_GET_ARG3(call))
+
+/** Return the error service message argument.
+ &
+ * @param[in] call Message call structure.
+ *
+ */
+#define IPC_GET_ERROR(call)  ((services_t) IPC_GET_ARG4(call))
+
+/** Return the phone message argument.
+ *
+ * @param[in] call Message call structure.
+ *
+ */
+#define IPC_GET_PHONE(call)  ((int) IPC_GET_ARG5(call))
+
+/** Set the device identifier in the message answer.
+ *
+ * @param[out] answer Message answer structure.
+ * @param[in]  value  Value to set.
+ *
+ */
+#define IPC_SET_DEVICE(answer, value)  IPC_SET_ARG1(answer, (sysarg_t) (value))
+
+/** Set the minimum address length in the message answer.
+ *
+ * @param[out] answer Message answer structure.
+ * @param[in]  value  Value to set.
+ *
+ */
+#define IPC_SET_ADDR(answer, value)  IPC_SET_ARG1(answer, (sysarg_t) (value))
+
+/** Set the minimum prefix size in the message answer.
+ *
+ * @param[out] answer Message answer structure.
+ * @param[in]  value  Value to set.
+ *
+ */
+#define IPC_SET_PREFIX(answer, value)  IPC_SET_ARG2(answer, (sysarg_t) (value))
+
+/** Set the maximum content size in the message answer.
+ *
+ * @param[out] answer Message answer structure.
+ * @param[in]  value  Value to set.
+ *
+ */
+#define IPC_SET_CONTENT(answer, value)  IPC_SET_ARG3(answer, (sysarg_t) (value))
+
+/** Set the minimum suffix size in the message answer.
+ *
+ * @param[out] answer Message answer structure.
+ * @param[in]  value  Value to set.
+ *
+ */
+#define IPC_SET_SUFFIX(answer, value)  IPC_SET_ARG4(answer, (sysarg_t) (value))
 
 /*@}*/
Index: uspace/lib/c/include/ipc/netif.h
===================================================================
--- uspace/lib/c/include/ipc/netif.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/c/include/ipc/netif.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -47,20 +47,25 @@
 	 */
 	NET_NETIF_PROBE = NET_NETIF_FIRST,
+	
 	/** Send packet message.
 	 * @see netif_send_msg()
 	 */
 	NET_NETIF_SEND,
+	
 	/** Start device message.
 	 * @see netif_start_req()
 	 */
 	NET_NETIF_START,
+	
 	/** Get device usage statistics message.
 	 * @see netif_stats_req()
 	 */
 	NET_NETIF_STATS,
+	
 	/** Stop device message.
 	 * @see netif_stop_req()
 	 */
 	NET_NETIF_STOP,
+	
 	/** Get device address message.
 	 * @see netif_get_addr_req()
@@ -73,20 +78,16 @@
 
 /** Return the interrupt number message parameter.
- * @param[in] call The message call structure.
+ *
+ * @param[in] call Mmessage call structure.
+ *
  */
-#define NETIF_GET_IRQ(call) \
-	({ \
-		int irq = (int) IPC_GET_ARG2(*call); \
-		irq; \
-	})
+#define NETIF_GET_IRQ(call) ((int) IPC_GET_ARG2(call))
 
 /** Return the input/output address message parameter.
- * @param[in] call The message call structure.
+ *
+ * @param[in] call Message call structure.
+ *
  */
-#define NETIF_GET_IO(call) \
-	({ \
-		int io = (int) IPC_GET_ARG3(*call); \
-		io; \
-	})
+#define NETIF_GET_IO(call) ((void *) IPC_GET_ARG3(call))
 
 /*@}*/
Index: uspace/lib/c/include/ipc/nil.h
===================================================================
--- uspace/lib/c/include/ipc/nil.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/c/include/ipc/nil.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -77,9 +77,5 @@
 
 /** Return the protocol service message parameter. */
-#define NIL_GET_PROTO(call) \
-	({ \
-		services_t service = (services_t) IPC_GET_ARG2(*call); \
-		service; \
-	})
+#define NIL_GET_PROTO(call)  ((services_t) IPC_GET_ARG2(call))
 
 /*@}*/
Index: uspace/lib/c/include/ipc/packet.h
===================================================================
--- uspace/lib/c/include/ipc/packet.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/c/include/ipc/packet.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -70,21 +70,21 @@
 } packet_messages;
 
-/** Returns the protocol service message parameter. */
-#define ARP_GET_PROTO(call)	(services_t) IPC_GET_ARG2(*call)
+/** Return the protocol service message parameter. */
+#define ARP_GET_PROTO(call)  ((services_t) IPC_GET_ARG2(call))
 
-/** Returns the packet identifier message parameter. */
-#define IPC_GET_ID(call)	(packet_id_t) IPC_GET_ARG1(*call)
+/** Return the packet identifier message parameter. */
+#define IPC_GET_ID(call)  ((packet_id_t) IPC_GET_ARG1(call))
 
-/** Returns the maximal content length message parameter. */
-#define IPC_GET_CONTENT(call)	(size_t) IPC_GET_ARG1(*call)
+/** Return the maximal content length message parameter. */
+#define IPC_GET_CONTENT(call)  ((size_t) IPC_GET_ARG1(call))
 
-/** Returns the maximal address length message parameter. */
-#define IPC_GET_ADDR_LEN(call)	(size_t) IPC_GET_ARG2(*call)
+/** Return the maximal address length message parameter. */
+#define IPC_GET_ADDR_LEN(call)  ((size_t) IPC_GET_ARG2(call))
 
-/** Returns the maximal prefix length message parameter. */
-#define IPC_GET_PREFIX(call)	(size_t) IPC_GET_ARG3(*call)
+/** Return the maximal prefix length message parameter. */
+#define IPC_GET_PREFIX(call)  ((size_t) IPC_GET_ARG3(call))
 
-/** Returns the maximal suffix length message parameter. */
-#define IPC_GET_SUFFIX(call)	(size_t) IPC_GET_ARG4(*call)
+/** Return the maximal suffix length message parameter. */
+#define IPC_GET_SUFFIX(call)  ((size_t) IPC_GET_ARG4(call))
 
 #endif
Index: uspace/lib/c/include/ipc/services.h
===================================================================
--- uspace/lib/c/include/ipc/services.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/c/include/ipc/services.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -49,4 +49,6 @@
 	SERVICE_FHC,
 	SERVICE_OBIO,
+	SERVICE_APIC,
+	SERVICE_I8259,
 	SERVICE_CLIPBOARD,
 	SERVICE_NETWORKING,
Index: uspace/lib/c/include/mem.h
===================================================================
--- uspace/lib/c/include/mem.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/c/include/mem.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -44,5 +44,5 @@
 extern void *memmove(void *, const void *, size_t);
 
-extern int bcmp(const char *, const char *, size_t);
+extern int bcmp(const void *, const void *, size_t);
 
 #endif
Index: uspace/lib/c/include/net/in.h
===================================================================
--- uspace/lib/c/include/net/in.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/c/include/net/in.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -43,10 +43,10 @@
 
 /** INET string address maximum length. */
-#define INET_ADDRSTRLEN		(4 * 3 + 3 + 1)
+#define INET_ADDRSTRLEN  (4 * 3 + 3 + 1)
 
 /** Type definition of the INET address.
  * @see in_addr
  */
-typedef struct in_addr		in_addr_t;
+typedef struct in_addr in_addr_t;
 
 /** Type definition of the INET socket address.
Index: uspace/lib/c/include/net/modules.h
===================================================================
--- uspace/lib/c/include/net/modules.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/c/include/net/modules.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -51,10 +51,12 @@
 /** Connect to the needed module function type definition.
  *
- * @param[in] need	The needed module service.
- * @return		The phone of the needed service.
+ * @param[in] need The needed module service.
+ *
+ * @return The phone of the needed service.
+ *
  */
 typedef int connect_module_t(services_t need);
 
-extern void answer_call(ipc_callid_t, int, ipc_call_t *, int);
+extern void answer_call(ipc_callid_t, int, ipc_call_t *, size_t);
 extern int bind_service(services_t, sysarg_t, sysarg_t, sysarg_t,
     async_client_conn_t);
@@ -64,5 +66,5 @@
 extern int connect_to_service_timeout(services_t, suseconds_t);
 extern int data_reply(void *, size_t);
-extern void refresh_answer(ipc_call_t *, int *);
+extern void refresh_answer(ipc_call_t *, size_t *);
 
 #endif
Index: uspace/lib/c/include/stdlib.h
===================================================================
--- uspace/lib/c/include/stdlib.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/c/include/stdlib.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -46,4 +46,7 @@
 	} while (0)
 
+#define core() \
+	*((int *) 0) = 0xbadbad;
+
 #define exit(status)  _exit((status))
 
Index: uspace/lib/drv/Makefile
===================================================================
--- uspace/lib/drv/Makefile	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/drv/Makefile	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -35,8 +35,8 @@
 	generic/driver.c \
 	generic/dev_iface.c \
-	generic/remote_res.c \
+	generic/remote_char_dev.c \
+	generic/remote_hw_res.c \
 	generic/remote_usb.c \
-	generic/remote_usbhc.c \
-	generic/remote_char.c
+	generic/remote_usbhc.c
 
 include $(USPACE_PREFIX)/Makefile.common
Index: uspace/lib/drv/generic/dev_iface.c
===================================================================
--- uspace/lib/drv/generic/dev_iface.c	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/drv/generic/dev_iface.c	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -36,7 +36,9 @@
  */
 
+#include <assert.h>
+
 #include "dev_iface.h"
-#include "remote_res.h"
-#include "remote_char.h"
+#include "remote_hw_res.h"
+#include "remote_char_dev.h"
 #include "remote_usb.h"
 #include "remote_usbhc.h"
@@ -44,6 +46,6 @@
 static iface_dipatch_table_t remote_ifaces = {
 	.ifaces = {
-		&remote_res_iface,
-		&remote_char_iface,
+		&remote_hw_res_iface,
+		&remote_char_dev_iface,
 		&remote_usb_iface,
 		&remote_usbhc_iface
@@ -51,6 +53,6 @@
 };
 
-remote_iface_t* get_remote_iface(int idx)
-{	
+remote_iface_t *get_remote_iface(int idx)
+{
 	assert(is_valid_iface_idx(idx));
 	return remote_ifaces.ifaces[idx];
@@ -63,5 +65,11 @@
 		return NULL;
 	}
+
 	return rem_iface->methods[iface_method_idx];
+}
+
+bool is_valid_iface_idx(int idx)
+{
+	return (0 <= idx) && (idx < DEV_IFACE_MAX);
 }
 
Index: uspace/lib/drv/generic/driver.c
===================================================================
--- uspace/lib/drv/generic/driver.c	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/drv/generic/driver.c	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -52,17 +52,15 @@
 #include <ipc/driver.h>
 
+#include "dev_iface.h"
 #include "driver.h"
 
-/* driver structure */
-
+/** Driver structure */
 static driver_t *driver;
 
-/* devices */
-
+/** Devices */
 LIST_INITIALIZE(devices);
 FIBRIL_MUTEX_INITIALIZE(devices_mutex);
 
-/* interrupts */
-
+/** Interrupts */
 static interrupt_context_list_t interrupt_contexts;
 
@@ -85,7 +83,91 @@
 	
 	ctx = find_interrupt_context_by_id(&interrupt_contexts, id);
-	if (NULL != ctx && NULL != ctx->handler)
+	if (ctx != NULL && ctx->handler != NULL)
 		(*ctx->handler)(ctx->dev, iid, icall);
 }
+
+interrupt_context_t *create_interrupt_context(void)
+{
+	interrupt_context_t *ctx;
+	
+	ctx = (interrupt_context_t *) malloc(sizeof(interrupt_context_t));
+	if (ctx != NULL)
+		memset(ctx, 0, sizeof(interrupt_context_t));
+	
+	return ctx;
+}
+
+void delete_interrupt_context(interrupt_context_t *ctx)
+{
+	if (ctx != NULL)
+		free(ctx);
+}
+
+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);
+}
+
+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);
+}
+
+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);
+}
+
+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 (ctx->id == id) {
+			fibril_mutex_unlock(&list->mutex);
+			return ctx;
+		}
+		link = link->next;
+	}
+	
+	fibril_mutex_unlock(&list->mutex);
+	return NULL;
+}
+
+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 (ctx->irq == irq && ctx->dev == dev) {
+			fibril_mutex_unlock(&list->mutex);
+			return ctx;
+		}
+		link = link->next;
+	}
+	
+	fibril_mutex_unlock(&list->mutex);
+	return NULL;
+}
+
 
 int
@@ -101,9 +183,9 @@
 	add_interrupt_context(&interrupt_contexts, ctx);
 	
-	if (NULL == pseudocode)
+	if (pseudocode == NULL)
 		pseudocode = &default_pseudocode;
 	
 	int res = ipc_register_irq(irq, dev->handle, ctx->id, pseudocode);
-	if (0 != res) {
+	if (res != EOK) {
 		remove_interrupt_context(&interrupt_contexts, ctx);
 		delete_interrupt_context(ctx);
@@ -118,9 +200,10 @@
 	    dev, irq);
 	int res = ipc_unregister_irq(irq, dev->handle);
-
-	if (NULL != ctx) {
+	
+	if (ctx != NULL) {
 		remove_interrupt_context(&interrupt_contexts, ctx);
 		delete_interrupt_context(ctx);
 	}
+	
 	return res;
 }
@@ -140,5 +223,5 @@
 }
 
-static device_t * driver_get_device(link_t *devices, devman_handle_t handle)
+static device_t *driver_get_device(link_t *devices, devman_handle_t handle)
 {
 	device_t *dev = NULL;
@@ -146,7 +229,8 @@
 	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) {
+		if (dev->handle == handle) {
 			fibril_mutex_unlock(&devices_mutex);
 			return dev;
@@ -154,6 +238,7 @@
 		link = link->next;
 	}
+	
 	fibril_mutex_unlock(&devices_mutex);
-
+	
 	return NULL;
 }
@@ -162,9 +247,9 @@
 {
 	char *dev_name = NULL;
-	int res = EOK;
-	
-	devman_handle_t dev_handle =  IPC_GET_ARG1(*icall);
+	int res;
+	
+	devman_handle_t dev_handle = IPC_GET_ARG1(*icall);
     	devman_handle_t parent_dev_handle = IPC_GET_ARG2(*icall);
-    
+	
 	device_t *dev = create_device();
 	dev->handle = dev_handle;
@@ -177,5 +262,5 @@
 	
 	res = driver->driver_ops->add_device(dev);
-	if (0 == res) {
+	if (res == EOK) {
 		printf("%s: new device with handle=%" PRIun " was added.\n",
 		    driver->name, dev_handle);
@@ -194,10 +279,10 @@
 	/* 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_IMETHOD(call)) {
 		case IPC_M_PHONE_HUNGUP:
@@ -240,14 +325,14 @@
 	 * use the device.
 	 */
-
+	
 	int ret = EOK;
 	/* open the device */
-	if (NULL != dev->ops && NULL != dev->ops->open)
+	if (dev->ops != NULL && dev->ops->open != NULL)
 		ret = (*dev->ops->open)(dev);
 	
-	ipc_answer_0(iid, ret);	
-	if (EOK != ret)
+	ipc_answer_0(iid, ret);
+	if (ret != EOK)
 		return;
-
+	
 	while (1) {
 		ipc_callid_t callid;
@@ -258,11 +343,11 @@
 		
 		switch  (method) {
-		case IPC_M_PHONE_HUNGUP:		
+		case IPC_M_PHONE_HUNGUP:
 			/* close the device */
-			if (NULL != dev->ops && NULL != dev->ops->close)
+			if (dev->ops != NULL && dev->ops->close != NULL)
 				(*dev->ops->close)(dev);
 			ipc_answer_0(callid, EOK);
 			return;
-		default:		
+		default:
 			/* convert ipc interface id to interface index */
 			
@@ -272,5 +357,5 @@
 				remote_handler_t *default_handler =
 				    device_get_default_handler(dev);
-				if (NULL != default_handler) {
+				if (default_handler != NULL) {
 					(*default_handler)(dev, callid, &call);
 					break;
@@ -286,10 +371,10 @@
 				break;
 			}
-
+			
 			/* calling one of the device's interfaces */
 			
-			/* get the device interface structure */
-			void *iface = device_get_iface(dev, iface_idx);
-			if (NULL == iface) {
+			/* Get the interface ops structure. */
+			void *ops = device_get_ops(dev, iface_idx);
+			if (ops == NULL) {
 				printf("%s: driver_connection_gen error - ",
 				    driver->name);
@@ -299,17 +384,17 @@
 				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);
-
+			remote_iface_t *rem_iface = get_remote_iface(iface_idx);
+			assert(rem_iface != NULL);
+			
 			/* get the method of the remote interface */
 			sysarg_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) {
+			if (iface_method_ptr == NULL) {
 				// the interface has not such method
 				printf("%s: driver_connection_gen error - "
@@ -325,5 +410,5 @@
 			 * associated with the device by its driver.
 			 */
-			(*iface_method_ptr)(dev, iface, callid, &call);
+			(*iface_method_ptr)(dev, ops, callid, &call);
 			break;
 		}
@@ -348,16 +433,15 @@
 	switch ((sysarg_t) (IPC_GET_ARG1(*icall))) {
 	case DRIVER_DEVMAN:
-		/* handle PnP events from device manager */
+		/* Handle request from device manager */
 		driver_connection_devman(iid, icall);
 		break;
 	case DRIVER_DRIVER:
-		/* handle request from drivers of child devices */
+		/* Handle request from drivers of child devices */
 		driver_connection_driver(iid, icall);
 		break;
 	case DRIVER_CLIENT:
-		/* handle requests from client applications */
+		/* Handle request from client applications */
 		driver_connection_client(iid, icall);
 		break;
-
 	default:
 		/* No such interface */
@@ -366,8 +450,44 @@
 }
 
+/** Create new device structure.
+ *
+ * @return		The device structure.
+ */
+device_t *create_device(void)
+{
+	device_t *dev = malloc(sizeof(device_t));
+
+	if (dev != NULL) {
+		memset(dev, 0, sizeof(device_t));
+		init_match_ids(&dev->match_ids);
+	}
+
+	return dev;
+}
+
+/** Delete device structure.
+ *
+ * @param dev		The device structure.
+ */
+void delete_device(device_t *dev)
+{
+	clean_match_ids(&dev->match_ids);
+	if (dev->name != NULL)
+		free(dev->name);
+	free(dev);
+}
+
+void *device_get_ops(device_t *dev, dev_inferface_idx_t idx)
+{
+	assert(is_valid_iface_idx(idx));
+	if (dev->ops == NULL)
+		return NULL;
+	return dev->ops->interfaces[idx];
+}
+
 int child_device_register(device_t *child, device_t *parent)
 {
-	assert(NULL != child->name);
-
+	assert(child->name != NULL);
+	
 	int res;
 	
@@ -375,7 +495,9 @@
 	res = devman_child_device_register(child->name, &child->match_ids,
 	    parent->handle, &child->handle);
-	if (EOK == res)
+	if (res != EOK) {
+		remove_from_devices_list(child);
 		return res;
-	remove_from_devices_list(child);	
+	}
+	
 	return res;
 }
@@ -396,5 +518,5 @@
 	match_id_t *match_id = NULL;
 	int rc;
-
+	
 	child = create_device();
 	if (child == NULL) {
@@ -402,7 +524,7 @@
 		goto failure;
 	}
-
+	
 	child->name = child_name;
-
+	
 	match_id = create_match_id();
 	if (match_id == NULL) {
@@ -410,11 +532,11 @@
 		goto failure;
 	}
-
+	
 	match_id->id = child_match_id;
 	match_id->score = child_match_score;
 	add_match_id(&child->match_ids, match_id);
-
+	
 	rc = child_device_register(child, parent);
-	if (EOK != rc)
+	if (rc != EOK)
 		goto failure;
 
@@ -422,6 +544,7 @@
 		*child_handle = child->handle;
 	}
+
 	return EOK;
-
+	
 failure:
 	if (match_id != NULL) {
@@ -429,11 +552,24 @@
 		delete_match_id(match_id);
 	}
-
+	
 	if (child != NULL) {
 		child->name = NULL;
 		delete_device(child);
 	}
-
+	
 	return rc;
+}
+
+/** Get default handler for client requests */
+remote_handler_t *device_get_default_handler(device_t *dev)
+{
+	if (dev->ops == NULL)
+		return NULL;
+	return dev->ops->default_handler;
+}
+
+int add_device_to_class(device_t *dev, const char *class_name)
+{
+	return devman_add_device_to_class(dev->handle, class_name);
 }
 
@@ -445,5 +581,5 @@
 	 */
 	driver = drv;
-
+	
 	/* Initialize the list of interrupt contexts. */
 	init_interrupt_context_list(&interrupt_contexts);
@@ -457,7 +593,7 @@
 	 */
 	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 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ 	(revision )
@@ -1,162 +1,0 @@
-/*
- * 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 *, void *, ipc_callid_t, ipc_call_t *);
-static void remote_char_write(device_t *, void *, ipc_callid_t, ipc_call_t *);
-
-/** 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_char_dev.c
===================================================================
--- uspace/lib/drv/generic/remote_char_dev.c	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
+++ uspace/lib/drv/generic/remote_char_dev.c	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -0,0 +1,162 @@
+/*
+ * 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 "ops/char_dev.h"
+#include "driver.h"
+
+#define MAX_CHAR_RW_COUNT 256
+
+static void remote_char_read(device_t *, void *, ipc_callid_t, ipc_call_t *);
+static void remote_char_write(device_t *, void *, ipc_callid_t, ipc_call_t *);
+
+/** Remote character interface operations. */
+static remote_iface_func_ptr_t remote_char_dev_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_dev_iface = {
+	.method_count = sizeof(remote_char_dev_iface_ops) /
+	    sizeof(remote_iface_func_ptr_t),
+	.methods = remote_char_dev_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 ops		The local ops structure.
+ */
+static void
+remote_char_read(device_t *dev, void *ops, ipc_callid_t callid,
+    ipc_call_t *call)
+{
+	char_dev_ops_t *char_dev_ops = (char_dev_ops_t *) ops;
+	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_dev_ops->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_dev_ops->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 ops		The local ops structure.
+ */
+static void
+remote_char_write(device_t *dev, void *ops, ipc_callid_t callid,
+    ipc_call_t *call)
+{
+	char_dev_ops_t *char_dev_ops = (char_dev_ops_t *) ops;
+	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_dev_ops->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_dev_ops->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_hw_res.c
===================================================================
--- uspace/lib/drv/generic/remote_hw_res.c	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
+++ uspace/lib/drv/generic/remote_hw_res.c	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -0,0 +1,99 @@
+/*
+ * 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 "ops/hw_res.h"
+#include "driver.h"
+
+static void remote_hw_res_get_resource_list(device_t *, void *, ipc_callid_t,
+    ipc_call_t *);
+static void remote_hw_res_enable_interrupt(device_t *, void *, ipc_callid_t,
+    ipc_call_t *);
+
+static remote_iface_func_ptr_t remote_hw_res_iface_ops [] = {
+	&remote_hw_res_get_resource_list,
+	&remote_hw_res_enable_interrupt
+};
+
+remote_iface_t remote_hw_res_iface = {
+	.method_count = sizeof(remote_hw_res_iface_ops) /
+	    sizeof(remote_iface_func_ptr_t),
+	.methods = remote_hw_res_iface_ops
+};
+
+static void remote_hw_res_enable_interrupt(device_t *dev, void *ops,
+    ipc_callid_t callid, ipc_call_t *call)
+{
+	hw_res_ops_t *hw_res_ops = (hw_res_ops_t *) ops;
+	
+	if (hw_res_ops->enable_interrupt == NULL)
+		ipc_answer_0(callid, ENOTSUP);
+	else if (hw_res_ops->enable_interrupt(dev))
+		ipc_answer_0(callid, EOK);
+	else
+		ipc_answer_0(callid, EREFUSED);
+}
+
+static void remote_hw_res_get_resource_list(device_t *dev, void *ops,
+    ipc_callid_t callid, ipc_call_t *call)
+{
+	hw_res_ops_t *hw_res_ops = (hw_res_ops_t *) ops;
+
+	if (hw_res_ops->get_resource_list == NULL) {
+		ipc_answer_0(callid, ENOTSUP);
+		return;
+	}
+	
+	hw_resource_list_t *hw_resources = hw_res_ops->get_resource_list(dev);
+	if (hw_resources == NULL){
+		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/generic/remote_res.c
===================================================================
--- uspace/lib/drv/generic/remote_res.c	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ 	(revision )
@@ -1,98 +1,0 @@
-/*
- * 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 *, void *, ipc_callid_t,
-    ipc_call_t *);
-static void remote_res_enable_interrupt(device_t *, void *, ipc_callid_t,
-    ipc_call_t *);
-
-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 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ 	(revision )
@@ -1,49 +1,0 @@
-/*
- * 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 *, char *, size_t);
-	int (*write)(device_t *, char *, size_t);
-} char_iface_t;
-
-#endif
-
-/**
- * @}
- */
Index: uspace/lib/drv/include/dev_iface.h
===================================================================
--- uspace/lib/drv/include/dev_iface.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/drv/include/dev_iface.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -36,7 +36,35 @@
 #define LIBDRV_DEV_IFACE_H_
 
-#include "driver.h"
+#include <ipc/dev_iface.h>
 
-/* TODO declare device interface structures here */
+/*
+ * Device interface
+ */
+
+struct device;
+
+/*
+ * First two parameters: device and interface structure registered by the
+ * devices driver.
+ */
+typedef void remote_iface_func_t(struct device *, void *, ipc_callid_t,
+    ipc_call_t *);
+typedef remote_iface_func_t *remote_iface_func_ptr_t;
+typedef void remote_handler_t(struct device *, 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;
+
+extern remote_iface_t *get_remote_iface(int);
+extern remote_iface_func_ptr_t get_remote_method(remote_iface_t *, sysarg_t);
+
+
+extern bool is_valid_iface_idx(int);
 
 #endif
Index: uspace/lib/drv/include/driver.h
===================================================================
--- uspace/lib/drv/include/driver.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/drv/include/driver.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -41,6 +41,4 @@
 #include <ipc/devman.h>
 #include <ipc/dev_iface.h>
-#include <device/hw_res.h>
-#include <device/char.h>
 #include <assert.h>
 #include <ddi.h>
@@ -49,40 +47,14 @@
 #include <malloc.h>
 
+#include "dev_iface.h"
+
 struct device;
 typedef struct device device_t;
 
-/* device interface */
+/*
+ * Device class
+ */
 
-/*
- * 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);
-remote_iface_func_ptr_t get_remote_method(remote_iface_t *, sysarg_t);
-
-
-/* device class */
-
-/** Devices operations. */
+/** Devices operations */
 typedef struct device_ops {
 	/**
@@ -110,7 +82,9 @@
 
 
-/* device */
+/*
+ * Device
+ */
 
-/** The device. */
+/** Device structure */
 struct device {
 	/**
@@ -121,42 +95,40 @@
 	
 	/**
-	 * The phone to the parent device driver (if it is different from this
-	 * driver).
+	 * 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. */
+	/** Parent device if handled by this driver, NULL otherwise */
 	device_t *parent;
-	/** The device's name. */
+	/** Device name */
 	const char *name;
-	/** The list of device ids for device-to-driver matching. */
+	/** List of device ids for device-to-driver matching */
 	match_id_list_t match_ids;
-	/** The device driver's data associated with this device. */
+	/** Driver-specific data associated with this device */
 	void *driver_data;
-	/** The implementation of operations provided by this device. */
+	/** 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 in the list of devices handled by the driver */
 	link_t link;
 };
 
+/*
+ * Driver
+ */
 
-/* driver */
-
-/** Generic device driver operations. */
+/** Generic device driver operations */
 typedef struct driver_ops {
-	/** Callback method for passing a new device to the device driver.*/
+	/** Callback method for passing a new device to the device driver */
 	int (*add_device)(device_t *dev);
-	/* TODO add other generic driver operations */
+	/* TODO: add other generic driver operations */
 } driver_ops_t;
 
-/** The driver structure.*/
+/** Driver structure */
 typedef struct driver {
-	/** The name of the device driver. */
+	/** Name of the device driver */
 	const char *name;
-	/** Generic device driver operations. */
+	/** Generic device driver operations */
 	driver_ops_t *driver_ops;
 } driver_t;
@@ -168,40 +140,15 @@
  * @return		The device structure.
  */
-static inline device_t *create_device(void)
-{
-	device_t *dev = malloc(sizeof(device_t));
-	if (NULL != dev) {
-		memset(dev, 0, sizeof(device_t));
-		init_match_ids(&dev->match_ids);
-	}	
-	return dev;
-}
+extern device_t *create_device(void);
+extern void delete_device(device_t *);
+extern void *device_get_ops(device_t *, dev_inferface_idx_t);
 
-/** Delete device structure.
- *
- * @param dev		The device structure.
+extern int child_device_register(device_t *, device_t *);
+extern int child_device_register_wrapper(device_t *, const char *, const char *,
+    int, devman_handle_t *);
+
+/*
+ * Interrupts
  */
-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 *, device_t *);
-int child_device_register_wrapper(device_t *, const char *, const char *, int,
-    devman_handle_t *);
-
-
-/* interrupts */
 
 typedef void interrupt_handler_t(device_t *, ipc_callid_t, ipc_call_t *);
@@ -221,106 +168,22 @@
 } interrupt_context_list_t;
 
-static inline interrupt_context_t *create_interrupt_context(void)
-{
-	interrupt_context_t *ctx;
-	
-	ctx = (interrupt_context_t *) malloc(sizeof(interrupt_context_t));
-	if (NULL != ctx)
-		memset(ctx, 0, sizeof(interrupt_context_t));
-	
-	return ctx;
-}
+extern interrupt_context_t *create_interrupt_context(void);
+extern void delete_interrupt_context(interrupt_context_t *);
+extern void init_interrupt_context_list(interrupt_context_list_t *);
+extern void add_interrupt_context(interrupt_context_list_t *,
+    interrupt_context_t *);
+extern void remove_interrupt_context(interrupt_context_list_t *,
+    interrupt_context_t *);
+extern interrupt_context_t *find_interrupt_context_by_id(
+    interrupt_context_list_t *, int);
+extern interrupt_context_t *find_interrupt_context(
+    interrupt_context_list_t *, device_t *, int);
 
-static inline void delete_interrupt_context(interrupt_context_t *ctx)
-{
-	if (NULL != ctx)
-		free(ctx);
-}
+extern int register_interrupt_handler(device_t *, int, interrupt_handler_t *,
+    irq_code_t *);
+extern int unregister_interrupt_handler(device_t *, int);
 
-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 *, int, interrupt_handler_t *,
-    irq_code_t *);
-int unregister_interrupt_handler(device_t *, int);
-
-
-/* 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);
-}
+extern remote_handler_t *device_get_default_handler(device_t *);
+extern int add_device_to_class(device_t *, const char *);
 
 #endif
Index: uspace/lib/drv/include/ops/char_dev.h
===================================================================
--- uspace/lib/drv/include/ops/char_dev.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
+++ uspace/lib/drv/include/ops/char_dev.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -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_OPS_CHAR_DEV_H_
+#define LIBDRV_OPS_CHAR_DEV_H_
+
+#include "../driver.h"
+
+typedef struct {
+	int (*read)(device_t *, char *, size_t);
+	int (*write)(device_t *, char *, size_t);
+} char_dev_ops_t;
+
+#endif
+
+/**
+ * @}
+ */
Index: uspace/lib/drv/include/ops/hw_res.h
===================================================================
--- uspace/lib/drv/include/ops/hw_res.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
+++ uspace/lib/drv/include/ops/hw_res.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -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.
+ */
+
+/** @addtogroup libdrv
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBDRV_OPS_HW_RES_H_
+#define LIBDRV_OPS_HW_RES_H_
+
+#include <device/hw_res.h>
+#include <sys/types.h>
+
+#include "../driver.h"
+
+typedef struct {
+	 hw_resource_list_t *(*get_resource_list)(device_t *);
+	 bool (*enable_interrupt)(device_t *);
+} hw_res_ops_t;
+
+#endif
+
+/**
+ * @}
+ */
Index: uspace/lib/drv/include/remote_char.h
===================================================================
--- uspace/lib/drv/include/remote_char.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ 	(revision )
@@ -1,44 +1,0 @@
-/*
- * 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_char_dev.h
===================================================================
--- uspace/lib/drv/include/remote_char_dev.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
+++ uspace/lib/drv/include/remote_char_dev.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -0,0 +1,44 @@
+/*
+ * 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_DEV_H_
+#define LIBDRV_REMOTE_CHAR_DEV_H_
+
+extern remote_iface_t remote_char_dev_iface;
+
+#endif
+
+/**
+ * @}
+ */
Index: uspace/lib/drv/include/remote_hw_res.h
===================================================================
--- uspace/lib/drv/include/remote_hw_res.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
+++ uspace/lib/drv/include/remote_hw_res.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -0,0 +1,44 @@
+/*
+ * 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_HW_RES_H_
+#define LIBDRV_REMOTE_HW_RES_H_
+
+extern remote_iface_t remote_hw_res_iface;
+
+#endif
+
+/**
+ * @}
+ */
Index: uspace/lib/drv/include/remote_res.h
===================================================================
--- uspace/lib/drv/include/remote_res.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ 	(revision )
@@ -1,44 +1,0 @@
-/*
- * 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 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ 	(revision )
@@ -1,50 +1,0 @@
-/*
- * 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 *);
-	 bool (*enable_interrupt)(device_t *);
-} resource_iface_t;
-
-
-#endif
-
-/**
- * @}
- */
Index: uspace/lib/net/Makefile
===================================================================
--- uspace/lib/net/Makefile	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/net/Makefile	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -40,6 +40,6 @@
 	generic/protocol_map.c \
 	adt/module_map.c \
-	netif/netif_local.c \
 	netif/netif_remote.c \
+	netif/netif_skel.c \
 	nil/nil_remote.c \
 	il/il_interface.c \
Index: uspace/lib/net/adt/module_map.c
===================================================================
--- uspace/lib/net/adt/module_map.c	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/net/adt/module_map.c	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -63,6 +63,6 @@
  */
 int
-add_module(module_t **module, modules_t *modules, const char *name,
-    const char *filename, services_t service, task_id_t task_id,
+add_module(module_t **module, modules_t *modules, const uint8_t *name,
+    const uint8_t *filename, services_t service, task_id_t task_id,
     connect_module_t connect_module)
 {
@@ -104,5 +104,5 @@
  * @return		NULL if there is no such module.
  */
-module_t *get_running_module(modules_t *modules, char *name)
+module_t *get_running_module(modules_t *modules, uint8_t *name)
 {
 	module_t *module;
@@ -113,5 +113,5 @@
 
 	if (!module->task_id) {
-		module->task_id = spawn(module->filename);
+		module->task_id = net_spawn(module->filename);
 		if (!module->task_id)
 			return NULL;
@@ -123,16 +123,18 @@
 }
 
-/** Starts the given module.
+/** Start the given module.
  *
- * @param[in] fname	The module full or relative path filename.
- * @return		The new module task identifier on success.
- * @return		Zero if there is no such module.
+ * @param[in] fname The module full or relative path filename.
+ *
+ * @return The new module task identifier on success.
+ * @return Zero if there is no such module.
+ *
  */
-task_id_t spawn(const char *fname)
+task_id_t net_spawn(const uint8_t *fname)
 {
 	task_id_t id;
 	int rc;
 	
-	rc = task_spawnl(&id, fname, fname, NULL);
+	rc = task_spawnl(&id, (const char *) fname, (const char *) fname, NULL);
 	if (rc != EOK)
 		return 0;
Index: uspace/lib/net/generic/generic.c
===================================================================
--- uspace/lib/net/generic/generic.c	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/net/generic/generic.c	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -100,5 +100,5 @@
 int
 generic_get_addr_req(int phone, int message, device_id_t device_id,
-    measured_string_t **address, char ** data)
+    measured_string_t **address, uint8_t **data)
 {
 	aid_t message_id;
@@ -234,5 +234,5 @@
 generic_translate_req(int phone, int message, device_id_t device_id,
     services_t service, measured_string_t *configuration, size_t count,
-    measured_string_t **translation, char **data)
+    measured_string_t **translation, uint8_t **data)
 {
 	aid_t message_id;
Index: uspace/lib/net/generic/net_remote.c
===================================================================
--- uspace/lib/net/generic/net_remote.c	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/net/generic/net_remote.c	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -63,5 +63,5 @@
  * @see net_get_conf_req()
  */
-void net_free_settings(measured_string_t *settings, char *data)
+void net_free_settings(measured_string_t *settings, uint8_t *data)
 {
 	if (settings)
@@ -91,5 +91,5 @@
 int
 net_get_conf_req(int net_phone, measured_string_t **configuration,
-    size_t count, char **data)
+    size_t count, uint8_t **data)
 {
 	return generic_translate_req(net_phone, NET_NET_GET_DEVICE_CONF, 0, 0,
@@ -118,5 +118,5 @@
 int
 net_get_device_conf_req(int net_phone, device_id_t device_id,
-    measured_string_t **configuration, size_t count, char **data)
+    measured_string_t **configuration, size_t count, uint8_t **data)
 {
 	return generic_translate_req(net_phone, NET_NET_GET_DEVICE_CONF,
Index: uspace/lib/net/il/arp_remote.c
===================================================================
--- uspace/lib/net/il/arp_remote.c	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/net/il/arp_remote.c	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -165,5 +165,5 @@
 int
 arp_translate_req(int arp_phone, device_id_t device_id, services_t protocol,
-    measured_string_t *address, measured_string_t **translation, char **data)
+    measured_string_t *address, measured_string_t **translation, uint8_t **data)
 {
 	return generic_translate_req(arp_phone, NET_ARP_TRANSLATE, device_id,
Index: uspace/lib/net/il/ip_remote.c
===================================================================
--- uspace/lib/net/il/ip_remote.c	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/net/il/ip_remote.c	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -170,5 +170,5 @@
 		free(*header);
 	else
-		*device_id = IPC_GET_DEVICE(&answer);
+		*device_id = IPC_GET_DEVICE(answer);
 	
 	return (int) result;
Index: uspace/lib/net/include/adt/module_map.h
===================================================================
--- uspace/lib/net/include/adt/module_map.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/net/include/adt/module_map.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -65,15 +65,15 @@
 	int usage;
 	/** Module name. */
-	const char *name;
+	const uint8_t *name;
 	/** Module full path filename. */
-	const char *filename;
+	const uint8_t *filename;
 	/** Connecting function. */
 	connect_module_t *connect_module;
 };
 
-extern int add_module(module_t **, modules_t *, const char *, const char *,
-    services_t, task_id_t, connect_module_t *);
-extern module_t *get_running_module(modules_t *, char *);
-extern task_id_t spawn(const char *);
+extern int add_module(module_t **, modules_t *, const uint8_t *,
+    const uint8_t *, services_t, task_id_t, connect_module_t *);
+extern module_t *get_running_module(modules_t *, uint8_t *);
+extern task_id_t net_spawn(const uint8_t *);
 
 #endif
Index: uspace/lib/net/include/arp_interface.h
===================================================================
--- uspace/lib/net/include/arp_interface.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/net/include/arp_interface.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -50,5 +50,5 @@
     measured_string_t *);
 extern int arp_translate_req(int, device_id_t, services_t, measured_string_t *,
-    measured_string_t **, char **);
+    measured_string_t **, uint8_t **);
 extern int arp_clear_device_req(int, device_id_t);
 extern int arp_clear_address_req(int, device_id_t, services_t,
Index: uspace/lib/net/include/generic.h
===================================================================
--- uspace/lib/net/include/generic.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/net/include/generic.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -50,5 +50,5 @@
 extern int generic_device_req_remote(int, int, device_id_t, int, services_t);
 extern int generic_get_addr_req(int, int, device_id_t, measured_string_t **,
-    char **);
+    uint8_t **);
 extern int generic_packet_size_req_remote(int, int, device_id_t,
     packet_dimension_t *);
@@ -58,5 +58,5 @@
     services_t, services_t);
 extern int generic_translate_req(int, int, device_id_t, services_t,
-    measured_string_t *, size_t, measured_string_t **, char **);
+    measured_string_t *, size_t, measured_string_t **, uint8_t **);
 
 #endif
Index: uspace/lib/net/include/il_local.h
===================================================================
--- uspace/lib/net/include/il_local.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/net/include/il_local.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -49,5 +49,5 @@
  */
 extern int il_module_message_standalone(ipc_callid_t callid, ipc_call_t *call,
-    ipc_call_t *answer, int *answer_count);
+    ipc_call_t *answer, size_t *answer_count);
 
 /** Starts the Internet layer module.
Index: uspace/lib/net/include/net_interface.h
===================================================================
--- uspace/lib/net/include/net_interface.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/net/include/net_interface.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -45,7 +45,7 @@
 
 extern int net_get_device_conf_req(int, device_id_t, measured_string_t **,
-    size_t, char **);
-extern int net_get_conf_req(int, measured_string_t **, size_t, char **);
-extern void net_free_settings(measured_string_t *, char *);
+    size_t, uint8_t **);
+extern int net_get_conf_req(int, measured_string_t **, size_t, uint8_t **);
+extern void net_free_settings(measured_string_t *, uint8_t *);
 extern int net_connect_module(void);
 
Index: uspace/lib/net/include/netif_interface.h
===================================================================
--- uspace/lib/net/include/netif_interface.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ 	(revision )
@@ -1,52 +1,0 @@
-/*
- * Copyright (c) 2009 Lukas Mejdrech
- * 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 libnet
- * @{
- */
-
-#ifndef LIBNET_NETIF_INTERFACE_H_
-#define LIBNET_NETIF_INTERFACE_H_
-
-#include <netif_remote.h>
-#include <packet_client.h>
-
-#define netif_module_message    netif_module_message_standalone
-#define netif_module_start      netif_module_start_standalone
-#define netif_get_addr_req      netif_get_addr_req_remote
-#define netif_probe_req         netif_probe_req_remote
-#define netif_send_msg          netif_send_msg_remote
-#define netif_start_req         netif_start_req_remote
-#define netif_stop_req          netif_stop_req_remote
-#define netif_stats_req         netif_stats_req_remote
-#define netif_bind_service      netif_bind_service_remote
-
-#endif
-
-/** @}
- */
Index: uspace/lib/net/include/netif_local.h
===================================================================
--- uspace/lib/net/include/netif_local.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ 	(revision )
@@ -1,220 +1,0 @@
-/*
- * Copyright (c) 2009 Lukas Mejdrech
- * 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 libnet
- * @{
- */
-
-/** @file
- * Network interface module skeleton.
- * The skeleton has to be part of each network interface module.
- */
-
-#ifndef NET_NETIF_LOCAL_H_
-#define NET_NETIF_LOCAL_H_
-
-#include <async.h>
-#include <fibril_synch.h>
-#include <ipc/ipc.h>
-#include <ipc/services.h>
-
-#include <adt/measured_strings.h>
-#include <net/device.h>
-#include <net/packet.h>
-
-/** Network interface device specific data. */
-typedef struct {
-	device_id_t device_id;  /**< Device identifier. */
-	int nil_phone;          /**< Receiving network interface layer phone. */
-	device_state_t state;   /**< Actual device state. */
-	void *specific;         /**< Driver specific data. */
-} netif_device_t;
-
-/** Device map.
- *
- * Maps device identifiers to the network interface device specific data.
- * @see device.h
- *
- */
-DEVICE_MAP_DECLARE(netif_device_map, netif_device_t);
-
-/** Network interface module skeleton global data. */
-typedef struct {
-	int net_phone;                  /**< Networking module phone. */
-	netif_device_map_t device_map;  /**< Device map. */
-	fibril_rwlock_t lock;           /**< Safety lock. */
-} netif_globals_t;
-
-extern netif_globals_t netif_globals;
-
-/** Initialize the specific module.
- *
- * This function has to be implemented in user code.
- */
-extern int netif_initialize(void);
-
-/** Probe the existence of the device.
- *
- * This has to be implemented in user code.
- *
- * @param[in] device_id	The device identifier.
- * @param[in] irq	The device interrupt number.
- * @param[in] io	The device input/output address.
- *
- * @return		EOK on success.
- * @return		Other error codes as defined for the find_device()
- *			function.
- * @return		Other error codes as defined for the specific module
- *			message implementation.
- */
-extern int netif_probe_message(device_id_t device_id, int irq, uintptr_t io);
-
-/** Send the packet queue.
- *
- * This has to be implemented in user code.
- *
- * @param[in] device_id	The device identifier.
- * @param[in] packet	The packet queue.
- * @param[in] sender	The sending module service.
- *
- * @return		EOK on success.
- * @return		EFORWARD if the device is not active (in the
- *			NETIF_ACTIVE state).
- * @return		Other error codes as defined for the find_device()
- *			function.
- * @return		Other error codes as defined for the specific module
- *			message implementation.
- */
-extern int netif_send_message(device_id_t device_id, packet_t *packet,
-    services_t sender);
-
-/** Start the device.
- *
- * This has to be implemented in user code.
- *
- * @param[in] device	The device structure.
- *
- * @return		EOK on success.
- * @return		Other error codes as defined for the find_device()
- *			function.
- * @return		Other error codes as defined for the specific module
- *			message implementation.
- */
-extern int netif_start_message(netif_device_t *device);
-
-/** Stop the device.
- *
- * This has to be implemented in user code.
- *
- * @param[in] device	The device structure.
- *
- * @return		EOK on success.
- * @return		Other error codes as defined for the find_device()
- *			function.
- * @return		Other error codes as defined for the specific module
- *			message implementation.
- */
-extern int netif_stop_message(netif_device_t *device);
-
-/** Return the device local hardware address.
- *
- * This has to be implemented in user code.
- *
- * @param[in] device_id	The device identifier.
- * @param[out] address	The device local hardware address.
- *
- * @return		EOK on success.
- * @return		EBADMEM if the address parameter is NULL.
- * @return		ENOENT if there no such device.
- * @return		Other error codes as defined for the find_device()
- *			function.
- * @return		Other error codes as defined for the specific module
- *			message implementation.
- */
-extern int netif_get_addr_message(device_id_t device_id,
-    measured_string_t *address);
-
-/** Process the netif driver specific message.
- *
- * This function is called for uncommon messages received by the netif
- * skeleton. This has to be implemented in user code.
- *
- * @param[in] callid	The message identifier.
- * @param[in] call	The message parameters.
- * @param[out] answer	The message answer parameters.
- * @param[out] answer_count The last parameter for the actual answer in
- *			the answer parameter.
- *
- * @return		EOK on success.
- * @return		ENOTSUP if the message is not known.
- * @return		Other error codes as defined for the specific module
- *			message implementation.
- */
-extern int netif_specific_message(ipc_callid_t callid, ipc_call_t *call,
-    ipc_call_t *answer, int *answer_count);
-
-/** Return the device usage statistics.
- *
- * This has to be implemented in user code.
- *
- * @param[in] device_id	The device identifier.
- * @param[out] stats	The device usage statistics.
- *
- * @return		EOK on success.
- * @return		Other error codes as defined for the find_device()
- *			function.
- * @return		Other error codes as defined for the specific module
- *			message implementation.
- */
-extern int netif_get_device_stats(device_id_t device_id,
-    device_stats_t *stats);
-
-extern int netif_get_addr_req_local(int, device_id_t, measured_string_t **,
-    char **);
-extern int netif_probe_req_local(int, device_id_t, int, int);
-extern int netif_send_msg_local(int, device_id_t, packet_t *, services_t);
-extern int netif_start_req_local(int, device_id_t);
-extern int netif_stop_req_local(int, device_id_t);
-extern int netif_stats_req_local(int, device_id_t, device_stats_t *);
-extern int netif_bind_service_local(services_t, device_id_t, services_t,
-    async_client_conn_t);
-
-extern int find_device(device_id_t, netif_device_t **);
-extern void null_device_stats(device_stats_t *);
-extern void netif_pq_release(packet_id_t);
-extern packet_t *netif_packet_get_1(size_t);
-extern int netif_init_module(async_client_conn_t);
-
-extern int netif_module_message_standalone(const char *, ipc_callid_t,
-    ipc_call_t *, ipc_call_t *, int *);
-extern int netif_module_start_standalone(async_client_conn_t);
-
-#endif
-
-/** @}
- */
Index: uspace/lib/net/include/netif_remote.h
===================================================================
--- uspace/lib/net/include/netif_remote.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/net/include/netif_remote.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -41,12 +41,12 @@
 #include <net/packet.h>
 
-extern int netif_get_addr_req_remote(int, device_id_t, measured_string_t **,
-    char **);
-extern int netif_probe_req_remote(int, device_id_t, int, int);
-extern int netif_send_msg_remote(int, device_id_t, packet_t *, services_t);
-extern int netif_start_req_remote(int, device_id_t);
-extern int netif_stop_req_remote(int, device_id_t);
-extern int netif_stats_req_remote(int, device_id_t, device_stats_t *);
-extern int netif_bind_service_remote(services_t, device_id_t, services_t,
+extern int netif_get_addr_req(int, device_id_t, measured_string_t **,
+    uint8_t **);
+extern int netif_probe_req(int, device_id_t, int, void *);
+extern int netif_send_msg(int, device_id_t, packet_t *, services_t);
+extern int netif_start_req(int, device_id_t);
+extern int netif_stop_req(int, device_id_t);
+extern int netif_stats_req(int, device_id_t, device_stats_t *);
+extern int netif_bind_service(services_t, device_id_t, services_t,
     async_client_conn_t);
 
Index: uspace/lib/net/include/netif_skel.h
===================================================================
--- uspace/lib/net/include/netif_skel.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
+++ uspace/lib/net/include/netif_skel.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -0,0 +1,215 @@
+/*
+ * Copyright (c) 2009 Lukas Mejdrech
+ * 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 libnet
+ * @{
+ */
+
+/** @file
+ * Network interface module skeleton.
+ * The skeleton has to be part of each network interface module.
+ */
+
+#ifndef NET_NETIF_SKEL_H_
+#define NET_NETIF_SKEL_H_
+
+#include <async.h>
+#include <fibril_synch.h>
+#include <ipc/ipc.h>
+#include <ipc/services.h>
+
+#include <adt/measured_strings.h>
+#include <net/device.h>
+#include <net/packet.h>
+
+/** Network interface device specific data. */
+typedef struct {
+	device_id_t device_id;  /**< Device identifier. */
+	int nil_phone;          /**< Receiving network interface layer phone. */
+	device_state_t state;   /**< Actual device state. */
+	void *specific;         /**< Driver specific data. */
+} netif_device_t;
+
+/** Device map.
+ *
+ * Maps device identifiers to the network interface device specific data.
+ * @see device.h
+ *
+ */
+DEVICE_MAP_DECLARE(netif_device_map, netif_device_t);
+
+/** Network interface module skeleton global data. */
+typedef struct {
+	int net_phone;                  /**< Networking module phone. */
+	netif_device_map_t device_map;  /**< Device map. */
+	fibril_rwlock_t lock;           /**< Safety lock. */
+} netif_globals_t;
+
+extern netif_globals_t netif_globals;
+
+/** Initialize the specific module.
+ *
+ * This function has to be implemented in user code.
+ *
+ */
+extern int netif_initialize(void);
+
+/** Probe the existence of the device.
+ *
+ * This has to be implemented in user code.
+ *
+ * @param[in] device_id Device identifier.
+ * @param[in] irq       Device interrupt number.
+ * @param[in] io        Device input/output address.
+ *
+ * @return EOK on success.
+ * @return Other error codes as defined for the find_device()
+ *         function.
+ * @return Other error codes as defined for the specific module
+ *         message implementation.
+ *
+ */
+extern int netif_probe_message(device_id_t device_id, int irq, void *io);
+
+/** Send the packet queue.
+ *
+ * This has to be implemented in user code.
+ *
+ * @param[in] device_id Device identifier.
+ * @param[in] packet    Packet queue.
+ * @param[in] sender    Sending module service.
+ *
+ * @return EOK on success.
+ * @return EFORWARD if the device is not active (in the
+ *         NETIF_ACTIVE state).
+ * @return Other error codes as defined for the find_device()
+ *         function.
+ * @return Other error codes as defined for the specific module
+ *         message implementation.
+ *
+ */
+extern int netif_send_message(device_id_t device_id, packet_t *packet,
+    services_t sender);
+
+/** Start the device.
+ *
+ * This has to be implemented in user code.
+ *
+ * @param[in] device Device structure.
+ *
+ * @return New network interface state (non-negative values).
+ * @return Other error codes as defined for the find_device()
+ *         function.
+ * @return Other error codes as defined for the specific module
+ *         message implementation.
+ 
+ *
+ */
+extern int netif_start_message(netif_device_t *device);
+
+/** Stop the device.
+ *
+ * This has to be implemented in user code.
+ *
+ * @param[in] device Device structure.
+ *
+ * @return EOK on success.
+ * @return Other error codes as defined for the find_device()
+ *         function.
+ * @return Other error codes as defined for the specific module
+ *         message implementation.
+ *
+ */
+extern int netif_stop_message(netif_device_t *device);
+
+/** Return the device local hardware address.
+ *
+ * This has to be implemented in user code.
+ *
+ * @param[in] device_id Device identifier.
+ * @param[out] address  Device local hardware address.
+ *
+ * @return EOK on success.
+ * @return EBADMEM if the address parameter is NULL.
+ * @return ENOENT if there no such device.
+ * @return Other error codes as defined for the find_device()
+ *         function.
+ * @return Other error codes as defined for the specific module
+ *         message implementation.
+ *
+ */
+extern int netif_get_addr_message(device_id_t device_id,
+    measured_string_t *address);
+
+/** Process the netif driver specific message.
+ *
+ * This function is called for uncommon messages received by the netif
+ * skeleton. This has to be implemented in user code.
+ *
+ * @param[in]  callid Message identifier.
+ * @param[in]  call   Message.
+ * @param[out] answer Answer.
+ * @param[out] count  Number of answer arguments.
+ *
+ * @return EOK on success.
+ * @return ENOTSUP if the message is not known.
+ * @return Other error codes as defined for the specific module
+ *         message implementation.
+ *
+ */
+extern int netif_specific_message(ipc_callid_t callid, ipc_call_t *call,
+    ipc_call_t *answer, size_t *count);
+
+/** Return the device usage statistics.
+ *
+ * This has to be implemented in user code.
+ *
+ * @param[in]  device_id Device identifier.
+ * @param[out] stats     Device usage statistics.
+ *
+ * @return EOK on success.
+ * @return Other error codes as defined for the find_device()
+ *         function.
+ * @return Other error codes as defined for the specific module
+ *         message implementation.
+ *
+ */
+extern int netif_get_device_stats(device_id_t device_id,
+    device_stats_t *stats);
+
+extern int find_device(device_id_t, netif_device_t **);
+extern void null_device_stats(device_stats_t *);
+extern void netif_pq_release(packet_id_t);
+extern packet_t *netif_packet_get_1(size_t);
+
+extern int netif_module_start(void);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/net/include/nil_local.h
===================================================================
--- uspace/lib/net/include/nil_local.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/net/include/nil_local.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -96,5 +96,5 @@
  */
 extern int nil_message_standalone(const char *, ipc_callid_t, ipc_call_t *,
-    ipc_call_t *, int *);
+    ipc_call_t *, size_t *);
 
 /** Pass the parameters to the module specific nil_message() function.
@@ -112,5 +112,5 @@
  */
 extern int nil_module_message_standalone(const char *, ipc_callid_t,
-    ipc_call_t *, ipc_call_t *, int *);
+    ipc_call_t *, ipc_call_t *, size_t *);
 
 /** Start the standalone nil layer module.
Index: uspace/lib/net/include/socket_core.h
===================================================================
--- uspace/lib/net/include/socket_core.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/net/include/socket_core.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -86,5 +86,5 @@
 	void *specific_data;
 	/** Socket ports map key. */
-	const char *key;
+	const uint8_t *key;
 	/** Length of the Socket ports map key. */
 	size_t key_length;
@@ -118,9 +118,9 @@
     void (*)(socket_core_t *));
 extern int socket_reply_packets(packet_t *, size_t *);
-extern socket_core_t *socket_port_find(socket_ports_t *, int, const char *,
+extern socket_core_t *socket_port_find(socket_ports_t *, int, const uint8_t *,
     size_t);
 extern void socket_port_release(socket_ports_t *, socket_core_t *);
 extern int socket_port_add(socket_ports_t *, int, socket_core_t *,
-    const char *, size_t);
+    const uint8_t *, size_t);
 
 #endif
Index: uspace/lib/net/include/tl_local.h
===================================================================
--- uspace/lib/net/include/tl_local.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/net/include/tl_local.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -52,6 +52,5 @@
  */
 extern int tl_module_message_standalone(ipc_callid_t, ipc_call_t *,
-    ipc_call_t *, int *);
-
+    ipc_call_t *, size_t *);
 
 /** Processes the TL module message.
Index: uspace/lib/net/netif/netif_local.c
===================================================================
--- uspace/lib/net/netif/netif_local.c	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ 	(revision )
@@ -1,458 +1,0 @@
-/*
- * Copyright (c) 2009 Lukas Mejdrech
- * 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 libnet 
- * @{
- */
-
-/** @file
- * Network interface module skeleton implementation.
- * @see netif.h
- */
-
-#include <async.h>
-#include <mem.h>
-#include <fibril_synch.h>
-#include <stdio.h>
-#include <ipc/ipc.h>
-#include <ipc/services.h>
-#include <ipc/netif.h>
-#include <errno.h>
-
-#include <generic.h>
-#include <net/modules.h>
-#include <net/packet.h>
-#include <packet_client.h>
-#include <packet_remote.h>
-#include <adt/measured_strings.h>
-#include <net/device.h>
-#include <nil_interface.h>
-#include <netif_local.h>
-#include <netif_interface.h>
-
-DEVICE_MAP_IMPLEMENT(netif_device_map, netif_device_t);
-
-/** Network interface global data. */
-netif_globals_t netif_globals;
-
-/** Probe the existence of the device.
- *
- * @param[in] netif_phone The network interface phone.
- * @param[in] device_id	The device identifier.
- * @param[in] irq	The device interrupt number.
- * @param[in] io	The device input/output address.
- * @return		EOK on success.
- * @return		Other error codes as defined for the
- *			netif_probe_message().
- */
-int
-netif_probe_req_local(int netif_phone, device_id_t device_id, int irq, int io)
-{
-	fibril_rwlock_write_lock(&netif_globals.lock);
-	int result = netif_probe_message(device_id, irq, io);
-	fibril_rwlock_write_unlock(&netif_globals.lock);
-	
-	return result;
-}
-
-/** Send the packet queue.
- *
- * @param[in] netif_phone The network interface phone.
- * @param[in] device_id	The device identifier.
- * @param[in] packet	The packet queue.
- * @param[in] sender	The sending module service.
- * @return		EOK on success.
- * @return		Other error codes as defined for the generic_send_msg()
- *			function.
- */
-int netif_send_msg_local(int netif_phone, device_id_t device_id,
-    packet_t *packet, services_t sender)
-{
-	fibril_rwlock_write_lock(&netif_globals.lock);
-	int result = netif_send_message(device_id, packet, sender);
-	fibril_rwlock_write_unlock(&netif_globals.lock);
-	
-	return result;
-}
-
-/** Start the device.
- *
- * @param[in] netif_phone The network interface phone.
- * @param[in] device_id	The device identifier.
- * @return		EOK on success.
- * @return		Other error codes as defined for the find_device()
- *			function.
- * @return		Other error codes as defined for the
- *			netif_start_message() function.
- */
-int netif_start_req_local(int netif_phone, device_id_t device_id)
-{
-	int rc;
-	
-	fibril_rwlock_write_lock(&netif_globals.lock);
-	
-	netif_device_t *device;
-	rc = find_device(device_id, &device);
-	if (rc != EOK) {
-		fibril_rwlock_write_unlock(&netif_globals.lock);
-		return rc;
-	}
-	
-	int result = netif_start_message(device);
-	if (result > NETIF_NULL) {
-		int phone = device->nil_phone;
-		fibril_rwlock_write_unlock(&netif_globals.lock);
-		nil_device_state_msg(phone, device_id, result);
-		return EOK;
-	}
-	
-	fibril_rwlock_write_unlock(&netif_globals.lock);
-	
-	return result;
-}
-
-/** Stop the device.
- *
- * @param[in] netif_phone The network interface phone.
- * @param[in] device_id	The device identifier.
- * @return		EOK on success.
- * @return		Other error codes as defined for the find_device()
- *			function.
- * @return		Other error codes as defined for the
- *			netif_stop_message() function.
- */
-int netif_stop_req_local(int netif_phone, device_id_t device_id)
-{
-	int rc;
-	
-	fibril_rwlock_write_lock(&netif_globals.lock);
-	
-	netif_device_t *device;
-	rc = find_device(device_id, &device);
-	if (rc != EOK) {
-		fibril_rwlock_write_unlock(&netif_globals.lock);
-		return rc;
-	}
-	
-	int result = netif_stop_message(device);
-	if (result > NETIF_NULL) {
-		int phone = device->nil_phone;
-		fibril_rwlock_write_unlock(&netif_globals.lock);
-		nil_device_state_msg(phone, device_id, result);
-		return EOK;
-	}
-	
-	fibril_rwlock_write_unlock(&netif_globals.lock);
-	
-	return result;
-}
-
-/** Return the device usage statistics.
- *
- * @param[in] netif_phone The network interface phone.
- * @param[in] device_id	The device identifier.
- * @param[out] stats	The device usage statistics.
- * @return EOK on success.
- */
-int netif_stats_req_local(int netif_phone, device_id_t device_id,
-    device_stats_t *stats)
-{
-	fibril_rwlock_read_lock(&netif_globals.lock);
-	int res = netif_get_device_stats(device_id, stats);
-	fibril_rwlock_read_unlock(&netif_globals.lock);
-	
-	return res;
-}
-
-/** Return the device local hardware address.
- *
- * @param[in] netif_phone The network interface phone.
- * @param[in] device_id	The device identifier.
- * @param[out] address	The device local hardware address.
- * @param[out] data	The address data.
- * @return		EOK on success.
- * @return		EBADMEM if the address parameter is NULL.
- * @return		ENOENT if there no such device.
- * @return		Other error codes as defined for the
- *			netif_get_addr_message() function.
- */
-int netif_get_addr_req_local(int netif_phone, device_id_t device_id,
-    measured_string_t **address, char **data)
-{
-	int rc;
-	
-	if (!address || !data)
-		return EBADMEM;
-	
-	fibril_rwlock_read_lock(&netif_globals.lock);
-	
-	measured_string_t translation;
-	rc = netif_get_addr_message(device_id, &translation);
-	if (rc == EOK) {
-		*address = measured_string_copy(&translation);
-		rc = (*address) ? EOK : ENOMEM;
-	}
-	
-	fibril_rwlock_read_unlock(&netif_globals.lock);
-	
-	*data = (**address).value;
-	
-	return rc;
-}
-
-/** Find the device specific data.
- *
- * @param[in] device_id	The device identifier.
- * @param[out] device	The device specific data.
- * @return		EOK on success.
- * @return		ENOENT if device is not found.
- * @return		EPERM if the device is not initialized.
- */
-int find_device(device_id_t device_id, netif_device_t **device)
-{
-	if (!device)
-		return EBADMEM;
-	
-	*device = netif_device_map_find(&netif_globals.device_map, device_id);
-	if (*device == NULL)
-		return ENOENT;
-	
-	if ((*device)->state == NETIF_NULL)
-		return EPERM;
-	
-	return EOK;
-}
-
-/** Clear the usage statistics.
- *
- * @param[in] stats	The usage statistics.
- */
-void null_device_stats(device_stats_t *stats)
-{
-	bzero(stats, sizeof(device_stats_t));
-}
-
-/** Initialize the netif module.
- *
- * @param[in] client_connection The client connection functio to be registered.
- * @return		EOK on success.
- * @return		Other error codes as defined for each specific module
- *			message function.
- */
-int netif_init_module(async_client_conn_t client_connection)
-{
-	int rc;
-	
-	async_set_client_connection(client_connection);
-	
-	netif_globals.net_phone = connect_to_service(SERVICE_NETWORKING);
-	netif_device_map_initialize(&netif_globals.device_map);
-	
-	rc = pm_init();
-	if (rc != EOK)
-		return rc;
-	
-	fibril_rwlock_initialize(&netif_globals.lock);
-	
-	rc = netif_initialize();
-	if (rc != EOK) {
-		pm_destroy();
-		return rc;
-	}
-	
-	return EOK;
-}
-
-/** Release the given packet.
- *
- * Prepared for future optimization.
- *
- * @param[in] packet_id	The packet identifier.
- */
-void netif_pq_release(packet_id_t packet_id)
-{
-	pq_release_remote(netif_globals.net_phone, packet_id);
-}
-
-/** Allocate new packet to handle the given content size.
- *
- * @param[in] content	The minimum content size.
- * @return		The allocated packet.
- * @return		NULL if there is an error.
- *
- */
-packet_t *netif_packet_get_1(size_t content)
-{
-	return packet_get_1_remote(netif_globals.net_phone, content);
-}
-
-/** Register the device notification receiver, the network interface layer
- * module.
- *
- * @param[in] name	Module name.
- * @param[in] device_id	The device identifier.
- * @param[in] phone	The network interface layer module phone.
- * @return		EOK on success.
- * @return		ENOENT if there is no such device.
- * @return		ELIMIT if there is another module registered.
- */
-static int register_message(const char *name, device_id_t device_id, int phone)
-{
-	netif_device_t *device;
-	int rc;
-	
-	rc = find_device(device_id, &device);
-	if (rc != EOK)
-		return rc;
-	
-	if (device->nil_phone > 0)
-		return ELIMIT;
-	
-	device->nil_phone = phone;
-	printf("%s: Receiver of device %d registered (phone: %d)\n",
-	    name, device->device_id, device->nil_phone);
-	return EOK;
-}
-
-/** Process the netif module messages.
- *
- * @param[in] name 	Module name.
- * @param[in] callid	The message identifier.
- * @param[in] call	The message parameters.
- * @param[out] answer	The message answer parameters.
- * @param[out] answer_count The last parameter for the actual answer in the
- *			answer parameter.
- * @return		EOK on success.
- * @return		ENOTSUP if the message is not known.
- * @return		Other error codes as defined for each specific module
- *			message function.
- *
- * @see IS_NET_NETIF_MESSAGE()
- *
- */
-int netif_module_message_standalone(const char *name, ipc_callid_t callid,
-    ipc_call_t *call, ipc_call_t *answer, int *answer_count)
-{
-	size_t length;
-	device_stats_t stats;
-	packet_t *packet;
-	measured_string_t address;
-	int rc;
-	
-	*answer_count = 0;
-	switch (IPC_GET_IMETHOD(*call)) {
-	case IPC_M_PHONE_HUNGUP:
-		return EOK;
-	
-	case NET_NETIF_PROBE:
-		return netif_probe_req_local(0, IPC_GET_DEVICE(call),
-		    NETIF_GET_IRQ(call), NETIF_GET_IO(call));
-		    
-	case IPC_M_CONNECT_TO_ME:
-		fibril_rwlock_write_lock(&netif_globals.lock);
-		rc = register_message(name, IPC_GET_DEVICE(call),
-		    IPC_GET_PHONE(call));
-		fibril_rwlock_write_unlock(&netif_globals.lock);
-		return rc;
-		
-	case NET_NETIF_SEND:
-		rc = packet_translate_remote(netif_globals.net_phone, &packet,
-		    IPC_GET_PACKET(call));
-		if (rc != EOK)
-			return rc;
-		return netif_send_msg_local(0, IPC_GET_DEVICE(call), packet,
-		    IPC_GET_SENDER(call));
-		
-	case NET_NETIF_START:
-		return netif_start_req_local(0, IPC_GET_DEVICE(call));
-		
-	case NET_NETIF_STATS:
-		fibril_rwlock_read_lock(&netif_globals.lock);
-
-		rc = async_data_read_receive(&callid, &length);
-		if (rc != EOK) {
-			fibril_rwlock_read_unlock(&netif_globals.lock);
-			return rc;
-		}
-		if (length < sizeof(device_stats_t)) {
-			fibril_rwlock_read_unlock(&netif_globals.lock);
-			return EOVERFLOW;
-		}
-
-		rc = netif_get_device_stats(IPC_GET_DEVICE(call), &stats);
-		if (rc == EOK) {
-			rc = async_data_read_finalize(callid, &stats,
-			    sizeof(device_stats_t));
-		}
-
-		fibril_rwlock_read_unlock(&netif_globals.lock);
-		return rc;
-
-	case NET_NETIF_STOP:
-		return netif_stop_req_local(0, IPC_GET_DEVICE(call));
-		
-	case NET_NETIF_GET_ADDR:
-		fibril_rwlock_read_lock(&netif_globals.lock);
-		rc = netif_get_addr_message(IPC_GET_DEVICE(call), &address);
-		if (rc == EOK)
-			rc = measured_strings_reply(&address, 1);
-		fibril_rwlock_read_unlock(&netif_globals.lock);
-		return rc;
-	}
-	
-	return netif_specific_message(callid, call, answer, answer_count);
-}
-
-/** Start the network interface module.
- *
- * Initialize the client connection serving function, initialize the module,
- * registers the module service and start the async manager, processing IPC
- * messages in an infinite loop.
- *
- * @param[in] client_connection The client connection processing function.
- *			The module skeleton propagates its own one.
- * @return		EOK on success.
- * @return		Other error codes as defined for each specific module
- *			message function.
- */
-int netif_module_start_standalone(async_client_conn_t client_connection)
-{
-	int rc;
-	
-	rc = netif_init_module(client_connection);
-	if (rc != EOK)
-		return rc;
-	
-	async_manager();
-	
-	pm_destroy();
-	return EOK;
-}
-
-/** @}
- */
Index: uspace/lib/net/netif/netif_remote.c
===================================================================
--- uspace/lib/net/netif/netif_remote.c	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/net/netif/netif_remote.c	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libnet 
+/** @addtogroup libnet
  * @{
  */
@@ -49,16 +49,18 @@
 /** Return the device local hardware address.
  *
- * @param[in] netif_phone The network interface phone.
- * @param[in] device_id	The device identifier.
- * @param[out] address	The device local hardware address.
- * @param[out] data	The address data.
- * @return		EOK on success.
- * @return		EBADMEM if the address parameter is NULL.
- * @return		ENOENT if there no such device.
- * @return		Other error codes as defined for the
- *			netif_get_addr_message() function.
+ * @param[in]  netif_phone Network interface phone.
+ * @param[in]  device_id   Device identifier.
+ * @param[out] address     Device local hardware address.
+ * @param[out] data        Address data.
+ *
+ * @return EOK on success.
+ * @return EBADMEM if the address parameter is NULL.
+ * @return ENOENT if there no such device.
+ * @return Other error codes as defined for the
+ *         netif_get_addr_message() function.
+ *
  */
-int netif_get_addr_req_remote(int netif_phone, device_id_t device_id,
-    measured_string_t **address, char **data)
+int netif_get_addr_req(int netif_phone, device_id_t device_id,
+    measured_string_t **address, uint8_t **data)
 {
 	return generic_get_addr_req(netif_phone, NET_NETIF_GET_ADDR, device_id,
@@ -68,30 +70,33 @@
 /** Probe the existence of the device.
  *
- * @param[in] netif_phone The network interface phone.
- * @param[in] device_id	The device identifier.
- * @param[in] irq	The device interrupt number.
- * @param[in] io	The device input/output address.
- * @return		EOK on success.
- * @return		Other error codes as defined for the
- *			netif_probe_message().
+ * @param[in] netif_phone Network interface phone.
+ * @param[in] device_id   Device identifier.
+ * @param[in] irq         Device interrupt number.
+ * @param[in] io          Device input/output address.
+ *
+ * @return EOK on success.
+ * @return Other error codes as defined for the
+ *         netif_probe_message().
+ *
  */
-int
-netif_probe_req_remote(int netif_phone, device_id_t device_id, int irq, int io)
+int netif_probe_req(int netif_phone, device_id_t device_id, int irq, void *io)
 {
-	return async_req_3_0(netif_phone, NET_NETIF_PROBE, device_id, irq, io);
+	return async_req_3_0(netif_phone, NET_NETIF_PROBE, device_id, irq,
+	    (sysarg_t) io);
 }
 
 /** Send the packet queue.
  *
- * @param[in] netif_phone The network interface phone.
- * @param[in] device_id	The device identifier.
- * @param[in] packet	The packet queue.
- * @param[in] sender	The sending module service.
- * @return		EOK on success.
- * @return		Other error codes as defined for the generic_send_msg()
- *			function.
+ * @param[in] netif_phone Network interface phone.
+ * @param[in] device_id   Device identifier.
+ * @param[in] packet      Packet queue.
+ * @param[in] sender      Sending module service.
+ *
+ * @return EOK on success.
+ * @return Other error codes as defined for the generic_send_msg()
+ *         function.
+ *
  */
-int
-netif_send_msg_remote(int netif_phone, device_id_t device_id, packet_t *packet,
+int netif_send_msg(int netif_phone, device_id_t device_id, packet_t *packet,
     services_t sender)
 {
@@ -102,13 +107,15 @@
 /** Start the device.
  *
- * @param[in] netif_phone The network interface phone.
- * @param[in] device_id	The device identifier.
- * @return		EOK on success.
- * @return		Other error codes as defined for the find_device()
- *			function.
- * @return		Other error codes as defined for the
- *			netif_start_message() function.
+ * @param[in] netif_phone Network interface phone.
+ * @param[in] device_id   Device identifier.
+ *
+ * @return EOK on success.
+ * @return Other error codes as defined for the find_device()
+ *         function.
+ * @return Other error codes as defined for the
+ *         netif_start_message() function.
+ *
  */
-int netif_start_req_remote(int netif_phone, device_id_t device_id)
+int netif_start_req(int netif_phone, device_id_t device_id)
 {
 	return async_req_1_0(netif_phone, NET_NETIF_START, device_id);
@@ -117,13 +124,15 @@
 /** Stop the device.
  *
- * @param[in] netif_phone The network interface phone.
- * @param[in] device_id	The device identifier.
- * @return		EOK on success.
- * @return		Other error codes as defined for the find_device()
- *			function.
- * @return		Other error codes as defined for the
- *			netif_stop_message() function.
+ * @param[in] netif_phone Network interface phone.
+ * @param[in] device_id   Device identifier.
+ *
+ * @return EOK on success.
+ * @return Other error codes as defined for the find_device()
+ *         function.
+ * @return Other error codes as defined for the
+ *         netif_stop_message() function.
+ *
  */
-int netif_stop_req_remote(int netif_phone, device_id_t device_id)
+int netif_stop_req(int netif_phone, device_id_t device_id)
 {
 	return async_req_1_0(netif_phone, NET_NETIF_STOP, device_id);
@@ -132,10 +141,12 @@
 /** Return the device usage statistics.
  *
- * @param[in] netif_phone The network interface phone.
- * @param[in] device_id	The device identifier.
- * @param[out] stats	The device usage statistics.
+ * @param[in] netif_phone Network interface phone.
+ * @param[in] device_id   Device identifier.
+ * @param[out] stats      Device usage statistics.
+ *
  * @return EOK on success.
+ *
  */
-int netif_stats_req_remote(int netif_phone, device_id_t device_id,
+int netif_stats_req(int netif_phone, device_id_t device_id,
     device_stats_t *stats)
 {
@@ -153,6 +164,8 @@
 }
 
-/** Create bidirectional connection with the network interface module and
- * registers the message receiver.
+/** Create bidirectional connection with the network interface module
+ *
+ * Create bidirectional connection with the network interface module and
+ * register the message receiver.
  *
  * @param[in] service   The network interface module service.
@@ -161,11 +174,11 @@
  * @param[in] receiver  The message receiver.
  *
- * @return		The phone of the needed service.
- * @return		EOK on success.
- * @return		Other error codes as defined for the bind_service()
- *			function.
+ * @return The phone of the needed service.
+ * @return EOK on success.
+ * @return Other error codes as defined for the bind_service()
+ *         function.
+ *
  */
-int
-netif_bind_service_remote(services_t service, device_id_t device_id,
+int netif_bind_service(services_t service, device_id_t device_id,
     services_t me, async_client_conn_t receiver)
 {
Index: uspace/lib/net/netif/netif_skel.c
===================================================================
--- uspace/lib/net/netif/netif_skel.c	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
+++ uspace/lib/net/netif/netif_skel.c	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -0,0 +1,434 @@
+/*
+ * Copyright (c) 2009 Lukas Mejdrech
+ * 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 libnet
+ * @{
+ */
+
+/** @file
+ * Network interface module skeleton implementation.
+ * @see netif.h
+ */
+
+#include <async.h>
+#include <mem.h>
+#include <fibril_synch.h>
+#include <stdio.h>
+#include <ipc/ipc.h>
+#include <ipc/services.h>
+#include <ipc/netif.h>
+#include <errno.h>
+
+#include <generic.h>
+#include <net/modules.h>
+#include <net/packet.h>
+#include <packet_client.h>
+#include <packet_remote.h>
+#include <adt/measured_strings.h>
+#include <net/device.h>
+#include <nil_interface.h>
+#include <netif_skel.h>
+
+DEVICE_MAP_IMPLEMENT(netif_device_map, netif_device_t);
+
+/** Network interface global data. */
+netif_globals_t netif_globals;
+
+/** Probe the existence of the device.
+ *
+ * @param[in] netif_phone Network interface phone.
+ * @param[in] device_id   Device identifier.
+ * @param[in] irq         Device interrupt number.
+ * @param[in] io          Device input/output address.
+ *
+ * @return EOK on success.
+ * @return Other error codes as defined for the
+ *         netif_probe_message().
+ *
+ */
+static int netif_probe_req_local(int netif_phone, device_id_t device_id,
+    int irq, void *io)
+{
+	fibril_rwlock_write_lock(&netif_globals.lock);
+	int result = netif_probe_message(device_id, irq, io);
+	fibril_rwlock_write_unlock(&netif_globals.lock);
+	
+	return result;
+}
+
+/** Send the packet queue.
+ *
+ * @param[in] netif_phone Network interface phone.
+ * @param[in] device_id   Device identifier.
+ * @param[in] packet      Packet queue.
+ * @param[in] sender      Sending module service.
+ *
+ * @return EOK on success.
+ * @return Other error codes as defined for the generic_send_msg()
+ *         function.
+ *
+ */
+static int netif_send_msg_local(int netif_phone, device_id_t device_id,
+    packet_t *packet, services_t sender)
+{
+	fibril_rwlock_write_lock(&netif_globals.lock);
+	int result = netif_send_message(device_id, packet, sender);
+	fibril_rwlock_write_unlock(&netif_globals.lock);
+	
+	return result;
+}
+
+/** Start the device.
+ *
+ * @param[in] netif_phone Network interface phone.
+ * @param[in] device_id   Device identifier.
+ *
+ * @return EOK on success.
+ * @return Other error codes as defined for the find_device()
+ *         function.
+ * @return Other error codes as defined for the
+ *         netif_start_message() function.
+ *
+ */
+static int netif_start_req_local(int netif_phone, device_id_t device_id)
+{
+	fibril_rwlock_write_lock(&netif_globals.lock);
+	
+	netif_device_t *device;
+	int rc = find_device(device_id, &device);
+	if (rc != EOK) {
+		fibril_rwlock_write_unlock(&netif_globals.lock);
+		return rc;
+	}
+	
+	int result = netif_start_message(device);
+	if (result > NETIF_NULL) {
+		int phone = device->nil_phone;
+		fibril_rwlock_write_unlock(&netif_globals.lock);
+		nil_device_state_msg(phone, device_id, result);
+		return EOK;
+	}
+	
+	fibril_rwlock_write_unlock(&netif_globals.lock);
+	
+	return result;
+}
+
+/** Stop the device.
+ *
+ * @param[in] netif_phone Network interface phone.
+ * @param[in] device_id   Device identifier.
+ *
+ * @return EOK on success.
+ * @return Other error codes as defined for the find_device()
+ *         function.
+ * @return Other error codes as defined for the
+ *         netif_stop_message() function.
+ *
+ */
+static int netif_stop_req_local(int netif_phone, device_id_t device_id)
+{
+	fibril_rwlock_write_lock(&netif_globals.lock);
+	
+	netif_device_t *device;
+	int rc = find_device(device_id, &device);
+	if (rc != EOK) {
+		fibril_rwlock_write_unlock(&netif_globals.lock);
+		return rc;
+	}
+	
+	int result = netif_stop_message(device);
+	if (result > NETIF_NULL) {
+		int phone = device->nil_phone;
+		fibril_rwlock_write_unlock(&netif_globals.lock);
+		nil_device_state_msg(phone, device_id, result);
+		return EOK;
+	}
+	
+	fibril_rwlock_write_unlock(&netif_globals.lock);
+	
+	return result;
+}
+
+/** Find the device specific data.
+ *
+ * @param[in]  device_id Device identifier.
+ * @param[out] device    Device specific data.
+ *
+ * @return EOK on success.
+ * @return ENOENT if device is not found.
+ * @return EPERM if the device is not initialized.
+ *
+ */
+int find_device(device_id_t device_id, netif_device_t **device)
+{
+	if (!device)
+		return EBADMEM;
+	
+	*device = netif_device_map_find(&netif_globals.device_map, device_id);
+	if (*device == NULL)
+		return ENOENT;
+	
+	if ((*device)->state == NETIF_NULL)
+		return EPERM;
+	
+	return EOK;
+}
+
+/** Clear the usage statistics.
+ *
+ * @param[in] stats The usage statistics.
+ *
+ */
+void null_device_stats(device_stats_t *stats)
+{
+	bzero(stats, sizeof(device_stats_t));
+}
+
+/** Release the given packet.
+ *
+ * Prepared for future optimization.
+ *
+ * @param[in] packet_id The packet identifier.
+ *
+ */
+void netif_pq_release(packet_id_t packet_id)
+{
+	pq_release_remote(netif_globals.net_phone, packet_id);
+}
+
+/** Allocate new packet to handle the given content size.
+ *
+ * @param[in] content Minimum content size.
+ *
+ * @return The allocated packet.
+ * @return NULL on error.
+ *
+ */
+packet_t *netif_packet_get_1(size_t content)
+{
+	return packet_get_1_remote(netif_globals.net_phone, content);
+}
+
+/** Register the device notification receiver,
+ *
+ * Register a  network interface layer module as the device
+ * notification receiver.
+ *
+ * @param[in] device_id Device identifier.
+ * @param[in] phone     Network interface layer module phone.
+ *
+ * @return EOK on success.
+ * @return ENOENT if there is no such device.
+ * @return ELIMIT if there is another module registered.
+ *
+ */
+static int register_message(device_id_t device_id, int phone)
+{
+	netif_device_t *device;
+	int rc = find_device(device_id, &device);
+	if (rc != EOK)
+		return rc;
+	
+	if (device->nil_phone >= 0)
+		return ELIMIT;
+	
+	device->nil_phone = phone;
+	return EOK;
+}
+
+/** Process the netif module messages.
+ *
+ * @param[in]  callid Mmessage identifier.
+ * @param[in]  call   Message.
+ * @param[out] answer Answer.
+ * @param[out] count  Number of arguments of the answer.
+ *
+ * @return EOK on success.
+ * @return ENOTSUP if the message is unknown.
+ * @return Other error codes as defined for each specific module
+ *         message function.
+ *
+ * @see IS_NET_NETIF_MESSAGE()
+ *
+ */
+static int netif_module_message(ipc_callid_t callid, ipc_call_t *call,
+    ipc_call_t *answer, size_t *count)
+{
+	size_t length;
+	device_stats_t stats;
+	packet_t *packet;
+	measured_string_t address;
+	int rc;
+	
+	*count = 0;
+	
+	switch (IPC_GET_IMETHOD(*call)) {
+	case IPC_M_PHONE_HUNGUP:
+		return EOK;
+	
+	case NET_NETIF_PROBE:
+		return netif_probe_req_local(0, IPC_GET_DEVICE(*call),
+		    NETIF_GET_IRQ(*call), NETIF_GET_IO(*call));
+	
+	case IPC_M_CONNECT_TO_ME:
+		fibril_rwlock_write_lock(&netif_globals.lock);
+		
+		rc = register_message(IPC_GET_DEVICE(*call), IPC_GET_PHONE(*call));
+		
+		fibril_rwlock_write_unlock(&netif_globals.lock);
+		return rc;
+	
+	case NET_NETIF_SEND:
+		rc = packet_translate_remote(netif_globals.net_phone, &packet,
+		    IPC_GET_PACKET(*call));
+		if (rc != EOK)
+			return rc;
+		
+		return netif_send_msg_local(0, IPC_GET_DEVICE(*call), packet,
+		    IPC_GET_SENDER(*call));
+	
+	case NET_NETIF_START:
+		return netif_start_req_local(0, IPC_GET_DEVICE(*call));
+	
+	case NET_NETIF_STATS:
+		fibril_rwlock_read_lock(&netif_globals.lock);
+		
+		rc = async_data_read_receive(&callid, &length);
+		if (rc != EOK) {
+			fibril_rwlock_read_unlock(&netif_globals.lock);
+			return rc;
+		}
+		
+		if (length < sizeof(device_stats_t)) {
+			fibril_rwlock_read_unlock(&netif_globals.lock);
+			return EOVERFLOW;
+		}
+		
+		rc = netif_get_device_stats(IPC_GET_DEVICE(*call), &stats);
+		if (rc == EOK) {
+			rc = async_data_read_finalize(callid, &stats,
+			    sizeof(device_stats_t));
+		}
+		
+		fibril_rwlock_read_unlock(&netif_globals.lock);
+		return rc;
+	
+	case NET_NETIF_STOP:
+		return netif_stop_req_local(0, IPC_GET_DEVICE(*call));
+	
+	case NET_NETIF_GET_ADDR:
+		fibril_rwlock_read_lock(&netif_globals.lock);
+		
+		rc = netif_get_addr_message(IPC_GET_DEVICE(*call), &address);
+		if (rc == EOK)
+			rc = measured_strings_reply(&address, 1);
+		
+		fibril_rwlock_read_unlock(&netif_globals.lock);
+		return rc;
+	}
+	
+	return netif_specific_message(callid, call, answer, count);
+}
+
+/** Default fibril for new module connections.
+ *
+ * @param[in] iid   Initial message identifier.
+ * @param[in] icall Initial message call structure.
+ *
+ */
+static void netif_client_connection(ipc_callid_t iid, ipc_call_t *icall)
+{
+	/*
+	 * Accept the connection by answering
+	 * the initial IPC_M_CONNECT_ME_TO call.
+	 */
+	ipc_answer_0(iid, EOK);
+	
+	while (true) {
+		ipc_call_t answer;
+		size_t count;
+		
+		/* Clear the answer structure */
+		refresh_answer(&answer, &count);
+		
+		/* Fetch the next message */
+		ipc_call_t call;
+		ipc_callid_t callid = async_get_call(&call);
+		
+		/* Process the message */
+		int res = netif_module_message(callid, &call, &answer, &count);
+		
+		/* End if said to either by the message or the processing result */
+		if ((IPC_GET_IMETHOD(call) == IPC_M_PHONE_HUNGUP) ||
+		    (res == EHANGUP))
+			return;
+		
+		/* Answer the message */
+		answer_call(callid, res, &answer, count);
+	}
+}
+
+/** Start the network interface module.
+ *
+ * Initialize the client connection serving function, initialize the module,
+ * registers the module service and start the async manager, processing IPC
+ * messages in an infinite loop.
+ *
+ * @return EOK on success.
+ * @return Other error codes as defined for each specific module
+ *         message function.
+ *
+ */
+int netif_module_start(void)
+{
+	async_set_client_connection(netif_client_connection);
+	
+	netif_globals.net_phone = connect_to_service(SERVICE_NETWORKING);
+	netif_device_map_initialize(&netif_globals.device_map);
+	
+	int rc = pm_init();
+	if (rc != EOK)
+		return rc;
+	
+	fibril_rwlock_initialize(&netif_globals.lock);
+	
+	rc = netif_initialize();
+	if (rc != EOK) {
+		pm_destroy();
+		return rc;
+	}
+	
+	async_manager();
+	
+	pm_destroy();
+	return EOK;
+}
+
+/** @}
+ */
Index: uspace/lib/net/tl/socket_core.c
===================================================================
--- uspace/lib/net/tl/socket_core.c	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/net/tl/socket_core.c	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -161,5 +161,5 @@
 static int
 socket_port_add_core(socket_port_t *socket_port, socket_core_t *socket,
-    const char *key, size_t key_length)
+    const uint8_t *key, size_t key_length)
 {
 	socket_core_t **socket_ref;
@@ -216,6 +216,6 @@
 		goto fail;
 	
-	rc = socket_port_add_core(socket_port, socket, SOCKET_MAP_KEY_LISTENING,
-	    0);
+	rc = socket_port_add_core(socket_port, socket,
+	    (const uint8_t *) SOCKET_MAP_KEY_LISTENING, 0);
 	if (rc != EOK)
 		goto fail;
@@ -602,5 +602,5 @@
  */
 socket_core_t *
-socket_port_find(socket_ports_t *global_sockets, int port, const char *key,
+socket_port_find(socket_ports_t *global_sockets, int port, const uint8_t *key,
     size_t key_length)
 {
@@ -680,5 +680,5 @@
 int
 socket_port_add(socket_ports_t *global_sockets, int port,
-    socket_core_t *socket, const char *key, size_t key_length)
+    socket_core_t *socket, const uint8_t *key, size_t key_length)
 {
 	socket_port_t *socket_port;
Index: uspace/lib/packet/generic/packet_server.c
===================================================================
--- uspace/lib/packet/generic/packet_server.c	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/packet/generic/packet_server.c	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -322,5 +322,5 @@
 int
 packet_server_message(ipc_callid_t callid, ipc_call_t *call, ipc_call_t *answer,
-    int *answer_count)
+    size_t *answer_count)
 {
 	packet_t *packet;
@@ -333,5 +333,5 @@
 	case NET_PACKET_CREATE_1:
 		packet = packet_get_local(DEFAULT_ADDR_LEN, DEFAULT_PREFIX,
-		    IPC_GET_CONTENT(call), DEFAULT_SUFFIX);
+		    IPC_GET_CONTENT(*call), DEFAULT_SUFFIX);
 		if (!packet)
 			return ENOMEM;
@@ -343,9 +343,9 @@
 	case NET_PACKET_CREATE_4:
 		packet = packet_get_local(
-		    ((DEFAULT_ADDR_LEN < IPC_GET_ADDR_LEN(call)) ?
-		    IPC_GET_ADDR_LEN(call) : DEFAULT_ADDR_LEN),
-		    DEFAULT_PREFIX + IPC_GET_PREFIX(call),
-		    IPC_GET_CONTENT(call),
-		    DEFAULT_SUFFIX + IPC_GET_SUFFIX(call));
+		    ((DEFAULT_ADDR_LEN < IPC_GET_ADDR_LEN(*call)) ?
+		    IPC_GET_ADDR_LEN(*call) : DEFAULT_ADDR_LEN),
+		    DEFAULT_PREFIX + IPC_GET_PREFIX(*call),
+		    IPC_GET_CONTENT(*call),
+		    DEFAULT_SUFFIX + IPC_GET_SUFFIX(*call));
 		if (!packet)
 			return ENOMEM;
@@ -356,5 +356,5 @@
 	
 	case NET_PACKET_GET:
-		packet = pm_find(IPC_GET_ID(call));
+		packet = pm_find(IPC_GET_ID(*call));
 		if (!packet_is_valid(packet))
 			return ENOENT;
@@ -362,5 +362,5 @@
 	
 	case NET_PACKET_GET_SIZE:
-		packet = pm_find(IPC_GET_ID(call));
+		packet = pm_find(IPC_GET_ID(*call));
 		if (!packet_is_valid(packet))
 			return ENOENT;
@@ -370,5 +370,5 @@
 	
 	case NET_PACKET_RELEASE:
-		return packet_release_wrapper(IPC_GET_ID(call));
+		return packet_release_wrapper(IPC_GET_ID(*call));
 	}
 	
Index: uspace/lib/packet/include/packet_server.h
===================================================================
--- uspace/lib/packet/include/packet_server.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/packet/include/packet_server.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -48,5 +48,5 @@
 
 extern int packet_server_message(ipc_callid_t, ipc_call_t *, ipc_call_t *,
-    int *);
+    size_t *);
 
 #endif
Index: uspace/lib/usb/include/usb/devreq.h
===================================================================
--- uspace/lib/usb/include/usb/devreq.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/usb/include/usb/devreq.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -85,5 +85,14 @@
 } __attribute__ ((packed)) usb_device_request_setup_packet_t;
 
+
+int usb_drv_req_get_status(int, usb_address_t, usb_request_recipient_t,
+    uint16_t, uint16_t *);
+int usb_drv_req_clear_feature(int, usb_address_t, usb_request_recipient_t,
+    uint16_t, uint16_t);
+int usb_drv_req_set_feature(int, usb_address_t, usb_request_recipient_t,
+    uint16_t, uint16_t);
 int usb_drv_req_set_address(int, usb_address_t, usb_address_t);
+int usb_drv_req_get_descriptor(int, usb_address_t, usb_request_type_t,
+    uint8_t, uint8_t, uint16_t, void *, size_t, size_t *);
 int usb_drv_req_get_device_descriptor(int, usb_address_t,
     usb_standard_device_descriptor_t *);
@@ -92,5 +101,10 @@
 int usb_drv_req_get_full_configuration_descriptor(int, usb_address_t, int,
     void *, size_t, size_t *);
-
+int usb_drv_req_set_descriptor(int, usb_address_t, uint8_t, uint8_t, uint16_t,
+    void *, size_t);
+int usb_drv_req_get_configuration(int, usb_address_t, uint8_t *);
+int usb_drv_req_set_configuration(int, usb_address_t, uint8_t);
+int usb_drv_req_get_interface(int, usb_address_t, uint16_t, uint8_t *);
+int usb_drv_req_set_interface(int, usb_address_t, uint16_t, uint8_t);
 
 #endif
Index: uspace/lib/usb/include/usb/usb.h
===================================================================
--- uspace/lib/usb/include/usb/usb.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/usb/include/usb/usb.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -54,4 +54,18 @@
 	USB_DIRECTION_OUT
 } usb_direction_t;
+
+/** USB request type target. */
+typedef enum {
+	USB_REQUEST_TYPE_STANDARD = 0,
+	USB_REQUEST_TYPE_CLASS = 1,
+	USB_REQUEST_TYPE_VENDOR = 2
+} usb_request_type_t;
+
+/** USB request recipient. */
+typedef enum {
+	USB_REQUEST_RECIPIENT_DEVICE = 0,
+	USB_REQUEST_RECIPIENT_INTERFACE = 1,
+	USB_REQUEST_RECIPIENT_ENDPOINT = 2
+} usb_request_recipient_t;
 
 /** USB transaction outcome. */
Index: uspace/lib/usb/include/usb/usbdrv.h
===================================================================
--- uspace/lib/usb/include/usb/usbdrv.h	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/usb/include/usb/usbdrv.h	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -96,4 +96,9 @@
 int usb_drv_async_wait_for(usb_handle_t);
 
+int usb_drv_create_match_ids_from_device_descriptor(match_id_list_t *,
+    const usb_standard_device_descriptor_t *);
+int usb_drv_create_match_ids_from_configuration_descriptor(match_id_list_t *,
+    const void *, size_t);
+
 int usb_drv_create_device_match_ids(int, match_id_list_t *, usb_address_t);
 int usb_drv_register_child_in_devman(int, device_t *, usb_address_t,
Index: uspace/lib/usb/src/addrkeep.c
===================================================================
--- uspace/lib/usb/src/addrkeep.c	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/usb/src/addrkeep.c	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -187,4 +187,8 @@
 		new_address_position = addresses->used_addresses.next;
 	} else {
+		usb_address_keeping_used_t *first
+		    = used_address_get_instance(addresses->used_addresses.next);
+		previous_address = first->address;
+		
 		for_all_used_addresses(new_address_position, addresses) {
 			usb_address_keeping_used_t *info
@@ -194,4 +198,5 @@
 				break;
 			}
+			previous_address = info->address;
 		}
 
Index: uspace/lib/usb/src/recognise.c
===================================================================
--- uspace/lib/usb/src/recognise.c	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/usb/src/recognise.c	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -129,4 +129,103 @@
 }
 
+/** Create DDF match ids from USB device descriptor.
+ *
+ * @param matches List of match ids to extend.
+ * @param device_descriptor Device descriptor returned by given device.
+ * @return Error code.
+ */
+int usb_drv_create_match_ids_from_device_descriptor(
+    match_id_list_t *matches,
+    const usb_standard_device_descriptor_t *device_descriptor)
+{
+	int rc;
+	
+	/*
+	 * Unless the vendor id is 0, the pair idVendor-idProduct
+	 * quite uniquely describes the device.
+	 */
+	if (device_descriptor->vendor_id != 0) {
+		/* First, with release number. */
+		rc = usb_add_match_id(matches, 100,
+		    "usb&vendor=%d&product=%d&release=" BCD_FMT,
+		    (int) device_descriptor->vendor_id,
+		    (int) device_descriptor->product_id,
+		    BCD_ARGS(device_descriptor->device_version));
+		if (rc != EOK) {
+			return rc;
+		}
+		
+		/* Next, without release number. */
+		rc = usb_add_match_id(matches, 90, "usb&vendor=%d&product=%d",
+		    (int) device_descriptor->vendor_id,
+		    (int) device_descriptor->product_id);
+		if (rc != EOK) {
+			return rc;
+		}
+	}	
+
+	/*
+	 * If the device class points to interface we skip adding
+	 * class directly.
+	 */
+	if (device_descriptor->device_class != USB_CLASS_USE_INTERFACE) {
+		rc = usb_add_match_id(matches, 50, "usb&class=%s",
+		    usb_str_class(device_descriptor->device_class));
+		if (rc != EOK) {
+			return rc;
+		}
+	}
+	
+	return EOK;
+}
+
+/** Create DDF match ids from USB configuration descriptor.
+ * The configuration descriptor is expected to be in the complete form,
+ * i.e. including interface, endpoint etc. descriptors.
+ *
+ * @param matches List of match ids to extend.
+ * @param config_descriptor Configuration descriptor returned by given device.
+ * @param total_size Size of the @p config_descriptor.
+ * @return Error code.
+ */
+int usb_drv_create_match_ids_from_configuration_descriptor(
+    match_id_list_t *matches,
+    const void *config_descriptor, size_t total_size)
+{
+	/*
+	 * Iterate through config descriptor to find the interface
+	 * descriptors.
+	 */
+	size_t position = sizeof(usb_standard_configuration_descriptor_t);
+	while (position + 1 < total_size) {
+		uint8_t *current_descriptor
+		    = ((uint8_t *) config_descriptor) + position;
+		uint8_t cur_descr_len = current_descriptor[0];
+		uint8_t cur_descr_type = current_descriptor[1];
+		
+		position += cur_descr_len;
+		
+		if (cur_descr_type != USB_DESCTYPE_INTERFACE) {
+			continue;
+		}
+		
+		/*
+		 * Finally, we found an interface descriptor.
+		 */
+		usb_standard_interface_descriptor_t *interface
+		    = (usb_standard_interface_descriptor_t *)
+		    current_descriptor;
+		
+		int rc = usb_add_match_id(matches, 50,
+		    "usb&interface&class=%s",
+		    usb_str_class(interface->interface_class));
+		if (rc != EOK) {
+			return rc;
+		}
+	}
+	
+	return EOK;
+}
+
 /** Add match ids based on configuration descriptor.
  *
@@ -169,36 +268,13 @@
 			continue;
 		}
-
-		/*
-		 * Iterate through config descriptor to find the interface
-		 * descriptors.
-		 */
-		size_t position = sizeof(config_descriptor);
-		while (position + 1 < full_config_descriptor_size) {
-			uint8_t *current_descriptor
-			    = ((uint8_t *) full_config_descriptor) + position;
-			uint8_t cur_descr_len = current_descriptor[0];
-			uint8_t cur_descr_type = current_descriptor[1];
-			
-			position += cur_descr_len;
-			
-			if (cur_descr_type != USB_DESCTYPE_INTERFACE) {
-				continue;
-			}
-			/*
-			 * Finally, we found an interface descriptor.
-			 */
-			usb_standard_interface_descriptor_t *interface
-			    = (usb_standard_interface_descriptor_t *)
-			    current_descriptor;
-			
-			rc = usb_add_match_id(matches, 50,
-			    "usb&interface&class=%s",
-			    usb_str_class(interface->interface_class));
-			if (rc != EOK) {
-				final_rc = rc;
-				break;
-			}
-		}
+		
+		rc = usb_drv_create_match_ids_from_configuration_descriptor(
+		    matches,
+		    full_config_descriptor, full_config_descriptor_size);
+		if (rc != EOK) {
+			final_rc = rc;
+			continue;
+		}
+		
 	}
 	
@@ -220,4 +296,8 @@
 {
 	int rc;
+	
+	/*
+	 * Retrieve device descriptor and add matches from it.
+	 */
 	usb_standard_device_descriptor_t device_descriptor;
 
@@ -227,41 +307,11 @@
 		return rc;
 	}
-
-	/*
-	 * Unless the vendor id is 0, the pair idVendor-idProduct
-	 * quite uniquely describes the device.
-	 */
-	if (device_descriptor.vendor_id != 0) {
-		/* First, with release number. */
-		rc = usb_add_match_id(matches, 100,
-		    "usb&vendor=%d&product=%d&release=" BCD_FMT,
-		    (int) device_descriptor.vendor_id,
-		    (int) device_descriptor.product_id,
-		    BCD_ARGS(device_descriptor.device_version));
-		if (rc != EOK) {
-			return rc;
-		}
-		
-		/* Next, without release number. */
-		rc = usb_add_match_id(matches, 90, "usb&vendor=%d&product=%d",
-		    (int) device_descriptor.vendor_id,
-		    (int) device_descriptor.product_id);
-		if (rc != EOK) {
-			return rc;
-		}
-
-	}	
-
-	/*
-	 * If the device class points to interface we skip adding
-	 * class directly.
-	 */
-	if (device_descriptor.device_class != USB_CLASS_USE_INTERFACE) {
-		rc = usb_add_match_id(matches, 50, "usb&class=%s",
-		    usb_str_class(device_descriptor.device_class));
-		if (rc != EOK) {
-			return rc;
-		}
-	}
+	
+	rc = usb_drv_create_match_ids_from_device_descriptor(matches,
+	    &device_descriptor);
+	if (rc != EOK) {
+		return rc;
+	}
+	
 	/*
 	 * Go through all configurations and add matches
Index: uspace/lib/usb/src/usbdrvreq.c
===================================================================
--- uspace/lib/usb/src/usbdrvreq.c	(revision 6986418a911da2a0d9bbcff0c77f11874afbefb6)
+++ uspace/lib/usb/src/usbdrvreq.c	(revision f40131243ad1635ce6cd59eaf5a91902710c0306)
@@ -36,4 +36,146 @@
 #include <errno.h>
 
+/**  Prepare USB target for control endpoint.
+ *
+ * @param name Variable name with the USB target.
+ * @param target_address Target USB address.
+ */
+#define PREPARE_TARGET(name, target_address) \
+	usb_target_t name = { \
+		.address = target_address, \
+		.endpoint = 0 \
+	}
+
+/** Prepare setup packet.
+ *
+ * @param name Variable name with the setup packet.
+ * @param p_direction Data transfer direction.
+ * @param p_type Request type (standard/class/vendor)
+ * @param p_recipient Recipient of the request.
+ * @param p_request Request.
+ * @param p_value wValue field of setup packet.
+ * @param p_index wIndex field of setup packet.
+ * @param p_length Length of extra data.
+ */
+#define PREPARE_SETUP_PACKET(name, p_direction, p_type, p_recipient, \
+    p_request, p_value, p_index, p_length) \
+	usb_device_request_setup_packet_t setup_packet = { \
+		.request_type = \
+			((p_direction) == USB_DIRECTION_IN ? 128 : 0) \
+			| ((p_type) << 5) \
+			| (p_recipient), \
+		.request = (p_request), \
+		{ .value = (p_value) }, \
+		.index = (p_index), \
+		.length = (p_length) \
+	}
+
+/** Prepare setup packet.
+ *
+ * @param name Variable name with the setup packet.
+ * @param p_direction Data transfer direction.
+ * @param p_type Request type (standard/class/vendor)
+ * @param p_recipient Recipient of the request.
+ * @param p_request Request.
+ * @param p_value_low wValue field of setup packet (low byte).
+ * @param p_value_high wValue field of setup packet (high byte).
+ * @param p_index wIndex field of setup packet.
+ * @param p_length Length of extra data.
+ */
+#define PREPARE_SETUP_PACKET_LOHI(name, p_direction, p_type, p_recipient, \
+    p_request, p_value_low, p_value_high, p_index, p_length) \
+	PREPARE_SETUP_PACKET(name, p_direction, p_type, p_recipient, \
+	    p_request, (p_value_low) | ((p_value_high) << 8), \
+	    p_index, p_length)
+
+/** Retrieve status of a USB device.
+ *
+ * @param[in] hc_phone Open phone to HC driver.
+ * @param[in] address Device address.
+ * @param[in] recipient Recipient of the request.
+ * @param[in] recipient_index Index of @p recipient.
+ * @param[out] status Status (see figure 9-4 in USB 1.1 specification).
+ * @return Error code.
+ */
+int usb_drv_req_get_status(int hc_phone, usb_address_t address,
+    usb_request_recipient_t recipient, uint16_t recipient_index,
+    uint16_t *status)
+{
+	if (status == NULL) {
+		return EBADMEM;
+	}
+
+	PREPARE_TARGET(target, address);
+
+	PREPARE_SETUP_PACKET(setup_packet,
+	    USB_DIRECTION_IN, USB_REQUEST_TYPE_STANDARD,
+	    recipient, USB_DEVREQ_GET_STATUS, 0, recipient_index, 2);
+
+	size_t transfered;
+	uint16_t tmp_status;
+	int rc = usb_drv_psync_control_read(hc_phone, target,
+	    &setup_packet, sizeof(setup_packet), &tmp_status, 2, &transfered);
+	if (rc != EOK) {
+		return rc;
+	}
+	if (transfered != 2) {
+		return ERANGE;
+	}
+
+	*status = tmp_status;
+
+	return EOK;
+}
+
+/** Clear or disable USB device feature.
+ *
+ * @param[in] hc_phone Open phone to HC driver.
+ * @param[in] address Device address.
+ * @param[in] recipient Recipient of the request.
+ * @param[in] selector Feature selector.
+ * @param[in] index Index of @p recipient.
+ * @return Error code.
+ */
+int usb_drv_req_clear_feature(int hc_phone, usb_address_t address,
+    usb_request_recipient_t recipient,
+    uint16_t selector, uint16_t index)
+{
+	PREPARE_TARGET(target, address);
+
+	PREPARE_SETUP_PACKET(setup_packet,
+	    USB_DIRECTION_OUT, USB_REQUEST_TYPE_STANDARD,
+	    recipient, USB_DEVREQ_CLEAR_FEATURE, selector, index, 0);
+
+	int rc = usb_drv_psync_control_write(hc_phone, target,
+	    &setup_packet, sizeof(setup_packet), NULL, 0);
+
+	return rc;
+}
+
+/** Set or enable USB device feature.
+ *
+ * @param[in] hc_phone Open phone to HC driver.
+ * @param[in] address Device address.
+ * @param[in] recipient Recipient of the request.
+ * @param[in] selector Feature selector.
+ * @param[in] index Index of @p recipient.
+ * @return Error code.
+ */
+int usb_drv_req_set_feature(int hc_phone, usb_address_t address,
+    usb_request_recipient_t recipient,
+    uint16_t selector, uint16_t index)
+{
+	PREPARE_TARGET(target, address);
+
+	PREPARE_SETUP_PACKET(setup_packet,
+	    USB_DIRECTION_OUT, USB_REQUEST_TYPE_STANDARD,
+	    recipient, USB_DEVREQ_SET_FEATURE, selector, index, 0);
+
+	int rc = usb_drv_psync_control_write(hc_phone, target,
+	    &setup_packet, sizeof(setup_packet), NULL, 0);
+
+	return rc;
+}
+
 /** Change address of connected device.
  *
@@ -44,7 +186,7 @@
  * @see usb_drv_bind_address
  *
- * @param phone Open phone to HC driver.
- * @param old_address Current address.
- * @param address Address to be set.
+ * @param[in] phone Open phone to HC driver.
+ * @param[in] old_address Current address.
+ * @param[in] address Address to be set.
  * @return Error code.
  */
@@ -52,18 +194,9 @@
     usb_address_t new_address)
 {
-	/* Prepare the target. */
-	usb_target_t target = {
-		.address = old_address,
-		.endpoint = 0
-	};
-
-	/* Prepare the setup packet. */
-	usb_device_request_setup_packet_t setup_packet = {
-		.request_type = 0,
-		.request = USB_DEVREQ_SET_ADDRESS,
-		.index = 0,
-		.length = 0,
-	};
-	setup_packet.value = new_address;
+	PREPARE_TARGET(target, old_address);
+
+	PREPARE_SETUP_PACKET(setup_packet, USB_DIRECTION_OUT,
+	    USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_DEVICE,
+	    USB_DEVREQ_SET_ADDRESS, new_address, 0, 0);
 
 	int rc = usb_drv_psync_control_write(phone, target,
@@ -73,8 +206,50 @@
 }
 
+/** Retrieve USB descriptor of connected USB device.
+ *
+ * @param[in] hc_phone Open phone to HC driver.
+ * @param[in] address Device address.
+ * @param[in] request_type Request type (standard/class/vendor).
+ * @param[in] descriptor_type Descriptor type (device/configuration/HID/...).
+ * @param[in] descriptor_index Descriptor index.
+ * @param[in] language Language index.
+ * @param[out] buffer Buffer where to store the retrieved descriptor.
+ * @param[in] size Size of the @p buffer.
+ * @param[out] actual_size Number of bytes actually transferred.
+ * @return Error code.
+ */
+int usb_drv_req_get_descriptor(int hc_phone, usb_address_t address,
+    usb_request_type_t request_type,
+    uint8_t descriptor_type, uint8_t descriptor_index,
+    uint16_t language,
+    void *buffer, size_t size, size_t *actual_size)
+{
+	if (buffer == NULL) {
+		return EBADMEM;
+	}
+	if (size == 0) {
+		return EINVAL;
+	}
+
+	// FIXME: check that size is not too big
+
+	PREPARE_TARGET(target, address);
+
+	PREPARE_SETUP_PACKET_LOHI(setup_packet, USB_DIRECTION_IN,
+	    request_type, USB_REQUEST_RECIPIENT_DEVICE,
+	    USB_DEVREQ_GET_DESCRIPTOR, descriptor_index, descriptor_type,
+	    language, size);
+
+	int rc = usb_drv_psync_control_read(hc_phone, target,
+	    &setup_packet, sizeof(setup_packet),
+	    buffer, size, actual_size);
+	
+	return rc;
+}
+
 /** Retrieve device descriptor of connected USB device.
  *
  * @param[in] phone Open phone to HC driver.
- * @param[in] address Device USB address.
+ * @param[in] address Device address.
  * @param[out] descriptor Storage for the device descriptor.
  * @return Error code.
@@ -87,29 +262,13 @@
 		return EBADMEM;
 	}
-
-	/* Prepare the target. */
-	usb_target_t target = {
-		.address = address,
-		.endpoint = 0
-	};
-
-	/* Prepare the setup packet. */
-	usb_device_request_setup_packet_t setup_packet = {
-		.request_type = 128,
-		.request = USB_DEVREQ_GET_DESCRIPTOR,
-		.index = 0,
-		.length = sizeof(usb_standard_device_descriptor_t)
-	};
-	setup_packet.value_high = USB_DESCTYPE_DEVICE;
-	setup_packet.value_low = 0;
-
-	/* Prepare local descriptor. */
+	
 	size_t actually_transferred = 0;
 	usb_standard_device_descriptor_t descriptor_tmp;
-
-	/* Perform the control read transaction. */
-	int rc = usb_drv_psync_control_read(phone, target,
-	    &setup_packet, sizeof(setup_packet),
-	    &descriptor_tmp, sizeof(descriptor_tmp), &actually_transferred);
+	int rc = usb_drv_req_get_descriptor(phone, address,
+	    USB_REQUEST_TYPE_STANDARD,
+	    USB_DESCTYPE_DEVICE, 0,
+	    0,
+	    &descriptor_tmp, sizeof(descriptor_tmp),
+	    &actually_transferred);
 
 	if (rc != EOK) {
@@ -137,5 +296,5 @@
  *
  * @param[in] phone Open phone to HC driver.
- * @param[in] address Device USB address.
+ * @param[in] address Device address.
  * @param[in] index Configuration descriptor index.
  * @param[out] descriptor Storage for the configuration descriptor.
@@ -150,29 +309,13 @@
 		return EBADMEM;
 	}
-
-	/* Prepare the target. */
-	usb_target_t target = {
-		.address = address,
-		.endpoint = 0
-	};
-
-	/* Prepare the setup packet. */
-	usb_device_request_setup_packet_t setup_packet = {
-		.request_type = 128,
-		.request = USB_DEVREQ_GET_DESCRIPTOR,
-		.index = 0,
-		.length = sizeof(usb_standard_configuration_descriptor_t)
-	};
-	setup_packet.value_high = USB_DESCTYPE_CONFIGURATION;
-	setup_packet.value_low = index;
-
-	/* Prepare local descriptor. */
+	
 	size_t actually_transferred = 0;
 	usb_standard_configuration_descriptor_t descriptor_tmp;
-
-	/* Perform the control read transaction. */
-	int rc = usb_drv_psync_control_read(phone, target,
-	    &setup_packet, sizeof(setup_packet),
-	    &descriptor_tmp, sizeof(descriptor_tmp), &actually_transferred);
+	int rc = usb_drv_req_get_descriptor(phone, address,
+	    USB_REQUEST_TYPE_STANDARD,
+	    USB_DESCTYPE_CONFIGURATION, 0,
+	    0,
+	    &descriptor_tmp, sizeof(descriptor_tmp),
+	    &actually_transferred);
 
 	if (rc != EOK) {
@@ -195,8 +338,8 @@
  *
  * @warning The @p buffer might be touched (i.e. its contents changed)
- * even when error occurres.
+ * even when error occurs.
  *
  * @param[in] phone Open phone to HC driver.
- * @param[in] address Device USB address.
+ * @param[in] address Device address.
  * @param[in] index Configuration descriptor index.
  * @param[out] buffer Buffer for the whole configuration descriptor.
@@ -210,32 +353,169 @@
     void *buffer, size_t buffer_size, size_t *actual_buffer_size)
 {
-	if (buffer == NULL) {
+	int rc = usb_drv_req_get_descriptor(phone, address,
+	    USB_REQUEST_TYPE_STANDARD,
+	    USB_DESCTYPE_CONFIGURATION, 0,
+	    0,
+	    buffer, buffer_size,
+	    actual_buffer_size);
+
+	return rc;
+}
+
+/** Update existing descriptor of a USB device.
+ *
+ * @param[in] hc_phone Open phone to HC driver.
+ * @param[in] address Device address.
+ * @param[in] descriptor_type Descriptor type (device/configuration/...).
+ * @param[in] descriptor_index Descriptor index.
+ * @param[in] language Language index.
+ * @param[in] descriptor Actual descriptor data.
+ * @param[in] descriptor_size Descriptor size.
+ * @return Error code.
+ */
+int usb_drv_req_set_descriptor(int hc_phone, usb_address_t address,
+    uint8_t descriptor_type, uint8_t descriptor_index,
+    uint16_t language,
+    void *descriptor, size_t descriptor_size)
+{
+	// FIXME: check that descriptor is not too big
+
+	PREPARE_TARGET(target, address);
+
+	PREPARE_SETUP_PACKET_LOHI(setup_packet, USB_DIRECTION_OUT,
+	    USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_DEVICE,
+	    USB_DEVREQ_SET_DESCRIPTOR, descriptor_index, descriptor_type,
+	    language, descriptor_size);
+
+	int rc = usb_drv_psync_control_write(hc_phone, target,
+	    &setup_packet, sizeof(setup_packet),
+	    descriptor, descriptor_size);
+
+	return rc;
+}
+
+/** Determine current configuration value of USB device.
+ *
+ * @param[in] hc_phone Open phone to HC driver.
+ * @param[in] address Device address.
+ * @param[out] configuration_value Current configuration value.
+ * @return Error code.
+ */
+int usb_drv_req_get_configuration(int hc_phone, usb_address_t address,
+    uint8_t *configuration_value)
+{
+	if (configuration_value == NULL) {
 		return EBADMEM;
 	}
 
-	/* Prepare the target. */
-	usb_target_t target = {
-		.address = address,
-		.endpoint = 0
-	};
-
-	/* Prepare the setup packet. */
-	usb_device_request_setup_packet_t setup_packet = {
-		.request_type = 128,
-		.request = USB_DEVREQ_GET_DESCRIPTOR,
-		.index = 0,
-		.length = buffer_size
-	};
-	setup_packet.value_high = USB_DESCTYPE_CONFIGURATION;
-	setup_packet.value_low = index;
-
-	/* Perform the control read transaction. */
-	int rc = usb_drv_psync_control_read(phone, target,
-	    &setup_packet, sizeof(setup_packet),
-	    buffer, buffer_size, actual_buffer_size);
-
-	return rc;
-}
-
+	PREPARE_TARGET(target, address);
+
+	PREPARE_SETUP_PACKET(setup_packet, USB_DIRECTION_IN,
+	    USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_DEVICE,
+	    USB_DEVREQ_GET_CONFIGURATION, 0, 0, 1);
+
+	uint8_t value;
+	size_t transfered;
+	int rc = usb_drv_psync_control_read(hc_phone, target,
+	    &setup_packet, sizeof(setup_packet), &value, 1, &transfered);
+
+	if (rc != EOK) {
+		return rc;
+	}
+
+	if (transfered != 1) {
+		return ERANGE;
+	}
+
+	*configuration_value = value;
+
+	return EOK;
+}
+
+/** Set configuration of USB device.
+ *
+ * @param[in] hc_phone Open phone to HC driver.
+ * @param[in] address Device address.
+ * @param[in] configuration_value New configuration value.
+ * @return Error code.
+ */
+int usb_drv_req_set_configuration(int hc_phone, usb_address_t address,
+    uint8_t configuration_value)
+{
+	PREPARE_TARGET(target, address);
+
+	PREPARE_SETUP_PACKET_LOHI(setup_packet, USB_DIRECTION_OUT,
+	    USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_DEVICE,
+	    USB_DEVREQ_SET_CONFIGURATION, configuration_value, 0,
+	    0, 0);
+
+	int rc = usb_drv_psync_control_write(hc_phone, target,
+	    &setup_packet, sizeof(setup_packet), NULL, 0);
+
+	return rc;
+}
+
+/** Determine alternate setting of USB device interface.
+ *
+ * @param[in] hc_phone Open phone to HC driver.
+ * @param[in] address Device address.
+ * @param[in] interface_index Interface index.
+ * @param[out] alternate_setting Value of alternate setting.
+ * @return Error code.
+ */
+int usb_drv_req_get_interface(int hc_phone, usb_address_t address,
+    uint16_t interface_index, uint8_t *alternate_setting)
+{
+	if (alternate_setting == NULL) {
+		return EBADMEM;
+	}
+
+	PREPARE_TARGET(target, address);
+
+	PREPARE_SETUP_PACKET(setup_packet, USB_DIRECTION_IN,
+	    USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_INTERFACE,
+	    USB_DEVREQ_GET_INTERFACE, 0, interface_index, 1);
+
+	uint8_t alternate;
+	size_t transfered;
+	int rc = usb_drv_psync_control_read(hc_phone, target,
+	    &setup_packet, sizeof(setup_packet), &alternate, 1, &transfered);
+
+	if (rc != EOK) {
+		return rc;
+	}
+
+	if (transfered != 1) {
+		return ERANGE;
+	}
+
+	*alternate_setting = alternate;
+
+	return EOK;
+}
+
+/** Select an alternate setting of USB device interface.
+ *
+ * @param[in] hc_phone Open phone to HC driver.
+ * @param[in] address Device address.
+ * @param[in] interface_index Interface index.
+ * @param[in] alternate_setting Value of alternate setting.
+ * @return Error code.
+ */
+int usb_drv_req_set_interface(int hc_phone, usb_address_t address,
+    uint16_t interface_index, uint8_t alternate_setting)
+{
+	PREPARE_TARGET(target, address);
+
+	PREPARE_SETUP_PACKET_LOHI(setup_packet, USB_DIRECTION_OUT,
+	    USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_INTERFACE,
+	    USB_DEVREQ_SET_INTERFACE, alternate_setting, 0,
+	    0, 0);
+
+	int rc = usb_drv_psync_control_write(hc_phone, target,
+	    &setup_packet, sizeof(setup_packet), NULL, 0);
+
+	return rc;
+}
 
 /**
