Index: HelenOS.config
===================================================================
--- HelenOS.config	(revision b8d453ec72e401e6dcf16ce9063cf7b3cbbc97ab)
+++ HelenOS.config	(revision 9a2923dbca07f53224949aee0bc02acfe467f501)
@@ -554,2 +554,6 @@
 % Polling UHCI & OHCI (no interrupts)
 ! [PLATFORM=ia32|PLATFORM=amd64] CONFIG_USBHC_NO_INTERRUPTS (y/n)
+
+% Run devman in kconsole (not recommended)
+! CONFIG_DEVMAN_EARLY_LAUNCH (n/y)
+
Index: uspace/app/init/init.c
===================================================================
--- uspace/app/init/init.c	(revision b8d453ec72e401e6dcf16ce9063cf7b3cbbc97ab)
+++ uspace/app/init/init.c	(revision 9a2923dbca07f53224949aee0bc02acfe467f501)
@@ -288,4 +288,8 @@
 	
 	spawn("/srv/clip");
+
+#ifdef CONFIG_DEVMAN_EARLY_LAUNCH
+	spawn("/srv/devman");
+#endif
 	
 	/*
@@ -313,6 +317,9 @@
 	getterm("term/vc5", "/app/bdsh", false);
 	getterm("term/vc6", "/app/klog", false);
+
+#ifndef CONFIG_DEVMAN_EARLY_LAUNCH
 	getterm("term/vc7", "/srv/devman", false);
-	
+#endif
+
 	return 0;
 }
Index: uspace/app/klog/klog.c
===================================================================
--- uspace/app/klog/klog.c	(revision b8d453ec72e401e6dcf16ce9063cf7b3cbbc97ab)
+++ uspace/app/klog/klog.c	(revision 9a2923dbca07f53224949aee0bc02acfe467f501)
@@ -44,4 +44,5 @@
 #include <io/klog.h>
 #include <sysinfo.h>
+#include <fibril_synch.h>
 
 #define NAME       "klog"
@@ -54,6 +55,12 @@
 static FILE *log;
 
+/* Serialize the output a bit. This will not avoid messed-up log completely
+   but chances for are pretty high (experimentally confirmed). */
+static FIBRIL_MUTEX_INITIALIZE(log_mutex);
+
 static void interrupt_received(ipc_callid_t callid, ipc_call_t *call)
 {
+	fibril_mutex_lock(&log_mutex);
+	
 	size_t klog_start = (size_t) IPC_GET_ARG1(*call);
 	size_t klog_len = (size_t) IPC_GET_ARG2(*call);
@@ -74,4 +81,6 @@
 		fsync(fileno(log));
 	}
+	
+	fibril_mutex_unlock(&log_mutex);
 }
 
Index: uspace/drv/usbmid/explore.c
===================================================================
--- uspace/drv/usbmid/explore.c	(revision b8d453ec72e401e6dcf16ce9063cf7b3cbbc97ab)
+++ uspace/drv/usbmid/explore.c	(revision 9a2923dbca07f53224949aee0bc02acfe467f501)
@@ -40,5 +40,11 @@
 #include <usb/request.h>
 #include <usb/dp.h>
+#include <usb/ddfiface.h>
 #include "usbmid.h"
+
+/** Operations of the device itself. */
+static ddf_dev_ops_t mid_device_ops = {
+	.interfaces[USB_DEV_IFACE] = &usb_iface_hub_impl
+};
 
 /** Find starting indexes of all interface descriptors in a configuration.
@@ -105,37 +111,22 @@
  * @return Whether to accept this device from devman.
  */
