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"
