Index: uspace/Makefile.common
===================================================================
--- uspace/Makefile.common	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/Makefile.common	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -220,2 +220,8 @@
 	makedepend -f - -- $(DEPEND_DEFS) $(CFLAGS) -- $(SOURCES) > $@ 2> /dev/null
 	-[ -f $(DEPEND_PREV) ] && diff -q $(DEPEND_PREV) $@ && mv -f $(DEPEND_PREV) $@
+
+##
+# This explicit dependecy of the output binary on the object files seems to be
+# necessary to prevent parallel build failures (GNU make bug #26893 ???).
+$(OUTPUT): $(OBJECTS)
+
Index: uspace/app/taskdump/taskdump.c
===================================================================
--- uspace/app/taskdump/taskdump.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/app/taskdump/taskdump.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -406,4 +406,17 @@
 	}
 
+	rc = asprintf(&file_name, "/drv/%s/%s", app_name, app_name);
+	if (rc < 0) {
+		printf("Memory allocation failure.\n");
+		exit(1);
+	}
+
+	rc = symtab_load(file_name, &app_symtab);
+	if (rc == EOK) {
+		printf("Loaded symbol table from %s\n", file_name);
+		free(file_name);
+		return;
+	}
+
 	free(file_name);
 	printf("Failed autoloading symbol table.\n");
Index: uspace/app/tester/hw/misc/virtchar1.c
===================================================================
--- uspace/app/tester/hw/misc/virtchar1.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/app/tester/hw/misc/virtchar1.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -47,5 +47,5 @@
 #include "../../tester.h"
 
-#define DEVICE_PATH_NORMAL "/dev/devices/\\virt\\null"
+#define DEVICE_PATH_NORMAL "/dev/devices/\\virt\\null\\a"
 #define DEVICE_PATH_CLASSES "/dev/class/virt-null\\1"
 #define BUFFER_SIZE 64
Index: uspace/app/tester/hw/serial/serial1.c
===================================================================
--- uspace/app/tester/hw/serial/serial1.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/app/tester/hw/serial/serial1.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -74,5 +74,5 @@
 	
 	devman_handle_t handle;
-	res = devman_device_get_handle("/hw/pci0/00:01.0/com1", &handle,
+	res = devman_device_get_handle("/hw/pci0/00:01.0/com1/a", &handle,
 	    IPC_FLAG_BLOCKING);
 	if (res != EOK)
Index: uspace/drv/isa/isa.c
===================================================================
--- uspace/drv/isa/isa.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/isa/isa.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -1,4 +1,5 @@
 /*
  * Copyright (c) 2010 Lenka Trochtova
+ * Copyright (c) 2011 Jiri Svoboda
  * All rights reserved.
  *
@@ -43,4 +44,5 @@
 #include <stdlib.h>
 #include <str.h>
+#include <str_error.h>
 #include <ctype.h>
 #include <macros.h>
@@ -50,5 +52,5 @@
 #include <sys/stat.h>
 
-#include <driver.h>
+#include <ddf/driver.h>
 #include <ops/hw_res.h>
 
@@ -58,24 +60,25 @@
 
 #define NAME "isa"
-#define CHILD_DEV_CONF_PATH "/drv/isa/isa.dev"
+#define CHILD_FUN_CONF_PATH "/drv/isa/isa.dev"
+
+/** Obtain soft-state pointer from function node pointer */
+#define ISA_FUN(fnode) ((isa_fun_t *) ((fnode)->driver_data))
 
 #define ISA_MAX_HW_RES 4
 
-typedef struct isa_child_data {
+typedef struct isa_fun {
+	ddf_fun_t *fnode;
 	hw_resource_list_t hw_resources;
-} isa_child_data_t;
-
-static hw_resource_list_t *isa_get_child_resources(device_t *dev)
-{
-	isa_child_data_t *dev_data;
-
-	dev_data = (isa_child_data_t *)dev->driver_data;
-	if (dev_data == NULL)
-		return NULL;
-
-	return &dev_data->hw_resources;
-}
-
-static bool isa_enable_child_interrupt(device_t *dev)
+} isa_fun_t;
+
+static hw_resource_list_t *isa_get_fun_resources(ddf_fun_t *fnode)
+{
+	isa_fun_t *fun = ISA_FUN(fnode);
+	assert(fun != NULL);
+
+	return &fun->hw_resources;
+}
+
+static bool isa_enable_fun_interrupt(ddf_fun_t *fnode)
 {
 	// TODO
@@ -84,12 +87,12 @@
 }
 
-static hw_res_ops_t isa_child_hw_res_ops = {
-	&isa_get_child_resources,
-	&isa_enable_child_interrupt
+static hw_res_ops_t isa_fun_hw_res_ops = {
+	&isa_get_fun_resources,
+	&isa_enable_fun_interrupt
 };
 
-static device_ops_t isa_child_dev_ops;
-
-static int isa_add_device(device_t *dev);
+static ddf_dev_ops_t isa_fun_ops;
+
+static int isa_add_device(ddf_dev_t *dev);
 
 /** The isa device driver's standard operations */
@@ -104,33 +107,22 @@
 };
 
-
-static isa_child_data_t *create_isa_child_data() 
-{
-	isa_child_data_t *data;
-
-	data = (isa_child_data_t *) malloc(sizeof(isa_child_data_t));
-	if (data != NULL)
-		memset(data, 0, sizeof(isa_child_data_t));
-
-	return data;
-}
-
-static device_t *create_isa_child_dev()
-{
-	device_t *dev = create_device();
-	if (dev == NULL)
+static isa_fun_t *isa_fun_create(ddf_dev_t *dev, const char *name)
+{
+	isa_fun_t *fun = calloc(1, sizeof(isa_fun_t));
+	if (fun == NULL)
 		return NULL;
 
-	isa_child_data_t *data = create_isa_child_data();
-	if (data == NULL) {
-		delete_device(dev);
+	ddf_fun_t *fnode = ddf_fun_create(dev, fun_inner, name);
+	if (fnode == NULL) {
+		free(fun);
 		return NULL;
 	}
 
-	dev->driver_data = data;
-	return dev;
-}
-
-static char *read_dev_conf(const char *conf_path)
+	fun->fnode = fnode;
+	fnode->driver_data = fun;
+	return fun;
+}
+
+static char *fun_conf_read(const char *conf_path)
 {
 	bool suc = false;
@@ -151,5 +143,5 @@
 	lseek(fd, 0, SEEK_SET);	
 	if (len == 0) {
-		printf(NAME ": read_dev_conf error: configuration file '%s' "
+		printf(NAME ": fun_conf_read error: configuration file '%s' "
 		    "is empty.\n", conf_path);
 		goto cleanup;
@@ -158,10 +150,10 @@
 	buf = malloc(len + 1);
 	if (buf == NULL) {
-		printf(NAME ": read_dev_conf error: memory allocation failed.\n");
+		printf(NAME ": fun_conf_read error: memory allocation failed.\n");
 		goto cleanup;
 	}
 
 	if (0 >= read(fd, buf, len)) {
-		printf(NAME ": read_dev_conf error: unable to read file '%s'.\n",
+		printf(NAME ": fun_conf_read error: unable to read file '%s'.\n",
 		    conf_path);
 		goto cleanup;
@@ -249,10 +241,8 @@
 }
 
-static void isa_child_set_irq(device_t *dev, int irq)
-{
-	isa_child_data_t *data = (isa_child_data_t *)dev->driver_data;
-
-	size_t count = data->hw_resources.count;
-	hw_resource_t *resources = data->hw_resources.resources;
+static void isa_fun_set_irq(isa_fun_t *fun, int irq)
+{
+	size_t count = fun->hw_resources.count;
+	hw_resource_t *resources = fun->hw_resources.resources;
 
 	if (count < ISA_MAX_HW_RES) {
@@ -260,16 +250,15 @@
 		resources[count].res.interrupt.irq = irq;
 
-		data->hw_resources.count++;
-
-		printf(NAME ": added irq 0x%x to device %s\n", irq, dev->name);
-	}
-}
-
-static void isa_child_set_io_range(device_t *dev, size_t addr, size_t len)
-{
-	isa_child_data_t *data = (isa_child_data_t *)dev->driver_data;
-
-	size_t count = data->hw_resources.count;
-	hw_resource_t *resources = data->hw_resources.resources;
+		fun->hw_resources.count++;
+
+		printf(NAME ": added irq 0x%x to function %s\n", irq,
+		    fun->fnode->name);
+	}
+}
+
+static void isa_fun_set_io_range(isa_fun_t *fun, size_t addr, size_t len)
+{
+	size_t count = fun->hw_resources.count;
+	hw_resource_t *resources = fun->hw_resources.resources;
 
 	if (count < ISA_MAX_HW_RES) {
@@ -279,30 +268,30 @@
 		resources[count].res.io_range.endianness = LITTLE_ENDIAN;
 
-		data->hw_resources.count++;
+		fun->hw_resources.count++;
 
 		printf(NAME ": added io range (addr=0x%x, size=0x%x) to "
-		    "device %s\n", (unsigned int) addr, (unsigned int) len,
-		    dev->name);
-	}
-}
-
-static void get_dev_irq(device_t *dev, char *val)
+		    "function %s\n", (unsigned int) addr, (unsigned int) len,
+		    fun->fnode->name);
+	}
+}
+
+static void fun_parse_irq(isa_fun_t *fun, char *val)
 {
 	int irq = 0;
 	char *end = NULL;
 
-	val = skip_spaces(val);	
+	val = skip_spaces(val);
 	irq = (int)strtol(val, &end, 0x10);
 
 	if (val != end)
-		isa_child_set_irq(dev, irq);
-}
-
-static void get_dev_io_range(device_t *dev, char *val)
+		isa_fun_set_irq(fun, irq);
+}
+
+static void fun_parse_io_range(isa_fun_t *fun, char *val)
 {
 	size_t addr, len;
 	char *end = NULL;
 
-	val = skip_spaces(val);	
+	val = skip_spaces(val);
 	addr = strtol(val, &end, 0x10);
 
@@ -310,5 +299,5 @@
 		return;
 
-	val = skip_spaces(end);	
+	val = skip_spaces(end);
 	len = strtol(val, &end, 0x10);
 
@@ -316,5 +305,5 @@
 		return;
 
-	isa_child_set_io_range(dev, addr, len);
+	isa_fun_set_io_range(fun, addr, len);
 }
 
@@ -331,45 +320,38 @@
 }
 
-static void get_dev_match_id(device_t *dev, char *val)
+static void fun_parse_match_id(isa_fun_t *fun, char *val)
 {
 	char *id = NULL;
 	int score = 0;
 	char *end = NULL;
-
-	val = skip_spaces(val);	
+	int rc;
+
+	val = skip_spaces(val);
 
 	score = (int)strtol(val, &end, 10);
 	if (val == end) {
 		printf(NAME " : error - could not read match score for "
-		    "device %s.\n", dev->name);
+		    "function %s.\n", fun->fnode->name);
 		return;
 	}
 
-	match_id_t *match_id = create_match_id();
-	if (match_id == NULL) {
-		printf(NAME " : failed to allocate match id for device %s.\n",
-		    dev->name);
-		return;
-	}
-
-	val = skip_spaces(end);	
+	val = skip_spaces(end);
 	get_match_id(&id, val);
 	if (id == NULL) {
 		printf(NAME " : error - could not read match id for "
-		    "device %s.\n", dev->name);
-		delete_match_id(match_id);
+		    "function %s.\n", fun->fnode->name);
 		return;
 	}
 
-	match_id->id = id;
-	match_id->score = score;
-
-	printf(NAME ": adding match id '%s' with score %d to device %s\n", id,
-	    score, dev->name);
-	add_match_id(&dev->match_ids, match_id);
-}
-
-static bool read_dev_prop(device_t *dev, char *line, const char *prop,
-    void (*read_fn)(device_t *, char *))
+	printf(NAME ": adding match id '%s' with score %d to function %s\n", id,
+	    score, fun->fnode->name);
+
+	rc = ddf_fun_add_match_id(fun->fnode, id, score);
+	if (rc != EOK)
+		printf(NAME ": error adding match ID: %s\n", str_error(rc));
+}
+
+static bool prop_parse(isa_fun_t *fun, char *line, const char *prop,
+    void (*read_fn)(isa_fun_t *, char *))
 {
 	size_t proplen = str_size(prop);
@@ -378,5 +360,5 @@
 		line += proplen;
 		line = skip_spaces(line);
-		(*read_fn)(dev, line);
+		(*read_fn)(fun, line);
 
 		return true;
@@ -386,12 +368,12 @@
 }
 