-bool usbmid_explore_device(usbmid_device_t *dev)
+bool usbmid_explore_device(usb_device_t *dev)
 {
-	usb_standard_device_descriptor_t device_descriptor;
-	int rc = usb_request_get_device_descriptor(&dev->ctrl_pipe,
-	    &device_descriptor);
-	if (rc != EOK) {
-		usb_log_error("Getting device descriptor failed: %s.\n",
-		    str_error(rc));
-		return false;
-	}
-
-	if (device_descriptor.device_class != USB_CLASS_USE_INTERFACE) {
+	int rc;
+
+	int dev_class = dev->descriptors.device.device_class;
+	if (dev_class != USB_CLASS_USE_INTERFACE) {
 		usb_log_warning(
 		    "Device class: %d (%s), but expected class 0.\n",
-		    device_descriptor.device_class,
-		    usb_str_class(device_descriptor.device_class));
+		    dev_class, usb_str_class(dev_class));
 		usb_log_error("Not multi interface device, refusing.\n");
 		return false;
 	}
 
-	size_t config_descriptor_size;
-	uint8_t *config_descriptor_raw = NULL;
-	rc = usb_request_get_full_configuration_descriptor_alloc(
-	    &dev->ctrl_pipe, 0,
-	    (void **) &config_descriptor_raw, &config_descriptor_size);
-	if (rc != EOK) {
-		usb_log_error("Failed getting full config descriptor: %s.\n",
-		    str_error(rc));
-		return false;
-	}
-
-	usb_standard_configuration_descriptor_t *config_descriptor
-	    = (usb_standard_configuration_descriptor_t *) config_descriptor_raw;
+	/* Short cuts to save on typing ;-). */
+	uint8_t *config_descriptor_raw = dev->descriptors.configuration;
+	size_t config_descriptor_size = dev->descriptors.configuration_size;
+	usb_standard_configuration_descriptor_t *config_descriptor =
+	    (usb_standard_configuration_descriptor_t *) config_descriptor_raw;
 
 	size_t *interface_descriptors
@@ -154,5 +145,4 @@
 	if (interface_descriptors_count == (size_t) -1) {
 		usb_log_error("Problem parsing configuration descriptor.\n");
-		free(config_descriptor_raw);
 		free(interface_descriptors);
 		return false;
@@ -165,5 +155,4 @@
 		usb_log_error("Failed to set device configuration: %s.\n",
 		    str_error(rc));
-		free(config_descriptor_raw);
 		free(interface_descriptors);
 		return false;
@@ -172,16 +161,17 @@
 
 	/* Create control function */
-	ddf_fun_t *ctl_fun = ddf_fun_create(dev->dev, fun_exposed, "ctl");
+	ddf_fun_t *ctl_fun = ddf_fun_create(dev->ddf_dev, fun_exposed, "ctl");
 	if (ctl_fun == NULL) {
 		usb_log_error("Failed to create control function.\n");
-		free(config_descriptor_raw);
-		free(interface_descriptors);
-		return false;
-	}
+		free(interface_descriptors);
+		return false;
+	}
+
+	ctl_fun->ops = &mid_device_ops;
+
 	rc = ddf_fun_bind(ctl_fun);
 	if (rc != EOK) {
 		usb_log_error("Failed to bind control function: %s.\n",
 		    str_error(rc));
-		free(config_descriptor_raw);
 		free(interface_descriptors);
 		return false;
@@ -199,5 +189,5 @@
 		    (int) interface->interface_number,
 		    usb_str_class(interface->interface_class));
-		rc = usbmid_spawn_interface_child(dev, &device_descriptor,
+		rc = usbmid_spawn_interface_child(dev, &dev->descriptors.device,
 		    interface);
 		if (rc != EOK) {
@@ -207,6 +197,4 @@
 	}
 
-	free(config_descriptor_raw);
-
 	return true;
 }
Index: uspace/drv/usbmid/main.c
===================================================================
--- uspace/drv/usbmid/main.c	(revision b8d453ec72e401e6dcf16ce9063cf7b3cbbc97ab)
+++ uspace/drv/usbmid/main.c	(revision 9a2923dbca07f53224949aee0bc02acfe467f501)
@@ -49,13 +49,7 @@
  * @return Error code.
  */
-static int usbmid_add_device(ddf_dev_t *gen_dev)
+static int usbmid_add_device(usb_device_t *dev)
 {
-	usbmid_device_t *dev = usbmid_device_create(gen_dev);
-	if (dev == NULL) {
-		return ENOMEM;
-	}
-
-	usb_log_info("Taking care of new MID: addr %d (HC %zu)\n",
-	    dev->wire.address, dev->wire.hc_handle);
+	usb_log_info("Taking care of new MID `%s'.\n", dev->ddf_dev->name);
 
 	int rc;
@@ -65,5 +59,5 @@
 		usb_log_error("Failed to start session on control pipe: %s.\n",
 		    str_error(rc));
-		goto error_leave;
+		return rc;
 	}
 
@@ -77,27 +71,20 @@
 
 	if (!accept) {
-		rc = ENOTSUP;
-		goto error_leave;
+		return ENOTSUP;
 	}
 
-	gen_dev->driver_data = dev;
-
 	return EOK;
-
-
-error_leave:
-	free(dev);
-	return rc;
 }
 
 /** USB MID driver ops. */
-static driver_ops_t mid_driver_ops = {
+static usb_driver_ops_t mid_driver_ops = {
 	.add_device = usbmid_add_device,
 };
 
 /** USB MID driver. */
-static driver_t mid_driver = {
+static usb_driver_t mid_driver = {
 	.name = NAME,
-	.driver_ops = &mid_driver_ops
+	.ops = &mid_driver_ops,
+	.endpoints = NULL
 };
 
@@ -107,5 +94,6 @@
 
 	usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME);
-	return ddf_driver_main(&mid_driver);
+
+	return usb_driver_main(&mid_driver);
 }
 
Index: uspace/drv/usbmid/usbmid.c
===================================================================
--- uspace/drv/usbmid/usbmid.c	(revision b8d453ec72e401e6dcf16ce9063cf7b3cbbc97ab)
+++ uspace/drv/usbmid/usbmid.c	(revision 9a2923dbca07f53224949aee0bc02acfe467f501)
@@ -79,55 +79,4 @@
 };
 
-/** Operations of the device itself. */
-static ddf_dev_ops_t mid_device_ops = {
-	.interfaces[USB_DEV_IFACE] = &usb_iface_hub_impl
-};
-
-/** Create new USB multi interface device.
- *
- * @param dev Backing generic DDF device.
- * @return New USB MID device.
- * @retval NULL Error occured.
- */
-usbmid_device_t *usbmid_device_create(ddf_dev_t *dev)
-{
-	usbmid_device_t *mid = malloc(sizeof(usbmid_device_t));
-	if (mid == NULL) {
-		usb_log_error("Out of memory (wanted %zu bytes).\n",
-		    sizeof(usbmid_device_t));
-		return NULL;
-	}
-
-	int rc;
-	rc = usb_device_connection_initialize_from_device(&mid->wire, dev);
-	if (rc != EOK) {
-		usb_log_error("Failed to initialize `USB wire': %s.\n",
-		    str_error(rc));
-		free(mid);
-		return NULL;
-	}
-
-	rc = usb_pipe_initialize_default_control(&mid->ctrl_pipe,
-	    &mid->wire);
-	if (rc != EOK) {
-		usb_log_error("Failed to initialize control pipe: %s.\n",
-		    str_error(rc));
-		free(mid);
-		return NULL;
-	}
-	rc = usb_pipe_probe_default_control(&mid->ctrl_pipe);
-	if (rc != EOK) {
-		usb_log_error("Probing default control pipe failed: %s.\n",
-		    str_error(rc));
-		free(mid);
-		return NULL;
-	}
-
-	mid->dev = dev;
-	(void) &mid_device_ops;
-
-	return mid;
-}
-
 /** Create new interface for USB MID device.
  *
@@ -160,5 +109,5 @@
  * @return Error code.
  */
-int usbmid_spawn_interface_child(usbmid_device_t *parent,
+int usbmid_spawn_interface_child(usb_device_t *parent,
     const usb_standard_device_descriptor_t *device_descriptor,
     const usb_standard_interface_descriptor_t *interface_descriptor)
@@ -182,5 +131,5 @@
 
 	/* Create the device. */
-	child = ddf_fun_create(parent->dev, fun_inner, child_name);
+	child = ddf_fun_create(parent->ddf_dev, fun_inner, child_name);
 	if (child == NULL) {
 		rc = ENOMEM;
Index: uspace/drv/usbmid/usbmid.h
===================================================================
--- uspace/drv/usbmid/usbmid.h	(revision b8d453ec72e401e6dcf16ce9063cf7b3cbbc97ab)
+++ uspace/drv/usbmid/usbmid.h	(revision 9a2923dbca07f53224949aee0bc02acfe467f501)
@@ -41,18 +41,7 @@
 #include <usb/pipes.h>
 #include <usb/debug.h>
+#include <usb/devdrv.h>
 
 #define NAME "usbmid"
-
-/** USB MID device container. */
-typedef struct {
-	/** Device container. */
-	ddf_dev_t *dev;
-
-	/** Representation of USB wire. */
-	usb_device_connection_t wire;
-	/** Default control pipe. */
-	usb_pipe_t ctrl_pipe;
-} usbmid_device_t;
-
 
 /** Container for single interface in a MID device. */
@@ -65,8 +54,7 @@
 } usbmid_interface_t;
 
-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 *,
+bool usbmid_explore_device(usb_device_t *);
+int usbmid_spawn_interface_child(usb_device_t *,
     const usb_standard_device_descriptor_t *,
     const usb_standard_interface_descriptor_t *);