-static void get_dev_prop(device_t *dev, char *line)
+static void fun_prop_parse(isa_fun_t *fun, char *line)
 {
 	/* Skip leading spaces. */
 	line = skip_spaces(line);
 
-	if (!read_dev_prop(dev, line, "io_range", &get_dev_io_range) &&
-	    !read_dev_prop(dev, line, "irq", &get_dev_irq) &&
-	    !read_dev_prop(dev, line, "match", &get_dev_match_id))
+	if (!prop_parse(fun, line, "io_range", &fun_parse_io_range) &&
+	    !prop_parse(fun, line, "irq", &fun_parse_irq) &&
+	    !prop_parse(fun, line, "match", &fun_parse_match_id))
 	{
 	    printf(NAME " error undefined device property at line '%s'\n",
@@ -400,19 +382,18 @@
 }
 
-static void child_alloc_hw_res(device_t *dev)
-{
-	isa_child_data_t *data = (isa_child_data_t *)dev->driver_data;
-	data->hw_resources.resources = 
+static void fun_hw_res_alloc(isa_fun_t *fun)
+{
+	fun->hw_resources.resources = 
 	    (hw_resource_t *)malloc(sizeof(hw_resource_t) * ISA_MAX_HW_RES);
 }
 
-static char *read_isa_dev_info(char *dev_conf, device_t *parent)
+static char *isa_fun_read_info(char *fun_conf, ddf_dev_t *dev)
 {
 	char *line;
-	char *dev_name = NULL;
+	char *fun_name = NULL;
 
 	/* Skip empty lines. */
 	while (true) {
-		line = str_get_line(dev_conf, &dev_conf);
+		line = str_get_line(fun_conf, &fun_conf);
 
 		if (line == NULL) {
@@ -426,22 +407,20 @@
 
 	/* Get device name. */
-	dev_name = get_device_name(line);
-	if (dev_name == NULL)
+	fun_name = get_device_name(line);
+	if (fun_name == NULL)
 		return NULL;
 
-	device_t *dev = create_isa_child_dev();
-	if (dev == NULL) {
-		free(dev_name);
+	isa_fun_t *fun = isa_fun_create(dev, fun_name);
+	if (fun == NULL) {
+		free(fun_name);
 		return NULL;
 	}
 
-	dev->name = dev_name;
-
 	/* Allocate buffer for the list of hardware resources of the device. */
-	child_alloc_hw_res(dev);
+	fun_hw_res_alloc(fun);
 
 	/* Get properties of the device (match ids, irq and io range). */
 	while (true) {
-		line = str_get_line(dev_conf, &dev_conf);
+		line = str_get_line(fun_conf, &fun_conf);
 
 		if (line_empty(line)) {
@@ -454,46 +433,58 @@
 		 * and store it in the device structure.
 		 */
-		get_dev_prop(dev, line);
-
-		//printf(NAME ": next line ='%s'\n", dev_conf);
-		//printf(NAME ": current line ='%s'\n", line);
+		fun_prop_parse(fun, line);
 	}
 
 	/* Set device operations to the device. */
-	dev->ops = &isa_child_dev_ops;
-
-	printf(NAME ": child_device_register(dev, parent); device is %s.\n",
-	    dev->name);
-	child_device_register(dev, parent);
-
-	return dev_conf;
-}
-
-static void parse_dev_conf(char *conf, device_t *parent)
+	fun->fnode->ops = &isa_fun_ops;
+
+	printf(NAME ": Binding function %s.\n", fun->fnode->name);
+
+	/* XXX Handle error */
+	(void) ddf_fun_bind(fun->fnode);
+
+	return fun_conf;
+}
+
+static void fun_conf_parse(char *conf, ddf_dev_t *dev)
 {
 	while (conf != NULL && *conf != '\0') {
-		conf = read_isa_dev_info(conf, parent);
-	}
-}
-
-static void add_legacy_children(device_t *parent)
-{
-	char *dev_conf;
-
-	dev_conf = read_dev_conf(CHILD_DEV_CONF_PATH);
-	if (dev_conf != NULL) {
-		parse_dev_conf(dev_conf, parent);
-		free(dev_conf);
-	}
-}
-
-static int isa_add_device(device_t *dev)
+		conf = isa_fun_read_info(conf, dev);
+	}
+}
+
+static void isa_functions_add(ddf_dev_t *dev)
+{
+	char *fun_conf;
+
+	fun_conf = fun_conf_read(CHILD_FUN_CONF_PATH);
+	if (fun_conf != NULL) {
+		fun_conf_parse(fun_conf, dev);
+		free(fun_conf);
+	}
+}
+
+static int isa_add_device(ddf_dev_t *dev)
 {
 	printf(NAME ": isa_add_device, device handle = %d\n",
 	    (int) dev->handle);
 
-	/* Add child devices. */
-	add_legacy_children(dev);
-	printf(NAME ": finished the enumeration of legacy devices\n");
+	/* Make the bus device more visible. Does not do anything. */
+	printf(NAME ": adding a 'ctl' function\n");
+
+	ddf_fun_t *ctl = ddf_fun_create(dev, fun_exposed, "ctl");
+	if (ctl == NULL) {
+		printf(NAME ": Error creating control function.\n");
+		return EXDEV;
+	}
+
+	if (ddf_fun_bind(ctl) != EOK) {
+		printf(NAME ": Error binding control function.\n");
+		return EXDEV;
+	}
+
+	/* Add functions as specified in the configuration file. */
+	isa_functions_add(dev);
+	printf(NAME ": finished the enumeration of legacy functions\n");
 
 	return EOK;
@@ -502,5 +493,5 @@
 static void isa_init() 
 {
-	isa_child_dev_ops.interfaces[HW_RES_DEV_IFACE] = &isa_child_hw_res_ops;
+	isa_fun_ops.interfaces[HW_RES_DEV_IFACE] = &isa_fun_hw_res_ops;
 }
 
@@ -509,5 +500,5 @@
 	printf(NAME ": HelenOS ISA bus driver\n");
 	isa_init();
-	return driver_main(&isa_driver);
+	return ddf_driver_main(&isa_driver);
 }
 
@@ -515,3 +506,2 @@
  * @}
  */
- 
Index: uspace/drv/ns8250/ns8250.c
===================================================================
--- uspace/drv/ns8250/ns8250.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/ns8250/ns8250.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -1,4 +1,5 @@
 /*
  * Copyright (c) 2010 Lenka Trochtova
+ * Copyright (c) 2011 Jiri Svoboda
  * All rights reserved.
  *
@@ -52,5 +53,6 @@
 #include <libarch/ddi.h>
 
-#include <driver.h>
+#include <ddf/driver.h>
+#include <ddf/interrupt.h>
 #include <ops/char_dev.h>
 
@@ -67,4 +69,10 @@
 #define MAX_BAUD_RATE 115200
 #define DLAB_MASK (1 << 7)
+
+/** Obtain soft-state structure from function node */
+#define NS8250(fnode) ((ns8250_t *) ((fnode)->dev->driver_data))
+
+/** Obtain soft-state structure from device node */
+#define NS8250_FROM_DEV(dnode) ((ns8250_t *) ((dnode)->driver_data))
 
 /** The number of bits of one data unit send by the serial port. */
@@ -85,5 +93,9 @@
 
 /** The driver data for the serial port devices. */
-typedef struct ns8250_dev_data {
+typedef struct ns8250 {
+	/** DDF device node */
+	ddf_dev_t *dev;
+	/** DDF function node */
+	ddf_fun_t *fun;
 	/** Is there any client conntected to the device? */
 	bool client_connected;
@@ -98,30 +110,30 @@
 	/** The fibril mutex for synchronizing the access to the device. */
 	fibril_mutex_t mutex;
-} ns8250_dev_data_t;
-
-/** Create driver data for a device.
- *
- * @return		The driver data.
- */
-static ns8250_dev_data_t *create_ns8250_dev_data(void)
-{
-	ns8250_dev_data_t *data;
-	
-	data = (ns8250_dev_data_t *) malloc(sizeof(ns8250_dev_data_t));
-	if (NULL != data) {
-		memset(data, 0, sizeof(ns8250_dev_data_t));
-		fibril_mutex_initialize(&data->mutex);
-	}
-	return data;
-}
-
-/** Delete driver data.
- *
- * @param data		The driver data structure.
- */
-static void delete_ns8250_dev_data(ns8250_dev_data_t *data)
-{
-	if (data != NULL)
-		free(data);
+} ns8250_t;
+
+/** Create per-device soft-state structure.
+ *
+ * @return	Pointer to soft-state structure.
+ */
+static ns8250_t *ns8250_new(void)
+{
+	ns8250_t *ns;
+	
+	ns = (ns8250_t *) calloc(1, sizeof(ns8250_t));
+	if (ns == NULL)
+		return NULL;
+	
+	fibril_mutex_initialize(&ns->mutex);
+	return ns;
+}
+
+/** Delete soft-state structure.
+ *
+ * @param ns	The driver data structure.
+ */
+static void ns8250_delete(ns8250_t *ns)
+{
+	assert(ns != NULL);
+	free(ns);
 }
 
@@ -171,5 +183,5 @@
 /** Read data from the serial port device.
  *
- * @param dev		The serial port device.
+ * @param fun		The serial port function
  * @param buf		The ouput buffer for read data.
  * @param count		The number of bytes to be read.
@@ -178,15 +190,15 @@
  *			error number otherwise.
  */
-static int ns8250_read(device_t *dev, char *buf, size_t count)
-{
+static int ns8250_read(ddf_fun_t *fun, char *buf, size_t count)
+{
+	ns8250_t *ns = NS8250(fun);
 	int ret = EOK;
-	ns8250_dev_data_t *data = (ns8250_dev_data_t *) dev->driver_data;
-	
-	fibril_mutex_lock(&data->mutex);
-	while (!buf_is_empty(&data->input_buffer) && (size_t)ret < count) {
-		buf[ret] = (char)buf_pop_front(&data->input_buffer);
+	
+	fibril_mutex_lock(&ns->mutex);
+	while (!buf_is_empty(&ns->input_buffer) && (size_t)ret < count) {
+		buf[ret] = (char)buf_pop_front(&ns->input_buffer);
 		ret++;
 	}
-	fibril_mutex_unlock(&data->mutex);
+	fibril_mutex_unlock(&ns->mutex);
 	
 	return ret;
@@ -195,33 +207,33 @@
 /** Write a character to the serial port.
  *
- * @param data		The serial port device's driver data.
- * @param c		The character to be written.
- */
-static inline void ns8250_putchar(ns8250_dev_data_t *data, uint8_t c)
-{
-	fibril_mutex_lock(&data->mutex);
-	ns8250_write_8(data->port, c);
-	fibril_mutex_unlock(&data->mutex);
+ * @param ns		Serial port device
+ * @param c		The character to be written
+ */
+static inline void ns8250_putchar(ns8250_t *ns, uint8_t c)
+{
+	fibril_mutex_lock(&ns->mutex);
+	ns8250_write_8(ns->port, c);
+	fibril_mutex_unlock(&ns->mutex);
 }
 
 /** Write data to the serial port.
  *
- * @param dev		The serial port device.
- * @param buf		The data to be written.
- * @param count		The number of bytes to be written.
- * @return		Zero on success.
- */
-static int ns8250_write(device_t *dev, char *buf, size_t count) 
-{
-	ns8250_dev_data_t *data = (ns8250_dev_data_t *) dev->driver_data;
+ * @param fun		The serial port function
+ * @param buf		The data to be written
+ * @param count		The number of bytes to be written
+ * @return		Zero on success
+ */
+static int ns8250_write(ddf_fun_t *fun, char *buf, size_t count)
+{
+	ns8250_t *ns = NS8250(fun);
 	size_t idx;
 	
 	for (idx = 0; idx < count; idx++)
-		ns8250_putchar(data, (uint8_t) buf[idx]);
+		ns8250_putchar(ns, (uint8_t) buf[idx]);
 	
 	return 0;
 }
 
-static device_ops_t ns8250_dev_ops;
+static ddf_dev_ops_t ns8250_dev_ops;
 
 /** The character interface's callbacks. */
@@ -231,5 +243,5 @@
 };
 
-static int ns8250_add_device(device_t *dev);
+static int ns8250_add_device(ddf_dev_t *dev);
 
 /** The serial port device driver's standard operations. */
@@ -244,18 +256,13 @@
 };
 
-/** Clean up the serial port device structure.
- *
- * @param dev		The device structure.
- */
-static void ns8250_dev_cleanup(device_t *dev)
-{
-	if (dev->driver_data != NULL) {
-		delete_ns8250_dev_data((ns8250_dev_data_t*) dev->driver_data);
-		dev->driver_data = NULL;
-	}
-	
-	if (dev->parent_phone > 0) {
-		async_hangup(dev->parent_phone);
-		dev->parent_phone = 0;
+/** Clean up the serial port soft-state
+ *
+ * @param ns		Serial port device
+ */
+static void ns8250_dev_cleanup(ns8250_t *ns)
+{
+	if (ns->dev->parent_phone > 0) {
+		async_hangup(ns->dev->parent_phone);
+		ns->dev->parent_phone = 0;
 	}
 }
@@ -263,18 +270,16 @@
 /** Enable the i/o ports of the device.
  *
- * @param dev		The serial port device.
- * @return		True on success, false otherwise.
- */
-static bool ns8250_pio_enable(device_t *dev)
-{
-	printf(NAME ": ns8250_pio_enable %s\n", dev->name);
-	
-	ns8250_dev_data_t *data = (ns8250_dev_data_t *)dev->driver_data;
+ * @param ns		Serial port device
+ * @return		True on success, false otherwise
+ */
+static bool ns8250_pio_enable(ns8250_t *ns)
+{
+	printf(NAME ": ns8250_pio_enable %s\n", ns->dev->name);
 	
 	/* Gain control over port's registers. */
-	if (pio_enable((void *)(uintptr_t) data->io_addr, REG_COUNT,
-	    (void **) &data->port)) {
+	if (pio_enable((void *)(uintptr_t) ns->io_addr, REG_COUNT,
+	    (void **) &ns->port)) {
 		printf(NAME ": error - cannot gain the port %#" PRIx32 " for device "
-		    "%s.\n", data->io_addr, dev->name);
+		    "%s.\n", ns->io_addr, ns->dev->name);
 		return false;
 	}
@@ -285,13 +290,12 @@
 /** Probe the serial port device for its presence.
  *
- * @param dev		The serial port device.
- * @return		True if the device is present, false otherwise.
- */
-static bool ns8250_dev_probe(device_t *dev)
-{
-	printf(NAME ": ns8250_dev_probe %s\n", dev->name);
-	
-	ns8250_dev_data_t *data = (ns8250_dev_data_t *) dev->driver_data;
-	ioport8_t *port_addr = data->port;
+ * @param ns		Serial port device
+ * @return		True if the device is present, false otherwise
+ */
+static bool ns8250_dev_probe(ns8250_t *ns)
+{
+	printf(NAME ": ns8250_dev_probe %s\n", ns->dev->name);
+	
+	ioport8_t *port_addr = ns->port;
 	bool res = true;
 	uint8_t olddata;
@@ -310,5 +314,5 @@
 	
 	if (!res)
-		printf(NAME ": device %s is not present.\n", dev->name);
+		printf(NAME ": device %s is not present.\n", ns->dev->name);
 	
 	return res;
@@ -317,10 +321,10 @@
 /** Initialize serial port device.
  *
- * @param dev		The serial port device.
- * @return		Zero on success, negative error number otherwise.
- */
-static int ns8250_dev_initialize(device_t *dev)
-{
-	printf(NAME ": ns8250_dev_initialize %s\n", dev->name);
+ * @param ns		Serial port device
+ * @return		Zero on success, negative error number otherwise
+ */
+static int ns8250_dev_initialize(ns8250_t *ns)
+{
+	printf(NAME ": ns8250_dev_initialize %s\n", ns->dev->name);
 	
 	int ret = EOK;
@@ -329,25 +333,19 @@
 	memset(&hw_resources, 0, sizeof(hw_resource_list_t));
 	
-	/* Allocate driver data for the device. */
-	ns8250_dev_data_t *data = create_ns8250_dev_data();
-	if (data == NULL)
-		return ENOMEM;
-	dev->driver_data = data;
-	
 	/* Connect to the parent's driver. */
-	dev->parent_phone = devman_parent_device_connect(dev->handle,
+	ns->dev->parent_phone = devman_parent_device_connect(ns->dev->handle,
 	    IPC_FLAG_BLOCKING);
-	if (dev->parent_phone < 0) {
+	if (ns->dev->parent_phone < 0) {
 		printf(NAME ": failed to connect to the parent driver of the "
-		    "device %s.\n", dev->name);
-		ret = dev->parent_phone;
+		    "device %s.\n", ns->dev->name);
+		ret = ns->dev->parent_phone;
 		goto failed;
 	}
 	
 	/* Get hw resources. */
-	ret = hw_res_get_resource_list(dev->parent_phone, &hw_resources);
+	ret = hw_res_get_resource_list(ns->dev->parent_phone, &hw_resources);
 	if (ret != EOK) {
 		printf(NAME ": failed to get hw resources for the device "
-		    "%s.\n", dev->name);
+		    "%s.\n", ns->dev->name);
 		goto failed;
 	}
@@ -362,15 +360,15 @@
 		switch (res->type) {
 		case INTERRUPT:
-			data->irq = res->res.interrupt.irq;
+			ns->irq = res->res.interrupt.irq;
 			irq = true;
 			printf(NAME ": the %s device was asigned irq = 0x%x.\n",
-			    dev->name, data->irq);
+			    ns->dev->name, ns->irq);
 			break;
 			
 		case IO_RANGE:
-			data->io_addr = res->res.io_range.address;
+			ns->io_addr = res->res.io_range.address;
 			if (res->res.io_range.size < REG_COUNT) {
 				printf(NAME ": i/o range assigned to the device "
-				    "%s is too small.\n", dev->name);
+				    "%s is too small.\n", ns->dev->name);
 				ret = ELIMIT;
 				goto failed;
@@ -378,5 +376,5 @@
 			ioport = true;
 			printf(NAME ": the %s device was asigned i/o address = "
-			    "0x%x.\n", dev->name, data->io_addr);
+			    "0x%x.\n", ns->dev->name, ns->io_addr);
 			break;
 			
@@ -388,5 +386,5 @@
 	if (!irq || !ioport) {
 		printf(NAME ": missing hw resource(s) for the device %s.\n",
-		    dev->name);
+		    ns->dev->name);
 		ret = ENOENT;
 		goto failed;
@@ -397,5 +395,5 @@
 	
 failed:
-	ns8250_dev_cleanup(dev);
+	ns8250_dev_cleanup(ns);
 	hw_res_clean_resource_list(&hw_resources);
 	return ret;
@@ -404,10 +402,10 @@
 /** Enable interrupts on the serial port device.
  *
- * Interrupt when data is received.
+ * Interrupt when data is received
  *
  * @param port		The base address of the serial port device's ports.
  */
 static inline void ns8250_port_interrupts_enable(ioport8_t *port)
-{	
+{
 	pio_write_8(port + 1, 0x1);	/* Interrupt when data received. */
 	pio_write_8(port + 4, 0xB);
@@ -416,5 +414,5 @@
 /** Disable interrupts on the serial port device.
  *
- * @param port		The base address of the serial port device's ports.
+ * @param port		The base address of the serial port device's ports
  */
 static inline void ns8250_port_interrupts_disable(ioport8_t *port)
@@ -425,13 +423,11 @@
 /** Enable interrupts for the serial port device.
  *
- * @param dev		The device.
- * @return		Zero on success, negative error number otherwise.
- */
-static int ns8250_interrupt_enable(device_t *dev)
-{
-	ns8250_dev_data_t *data = (ns8250_dev_data_t *) dev->driver_data;
-	
+ * @param ns		Serial port device
+ * @return		Zero on success, negative error number otherwise
+ */
+static int ns8250_interrupt_enable(ns8250_t *ns)
+{
 	/* Enable interrupt on the serial port. */
-	ns8250_port_interrupts_enable(data->port);
+	ns8250_port_interrupts_enable(ns->port);
 	
 	return EOK;
@@ -618,10 +614,9 @@
  * Set the default parameters of the serial communication.
  *
- * @param dev		The serial port device.
- */
-static void ns8250_initialize_port(device_t *dev)
-{
-	ns8250_dev_data_t *data = (ns8250_dev_data_t *)dev->driver_data;
-	ioport8_t *port = data->port;
+ * @param ns		Serial port device
+ */
+static void ns8250_initialize_port(ns8250_t *ns)
+{
+	ioport8_t *port = ns->port;
 	
 	/* Disable interrupts. */
@@ -643,14 +638,13 @@
  * buffer.
  *
- * @param dev		The serial port device.
- */
-static void ns8250_read_from_device(device_t *dev)
-{
-	ns8250_dev_data_t *data = (ns8250_dev_data_t *) dev->driver_data;
-	ioport8_t *port = data->port;
+ * @param ns		Serial port device
+ */
+static void ns8250_read_from_device(ns8250_t *ns)
+{
+	ioport8_t *port = ns->port;
 	bool cont = true;
 	
 	while (cont) {
-		fibril_mutex_lock(&data->mutex);
+		fibril_mutex_lock(&ns->mutex);
 		
 		cont = ns8250_received(port);
@@ -658,17 +652,17 @@
 			uint8_t val = ns8250_read_8(port);
 			
-			if (data->client_connected) {
-				if (!buf_push_back(&data->input_buffer, val)) {
+			if (ns->client_connected) {
+				if (!buf_push_back(&ns->input_buffer, val)) {
 					printf(NAME ": buffer overflow on "
-					    "%s.\n", dev->name);
+					    "%s.\n", ns->dev->name);
 				} else {
 					printf(NAME ": the character %c saved "
 					    "to the buffer of %s.\n",
-					    val, dev->name);
+					    val, ns->dev->name);
 				}
 			}
 		}
 		
-		fibril_mutex_unlock(&data->mutex);
+		fibril_mutex_unlock(&ns->mutex);
 		fibril_yield();
 	}
@@ -682,83 +676,107 @@
  * @param dev		The serial port device.
  */
-static inline void ns8250_interrupt_handler(device_t *dev, ipc_callid_t iid,
+static inline void ns8250_interrupt_handler(ddf_dev_t *dev, ipc_callid_t iid,
     ipc_call_t *icall)
 {
-	ns8250_read_from_device(dev);
+	ns8250_read_from_device(NS8250_FROM_DEV(dev));
 }
 
 /** Register the interrupt handler for the device.
  *
+ * @param ns		Serial port device
+ */
+static inline int ns8250_register_interrupt_handler(ns8250_t *ns)
+{
+	return register_interrupt_handler(ns->dev, ns->irq,
+	    ns8250_interrupt_handler, NULL);
+}
+
+/** Unregister the interrupt handler for the device.
+ *
+ * @param ns		Serial port device
+ */
+static inline int ns8250_unregister_interrupt_handler(ns8250_t *ns)
+{
+	return unregister_interrupt_handler(ns->dev, ns->irq);
+}
+
+/** The add_device callback method of the serial port driver.
+ *
+ * Probe and initialize the newly added device.
+ *
  * @param dev		The serial port device.
  */
-static inline int ns8250_register_interrupt_handler(device_t *dev)
-{
-	ns8250_dev_data_t *data = (ns8250_dev_data_t *) dev->driver_data;
-	
-	return register_interrupt_handler(dev, data->irq,
-	    ns8250_interrupt_handler, NULL);
-}
-
-/** Unregister the interrupt handler for the device.
- *
- * @param dev		The serial port device.
- */
-static inline int ns8250_unregister_interrupt_handler(device_t *dev)
-{
-	ns8250_dev_data_t *data = (ns8250_dev_data_t *) dev->driver_data;
-	
-	return unregister_interrupt_handler(dev, data->irq);
-}
-
-/** The add_device callback method of the serial port driver.
- *
- * Probe and initialize the newly added device.
- *
- * @param dev		The serial port device.
- */
-static int ns8250_add_device(device_t *dev)
-{
+static int ns8250_add_device(ddf_dev_t *dev)
+{
+	ns8250_t *ns = NULL;
+	ddf_fun_t *fun = NULL;
+	bool need_cleanup = false;
+	int rc;
+	
 	printf(NAME ": ns8250_add_device %s (handle = %d)\n",
 	    dev->name, (int) dev->handle);
 	
-	int res = ns8250_dev_initialize(dev);
-	if (res != EOK)
-		return res;
-	
-	if (!ns8250_pio_enable(dev)) {
-		ns8250_dev_cleanup(dev);
-		return EADDRNOTAVAIL;
+	/* Allocate soft-state for the device */
+	ns = ns8250_new();
+	if (ns == NULL) {
+		rc = ENOMEM;
+		goto fail;
+	}
+	
+	ns->dev = dev;
+	dev->driver_data = ns;
+	
+	rc = ns8250_dev_initialize(ns);
+	if (rc != EOK)
+		goto fail;
+	
+	need_cleanup = true;
+	
+	if (!ns8250_pio_enable(ns)) {
+		rc = EADDRNOTAVAIL;
+		goto fail;
 	}
 	
 	/* Find out whether the device is present. */
-	if (!ns8250_dev_probe(dev)) {
-		ns8250_dev_cleanup(dev);
-		return ENOENT;
+	if (!ns8250_dev_probe(ns)) {
+		rc = ENOENT;
+		goto fail;
 	}
 	
 	/* Serial port initialization (baud rate etc.). */
-	ns8250_initialize_port(dev);
+	ns8250_initialize_port(ns);
 	
 	/* Register interrupt handler. */
-	if (ns8250_register_interrupt_handler(dev) != EOK) {
+	if (ns8250_register_interrupt_handler(ns) != EOK) {
 		printf(NAME ": failed to register interrupt handler.\n");
-		ns8250_dev_cleanup(dev);
-		return res;
+		rc = EADDRNOTAVAIL;
+		goto fail;
 	}
 	
 	/* Enable interrupt. */
-	res = ns8250_interrupt_enable(dev);
-	if (res != EOK) {
+	rc = ns8250_interrupt_enable(ns);
+	if (rc != EOK) {
 		printf(NAME ": failed to enable the interrupt. Error code = "
-		    "%d.\n", res);
-		ns8250_dev_cleanup(dev);
-		ns8250_unregister_interrupt_handler(dev);
-		return res;
+		    "%d.\n", rc);
+		goto fail;
+	}
+	
+	fun = ddf_fun_create(dev, fun_exposed, "a");
+	if (fun == NULL) {
+		printf(NAME ": error creating function.\n");
+		goto fail;
 	}
 	
 	/* Set device operations. */
-	dev->ops = &ns8250_dev_ops;
-	
-	add_device_to_class(dev, "serial");
+	fun->ops = &ns8250_dev_ops;
+	rc = ddf_fun_bind(fun);
+	if (rc != EOK) {
+		printf(NAME ": error binding function.\n");
+		goto fail;
+	}
+
+	ns->fun = fun;
+	
+	ddf_fun_add_to_class(fun, "serial");
 	
 	printf(NAME ": the %s device has been successfully initialized.\n",
@@ -766,4 +784,12 @@
 	
 	return EOK;
+fail:
+	if (fun != NULL)
+		ddf_fun_destroy(fun);
+	if (need_cleanup)
+		ns8250_dev_cleanup(ns);
+	if (ns != NULL)
+		ns8250_delete(ns);
+	return rc;
 }
 
@@ -775,7 +801,7 @@
  * @param dev		The device.
  */
-static int ns8250_open(device_t *dev)
-{
-	ns8250_dev_data_t *data = (ns8250_dev_data_t *) dev->driver_data;
+static int ns8250_open(ddf_fun_t *fun)
+{
+	ns8250_t *data = (ns8250_t *) fun->dev->driver_data;
 	int res;
 	
@@ -788,5 +814,5 @@
 	}
 	fibril_mutex_unlock(&data->mutex);
-
+	
 	return res;
 }
@@ -799,7 +825,7 @@
  * @param dev		The device.
  */
-static void ns8250_close(device_t *dev)
-{
-	ns8250_dev_data_t *data = (ns8250_dev_data_t *) dev->driver_data;
+static void ns8250_close(ddf_fun_t *fun)
+{
+	ns8250_t *data = (ns8250_t *) fun->dev->driver_data;
 	
 	fibril_mutex_lock(&data->mutex);
@@ -823,8 +849,8 @@
  */
 static void
-ns8250_get_props(device_t *dev, unsigned int *baud_rate, unsigned int *parity,
+ns8250_get_props(ddf_dev_t *dev, unsigned int *baud_rate, unsigned int *parity,
     unsigned int *word_length, unsigned int* stop_bits)
 {
-	ns8250_dev_data_t *data = (ns8250_dev_data_t *) dev->driver_data;
+	ns8250_t *data = (ns8250_t *) dev->driver_data;
 	ioport8_t *port = data->port;
 	
@@ -850,5 +876,5 @@
  * @param stop_bits	The number of stop bits to be used.
  */
-static int ns8250_set_props(device_t *dev, unsigned int baud_rate,
+static int ns8250_set_props(ddf_dev_t *dev, unsigned int baud_rate,
     unsigned int parity, unsigned int word_length, unsigned int stop_bits)
 {
@@ -857,5 +883,5 @@
 	    stop_bits);
 	
-	ns8250_dev_data_t *data = (ns8250_dev_data_t *) dev->driver_data;
+	ns8250_t *data = (ns8250_t *) dev->driver_data;
 	ioport8_t *port = data->port;
 	int ret;
@@ -877,5 +903,5 @@
  * Configure the parameters of the serial communication.
  */
-static void ns8250_default_handler(device_t *dev, ipc_callid_t callid,
+static void ns8250_default_handler(ddf_fun_t *fun, ipc_callid_t callid,
     ipc_call_t *call)
 {
@@ -886,5 +912,5 @@
 	switch (method) {
 	case SERIAL_GET_COM_PROPS:
-		ns8250_get_props(dev, &baud_rate, &parity, &word_length,
+		ns8250_get_props(fun->dev, &baud_rate, &parity, &word_length,
 		    &stop_bits);
 		async_answer_4(callid, EOK, baud_rate, parity, word_length,
@@ -897,5 +923,5 @@
 		word_length = IPC_GET_ARG3(*call);
 		stop_bits = IPC_GET_ARG4(*call);
-		ret = ns8250_set_props(dev, baud_rate, parity, word_length,
+		ret = ns8250_set_props(fun->dev, baud_rate, parity, word_length,
 		    stop_bits);
 		async_answer_0(callid, ret);
@@ -925,5 +951,5 @@
 	printf(NAME ": HelenOS serial port driver\n");
 	ns8250_init();
-	return driver_main(&ns8250_driver);
+	return ddf_driver_main(&ns8250_driver);
 }
 
Index: uspace/drv/pciintel/pci.c
===================================================================
--- uspace/drv/pciintel/pci.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/pciintel/pci.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -1,4 +1,5 @@
 /*
  * Copyright (c) 2010 Lenka Trochtova
+ * Copyright (c) 2011 Jiri Svoboda
  * All rights reserved.
  *
@@ -44,6 +45,7 @@
 #include <ctype.h>
 #include <macros.h>
-
-#include <driver.h>
+#include <str_error.h>
+
+#include <ddf/driver.h>
 #include <devman.h>
 #include <ipc/devman.h>
@@ -65,18 +67,27 @@
 	((1 << 31) | (bus << 16) | (dev << 11) | (fn << 8) | (reg & ~3))
 
-static hw_resource_list_t *pciintel_get_child_resources(device_t *dev)
-{
-	pci_dev_data_t *dev_data = (pci_dev_data_t *) dev->driver_data;
-	
-	if (dev_data == NULL)
+/** Obtain PCI function soft-state from DDF function node */
+#define PCI_FUN(fnode) ((pci_fun_t *) (fnode)->driver_data)
+
+/** Obtain PCI bus soft-state from DDF device node */
+#define PCI_BUS(dnode) ((pci_bus_t *) (dnode)->driver_data)
+
+/** Obtain PCI bus soft-state from function soft-state */
+#define PCI_BUS_FROM_FUN(fun) ((fun)->busptr)
+
+static hw_resource_list_t *pciintel_get_resources(ddf_fun_t *fnode)
+{
+	pci_fun_t *fun = PCI_FUN(fnode);
+	
+	if (fun == NULL)
 		return NULL;
-	return &dev_data->hw_resources;
-}
-
-static bool pciintel_enable_child_interrupt(device_t *dev)
+	return &fun->hw_resources;
+}
+
+static bool pciintel_enable_interrupt(ddf_fun_t *fnode)
 {
 	/* This is an old ugly way, copied from ne2000 driver */
-	assert(dev);
-	pci_dev_data_t *dev_data = (pci_dev_data_t *) dev->driver_data;
+	assert(fnode);
+	pci_fun_t *dev_data = (pci_fun_t *) fnode->driver_data;
 
   sysarg_t apic;
@@ -110,19 +121,19 @@
 }
 
-static hw_res_ops_t pciintel_child_hw_res_ops = {
-	&pciintel_get_child_resources,
-	&pciintel_enable_child_interrupt
+static hw_res_ops_t pciintel_hw_res_ops = {
+	&pciintel_get_resources,
+	&pciintel_enable_interrupt
 };
 
-static device_ops_t pci_child_ops;
-
-static int pci_add_device(device_t *);
-
-/** The pci bus driver's standard operations. */
+static ddf_dev_ops_t pci_fun_ops;
+
+static int pci_add_device(ddf_dev_t *);
+
+/** PCI bus driver standard operations */
 static driver_ops_t pci_ops = {
 	.add_device = &pci_add_device
 };
 
-/** The pci bus driver structure. */
+/** PCI bus driver structure */
 static driver_t pci_driver = {
 	.name = NAME,
@@ -130,43 +141,33 @@
 };
 
-typedef struct pciintel_bus_data {
-	uint32_t conf_io_addr;
-	void *conf_data_port;
-	void *conf_addr_port;
-	fibril_mutex_t conf_mutex;
-} pci_bus_data_t;
-
-static pci_bus_data_t *create_pci_bus_data(void)
-{
-	pci_bus_data_t *bus_data;
-	
-	bus_data = (pci_bus_data_t *) malloc(sizeof(pci_bus_data_t));
-	if (bus_data != NULL) {
-		memset(bus_data, 0, sizeof(pci_bus_data_t));
-		fibril_mutex_initialize(&bus_data->conf_mutex);
-	}
-
-	return bus_data;
-}
-
-static void delete_pci_bus_data(pci_bus_data_t *bus_data)
-{
-	free(bus_data);
-}
-
-static void pci_conf_read(device_t *dev, int reg, uint8_t *buf, size_t len)
-{
-	assert(dev->parent != NULL);
-	
-	pci_dev_data_t *dev_data = (pci_dev_data_t *) dev->driver_data;
-	pci_bus_data_t *bus_data = (pci_bus_data_t *) dev->parent->driver_data;
-	
-	fibril_mutex_lock(&bus_data->conf_mutex);
+static pci_bus_t *pci_bus_new(void)
+{
+	pci_bus_t *bus;
+	
+	bus = (pci_bus_t *) calloc(1, sizeof(pci_bus_t));
+	if (bus == NULL)
+		return NULL;
+	
+	fibril_mutex_initialize(&bus->conf_mutex);
+	return bus;
+}
+
+static void pci_bus_delete(pci_bus_t *bus)
+{
+	assert(bus != NULL);
+	free(bus);
+}
+
+static void pci_conf_read(pci_fun_t *fun, int reg, uint8_t *buf, size_t len)
+{
+	pci_bus_t *bus = PCI_BUS_FROM_FUN(fun);
+	
+	fibril_mutex_lock(&bus->conf_mutex);
 	
 	uint32_t conf_addr;
-	conf_addr = CONF_ADDR(dev_data->bus, dev_data->dev, dev_data->fn, reg);
-	void *addr = bus_data->conf_data_port + (reg & 3);
-	
-	pio_write_32(bus_data->conf_addr_port, conf_addr);
+	conf_addr = CONF_ADDR(fun->bus, fun->dev, fun->fn, reg);
+	void *addr = bus->conf_data_port + (reg & 3);
+	
+	pio_write_32(bus->conf_addr_port, conf_addr);
 	
 	switch (len) {
@@ -182,21 +183,18 @@
 	}
 	
-	fibril_mutex_unlock(&bus_data->conf_mutex);
-}
-
-static void pci_conf_write(device_t *dev, int reg, uint8_t *buf, size_t len)
-{
-	assert(dev->parent != NULL);
-	
-	pci_dev_data_t *dev_data = (pci_dev_data_t *) dev->driver_data;
-	pci_bus_data_t *bus_data = (pci_bus_data_t *) dev->parent->driver_data;
-	
-	fibril_mutex_lock(&bus_data->conf_mutex);
+	fibril_mutex_unlock(&bus->conf_mutex);
+}
+
+static void pci_conf_write(pci_fun_t *fun, int reg, uint8_t *buf, size_t len)
+{
+	pci_bus_t *bus = PCI_BUS_FROM_FUN(fun);
+	
+	fibril_mutex_lock(&bus->conf_mutex);
 	
 	uint32_t conf_addr;
-	conf_addr = CONF_ADDR(dev_data->bus, dev_data->dev, dev_data->fn, reg);
-	void *addr = bus_data->conf_data_port + (reg & 3);
-	
-	pio_write_32(bus_data->conf_addr_port, conf_addr);
+	conf_addr = CONF_ADDR(fun->bus, fun->dev, fun->fn, reg);
+	void *addr = bus->conf_data_port + (reg & 3);
+	
+	pio_write_32(bus->conf_addr_port, conf_addr);
 	
 	switch (len) {
@@ -212,66 +210,69 @@
 	}
 	
-	fibril_mutex_unlock(&bus_data->conf_mutex);
-}
-
-uint8_t pci_conf_read_8(device_t *dev, int reg)
+	fibril_mutex_unlock(&bus->conf_mutex);
+}
+
+uint8_t pci_conf_read_8(pci_fun_t *fun, int reg)
 {
 	uint8_t res;
-	pci_conf_read(dev, reg, &res, 1);
+	pci_conf_read(fun, reg, &res, 1);
 	return res;
 }
 
-uint16_t pci_conf_read_16(device_t *dev, int reg)
+uint16_t pci_conf_read_16(pci_fun_t *fun, int reg)
 {
 	uint16_t res;
-	pci_conf_read(dev, reg, (uint8_t *) &res, 2);
+	pci_conf_read(fun, reg, (uint8_t *) &res, 2);
 	return res;
 }
 
-uint32_t pci_conf_read_32(device_t *dev, int reg)
+uint32_t pci_conf_read_32(pci_fun_t *fun, int reg)
 {
 	uint32_t res;
-	pci_conf_read(dev, reg, (uint8_t *) &res, 4);
+	pci_conf_read(fun, reg, (uint8_t *) &res, 4);
 	return res;
 }
 
-void pci_conf_write_8(device_t *dev, int reg, uint8_t val)
-{
-	pci_conf_write(dev, reg, (uint8_t *) &val, 1);
-}
-
-void pci_conf_write_16(device_t *dev, int reg, uint16_t val)
-{
-	pci_conf_write(dev, reg, (uint8_t *) &val, 2);
-}
-
-void pci_conf_write_32(device_t *dev, int reg, uint32_t val)
-{
-	pci_conf_write(dev, reg, (uint8_t *) &val, 4);
-}
-
-void create_pci_match_ids(device_t *dev)
-{
-	pci_dev_data_t *dev_data = (pci_dev_data_t *) dev->driver_data;
-	match_id_t *match_id = NULL;
+void pci_conf_write_8(pci_fun_t *fun, int reg, uint8_t val)
+{
+	pci_conf_write(fun, reg, (uint8_t *) &val, 1);
+}
+
+void pci_conf_write_16(pci_fun_t *fun, int reg, uint16_t val)
+{
+	pci_conf_write(fun, reg, (uint8_t *) &val, 2);
+}
+
+void pci_conf_write_32(pci_fun_t *fun, int reg, uint32_t val)
+{
+	pci_conf_write(fun, reg, (uint8_t *) &val, 4);
+}
+
+void pci_fun_create_match_ids(pci_fun_t *fun)
+{
 	char *match_id_str;
-	
-	match_id = create_match_id();
-	if (match_id != NULL) {
-		asprintf(&match_id_str, "pci/ven=%04x&dev=%04x",
-		    dev_data->vendor_id, dev_data->device_id);
-		match_id->id = match_id_str;
-		match_id->score = 90;
-		add_match_id(&dev->match_ids, match_id);
-	}
-
+	int rc;
+	
+	asprintf(&match_id_str, "pci/ven=%04x&dev=%04x",
+	    fun->vendor_id, fun->device_id);
+
+	if (match_id_str == NULL) {
+		printf(NAME ": out of memory creating match ID.\n");
+		return;
+	}
+
+	rc = ddf_fun_add_match_id(fun->fnode, match_id_str, 90);
+	if (rc != EOK) {
+		printf(NAME ": error adding match ID: %s\n",
+		    str_error(rc));
+	}
+	
 	/* TODO add more ids (with subsys ids, using class id etc.) */
 }
 
-void
-pci_add_range(device_t *dev, uint64_t range_addr, size_t range_size, bool io)
-{
-	pci_dev_data_t *dev_data = (pci_dev_data_t *) dev->driver_data;
-	hw_resource_list_t *hw_res_list = &dev_data->hw_resources;
+void pci_add_range(pci_fun_t *fun, uint64_t range_addr, size_t range_size,
+    bool io)
+{
+	hw_resource_list_t *hw_res_list = &fun->hw_resources;
 	hw_resource_t *hw_resources =  hw_res_list->resources;
 	size_t count = hw_res_list->count;
@@ -298,11 +299,11 @@
  * address add it to the devices hw resource list.
  *
- * @param dev	The pci device.
+ * @param fun	PCI function
  * @param addr	The address of the BAR in the PCI configuration address space of
- *		the device.
- * @return	The addr the address of the BAR which should be read next.
+ *		the device
+ * @return	The addr the address of the BAR which should be read next
  */
-int pci_read_bar(device_t *dev, int addr)
-{	
+int pci_read_bar(pci_fun_t *fun, int addr)
+{
 	/* Value of the BAR */
 	uint32_t val, mask;
@@ -318,5 +319,5 @@
 	
 	/* Get the value of the BAR. */
-	val = pci_conf_read_32(dev, addr);
+	val = pci_conf_read_32(fun, addr);
 	
 	io = (bool) (val & 1);
@@ -338,15 +339,15 @@
 	
 	/* Get the address mask. */
-	pci_conf_write_32(dev, addr, 0xffffffff);
-	mask = pci_conf_read_32(dev, addr);
+	pci_conf_write_32(fun, addr, 0xffffffff);
+	mask = pci_conf_read_32(fun, addr);
 	
 	/* Restore the original value. */
-	pci_conf_write_32(dev, addr, val);
-	val = pci_conf_read_32(dev, addr);
+	pci_conf_write_32(fun, addr, val);
+	val = pci_conf_read_32(fun, addr);
 	
 	range_size = pci_bar_mask_to_size(mask);
 	
 	if (addrw64) {
-		range_addr = ((uint64_t)pci_conf_read_32(dev, addr + 4) << 32) |
+		range_addr = ((uint64_t)pci_conf_read_32(fun, addr + 4) << 32) |
 		    (val & 0xfffffff0);
 	} else {
@@ -355,10 +356,10 @@
 	
 	if (range_addr != 0) {
-		printf(NAME ": device %s : ", dev->name);
+		printf(NAME ": function %s : ", fun->fnode->name);
 		printf("address = %" PRIx64, range_addr);
 		printf(", size = %x\n", (unsigned int) range_size);
 	}
 	
-	pci_add_range(dev, range_addr, range_size, io);
+	pci_add_range(fun, range_addr, range_size, io);
 	
 	if (addrw64)
@@ -368,8 +369,7 @@
 }
 
-void pci_add_interrupt(device_t *dev, int irq)
-{
-	pci_dev_data_t *dev_data = (pci_dev_data_t *) dev->driver_data;
-	hw_resource_list_t *hw_res_list = &dev_data->hw_resources;
+void pci_add_interrupt(pci_fun_t *fun, int irq)
+{
+	hw_resource_list_t *hw_res_list = &fun->hw_resources;
 	hw_resource_t *hw_resources = hw_res_list->resources;
 	size_t count = hw_res_list->count;
@@ -383,40 +383,40 @@
 	hw_res_list->count++;
 	
-	printf(NAME ": device %s uses irq %x.\n", dev->name, irq);
-}
-
-void pci_read_interrupt(device_t *dev)
-{
-	uint8_t irq = pci_conf_read_8(dev, PCI_BRIDGE_INT_LINE);
+	printf(NAME ": function %s uses irq %x.\n", fun->fnode->name, irq);
+}
+
+void pci_read_interrupt(pci_fun_t *fun)
+{
+	uint8_t irq = pci_conf_read_8(fun, PCI_BRIDGE_INT_LINE);
 	if (irq != 0xff)
-		pci_add_interrupt(dev, irq);
+		pci_add_interrupt(fun, irq);
 }
 
 /** Enumerate (recursively) and register the devices connected to a pci bus.
  *
- * @param parent	The host-to-pci bridge device.
- * @param bus_num	The bus number.
+ * @param bus		Host-to-PCI bridge
+ * @param bus_num	Bus number
  */
-void pci_bus_scan(device_t *parent, int bus_num) 
-{
-	device_t *dev = create_device();
-	pci_dev_data_t *dev_data = create_pci_dev_data();
-	dev->driver_data = dev_data;
-	dev->parent = parent;
+void pci_bus_scan(pci_bus_t *bus, int bus_num) 
+{
+	ddf_fun_t *fnode;
+	pci_fun_t *fun;
 	
 	int child_bus = 0;
 	int dnum, fnum;
 	bool multi;
-	uint8_t header_type; 
+	uint8_t header_type;
+	
+	fun = pci_fun_new(bus);
 	
 	for (dnum = 0; dnum < 32; dnum++) {
 		multi = true;
 		for (fnum = 0; multi && fnum < 8; fnum++) {
-			init_pci_dev_data(dev_data, bus_num, dnum, fnum);
-			dev_data->vendor_id = pci_conf_read_16(dev,
+			pci_fun_init(fun, bus_num, dnum, fnum);
+			fun->vendor_id = pci_conf_read_16(fun,
 			    PCI_VENDOR_ID);
-			dev_data->device_id = pci_conf_read_16(dev,
+			fun->device_id = pci_conf_read_16(fun,
 			    PCI_DEVICE_ID);
-			if (dev_data->vendor_id == 0xffff) {
+			if (fun->vendor_id == 0xffff) {
 				/*
 				 * The device is not present, go on scanning the
@@ -429,5 +429,5 @@
 			}
 			
-			header_type = pci_conf_read_8(dev, PCI_HEADER_TYPE);
+			header_type = pci_conf_read_8(fun, PCI_HEADER_TYPE);
 			if (fnum == 0) {
 				/* Is the device multifunction? */
@@ -437,22 +437,36 @@
 			header_type = header_type & 0x7F;
 			
-			create_pci_dev_name(dev);
-			
-			pci_alloc_resource_list(dev);
-			pci_read_bars(dev);
-			pci_read_interrupt(dev);
-			
-			dev->ops = &pci_child_ops;
-			
-			printf(NAME ": adding new child device %s.\n",
-			    dev->name);
-			
-			create_pci_match_ids(dev);
-			
-			if (child_device_register(dev, parent) != EOK) {
-				pci_clean_resource_list(dev);
-				clean_match_ids(&dev->match_ids);
-				free((char *) dev->name);
-				dev->name = NULL;
+			char *fun_name = pci_fun_create_name(fun);
+			if (fun_name == NULL) {
+				printf(NAME ": out of memory.\n");
+				return;
+			}
+			
+			fnode = ddf_fun_create(bus->dnode, fun_inner, fun_name);
+			if (fnode == NULL) {
+				printf(NAME ": error creating function.\n");
+				return;
+			}
+			
+			free(fun_name);
+			fun->fnode = fnode;
+			
+			pci_alloc_resource_list(fun);
+			pci_read_bars(fun);
+			pci_read_interrupt(fun);
+			
+			fnode->ops = &pci_fun_ops;
+			fnode->driver_data = fun;
+			
+			printf(NAME ": adding new function %s.\n",
+			    fnode->name);
+			
+			pci_fun_create_match_ids(fun);
+			
+			if (ddf_fun_bind(fnode) != EOK) {
+				pci_clean_resource_list(fun);
+				clean_match_ids(&fnode->match_ids);
+				free((char *) fnode->name);
+				fnode->name = NULL;
 				continue;
 			}
@@ -460,58 +474,59 @@
 			if (header_type == PCI_HEADER_TYPE_BRIDGE ||
 			    header_type == PCI_HEADER_TYPE_CARDBUS) {
-				child_bus = pci_conf_read_8(dev,
+				child_bus = pci_conf_read_8(fun,
 				    PCI_BRIDGE_SEC_BUS_NUM);
 				printf(NAME ": device is pci-to-pci bridge, "
 				    "secondary bus number = %d.\n", bus_num);
 				if (child_bus > bus_num)
-					pci_bus_scan(parent, child_bus);
+					pci_bus_scan(bus, child_bus);
 			}
 			
-			/* Alloc new aux. dev. structure. */
-			dev = create_device();
-			dev_data = create_pci_dev_data();
-			dev->driver_data = dev_data;
-			dev->parent = parent;
+			fun = pci_fun_new(bus);
 		}
 	}
 	
-	if (dev_data->vendor_id == 0xffff) {
-		delete_device(dev);
-		/* Free the auxiliary device structure. */
-		delete_pci_dev_data(dev_data);
-	}
-}
-
-static int pci_add_device(device_t *dev)
-{
+	if (fun->vendor_id == 0xffff) {
+		/* Free the auxiliary function structure. */
+		pci_fun_delete(fun);
+	}
+}
+
+static int pci_add_device(ddf_dev_t *dnode)
+{
+	pci_bus_t *bus = NULL;
+	ddf_fun_t *ctl = NULL;
+	bool got_res = false;
 	int rc;
-
+	
 	printf(NAME ": pci_add_device\n");
-	
-	pci_bus_data_t *bus_data = create_pci_bus_data();
-	if (bus_data == NULL) {
+	dnode->parent_phone = -1;
+	
+	bus = pci_bus_new();
+	if (bus == NULL) {
 		printf(NAME ": pci_add_device allocation failed.\n");
-		return ENOMEM;
-	}
-	
-	dev->parent_phone = devman_parent_device_connect(dev->handle,
+		rc = ENOMEM;
+		goto fail;
+	}
+	bus->dnode = dnode;
+	dnode->driver_data = bus;
+	
+	dnode->parent_phone = devman_parent_device_connect(dnode->handle,
 	    IPC_FLAG_BLOCKING);
-	if (dev->parent_phone < 0) {
+	if (dnode->parent_phone < 0) {
 		printf(NAME ": pci_add_device failed to connect to the "
 		    "parent's driver.\n");
-		delete_pci_bus_data(bus_data);
-		return dev->parent_phone;
+		rc = dnode->parent_phone;
+		goto fail;
 	}
 	
 	hw_resource_list_t hw_resources;
 	
-	rc = hw_res_get_resource_list(dev->parent_phone, &hw_resources);
+	rc = hw_res_get_resource_list(dnode->parent_phone, &hw_resources);
 	if (rc != EOK) {
 		printf(NAME ": pci_add_device failed to get hw resources for "
 		    "the device.\n");
-		delete_pci_bus_data(bus_data);
-		async_hangup(dev->parent_phone);
-		return rc;
-	}	
+		goto fail;
+	}
+	got_res = true;
 	
 	printf(NAME ": conf_addr = %" PRIx64 ".\n",
@@ -522,92 +537,113 @@
 	assert(hw_resources.resources[0].res.io_range.size == 8);
 	
-	bus_data->conf_io_addr =
+	bus->conf_io_addr =
 	    (uint32_t) hw_resources.resources[0].res.io_range.address;
 	
-	if (pio_enable((void *)(uintptr_t)bus_data->conf_io_addr, 8,
-	    &bus_data->conf_addr_port)) {
+	if (pio_enable((void *)(uintptr_t)bus->conf_io_addr, 8,
+	    &bus->conf_addr_port)) {
 		printf(NAME ": failed to enable configuration ports.\n");
-		delete_pci_bus_data(bus_data);
-		async_hangup(dev->parent_phone);
+		rc = EADDRNOTAVAIL;
+		goto fail;
+	}
+	bus->conf_data_port = (char *) bus->conf_addr_port + 4;
+	
+	/* Make the bus device more visible. It has no use yet. */
+	printf(NAME ": adding a 'ctl' function\n");
+	
+	ctl = ddf_fun_create(bus->dnode, fun_exposed, "ctl");
+	if (ctl == NULL) {
+		printf(NAME ": error creating control function.\n");
+		rc = ENOMEM;
+		goto fail;
+	}
+	
+	rc = ddf_fun_bind(ctl);
+	if (rc != EOK) {
+		printf(NAME ": error binding control function.\n");
+		goto fail;
+	}
+	
+	/* Enumerate functions. */
+	printf(NAME ": scanning the bus\n");
+	pci_bus_scan(bus, 0);
+	
+	hw_res_clean_resource_list(&hw_resources);
+	
+	return EOK;
+	
+fail:
+	if (bus != NULL)
+		pci_bus_delete(bus);
+	if (dnode->parent_phone >= 0)
+		async_hangup(dnode->parent_phone);
+	if (got_res)
 		hw_res_clean_resource_list(&hw_resources);
-		return EADDRNOTAVAIL;
-	}
-	bus_data->conf_data_port = (char *) bus_data->conf_addr_port + 4;
-	
-	dev->driver_data = bus_data;
-	
-	/* Enumerate child devices. */
-	printf(NAME ": scanning the bus\n");
-	pci_bus_scan(dev, 0);
-	
-	hw_res_clean_resource_list(&hw_resources);
-	
-	return EOK;
+	if (ctl != NULL)
+		ddf_fun_destroy(ctl);
+
+	return rc;
 }
 
 static void pciintel_init(void)
 {
-	pci_child_ops.interfaces[HW_RES_DEV_IFACE] = &pciintel_child_hw_res_ops;
-}
-
-pci_dev_data_t *create_pci_dev_data(void)
-{
-	pci_dev_data_t *res = (pci_dev_data_t *) malloc(sizeof(pci_dev_data_t));
-	
-	if (res != NULL)
-		memset(res, 0, sizeof(pci_dev_data_t));
-	return res;
-}
-
-void init_pci_dev_data(pci_dev_data_t *dev_data, int bus, int dev, int fn)
-{
-	dev_data->bus = bus;
-	dev_data->dev = dev;
-	dev_data->fn = fn;
-}
-
-void delete_pci_dev_data(pci_dev_data_t *dev_data)
-{
-	if (dev_data != NULL) {
-		hw_res_clean_resource_list(&dev_data->hw_resources);
-		free(dev_data);
-	}
-}
-
-void create_pci_dev_name(device_t *dev)
-{
-	pci_dev_data_t *dev_data = (pci_dev_data_t *) dev->driver_data;
+	pci_fun_ops.interfaces[HW_RES_DEV_IFACE] = &pciintel_hw_res_ops;
+}
+
+pci_fun_t *pci_fun_new(pci_bus_t *bus)
+{
+	pci_fun_t *fun;
+	
+	fun = (pci_fun_t *) calloc(1, sizeof(pci_fun_t));
+	if (fun == NULL)
+		return NULL;
+
+	fun->busptr = bus;
+	return fun;
+}
+
+void pci_fun_init(pci_fun_t *fun, int bus, int dev, int fn)
+{
+	fun->bus = bus;
+	fun->dev = dev;
+	fun->fn = fn;
+}
+
+void pci_fun_delete(pci_fun_t *fun)
+{
+	assert(fun != NULL);
+	hw_res_clean_resource_list(&fun->hw_resources);
+	free(fun);
+}
+
+char *pci_fun_create_name(pci_fun_t *fun)
+{
 	char *name = NULL;
 	
-	asprintf(&name, "%02x:%02x.%01x", dev_data->bus, dev_data->dev,
-	    dev_data->fn);
-	dev->name = name;
-}
-
-bool pci_alloc_resource_list(device_t *dev)
-{
-	pci_dev_data_t *dev_data = (pci_dev_data_t *)dev->driver_data;
-	
-	dev_data->hw_resources.resources =
+	asprintf(&name, "%02x:%02x.%01x", fun->bus, fun->dev,
+	    fun->fn);
+	return name;
+}
+
+bool pci_alloc_resource_list(pci_fun_t *fun)
+{
+	fun->hw_resources.resources =
 	    (hw_resource_t *) malloc(PCI_MAX_HW_RES * sizeof(hw_resource_t));
-	return dev_data->hw_resources.resources != NULL;
-}
-
-void pci_clean_resource_list(device_t *dev)
-{
-	pci_dev_data_t *dev_data = (pci_dev_data_t *) dev->driver_data;
-	
-	if (dev_data->hw_resources.resources != NULL) {
-		free(dev_data->hw_resources.resources);
-		dev_data->hw_resources.resources = NULL;
-	}
-}
-
-/** Read the base address registers (BARs) of the device and adds the addresses
- * to its hw resource list.
+	return fun->hw_resources.resources != NULL;
+}
+
+void pci_clean_resource_list(pci_fun_t *fun)
+{
+	if (fun->hw_resources.resources != NULL) {
+		free(fun->hw_resources.resources);
+		fun->hw_resources.resources = NULL;
+	}
+}
+
+/** Read the base address registers (BARs) of the function and add the addresses
+ * to its HW resource list.
  *
- * @param dev the pci device.
+ * @param fun	PCI function
  */
-void pci_read_bars(device_t *dev)
+void pci_read_bars(pci_fun_t *fun)
 {
 	/*
@@ -618,5 +654,5 @@
 	
 	while (addr <= PCI_BASE_ADDR_5)
-		addr = pci_read_bar(dev, addr);
+		addr = pci_read_bar(fun, addr);
 }
 
@@ -630,5 +666,5 @@
 	printf(NAME ": HelenOS pci bus driver (intel method 1).\n");
 	pciintel_init();
-	return driver_main(&pci_driver);
+	return ddf_driver_main(&pci_driver);
 }
 
Index: uspace/drv/pciintel/pci.h
===================================================================
--- uspace/drv/pciintel/pci.h	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/pciintel/pci.h	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -1,4 +1,5 @@
 /*
  * Copyright (c) 2010 Lenka Trochtova
+ * Copyright (c) 2011 Jiri Svoboda
  * All rights reserved.
  *
@@ -36,13 +37,22 @@
 #define PCI_H_
 
-#include <stdlib.h>
-#include <driver.h>
-#include <malloc.h>
-
+#include <ddf/driver.h>
 #include "pci_regs.h"
 
 #define PCI_MAX_HW_RES 8
 
-typedef struct pci_dev_data {
+typedef struct pciintel_bus {
+	/** DDF device node */
+	ddf_dev_t *dnode;
+	uint32_t conf_io_addr;
+	void *conf_data_port;
+	void *conf_addr_port;
+	fibril_mutex_t conf_mutex;
+} pci_bus_t;
+
+typedef struct pci_fun_data {
+	pci_bus_t *busptr;
+	ddf_fun_t *fnode;
+
 	int bus;
 	int dev;
@@ -51,31 +61,31 @@
 	int device_id;
 	hw_resource_list_t hw_resources;
-} pci_dev_data_t;
+} pci_fun_t;
 
-extern void create_pci_match_ids(device_t *);
+extern void pci_fun_create_match_ids(pci_fun_t *);
 
-extern uint8_t pci_conf_read_8(device_t *, int);
-extern uint16_t pci_conf_read_16(device_t *, int);
-extern uint32_t pci_conf_read_32(device_t *, int);
-extern void pci_conf_write_8(device_t *, int, uint8_t);
-extern void pci_conf_write_16(device_t *, int, uint16_t);
-extern void pci_conf_write_32(device_t *, int, uint32_t);
+extern uint8_t pci_conf_read_8(pci_fun_t *, int);
+extern uint16_t pci_conf_read_16(pci_fun_t *, int);
+extern uint32_t pci_conf_read_32(pci_fun_t *, int);
+extern void pci_conf_write_8(pci_fun_t *, int, uint8_t);
+extern void pci_conf_write_16(pci_fun_t *, int, uint16_t);
+extern void pci_conf_write_32(pci_fun_t *, int, uint32_t);
 
-extern void pci_add_range(device_t *, uint64_t, size_t, bool);
-extern int pci_read_bar(device_t *, int);
-extern void pci_read_interrupt(device_t *);
-extern void pci_add_interrupt(device_t *, int);
+extern void pci_add_range(pci_fun_t *, uint64_t, size_t, bool);
+extern int pci_read_bar(pci_fun_t *, int);
+extern void pci_read_interrupt(pci_fun_t *);
+extern void pci_add_interrupt(pci_fun_t *, int);
 
-extern void pci_bus_scan(device_t *, int);
+extern pci_fun_t *pci_fun_new(pci_bus_t *);
+extern void pci_fun_init(pci_fun_t *, int, int, int);
+extern void pci_fun_delete(pci_fun_t *);
+extern char *pci_fun_create_name(pci_fun_t *);
 
-extern pci_dev_data_t *create_pci_dev_data(void);
-extern void init_pci_dev_data(pci_dev_data_t *, int, int, int);
-extern void delete_pci_dev_data(pci_dev_data_t *);
-extern void create_pci_dev_name(device_t *);
+extern void pci_bus_scan(pci_bus_t *, int);
 
-extern bool pci_alloc_resource_list(device_t *);
-extern void pci_clean_resource_list(device_t *);
+extern bool pci_alloc_resource_list(pci_fun_t *);
+extern void pci_clean_resource_list(pci_fun_t *);
 
-extern void pci_read_bars(device_t *);
+extern void pci_read_bars(pci_fun_t *);
 extern size_t pci_bar_mask_to_size(uint32_t);
 
Index: uspace/drv/root/root.c
===================================================================
--- uspace/drv/root/root.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/root/root.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -2,4 +2,5 @@
  * Copyright (c) 2010 Lenka Trochtova
  * Copyright (c) 2010 Vojtech Horky
+ * Copyright (c) 2011 Jiri Svoboda
  * All rights reserved.
  *
@@ -44,4 +45,5 @@
 #include <stdlib.h>
 #include <str.h>
+#include <str_error.h>
 #include <ctype.h>
 #include <macros.h>
@@ -49,5 +51,5 @@
 #include <sysinfo.h>
 
-#include <driver.h>
+#include <ddf/driver.h>
 #include <devman.h>
 #include <ipc/devman.h>
@@ -55,13 +57,13 @@
 #define NAME "root"
 
-#define PLATFORM_DEVICE_NAME "hw"
-#define PLATFORM_DEVICE_MATCH_ID_FMT "platform/%s"
-#define PLATFORM_DEVICE_MATCH_SCORE 100
-
-#define VIRTUAL_DEVICE_NAME "virt"
-#define VIRTUAL_DEVICE_MATCH_ID "rootvirt"
-#define VIRTUAL_DEVICE_MATCH_SCORE 100
-
-static int root_add_device(device_t *dev);
+#define PLATFORM_FUN_NAME "hw"
+#define PLATFORM_FUN_MATCH_ID_FMT "platform/%s"
+#define PLATFORM_FUN_MATCH_SCORE 100
+
+#define VIRTUAL_FUN_NAME "virt"
+#define VIRTUAL_FUN_MATCH_ID "rootvirt"
+#define VIRTUAL_FUN_MATCH_SCORE 100
+
+static int root_add_device(ddf_dev_t *dev);
 
 /** The root device driver's standard operations. */
@@ -76,36 +78,60 @@
 };
 
-/** Create the device which represents the root of virtual device tree.
- *
- * @param parent Parent of the newly created device.
- * @return Error code.
- */
-static int add_virtual_root_child(device_t *parent)
-{
-	printf(NAME ": adding new child for virtual devices.\n");
-	printf(NAME ":   device node is `%s' (%d %s)\n", VIRTUAL_DEVICE_NAME,
-	    VIRTUAL_DEVICE_MATCH_SCORE, VIRTUAL_DEVICE_MATCH_ID);
-
-	int res = child_device_register_wrapper(parent, VIRTUAL_DEVICE_NAME,
-	    VIRTUAL_DEVICE_MATCH_ID, VIRTUAL_DEVICE_MATCH_SCORE,
-	    NULL);
-
-	return res;
-}
-
-/** Create the device which represents the root of HW device tree.
- *
- * @param parent	Parent of the newly created device.
- * @return 0 on success, negative error number otherwise.
- */
-static int add_platform_child(device_t *parent)
+/** Create the function which represents the root of virtual device tree.
+ *
+ * @param dev	Device
+ * @return	EOK on success or negative error code
+ */
+static int add_virtual_root_fun(ddf_dev_t *dev)
+{
+	const char *name = VIRTUAL_FUN_NAME;
+	ddf_fun_t *fun;
+	int rc;
+
+	printf(NAME ": adding new function for virtual devices.\n");
+	printf(NAME ":   function node is `%s' (%d %s)\n", name,
+	    VIRTUAL_FUN_MATCH_SCORE, VIRTUAL_FUN_MATCH_ID);
+
+	fun = ddf_fun_create(dev, fun_inner, name);
+	if (fun == NULL) {
+		printf(NAME ": error creating function %s\n", name);
+		return ENOMEM;
+	}
+
+	rc = ddf_fun_add_match_id(fun, VIRTUAL_FUN_MATCH_ID,
+	    VIRTUAL_FUN_MATCH_SCORE);
+	if (rc != EOK) {
+		printf(NAME ": error adding match IDs to function %s\n", name);
+		ddf_fun_destroy(fun);
+		return rc;
+	}
+
+	rc = ddf_fun_bind(fun);
+	if (rc != EOK) {
+		printf(NAME ": error binding function %s: %s\n", name,
+		    str_error(rc));
+		ddf_fun_destroy(fun);
+		return rc;
+	}
+
+	return EOK;
+}
+
+/** Create the function which represents the root of HW device tree.
+ *
+ * @param dev	Device
+ * @return	EOK on success or negative error code
+ */
+static int add_platform_fun(ddf_dev_t *dev)
 {
 	char *match_id;
 	char *platform;
 	size_t platform_size;
-	int res;
+
+	const char *name = PLATFORM_FUN_NAME;
+	ddf_fun_t *fun;
+	int rc;
 
 	/* Get platform name from sysinfo. */
-
 	platform = sysinfo_get_data("platform", &platform_size);
 	if (platform == NULL) {
@@ -124,20 +150,36 @@
 
 	/* Construct match ID. */
-
-	if (asprintf(&match_id, PLATFORM_DEVICE_MATCH_ID_FMT, platform) == -1) {
+	if (asprintf(&match_id, PLATFORM_FUN_MATCH_ID_FMT, platform) == -1) {
 		printf(NAME ": Memory allocation failed.\n");
 		return ENOMEM;
 	}
 
-	/* Add child. */
-
-	printf(NAME ": adding new child for platform device.\n");
-	printf(NAME ":   device node is `%s' (%d %s)\n", PLATFORM_DEVICE_NAME,
-	    PLATFORM_DEVICE_MATCH_SCORE, match_id);
-
-	res = child_device_register_wrapper(parent, PLATFORM_DEVICE_NAME,
-	    match_id, PLATFORM_DEVICE_MATCH_SCORE, NULL);
-
-	return res;
+	/* Add function. */
+	printf(NAME ": adding platform function\n");
+	printf(NAME ":   function node is `%s' (%d %s)\n", PLATFORM_FUN_NAME,
+	    PLATFORM_FUN_MATCH_SCORE, match_id);
+
+	fun = ddf_fun_create(dev, fun_inner, name);
+	if (fun == NULL) {
+		printf(NAME ": error creating function %s\n", name);
+		return ENOMEM;
+	}
+
+	rc = ddf_fun_add_match_id(fun, match_id, PLATFORM_FUN_MATCH_SCORE);
+	if (rc != EOK) {
+		printf(NAME ": error adding match IDs to function %s\n", name);
+		ddf_fun_destroy(fun);
+		return rc;
+	}
+
+	rc = ddf_fun_bind(fun);
+	if (rc != EOK) {
+		printf(NAME ": error binding function %s: %s\n", name,
+		    str_error(rc));
+		ddf_fun_destroy(fun);
+		return rc;
+	}
+
+	return EOK;
 }
 
@@ -147,9 +189,9 @@
  *			of HW and pseudo devices).
  */
-static int root_add_device(device_t *dev)
+static int root_add_device(ddf_dev_t *dev)
 {
 	printf(NAME ": root_add_device, device handle=%" PRIun "\n",
 	    dev->handle);
-	
+
 	/*
 	 * Register virtual devices root.
@@ -157,11 +199,11 @@
 	 * vital for the system.
 	 */
-	add_virtual_root_child(dev);
+	add_virtual_root_fun(dev);
 
 	/* Register root device's children. */
-	int res = add_platform_child(dev);
+	int res = add_platform_fun(dev);
 	if (EOK != res)
 		printf(NAME ": failed to add child device for platform.\n");
-	
+
 	return res;
 }
@@ -170,5 +212,5 @@
 {
 	printf(NAME ": HelenOS root device driver\n");
-	return driver_main(&root_driver);
+	return ddf_driver_main(&root_driver);
 }
 
Index: uspace/drv/rootpc/rootpc.c
===================================================================
--- uspace/drv/rootpc/rootpc.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/rootpc/rootpc.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -46,5 +46,5 @@
 #include <macros.h>
 
-#include <driver.h>
+#include <ddf/driver.h>
 #include <devman.h>
 #include <ipc/devman.h>
@@ -55,9 +55,12 @@
 #define NAME "rootpc"
 
-typedef struct rootpc_child_dev_data {
+/** Obtain function soft-state from DDF function node */
+#define ROOTPC_FUN(fnode) ((rootpc_fun_t *) (fnode)->driver_data)
+
+typedef struct rootpc_fun {
 	hw_resource_list_t hw_resources;
-} rootpc_child_dev_data_t;
-
-static int rootpc_add_device(device_t *dev);
+} rootpc_fun_t;
+
+static int rootpc_add_device(ddf_dev_t *dev);
 static void root_pc_init(void);
 
@@ -82,5 +85,5 @@
 };
 
-static rootpc_child_dev_data_t pci_data = {
+static rootpc_fun_t pci_data = {
 	.hw_resources = {
 		1,
@@ -89,16 +92,13 @@
 };
 
-static hw_resource_list_t *rootpc_get_child_resources(device_t *dev)
-{
-	rootpc_child_dev_data_t *data;
-	
-	data = (rootpc_child_dev_data_t *) dev->driver_data;
-	if (NULL == data)
-		return NULL;
-	
-	return &data->hw_resources;
-}
-
-static bool rootpc_enable_child_interrupt(device_t *dev)
+static hw_resource_list_t *rootpc_get_resources(ddf_fun_t *fnode)
+{
+	rootpc_fun_t *fun = ROOTPC_FUN(fnode);
+	
+	assert(fun != NULL);
+	return &fun->hw_resources;
+}
+
+static bool rootpc_enable_interrupt(ddf_fun_t *fun)
 {
 	/* TODO */
@@ -107,64 +107,63 @@
 }
 
-static hw_res_ops_t child_hw_res_ops = {
-	&rootpc_get_child_resources,
-	&rootpc_enable_child_interrupt
+static hw_res_ops_t fun_hw_res_ops = {
+	&rootpc_get_resources,
+	&rootpc_enable_interrupt
 };
 
 /* Initialized in root_pc_init() function. */
-static device_ops_t rootpc_child_ops;
+static ddf_dev_ops_t rootpc_fun_ops;
 
 static bool
-rootpc_add_child(device_t *parent, const char *name, const char *str_match_id,
-    rootpc_child_dev_data_t *drv_data)
-{
-	printf(NAME ": adding new child device '%s'.\n", name);
-	
-	device_t *child = NULL;
+rootpc_add_fun(ddf_dev_t *dev, const char *name, const char *str_match_id,
+    rootpc_fun_t *fun)
+{
+	printf(NAME ": adding new function '%s'.\n", name);
+	
+	ddf_fun_t *fnode = NULL;
 	match_id_t *match_id = NULL;
 	
 	/* Create new device. */
-	child = create_device();
-	if (NULL == child)
+	fnode = ddf_fun_create(dev, fun_inner, name);
+	if (fnode == NULL)
 		goto failure;
 	
-	child->name = name;
-	child->driver_data = drv_data;
+	fnode->driver_data = fun;
 	
 	/* Initialize match id list */
 	match_id = create_match_id();
-	if (NULL == match_id)
+	if (match_id == NULL)
 		goto failure;
 	
 	match_id->id = str_match_id;
 	match_id->score = 100;
-	add_match_id(&child->match_ids, match_id);
+	add_match_id(&fnode->match_ids, match_id);
 	
 	/* Set provided operations to the device. */
-	child->ops = &rootpc_child_ops;
-	
-	/* Register child device. */
-	if (EOK != child_device_register(child, parent))
+	fnode->ops = &rootpc_fun_ops;
+	
+	/* Register function. */
+	if (ddf_fun_bind(fnode) != EOK) {
+		printf(NAME ": error binding function %s.\n", name);
 		goto failure;
+	}
 	
 	return true;
 	
 failure:
-	if (NULL != match_id)
+	if (match_id != NULL)
 		match_id->id = NULL;
 	
-	if (NULL != child) {
-		child->name = NULL;
-		delete_device(child);
-	}
-	
-	printf(NAME ": failed to add child device '%s'.\n", name);
+	if (fnode != NULL)
+		ddf_fun_destroy(fnode);
+	
+	printf(NAME ": failed to add function '%s'.\n", name);
 	
 	return false;
 }
 
-static bool rootpc_add_children(device_t *dev)
-{
-	return rootpc_add_child(dev, "pci0", "intel_pci", &pci_data);
+static bool rootpc_add_functions(ddf_dev_t *dev)
+{
+	return rootpc_add_fun(dev, "pci0", "intel_pci", &pci_data);
 }
 
@@ -175,12 +174,12 @@
  * @return		Zero on success, negative error number otherwise.
  */
-static int rootpc_add_device(device_t *dev)
+static int rootpc_add_device(ddf_dev_t *dev)
 {
 	printf(NAME ": rootpc_add_device, device handle = %d\n",
 	    (int)dev->handle);
 	
-	/* Register child devices. */
-	if (!rootpc_add_children(dev)) {
-		printf(NAME ": failed to add child devices for PC platform.\n");
+	/* Register functions. */
+	if (!rootpc_add_functions(dev)) {
+		printf(NAME ": failed to add functions for PC platform.\n");
 	}
 	
@@ -190,5 +189,5 @@
 static void root_pc_init(void)
 {
-	rootpc_child_ops.interfaces[HW_RES_DEV_IFACE] = &child_hw_res_ops;
+	rootpc_fun_ops.interfaces[HW_RES_DEV_IFACE] = &fun_hw_res_ops;
 }
 
@@ -197,5 +196,5 @@
 	printf(NAME ": HelenOS PC platform driver\n");
 	root_pc_init();
-	return driver_main(&rootpc_driver);
+	return ddf_driver_main(&rootpc_driver);
 }
 
Index: uspace/drv/rootvirt/rootvirt.c
===================================================================
--- uspace/drv/rootvirt/rootvirt.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/rootvirt/rootvirt.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -39,20 +39,20 @@
 #include <errno.h>
 #include <str_error.h>
-#include <driver.h>
+#include <ddf/driver.h>
 
 #define NAME "rootvirt"
 
-/** Virtual device entry. */
+/** Virtual function entry */
 typedef struct {
-	/** Device name. */
+	/** Function name */
 	const char *name;
-	/** Device match id. */
+	/** Function match ID */
 	const char *match_id;
-} virtual_device_t;
+} virtual_function_t;
 
-/** List of existing virtual devices. */
-virtual_device_t virtual_devices[] = {
+/** List of existing virtual functions */
+virtual_function_t virtual_functions[] = {
 #include "devices.def"
-	/* Terminating item. */
+	/* Terminating item */
 	{
 		.name = NULL,
@@ -61,8 +61,8 @@
 };
 
-static int add_device(device_t *dev);
+static int rootvirt_add_device(ddf_dev_t *dev);
 
 static driver_ops_t rootvirt_ops = {
-	.add_device = &add_device
+	.add_device = &rootvirt_add_device
 };
 
@@ -72,30 +72,45 @@
 };
 
-/** Add child device.
+/** Add function to the virtual device.
  *
- * @param parent Parent device.
- * @param virt_dev Virtual device to add.
- * @return Error code.
+ * @param vdev		The virtual device
+ * @param vfun		Virtual function description
+ * @return		EOK on success or negative error code.
  */
-static int add_child(device_t *parent, virtual_device_t *virt_dev)
+static int rootvirt_add_fun(ddf_dev_t *vdev, virtual_function_t *vfun)
 {
-	printf(NAME ": registering child device `%s' (match \"%s\")\n",
-	    virt_dev->name, virt_dev->match_id);
+	ddf_fun_t *fun;
+	int rc;
 
-	int rc = child_device_register_wrapper(parent, virt_dev->name,
-	    virt_dev->match_id, 10, NULL);
+	printf(NAME ": registering function `%s' (match \"%s\")\n",
+	    vfun->name, vfun->match_id);
 
-	if (rc == EOK) {
-		printf(NAME ": registered child device `%s'\n",
-		    virt_dev->name);
-	} else {
-		printf(NAME ": failed to register child device `%s': %s\n",
-		    virt_dev->name, str_error(rc));
+	fun = ddf_fun_create(vdev, fun_inner, vfun->name);
+	if (fun == NULL) {
+		printf(NAME ": error creating function %s\n", vfun->name);
+		return ENOMEM;
 	}
 
-	return rc;
+	rc = ddf_fun_add_match_id(fun, vfun->match_id, 10);
+	if (rc != EOK) {
+		printf(NAME ": error adding match IDs to function %s\n",
+		    vfun->name);
+		ddf_fun_destroy(fun);
+		return rc;
+	}
+
+	rc = ddf_fun_bind(fun);
+	if (rc != EOK) {
+		printf(NAME ": error binding function %s: %s\n", vfun->name,
+		    str_error(rc));
+		ddf_fun_destroy(fun);
+		return rc;
+	}
+
+	printf(NAME ": registered child device `%s'\n", vfun->name);
+	return EOK;
 }
 
-static int add_device(device_t *dev)
+static int rootvirt_add_device(ddf_dev_t *dev)
 {
 	static int instances = 0;
@@ -109,15 +124,14 @@
 	}
 
-	printf(NAME ": add_device(name=\"%s\", handle=%d)\n",
-	    dev->name, (int)dev->handle);
-	
+	printf(NAME ": add_device(handle=%d)\n", (int)dev->handle);
+
 	/*
-	 * Go through all virtual devices and try to add them.
+	 * Go through all virtual functions and try to add them.
 	 * We silently ignore failures.
 	 */
-	virtual_device_t *virt_dev = virtual_devices;
-	while (virt_dev->name != NULL) {
-		(void) add_child(dev, virt_dev);
-		virt_dev++;
+	virtual_function_t *vfun = virtual_functions;
+	while (vfun->name != NULL) {
+		(void) rootvirt_add_fun(dev, vfun);
+		vfun++;
 	}
 
@@ -128,5 +142,5 @@
 {
 	printf(NAME ": HelenOS virtual devices root driver\n");
-	return driver_main(&rootvirt_driver);
+	return ddf_driver_main(&rootvirt_driver);
 }
 
Index: uspace/drv/test1/char.c
===================================================================
--- uspace/drv/test1/char.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/test1/char.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -37,10 +37,10 @@
 #include "test1.h"
 
-static int impl_char_read(device_t *dev, char *buf, size_t count) {
+static int impl_char_read(ddf_fun_t *fun, char *buf, size_t count) {
 	memset(buf, 0, count);
 	return count;
 }
 
-static int imp_char_write(device_t *dev, char *buf, size_t count) {
+static int imp_char_write(ddf_fun_t *fun, char *buf, size_t count) {
 	return count;
 }
@@ -51,5 +51,5 @@
 };
 
-device_ops_t char_device_ops = {
+ddf_dev_ops_t char_device_ops = {
 	.interfaces[CHAR_DEV_IFACE] = &char_dev_ops
 };
Index: uspace/drv/test1/test1.c
===================================================================
--- uspace/drv/test1/test1.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/test1/test1.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -34,13 +34,15 @@
 #include <errno.h>
 #include <str_error.h>
+#include <ddf/driver.h>
+
 #include "test1.h"
 
-static int add_device(device_t *dev);
+static int test1_add_device(ddf_dev_t *dev);
 
 static driver_ops_t driver_ops = {
-	.add_device = &add_device
+	.add_device = &test1_add_device
 };
 
-static driver_t the_driver = {
+static driver_t test1_driver = {
 	.name = NAME,
 	.driver_ops = &driver_ops
@@ -55,19 +57,35 @@
  * @param score Device match score.
  */
-static void register_child_verbose(device_t *parent, const char *message,
+static int register_fun_verbose(ddf_dev_t *parent, const char *message,
     const char *name, const char *match_id, int match_score)
 {
-	printf(NAME ": registering child device `%s': %s.\n",
-	   name, message);
+	ddf_fun_t *fun;
+	int rc;
 
-	int rc = child_device_register_wrapper(parent, name,
-	    match_id, match_score, NULL);
+	printf(NAME ": registering function `%s': %s.\n", name, message);
 
-	if (rc == EOK) {
-		printf(NAME ": registered child device `%s'.\n", name);
-	} else {
-		printf(NAME ": failed to register child `%s' (%s).\n",
-		    name, str_error(rc));
+	fun = ddf_fun_create(parent, fun_inner, name);
+	if (fun == NULL) {
+		printf(NAME ": error creating function %s\n", name);
+		return ENOMEM;
 	}
+
+	rc = ddf_fun_add_match_id(fun, match_id, match_score);
+	if (rc != EOK) {
+		printf(NAME ": error adding match IDs to function %s\n", name);
+		ddf_fun_destroy(fun);
+		return rc;
+	}
+
+	rc = ddf_fun_bind(fun);
+	if (rc != EOK) {
+		printf(NAME ": error binding function %s: %s\n", name,
+		    str_error(rc));
+		ddf_fun_destroy(fun);
+		return rc;
+	}
+
+	printf(NAME ": registered child device `%s'\n", name);
+	return EOK;
 }
 
@@ -89,19 +107,34 @@
  * @return Error code reporting success of the operation.
  */
-static int add_device(device_t *dev)
+static int test1_add_device(ddf_dev_t *dev)
 {
+	ddf_fun_t *fun_a;
+	int rc;
+
 	printf(NAME ": add_device(name=\"%s\", handle=%d)\n",
 	    dev->name, (int) dev->handle);
 
-	add_device_to_class(dev, "virtual");
+	fun_a = ddf_fun_create(dev, fun_exposed, "a");
+	if (fun_a == NULL) {
+		printf(NAME ": error creating function 'a'.\n");
+		return ENOMEM;
+	}
+
+	rc = ddf_fun_bind(fun_a);
+	if (rc != EOK) {
+		printf(NAME ": error binding function 'a'.\n");
+		return rc;
+	}
+
+	ddf_fun_add_to_class(fun_a, "virtual");
 
 	if (str_cmp(dev->name, "null") == 0) {
-		dev->ops = &char_device_ops;
-		add_device_to_class(dev, "virt-null");
-	} else if (dev->parent == NULL) {
-		register_child_verbose(dev, "cloning myself ;-)", "clone",
+		fun_a->ops = &char_device_ops;
+		ddf_fun_add_to_class(fun_a, "virt-null");
+	} else if (str_cmp(dev->name, "test1") == 0) {
+		(void) register_fun_verbose(dev, "cloning myself ;-)", "clone",
 		    "virtual&test1", 10);
 	} else if (str_cmp(dev->name, "clone") == 0) {
-		register_child_verbose(dev, "run by the same task", "child",
+		(void) register_fun_verbose(dev, "run by the same task", "child",
 		    "virtual&test1&child", 10);
 	}
@@ -115,5 +148,5 @@
 {
 	printf(NAME ": HelenOS test1 virtual device driver\n");
-	return driver_main(&the_driver);
+	return ddf_driver_main(&test1_driver);
 }
 
Index: uspace/drv/test1/test1.h
===================================================================
--- uspace/drv/test1/test1.h	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/test1/test1.h	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -32,9 +32,9 @@
 #define DRV_TEST1_TEST1_H_
 
-#include <driver.h>
+#include <ddf/driver.h>
 
 #define NAME "test1"
 
-extern device_ops_t char_device_ops;
+extern ddf_dev_ops_t char_device_ops;
 
 #endif
Index: uspace/drv/test2/test2.c
===================================================================
--- uspace/drv/test2/test2.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/test2/test2.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -31,18 +31,19 @@
 
 #include <assert.h>
+#include <async.h>
 #include <stdio.h>
 #include <errno.h>
 #include <str_error.h>
-#include <driver.h>
+#include <ddf/driver.h>
 
 #define NAME "test2"
 
-static int add_device(device_t *dev);
+static int test2_add_device(ddf_dev_t *dev);
 
 static driver_ops_t driver_ops = {
-	.add_device = &add_device
+	.add_device = &test2_add_device
 };
 
-static driver_t the_driver = {
+static driver_t test2_driver = {
 	.name = NAME,
 	.driver_ops = &driver_ops
@@ -57,49 +58,78 @@
  * @param score Device match score.
  */
-static void register_child_verbose(device_t *parent, const char *message,
+static int register_fun_verbose(ddf_dev_t *parent, const char *message,
     const char *name, const char *match_id, int match_score)
 {
-	printf(NAME ": registering child device `%s': %s.\n",
-	   name, message);
+	ddf_fun_t *fun;
+	int rc;
 
-	int rc = child_device_register_wrapper(parent, name,
-	    match_id, match_score, NULL);
+	printf(NAME ": registering function `%s': %s.\n", name, message);
 
-	if (rc == EOK) {
-		printf(NAME ": registered child device `%s'.\n", name);
-	} else {
-		printf(NAME ": failed to register child `%s' (%s).\n",
-		    name, str_error(rc));
+	fun = ddf_fun_create(parent, fun_inner, name);
+	if (fun == NULL) {
+		printf(NAME ": error creating function %s\n", name);
+		return ENOMEM;
 	}
+
+	rc = ddf_fun_add_match_id(fun, match_id, match_score);
+	if (rc != EOK) {
+		printf(NAME ": error adding match IDs to function %s\n", name);
+		ddf_fun_destroy(fun);
+		return rc;
+	}
+
+	rc = ddf_fun_bind(fun);
+	if (rc != EOK) {
+		printf(NAME ": error binding function %s: %s\n", name,
+		    str_error(rc));
+		ddf_fun_destroy(fun);
+		return rc;
+	}
+
+	printf(NAME ": registered child device `%s'\n", name);
+	return EOK;
 }
 
 /** Add child devices after some sleep.
  *
- * @param arg Parent device structure (device_t *).
+ * @param arg Parent device structure (ddf_dev_t *).
  * @return Always EOK.
  */
 static int postponed_birth(void *arg)
 {
-	device_t *dev = (device_t *) arg;
+	ddf_dev_t *dev = (ddf_dev_t *) arg;
+	ddf_fun_t *fun_a;
+	int rc;
 
 	async_usleep(1000);
 
-	register_child_verbose(dev, "child driven by the same task",
+	(void) register_fun_verbose(dev, "child driven by the same task",
 	    "child", "virtual&test2", 10);
-	register_child_verbose(dev, "child driven by test1",
+	(void) register_fun_verbose(dev, "child driven by test1",
 	    "test1", "virtual&test1", 10);
 
-	add_device_to_class(dev, "virtual");
+	fun_a = ddf_fun_create(dev, fun_exposed, "a");
+	if (fun_a == NULL) {
+		printf(NAME ": error creating function 'a'.\n");
+		return ENOMEM;
+	}
+
+	rc = ddf_fun_bind(fun_a);
+	if (rc != EOK) {
+		printf(NAME ": error binding function 'a'.\n");
+		return rc;
+	}
+
+	ddf_fun_add_to_class(fun_a, "virtual");
 
 	return EOK;
 }
 
-
-static int add_device(device_t *dev)
+static int test2_add_device(ddf_dev_t *dev)
 {
-	printf(NAME ": add_device(name=\"%s\", handle=%d)\n",
+	printf(NAME ": test2_add_device(name=\"%s\", handle=%d)\n",
 	    dev->name, (int) dev->handle);
 
-	if (dev->parent == NULL) {
+	if (str_cmp(dev->name, "child") != 0) {
 		fid_t postpone = fibril_create(postponed_birth, dev);
 		if (postpone == 0) {
@@ -109,5 +139,5 @@
 		fibril_add_ready(postpone);
 	} else {
-		register_child_verbose(dev, "child without available driver",
+		(void) register_fun_verbose(dev, "child without available driver",
 		    "ERROR", "non-existent.match.id", 10);
 	}
@@ -119,5 +149,5 @@
 {
 	printf(NAME ": HelenOS test2 virtual device driver\n");
-	return driver_main(&the_driver);
+	return ddf_driver_main(&test2_driver);
 }
 
Index: uspace/drv/uhci-hcd/batch.c
===================================================================
--- uspace/drv/uhci-hcd/batch.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/uhci-hcd/batch.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -51,5 +51,5 @@
 
 
-batch_t * batch_get(device_t *dev, usb_target_t target,
+batch_t * batch_get(ddf_fun_t *fun, usb_target_t target,
     usb_transfer_type_t transfer_type, size_t max_packet_size,
     dev_speed_t speed, char *buffer, size_t size,
@@ -128,5 +128,5 @@
 	instance->buffer_size = size;
 	instance->setup_size = setup_size;
-	instance->dev = dev;
+	instance->fun = fun;
 	instance->arg = arg;
 	instance->speed = speed;
@@ -291,5 +291,5 @@
 	    err, instance->transfered_size);
 
-	instance->callback_in(instance->dev,
+	instance->callback_in(instance->fun,
 	    err, instance->transfered_size,
 	    instance->arg);
@@ -303,5 +303,5 @@
 	int err = instance->error;
 	usb_log_info("Callback OUT(%d): %d.\n", instance->transfer_type, err);
-	instance->callback_out(instance->dev,
+	instance->callback_out(instance->fun,
 	    err, instance->arg);
 }
@@ -334,5 +334,5 @@
 {
 	assert(instance);
-	uhci_t *hc = dev_to_uhci(instance->dev);
+	uhci_t *hc = fun_to_uhci(instance->fun);
 	assert(hc);
 	return uhci_schedule(hc, instance);
Index: uspace/drv/uhci-hcd/batch.h
===================================================================
--- uspace/drv/uhci-hcd/batch.h	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/uhci-hcd/batch.h	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -68,5 +68,5 @@
 	size_t transfered_size;
 	int error;
-	device_t *dev;
+	ddf_fun_t *fun;
 	queue_head_t *qh;
 	transfer_descriptor_t *tds;
@@ -74,5 +74,5 @@
 } batch_t;
 
-batch_t * batch_get(device_t *dev, usb_target_t target,
+batch_t * batch_get(ddf_fun_t *fun, usb_target_t target,
     usb_transfer_type_t transfer_type, size_t max_packet_size,
     dev_speed_t speed, char *buffer, size_t size,
Index: uspace/drv/uhci-hcd/iface.c
===================================================================
--- uspace/drv/uhci-hcd/iface.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/uhci-hcd/iface.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -32,5 +32,5 @@
  * @brief UHCI driver
  */
-#include <driver.h>
+#include <ddf/driver.h>
 #include <remote_usbhc.h>
 
@@ -43,8 +43,8 @@
 
 /*----------------------------------------------------------------------------*/
-static int reserve_default_address(device_t *dev, usb_speed_t speed)
+static int reserve_default_address(ddf_fun_t *fun, usb_speed_t speed)
 {
-	assert(dev);
-	uhci_t *hc = dev_to_uhci(dev);
+	assert(fun);
+	uhci_t *hc = fun_to_uhci(fun);
 	assert(hc);
 	usb_address_keeping_reserve_default(&hc->address_manager);
@@ -52,8 +52,8 @@
 }
 /*----------------------------------------------------------------------------*/
-static int release_default_address(device_t *dev)
+static int release_default_address(ddf_fun_t *fun)
 {
-	assert(dev);
-	uhci_t *hc = dev_to_uhci(dev);
+	assert(fun);
+	uhci_t *hc = fun_to_uhci(fun);
 	assert(hc);
 	usb_address_keeping_release_default(&hc->address_manager);
@@ -61,9 +61,9 @@
 }
 /*----------------------------------------------------------------------------*/
-static int request_address(device_t *dev, usb_speed_t speed,
+static int request_address(ddf_fun_t *fun, usb_speed_t speed,
     usb_address_t *address)
 {
-	assert(dev);
-	uhci_t *hc = dev_to_uhci(dev);
+	assert(fun);
+	uhci_t *hc = fun_to_uhci(fun);
 	assert(hc);
 	*address = usb_address_keeping_request(&hc->address_manager);
@@ -74,8 +74,8 @@
 /*----------------------------------------------------------------------------*/
 static int bind_address(
-  device_t *dev, usb_address_t address, devman_handle_t handle)
+  ddf_fun_t *fun, usb_address_t address, devman_handle_t handle)
 {
-	assert(dev);
-	uhci_t *hc = dev_to_uhci(dev);
+	assert(fun);
+	uhci_t *hc = fun_to_uhci(fun);
 	assert(hc);
 	usb_address_keeping_devman_bind(&hc->address_manager, address, handle);
@@ -83,8 +83,8 @@
 }
 /*----------------------------------------------------------------------------*/
-static int release_address(device_t *dev, usb_address_t address)
+static int release_address(ddf_fun_t *fun, usb_address_t address)
 {
-	assert(dev);
-	uhci_t *hc = dev_to_uhci(dev);
+	assert(fun);
+	uhci_t *hc = fun_to_uhci(fun);
 	assert(hc);
 	usb_address_keeping_release_default(&hc->address_manager);
@@ -92,5 +92,5 @@
 }
 /*----------------------------------------------------------------------------*/
-static int interrupt_out(device_t *dev, usb_target_t target,
+static int interrupt_out(ddf_fun_t *fun, usb_target_t target,
     size_t max_packet_size,
     void *data, size_t size,
@@ -99,5 +99,5 @@
 	dev_speed_t speed = FULL_SPEED;
 
-	batch_t *batch = batch_get(dev, target, USB_TRANSFER_INTERRUPT,
+	batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT,
 	    max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg);
 	if (!batch)
@@ -107,5 +107,5 @@
 }
 /*----------------------------------------------------------------------------*/
-static int interrupt_in(device_t *dev, usb_target_t target,
+static int interrupt_in(ddf_fun_t *fun, usb_target_t target,
     size_t max_packet_size,
     void *data, size_t size,
@@ -114,5 +114,5 @@
 	dev_speed_t speed = FULL_SPEED;
 
-	batch_t *batch = batch_get(dev, target, USB_TRANSFER_INTERRUPT,
+	batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT,
 	    max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg);
 	if (!batch)
@@ -122,5 +122,5 @@
 }
 /*----------------------------------------------------------------------------*/
-static int control_write(device_t *dev, usb_target_t target,
+static int control_write(ddf_fun_t *fun, usb_target_t target,
     size_t max_packet_size,
     void *setup_data, size_t setup_size, void *data, size_t size,
@@ -129,5 +129,5 @@
 	dev_speed_t speed = FULL_SPEED;
 
-	batch_t *batch = batch_get(dev, target, USB_TRANSFER_CONTROL,
+	batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL,
 	    max_packet_size, speed, data, size, setup_data, setup_size,
 	    NULL, callback, arg);
@@ -138,5 +138,5 @@
 }
 /*----------------------------------------------------------------------------*/
-static int control_read(device_t *dev, usb_target_t target,
+static int control_read(ddf_fun_t *fun, usb_target_t target,
     size_t max_packet_size,
     void *setup_data, size_t setup_size, void *data, size_t size,
@@ -145,5 +145,5 @@
 	dev_speed_t speed = FULL_SPEED;
 
-	batch_t *batch = batch_get(dev, target, USB_TRANSFER_CONTROL,
+	batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL,
 	    max_packet_size, speed, data, size, setup_data, setup_size, callback,
 	    NULL, arg);
Index: uspace/drv/uhci-hcd/iface.h
===================================================================
--- uspace/drv/uhci-hcd/iface.h	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/uhci-hcd/iface.h	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -38,5 +38,5 @@
 #include <usbhc_iface.h>
 
-usbhc_iface_t uhci_iface;
+extern usbhc_iface_t uhci_iface;
 
 #endif
Index: uspace/drv/uhci-hcd/main.c
===================================================================
--- uspace/drv/uhci-hcd/main.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/uhci-hcd/main.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -32,5 +32,6 @@
  * @brief UHCI driver
  */
-#include <driver.h>
+#include <ddf/driver.h>
+#include <ddf/interrupt.h>
 #include <usb_iface.h>
 #include <usb/ddfiface.h>
@@ -48,36 +49,6 @@
 #define NAME "uhci-hcd"
 
-static int uhci_add_device(device_t *device);
+static int uhci_add_device(ddf_dev_t *device);
 
-static int usb_iface_get_address(device_t *dev, devman_handle_t handle,
-    usb_address_t *address)
-{
-	assert(dev);
-	uhci_t *hc = dev_to_uhci(dev);
-	assert(hc);
-
-	usb_address_t addr = usb_address_keeping_find(&hc->address_manager,
-	    handle);
-	if (addr < 0) {
-		return addr;
-	}
-
-	if (address != NULL) {
-		*address = addr;
-	}
-
-	return EOK;
-}
-
-
-static usb_iface_t hc_usb_iface = {
-	.get_hc_handle = usb_iface_get_hc_handle_hc_impl,
-	.get_address = usb_iface_get_address
-};
-/*----------------------------------------------------------------------------*/
-static device_ops_t uhci_ops = {
-	.interfaces[USB_DEV_IFACE] = &hc_usb_iface,
-	.interfaces[USBHC_DEV_IFACE] = &uhci_iface
-};
 /*----------------------------------------------------------------------------*/
 static driver_ops_t uhci_driver_ops = {
@@ -90,8 +61,8 @@
 };
 /*----------------------------------------------------------------------------*/
-static void irq_handler(device_t *device, ipc_callid_t iid, ipc_call_t *call)
+static void irq_handler(ddf_dev_t *dev, ipc_callid_t iid, ipc_call_t *call)
 {
-	assert(device);
-	uhci_t *hc = dev_to_uhci(device);
+	assert(dev);
+	uhci_t *hc = dev_to_uhci(dev);
 	uint16_t status = IPC_GET_ARG1(*call);
 	assert(hc);
@@ -105,10 +76,10 @@
 }
 
-static int uhci_add_device(device_t *device)
+static int uhci_add_device(ddf_dev_t *device)
 {
 	assert(device);
 
 	usb_log_info("uhci_add_device() called\n");
-	device->ops = &uhci_ops;
+
 
 	uintptr_t io_reg_base;
@@ -131,5 +102,5 @@
 	CHECK_RET_RETURN(ret, "Failed to allocate memory for uhci hcd driver.\n");
 
-	ret = uhci_init(uhci_hc, (void*)io_reg_base, io_reg_size);
+	ret = uhci_init(uhci_hc, device, (void*)io_reg_base, io_reg_size);
 	if (ret != EOK) {
 		usb_log_error("Failed to init uhci-hcd.\n");
@@ -137,4 +108,10 @@
 		return ret;
 	}
+
+	/*
+	 * We might free uhci_hc, but that does not matter since no one
+	 * else would access driver_data anyway.
+	 */
+	device->driver_data = uhci_hc;
 
 	ret = register_interrupt_handler(device, irq, irq_handler,
@@ -147,5 +124,5 @@
 	}
 
-	device_t *rh;
+	ddf_fun_t *rh;
 	ret = setup_root_hub(&rh, device);
 	if (ret != EOK) {
@@ -155,6 +132,7 @@
 		return ret;
 	}
+	rh->driver_data = uhci_hc->ddf_instance;
 
-	ret = child_device_register(rh, device);
+	ret = ddf_fun_bind(rh);
 	if (ret != EOK) {
 		usb_log_error("Failed to register root hub.\n");
@@ -165,5 +143,4 @@
 	}
 
-	device->driver_data = uhci_hc;
 	return EOK;
 }
@@ -172,7 +149,7 @@
 {
 	sleep(3);
-	usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
+	usb_log_enable(USB_LOG_LEVEL_INFO, NAME);
 
-	return driver_main(&uhci_driver);
+	return ddf_driver_main(&uhci_driver);
 }
 /**
Index: uspace/drv/uhci-hcd/pci.c
===================================================================
--- uspace/drv/uhci-hcd/pci.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/uhci-hcd/pci.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -49,5 +49,5 @@
  * @return Error code.
  */
-int pci_get_my_registers(device_t *dev,
+int pci_get_my_registers(ddf_dev_t *dev,
     uintptr_t *io_reg_address, size_t *io_reg_size,
     int *irq_no)
@@ -122,5 +122,5 @@
 }
 /*----------------------------------------------------------------------------*/
-int pci_enable_interrupts(device_t *device)
+int pci_enable_interrupts(ddf_dev_t *device)
 {
 	int parent_phone = devman_parent_device_connect(device->handle,
Index: uspace/drv/uhci-hcd/pci.h
===================================================================
--- uspace/drv/uhci-hcd/pci.h	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/uhci-hcd/pci.h	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -36,8 +36,8 @@
 #define DRV_UHCI_PCI_H
 
-#include <driver.h>
+#include <ddf/driver.h>
 
-int pci_get_my_registers(device_t *, uintptr_t *, size_t *, int *);
-int pci_enable_interrupts(device_t *device);
+int pci_get_my_registers(ddf_dev_t *, uintptr_t *, size_t *, int *);
+int pci_enable_interrupts(ddf_dev_t *);
 
 #endif
Index: uspace/drv/uhci-hcd/root_hub.c
===================================================================
--- uspace/drv/uhci-hcd/root_hub.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/uhci-hcd/root_hub.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -39,20 +39,57 @@
 
 #include "root_hub.h"
+#include "uhci.h"
 
-extern device_ops_t child_ops;
+static int usb_iface_get_hc_handle_rh_impl(ddf_fun_t *root_hub_fun,
+    devman_handle_t *handle)
+{
+	ddf_fun_t *hc_fun = root_hub_fun->driver_data;
+	assert(hc_fun != NULL);
+
+	*handle = hc_fun->handle;
+
+	return EOK;
+}
+
+static int usb_iface_get_address_rh_impl(ddf_fun_t *fun, devman_handle_t handle,
+    usb_address_t *address)
+{
+	assert(fun);
+	ddf_fun_t *hc_fun = fun->driver_data;
+	assert(hc_fun);
+	uhci_t *hc = fun_to_uhci(hc_fun);
+	assert(hc);
+
+	usb_address_t addr = usb_address_keeping_find(&hc->address_manager,
+	    handle);
+	if (addr < 0) {
+		return addr;
+	}
+
+	if (address != NULL) {
+		*address = addr;
+	}
+
+	return EOK;
+}
+
+usb_iface_t usb_iface_root_hub_fun_impl = {
+	.get_hc_handle = usb_iface_get_hc_handle_rh_impl,
+	.get_address = usb_iface_get_address_rh_impl
+};
+
+static ddf_dev_ops_t root_hub_ops = {
+	.interfaces[USB_DEV_IFACE] = &usb_iface_root_hub_fun_impl
+};
+
 /*----------------------------------------------------------------------------*/
-int setup_root_hub(device_t **device, device_t *hc)
+int setup_root_hub(ddf_fun_t **fun, ddf_dev_t *hc)
 {
-	assert(device);
-	device_t *hub = create_device();
+	assert(fun);
+	int ret;
+
+	ddf_fun_t *hub = ddf_fun_create(hc, fun_inner, "root-hub");
 	if (!hub) {
 		usb_log_error("Failed to create root hub device structure.\n");
-		return ENOMEM;
-	}
-	char *name;
-	int ret = asprintf(&name, "UHCI Root Hub");
-	if (ret < 0) {
-		usb_log_error("Failed to create root hub name.\n");
-		free(hub);
 		return ENOMEM;
 	}
@@ -62,25 +99,18 @@
 	if (ret < 0) {
 		usb_log_error("Failed to create root hub match string.\n");
-		free(hub);
-		free(name);
+		ddf_fun_destroy(hub);
 		return ENOMEM;
 	}
 
-	match_id_t *match_id = create_match_id();
-	if (!match_id) {
-		usb_log_error("Failed to create root hub match id.\n");
-		free(hub);
-		free(match_str);
+	ret = ddf_fun_add_match_id(hub, match_str, 100);
+	if (ret != EOK) {
+		usb_log_error("Failed to add root hub match id.\n");
+		ddf_fun_destroy(hub);
 		return ENOMEM;
 	}
-	match_id->id = match_str;
-	match_id->score = 90;
 
-	add_match_id(&hub->match_ids, match_id);
-	hub->name = name;
-	hub->parent = hc;
-	hub->ops = &child_ops;
+	hub->ops = &root_hub_ops;
 
-	*device = hub;
+	*fun = hub;
 	return EOK;
 }
Index: uspace/drv/uhci-hcd/root_hub.h
===================================================================
--- uspace/drv/uhci-hcd/root_hub.h	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/uhci-hcd/root_hub.h	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -36,7 +36,7 @@
 #define DRV_UHCI_ROOT_HUB_H
 
-#include <driver.h>
+#include <ddf/driver.h>
 
-int setup_root_hub(device_t **device, device_t *hc);
+int setup_root_hub(ddf_fun_t **device, ddf_dev_t *hc);
 
 #endif
Index: uspace/drv/uhci-hcd/uhci.c
===================================================================
--- uspace/drv/uhci-hcd/uhci.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/uhci-hcd/uhci.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -33,10 +33,16 @@
  */
 #include <errno.h>
+#include <str_error.h>
 #include <adt/list.h>
+#include <libarch/ddi.h>
 
 #include <usb/debug.h>
 #include <usb/usb.h>
+#include <usb/ddfiface.h>
+#include <usb_iface.h>
 
 #include "uhci.h"
+#include "iface.h"
+
 static irq_cmd_t uhci_cmds[] = {
 	{
@@ -55,4 +61,35 @@
 };
 
+static int usb_iface_get_address(ddf_fun_t *fun, devman_handle_t handle,
+    usb_address_t *address)
+{
+	assert(fun);
+	uhci_t *hc = fun_to_uhci(fun);
+	assert(hc);
+
+	usb_address_t addr = usb_address_keeping_find(&hc->address_manager,
+	    handle);
+	if (addr < 0) {
+		return addr;
+	}
+
+	if (address != NULL) {
+		*address = addr;
+	}
+
+	return EOK;
+}
+
+
+static usb_iface_t hc_usb_iface = {
+	.get_hc_handle = usb_iface_get_hc_handle_hc_impl,
+	.get_address = usb_iface_get_address
+};
+/*----------------------------------------------------------------------------*/
+static ddf_dev_ops_t uhci_ops = {
+	.interfaces[USB_DEV_IFACE] = &hc_usb_iface,
+	.interfaces[USBHC_DEV_IFACE] = &uhci_iface
+};
+
 static int uhci_init_transfer_lists(uhci_t *instance);
 static int uhci_init_mem_structures(uhci_t *instance);
@@ -71,11 +108,27 @@
 	} else (void) 0
 
-int uhci_init(uhci_t *instance, void *regs, size_t reg_size)
+int uhci_init(uhci_t *instance, ddf_dev_t *dev, void *regs, size_t reg_size)
 {
 	assert(reg_size >= sizeof(regs_t));
+	int ret;
+
+	/*
+	 * Create UHCI function.
+	 */
+	instance->ddf_instance = ddf_fun_create(dev, fun_exposed, "uhci");
+	if (instance->ddf_instance == NULL) {
+		usb_log_error("Failed to create UHCI device function.\n");
+		return ENOMEM;
+	}
+	instance->ddf_instance->ops = &uhci_ops;
+	instance->ddf_instance->driver_data = instance;
+
+	ret = ddf_fun_bind(instance->ddf_instance);
+	CHECK_RET_RETURN(ret, "Failed to bind UHCI device function: %s.\n",
+	    str_error(ret));
 
 	/* allow access to hc control registers */
 	regs_t *io;
-	int ret = pio_enable(regs, reg_size, (void**)&io);
+	ret = pio_enable(regs, reg_size, (void**)&io);
 	CHECK_RET_RETURN(ret, "Failed to gain access to registers at %p.\n", io);
 	instance->registers = io;
Index: uspace/drv/uhci-hcd/uhci.h
===================================================================
--- uspace/drv/uhci-hcd/uhci.h	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/uhci-hcd/uhci.h	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -39,4 +39,5 @@
 #include <fibril_synch.h>
 #include <adt/list.h>
+#include <ddi.h>
 
 #include <usb/addrkeep.h>
@@ -97,8 +98,10 @@
 	fid_t cleaner;
 	fid_t debug_checker;
+
+	ddf_fun_t *ddf_instance;
 } uhci_t;
 
 /* init uhci specifics in device.driver_data */
-int uhci_init(uhci_t *instance, void *regs, size_t reg_size);
+int uhci_init(uhci_t *instance, ddf_dev_t *dev, void *regs, size_t reg_size);
 
 static inline void uhci_fini(uhci_t *instance) {};
@@ -108,6 +111,9 @@
 void uhci_interrupt(uhci_t *instance, uint16_t status);
 
-static inline uhci_t * dev_to_uhci(device_t *dev)
+static inline uhci_t * dev_to_uhci(ddf_dev_t *dev)
 	{ return (uhci_t*)dev->driver_data; }
+
+static inline uhci_t * fun_to_uhci(ddf_fun_t *fun)
+	{ return (uhci_t*)fun->driver_data; }
 
 
Index: uspace/drv/uhci-rhd/main.c
===================================================================
--- uspace/drv/uhci-rhd/main.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/uhci-rhd/main.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -32,5 +32,5 @@
  * @brief UHCI driver
  */
-#include <driver.h>
+#include <ddf/driver.h>
 #include <usb_iface.h>
 #include <usb/ddfiface.h>
@@ -44,12 +44,11 @@
 #define NAME "uhci-rhd"
 
-static int usb_iface_get_hc_handle(device_t *dev, devman_handle_t *handle)
+static int usb_iface_get_hc_handle(ddf_fun_t *fun, devman_handle_t *handle)
 {
-	assert(dev);
-	assert(dev->driver_data);
+	assert(fun);
+	assert(fun->driver_data);
 	assert(handle);
 
-	*handle = ((uhci_root_hub_t*)dev->driver_data)->hc_handle;
-	usb_log_debug("Answering HC handle: %d.\n", *handle);
+	*handle = ((uhci_root_hub_t*)fun->driver_data)->hc_handle;
 
 	return EOK;
@@ -61,9 +60,9 @@
 };
 
-static device_ops_t uhci_rh_ops = {
+static ddf_dev_ops_t uhci_rh_ops = {
 	.interfaces[USB_DEV_IFACE] = &uhci_rh_usb_iface,
 };
 
-static int uhci_rh_add_device(device_t *device)
+static int uhci_rh_add_device(ddf_dev_t *device)
 {
 	if (!device)
@@ -71,5 +70,7 @@
 
 	usb_log_debug2("%s called device %d\n", __FUNCTION__, device->handle);
-	device->ops = &uhci_rh_ops;
+
+	//device->ops = &uhci_rh_ops;
+	(void) uhci_rh_ops;
 
 	uhci_root_hub_t *rh = malloc(sizeof(uhci_root_hub_t));
@@ -104,6 +105,6 @@
 int main(int argc, char *argv[])
 {
-	usb_log_enable(USB_LOG_LEVEL_ERROR, NAME);
-	return driver_main(&uhci_rh_driver);
+	usb_log_enable(USB_LOG_LEVEL_INFO, NAME);
+	return ddf_driver_main(&uhci_rh_driver);
 }
 /**
Index: uspace/drv/uhci-rhd/port.c
===================================================================
--- uspace/drv/uhci-rhd/port.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/uhci-rhd/port.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -52,5 +52,5 @@
 int uhci_port_init(
   uhci_port_t *port, port_status_t *address, unsigned number,
-  unsigned usec, device_t *rh, int parent_phone)
+  unsigned usec, ddf_dev_t *rh, int parent_phone)
 {
 	assert(port);
@@ -187,5 +187,5 @@
 	    USB_SPEED_FULL,
 	    new_device_enable_port, port->number, port,
-	    &dev_addr, &port->attached_device);
+	    &dev_addr, &port->attached_device, NULL, NULL, NULL);
 	if (rc != EOK) {
 		usb_log_error("Failed adding new device on port %u: %s.\n",
Index: uspace/drv/uhci-rhd/port.h
===================================================================
--- uspace/drv/uhci-rhd/port.h	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/uhci-rhd/port.h	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -36,5 +36,5 @@
 
 #include <assert.h>
-#include <driver.h> /* device_t */
+#include <ddf/driver.h>
 #include <stdint.h>
 #include <usb/usbdevice.h>
@@ -48,5 +48,5 @@
 	unsigned wait_period_usec;
 	usb_hc_connection_t hc_connection;
-	device_t *rh;
+	ddf_dev_t *rh;
 	devman_handle_t attached_device;
 	fid_t checker;
@@ -55,5 +55,5 @@
 int uhci_port_init(
   uhci_port_t *port, port_status_t *address, unsigned number,
-  unsigned usec, device_t *rh, int parent_phone);
+  unsigned usec, ddf_dev_t *rh, int parent_phone);
 
 void uhci_port_fini(uhci_port_t *port);
Index: uspace/drv/uhci-rhd/root_hub.c
===================================================================
--- uspace/drv/uhci-rhd/root_hub.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/uhci-rhd/root_hub.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -34,5 +34,6 @@
 #include <errno.h>
 #include <stdint.h>
-
+#include <ddi.h>
+#include <devman.h>
 #include <usb/debug.h>
 
@@ -41,5 +42,5 @@
 
 int uhci_root_hub_init(
-  uhci_root_hub_t *instance, void *addr, size_t size, device_t *rh)
+  uhci_root_hub_t *instance, void *addr, size_t size, ddf_dev_t *rh)
 {
 	assert(instance);
Index: uspace/drv/uhci-rhd/root_hub.h
===================================================================
--- uspace/drv/uhci-rhd/root_hub.h	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/uhci-rhd/root_hub.h	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -36,5 +36,5 @@
 
 #include <fibril.h>
-#include <driver.h> /* for device_t */
+#include <ddf/driver.h>
 
 #include "port.h"
@@ -50,5 +50,5 @@
 
 int uhci_root_hub_init(
-  uhci_root_hub_t *instance, void *addr, size_t size, device_t *rh);
+  uhci_root_hub_t *instance, void *addr, size_t size, ddf_dev_t *rh);
 
 int uhci_root_hub_fini(uhci_root_hub_t *instance);
Index: uspace/drv/usbhid/descdump.c
===================================================================
--- uspace/drv/usbhid/descdump.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/usbhid/descdump.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -35,4 +35,6 @@
 
 #include <usb/classes/hid.h>
+#include <stdio.h>
+#include <assert.h>
 
 #include "descdump.h"
Index: uspace/drv/usbhid/descparser.c
===================================================================
--- uspace/drv/usbhid/descparser.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/usbhid/descparser.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -36,4 +36,5 @@
 #include <errno.h>
 #include <stdint.h>
+#include <stdio.h>
 #include <usb/usb.h>
 #include <usb/classes/hid.h>
Index: uspace/drv/usbhid/hid.h
===================================================================
--- uspace/drv/usbhid/hid.h	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/usbhid/hid.h	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -38,5 +38,5 @@
 
 #include <usb/classes/hid.h>
-#include <driver.h>
+#include <ddf/driver.h>
 #include <usb/pipes.h>
 
@@ -67,5 +67,5 @@
  */
 typedef struct {
-	device_t *device;
+	ddf_dev_t *device;
 	usb_hid_configuration_t *conf;
 	usb_hid_report_parser_t *parser;
Index: uspace/drv/usbhid/main.c
===================================================================
--- uspace/drv/usbhid/main.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/usbhid/main.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -36,5 +36,5 @@
  */
 
-#include <driver.h>
+#include <ddf/driver.h>
 #include <ipc/driver.h>
 #include <ipc/kbd.h>
@@ -72,6 +72,6 @@
 };
 
-static void default_connection_handler(device_t *, ipc_callid_t, ipc_call_t *);
-static device_ops_t keyboard_ops = {
+static void default_connection_handler(ddf_fun_t *, ipc_callid_t, ipc_call_t *);
+static ddf_dev_ops_t keyboard_ops = {
 	.default_handler = default_connection_handler
 };
@@ -85,5 +85,5 @@
  * @param icall Call data.
  */
-void default_connection_handler(device_t *dev,
+void default_connection_handler(ddf_fun_t *fun,
     ipc_callid_t icallid, ipc_call_t *icall)
 {
@@ -413,5 +413,5 @@
 }
 
-static usb_hid_dev_kbd_t *usbkbd_init_device(device_t *dev)
+static usb_hid_dev_kbd_t *usbkbd_init_device(ddf_dev_t *dev)
 {
 	int rc;
@@ -554,5 +554,5 @@
 	}
 
-	device_t *dev = (device_t *)arg;
+	ddf_dev_t *dev = (ddf_dev_t *)arg;
 
 	// initialize device (get and process descriptors, get address, etc.)
@@ -568,5 +568,5 @@
 }
 
-static int usbkbd_add_device(device_t *dev)
+static int usbkbd_add_device(ddf_dev_t *dev)
 {
 	/* For now, fail immediately. */
@@ -590,4 +590,17 @@
 
 	/*
+	 * Create default function.
+	 */
+	// FIXME - check for errors
+	ddf_fun_t *kbd_fun = ddf_fun_create(dev, fun_exposed, "keyboard");
+	assert(kbd_fun != NULL);
+	kbd_fun->ops = &keyboard_ops;
+
+	int rc = ddf_fun_bind(kbd_fun);
+	assert(rc == EOK);
+	rc = ddf_fun_add_to_class(kbd_fun, "keyboard");
+	assert(rc == EOK);
+
+	/*
 	 * Create new fibril for handling this keyboard
 	 */
@@ -599,7 +612,8 @@
 	fibril_add_ready(fid);
 
-	dev->ops = &keyboard_ops;
-
-	add_device_to_class(dev, "keyboard");
+	//dev->ops = &keyboard_ops;
+	(void)keyboard_ops;
+
+	//add_device_to_class(dev, "keyboard");
 
 	/*
@@ -621,5 +635,5 @@
 {
 	usb_log_enable(USB_LOG_LEVEL_INFO, "usbhid");
-	return driver_main(&kbd_driver);
+	return ddf_driver_main(&kbd_driver);
 }
 
Index: uspace/drv/usbhub/main.c
===================================================================
--- uspace/drv/usbhub/main.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/usbhub/main.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -31,5 +31,5 @@
  */
 
-#include <driver.h>
+#include <ddf/driver.h>
 #include <errno.h>
 #include <async.h>
@@ -62,5 +62,5 @@
 int main(int argc, char *argv[])
 {
-	usb_log_enable(USB_LOG_LEVEL_INFO, NAME);
+	usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
 	
 	fibril_mutex_initialize(&usb_hub_list_lock);
@@ -77,5 +77,5 @@
 	fibril_add_ready(fid);
 
-	return driver_main(&hub_driver);
+	return ddf_driver_main(&hub_driver);
 }
 
Index: uspace/drv/usbhub/usbhub.c
===================================================================
--- uspace/drv/usbhub/usbhub.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/usbhub/usbhub.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -33,5 +33,5 @@
  */
 
-#include <driver.h>
+#include <ddf/driver.h>
 #include <bool.h>
 #include <errno.h>
@@ -52,5 +52,5 @@
 #include "usb/classes/classes.h"
 
-static device_ops_t hub_device_ops = {
+static ddf_dev_ops_t hub_device_ops = {
 	.interfaces[USB_DEV_IFACE] = &usb_iface_hub_impl
 };
@@ -79,4 +79,5 @@
  */
 static int usb_hub_init_communication(usb_hub_info_t * hub){
+	usb_log_debug("Initializing hub USB communication (hub->device->handle=%zu).\n", hub->device->handle);
 	int opResult;
 	opResult = usb_device_connection_initialize_from_device(
@@ -88,4 +89,5 @@
 		return opResult;
 	}
+	usb_log_debug("Initializing USB wire abstraction.\n");
 	opResult = usb_hc_connection_initialize_from_device(&hub->connection,
 			hub->device);
@@ -95,4 +97,5 @@
 		return opResult;
 	}
+	usb_log_debug("Initializing default control pipe.\n");
 	opResult = usb_endpoint_pipe_initialize_default_control(&hub->endpoints.control,
             &hub->device_connection);
@@ -222,5 +225,5 @@
  * @return pointer to created structure or NULL in case of error
  */
-usb_hub_info_t * usb_create_hub_info(device_t * device) {
+usb_hub_info_t * usb_create_hub_info(ddf_dev_t * device) {
 	usb_hub_info_t* result = usb_new(usb_hub_info_t);
 	result->device = device;
@@ -291,8 +294,9 @@
  * @return
  */
-int usb_add_hub_device(device_t *dev) {
+int usb_add_hub_device(ddf_dev_t *dev) {
 	dprintf(USB_LOG_LEVEL_INFO, "add_hub_device(handle=%d)", (int) dev->handle);
 
-	dev->ops = &hub_device_ops;
+	//dev->ops = &hub_device_ops;
+	(void) hub_device_ops;
 
 	usb_hub_info_t * hub_info = usb_create_hub_info(dev);
@@ -450,5 +454,6 @@
 	//??
     opResult = usb_device_register_child_in_devman(new_device_address,
-            hub->connection.hc_handle, hub->device, &child_handle);
+            hub->connection.hc_handle, hub->device, &child_handle,
+            NULL, NULL, NULL);
 
 	if (opResult != EOK) {
Index: uspace/drv/usbhub/usbhub.h
===================================================================
--- uspace/drv/usbhub/usbhub.h	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/usbhub/usbhub.h	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -38,5 +38,5 @@
 #include <ipc/devman.h>
 #include <usb/usb.h>
-#include <driver.h>
+#include <ddf/driver.h>
 
 #define NAME "usbhub"
@@ -63,5 +63,5 @@
 	//usb_hcd_attached_device_info_t * usb_device;
 	/** General device info*/
-	device_t * device;
+	ddf_dev_t * device;
 	/** connection to hcd */
 	//usb_device_connection_t connection;
@@ -84,5 +84,5 @@
  * @return Error code.
  */
-int usb_add_hub_device(device_t *dev);
+int usb_add_hub_device(ddf_dev_t *dev);
 
 /**
Index: uspace/drv/usbhub/usbhub_private.h
===================================================================
--- uspace/drv/usbhub/usbhub_private.h	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/usbhub/usbhub_private.h	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -42,5 +42,5 @@
 #include <adt/list.h>
 #include <bool.h>
-#include <driver.h>
+#include <ddf/driver.h>
 #include <fibril_synch.h>
 
@@ -76,5 +76,5 @@
  * @return
  */
-usb_hub_info_t * usb_create_hub_info(device_t * device);
+usb_hub_info_t * usb_create_hub_info(ddf_dev_t * device);
 
 /** List of hubs maanged by this driver */
Index: uspace/drv/usbhub/utils.c
===================================================================
--- uspace/drv/usbhub/utils.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/usbhub/utils.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -33,5 +33,5 @@
  * @brief various utilities
  */
-#include <driver.h>
+#include <ddf/driver.h>
 #include <bool.h>
 #include <errno.h>
Index: uspace/drv/usbmid/main.c
===================================================================
--- uspace/drv/usbmid/main.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/usbmid/main.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -44,5 +44,5 @@
 #include "usbmid.h"
 
-static int usbmid_add_device(device_t *gen_dev)
+static int usbmid_add_device(ddf_dev_t *gen_dev)
 {
 	usbmid_device_t *dev = usbmid_device_create(gen_dev);
@@ -99,6 +99,6 @@
 	printf(NAME ": USB multi interface device driver.\n");
 
-	usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
-	return driver_main(&mid_driver);
+	usb_log_enable(USB_LOG_LEVEL_INFO, NAME);
+	return ddf_driver_main(&mid_driver);
 }
 
Index: uspace/drv/usbmid/usbmid.c
===================================================================
--- uspace/drv/usbmid/usbmid.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/usbmid/usbmid.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -45,34 +45,17 @@
 
 /** Callback for DDF USB interface. */
-static int usb_iface_get_address_impl(device_t *device, devman_handle_t handle,
+static int usb_iface_get_address_impl(ddf_fun_t *fun, devman_handle_t handle,
     usb_address_t *address)
 {
-	assert(device);
-	device_t *parent = device->parent;
-
-	/* Default error, device does not support this operation. */
-	int rc = ENOTSUP;
-
-	if (parent && parent->ops && parent->ops->interfaces[USB_DEV_IFACE]) {
-		usb_iface_t *usb_iface
-		    = (usb_iface_t *) parent->ops->interfaces[USB_DEV_IFACE];
-		assert(usb_iface != NULL);
-
-		if (usb_iface->get_address) {
-			rc = usb_iface->get_address(parent, parent->handle,
-			    address);
-		}
-	}
-
-	return rc;
+	return usb_iface_get_address_hub_impl(fun, handle, address);
 }
 
 /** Callback for DDF USB interface. */
-static int usb_iface_get_interface_impl(device_t *device, devman_handle_t handle,
+static int usb_iface_get_interface_impl(ddf_fun_t *fun, devman_handle_t handle,
     int *iface_no)
 {
-	assert(device);
-
-	usbmid_interface_t *iface = device->driver_data;
+	assert(fun);
+
+	usbmid_interface_t *iface = fun->driver_data;
 	assert(iface);
 
@@ -91,9 +74,9 @@
 
 
-static device_ops_t child_device_ops = {
+static ddf_dev_ops_t child_device_ops = {
 	.interfaces[USB_DEV_IFACE] = &child_usb_iface
 };
 
-static device_ops_t mid_device_ops = {
+static ddf_dev_ops_t mid_device_ops = {
 	.interfaces[USB_DEV_IFACE] = &usb_iface_hub_impl
 };
@@ -105,5 +88,5 @@
  * @retval NULL Error occured.
  */
-usbmid_device_t *usbmid_device_create(device_t *dev)
+usbmid_device_t *usbmid_device_create(ddf_dev_t *dev)
 {
 	usbmid_device_t *mid = malloc(sizeof(usbmid_device_t));
@@ -133,5 +116,5 @@
 
 	mid->dev = dev;
-	dev->ops = &mid_device_ops;
+	(void) &mid_device_ops;
 
 	return mid;
@@ -145,5 +128,5 @@
  * @retval NULL Error occured.
  */
-usbmid_interface_t *usbmid_interface_create(device_t *dev, int iface_no)
+usbmid_interface_t *usbmid_interface_create(ddf_fun_t *fun, int iface_no)
 {
 	usbmid_interface_t *iface = malloc(sizeof(usbmid_interface_t));
@@ -154,5 +137,5 @@
 	}
 
-	iface->dev = dev;
+	iface->fun = fun;
 	iface->interface_no = iface_no;
 
@@ -172,15 +155,8 @@
     const usb_standard_interface_descriptor_t *interface_descriptor)
 {
-	device_t *child = NULL;
+	ddf_fun_t *child = NULL;
 	char *child_name = NULL;
 	usbmid_interface_t *child_as_interface = NULL;
 	int rc;
-
-	/* Create the device. */
-	child = create_device();
-	if (child == NULL) {
-		rc = ENOMEM;
-		goto error_leave;
-	}
 
 	/*
@@ -196,4 +172,13 @@
 	}
 
+	/* Create the device. */
+	child = ddf_fun_create(parent->dev, fun_inner, child_name);
+	if (child == NULL) {
+		rc = ENOMEM;
+		goto error_leave;
+	}
+
+
+
 	child_as_interface = usbmid_interface_create(child,
 	    (int) interface_descriptor->interface_number);
@@ -204,6 +189,4 @@
 
 	child->driver_data = child_as_interface;
-	child->parent = parent->dev;
-	child->name = child_name;
 	child->ops = &child_device_ops;
 
@@ -215,5 +198,5 @@
 	}
 
-	rc = child_device_register(child, parent->dev);
+	rc = ddf_fun_bind(child);
 	if (rc != EOK) {
 		goto error_leave;
@@ -226,5 +209,5 @@
 		child->name = NULL;
 		/* This takes care of match_id deallocation as well. */
-		delete_device(child);
+		ddf_fun_destroy(child);
 	}
 	if (child_name != NULL) {
Index: uspace/drv/usbmid/usbmid.h
===================================================================
--- uspace/drv/usbmid/usbmid.h	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/usbmid/usbmid.h	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -37,5 +37,5 @@
 #define USBMID_H_
 
-#include <driver.h>
+#include <ddf/driver.h>
 #include <usb/usb.h>
 #include <usb/pipes.h>
@@ -46,5 +46,5 @@
 typedef struct {
 	/** Device container. */
-	device_t *dev;
+	ddf_dev_t *dev;
 
 	/** Representation of USB wire. */
@@ -55,6 +55,6 @@
 
 typedef struct {
-	/** Device container. */
-	device_t *dev;
+	/** Function container. */
+	ddf_fun_t *fun;
 
 	/** Interface number. */
@@ -62,6 +62,6 @@
 } usbmid_interface_t;
 
-usbmid_device_t *usbmid_device_create(device_t *);
-usbmid_interface_t *usbmid_interface_create(device_t *, int);
+usbmid_device_t *usbmid_device_create(ddf_dev_t *);
+usbmid_interface_t *usbmid_interface_create(ddf_fun_t *, int);
 bool usbmid_explore_device(usbmid_device_t *);
 int usbmid_spawn_interface_child(usbmid_device_t *,
Index: uspace/drv/vhc/conn.h
===================================================================
--- uspace/drv/vhc/conn.h	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/vhc/conn.h	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -46,10 +46,11 @@
 extern usbhc_iface_t vhc_iface;
 extern usb_iface_t vhc_usb_iface;
+extern usb_iface_t rh_usb_iface;
 
 void address_init(void);
 
 
-void default_connection_handler(device_t *, ipc_callid_t, ipc_call_t *);
-void on_client_close(device_t *);
+void default_connection_handler(ddf_fun_t *, ipc_callid_t, ipc_call_t *);
+void on_client_close(ddf_fun_t *);
 
 
Index: uspace/drv/vhc/conndev.c
===================================================================
--- uspace/drv/vhc/conndev.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/vhc/conndev.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -76,9 +76,9 @@
 /** Default handler for IPC methods not handled by DDF.
  *
- * @param dev Device handling the call.
+ * @param fun Device handling the call.
  * @param icallid Call id.
  * @param icall Call data.
  */
-void default_connection_handler(device_t *dev,
+void default_connection_handler(ddf_fun_t *fun,
     ipc_callid_t icallid, ipc_call_t *icall)
 {
@@ -112,5 +112,5 @@
  * @param d Device the client was connected to.
  */
-void on_client_close(device_t *d)
+void on_client_close(ddf_fun_t *fun)
 {
 	/*
Index: uspace/drv/vhc/connhost.c
===================================================================
--- uspace/drv/vhc/connhost.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/vhc/connhost.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -48,5 +48,5 @@
 	usbhc_iface_transfer_out_callback_t out_callback;
 	usbhc_iface_transfer_in_callback_t in_callback;
-	device_t *dev;
+	ddf_fun_t *fun;
 	size_t reported_size;
 	void *arg;
@@ -58,5 +58,5 @@
 	usbhc_iface_transfer_out_callback_t out_callback;
 	usbhc_iface_transfer_in_callback_t in_callback;
-	device_t *dev;
+	ddf_fun_t *fun;
 	void *arg;
 	void *data_buffer;
@@ -75,10 +75,10 @@
 	switch (transfer->direction) {
 		case USB_DIRECTION_IN:
-			transfer->in_callback(transfer->dev,
+			transfer->in_callback(transfer->fun,
 			    outcome, size,
 			    transfer->arg);
 			break;
 		case USB_DIRECTION_OUT:
-			transfer->out_callback(transfer->dev,
+			transfer->out_callback(transfer->fun,
 			    outcome,
 			    transfer->arg);
@@ -92,5 +92,5 @@
 }
 
-static transfer_info_t *create_transfer_info(device_t *dev,
+static transfer_info_t *create_transfer_info(ddf_fun_t *fun,
     usb_direction_t direction, void *arg)
 {
@@ -101,5 +101,5 @@
 	transfer->out_callback = NULL;
 	transfer->arg = arg;
-	transfer->dev = dev;
+	transfer->fun = fun;
 	transfer->reported_size = (size_t) -1;
 
@@ -112,10 +112,10 @@
 	switch (transfer->direction) {
 		case USB_DIRECTION_IN:
-			transfer->in_callback(transfer->dev,
+			transfer->in_callback(transfer->fun,
 			    outcome, size,
 			    transfer->arg);
 			break;
 		case USB_DIRECTION_OUT:
-			transfer->out_callback(transfer->dev,
+			transfer->out_callback(transfer->fun,
 			    outcome,
 			    transfer->arg);
@@ -138,5 +138,5 @@
 	}
 
-	transfer_info_t *transfer  = create_transfer_info(ctrl_transfer->dev,
+	transfer_info_t *transfer  = create_transfer_info(ctrl_transfer->fun,
 	    ctrl_transfer->direction, ctrl_transfer->arg);
 	transfer->out_callback = ctrl_transfer->out_callback;
@@ -195,5 +195,5 @@
 }
 
-static control_transfer_info_t *create_control_transfer_info(device_t *dev,
+static control_transfer_info_t *create_control_transfer_info(ddf_fun_t *fun,
     usb_direction_t direction, usb_target_t target,
     void *data_buffer, size_t data_buffer_size,
@@ -208,5 +208,5 @@
 	transfer->out_callback = NULL;
 	transfer->arg = arg;
-	transfer->dev = dev;
+	transfer->fun = fun;
 	transfer->data_buffer = data_buffer;
 	transfer->data_buffer_size = data_buffer_size;
@@ -215,5 +215,5 @@
 }
 
-static int enqueue_transfer_out(device_t *dev,
+static int enqueue_transfer_out(ddf_fun_t *fun,
     usb_target_t target, usb_transfer_type_t transfer_type,
     void *buffer, size_t size,
@@ -226,5 +226,5 @@
 
 	transfer_info_t *transfer
-	    = create_transfer_info(dev, USB_DIRECTION_OUT, arg);
+	    = create_transfer_info(fun, USB_DIRECTION_OUT, arg);
 	transfer->out_callback = callback;
 
@@ -235,5 +235,5 @@
 }
 
-static int enqueue_transfer_in(device_t *dev,
+static int enqueue_transfer_in(ddf_fun_t *fun,
     usb_target_t target, usb_transfer_type_t transfer_type,
     void *buffer, size_t size,
@@ -246,5 +246,5 @@
 
 	transfer_info_t *transfer
-	    = create_transfer_info(dev, USB_DIRECTION_IN, arg);
+	    = create_transfer_info(fun, USB_DIRECTION_IN, arg);
 	transfer->in_callback = callback;
 
@@ -256,25 +256,25 @@
 
 
-static int interrupt_out(device_t *dev, usb_target_t target,
+static int interrupt_out(ddf_fun_t *fun, usb_target_t target,
     size_t max_packet_size,
     void *data, size_t size,
     usbhc_iface_transfer_out_callback_t callback, void *arg)
 {
-	return enqueue_transfer_out(dev, target, USB_TRANSFER_INTERRUPT,
+	return enqueue_transfer_out(fun, target, USB_TRANSFER_INTERRUPT,
 	    data, size,
 	    callback, arg);
 }
 
-static int interrupt_in(device_t *dev, usb_target_t target,
+static int interrupt_in(ddf_fun_t *fun, usb_target_t target,
     size_t max_packet_size,
     void *data, size_t size,
     usbhc_iface_transfer_in_callback_t callback, void *arg)
 {
-	return enqueue_transfer_in(dev, target, USB_TRANSFER_INTERRUPT,
+	return enqueue_transfer_in(fun, target, USB_TRANSFER_INTERRUPT,
 	    data, size,
 	    callback, arg);
 }
 
-static int control_write(device_t *dev, usb_target_t target,
+static int control_write(ddf_fun_t *fun, usb_target_t target,
     size_t max_packet_size,
     void *setup_packet, size_t setup_packet_size,
@@ -283,5 +283,5 @@
 {
 	control_transfer_info_t *transfer
-	    = create_control_transfer_info(dev, USB_DIRECTION_OUT, target,
+	    = create_control_transfer_info(fun, USB_DIRECTION_OUT, target,
 	    data, data_size, arg);
 	transfer->out_callback = callback;
@@ -294,5 +294,5 @@
 }
 
-static int control_read(device_t *dev, usb_target_t target,
+static int control_read(ddf_fun_t *fun, usb_target_t target,
     size_t max_packet_size,
     void *setup_packet, size_t setup_packet_size,
@@ -301,5 +301,5 @@
 {
 	control_transfer_info_t *transfer
-	    = create_control_transfer_info(dev, USB_DIRECTION_IN, target,
+	    = create_control_transfer_info(fun, USB_DIRECTION_IN, target,
 	    data, data_size, arg);
 	transfer->in_callback = callback;
@@ -314,7 +314,9 @@
 static usb_address_keeping_t addresses;
 
-static int tell_address(device_t *dev, devman_handle_t handle,
+static int tell_address(ddf_fun_t *fun, devman_handle_t handle,
     usb_address_t *address)
 {
+	usb_log_debug("tell_address(fun \"%s\", handle %zu)\n",
+	    fun->name, (size_t) fun->handle);
 	usb_address_t addr = usb_address_keeping_find(&addresses, handle);
 	if (addr < 0) {
@@ -326,5 +328,5 @@
 }
 
-static int reserve_default_address(device_t *dev, usb_speed_t ignored)
+static int reserve_default_address(ddf_fun_t *fun, usb_speed_t ignored)
 {
 	usb_address_keeping_reserve_default(&addresses);
@@ -332,5 +334,5 @@
 }
 
-static int release_default_address(device_t *dev)
+static int release_default_address(ddf_fun_t *fun)
 {
 	usb_address_keeping_release_default(&addresses);
@@ -338,5 +340,5 @@
 }
 
-static int request_address(device_t *dev, usb_speed_t ignored,
+static int request_address(ddf_fun_t *fun, usb_speed_t ignored,
     usb_address_t *address)
 {
@@ -350,14 +352,36 @@
 }
 
-static int release_address(device_t *dev, usb_address_t address)
+static int release_address(ddf_fun_t *fun, usb_address_t address)
 {
 	return usb_address_keeping_release(&addresses, address);
 }
 
-static int bind_address(device_t *dev, usb_address_t address,
+static int bind_address(ddf_fun_t *fun, usb_address_t address,
     devman_handle_t handle)
 {
 	usb_address_keeping_devman_bind(&addresses, address, handle);
 	return EOK;
+}
+
+static int usb_iface_get_hc_handle_rh_impl(ddf_fun_t *root_hub_fun,
+    devman_handle_t *handle)
+{
+	ddf_fun_t *hc_fun = root_hub_fun->driver_data;
+	assert(hc_fun != NULL);
+
+	*handle = hc_fun->handle;
+
+	usb_log_debug("usb_iface_get_hc_handle_rh_impl returns %zu\n", *handle);
+
+	return EOK;
+}
+
+static int tell_address_rh(ddf_fun_t *root_hub_fun, devman_handle_t handle,
+    usb_address_t *address)
+{
+	ddf_fun_t *hc_fun = root_hub_fun->driver_data;
+	assert(hc_fun != NULL);
+
+	return tell_address(hc_fun, root_hub_fun->handle, address);
 }
 
@@ -386,4 +410,9 @@
 };
 
+usb_iface_t rh_usb_iface = {
+	.get_hc_handle = usb_iface_get_hc_handle_rh_impl,
+	.get_address = tell_address_rh
+};
+
 
 /**
Index: uspace/drv/vhc/hcd.c
===================================================================
--- uspace/drv/vhc/hcd.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/vhc/hcd.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -42,5 +42,5 @@
 #include <errno.h>
 #include <str_error.h>
-#include <driver.h>
+#include <ddf/driver.h>
 
 #include <usb/usb.h>
@@ -53,5 +53,5 @@
 #include "conn.h"
 
-static device_ops_t vhc_ops = {
+static ddf_dev_ops_t vhc_ops = {
 	.interfaces[USBHC_DEV_IFACE] = &vhc_iface,
 	.interfaces[USB_DEV_IFACE] = &vhc_usb_iface,
@@ -60,7 +60,9 @@
 };
 
-static int vhc_count = 0;
-static int vhc_add_device(device_t *dev)
+static int vhc_add_device(ddf_dev_t *dev)
 {
+	static int vhc_count = 0;
+	int rc;
+
 	/*
 	 * Currently, we know how to simulate only single HC.
@@ -70,17 +72,32 @@
 	}
 
-	vhc_count++;
+	/*
+	 * Create exposed function representing the host controller
+	 * itself.
+	 */
+	ddf_fun_t *hc = ddf_fun_create(dev, fun_exposed, "hc");
+	if (hc == NULL) {
+		usb_log_fatal("Failed to create device function.\n");
+		return ENOMEM;
+	}
 
-	dev->ops = &vhc_ops;
+	hc->ops = &vhc_ops;
 
-	devman_add_device_to_class(dev->handle, "usbhc");
+	rc = ddf_fun_bind(hc);
+	if (rc != EOK) {
+		usb_log_fatal("Failed to bind HC function: %s.\n",
+		    str_error(rc));
+		return rc;
+	}
+
+	ddf_fun_add_to_class(hc, "usbhc");
 
 	/*
 	 * Initialize our hub and announce its presence.
 	 */
-	virtual_hub_device_init(dev);
+	virtual_hub_device_init(hc);
 
-	usb_log_info("Virtual USB host controller ready (id = %zu).\n",
-	    (size_t) dev->handle);
+	usb_log_info("Virtual USB host controller ready (dev %zu, hc %zu).\n",
+	    (size_t) dev->handle, (size_t) hc->handle);
 
 	return EOK;
@@ -103,7 +120,7 @@
 	 * in devman output.
 	 */
-	sleep(5);
+	//sleep(5);
 
-	usb_log_enable(USB_LOG_LEVEL_INFO, NAME);
+	usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
 
 	printf(NAME ": virtual USB host controller driver.\n");
@@ -122,5 +139,5 @@
 	 * We are also a driver within devman framework.
 	 */
-	return driver_main(&vhc_driver);
+	return ddf_driver_main(&vhc_driver);
 }
 
Index: uspace/drv/vhc/hub.c
===================================================================
--- uspace/drv/vhc/hub.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/vhc/hub.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -39,5 +39,6 @@
 #include <str_error.h>
 #include <stdlib.h>
-#include <driver.h>
+#include <ddf/driver.h>
+#include <devman.h>
 #include <usb/hub.h>
 #include <usb/recognise.h>
@@ -46,10 +47,14 @@
 #include "hub/virthub.h"
 #include "vhcd.h"
+#include "conn.h"
 
 usbvirt_device_t virtual_hub_device;
+static ddf_dev_ops_t rh_ops = {
+	.interfaces[USB_DEV_IFACE] = &rh_usb_iface,
+};
 
 static int hub_register_in_devman_fibril(void *arg);
 
-void virtual_hub_device_init(device_t *hc_dev)
+void virtual_hub_device_init(ddf_fun_t *hc_dev)
 {
 	virthub_init(&virtual_hub_device);
@@ -83,5 +88,5 @@
 int hub_register_in_devman_fibril(void *arg)
 {
-	device_t *hc_dev = (device_t *) arg;
+	ddf_fun_t *hc_dev = (ddf_fun_t *) arg;
 
 	/*
@@ -94,12 +99,18 @@
 	async_hangup(phone);
 
+	int rc;
+
 	usb_hc_connection_t hc_conn;
-	usb_hc_connection_initialize(&hc_conn, hc_dev->handle);
+	rc = usb_hc_connection_initialize(&hc_conn, hc_dev->handle);
+	assert(rc == EOK);
 
-	usb_hc_connection_open(&hc_conn);
+	rc = usb_hc_connection_open(&hc_conn);
+	assert(rc == EOK);
 
-	int rc = usb_hc_new_device_wrapper(hc_dev, &hc_conn, USB_SPEED_FULL,
+	ddf_fun_t *hub_dev;
+	rc = usb_hc_new_device_wrapper(hc_dev->dev, &hc_conn,
+	    USB_SPEED_FULL,
 	    pretend_port_rest, 0, NULL,
-	    NULL, NULL);
+	    NULL, NULL, &rh_ops, hc_dev, &hub_dev);
 	if (rc != EOK) {
 		usb_log_fatal("Failed to create root hub: %s.\n",
@@ -108,4 +119,7 @@
 
 	usb_hc_connection_close(&hc_conn);
+
+	usb_log_info("Created root hub function (handle %zu).\n",
+	    (size_t) hub_dev->handle);
 
 	return 0;
Index: uspace/drv/vhc/hub.h
===================================================================
--- uspace/drv/vhc/hub.h	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/vhc/hub.h	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -37,5 +37,5 @@
 
 #include <usbvirt/device.h>
-#include <driver.h>
+#include <ddf/driver.h>
 
 #include "devices.h"
@@ -45,5 +45,5 @@
 extern usbvirt_device_t virtual_hub_device;
 
-void virtual_hub_device_init(device_t *);
+void virtual_hub_device_init(ddf_fun_t *);
 
 #endif
Index: uspace/drv/vhc/hub/hub.c
===================================================================
--- uspace/drv/vhc/hub/hub.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/vhc/hub/hub.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -38,6 +38,7 @@
 #include <errno.h>
 #include <str_error.h>
+#include <assert.h>
 #include <stdlib.h>
-#include <driver.h>
+#include <ddf/driver.h>
 
 #include "hub.h"
Index: uspace/drv/vhc/hub/virthub.c
===================================================================
--- uspace/drv/vhc/hub/virthub.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/drv/vhc/hub/virthub.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -39,6 +39,7 @@
 #include <errno.h>
 #include <str_error.h>
+#include <assert.h>
 #include <stdlib.h>
-#include <driver.h>
+#include <ddf/driver.h>
 
 #include "virthub.h"
Index: uspace/lib/block/libblock.c
===================================================================
--- uspace/lib/block/libblock.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/lib/block/libblock.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -626,4 +626,5 @@
 			unsigned long key = block->lba;
 			hash_table_remove(&cache->block_hash, &key, 1);
+			fibril_mutex_unlock(&block->lock);
 			free(block->data);
 			free(block);
Index: uspace/lib/c/Makefile
===================================================================
--- uspace/lib/c/Makefile	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/lib/c/Makefile	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -91,6 +91,6 @@
 	generic/loader.c \
 	generic/getopt.c \
-	generic/adt/list.o \
-	generic/adt/hash_table.o \
+	generic/adt/list.c \
+	generic/adt/hash_table.c \
 	generic/adt/dynamic_fifo.c \
 	generic/adt/measured_strings.c \
Index: uspace/lib/c/generic/devman.c
===================================================================
--- uspace/lib/c/generic/devman.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/lib/c/generic/devman.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -123,9 +123,13 @@
 }
 
-static int devman_send_match_id(int phone, match_id_t *match_id) \
-{
-	ipc_call_t answer;
-	aid_t req = async_send_1(phone, DEVMAN_ADD_MATCH_ID, match_id->score, &answer);
-	int retval = async_data_write_start(phone, match_id->id, str_size(match_id->id));
+static int devman_send_match_id(int phone, match_id_t *match_id)
+{
+	ipc_call_t answer;
+
+	aid_t req = async_send_1(phone, DEVMAN_ADD_MATCH_ID, match_id->score,
+	    &answer);
+	int retval = async_data_write_start(phone, match_id->id,
+	    str_size(match_id->id));
+
 	async_wait_for(req, NULL);
 	return retval;
@@ -133,26 +137,43 @@
 
 
-static int devman_send_match_ids(int phone, match_id_list_t *match_ids) 
+static int devman_send_match_ids(int phone, match_id_list_t *match_ids)
 {
 	link_t *link = match_ids->ids.next;
 	match_id_t *match_id = NULL;
 	int ret = EOK;
-	
+
 	while (link != &match_ids->ids) {
 		match_id = list_get_instance(link, match_id_t, link); 
-		if (EOK != (ret = devman_send_match_id(phone, match_id))) 
-		{
-			printf("Driver failed to send match id, error number = %d\n", ret);
-			return ret;			
-		}
+		ret = devman_send_match_id(phone, match_id);
+		if (ret != EOK) {
+			printf("Driver failed to send match id, error %d\n",
+			    ret);
+			return ret;
+		}
+
 		link = link->next;
 	}
-	return ret;	
-}
-
-int devman_child_device_register(
-	const char *name, match_id_list_t *match_ids, devman_handle_t parent_handle, devman_handle_t *handle)
-{		
+
+	return ret;
+}
+
+/** Add function to a device.
+ *
+ * Request devman to add a new function to the specified device owned by
+ * this driver task.
+ *
+ * @param name		Name of the new function
+ * @param ftype		Function type, fun_inner or fun_exposed
+ * @param match_ids	Match IDs (should be empty for fun_exposed)
+ * @param devh		Devman handle of the device
+ * @param funh		Place to store handle of the new function
+ *
+ * @return		EOK on success or negative error code.
+ */
+int devman_add_function(const char *name, fun_type_t ftype,
+    match_id_list_t *match_ids, devman_handle_t devh, devman_handle_t *funh)
+{
 	int phone = devman_get_phone(DEVMAN_DRIVER, IPC_FLAG_BLOCKING);
+	int fun_handle;
 	
 	if (phone < 0)
@@ -161,7 +182,9 @@
 	async_serialize_start();
 	
-	int match_count = list_count(&match_ids->ids);	
-	ipc_call_t answer;
-	aid_t req = async_send_2(phone, DEVMAN_ADD_CHILD_DEVICE, parent_handle, match_count, &answer);
+	int match_count = list_count(&match_ids->ids);
+	ipc_call_t answer;
+
+	aid_t req = async_send_3(phone, DEVMAN_ADD_FUNCTION, (sysarg_t) ftype,
+	    devh, match_count, &answer);
 
 	sysarg_t retval = async_data_write_start(phone, name, str_size(name));
@@ -178,18 +201,16 @@
 	async_serialize_end();
 	
-	if (retval != EOK) {
-		if (handle != NULL) {
-			*handle = -1;
-		}
-		return retval;
-	}	
-	
-	if (handle != NULL)
-		*handle = (int) IPC_GET_ARG1(answer);	
-		
-	return retval;
-}
-
-int devman_add_device_to_class(devman_handle_t devman_handle, const char *class_name)
+	if (retval == EOK)
+		fun_handle = (int) IPC_GET_ARG1(answer);
+	else
+		fun_handle = -1;
+	
+	*funh = fun_handle;
+
+	return retval;
+}
+
+int devman_add_device_to_class(devman_handle_t devman_handle,
+    const char *class_name)
 {
 	int phone = devman_get_phone(DEVMAN_DRIVER, IPC_FLAG_BLOCKING);
@@ -200,7 +221,9 @@
 	async_serialize_start();
 	ipc_call_t answer;
-	aid_t req = async_send_1(phone, DEVMAN_ADD_DEVICE_TO_CLASS, devman_handle, &answer);
-	
-	sysarg_t retval = async_data_write_start(phone, class_name, str_size(class_name));
+	aid_t req = async_send_1(phone, DEVMAN_ADD_DEVICE_TO_CLASS,
+	    devman_handle, &answer);
+	
+	sysarg_t retval = async_data_write_start(phone, class_name,
+	    str_size(class_name));
 	if (retval != EOK) {
 		async_wait_for(req, NULL);
@@ -212,5 +235,5 @@
 	async_serialize_end();
 	
-	return retval;	
+	return retval;
 }
 
@@ -265,5 +288,6 @@
 }
 
-int devman_device_get_handle(const char *pathname, devman_handle_t *handle, unsigned int flags)
+int devman_device_get_handle(const char *pathname, devman_handle_t *handle,
+    unsigned int flags)
 {
 	int phone = devman_get_phone(DEVMAN_CLIENT, flags);
@@ -278,5 +302,6 @@
 	    &answer);
 	
-	sysarg_t retval = async_data_write_start(phone, pathname, str_size(pathname));
+	sysarg_t retval = async_data_write_start(phone, pathname,
+	    str_size(pathname));
 	if (retval != EOK) {
 		async_wait_for(req, NULL);
Index: uspace/lib/c/generic/fibril.c
===================================================================
--- uspace/lib/c/generic/fibril.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/lib/c/generic/fibril.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -115,4 +115,6 @@
 	fibril->retval = 0;
 	fibril->flags = 0;
+	
+	fibril->waits_for = NULL;
 	
 	return fibril;
@@ -276,6 +278,4 @@
 	fibril->arg = arg;
 
-	fibril->waits_for = NULL;
-	
 	context_save(&fibril->ctx);
 	context_set(&fibril->ctx, FADDR(fibril_main), fibril->stack,
Index: uspace/lib/c/include/devman.h
===================================================================
--- uspace/lib/c/include/devman.h	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/lib/c/include/devman.h	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -45,5 +45,5 @@
 
 extern int devman_driver_register(const char *, async_client_conn_t);
-extern int devman_child_device_register(const char *, match_id_list_t *,
+extern int devman_add_function(const char *, fun_type_t, match_id_list_t *,
     devman_handle_t, devman_handle_t *);
 
Index: uspace/lib/c/include/ipc/devman.h
===================================================================
--- uspace/lib/c/include/ipc/devman.h	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/lib/c/include/ipc/devman.h	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -42,4 +42,13 @@
 
 typedef sysarg_t devman_handle_t;
+
+typedef enum {
+	/** Invalid value for debugging purposes */
+	fun_invalid = 0,
+	/** Function to which child devices attach */
+	fun_inner,
+	/** Fuction exported to external clients (leaf function) */
+	fun_exposed
+} fun_type_t;
 
 /** Ids of device models used for device-to-driver matching.
@@ -127,5 +136,5 @@
 typedef enum {
 	DEVMAN_DRIVER_REGISTER = IPC_FIRST_USER_METHOD,
-	DEVMAN_ADD_CHILD_DEVICE,
+	DEVMAN_ADD_FUNCTION,
 	DEVMAN_ADD_MATCH_ID,
 	DEVMAN_ADD_DEVICE_TO_CLASS
Index: uspace/lib/drv/generic/driver.c
===================================================================
--- uspace/lib/drv/generic/driver.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/lib/drv/generic/driver.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -1,4 +1,5 @@
 /*
  * Copyright (c) 2010 Lenka Trochtova
+ * Copyright (c) 2011 Jiri Svoboda
  * All rights reserved.
  *
@@ -49,9 +50,11 @@
 #include <errno.h>
 #include <inttypes.h>
+#include <devman.h>
 
 #include <ipc/driver.h>
 
 #include "dev_iface.h"
-#include "driver.h"
+#include "ddf/driver.h"
+#include "ddf/interrupt.h"
 
 /** Driver structure */
@@ -59,6 +62,6 @@
 
 /** Devices */
-LIST_INITIALIZE(devices);
-FIBRIL_MUTEX_INITIALIZE(devices_mutex);
+LIST_INITIALIZE(functions);
+FIBRIL_MUTEX_INITIALIZE(functions_mutex);
 
 /** Interrupts */
@@ -76,4 +79,8 @@
 };
 
+static ddf_dev_t *create_device(void);
+static void delete_device(ddf_dev_t *);
+static remote_handler_t *function_get_default_handler(ddf_fun_t *);
+static void *function_get_ops(ddf_fun_t *, dev_inferface_idx_t);
 
 static void driver_irq_handler(ipc_callid_t iid, ipc_call_t *icall)
@@ -150,5 +157,5 @@
 
 interrupt_context_t *
-find_interrupt_context(interrupt_context_list_t *list, device_t *dev, int irq)
+find_interrupt_context(interrupt_context_list_t *list, ddf_dev_t *dev, int irq)
 {
 	fibril_mutex_lock(&list->mutex);
@@ -172,5 +179,5 @@
 
 int
-register_interrupt_handler(device_t *dev, int irq, interrupt_handler_t *handler,
+register_interrupt_handler(ddf_dev_t *dev, int irq, interrupt_handler_t *handler,
     irq_code_t *pseudocode)
 {
@@ -195,5 +202,5 @@
 }
 
-int unregister_interrupt_handler(device_t *dev, int irq)
+int unregister_interrupt_handler(ddf_dev_t *dev, int irq)
 {
 	interrupt_context_t *ctx = find_interrupt_context(&interrupt_contexts,
@@ -209,35 +216,36 @@
 }
 
-static void add_to_devices_list(device_t *dev)
-{
-	fibril_mutex_lock(&devices_mutex);
-	list_append(&dev->link, &devices);
-	fibril_mutex_unlock(&devices_mutex);
-}
-
-static void remove_from_devices_list(device_t *dev)
-{
-	fibril_mutex_lock(&devices_mutex);
-	list_remove(&dev->link);
-	fibril_mutex_unlock(&devices_mutex);
-}
-
-static device_t *driver_get_device(link_t *devices, devman_handle_t handle)
-{
-	device_t *dev = NULL;
-	
-	fibril_mutex_lock(&devices_mutex);
-	link_t *link = devices->next;
-	
-	while (link != devices) {
-		dev = list_get_instance(link, device_t, link);
-		if (dev->handle == handle) {
-			fibril_mutex_unlock(&devices_mutex);
-			return dev;
+static void add_to_functions_list(ddf_fun_t *fun)
+{
+	fibril_mutex_lock(&functions_mutex);
+	list_append(&fun->link, &functions);
+	fibril_mutex_unlock(&functions_mutex);
+}
+
+static void remove_from_functions_list(ddf_fun_t *fun)
+{
+	fibril_mutex_lock(&functions_mutex);
+	list_remove(&fun->link);
+	fibril_mutex_unlock(&functions_mutex);
+}
+
+static ddf_fun_t *driver_get_function(link_t *functions, devman_handle_t handle)
+{
+	ddf_fun_t *fun = NULL;
+	
+	fibril_mutex_lock(&functions_mutex);
+	link_t *link = functions->next;
+	
+	while (link != functions) {
+		fun = list_get_instance(link, ddf_fun_t, link);
+		if (fun->handle == handle) {
+			fibril_mutex_unlock(&functions_mutex);
+			return fun;
 		}
+		
 		link = link->next;
 	}
 	
-	fibril_mutex_unlock(&devices_mutex);
+	fibril_mutex_unlock(&functions_mutex);
 	
 	return NULL;
@@ -250,14 +258,17 @@
 	
 	devman_handle_t dev_handle = IPC_GET_ARG1(*icall);
-    	devman_handle_t parent_dev_handle = IPC_GET_ARG2(*icall);
-	
-	device_t *dev = create_device();
+    	devman_handle_t parent_fun_handle = IPC_GET_ARG2(*icall);
+	
+	ddf_dev_t *dev = create_device();
 	dev->handle = dev_handle;
-	
+
 	async_data_write_accept((void **) &dev_name, true, 0, 0, 0, 0);
 	dev->name = dev_name;
-	
-	add_to_devices_list(dev);
-	dev->parent = driver_get_device(&devices, parent_dev_handle);
+
+	/*
+	 * Currently not used, parent fun handle is stored in context
+	 * of the connection to the parent device driver.
+	 */
+	(void) parent_fun_handle;
 	
 	res = driver->driver_ops->add_device(dev);
@@ -268,5 +279,4 @@
 		printf("%s: failed to add a new device with handle = %" PRIun ".\n",
 		    driver->name, dev_handle);
-		remove_from_devices_list(dev);
 		delete_device(dev);
 	}
@@ -311,8 +321,8 @@
 	 */
 	devman_handle_t handle = IPC_GET_ARG2(*icall);
-	device_t *dev = driver_get_device(&devices, handle);
-
-	if (dev == NULL) {
-		printf("%s: driver_connection_gen error - no device with handle"
+	ddf_fun_t *fun = driver_get_function(&functions, handle);
+
+	if (fun == NULL) {
+		printf("%s: driver_connection_gen error - no function with handle"
 		    " %" PRIun " was found.\n", driver->name, handle);
 		async_answer_0(iid, ENOENT);
@@ -327,7 +337,7 @@
 	
 	int ret = EOK;
-	/* open the device */
-	if (dev->ops != NULL && dev->ops->open != NULL)
-		ret = (*dev->ops->open)(dev);
+	/* Open device function */
+	if (fun->ops != NULL && fun->ops->open != NULL)
+		ret = (*fun->ops->open)(fun);
 	
 	async_answer_0(iid, ret);
@@ -344,7 +354,7 @@
 		switch  (method) {
 		case IPC_M_PHONE_HUNGUP:
-			/* close the device */
-			if (dev->ops != NULL && dev->ops->close != NULL)
-				(*dev->ops->close)(dev);
+			/* Close device function */
+			if (fun->ops != NULL && fun->ops->close != NULL)
+				(*fun->ops->close)(fun);
 			async_answer_0(callid, EOK);
 			return;
@@ -356,11 +366,12 @@
 			if (!is_valid_iface_idx(iface_idx)) {
 				remote_handler_t *default_handler =
-				    device_get_default_handler(dev);
+				    function_get_default_handler(fun);
 				if (default_handler != NULL) {
-					(*default_handler)(dev, callid, &call);
+					(*default_handler)(fun, callid, &call);
 					break;
 				}
+				
 				/*
-				 * This is not device's interface and the
+				 * Function has no such interface and
 				 * default handler is not provided.
 				 */
@@ -372,12 +383,12 @@
 			}
 			
-			/* calling one of the device's interfaces */
+			/* calling one of the function's interfaces */
 			
 			/* Get the interface ops structure. */
-			void *ops = device_get_ops(dev, iface_idx);
+			void *ops = function_get_ops(fun, iface_idx);
 			if (ops == NULL) {
 				printf("%s: driver_connection_gen error - ",
 				    driver->name);
-				printf("device with handle %" PRIun " has no interface "
+				printf("Function with handle %" PRIun " has no interface "
 				    "with id %d.\n", handle, iface_idx);
 				async_answer_0(callid, ENOTSUP);
@@ -408,7 +419,7 @@
 			 * receive parameters from the remote client and it will
 			 * pass it to the corresponding local interface method
-			 * associated with the device by its driver.
+			 * associated with the function by its driver.
 			 */
-			(*iface_method_ptr)(dev, ops, callid, &call);
+			(*iface_method_ptr)(fun, ops, callid, &call);
 			break;
 		}
@@ -425,5 +436,4 @@
 	driver_connection_gen(iid, icall, false);
 }
-
 
 /** Function for handling connections to device driver. */
@@ -454,125 +464,200 @@
  * @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);
-	}
-
+static ddf_dev_t *create_device(void)
+{
+	ddf_dev_t *dev;
+
+	dev = malloc(sizeof(ddf_dev_t));
+	if (dev == NULL)
+		return NULL;
+
+	memset(dev, 0, sizeof(ddf_dev_t));
 	return dev;
 }
 
+/** Create new function structure.
+ *
+ * @return		The device structure.
+ */
+static ddf_fun_t *create_function(void)
+{
+	ddf_fun_t *fun;
+
+	fun = calloc(1, sizeof(ddf_fun_t));
+	if (fun == NULL)
+		return NULL;
+
+	init_match_ids(&fun->match_ids);
+	link_initialize(&fun->link);
+
+	return fun;
+}
+
 /** 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);
+static void delete_device(ddf_dev_t *dev)
+{
 	free(dev);
 }
 
-void *device_get_ops(device_t *dev, dev_inferface_idx_t idx)
+/** Delete device structure.
+ *
+ * @param dev		The device structure.
+ */
+static void delete_function(ddf_fun_t *fun)
+{
+	clean_match_ids(&fun->match_ids);
+	if (fun->name != NULL)
+		free(fun->name);
+	free(fun);
+}
+
+/** Create a DDF function node.
+ *
+ * Create a DDF function (in memory). Both child devices and external clients
+ * communicate with a device via its functions.
+ *
+ * The created function node is fully formed, but only exists in the memory
+ * of the client task. In order to be visible to the system, the function
+ * must be bound using ddf_fun_bind().
+ *
+ * This function should only fail if there is not enough free memory.
+ * Specifically, this function succeeds even if @a dev already has
+ * a (bound) function with the same name.
+ *
+ * Type: A function of type fun_inner indicates that DDF should attempt
+ * to attach child devices to the function. fun_exposed means that
+ * the function should be exported to external clients (applications).
+ *
+ * @param dev		Device to which we are adding function
+ * @param ftype		Type of function (fun_inner or fun_exposed)
+ * @param name		Name of function
+ *
+ * @return		New function or @c NULL if memory is not available
+ */
+ddf_fun_t *ddf_fun_create(ddf_dev_t *dev, fun_type_t ftype, const char *name)
+{
+	ddf_fun_t *fun;
+
+	fun = create_function();
+	if (fun == NULL)
+		return NULL;
+
+	fun->bound = false;
+	fun->dev = dev;
+	fun->ftype = ftype;
+
+	fun->name = str_dup(name);
+	if (fun->name == NULL) {
+		delete_function(fun);
+		return NULL;
+	}
+
+	return fun;
+}
+
+/** Destroy DDF function node.
+ *
+ * Destroy a function previously created with ddf_fun_create(). The function
+ * must not be bound.
+ *
+ * @param fun		Function to destroy
+ */
+void ddf_fun_destroy(ddf_fun_t *fun)
+{
+	assert(fun->bound == false);
+	delete_function(fun);
+}
+
+static void *function_get_ops(ddf_fun_t *fun, dev_inferface_idx_t idx)
 {
 	assert(is_valid_iface_idx(idx));
-	if (dev->ops == NULL)
+	if (fun->ops == NULL)
 		return NULL;
-	return dev->ops->interfaces[idx];
-}
-
-int child_device_register(device_t *child, device_t *parent)
-{
-	assert(child->name != NULL);
+	return fun->ops->interfaces[idx];
+}
+
+/** Bind a function node.
+ *
+ * Bind the specified function to the system. This effectively makes
+ * the function visible to the system (uploads it to the server).
+ *
+ * This function can fail for several reasons. Specifically,
+ * it will fail if the device already has a bound function of
+ * the same name.
+ *
+ * @param fun		Function to bind
+ * @return		EOK on success or negative error code
+ */
+int ddf_fun_bind(ddf_fun_t *fun)
+{
+	assert(fun->name != NULL);
 	
 	int res;
 	
-	add_to_devices_list(child);
-	res = devman_child_device_register(child->name, &child->match_ids,
-	    parent->handle, &child->handle);
+	add_to_functions_list(fun);
+	res = devman_add_function(fun->name, fun->ftype, &fun->match_ids,
+	    fun->dev->handle, &fun->handle);
 	if (res != EOK) {
-		remove_from_devices_list(child);
+		remove_from_functions_list(fun);
 		return res;
 	}
 	
+	fun->bound = true;
 	return res;
 }
 
-/** Wrapper for child_device_register for devices with single match id.
- *
- * @param parent Parent device.
- * @param child_name Child device name.
- * @param child_match_id Child device match id.
- * @param child_match_score Child device match score.
- * @return Error code.
- */
-int child_device_register_wrapper(device_t *parent, const char *child_name,
-    const char *child_match_id, int child_match_score,
-    devman_handle_t *child_handle)
-{
-	device_t *child = NULL;
-	match_id_t *match_id = NULL;
-	int rc;
-	
-	child = create_device();
-	if (child == NULL) {
-		rc = ENOMEM;
-		goto failure;
-	}
-	
-	child->name = child_name;
+/** Add single match ID to inner function.
+ *
+ * Construct and add a single match ID to the specified function.
+ * Cannot be called when the function node is bound.
+ *
+ * @param fun			Function
+ * @param match_id_str		Match string
+ * @param match_score		Match score
+ * @return			EOK on success, ENOMEM if out of memory.
+ */
+int ddf_fun_add_match_id(ddf_fun_t *fun, const char *match_id_str,
+    int match_score)
+{
+	match_id_t *match_id;
+	
+	assert(fun->bound == false);
+	assert(fun->ftype == fun_inner);
 	
 	match_id = create_match_id();
-	if (match_id == NULL) {
-		rc = ENOMEM;
-		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 (rc != EOK)
-		goto failure;
-
-	if (child_handle != NULL) {
-		*child_handle = child->handle;
-	}
-
+	if (match_id == NULL)
+		return ENOMEM;
+	
+	match_id->id = match_id_str;
+	match_id->score = 90;
+	
+	add_match_id(&fun->match_ids, match_id);
 	return EOK;
-	
-failure:
-	if (match_id != NULL) {
-		match_id->id = NULL;
-		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)
+static remote_handler_t *function_get_default_handler(ddf_fun_t *fun)
+{
+	if (fun->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);
-}
-
-int driver_main(driver_t *drv)
+	return fun->ops->default_handler;
+}
+
+/** Add exposed function to class.
+ *
+ * Must only be called when the function is bound.
+ */
+int ddf_fun_add_to_class(ddf_fun_t *fun, const char *class_name)
+{
+	assert(fun->bound == true);
+	assert(fun->ftype == fun_exposed);
+	
+	return devman_add_device_to_class(fun->handle, class_name);
+}
+
+int ddf_driver_main(driver_t *drv)
 {
 	/*
Index: uspace/lib/drv/generic/remote_char_dev.c
===================================================================
--- uspace/lib/drv/generic/remote_char_dev.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/lib/drv/generic/remote_char_dev.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -37,10 +37,10 @@
 
 #include "ops/char_dev.h"
-#include "driver.h"
+#include "ddf/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 *);
+static void remote_char_read(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
+static void remote_char_write(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
 
 /** Remote character interface operations. */
@@ -67,9 +67,9 @@
  * local interface to the remote client.
  *
- * @param dev		The device from which the data are read.
+ * @param fun		The function 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,
+remote_char_read(ddf_fun_t *fun, void *ops, ipc_callid_t callid,
     ipc_call_t *call)
 {
@@ -94,5 +94,5 @@
 	
 	char buf[MAX_CHAR_RW_COUNT];
-	int ret = (*char_dev_ops->read)(dev, buf, len);
+	int ret = (*char_dev_ops->read)(fun, buf, len);
 	
 	if (ret < 0) {
@@ -114,9 +114,9 @@
  * local interface to the remote client.
  *
- * @param dev		The device to which the data are written.
+ * @param fun		The function 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,
+remote_char_write(ddf_fun_t *fun, void *ops, ipc_callid_t callid,
     ipc_call_t *call)
 {
@@ -144,5 +144,5 @@
 	async_data_write_finalize(cid, buf, len);
 	
-	int ret = (*char_dev_ops->write)(dev, buf, len);
+	int ret = (*char_dev_ops->write)(fun, buf, len);
 	if (ret < 0) {
 		/* Some error occured. */
Index: uspace/lib/drv/generic/remote_hw_res.c
===================================================================
--- uspace/lib/drv/generic/remote_hw_res.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/lib/drv/generic/remote_hw_res.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -37,9 +37,9 @@
 
 #include "ops/hw_res.h"
-#include "driver.h"
+#include "ddf/driver.h"
 
-static void remote_hw_res_get_resource_list(device_t *, void *, ipc_callid_t,
+static void remote_hw_res_get_resource_list(ddf_fun_t *, void *, ipc_callid_t,
     ipc_call_t *);
-static void remote_hw_res_enable_interrupt(device_t *, void *, ipc_callid_t,
+static void remote_hw_res_enable_interrupt(ddf_fun_t *, void *, ipc_callid_t,
     ipc_call_t *);
 
@@ -55,5 +55,5 @@
 };
 
-static void remote_hw_res_enable_interrupt(device_t *dev, void *ops,
+static void remote_hw_res_enable_interrupt(ddf_fun_t *fun, void *ops,
     ipc_callid_t callid, ipc_call_t *call)
 {
@@ -62,5 +62,5 @@
 	if (hw_res_ops->enable_interrupt == NULL)
 		async_answer_0(callid, ENOTSUP);
-	else if (hw_res_ops->enable_interrupt(dev))
+	else if (hw_res_ops->enable_interrupt(fun))
 		async_answer_0(callid, EOK);
 	else
@@ -68,5 +68,5 @@
 }
 
-static void remote_hw_res_get_resource_list(device_t *dev, void *ops,
+static void remote_hw_res_get_resource_list(ddf_fun_t *fun, void *ops,
     ipc_callid_t callid, ipc_call_t *call)
 {
@@ -78,5 +78,5 @@
 	}
 	
-	hw_resource_list_t *hw_resources = hw_res_ops->get_resource_list(dev);
+	hw_resource_list_t *hw_resources = hw_res_ops->get_resource_list(fun);
 	if (hw_resources == NULL){
 		async_answer_0(callid, ENOENT);
Index: uspace/lib/drv/generic/remote_usb.c
===================================================================
--- uspace/lib/drv/generic/remote_usb.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/lib/drv/generic/remote_usb.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -37,10 +37,10 @@
 
 #include "usb_iface.h"
-#include "driver.h"
+#include "ddf/driver.h"
 
 
-static void remote_usb_get_address(device_t *, void *, ipc_callid_t, ipc_call_t *);
-static void remote_usb_get_interface(device_t *, void *, ipc_callid_t, ipc_call_t *);
-static void remote_usb_get_hc_handle(device_t *, void *, ipc_callid_t, ipc_call_t *);
+static void remote_usb_get_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
+static void remote_usb_get_interface(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
+static void remote_usb_get_hc_handle(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
 //static void remote_usb(device_t *, void *, ipc_callid_t, ipc_call_t *);
 
@@ -61,5 +61,5 @@
 
 
-void remote_usb_get_address(device_t *device, void *iface,
+void remote_usb_get_address(ddf_fun_t *fun, void *iface,
     ipc_callid_t callid, ipc_call_t *call)
 {
@@ -74,5 +74,5 @@
 
 	usb_address_t address;
-	int rc = usb_iface->get_address(device, handle, &address);
+	int rc = usb_iface->get_address(fun, handle, &address);
 	if (rc != EOK) {
 		async_answer_0(callid, rc);
@@ -82,5 +82,5 @@
 }
 
-void remote_usb_get_interface(device_t *device, void *iface,
+void remote_usb_get_interface(ddf_fun_t *fun, void *iface,
     ipc_callid_t callid, ipc_call_t *call)
 {
@@ -95,5 +95,5 @@
 
 	int iface_no;
-	int rc = usb_iface->get_interface(device, handle, &iface_no);
+	int rc = usb_iface->get_interface(fun, handle, &iface_no);
 	if (rc != EOK) {
 		async_answer_0(callid, rc);
@@ -103,5 +103,5 @@
 }
 
-void remote_usb_get_hc_handle(device_t *device, void *iface,
+void remote_usb_get_hc_handle(ddf_fun_t *fun, void *iface,
     ipc_callid_t callid, ipc_call_t *call)
 {
@@ -114,5 +114,5 @@
 
 	devman_handle_t handle;
-	int rc = usb_iface->get_hc_handle(device, &handle);
+	int rc = usb_iface->get_hc_handle(fun, &handle);
 	if (rc != EOK) {
 		async_answer_0(callid, rc);
Index: uspace/lib/drv/generic/remote_usbhc.c
===================================================================
--- uspace/lib/drv/generic/remote_usbhc.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/lib/drv/generic/remote_usbhc.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -35,7 +35,8 @@
 #include <async.h>
 #include <errno.h>
+#include <assert.h>
 
 #include "usbhc_iface.h"
-#include "driver.h"
+#include "ddf/driver.h"
 
 #define USB_MAX_PAYLOAD_SIZE 1020
@@ -43,16 +44,16 @@
 #define HACK_MAX_PACKET_SIZE_INTERRUPT_IN 4
 
-static void remote_usbhc_interrupt_out(device_t *, void *, ipc_callid_t, ipc_call_t *);
-static void remote_usbhc_interrupt_in(device_t *, void *, ipc_callid_t, ipc_call_t *);
-static void remote_usbhc_bulk_out(device_t *, void *, ipc_callid_t, ipc_call_t *);
-static void remote_usbhc_bulk_in(device_t *, void *, ipc_callid_t, ipc_call_t *);
-static void remote_usbhc_control_write(device_t *, void *, ipc_callid_t, ipc_call_t *);
-static void remote_usbhc_control_read(device_t *, void *, ipc_callid_t, ipc_call_t *);
-static void remote_usbhc_reserve_default_address(device_t *, void *, ipc_callid_t, ipc_call_t *);
-static void remote_usbhc_release_default_address(device_t *, void *, ipc_callid_t, ipc_call_t *);
-static void remote_usbhc_request_address(device_t *, void *, ipc_callid_t, ipc_call_t *);
-static void remote_usbhc_bind_address(device_t *, void *, ipc_callid_t, ipc_call_t *);
-static void remote_usbhc_release_address(device_t *, void *, ipc_callid_t, ipc_call_t *);
-//static void remote_usbhc(device_t *, void *, ipc_callid_t, ipc_call_t *);
+static void remote_usbhc_interrupt_out(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
+static void remote_usbhc_interrupt_in(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
+static void remote_usbhc_bulk_out(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
+static void remote_usbhc_bulk_in(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
+static void remote_usbhc_control_write(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
+static void remote_usbhc_control_read(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
+static void remote_usbhc_reserve_default_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
+static void remote_usbhc_release_default_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
+static void remote_usbhc_request_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
+static void remote_usbhc_bind_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
+static void remote_usbhc_release_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
+//static void remote_usbhc(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
 
 /** Remote USB host controller interface operations. */
@@ -123,5 +124,5 @@
 }
 
-void remote_usbhc_reserve_default_address(device_t *device, void *iface,
+void remote_usbhc_reserve_default_address(ddf_fun_t *fun, void *iface,
     ipc_callid_t callid, ipc_call_t *call)
 {
@@ -135,10 +136,10 @@
 	usb_speed_t speed = DEV_IPC_GET_ARG1(*call);
 	
-	int rc = usb_iface->reserve_default_address(device, speed);
+	int rc = usb_iface->reserve_default_address(fun, speed);
 
 	async_answer_0(callid, rc);
 }
 
-void remote_usbhc_release_default_address(device_t *device, void *iface,
+void remote_usbhc_release_default_address(ddf_fun_t *fun, void *iface,
     ipc_callid_t callid, ipc_call_t *call)
 {
@@ -150,10 +151,10 @@
 	}
 
-	int rc = usb_iface->release_default_address(device);
+	int rc = usb_iface->release_default_address(fun);
 
 	async_answer_0(callid, rc);
 }
 
-void remote_usbhc_request_address(device_t *device, void *iface,
+void remote_usbhc_request_address(ddf_fun_t *fun, void *iface,
     ipc_callid_t callid, ipc_call_t *call)
 {
@@ -168,5 +169,5 @@
 
 	usb_address_t address;
-	int rc = usb_iface->request_address(device, speed, &address);
+	int rc = usb_iface->request_address(fun, speed, &address);
 	if (rc != EOK) {
 		async_answer_0(callid, rc);
@@ -176,5 +177,5 @@
 }
 
-void remote_usbhc_bind_address(device_t *device, void *iface,
+void remote_usbhc_bind_address(ddf_fun_t *fun, void *iface,
     ipc_callid_t callid, ipc_call_t *call)
 {
@@ -189,10 +190,10 @@
 	devman_handle_t handle = (devman_handle_t) DEV_IPC_GET_ARG2(*call);
 
-	int rc = usb_iface->bind_address(device, address, handle);
+	int rc = usb_iface->bind_address(fun, address, handle);
 
 	async_answer_0(callid, rc);
 }
 
-void remote_usbhc_release_address(device_t *device, void *iface,
+void remote_usbhc_release_address(ddf_fun_t *fun, void *iface,
     ipc_callid_t callid, ipc_call_t *call)
 {
@@ -206,5 +207,5 @@
 	usb_address_t address = (usb_address_t) DEV_IPC_GET_ARG1(*call);
 
-	int rc = usb_iface->release_address(device, address);
+	int rc = usb_iface->release_address(fun, address);
 
 	async_answer_0(callid, rc);
@@ -212,5 +213,5 @@
 
 
-static void callback_out(device_t *device,
+static void callback_out(ddf_fun_t *fun,
     int outcome, void *arg)
 {
@@ -222,5 +223,5 @@
 }
 
-static void callback_in(device_t *device,
+static void callback_in(ddf_fun_t *fun,
     int outcome, size_t actual_size, void *arg)
 {
@@ -255,5 +256,5 @@
  * @param transfer_func Transfer function (might be NULL).
  */
-static void remote_usbhc_out_transfer(device_t *device,
+static void remote_usbhc_out_transfer(ddf_fun_t *fun,
     ipc_callid_t callid, ipc_call_t *call,
     usbhc_iface_transfer_out_t transfer_func)
@@ -294,5 +295,5 @@
 	trans->size = len;
 
-	rc = transfer_func(device, target, max_packet_size,
+	rc = transfer_func(fun, target, max_packet_size,
 	    buffer, len,
 	    callback_out, trans);
@@ -311,5 +312,5 @@
  * @param transfer_func Transfer function (might be NULL).
  */
-static void remote_usbhc_in_transfer(device_t *device,
+static void remote_usbhc_in_transfer(ddf_fun_t *fun,
     ipc_callid_t callid, ipc_call_t *call,
     usbhc_iface_transfer_in_t transfer_func)
@@ -342,5 +343,5 @@
 	trans->size = len;
 
-	int rc = transfer_func(device, target, max_packet_size,
+	int rc = transfer_func(fun, target, max_packet_size,
 	    trans->buffer, len,
 	    callback_in, trans);
@@ -352,5 +353,5 @@
 }
 
-void remote_usbhc_interrupt_out(device_t *device, void *iface,
+void remote_usbhc_interrupt_out(ddf_fun_t *fun, void *iface,
     ipc_callid_t callid, ipc_call_t *call)
 {
@@ -358,9 +359,9 @@
 	assert(usb_iface != NULL);
 
-	return remote_usbhc_out_transfer(device, callid, call,
+	return remote_usbhc_out_transfer(fun, callid, call,
 	    usb_iface->interrupt_out);
 }
 
-void remote_usbhc_interrupt_in(device_t *device, void *iface,
+void remote_usbhc_interrupt_in(ddf_fun_t *fun, void *iface,
     ipc_callid_t callid, ipc_call_t *call)
 {
@@ -368,9 +369,9 @@
 	assert(usb_iface != NULL);
 
-	return remote_usbhc_in_transfer(device, callid, call,
+	return remote_usbhc_in_transfer(fun, callid, call,
 	    usb_iface->interrupt_in);
 }
 
-void remote_usbhc_bulk_out(device_t *device, void *iface,
+void remote_usbhc_bulk_out(ddf_fun_t *fun, void *iface,
     ipc_callid_t callid, ipc_call_t *call)
 {
@@ -378,9 +379,9 @@
 	assert(usb_iface != NULL);
 
-	return remote_usbhc_out_transfer(device, callid, call,
+	return remote_usbhc_out_transfer(fun, callid, call,
 	    usb_iface->bulk_out);
 }
 
-void remote_usbhc_bulk_in(device_t *device, void *iface,
+void remote_usbhc_bulk_in(ddf_fun_t *fun, void *iface,
     ipc_callid_t callid, ipc_call_t *call)
 {
@@ -388,9 +389,9 @@
 	assert(usb_iface != NULL);
 
-	return remote_usbhc_in_transfer(device, callid, call,
+	return remote_usbhc_in_transfer(fun, callid, call,
 	    usb_iface->bulk_in);
 }
 
-void remote_usbhc_control_write(device_t *device, void *iface,
+void remote_usbhc_control_write(ddf_fun_t *fun, void *iface,
 ipc_callid_t callid, ipc_call_t *call)
 {
@@ -444,5 +445,5 @@
 	trans->size = data_buffer_len;
 
-	rc = usb_iface->control_write(device, target, max_packet_size,
+	rc = usb_iface->control_write(fun, target, max_packet_size,
 	    setup_packet, setup_packet_len,
 	    data_buffer, data_buffer_len,
@@ -456,5 +457,5 @@
 
 
-void remote_usbhc_control_read(device_t *device, void *iface,
+void remote_usbhc_control_read(ddf_fun_t *fun, void *iface,
 ipc_callid_t callid, ipc_call_t *call)
 {
@@ -509,5 +510,5 @@
 	}
 
-	rc = usb_iface->control_read(device, target, max_packet_size,
+	rc = usb_iface->control_read(fun, target, max_packet_size,
 	    setup_packet, setup_packet_len,
 	    trans->buffer, trans->size,
Index: uspace/lib/drv/include/ddf/driver.h
===================================================================
--- uspace/lib/drv/include/ddf/driver.h	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
+++ uspace/lib/drv/include/ddf/driver.h	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2010 Lenka Trochtova
+ * Copyright (c) 2011 Jiri Svoboda
+ * 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 DDF_DRIVER_H_
+#define DDF_DRIVER_H_
+
+#include <ipc/devman.h>
+#include <ipc/dev_iface.h>
+
+#include "../dev_iface.h"
+
+typedef struct ddf_dev ddf_dev_t;
+typedef struct ddf_fun ddf_fun_t;
+
+/*
+ * Device
+ */
+
+/** Devices operations */
+typedef struct ddf_dev_ops {
+	/**
+	 * Optional callback function called when a client is connecting to the
+	 * device.
+	 */
+	int (*open)(ddf_fun_t *);
+	
+	/**
+	 * Optional callback function called when a client is disconnecting from
+	 * the device.
+	 */
+	void (*close)(ddf_fun_t *);
+	
+	/** The table of standard interfaces implemented by the device. */
+	void *interfaces[DEV_IFACE_COUNT];
+	
+	/**
+	 * The default handler of remote client requests. If the client's remote
+	 * request cannot be handled by any of the standard interfaces, the
+	 * default handler is used.
+	 */
+	remote_handler_t *default_handler;
+} ddf_dev_ops_t;
+
+/** Device structure */
+struct ddf_dev {
+	/**
+	 * Globally unique device identifier (assigned to the device by the
+	 * device manager).
+	 */
+	devman_handle_t handle;
+	
+	/**
+	 * Phone to the parent device driver (if it is different from this
+	 * driver)
+	 */
+	int parent_phone;
+	
+	/** Device name */
+	const char *name;
+	
+	/** Driver-specific data associated with this device */
+	void *driver_data;
+	
+	/** Link in the list of devices handled by the driver */
+	link_t link;
+};
+
+/** Function structure */
+struct ddf_fun {
+	/** True if bound to the device manager */
+	bool bound;
+	/** Function indentifier (asigned by device manager) */
+	devman_handle_t handle;
+	
+	/** Device which this function belogs to */
+	ddf_dev_t *dev;
+	
+	/** Function type */
+	fun_type_t ftype;
+	/** Function name */
+	const char *name;
+	/** List of device ids for driver matching */
+	match_id_list_t match_ids;
+	/** Driver-specific data associated with this function */
+	void *driver_data;
+	/** Implementation of operations provided by this function */
+	ddf_dev_ops_t *ops;
+	
+	/** Link in the list of functions handled by the driver */
+	link_t link;
+};
+
+/*
+ * Driver
+ */
+
+/** Generic device driver operations */
+typedef struct driver_ops {
+	/** Callback method for passing a new device to the device driver */
+	int (*add_device)(ddf_dev_t *dev);
+	/* TODO: add other generic driver operations */
+} driver_ops_t;
+
+/** Driver structure */
+typedef struct driver {
+	/** Name of the device driver */
+	const char *name;
+	/** Generic device driver operations */
+	driver_ops_t *driver_ops;
+} driver_t;
+
+extern int ddf_driver_main(driver_t *);
+
+extern ddf_fun_t *ddf_fun_create(ddf_dev_t *, fun_type_t, const char *);
+extern void ddf_fun_destroy(ddf_fun_t *);
+extern int ddf_fun_bind(ddf_fun_t *);
+extern int ddf_fun_add_match_id(ddf_fun_t *, const char *, int);
+
+extern int ddf_fun_add_to_class(ddf_fun_t *, const char *);
+
+#endif
+
+/**
+ * @}
+ */
Index: uspace/lib/drv/include/ddf/interrupt.h
===================================================================
--- uspace/lib/drv/include/ddf/interrupt.h	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
+++ uspace/lib/drv/include/ddf/interrupt.h	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -0,0 +1,86 @@
+/*
+ * 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 DDF_INTERRUPT_H_
+#define DDF_INTERRUPT_H_
+
+#include <kernel/ddi/irq.h>
+#include <adt/list.h>
+#include <ddi.h>
+#include <fibril_synch.h>
+
+#include "driver.h"
+#include "../dev_iface.h"
+
+/*
+ * Interrupts
+ */
+
+typedef void interrupt_handler_t(ddf_dev_t *, ipc_callid_t, ipc_call_t *);
+
+typedef struct interrupt_context {
+	int id;
+	ddf_dev_t *dev;
+	int irq;
+	interrupt_handler_t *handler;
+	link_t link;
+} interrupt_context_t;
+
+typedef struct interrupt_context_list {
+	int curr_id;
+	link_t contexts;
+	fibril_mutex_t mutex;
+} interrupt_context_list_t;
+
+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 *, ddf_dev_t *, int);
+
+extern int register_interrupt_handler(ddf_dev_t *, int, interrupt_handler_t *,
+    irq_code_t *);
+extern int unregister_interrupt_handler(ddf_dev_t *, int);
+
+#endif
+
+/**
+ * @}
+ */
Index: uspace/lib/drv/include/dev_iface.h
===================================================================
--- uspace/lib/drv/include/dev_iface.h	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/lib/drv/include/dev_iface.h	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -43,5 +43,5 @@
  */
 
-struct device;
+struct ddf_fun;
 
 /*
@@ -49,8 +49,8 @@
  * devices driver.
  */
-typedef void remote_iface_func_t(struct device *, void *, ipc_callid_t,
+typedef void remote_iface_func_t(struct ddf_fun *, 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 void remote_handler_t(struct ddf_fun *, ipc_callid_t, ipc_call_t *);
 
 typedef struct {
Index: uspace/lib/drv/include/driver.h
===================================================================
--- uspace/lib/drv/include/driver.h	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ 	(revision )
@@ -1,194 +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_DRIVER_H_
-#define LIBDRV_DRIVER_H_
-
-#include <sys/types.h>
-#include <kernel/ddi/irq.h>
-#include <adt/list.h>
-#include <devman.h>
-#include <ipc/devman.h>
-#include <ipc/dev_iface.h>
-#include <assert.h>
-#include <ddi.h>
-#include <libarch/ddi.h>
-#include <fibril_synch.h>
-#include <malloc.h>
-
-#include "dev_iface.h"
-
-struct device;
-typedef struct device device_t;
-
-/*
- * Device class
- */
-
-/** Devices operations */
-typedef struct device_ops {
-	/**
-	 * Optional callback function called when a client is connecting to the
-	 * device.
-	 */
-	int (*open)(device_t *);
-	
-	/**
-	 * Optional callback function called when a client is disconnecting from
-	 * the device.
-	 */
-	void (*close)(device_t *);
-	
-	/** The table of standard interfaces implemented by the device. */
-	void *interfaces[DEV_IFACE_COUNT];
-	
-	/**
-	 * The default handler of remote client requests. If the client's remote
-	 * request cannot be handled by any of the standard interfaces, the
-	 * default handler is used.
-	 */
-	remote_handler_t *default_handler;
-} device_ops_t;
-
-
-/*
- * Device
- */
-
-/** Device structure */
-struct device {
-	/**
-	 * Globally unique device identifier (assigned to the device by the
-	 * device manager).
-	 */
-	devman_handle_t handle;
-	
-	/**
-	 * Phone to the parent device driver (if it is different from this
-	 * driver)
-	 */
-	int parent_phone;
-	
-	/** Parent device if handled by this driver, NULL otherwise */
-	device_t *parent;
-	/** Device name */
-	const char *name;
-	/** List of device ids for device-to-driver matching */
-	match_id_list_t match_ids;
-	/** Driver-specific data associated with this device */
-	void *driver_data;
-	/** The implementation of operations provided by this device */
-	device_ops_t *ops;
-	
-	/** Link in the list of devices handled by the driver */
-	link_t link;
-};
-
-/*
- * Driver
- */
-
-/** Generic device driver operations */
-typedef struct driver_ops {
-	/** Callback method for passing a new device to the device driver */
-	int (*add_device)(device_t *dev);
-	/* TODO: add other generic driver operations */
-} driver_ops_t;
-
-/** Driver structure */
-typedef struct driver {
-	/** Name of the device driver */
-	const char *name;
-	/** Generic device driver operations */
-	driver_ops_t *driver_ops;
-} driver_t;
-
-int driver_main(driver_t *);
-
-/** Create new device structure.
- *
- * @return		The device structure.
- */
-extern device_t *create_device(void);
-extern void delete_device(device_t *);
-extern void *device_get_ops(device_t *, dev_inferface_idx_t);
-
-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
- */
-
-typedef void interrupt_handler_t(device_t *, ipc_callid_t, ipc_call_t *);
-
-typedef struct interrupt_context {
-	int id;
-	device_t *dev;
-	int irq;
-	interrupt_handler_t *handler;
-	link_t link;
-} interrupt_context_t;
-
-typedef struct interrupt_context_list {
-	int curr_id;
-	link_t contexts;
-	fibril_mutex_t mutex;
-} interrupt_context_list_t;
-
-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);
-
-extern int register_interrupt_handler(device_t *, int, interrupt_handler_t *,
-    irq_code_t *);
-extern int unregister_interrupt_handler(device_t *, int);
-
-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 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/lib/drv/include/ops/char_dev.h	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -36,9 +36,9 @@
 #define LIBDRV_OPS_CHAR_DEV_H_
 
-#include "../driver.h"
+#include "../ddf/driver.h"
 
 typedef struct {
-	int (*read)(device_t *, char *, size_t);
-	int (*write)(device_t *, char *, size_t);
+	int (*read)(ddf_fun_t *, char *, size_t);
+	int (*write)(ddf_fun_t *, char *, size_t);
 } char_dev_ops_t;
 
Index: uspace/lib/drv/include/ops/hw_res.h
===================================================================
--- uspace/lib/drv/include/ops/hw_res.h	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/lib/drv/include/ops/hw_res.h	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -39,9 +39,9 @@
 #include <sys/types.h>
 
-#include "../driver.h"
+#include "../ddf/driver.h"
 
 typedef struct {
-	 hw_resource_list_t *(*get_resource_list)(device_t *);
-	 bool (*enable_interrupt)(device_t *);
+	 hw_resource_list_t *(*get_resource_list)(ddf_fun_t *);
+	 bool (*enable_interrupt)(ddf_fun_t *);
 } hw_res_ops_t;
 
Index: uspace/lib/drv/include/usb_iface.h
===================================================================
--- uspace/lib/drv/include/usb_iface.h	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/lib/drv/include/usb_iface.h	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -38,5 +38,5 @@
 #define LIBDRV_USB_IFACE_H_
 
-#include "driver.h"
+#include "ddf/driver.h"
 #include <usb/usb.h>
 typedef enum {
@@ -75,7 +75,7 @@
 /** USB device communication interface. */
 typedef struct {
-	int (*get_address)(device_t *, devman_handle_t, usb_address_t *);
-	int (*get_interface)(device_t *, devman_handle_t, int *);
-	int (*get_hc_handle)(device_t *, devman_handle_t *);
+	int (*get_address)(ddf_fun_t *, devman_handle_t, usb_address_t *);
+	int (*get_interface)(ddf_fun_t *, devman_handle_t, int *);
+	int (*get_hc_handle)(ddf_fun_t *, devman_handle_t *);
 } usb_iface_t;
 
Index: uspace/lib/drv/include/usbhc_iface.h
===================================================================
--- uspace/lib/drv/include/usbhc_iface.h	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/lib/drv/include/usbhc_iface.h	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -38,5 +38,5 @@
 #define LIBDRV_USBHC_IFACE_H_
 
-#include "driver.h"
+#include "ddf/driver.h"
 #include <usb/usb.h>
 #include <bool.h>
@@ -171,14 +171,14 @@
 
 /** Callback for outgoing transfer. */
-typedef void (*usbhc_iface_transfer_out_callback_t)(device_t *,
+typedef void (*usbhc_iface_transfer_out_callback_t)(ddf_fun_t *,
     int, void *);
 
 /** Callback for incoming transfer. */
-typedef void (*usbhc_iface_transfer_in_callback_t)(device_t *,
+typedef void (*usbhc_iface_transfer_in_callback_t)(ddf_fun_t *,
     int, size_t, void *);
 
 
 /** Out transfer processing function prototype. */
-typedef int (*usbhc_iface_transfer_out_t)(device_t *, usb_target_t, size_t,
+typedef int (*usbhc_iface_transfer_out_t)(ddf_fun_t *, usb_target_t, size_t,
     void *, size_t,
     usbhc_iface_transfer_out_callback_t, void *);
@@ -188,5 +188,5 @@
 
 /** In transfer processing function prototype. */
-typedef int (*usbhc_iface_transfer_in_t)(device_t *, usb_target_t, size_t,
+typedef int (*usbhc_iface_transfer_in_t)(ddf_fun_t *, usb_target_t, size_t,
     void *, size_t,
     usbhc_iface_transfer_in_callback_t, void *);
@@ -194,9 +194,9 @@
 /** USB host controller communication interface. */
 typedef struct {
-	int (*reserve_default_address)(device_t *, usb_speed_t);
-	int (*release_default_address)(device_t *);
-	int (*request_address)(device_t *, usb_speed_t, usb_address_t *);
-	int (*bind_address)(device_t *, usb_address_t, devman_handle_t);
-	int (*release_address)(device_t *, usb_address_t);
+	int (*reserve_default_address)(ddf_fun_t *, usb_speed_t);
+	int (*release_default_address)(ddf_fun_t *);
+	int (*request_address)(ddf_fun_t *, usb_speed_t, usb_address_t *);
+	int (*bind_address)(ddf_fun_t *, usb_address_t, devman_handle_t);
+	int (*release_address)(ddf_fun_t *, usb_address_t);
 
 	usbhc_iface_transfer_out_t interrupt_out;
@@ -206,10 +206,10 @@
 	usbhc_iface_transfer_in_t bulk_in;
 
-	int (*control_write)(device_t *, usb_target_t,
+	int (*control_write)(ddf_fun_t *, usb_target_t,
 	    size_t,
 	    void *, size_t, void *, size_t,
 	    usbhc_iface_transfer_out_callback_t, void *);
 
-	int (*control_read)(device_t *, usb_target_t,
+	int (*control_read)(ddf_fun_t *, usb_target_t,
 	    size_t,
 	    void *, size_t, void *, size_t,
Index: uspace/lib/usb/include/usb/ddfiface.h
===================================================================
--- uspace/lib/usb/include/usb/ddfiface.h	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/lib/usb/include/usb/ddfiface.h	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -40,15 +40,15 @@
 #include <usb_iface.h>
 
-int usb_iface_get_hc_handle_hub_impl(device_t *, devman_handle_t *);
-int usb_iface_get_address_hub_impl(device_t *, devman_handle_t,
+int usb_iface_get_hc_handle_hub_impl(ddf_fun_t *, devman_handle_t *);
+int usb_iface_get_address_hub_impl(ddf_fun_t *, devman_handle_t,
     usb_address_t *);
 extern usb_iface_t usb_iface_hub_impl;
 
-int usb_iface_get_hc_handle_hub_child_impl(device_t *, devman_handle_t *);
-int usb_iface_get_address_hub_child_impl(device_t *, devman_handle_t,
+int usb_iface_get_hc_handle_hub_child_impl(ddf_fun_t *, devman_handle_t *);
+int usb_iface_get_address_hub_child_impl(ddf_fun_t *, devman_handle_t,
     usb_address_t *);
 extern usb_iface_t usb_iface_hub_child_impl;
 
-int usb_iface_get_hc_handle_hc_impl(device_t *, devman_handle_t *);
+int usb_iface_get_hc_handle_hc_impl(ddf_fun_t *, devman_handle_t *);
 
 
Index: uspace/lib/usb/include/usb/hub.h
===================================================================
--- uspace/lib/usb/include/usb/hub.h	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/lib/usb/include/usb/hub.h	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -39,6 +39,8 @@
 #include <usb/usbdevice.h>
 
-int usb_hc_new_device_wrapper(device_t *, usb_hc_connection_t *, usb_speed_t,
-    int (*)(int, void *), int, void *, usb_address_t *, devman_handle_t *);
+int usb_hc_new_device_wrapper(ddf_dev_t *, usb_hc_connection_t *, usb_speed_t,
+    int (*)(int, void *), int, void *,
+    usb_address_t *, devman_handle_t *,
+    ddf_dev_ops_t *, void *, ddf_fun_t **);
 
 /** Info about device attached to host controller.
Index: uspace/lib/usb/include/usb/pipes.h
===================================================================
--- uspace/lib/usb/include/usb/pipes.h	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/lib/usb/include/usb/pipes.h	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -41,5 +41,5 @@
 #include <usb/descriptor.h>
 #include <ipc/devman.h>
-#include <driver.h>
+#include <ddf/driver.h>
 
 /**
@@ -120,9 +120,9 @@
     usb_device_connection_t *, usb_hc_connection_t *);
 int usb_device_connection_initialize_from_device(usb_device_connection_t *,
-    device_t *);
+    ddf_dev_t *);
 int usb_device_connection_initialize(usb_device_connection_t *,
     devman_handle_t, usb_address_t);
 
-int usb_device_get_assigned_interface(device_t *);
+int usb_device_get_assigned_interface(ddf_dev_t *);
 
 int usb_endpoint_pipe_initialize(usb_endpoint_pipe_t *,
Index: uspace/lib/usb/include/usb/recognise.h
===================================================================
--- uspace/lib/usb/include/usb/recognise.h	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/lib/usb/include/usb/recognise.h	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -50,6 +50,6 @@
 int usb_device_create_match_ids(usb_endpoint_pipe_t *, match_id_list_t *);
 
-int usb_device_register_child_in_devman(usb_address_t address, devman_handle_t hc_handle,
-    device_t *parent, devman_handle_t *child_handle);
+int usb_device_register_child_in_devman(usb_address_t, devman_handle_t,
+    ddf_dev_t *, devman_handle_t *, ddf_dev_ops_t *, void *, ddf_fun_t **);
 
 #endif
Index: uspace/lib/usb/include/usb/usbdevice.h
===================================================================
--- uspace/lib/usb/include/usb/usbdevice.h	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/lib/usb/include/usb/usbdevice.h	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -38,5 +38,5 @@
 #include <sys/types.h>
 #include <ipc/devman.h>
-#include <driver.h>
+#include <ddf/driver.h>
 #include <bool.h>
 #include <usb/usb.h>
@@ -53,5 +53,5 @@
 
 int usb_hc_connection_initialize_from_device(usb_hc_connection_t *,
-    device_t *);
+    ddf_dev_t *);
 int usb_hc_connection_initialize(usb_hc_connection_t *, devman_handle_t);
 
Index: uspace/lib/usb/src/ddfiface.c
===================================================================
--- uspace/lib/usb/src/ddfiface.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/lib/usb/src/ddfiface.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -34,6 +34,10 @@
  */
 #include <ipc/devman.h>
+#include <devman.h>
+#include <async.h>
 #include <usb/ddfiface.h>
+#include <usb/debug.h>
 #include <errno.h>
+#include <assert.h>
 
 /** DDF interface for USB device, implementation for typical hub. */
@@ -56,8 +60,8 @@
  * @return Error code.
  */
-int usb_iface_get_hc_handle_hub_impl(device_t *device, devman_handle_t *handle)
+int usb_iface_get_hc_handle_hub_impl(ddf_fun_t *fun, devman_handle_t *handle)
 {
-	assert(device);
-	return usb_hc_find(device->handle, handle);
+	assert(fun);
+	return usb_hc_find(fun->handle, handle);
 }
 
@@ -69,24 +73,26 @@
  * @return Error code.
  */
-int usb_iface_get_hc_handle_hub_child_impl(device_t *device,
+int usb_iface_get_hc_handle_hub_child_impl(ddf_fun_t *fun,
     devman_handle_t *handle)
 {
-	assert(device);
-	device_t *parent = device->parent;
+	assert(fun != NULL);
 
-	/* Default error, device does not support this operation. */
-	int rc = ENOTSUP;
-
-	if (parent && parent->ops && parent->ops->interfaces[USB_DEV_IFACE]) {
-		usb_iface_t *usb_iface
-		    = (usb_iface_t *) parent->ops->interfaces[USB_DEV_IFACE];
-		assert(usb_iface != NULL);
-
-		if (usb_iface->get_hc_handle) {
-			rc = usb_iface->get_hc_handle(parent, handle);
-		}
+	int parent_phone = devman_parent_device_connect(fun->handle,
+	    IPC_FLAG_BLOCKING);
+	if (parent_phone < 0) {
+		return parent_phone;
 	}
 
-	return rc;
+	sysarg_t hc_handle;
+	int rc = async_req_1_1(parent_phone, DEV_IFACE_ID(USB_DEV_IFACE),
+	    IPC_M_USB_GET_HOST_CONTROLLER_HANDLE, &hc_handle);
+
+	if (rc != EOK) {
+		return rc;
+	}
+
+	*handle = hc_handle;
+
+	return EOK;
 }
 
@@ -97,10 +103,10 @@
  * @return Always EOK.
  */
-int usb_iface_get_hc_handle_hc_impl(device_t *device, devman_handle_t *handle)
+int usb_iface_get_hc_handle_hc_impl(ddf_fun_t *fun, devman_handle_t *handle)
 {
-	assert(device);
+	assert(fun);
 
 	if (handle != NULL) {
-		*handle = device->handle;
+		*handle = fun->handle;
 	}
 
@@ -115,9 +121,9 @@
  * @return Error code.
  */
-int usb_iface_get_address_hub_impl(device_t *device, devman_handle_t handle,
+int usb_iface_get_address_hub_impl(ddf_fun_t *fun, devman_handle_t handle,
     usb_address_t *address)
 {
-	assert(device);
-	int parent_phone = devman_parent_device_connect(device->handle,
+	assert(fun);
+	int parent_phone = devman_parent_device_connect(fun->handle,
 	    IPC_FLAG_BLOCKING);
 	if (parent_phone < 0) {
@@ -150,24 +156,11 @@
  * @return Error code.
  */
-int usb_iface_get_address_hub_child_impl(device_t *device,
+int usb_iface_get_address_hub_child_impl(ddf_fun_t *fun,
     devman_handle_t handle, usb_address_t *address)
 {
-	assert(device);
-	device_t *parent = device->parent;
-
-	/* Default error, device does not support this operation. */
-	int rc = ENOTSUP;
-
-	if (parent && parent->ops && parent->ops->interfaces[USB_DEV_IFACE]) {
-		usb_iface_t *usb_iface
-		    = (usb_iface_t *) parent->ops->interfaces[USB_DEV_IFACE];
-		assert(usb_iface != NULL);
-
-		if (usb_iface->get_address) {
-			rc = usb_iface->get_address(parent, handle, address);
-		}
+	if (handle == 0) {
+		handle = fun->handle;
 	}
-
-	return rc;
+	return usb_iface_get_address_hub_impl(fun, handle, address);
 }
 
Index: uspace/lib/usb/src/hub.c
===================================================================
--- uspace/lib/usb/src/hub.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/lib/usb/src/hub.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -39,4 +39,5 @@
 #include <usbhc_iface.h>
 #include <errno.h>
+#include <assert.h>
 
 /** Check that HC connection is alright.
@@ -172,8 +173,9 @@
  *	request or requests for descriptors when creating match ids).
  */
-int usb_hc_new_device_wrapper(device_t *parent, usb_hc_connection_t *connection,
+int usb_hc_new_device_wrapper(ddf_dev_t *parent, usb_hc_connection_t *connection,
     usb_speed_t dev_speed,
     int (*enable_port)(int port_no, void *arg), int port_no, void *arg,
-    usb_address_t *assigned_address, devman_handle_t *assigned_handle)
+    usb_address_t *assigned_address, devman_handle_t *assigned_handle,
+    ddf_dev_ops_t *dev_ops, void *new_dev_data, ddf_fun_t **new_fun)
 {
 	CHECK_CONNECTION(connection);
@@ -251,5 +253,6 @@
 	devman_handle_t child_handle;
 	rc = usb_device_register_child_in_devman(dev_addr, dev_conn.hc_handle,
-	    parent, &child_handle);
+	    parent, &child_handle,
+	    dev_ops, new_dev_data, new_fun);
 	if (rc != EOK) {
 		rc = ESTALL;
Index: uspace/lib/usb/src/pipes.c
===================================================================
--- uspace/lib/usb/src/pipes.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/lib/usb/src/pipes.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -35,6 +35,8 @@
 #include <usb/usb.h>
 #include <usb/pipes.h>
+#include <usb/debug.h>
 #include <usbhc_iface.h>
 #include <usb_iface.h>
+#include <devman.h>
 #include <errno.h>
 #include <assert.h>
@@ -46,10 +48,17 @@
  * @return USB address or error code.
  */
-static usb_address_t get_my_address(int phone, device_t *dev)
+static usb_address_t get_my_address(int phone, ddf_dev_t *dev)
 {
 	sysarg_t address;
+
+
+	/*
+	 * We are sending special value as a handle - zero - to get
+	 * handle of the parent function (that handle was used
+	 * when registering our device @p dev.
+	 */
 	int rc = async_req_2_1(phone, DEV_IFACE_ID(USB_DEV_IFACE),
 	    IPC_M_USB_GET_ADDRESS,
-	    dev->handle, &address);
+	    0, &address);
 
 	if (rc != EOK) {
@@ -65,5 +74,5 @@
  * @return Interface number (negative code means any).
  */
-int usb_device_get_assigned_interface(device_t *device)
+int usb_device_get_assigned_interface(ddf_dev_t *device)
 {
 	int parent_phone = devman_parent_device_connect(device->handle,
@@ -94,8 +103,8 @@
  */
 int usb_device_connection_initialize_from_device(
-    usb_device_connection_t *connection, device_t *device)
+    usb_device_connection_t *connection, ddf_dev_t *dev)
 {
 	assert(connection);
-	assert(device);
+	assert(dev);
 
 	int rc;
@@ -103,10 +112,10 @@
 	usb_address_t my_address;
 
-	rc = usb_hc_find(device->handle, &hc_handle);
+	rc = usb_hc_find(dev->handle, &hc_handle);
 	if (rc != EOK) {
 		return rc;
 	}
 
-	int parent_phone = devman_parent_device_connect(device->handle,
+	int parent_phone = devman_parent_device_connect(dev->handle,
 	    IPC_FLAG_BLOCKING);
 	if (parent_phone < 0) {
@@ -114,5 +123,5 @@
 	}
 
-	my_address = get_my_address(parent_phone, device);
+	my_address = get_my_address(parent_phone, dev);
 	if (my_address < 0) {
 		rc = my_address;
Index: uspace/lib/usb/src/recognise.c
===================================================================
--- uspace/lib/usb/src/recognise.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/lib/usb/src/recognise.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -34,4 +34,5 @@
  */
 #include <sys/types.h>
+#include <fibril_synch.h>
 #include <usb/pipes.h>
 #include <usb/recognise.h>
@@ -41,9 +42,10 @@
 #include <stdio.h>
 #include <errno.h>
+#include <assert.h>
 
 static size_t device_name_index = 0;
 static FIBRIL_MUTEX_INITIALIZE(device_name_index_mutex);
 
-device_ops_t child_ops = {
+ddf_dev_ops_t child_ops = {
 	.interfaces[USB_DEV_IFACE] = &usb_iface_hub_child_impl
 };
@@ -326,5 +328,6 @@
 int usb_device_register_child_in_devman(usb_address_t address,
     devman_handle_t hc_handle,
-    device_t *parent, devman_handle_t *child_handle)
+    ddf_dev_t *parent, devman_handle_t *child_handle,
+    ddf_dev_ops_t *dev_ops, void *dev_data, ddf_fun_t **child_fun)
 {
 	size_t this_device_name_index;
@@ -335,5 +338,5 @@
 	fibril_mutex_unlock(&device_name_index_mutex);
 
-	device_t *child = NULL;
+	ddf_fun_t *child = NULL;
 	char *child_name = NULL;
 	int rc;
@@ -352,5 +355,14 @@
 	}
 
-	child = create_device();
+	/*
+	 * TODO: Once the device driver framework support persistent
+	 * naming etc., something more descriptive could be created.
+	 */
+	rc = asprintf(&child_name, "usbdev%02zu", this_device_name_index);
+	if (rc < 0) {
+		goto failure;
+	}
+
+	child = ddf_fun_create(parent, fun_inner, child_name);
 	if (child == NULL) {
 		rc = ENOMEM;
@@ -358,15 +370,11 @@
 	}
 
-	/*
-	 * TODO: Once the device driver framework support persistent
-	 * naming etc., something more descriptive could be created.
-	 */
-	rc = asprintf(&child_name, "usbdev%02zu", this_device_name_index);
-	if (rc < 0) {
-		goto failure;
-	}
-	child->parent = parent;
-	child->name = child_name;
-	child->ops = &child_ops;
+	if (dev_ops != NULL) {
+		child->ops = dev_ops;
+	} else {
+		child->ops = &child_ops;
+	}
+
+	child->driver_data = dev_data;
 
 	rc = usb_endpoint_pipe_start_session(&ctrl_pipe);
@@ -385,5 +393,5 @@
 	}
 
-	rc = child_device_register(child, parent);
+	rc = ddf_fun_bind(child);
 	if (rc != EOK) {
 		goto failure;
@@ -392,4 +400,8 @@
 	if (child_handle != NULL) {
 		*child_handle = child->handle;
+	}
+
+	if (child_fun != NULL) {
+		*child_fun = child;
 	}
 
@@ -400,5 +412,5 @@
 		child->name = NULL;
 		/* This takes care of match_id deallocation as well. */
-		delete_device(child);
+		ddf_fun_destroy(child);
 	}
 	if (child_name != NULL) {
Index: uspace/lib/usb/src/request.c
===================================================================
--- uspace/lib/usb/src/request.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/lib/usb/src/request.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -35,4 +35,5 @@
 #include <usb/request.h>
 #include <errno.h>
+#include <assert.h>
 
 #define MAX_DATA_LENGTH ((size_t)(0xFFFF))
Index: uspace/lib/usb/src/usbdevice.c
===================================================================
--- uspace/lib/usb/src/usbdevice.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/lib/usb/src/usbdevice.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -37,5 +37,7 @@
 #include <usb_iface.h>
 #include <usb/usbdevice.h>
+#include <usb/debug.h>
 #include <errno.h>
+#include <assert.h>
 
 /** Find host controller handle that is ancestor of given device.
@@ -55,4 +57,5 @@
 
 	devman_handle_t h;
+	usb_log_debug("asking for HC handle (my handle is %zu).\n", device_handle);
 	int rc = async_req_1_1(parent_phone, DEV_IFACE_ID(USB_DEV_IFACE),
 	    IPC_M_USB_GET_HOST_CONTROLLER_HANDLE, &h);
@@ -78,5 +81,5 @@
  */
 int usb_hc_connection_initialize_from_device(usb_hc_connection_t *connection,
-    device_t *device)
+    ddf_dev_t *device)
 {
 	assert(connection);
Index: uspace/lib/usbvirt/src/main.c
===================================================================
--- uspace/lib/usbvirt/src/main.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/lib/usbvirt/src/main.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -203,5 +203,5 @@
 	}
 	
-	const char *vhc_path = "/virt/usbhc";
+	const char *vhc_path = "/virt/usbhc/hc";
 	int rc;
 	devman_handle_t handle;
Index: uspace/srv/devman/devman.c
===================================================================
--- uspace/srv/devman/devman.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/srv/devman/devman.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -41,4 +41,6 @@
 #include "devman.h"
 
+fun_node_t *find_node_child(fun_node_t *parent, const char *name);
+
 /* hash table operations */
 
@@ -51,13 +53,20 @@
     link_t *item)
 {
-	node_t *dev = hash_table_get_instance(item, node_t, devman_link);
+	dev_node_t *dev = hash_table_get_instance(item, dev_node_t, devman_dev);
 	return (dev->handle == (devman_handle_t) key[0]);
 }
 
-static int devmap_devices_compare(unsigned long key[], hash_count_t keys,
+static int devman_functions_compare(unsigned long key[], hash_count_t keys,
     link_t *item)
 {
-	node_t *dev = hash_table_get_instance(item, node_t, devmap_link);
-	return (dev->devmap_handle == (devmap_handle_t) key[0]);
+	fun_node_t *fun = hash_table_get_instance(item, fun_node_t, devman_fun);
+	return (fun->handle == (devman_handle_t) key[0]);
+}
+
+static int devmap_functions_compare(unsigned long key[], hash_count_t keys,
+    link_t *item)
+{
+	fun_node_t *fun = hash_table_get_instance(item, fun_node_t, devmap_fun);
+	return (fun->devmap_handle == (devmap_handle_t) key[0]);
 }
 
@@ -82,7 +91,13 @@
 };
 
+static hash_table_operations_t devman_functions_ops = {
+	.hash = devices_hash,
+	.compare = devman_functions_compare,
+	.remove_callback = devices_remove_callback
+};
+
 static hash_table_operations_t devmap_devices_ops = {
 	.hash = devices_hash,
-	.compare = devmap_devices_compare,
+	.compare = devmap_functions_compare,
 	.remove_callback = devices_remove_callback
 };
@@ -381,28 +396,52 @@
 }
 
-/** Create root device node in the device tree.
+/** Create root device and function node in the device tree.
  *
  * @param tree	The device tree.
  * @return	True on success, false otherwise.
  */
-bool create_root_node(dev_tree_t *tree)
-{
-	node_t *node;
-
-	printf(NAME ": create_root_node\n");
-
+bool create_root_nodes(dev_tree_t *tree)
+{
+	fun_node_t *fun;
+	dev_node_t *dev;
+	
+	printf(NAME ": create_root_nodes\n");
+	
 	fibril_rwlock_write_lock(&tree->rwlock);
-	node = create_dev_node();
-	if (node != NULL) {
-		insert_dev_node(tree, node, clone_string(""), NULL);
-		match_id_t *id = create_match_id();
-		id->id = clone_string("root");
-		id->score = 100;
-		add_match_id(&node->match_ids, id);
-		tree->root_node = node;
-	}
+	
+	/*
+	 * Create root function. This is a pseudo function to which
+	 * the root device node is attached. It allows us to match
+	 * the root device driver in a standard manner, i.e. against
+	 * the parent function.
+	 */
+	
+	fun = create_fun_node();
+	if (fun == NULL) {
+		fibril_rwlock_write_unlock(&tree->rwlock);
+		return false;
+	}
+	
+	insert_fun_node(tree, fun, clone_string(""), NULL);
+	match_id_t *id = create_match_id();
+	id->id = clone_string("root");
+	id->score = 100;
+	add_match_id(&fun->match_ids, id);
+	tree->root_node = fun;
+	
+	/*
+	 * Create root device node.
+	 */
+	dev = create_dev_node();
+	if (dev == NULL) {
+		fibril_rwlock_write_unlock(&tree->rwlock);
+		return false;
+	}
+	
+	insert_dev_node(tree, dev, fun);
+	
 	fibril_rwlock_write_unlock(&tree->rwlock);
-
-	return node != NULL;
+	
+	return dev != NULL;
 }
 
@@ -422,5 +461,5 @@
  *			is found.
  */
-driver_t *find_best_match_driver(driver_list_t *drivers_list, node_t *node)
+driver_t *find_best_match_driver(driver_list_t *drivers_list, dev_node_t *node)
 {
 	driver_t *best_drv = NULL, *drv = NULL;
@@ -450,13 +489,13 @@
  * @param drv		The driver.
  */
-void attach_driver(node_t *node, driver_t *drv)
+void attach_driver(dev_node_t *dev, driver_t *drv)
 {
 	printf(NAME ": attach_driver %s to device %s\n",
-	    drv->name, node->pathname);
+	    drv->name, dev->pfun->pathname);
 	
 	fibril_mutex_lock(&drv->driver_mutex);
 	
-	node->drv = drv;
-	list_append(&node->driver_devices, &drv->devices);
+	dev->drv = drv;
+	list_append(&dev->driver_devices, &drv->devices);
 	
 	fibril_mutex_unlock(&drv->driver_mutex);
@@ -538,5 +577,5 @@
 static void pass_devices_to_driver(driver_t *driver, dev_tree_t *tree)
 {
-	node_t *dev;
+	dev_node_t *dev;
 	link_t *link;
 	int phone;
@@ -559,5 +598,5 @@
 	link = driver->devices.next;
 	while (link != &driver->devices) {
-		dev = list_get_instance(link, node_t, driver_devices);
+		dev = list_get_instance(link, dev_node_t, driver_devices);
 		if (dev->passed_to_driver) {
 			link = link->next;
@@ -677,11 +716,11 @@
 }
 
-/** Create devmap path and name for the device. */
-static void devmap_register_tree_device(node_t *node, dev_tree_t *tree)
+/** Create devmap path and name for the function. */
+void devmap_register_tree_function(fun_node_t *fun, dev_tree_t *tree)
 {
 	char *devmap_pathname = NULL;
 	char *devmap_name = NULL;
 	
-	asprintf(&devmap_name, "%s", node->pathname);
+	asprintf(&devmap_name, "%s", fun->pathname);
 	if (devmap_name == NULL)
 		return;
@@ -697,7 +736,7 @@
 	
 	devmap_device_register_with_iface(devmap_pathname,
-	    &node->devmap_handle, DEVMAN_CONNECT_FROM_DEVMAP);
-	
-	tree_add_devmap_device(tree, node);
+	    &fun->devmap_handle, DEVMAN_CONNECT_FROM_DEVMAP);
+	
+	tree_add_devmap_function(tree, fun);
 	
 	free(devmap_name);
@@ -710,5 +749,5 @@
  * @param node		The device's node in the device tree.
  */
-void add_device(int phone, driver_t *drv, node_t *node, dev_tree_t *tree)
+void add_device(int phone, driver_t *drv, dev_node_t *dev, dev_tree_t *tree)
 {
 	/*
@@ -717,5 +756,5 @@
 	 */
 	printf(NAME ": add_device (driver `%s', device `%s')\n", drv->name,
-	    node->name);
+	    dev->pfun->name);
 	
 	sysarg_t rc;
@@ -724,16 +763,16 @@
 	/* Send the device to the driver. */
 	devman_handle_t parent_handle;
-	if (node->parent) {
-		parent_handle = node->parent->handle;
+	if (dev->pfun) {
+		parent_handle = dev->pfun->handle;
 	} else {
 		parent_handle = 0;
 	}
 
-	aid_t req = async_send_2(phone, DRIVER_ADD_DEVICE, node->handle,
+	aid_t req = async_send_2(phone, DRIVER_ADD_DEVICE, dev->handle,
 	    parent_handle, &answer);
 	
 	/* Send the device's name to the driver. */
-	rc = async_data_write_start(phone, node->name,
-	    str_size(node->name) + 1);
+	rc = async_data_write_start(phone, dev->pfun->name,
+	    str_size(dev->pfun->name) + 1);
 	if (rc != EOK) {
 		/* TODO handle error */
@@ -745,15 +784,14 @@
 	switch(rc) {
 	case EOK:
-		node->state = DEVICE_USABLE;
-		devmap_register_tree_device(node, tree);
+		dev->state = DEVICE_USABLE;
 		break;
 	case ENOENT:
-		node->state = DEVICE_NOT_PRESENT;
+		dev->state = DEVICE_NOT_PRESENT;
 		break;
 	default:
-		node->state = DEVICE_INVALID;
-	}
-	
-	node->passed_to_driver = true;
+		dev->state = DEVICE_INVALID;
+	}
+	
+	dev->passed_to_driver = true;
 
 	return;
@@ -767,18 +805,23 @@
  *			successfully assigned to the device, false otherwise.
  */
-bool assign_driver(node_t *node, driver_list_t *drivers_list, dev_tree_t *tree)
-{
+bool assign_driver(dev_node_t *dev, driver_list_t *drivers_list,
+    dev_tree_t *tree)
+{
+	assert(dev != NULL);
+	assert(drivers_list != NULL);
+	assert(tree != NULL);
+	
 	/*
 	 * Find the driver which is the most suitable for handling this device.
 	 */
-	driver_t *drv = find_best_match_driver(drivers_list, node);
+	driver_t *drv = find_best_match_driver(drivers_list, dev);
 	if (drv == NULL) {
 		printf(NAME ": no driver found for device '%s'.\n",
-		    node->pathname);
+		    dev->pfun->pathname);
 		return false;
 	}
 	
 	/* Attach the driver to the device. */
-	attach_driver(node, drv);
+	attach_driver(dev, drv);
 	
 	fibril_mutex_lock(&drv->driver_mutex);
@@ -794,5 +837,5 @@
 		int phone = async_connect_me_to(drv->phone, DRIVER_DEVMAN, 0, 0);
 		if (phone >= 0) {
-			add_device(phone, drv, node, tree);
+			add_device(phone, drv, dev, tree);
 			async_hangup(phone);
 		}
@@ -818,15 +861,17 @@
 	hash_table_create(&tree->devman_devices, DEVICE_BUCKETS, 1,
 	    &devman_devices_ops);
-	hash_table_create(&tree->devmap_devices, DEVICE_BUCKETS, 1,
+	hash_table_create(&tree->devman_functions, DEVICE_BUCKETS, 1,
+	    &devman_functions_ops);
+	hash_table_create(&tree->devmap_functions, DEVICE_BUCKETS, 1,
 	    &devmap_devices_ops);
 	
 	fibril_rwlock_initialize(&tree->rwlock);
 	
-	/* Create root node and add it to the device tree. */
-	if (!create_root_node(tree))
+	/* Create root function and root device and add them to the device tree. */
+	if (!create_root_nodes(tree))
 		return false;
 
 	/* Find suitable driver and start it. */
-	return assign_driver(tree->root_node, drivers_list, tree);
+	return assign_driver(tree->root_node->child, drivers_list, tree);
 }
 
@@ -837,13 +882,13 @@
  * @return		A device node structure.
  */
-node_t *create_dev_node(void)
-{
-	node_t *res = malloc(sizeof(node_t));
+dev_node_t *create_dev_node(void)
+{
+	dev_node_t *res = malloc(sizeof(dev_node_t));
 	
 	if (res != NULL) {
-		memset(res, 0, sizeof(node_t));
-		list_initialize(&res->children);
-		list_initialize(&res->match_ids.ids);
-		list_initialize(&res->classes);
+		memset(res, 0, sizeof(dev_node_t));
+		list_initialize(&res->functions);
+		link_initialize(&res->driver_devices);
+		link_initialize(&res->devman_dev);
 	}
 	
@@ -855,14 +900,11 @@
  * @param node		The device node structure.
  */
-void delete_dev_node(node_t *node)
-{
-	assert(list_empty(&node->children));
-	assert(node->parent == NULL);
-	assert(node->drv == NULL);
-	
-	clean_match_ids(&node->match_ids);
-	free_not_null(node->name);
-	free_not_null(node->pathname);
-	free(node);
+void delete_dev_node(dev_node_t *dev)
+{
+	assert(list_empty(&dev->functions));
+	assert(dev->pfun == NULL);
+	assert(dev->drv == NULL);
+	
+	free(dev);
 }
 
@@ -873,5 +915,5 @@
  * @return		The device node.
  */
-node_t *find_dev_node_no_lock(dev_tree_t *tree, devman_handle_t handle)
+dev_node_t *find_dev_node_no_lock(dev_tree_t *tree, devman_handle_t handle)
 {
 	unsigned long key = handle;
@@ -881,5 +923,5 @@
 	
 	link = hash_table_find(&tree->devman_devices, &key);
-	return hash_table_get_instance(link, node_t, devman_link);
+	return hash_table_get_instance(link, dev_node_t, devman_dev);
 }
 
@@ -890,15 +932,88 @@
  * @return		The device node.
  */
-node_t *find_dev_node(dev_tree_t *tree, devman_handle_t handle)
-{
-	node_t *node = NULL;
+dev_node_t *find_dev_node(dev_tree_t *tree, devman_handle_t handle)
+{
+	dev_node_t *dev = NULL;
 	
 	fibril_rwlock_read_lock(&tree->rwlock);
-	node = find_dev_node_no_lock(tree, handle);
+	dev = find_dev_node_no_lock(tree, handle);
 	fibril_rwlock_read_unlock(&tree->rwlock);
 	
-	return node;
-}
-
+	return dev;
+}
+
+/* Function nodes */
+
+/** Create a new function node.
+ *
+ * @return		A function node structure.
+ */
+fun_node_t *create_fun_node(void)
+{
+	fun_node_t *res = malloc(sizeof(fun_node_t));
+	
+	if (res != NULL) {
+		memset(res, 0, sizeof(fun_node_t));
+		link_initialize(&res->dev_functions);
+		list_initialize(&res->match_ids.ids);
+		list_initialize(&res->classes);
+		link_initialize(&res->devman_fun);
+		link_initialize(&res->devmap_fun);
+	}
+	
+	return res;
+}
+
+/** Delete a function node.
+ *
+ * @param fun		The device node structure.
+ */
+void delete_fun_node(fun_node_t *fun)
+{
+	assert(fun->dev == NULL);
+	assert(fun->child == NULL);
+	
+	clean_match_ids(&fun->match_ids);
+	free_not_null(fun->name);
+	free_not_null(fun->pathname);
+	free(fun);
+}
+
+/** Find the function node with the specified handle.
+ *
+ * @param tree		The device tree where we look for the device node.
+ * @param handle	The handle of the function.
+ * @return		The function node.
+ */
+fun_node_t *find_fun_node_no_lock(dev_tree_t *tree, devman_handle_t handle)
+{
+	unsigned long key = handle;
+	link_t *link;
+	
+	assert(fibril_rwlock_is_locked(&tree->rwlock));
+	
+	link = hash_table_find(&tree->devman_functions, &key);
+	if (link == NULL)
+		return NULL;
+	
+	return hash_table_get_instance(link, fun_node_t, devman_fun);
+}
+
+/** Find the function node with the specified handle.
+ *
+ * @param tree		The device tree where we look for the device node.
+ * @param handle	The handle of the function.
+ * @return		The function node.
+ */
+fun_node_t *find_fun_node(dev_tree_t *tree, devman_handle_t handle)
+{
+	fun_node_t *fun = NULL;
+	
+	fibril_rwlock_read_lock(&tree->rwlock);
+	fun = find_fun_node_no_lock(tree, handle);
+	fibril_rwlock_read_unlock(&tree->rwlock);
+	
+	return fun;
+}
 
 /** Create and set device's full path in device tree.
@@ -909,14 +1024,14 @@
  *			resources etc.).
  */
-static bool set_dev_path(node_t *node, node_t *parent)
-{
-	assert(node->name != NULL);
-	
-	size_t pathsize = (str_size(node->name) + 1);
+static bool set_fun_path(fun_node_t *fun, fun_node_t *parent)
+{
+	assert(fun->name != NULL);
+	
+	size_t pathsize = (str_size(fun->name) + 1);
 	if (parent != NULL)
 		pathsize += str_size(parent->pathname) + 1;
 	
-	node->pathname = (char *) malloc(pathsize);
-	if (node->pathname == NULL) {
+	fun->pathname = (char *) malloc(pathsize);
+	if (fun->pathname == NULL) {
 		printf(NAME ": failed to allocate device path.\n");
 		return false;
@@ -924,9 +1039,9 @@
 	
 	if (parent != NULL) {
-		str_cpy(node->pathname, pathsize, parent->pathname);
-		str_append(node->pathname, pathsize, "/");
-		str_append(node->pathname, pathsize, node->name);
+		str_cpy(fun->pathname, pathsize, parent->pathname);
+		str_append(fun->pathname, pathsize, "/");
+		str_append(fun->pathname, pathsize, fun->name);
 	} else {
-		str_cpy(node->pathname, pathsize, node->name);
+		str_cpy(fun->pathname, pathsize, fun->name);
 	}
 	
@@ -944,44 +1059,81 @@
  *			etc.).
  */
-bool insert_dev_node(dev_tree_t *tree, node_t *node, char *dev_name,
-    node_t *parent)
-{
-	assert(node != NULL);
+bool insert_dev_node(dev_tree_t *tree, dev_node_t *dev, fun_node_t *pfun)
+{
+	assert(dev != NULL);
 	assert(tree != NULL);
-	assert(dev_name != NULL);
 	assert(fibril_rwlock_is_write_locked(&tree->rwlock));
 	
-	node->name = dev_name;
-	if (!set_dev_path(node, parent)) {
+	/* Add the node to the handle-to-node map. */
+	dev->handle = ++tree->current_handle;
+	unsigned long key = dev->handle;
+	hash_table_insert(&tree->devman_devices, &key, &dev->devman_dev);
+
+	/* Add the node to the list of its parent's children. */
+	printf("insert_dev_node: dev=%p, dev->pfun := %p\n", dev, pfun);
+	dev->pfun = pfun;
+	pfun->child = dev;
+	
+	return true;
+}
+
+/** Insert new function into device tree.
+ *
+ * @param tree		The device tree.
+ * @param node		The newly added function node. 
+ * @param dev_name	The name of the newly added function.
+ * @param parent	Owning device node.
+ *
+ * @return		True on success, false otherwise (insufficient resources
+ *			etc.).
+ */
+bool insert_fun_node(dev_tree_t *tree, fun_node_t *fun, char *fun_name,
+    dev_node_t *dev)
+{
+	fun_node_t *pfun;
+	
+	assert(fun != NULL);
+	assert(tree != NULL);
+	assert(fun_name != NULL);
+	assert(fibril_rwlock_is_write_locked(&tree->rwlock));
+	
+	/*
+	 * The root function is a special case, it does not belong to any
+	 * device so for the root function dev == NULL.
+	 */
+	pfun = (dev != NULL) ? dev->pfun : NULL;
+	
+	fun->name = fun_name;
+	if (!set_fun_path(fun, pfun)) {
 		return false;
 	}
 	
 	/* Add the node to the handle-to-node map. */
-	node->handle = ++tree->current_handle;
-	unsigned long key = node->handle;
-	hash_table_insert(&tree->devman_devices, &key, &node->devman_link);
+	fun->handle = ++tree->current_handle;
+	unsigned long key = fun->handle;
+	hash_table_insert(&tree->devman_functions, &key, &fun->devman_fun);
 
 	/* Add the node to the list of its parent's children. */
-	node->parent = parent;
-	if (parent != NULL)
-		list_append(&node->sibling, &parent->children);
+	fun->dev = dev;
+	if (dev != NULL)
+		list_append(&fun->dev_functions, &dev->functions);
 	
 	return true;
 }
 
-/** Find device node with a specified path in the device tree.
+/** Find function node with a specified path in the device tree.
  * 
- * @param path		The path of the device node in the device tree.
+ * @param path		The path of the function node in the device tree.
  * @param tree		The device tree.
- * @return		The device node if it is present in the tree, NULL
+ * @return		The function node if it is present in the tree, NULL
  *			otherwise.
  */
-node_t *find_dev_node_by_path(dev_tree_t *tree, char *path)
+fun_node_t *find_fun_node_by_path(dev_tree_t *tree, char *path)
 {
 	fibril_rwlock_read_lock(&tree->rwlock);
 	
-	node_t *dev = tree->root_node;
+	fun_node_t *fun = tree->root_node;
 	/*
-	 * Relative path to the device from its parent (but with '/' at the
+	 * Relative path to the function from its parent (but with '/' at the
 	 * beginning)
 	 */
@@ -990,5 +1142,5 @@
 	bool cont = (rel_path[0] == '/');
 	
-	while (cont && dev != NULL) {
+	while (cont && fun != NULL) {
 		next_path_elem  = get_path_elem_end(rel_path + 1);
 		if (next_path_elem[0] == '/') {
@@ -999,5 +1151,5 @@
 		}
 		
-		dev = find_node_child(dev, rel_path + 1);
+		fun = find_node_child(fun, rel_path + 1);
 		
 		if (cont) {
@@ -1010,27 +1162,27 @@
 	fibril_rwlock_read_unlock(&tree->rwlock);
 	
-	return dev;
-}
-
-/** Find child device node with a specified name.
+	return fun;
+}
+
+/** Find child function node with a specified name.
  *
  * Device tree rwlock should be held at least for reading.
  *
- * @param parent	The parent device node.
- * @param name		The name of the child device node.
- * @return		The child device node.
- */
-node_t *find_node_child(node_t *parent, const char *name)
-{
-	node_t *dev;
+ * @param parent	The parent function node.
+ * @param name		The name of the child function.
+ * @return		The child function node.
+ */
+fun_node_t *find_node_child(fun_node_t *pfun, const char *name)
+{
+	fun_node_t *fun;
 	link_t *link;
 	
-	link = parent->children.next;
-	
-	while (link != &parent->children) {
-		dev = list_get_instance(link, node_t, sibling);
+	link = pfun->child->functions.next;
+	
+	while (link != &pfun->child->functions) {
+		fun = list_get_instance(link, fun_node_t, dev_functions);
 		
-		if (str_cmp(name, dev->name) == 0)
-			return dev;
+		if (str_cmp(name, fun->name) == 0)
+			return fun;
 		
 		link = link->next;
@@ -1115,5 +1267,5 @@
 }
 
-/** Add the device to the class.
+/** Add the device function to the class.
  *
  * The device may be added to multiple classes and a class may contain multiple
@@ -1128,12 +1280,18 @@
  *			with the class.
  */
-dev_class_info_t *add_device_to_class(node_t *dev, dev_class_t *cl,
+dev_class_info_t *add_function_to_class(fun_node_t *fun, dev_class_t *cl,
     const char *base_dev_name)
 {
-	dev_class_info_t *info = create_dev_class_info();
+	dev_class_info_t *info;
+
+	assert(fun != NULL);
+	assert(cl != NULL);
+
+	info = create_dev_class_info();
+
 	
 	if (info != NULL) {
 		info->dev_class = cl;
-		info->dev = dev;
+		info->fun = fun;
 		
 		/* Add the device to the class. */
@@ -1143,5 +1301,5 @@
 		
 		/* Add the class to the device. */
-		list_append(&info->dev_classes, &dev->classes);
+		list_append(&info->dev_classes, &fun->classes);
 		
 		/* Create unique name for the device within the class. */
@@ -1197,5 +1355,5 @@
 	list_initialize(&class_list->classes);
 	fibril_rwlock_initialize(&class_list->rwlock);
-	hash_table_create(&class_list->devmap_devices, DEVICE_BUCKETS, 1,
+	hash_table_create(&class_list->devmap_functions, DEVICE_BUCKETS, 1,
 	    &devmap_devices_class_ops);
 }
@@ -1204,23 +1362,23 @@
 /* Devmap devices */
 
-node_t *find_devmap_tree_device(dev_tree_t *tree, devmap_handle_t devmap_handle)
-{
-	node_t *dev = NULL;
+fun_node_t *find_devmap_tree_function(dev_tree_t *tree, devmap_handle_t devmap_handle)
+{
+	fun_node_t *fun = NULL;
 	link_t *link;
 	unsigned long key = (unsigned long) devmap_handle;
 	
 	fibril_rwlock_read_lock(&tree->rwlock);
-	link = hash_table_find(&tree->devmap_devices, &key);
+	link = hash_table_find(&tree->devmap_functions, &key);
 	if (link != NULL)
-		dev = hash_table_get_instance(link, node_t, devmap_link);
+		fun = hash_table_get_instance(link, fun_node_t, devmap_fun);
 	fibril_rwlock_read_unlock(&tree->rwlock);
 	
-	return dev;
-}
-
-node_t *find_devmap_class_device(class_list_t *classes,
+	return fun;
+}
+
+fun_node_t *find_devmap_class_function(class_list_t *classes,
     devmap_handle_t devmap_handle)
 {
-	node_t *dev = NULL;
+	fun_node_t *fun = NULL;
 	dev_class_info_t *cli;
 	link_t *link;
@@ -1228,31 +1386,31 @@
 	
 	fibril_rwlock_read_lock(&classes->rwlock);
-	link = hash_table_find(&classes->devmap_devices, &key);
+	link = hash_table_find(&classes->devmap_functions, &key);
 	if (link != NULL) {
 		cli = hash_table_get_instance(link, dev_class_info_t,
 		    devmap_link);
-		dev = cli->dev;
+		fun = cli->fun;
 	}
 	fibril_rwlock_read_unlock(&classes->rwlock);
 	
-	return dev;
-}
-
-void class_add_devmap_device(class_list_t *class_list, dev_class_info_t *cli)
+	return fun;
+}
+
+void class_add_devmap_function(class_list_t *class_list, dev_class_info_t *cli)
 {
 	unsigned long key = (unsigned long) cli->devmap_handle;
 	
 	fibril_rwlock_write_lock(&class_list->rwlock);
-	hash_table_insert(&class_list->devmap_devices, &key, &cli->devmap_link);
+	hash_table_insert(&class_list->devmap_functions, &key, &cli->devmap_link);
 	fibril_rwlock_write_unlock(&class_list->rwlock);
 
-	assert(find_devmap_class_device(class_list, cli->devmap_handle) != NULL);
-}
-
-void tree_add_devmap_device(dev_tree_t *tree, node_t *node)
-{
-	unsigned long key = (unsigned long) node->devmap_handle;
+	assert(find_devmap_class_function(class_list, cli->devmap_handle) != NULL);
+}
+
+void tree_add_devmap_function(dev_tree_t *tree, fun_node_t *fun)
+{
+	unsigned long key = (unsigned long) fun->devmap_handle;
 	fibril_rwlock_write_lock(&tree->rwlock);
-	hash_table_insert(&tree->devmap_devices, &key, &node->devmap_link);
+	hash_table_insert(&tree->devmap_functions, &key, &fun->devmap_fun);
 	fibril_rwlock_write_unlock(&tree->rwlock);
 }
Index: uspace/srv/devman/devman.h
===================================================================
--- uspace/srv/devman/devman.h	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/srv/devman/devman.h	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -56,6 +56,9 @@
 #define DEVMAP_SEPARATOR '\\'
 
-struct node;
-typedef struct node node_t;
+struct dev_node;
+typedef struct dev_node dev_node_t;
+
+struct fun_node;
+typedef struct fun_node fun_node_t;
 
 typedef enum {
@@ -117,55 +120,26 @@
 } device_state_t;
 
-/** Representation of a node in the device tree. */
-struct node {
+/** Device node in the device tree. */
+struct dev_node {
 	/** The global unique identifier of the device. */
 	devman_handle_t handle;
-	/** The name of the device specified by its parent. */
-	char *name;
-	
-	/**
-	 * Full path and name of the device in device hierarchi (i. e. in full
-	 * path in device tree).
-	 */
-	char *pathname;
-	
-	/** The node of the parent device. */
-	node_t *parent;
-	
-	/**
-	 * Pointers to previous and next child devices in the linked list of
-	 * parent device's node.
-	 */
-	link_t sibling;
-	
-	/** List of child device nodes. */
-	link_t children;
-	/** List of device ids for device-to-driver matching. */
-	match_id_list_t match_ids;
+	
+	/** (Parent) function the device is attached to. */
+	fun_node_t *pfun;
+	
+	/** List of device functions. */
+	link_t functions;
 	/** Driver of this device. */
 	driver_t *drv;
 	/** The state of the device. */
 	device_state_t state;
-	/**
-	 * Pointer to the previous and next device in the list of devices
-	 * owned by one driver.
-	 */
+	/** Link to list of devices owned by driver (driver_t.devices) */
 	link_t driver_devices;
 	
-	/** The list of device classes to which this device belongs. */
-	link_t classes;
-	/** Devmap handle if the device is registered by devmapper. */
-	devmap_handle_t devmap_handle;
-	
 	/**
 	 * Used by the hash table of devices indexed by devman device handles.
 	 */
-	link_t devman_link;
-	
-	/**
-	 * Used by the hash table of devices indexed by devmap device handles.
-	 */
-	link_t devmap_link;
-
+	link_t devman_dev;
+	
 	/**
 	 * Whether this device was already passed to the driver.
@@ -173,9 +147,47 @@
 	bool passed_to_driver;
 };
+
+/** Function node in the device tree. */
+struct fun_node {
+	/** The global unique identifier of the function */
+	devman_handle_t handle;
+	/** Name of the function, assigned by the device driver */
+	char *name;
+	
+	/** Full path and name of the device in device hierarchy */
+	char *pathname;
+	
+	/** Device which this function belongs to */
+	dev_node_t *dev;
+	
+	/** Link to list of functions in the device (ddf_dev_t.functions) */
+	link_t dev_functions;
+	
+	/** Child device node (if any attached). */
+	dev_node_t *child;
+	/** List of device ids for device-to-driver matching. */
+	match_id_list_t match_ids;
+	
+	/** The list of device classes to which this device function belongs. */
+	link_t classes;
+	/** Devmap handle if the device function is registered by devmap. */
+	devmap_handle_t devmap_handle;
+	
+	/**
+	 * Used by the hash table of functions indexed by devman device handles.
+	 */
+	link_t devman_fun;
+	
+	/**
+	 * Used by the hash table of functions indexed by devmap device handles.
+	 */
+	link_t devmap_fun;
+};
+
 
 /** Represents device tree. */
 typedef struct dev_tree {
 	/** Root device node. */
-	node_t *root_node;
+	fun_node_t *root_node;
 	
 	/**
@@ -191,9 +203,12 @@
 	hash_table_t devman_devices;
 	
+	/** Hash table of all devices indexed by devman handles. */
+	hash_table_t devman_functions;
+	
 	/**
 	 * Hash table of devices registered by devmapper, indexed by devmap
 	 * handles.
 	 */
-	hash_table_t devmap_devices;
+	hash_table_t devmap_functions;
 } dev_tree_t;
 
@@ -227,7 +242,7 @@
 
 /**
- * Provides n-to-m mapping between device nodes and classes - each device may
- * be register to the arbitrary number of classes and each class may contain
- * the arbitrary number of devices.
+ * Provides n-to-m mapping between function nodes and classes - each function
+ * can register in an arbitrary number of classes and each class can contain
+ * an arbitrary number of device functions.
  */
 typedef struct dev_class_info {
@@ -235,5 +250,5 @@
 	dev_class_t *dev_class;
 	/** The device. */
-	node_t *dev;
+	fun_node_t *fun;
 	
 	/**
@@ -249,5 +264,5 @@
 	link_t dev_classes;
 	
-	/** The name of the device within the class. */
+	/** The name of the device function within the class. */
 	char *dev_name;
 	/** The handle of the device by device mapper in the class namespace. */
@@ -270,5 +285,5 @@
 	 * indexed by devmap handles.
 	 */
-	hash_table_t devmap_devices;
+	hash_table_t devmap_functions;
 	
 	/** Fibril mutex for list of classes. */
@@ -278,5 +293,5 @@
 /* Match ids and scores */
 
-extern int get_match_score(driver_t *, node_t *);
+extern int get_match_score(driver_t *, dev_node_t *);
 
 extern bool parse_match_ids(char *, match_id_list_t *);
@@ -292,10 +307,10 @@
 extern int lookup_available_drivers(driver_list_t *, const char *);
 
-extern driver_t *find_best_match_driver(driver_list_t *, node_t *);
-extern bool assign_driver(node_t *, driver_list_t *, dev_tree_t *);
+extern driver_t *find_best_match_driver(driver_list_t *, dev_node_t *);
+extern bool assign_driver(dev_node_t *, driver_list_t *, dev_tree_t *);
 
 extern void add_driver(driver_list_t *, driver_t *);
-extern void attach_driver(node_t *, driver_t *);
-extern void add_device(int, driver_t *, node_t *, dev_tree_t *);
+extern void attach_driver(dev_node_t *, driver_t *);
+extern void add_device(int, driver_t *, dev_node_t *, dev_tree_t *);
 extern bool start_driver(driver_t *);
 
@@ -310,17 +325,24 @@
 /* Device nodes */
 
-extern node_t *create_dev_node(void);
-extern void delete_dev_node(node_t *node);
-extern node_t *find_dev_node_no_lock(dev_tree_t *tree,
+extern dev_node_t *create_dev_node(void);
+extern void delete_dev_node(dev_node_t *node);
+extern dev_node_t *find_dev_node_no_lock(dev_tree_t *tree,
     devman_handle_t handle);
-extern node_t *find_dev_node(dev_tree_t *tree, devman_handle_t handle);
-extern node_t *find_dev_node_by_path(dev_tree_t *, char *);
-extern node_t *find_node_child(node_t *, const char *);
+extern dev_node_t *find_dev_node(dev_tree_t *tree, devman_handle_t handle);
+extern dev_node_t *find_dev_function(dev_node_t *, const char *);
+
+extern fun_node_t *create_fun_node(void);
+extern void delete_fun_node(fun_node_t *);
+extern fun_node_t *find_fun_node_no_lock(dev_tree_t *tree,
+    devman_handle_t handle);
+extern fun_node_t *find_fun_node(dev_tree_t *tree, devman_handle_t handle);
+extern fun_node_t *find_fun_node_by_path(dev_tree_t *, char *);
 
 /* Device tree */
 
 extern bool init_device_tree(dev_tree_t *, driver_list_t *);
-extern bool create_root_node(dev_tree_t *);
-extern bool insert_dev_node(dev_tree_t *, node_t *, char *, node_t *);
+extern bool create_root_nodes(dev_tree_t *);
+extern bool insert_dev_node(dev_tree_t *, dev_node_t *, fun_node_t *);
+extern bool insert_fun_node(dev_tree_t *, fun_node_t *, char *, dev_node_t *);
 
 /* Device classes */
@@ -330,5 +352,5 @@
 extern size_t get_new_class_dev_idx(dev_class_t *);
 extern char *create_dev_name_for_class(dev_class_t *, const char *);
-extern dev_class_info_t *add_device_to_class(node_t *, dev_class_t *,
+extern dev_class_info_t *add_function_to_class(fun_node_t *, dev_class_t *,
     const char *);
 
@@ -341,9 +363,11 @@
 /* Devmap devices */
 
-extern node_t *find_devmap_tree_device(dev_tree_t *, devmap_handle_t);
-extern node_t *find_devmap_class_device(class_list_t *, devmap_handle_t);
-
-extern void class_add_devmap_device(class_list_t *, dev_class_info_t *);
-extern void tree_add_devmap_device(dev_tree_t *, node_t *);
+extern void devmap_register_tree_function(fun_node_t *, dev_tree_t *);
+
+extern fun_node_t *find_devmap_tree_function(dev_tree_t *, devmap_handle_t);
+extern fun_node_t *find_devmap_class_function(class_list_t *, devmap_handle_t);
+
+extern void class_add_devmap_function(class_list_t *, dev_class_info_t *);
+extern void tree_add_devmap_function(dev_tree_t *, fun_node_t *);
 
 #endif
Index: uspace/srv/devman/main.c
===================================================================
--- uspace/srv/devman/main.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/srv/devman/main.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -199,23 +199,26 @@
 static int assign_driver_fibril(void *arg)
 {
-	node_t *node = (node_t *) arg;
-	assign_driver(node, &drivers_list, &device_tree);
+	dev_node_t *dev_node = (dev_node_t *) arg;
+	assign_driver(dev_node, &drivers_list, &device_tree);
 	return EOK;
 }
 
-/** Handle child device registration.
+/** Handle function registration.
  *
  * Child devices are registered by their parent's device driver.
  */
-static void devman_add_child(ipc_callid_t callid, ipc_call_t *call)
-{
-	devman_handle_t parent_handle = IPC_GET_ARG1(*call);
-	sysarg_t match_count = IPC_GET_ARG2(*call);
+static void devman_add_function(ipc_callid_t callid, ipc_call_t *call)
+{
+	fun_type_t ftype = (fun_type_t) IPC_GET_ARG1(*call);
+	devman_handle_t dev_handle = IPC_GET_ARG2(*call);
+	sysarg_t match_count = IPC_GET_ARG3(*call);
 	dev_tree_t *tree = &device_tree;
 	
 	fibril_rwlock_write_lock(&tree->rwlock);
-	node_t *parent = find_dev_node_no_lock(&device_tree, parent_handle);
-	
-	if (parent == NULL) {
+
+	dev_node_t *dev = NULL;
+	dev_node_t *pdev = find_dev_node_no_lock(&device_tree, dev_handle);
+	
+	if (pdev == NULL) {
 		fibril_rwlock_write_unlock(&tree->rwlock);
 		async_answer_0(callid, ENOENT);
@@ -223,6 +226,15 @@
 	}
 	
-	char *dev_name = NULL;
-	int rc = async_data_write_accept((void **)&dev_name, true, 0, 0, 0, 0);
+	if (ftype != fun_inner && ftype != fun_exposed) {
+		/* Unknown function type */
+		printf(NAME ": Error, unknown function type provided by driver!\n");
+
+		fibril_rwlock_write_unlock(&tree->rwlock);
+		async_answer_0(callid, EINVAL);
+		return;
+	}
+	
+	char *fun_name = NULL;
+	int rc = async_data_write_accept((void **)&fun_name, true, 0, 0, 0, 0);
 	if (rc != EOK) {
 		fibril_rwlock_write_unlock(&tree->rwlock);
@@ -231,38 +243,55 @@
 	}
 	
-	node_t *node = create_dev_node();
-	if (!insert_dev_node(&device_tree, node, dev_name, parent)) {
+	fun_node_t *fun = create_fun_node();
+	if (!insert_fun_node(&device_tree, fun, fun_name, pdev)) {
 		fibril_rwlock_write_unlock(&tree->rwlock);
-		delete_dev_node(node);
+		delete_fun_node(fun);
 		async_answer_0(callid, ENOMEM);
 		return;
 	}
 
+	if (ftype == fun_inner) {
+		dev = create_dev_node();
+		if (dev == NULL) {
+			fibril_rwlock_write_unlock(&tree->rwlock);
+			delete_fun_node(fun);
+			async_answer_0(callid, ENOMEM);
+			return;
+		}
+
+		insert_dev_node(tree, dev, fun);
+	}
+
 	fibril_rwlock_write_unlock(&tree->rwlock);
 	
-	printf(NAME ": devman_add_child %s\n", node->pathname);
-	
-	devman_receive_match_ids(match_count, &node->match_ids);
-
-	/*
-	 * Try to find a suitable driver and assign it to the device.  We do
-	 * not want to block the current fibril that is used for processing
-	 * incoming calls: we will launch a separate fibril to handle the
-	 * driver assigning. That is because assign_driver can actually include
-	 * task spawning which could take some time.
-	 */
-	fid_t assign_fibril = fibril_create(assign_driver_fibril, node);
-	if (assign_fibril == 0) {
+	printf(NAME ": devman_add_function %s\n", fun->pathname);
+	
+	devman_receive_match_ids(match_count, &fun->match_ids);
+
+	if (ftype == fun_inner) {
+		assert(dev != NULL);
 		/*
-		 * Fallback in case we are out of memory.
-		 * Probably not needed as we will die soon anyway ;-).
+		 * Try to find a suitable driver and assign it to the device.  We do
+		 * not want to block the current fibril that is used for processing
+		 * incoming calls: we will launch a separate fibril to handle the
+		 * driver assigning. That is because assign_driver can actually include
+		 * task spawning which could take some time.
 		 */
-		(void) assign_driver_fibril(node);
+		fid_t assign_fibril = fibril_create(assign_driver_fibril, dev);
+		if (assign_fibril == 0) {
+			/*
+			 * Fallback in case we are out of memory.
+			 * Probably not needed as we will die soon anyway ;-).
+			 */
+			(void) assign_driver_fibril(fun);
+		} else {
+			fibril_add_ready(assign_fibril);
+		}
 	} else {
-		fibril_add_ready(assign_fibril);
-	}
-
+		devmap_register_tree_function(fun, tree);
+	}
+	
 	/* Return device handle to parent's driver. */
-	async_answer_1(callid, EOK, node->handle);
+	async_answer_1(callid, EOK, fun->handle);
 }
 
@@ -288,10 +317,10 @@
 	 * mapper.
 	 */
-	class_add_devmap_device(&class_list, cli);
+	class_add_devmap_function(&class_list, cli);
 	
 	free(devmap_pathname);
 }
 
-static void devman_add_device_to_class(ipc_callid_t callid, ipc_call_t *call)
+static void devman_add_function_to_class(ipc_callid_t callid, ipc_call_t *call)
 {
 	devman_handle_t handle = IPC_GET_ARG1(*call);
@@ -306,6 +335,6 @@
 	}	
 	
-	node_t *dev = find_dev_node(&device_tree, handle);
-	if (dev == NULL) {
+	fun_node_t *fun = find_fun_node(&device_tree, handle);
+	if (fun == NULL) {
 		async_answer_0(callid, ENOENT);
 		return;
@@ -313,11 +342,11 @@
 	
 	dev_class_t *cl = get_dev_class(&class_list, class_name);
-	dev_class_info_t *class_info = add_device_to_class(dev, cl, NULL);
+	dev_class_info_t *class_info = add_function_to_class(fun, cl, NULL);
 	
 	/* Register the device's class alias by devmapper. */
 	devmap_register_class_dev(class_info);
 	
-	printf(NAME ": device '%s' added to class '%s', class name '%s' was "
-	    "asigned to it\n", dev->pathname, class_name, class_info->dev_name);
+	printf(NAME ": function'%s' added to class '%s', class name '%s' was "
+	    "asigned to it\n", fun->pathname, class_name, class_info->dev_name);
 
 	async_answer_0(callid, EOK);
@@ -372,9 +401,9 @@
 			cont = false;
 			continue;
-		case DEVMAN_ADD_CHILD_DEVICE:
-			devman_add_child(callid, &call);
+		case DEVMAN_ADD_FUNCTION:
+			devman_add_function(callid, &call);
 			break;
 		case DEVMAN_ADD_DEVICE_TO_CLASS:
-			devman_add_device_to_class(callid, &call);
+			devman_add_function_to_class(callid, &call);
 			break;
 		default:
@@ -387,5 +416,5 @@
 /** Find handle for the device instance identified by the device's path in the
  * device tree. */
-static void devman_device_get_handle(ipc_callid_t iid, ipc_call_t *icall)
+static void devman_function_get_handle(ipc_callid_t iid, ipc_call_t *icall)
 {
 	char *pathname;
@@ -397,14 +426,14 @@
 	}
 	
-	node_t * dev = find_dev_node_by_path(&device_tree, pathname);
+	fun_node_t *fun = find_fun_node_by_path(&device_tree, pathname);
 	
 	free(pathname);
 
-	if (dev == NULL) {
+	if (fun == NULL) {
 		async_answer_0(iid, ENOENT);
 		return;
 	}
-	
-	async_answer_1(iid, EOK, dev->handle);
+
+	async_answer_1(iid, EOK, fun->handle);
 }
 
@@ -426,5 +455,5 @@
 			continue;
 		case DEVMAN_DEVICE_GET_HANDLE:
-			devman_device_get_handle(callid, &call);
+			devman_function_get_handle(callid, &call);
 			break;
 		default:
@@ -438,21 +467,41 @@
 {
 	devman_handle_t handle = IPC_GET_ARG2(*icall);
-	
-	node_t *dev = find_dev_node(&device_tree, handle);
-	if (dev == NULL) {
-		printf(NAME ": devman_forward error - no device with handle %" PRIun
-		    " was found.\n", handle);
+	devman_handle_t fwd_h;
+	fun_node_t *fun = NULL;
+	dev_node_t *dev = NULL;
+	
+	fun = find_fun_node(&device_tree, handle);
+	if (fun == NULL)
+		dev = find_dev_node(&device_tree, handle);
+	else
+		dev = fun->dev;
+
+	if (fun == NULL && dev == NULL) {
+		printf(NAME ": devman_forward error - no device or function with "
+		    "handle %" PRIun " was found.\n", handle);
 		async_answer_0(iid, ENOENT);
 		return;
 	}
+
+	if (fun == NULL && !drv_to_parent) {
+		printf(NAME ": devman_forward error - cannot connect to "
+		    "handle %" PRIun ", refers to a device.\n", handle);
+		async_answer_0(iid, ENOENT);
+		return;
+	}
 	
 	driver_t *driver = NULL;
 	
 	if (drv_to_parent) {
-		if (dev->parent != NULL)
-			driver = dev->parent->drv;
+		/* Connect to parent function of a device (or device function). */
+		if (dev->pfun->dev != NULL)
+			driver = dev->pfun->dev->drv;
+		fwd_h = dev->pfun->handle;
 	} else if (dev->state == DEVICE_USABLE) {
+		/* Connect to the specified function */
 		driver = dev->drv;
 		assert(driver != NULL);
+
+		fwd_h = handle;
 	}
 	
@@ -460,5 +509,5 @@
 		printf(NAME ": devman_forward error - the device %" PRIun \
 		    " (%s) is not in usable state.\n",
-		    handle, dev->pathname);
+		    handle, dev->pfun->pathname);
 		async_answer_0(iid, ENOENT);
 		return;
@@ -479,7 +528,13 @@
 	}
 
-	printf(NAME ": devman_forward: forward connection to device %s to "
-	    "driver %s.\n", dev->pathname, driver->name);
-	async_forward_fast(iid, driver->phone, method, dev->handle, 0, IPC_FF_NONE);
+	if (fun != NULL) {
+		printf(NAME ": devman_forward: forward connection to function %s to "
+		    "driver %s.\n", fun->pathname, driver->name);
+	} else {
+		printf(NAME ": devman_forward: forward connection to device %s to "
+		    "driver %s.\n", dev->pfun->pathname, driver->name);
+	}
+
+	async_forward_fast(iid, driver->phone, method, fwd_h, 0, IPC_FF_NONE);
 }
 
@@ -489,14 +544,17 @@
 {
 	devmap_handle_t devmap_handle = IPC_GET_ARG2(*icall);
-	node_t *dev;
-
-	dev = find_devmap_tree_device(&device_tree, devmap_handle);
-	if (dev == NULL)
-		dev = find_devmap_class_device(&class_list, devmap_handle);
-	
-	if (dev == NULL || dev->drv == NULL) {
+	fun_node_t *fun;
+	dev_node_t *dev;
+
+	fun = find_devmap_tree_function(&device_tree, devmap_handle);
+	if (fun == NULL)
+		fun = find_devmap_class_function(&class_list, devmap_handle);
+	
+	if (fun == NULL || fun->dev->drv == NULL) {
 		async_answer_0(iid, ENOENT);
 		return;
 	}
+	
+	dev = fun->dev;
 	
 	if (dev->state != DEVICE_USABLE || dev->drv->phone <= 0) {
@@ -505,8 +563,8 @@
 	}
 	
-	async_forward_fast(iid, dev->drv->phone, DRIVER_CLIENT, dev->handle, 0,
+	async_forward_fast(iid, dev->drv->phone, DRIVER_CLIENT, fun->handle, 0,
 	    IPC_FF_NONE);
 	printf(NAME ": devman_connection_devmapper: forwarded connection to "
-	    "device %s to driver %s.\n", dev->pathname, dev->drv->name);
+	    "device %s to driver %s.\n", fun->pathname, dev->drv->name);
 }
 
Index: uspace/srv/devman/match.c
===================================================================
--- uspace/srv/devman/match.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/srv/devman/match.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -57,8 +57,8 @@
 }
 
-int get_match_score(driver_t *drv, node_t *dev)
+int get_match_score(driver_t *drv, dev_node_t *dev)
 {
 	link_t *drv_head = &drv->match_ids.ids;
-	link_t *dev_head = &dev->match_ids.ids;
+	link_t *dev_head = &dev->pfun->match_ids.ids;
 	
 	if (list_empty(drv_head) || list_empty(dev_head))
Index: uspace/srv/fs/devfs/devfs_ops.c
===================================================================
--- uspace/srv/fs/devfs/devfs_ops.c	(revision 15b0432cf41987c321bca72fea786ffababd3b61)
+++ uspace/srv/fs/devfs/devfs_ops.c	(revision eb1a2f485e907e821965b3aafca2d8a5355f3518)
@@ -278,5 +278,4 @@
 				fibril_mutex_unlock(&devices_mutex);
 
-				free(dev);
 				return ENOENT;
 			}
