Index: .bzrignore
===================================================================
--- .bzrignore	(revision 3f0a7971b0a7536c06012fdd2835873631dfa824)
+++ .bzrignore	(revision 63b4f90725d28de0589f88b5750edf8a9c29b84e)
@@ -95,4 +95,5 @@
 ./uspace/dist/drv/uhci/
 ./uspace/dist/drv/usbkbd/
+./uspace/dist/drv/vhc/
 ./uspace/dist/srv/arp
 ./uspace/dist/srv/ata_bd
@@ -130,4 +131,5 @@
 ./uspace/drv/uhci/uhci
 ./uspace/drv/usbkbd/usbkbd
+./uspace/drv/vhc/vhc
 ./uspace/srv/bd/ata_bd/ata_bd
 ./uspace/srv/bd/file_bd/file_bd
@@ -149,5 +151,4 @@
 ./uspace/srv/hid/s3c24xx_ts/s3c24ts
 ./uspace/srv/hw/bus/pci/pci
-./uspace/srv/hw/bus/usb/hcd/virtual/vhcd
 ./uspace/srv/hw/char/i8042/i8042
 ./uspace/srv/hw/char/s3c24xx_uart/s3c24ser
Index: boot/Makefile.common
===================================================================
--- boot/Makefile.common	(revision 3f0a7971b0a7536c06012fdd2835873631dfa824)
+++ boot/Makefile.common	(revision 63b4f90725d28de0589f88b5750edf8a9c29b84e)
@@ -110,5 +110,6 @@
 	
 RD_DRVS = \
-	root
+	root \
+	vhc
 
 RD_DRV_CFG = 
Index: uspace/Makefile
===================================================================
--- uspace/Makefile	(revision 3f0a7971b0a7536c06012fdd2835873631dfa824)
+++ uspace/Makefile	(revision 63b4f90725d28de0589f88b5750edf8a9c29b84e)
@@ -81,5 +81,4 @@
 	srv/hw/char/s3c24xx_uart \
 	srv/hw/netif/dp8390 \
-	srv/hw/bus/usb/hcd/virtual \
 	srv/net/cfg \
 	srv/net/netif/lo \
@@ -90,5 +89,6 @@
 	srv/net/tl/tcp \
 	srv/net/net \
-	drv/root
+	drv/root \
+	drv/vhc
 
 ## Networking
Index: uspace/app/init/init.c
===================================================================
--- uspace/app/init/init.c	(revision 3f0a7971b0a7536c06012fdd2835873631dfa824)
+++ uspace/app/init/init.c	(revision 63b4f90725d28de0589f88b5750edf8a9c29b84e)
@@ -312,4 +312,5 @@
 	getterm("term/vc5", "/app/bdsh", false);
 	getterm("term/vc6", "/app/klog", false);
+	getterm("term/vc7", "/srv/devman", false);
 	
 	return 0;
Index: uspace/drv/root/root.c
===================================================================
--- uspace/drv/root/root.c	(revision 3f0a7971b0a7536c06012fdd2835873631dfa824)
+++ uspace/drv/root/root.c	(revision 63b4f90725d28de0589f88b5750edf8a9c29b84e)
@@ -119,4 +119,58 @@
 }
 
+/** Create virtual USB host controller device.
+ * Note that the virtual HC is actually device and driver in one
+ * task.
+ *
+ * @param parent Parent device.
+ * @return Error code.
+ */
+static int add_virtual_usb_host_controller(device_t *parent)
+{
+	printf(NAME ": adding virtual host contoller.\n");
+
+	int rc;
+	device_t *vhc = NULL;
+	match_id_t *match_id = NULL;
+
+	vhc = create_device();
+	if (vhc == NULL) {
+		rc = ENOMEM;
+		goto failure;
+	}
+
+	vhc->name = "vhc";
+	printf(NAME ": the new device's name is %s.\n", vhc->name);
+
+	/* Initialize match id list. */
+	match_id = create_match_id();
+	if (match_id == NULL) {
+		rc = ENOMEM;
+		goto failure;
+	}
+
+	match_id->id = "usb&hc=vhc";
+	match_id->score = 100;
+	add_match_id(&vhc->match_ids, match_id);
+
+	/* Register child device. */
+	rc = child_device_register(vhc, parent);
+	if (rc != EOK)
+		goto failure;
+
+	return EOK;
+
+failure:
+	if (match_id != NULL)
+		match_id->id = NULL;
+
+	if (vhc != NULL) {
+		vhc->name = NULL;
+		delete_device(vhc);
+	}
+
+	return rc;
+}
+
 /** Get the root device.
  *
@@ -133,4 +187,10 @@
 		printf(NAME ": failed to add child device for platform.\n");
 	
+	/* Register virtual USB host controller. */
+	int rc = add_virtual_usb_host_controller(dev);
+	if (EOK != rc) {
+		printf(NAME ": failed to add child device - virtual USB HC.\n");
+	}
+
 	return res;
 }
Index: uspace/drv/uhci/uhci.ma
===================================================================
--- uspace/drv/uhci/uhci.ma	(revision 3f0a7971b0a7536c06012fdd2835873631dfa824)
+++ uspace/drv/uhci/uhci.ma	(revision 63b4f90725d28de0589f88b5750edf8a9c29b84e)
@@ -1,3 +1,3 @@
-10 pci/ven=8086&dev=7020
+0 pci/ven=8086&dev=7020
 10 usb&hc=uhci
 10 usb&hc=uhci&hub
Index: uspace/drv/vhc/Makefile
===================================================================
--- uspace/drv/vhc/Makefile	(revision 63b4f90725d28de0589f88b5750edf8a9c29b84e)
+++ uspace/drv/vhc/Makefile	(revision 63b4f90725d28de0589f88b5750edf8a9c29b84e)
@@ -0,0 +1,49 @@
+#
+# Copyright (c) 2010 Vojtech Horky
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+USPACE_PREFIX = ../..
+LIBS = \
+	$(LIBUSB_PREFIX)/libusb.a \
+	$(LIBUSBVIRT_PREFIX)/libusbvirt.a \
+	$(LIBDRV_PREFIX)/libdrv.a
+EXTRA_CFLAGS += \
+	-I$(LIB_PREFIX) \
+	-I$(LIBDRV_PREFIX)/include
+BINARY = vhc
+
+SOURCES = \
+	conndev.c \
+	connhost.c \
+	debug.c \
+	devices.c \
+	hc.c \
+	hcd.c \
+	hub.c \
+	hubops.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/drv/vhc/conn.h
===================================================================
--- uspace/drv/vhc/conn.h	(revision 63b4f90725d28de0589f88b5750edf8a9c29b84e)
+++ uspace/drv/vhc/conn.h	(revision 63b4f90725d28de0589f88b5750edf8a9c29b84e)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup usb
+ * @{
+ */
+/** @file
+ * @brief Connection handling of incoming calls.
+ */
+#ifndef VHCD_CONN_H_
+#define VHCD_CONN_H_
+
+#include <usb/hcd.h>
+#include <usb/hcdhubd.h>
+#include "vhcd.h"
+#include "devices.h"
+
+void connection_handler_host(ipcarg_t);
+void connection_handler_device(ipcarg_t, virtdev_connection_t *);
+usb_hcd_transfer_ops_t vhc_transfer_ops;
+
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/vhc/conndev.c
===================================================================
--- uspace/drv/vhc/conndev.c	(revision 63b4f90725d28de0589f88b5750edf8a9c29b84e)
+++ uspace/drv/vhc/conndev.c	(revision 63b4f90725d28de0589f88b5750edf8a9c29b84e)
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup usb
+ * @{
+ */
+/** @file
+ * @brief Connection handling of calls from virtual device (implementation).
+ */
+
+#include <assert.h>
+#include <errno.h>
+#include <usbvirt/hub.h>
+
+#include "conn.h"
+#include "hc.h"
+#include "hub.h"
+
+#define DEVICE_NAME_MAXLENGTH 32
+
+static int get_device_name(int phone, char *buffer, size_t len)
+{
+	ipc_call_t answer_data;
+	ipcarg_t answer_rc;
+	aid_t req;
+	int rc;
+	
+	req = async_send_0(phone,
+	    IPC_M_USBVIRT_GET_NAME,
+	    &answer_data);
+	
+	rc = async_data_read_start(phone, buffer, len);
+	if (rc != EOK) {
+		async_wait_for(req, NULL);
+		return EINVAL;
+	}
+	
+	async_wait_for(req, &answer_rc);
+	rc = (int)answer_rc;
+	
+	if (IPC_GET_ARG1(answer_data) < len) {
+		len = IPC_GET_ARG1(answer_data);
+	} else {
+		len--;
+	}
+	buffer[len] = 0;
+	
+	return rc;
+}
+
+/** Connection handler for communcation with virtual device.
+ *
+ * This function also takes care of proper phone hung-up.
+ *
+ * @param phone_hash Incoming phone hash.
+ * @param dev Virtual device handle.
+ */
+void connection_handler_device(ipcarg_t phone_hash, virtdev_connection_t *dev)
+{
+	assert(dev != NULL);
+	
+	char devname[DEVICE_NAME_MAXLENGTH + 1];
+	int rc = get_device_name(dev->phone, devname, DEVICE_NAME_MAXLENGTH);
+	
+	dprintf(0, "virtual device connected (phone: %#x, name: %s)",
+	    phone_hash, rc == EOK ? devname : "<unknown>");
+	
+	
+	while (true) {
+		ipc_callid_t callid; 
+		ipc_call_t call; 
+		
+		callid = async_get_call(&call);
+		
+		switch (IPC_GET_METHOD(call)) {
+			case IPC_M_PHONE_HUNGUP:
+				ipc_hangup(dev->phone);
+				ipc_answer_0(callid, EOK);
+				dprintf(0, "phone%#x: device hung-up",
+				    phone_hash);
+				return;
+			
+			case IPC_M_CONNECT_TO_ME:
+				ipc_answer_0(callid, ELIMIT);
+				break;
+			
+			default:
+				dprintf_inval_call(2, call, phone_hash);
+				ipc_answer_0(callid, EINVAL);
+				break;
+		}
+	}
+}
+
+/**
+ * @}
+ */
Index: uspace/drv/vhc/connhost.c
===================================================================
--- uspace/drv/vhc/connhost.c	(revision 63b4f90725d28de0589f88b5750edf8a9c29b84e)
+++ uspace/drv/vhc/connhost.c	(revision 63b4f90725d28de0589f88b5750edf8a9c29b84e)
@@ -0,0 +1,311 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup usb
+ * @{
+ */
+/** @file
+ * @brief Connection handling of calls from host (implementation).
+ */
+#include <assert.h>
+#include <errno.h>
+#include <usb/hcd.h>
+
+#include "vhcd.h"
+#include "conn.h"
+#include "hc.h"
+
+typedef struct {
+	ipc_callid_t caller;
+	void *buffer;
+	size_t size;
+} async_transaction_t;
+
+static void async_out_callback(void * buffer, size_t len,
+    usb_transaction_outcome_t outcome, void * arg)
+{
+	async_transaction_t * trans = (async_transaction_t *)arg;
+	
+	dprintf(2, "async_out_callback(buffer, %u, %d, %p) -> %x",
+	    len, outcome, arg, trans->caller);
+	
+	// FIXME - answer according to outcome
+	ipc_answer_1(trans->caller, EOK, 0);
+	
+	free(trans);
+	if (buffer) {
+		free(buffer);
+	}
+	dprintf(4, "async_out_callback answered");
+}
+
+static void async_to_device(ipc_callid_t iid, ipc_call_t icall, bool setup_transaction)
+{
+	size_t expected_len = IPC_GET_ARG3(icall);
+	usb_target_t target = {
+		.address = IPC_GET_ARG1(icall),
+		.endpoint = IPC_GET_ARG2(icall)
+	};
+	
+	dprintf(1, "async_to_device: dev=%d:%d, size=%d, iid=%x",
+	    target.address, target.endpoint, expected_len, iid);
+	
+	size_t len = 0;
+	void * buffer = NULL;
+	if (expected_len > 0) {
+		int rc = async_data_write_accept(&buffer, false,
+		    1, USB_MAX_PAYLOAD_SIZE,
+		    0, &len);
+		
+		if (rc != EOK) {
+			ipc_answer_0(iid, rc);
+			return;
+		}
+	}
+	
+	async_transaction_t * trans = malloc(sizeof(async_transaction_t));
+	trans->caller = iid;
+	trans->buffer = NULL;
+	trans->size = 0;
+	
+	hc_add_transaction_to_device(setup_transaction, target,
+	    buffer, len,
+	    async_out_callback, trans);
+	
+	dprintf(2, "async transaction to device scheduled (%p)", trans);
+}
+
+static void async_in_callback(void * buffer, size_t len,
+    usb_transaction_outcome_t outcome, void * arg)
+{	
+	async_transaction_t * trans = (async_transaction_t *)arg;
+	
+	dprintf(2, "async_in_callback(buffer, %u, %d, %p) -> %x",
+	    len, outcome, arg, trans->caller);
+	
+	trans->buffer = buffer;
+	trans->size = len;
+	
+	ipc_callid_t caller = trans->caller;
+	
+	if (buffer == NULL) {
+		free(trans);
+		trans = NULL;
+	}
+	
+	
+	// FIXME - answer according to outcome
+	ipc_answer_1(caller, EOK, (ipcarg_t)trans);
+	dprintf(4, "async_in_callback answered (%#x)", (ipcarg_t)trans);
+}
+
+static void async_from_device(ipc_callid_t iid, ipc_call_t icall)
+{
+	usb_target_t target = {
+		.address = IPC_GET_ARG1(icall),
+		.endpoint = IPC_GET_ARG2(icall)
+	};
+	size_t len = IPC_GET_ARG3(icall);
+	
+	dprintf(1, "async_from_device: dev=%d:%d, size=%d, iid=%x",
+	    target.address, target.endpoint, len, iid);
+	
+	void * buffer = NULL;
+	if (len > 0) {
+		buffer = malloc(len);
+	}
+	
+	async_transaction_t * trans = malloc(sizeof(async_transaction_t));
+	trans->caller = iid;
+	trans->buffer = NULL;
+	trans->size = 0;
+	
+	hc_add_transaction_from_device(target,
+	    buffer, len,
+	    async_in_callback, trans);
+	
+	dprintf(2, "async transfer from device scheduled (%p)", trans);
+}
+
+static void async_get_buffer(ipc_callid_t iid, ipc_call_t icall)
+{
+	ipcarg_t buffer_hash = IPC_GET_ARG1(icall);
+	async_transaction_t * trans = (async_transaction_t *)buffer_hash;
+	if (trans == NULL) {
+		ipc_answer_0(iid, ENOENT);
+		return;
+	}
+	if (trans->buffer == NULL) {
+		ipc_answer_0(iid, EINVAL);
+		free(trans);
+		return;
+	}
+	
+	ipc_callid_t callid;
+	size_t accepted_size;
+	if (!async_data_read_receive(&callid, &accepted_size)) {
+		ipc_answer_0(iid, EINVAL);
+		return;
+	}
+	
+	if (accepted_size > trans->size) {
+		accepted_size = trans->size;
+	}
+	async_data_read_finalize(callid, trans->buffer, accepted_size);
+	
+	ipc_answer_1(iid, EOK, accepted_size);
+	
+	free(trans->buffer);
+	free(trans);
+}
+
+
+/** Connection handler for communcation with host.
+ * By host is typically meant top-level USB driver.
+ *
+ * This function also takes care of proper phone hung-up.
+ *
+ * @param phone_hash Incoming phone hash.
+ */
+void connection_handler_host(ipcarg_t phone_hash)
+{
+	dprintf(0, "host connected through phone %#x", phone_hash);
+	
+	
+	while (true) {
+		ipc_callid_t callid;
+		ipc_call_t call;
+		
+		callid = async_get_call(&call);
+		
+		dprintf(6, "host on %#x calls [%x: %u (%u, %u, %u, %u, %u)]",
+		    phone_hash,
+		    callid,
+		    IPC_GET_METHOD(call),
+		    IPC_GET_ARG1(call), IPC_GET_ARG2(call), IPC_GET_ARG3(call),
+		    IPC_GET_ARG4(call), IPC_GET_ARG5(call));
+		
+		switch (IPC_GET_METHOD(call)) {
+
+			/* standard IPC methods */
+
+			case IPC_M_PHONE_HUNGUP:
+				ipc_answer_0(callid, EOK);
+				dprintf(0, "phone%#x: host hung-up",
+				    phone_hash);
+				return;
+			
+			case IPC_M_CONNECT_TO_ME:
+				ipc_answer_0(callid, ELIMIT);
+				break;
+			
+
+			/* USB methods */
+
+			case IPC_M_USB_HCD_TRANSACTION_SIZE:
+				ipc_answer_1(callid, EOK, USB_MAX_PAYLOAD_SIZE);
+				break;
+			
+			case IPC_M_USB_HCD_GET_BUFFER_ASYNC:
+				async_get_buffer(callid, call);
+				break;
+	
+			case IPC_M_USB_HCD_INTERRUPT_OUT_ASYNC:
+			case IPC_M_USB_HCD_CONTROL_WRITE_DATA_ASYNC:
+			case IPC_M_USB_HCD_CONTROL_READ_STATUS_ASYNC:
+				async_to_device(callid, call, false);
+				break;
+			
+			case IPC_M_USB_HCD_CONTROL_WRITE_SETUP_ASYNC:
+			case IPC_M_USB_HCD_CONTROL_READ_SETUP_ASYNC:
+				async_to_device(callid, call, true);
+				break;
+			
+			case IPC_M_USB_HCD_INTERRUPT_IN_ASYNC:
+			case IPC_M_USB_HCD_CONTROL_WRITE_STATUS_ASYNC:
+			case IPC_M_USB_HCD_CONTROL_READ_DATA_ASYNC:
+				async_from_device(callid, call);
+				break;
+			
+
+			/* end of known methods */
+			
+			default:
+				dprintf_inval_call(2, call, phone_hash);
+				ipc_answer_0(callid, EINVAL);
+				break;
+		}
+	}
+}
+
+static int enqueue_transfer_out(usb_hc_device_t *hc,
+    usb_hcd_attached_device_info_t *dev, usb_hc_endpoint_info_t *endpoint,
+    void *buffer, size_t size,
+    usb_hcd_transfer_callback_out_t callback, void *arg)
+{
+	printf(NAME ": transfer OUT [%d.%d (%s); %u]\n",
+	    dev->address, endpoint->endpoint,
+	    usb_str_transfer_type(endpoint->transfer_type),
+	    size);
+	return ENOTSUP;
+}
+
+static int enqueue_transfer_setup(usb_hc_device_t *hc,
+    usb_hcd_attached_device_info_t *dev, usb_hc_endpoint_info_t *endpoint,
+    void *buffer, size_t size,
+    usb_hcd_transfer_callback_out_t callback, void *arg)
+{
+	printf(NAME ": transfer SETUP [%d.%d (%s); %u]\n",
+	    dev->address, endpoint->endpoint,
+	    usb_str_transfer_type(endpoint->transfer_type),
+	    size);
+	return ENOTSUP;
+}
+
+static int enqueue_transfer_in(usb_hc_device_t *hc,
+    usb_hcd_attached_device_info_t *dev, usb_hc_endpoint_info_t *endpoint,
+    void *buffer, size_t size,
+    usb_hcd_transfer_callback_in_t callback, void *arg)
+{
+	printf(NAME ": transfer IN [%d.%d (%s); %u]\n",
+	    dev->address, endpoint->endpoint,
+	    usb_str_transfer_type(endpoint->transfer_type),
+	    size);
+	return ENOTSUP;
+}
+
+
+usb_hcd_transfer_ops_t vhc_transfer_ops = {
+	.transfer_out = enqueue_transfer_out,
+	.transfer_in = enqueue_transfer_in,
+	.transfer_setup = enqueue_transfer_setup
+};
+
+/**
+ * @}
+ */
Index: uspace/drv/vhc/debug.c
===================================================================
--- uspace/drv/vhc/debug.c	(revision 63b4f90725d28de0589f88b5750edf8a9c29b84e)
+++ uspace/drv/vhc/debug.c	(revision 63b4f90725d28de0589f88b5750edf8a9c29b84e)
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup usb
+ * @{
+ */
+/** @file
+ * @brief Debugging support.
+ */
+#include <stdio.h>
+#include <ipc/ipc.h>
+
+#include "vhcd.h"
+
+/** Current debug level. */
+int debug_level = 0;
+
+/** Debugging printf.
+ * This function is intended for single-line messages as it
+ * automatically prints debugging prefix at the beginning of the
+ * line.
+ *
+ * @see printf
+ * @param level Debugging level.
+ */
+void dprintf(int level, const char *format, ...)
+{
+	if (level > debug_level) {
+		return;
+	}
+	
+	printf("%s(%d): ", NAME, level);
+	va_list args;
+	va_start(args, format);
+	vprintf(format, args);
+	va_end(args);
+	printf("\n");
+}
+
+/** Debug print informing of invalid call.
+ */
+void dprintf_inval_call(int level, ipc_call_t call, ipcarg_t phone_hash)
+{
+	dprintf(level, "phone%#x: invalid call [%u (%u, %u, %u, %u, %u)]",
+	    phone_hash,
+	    IPC_GET_METHOD(call),
+	    IPC_GET_ARG1(call), IPC_GET_ARG2(call), IPC_GET_ARG3(call),
+	    IPC_GET_ARG4(call), IPC_GET_ARG5(call));
+}
+
+/**
+ * @}
+ */
Index: uspace/drv/vhc/devices.c
===================================================================
--- uspace/drv/vhc/devices.c	(revision 63b4f90725d28de0589f88b5750edf8a9c29b84e)
+++ uspace/drv/vhc/devices.c	(revision 63b4f90725d28de0589f88b5750edf8a9c29b84e)
@@ -0,0 +1,186 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup usb
+ * @{
+ */
+/** @file
+ * @brief Virtual device management (implementation).
+ */
+
+#include <ipc/ipc.h>
+#include <adt/list.h>
+#include <bool.h>
+#include <async.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <str_error.h>
+
+#include <usbvirt/hub.h>
+
+#include "devices.h"
+#include "hub.h"
+#include "vhcd.h"
+
+#define list_foreach(pos, head) \
+	for (pos = (head)->next; pos != (head); \
+        	pos = pos->next)
+
+static LIST_INITIALIZE(devices);
+
+/** Create virtual device.
+ *
+ * @param address USB address.
+ * @param phone Callback phone.
+ * @return New device.
+ * @retval NULL Out of memory or address already occupied.
+ */
+virtdev_connection_t *virtdev_add_device(int phone)
+{
+	virtdev_connection_t *dev = (virtdev_connection_t *)
+	    malloc(sizeof(virtdev_connection_t));
+	dev->phone = phone;
+	list_append(&dev->link, &devices);
+	
+	hub_add_device(dev);
+	
+	return dev;
+}
+
+/** Destroy virtual device.
+ */
+void virtdev_destroy_device(virtdev_connection_t *dev)
+{
+	hub_remove_device(dev);
+	list_remove(&dev->link);
+	free(dev);
+}
+
+/** Send data to all connected devices.
+ *
+ * @param transaction Transaction to be sent over the bus.
+ */
+usb_transaction_outcome_t virtdev_send_to_all(transaction_t *transaction)
+{
+	link_t *pos;
+	list_foreach(pos, &devices) {
+		virtdev_connection_t *dev
+		    = list_get_instance(pos, virtdev_connection_t, link);
+		
+		if (!hub_can_device_signal(dev)) {
+			continue;
+		}
+		
+		ipc_call_t answer_data;
+		ipcarg_t answer_rc;
+		aid_t req;
+		int rc = EOK;
+		int method = IPC_M_USBVIRT_TRANSACTION_SETUP;
+		
+		switch (transaction->type) {
+			case USBVIRT_TRANSACTION_SETUP:
+				method = IPC_M_USBVIRT_TRANSACTION_SETUP;
+				break;
+			case USBVIRT_TRANSACTION_IN:
+				method = IPC_M_USBVIRT_TRANSACTION_IN;
+				break;
+			case USBVIRT_TRANSACTION_OUT:
+				method = IPC_M_USBVIRT_TRANSACTION_OUT;
+				break;
+		}
+		
+		req = async_send_3(dev->phone,
+		    method,
+		    transaction->target.address,
+		    transaction->target.endpoint,
+		    transaction->len,
+		    &answer_data);
+		
+		if (transaction->len > 0) {
+			if (transaction->type == USBVIRT_TRANSACTION_IN) {
+				rc = async_data_read_start(dev->phone,
+				    transaction->buffer, transaction->len);
+			} else {
+				rc = async_data_write_start(dev->phone,
+				    transaction->buffer, transaction->len);
+			}
+		}
+		
+		if (rc != EOK) {
+			async_wait_for(req, NULL);
+		} else {
+			async_wait_for(req, &answer_rc);
+			rc = (int)answer_rc;
+		}
+	}
+	
+	/*
+	 * Send the data to the virtual hub as well
+	 * (if the address matches).
+	 */
+	if (virthub_dev.address == transaction->target.address) {
+		size_t tmp;
+		dprintf(3, "sending `%s' transaction to hub",
+		    usbvirt_str_transaction_type(transaction->type));
+		switch (transaction->type) {
+			case USBVIRT_TRANSACTION_SETUP:
+				virthub_dev.transaction_setup(&virthub_dev,
+				    transaction->target.endpoint,
+				    transaction->buffer, transaction->len);
+				break;
+				
+			case USBVIRT_TRANSACTION_IN:
+				virthub_dev.transaction_in(&virthub_dev,
+				    transaction->target.endpoint,
+				    transaction->buffer, transaction->len,
+				    &tmp);
+				if (tmp < transaction->len) {
+					transaction->len = tmp;
+				}
+				break;
+				
+			case USBVIRT_TRANSACTION_OUT:
+				virthub_dev.transaction_out(&virthub_dev,
+				    transaction->target.endpoint,
+				    transaction->buffer, transaction->len);
+				break;
+		}
+		dprintf(4, "transaction on hub processed...");
+	}
+	
+	/*
+	 * TODO: maybe screw some transactions to get more
+	 * real-life image.
+	 */
+	return USB_OUTCOME_OK;
+}
+
+/**
+ * @}
+ */
Index: uspace/drv/vhc/devices.h
===================================================================
--- uspace/drv/vhc/devices.h	(revision 63b4f90725d28de0589f88b5750edf8a9c29b84e)
+++ uspace/drv/vhc/devices.h	(revision 63b4f90725d28de0589f88b5750edf8a9c29b84e)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup usb
+ * @{
+ */ 
+/** @file
+ * @brief Virtual device management.
+ */
+#ifndef VHCD_DEVICES_H_
+#define VHCD_DEVICES_H_
+
+#include <adt/list.h>
+#include <usb/hcd.h>
+
+#include "hc.h"
+
+/** Connected virtual device. */
+typedef struct {
+	/** Phone used when sending data to device. */
+	int phone;
+	/** Linked-list handle. */
+	link_t link;
+} virtdev_connection_t;
+
+virtdev_connection_t *virtdev_add_device(int);
+void virtdev_destroy_device(virtdev_connection_t *);
+usb_transaction_outcome_t virtdev_send_to_all(transaction_t *);
+
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/vhc/hc.c
===================================================================
--- uspace/drv/vhc/hc.c	(revision 63b4f90725d28de0589f88b5750edf8a9c29b84e)
+++ uspace/drv/vhc/hc.c	(revision 63b4f90725d28de0589f88b5750edf8a9c29b84e)
@@ -0,0 +1,186 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup usb
+ * @{
+ */
+/** @file
+ * @brief Virtual HC (implementation).
+ */
+
+#include <ipc/ipc.h>
+#include <adt/list.h>
+#include <bool.h>
+#include <async.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <str_error.h>
+
+#include <usbvirt/hub.h>
+
+#include "vhcd.h"
+#include "hc.h"
+#include "devices.h"
+#include "hub.h"
+
+#define USLEEP_BASE (500 * 1000)
+
+#define USLEEP_VAR 5000
+
+#define SHORTENING_VAR 15
+
+#define PROB_OUTCOME_BABBLE 5
+#define PROB_OUTCOME_CRCERROR 7
+
+#define PROB_TEST(var, new_value, prob, number) \
+	do { \
+		if (((number) % (prob)) == 0) { \
+			var = (new_value); \
+		} \
+	} while (0)
+
+static link_t transaction_list;
+
+#define TRANSACTION_FORMAT "T[%d:%d %s (%d)]"
+#define TRANSACTION_PRINTF(t) \
+	(t).target.address, (t).target.endpoint, \
+	usbvirt_str_transaction_type((t).type), \
+	(int)(t).len
+
+#define transaction_get_instance(lnk) \
+	list_get_instance(lnk, transaction_t, link)
+
+static inline unsigned int pseudo_random(unsigned int *seed)
+{
+	*seed = ((*seed) * 873511) % 22348977 + 7;
+	return ((*seed) >> 8);
+}
+
+/** Call transaction callback.
+ * Calling this callback informs the backend that transaction was processed.
+ */
+static void process_transaction_with_outcome(transaction_t * transaction,
+    usb_transaction_outcome_t outcome)
+{
+	dprintf(3, "processing transaction " TRANSACTION_FORMAT ", outcome: %s",
+	    TRANSACTION_PRINTF(*transaction),
+	    usb_str_transaction_outcome(outcome));
+	
+	transaction->callback(transaction->buffer, transaction->len, outcome,
+	    transaction->callback_arg);
+}
+
+/** Host controller manager main function.
+ */
+void hc_manager(void)
+{
+	list_initialize(&transaction_list);
+	
+	static unsigned int seed = 4573;
+	
+	printf("%s: transaction processor ready.\n", NAME);
+	
+	while (true) {
+		async_usleep(USLEEP_BASE + (pseudo_random(&seed) % USLEEP_VAR));
+		
+		if (list_empty(&transaction_list)) {
+			continue;
+		}
+		
+		char ports[HUB_PORT_COUNT + 2];
+		hub_get_port_statuses(ports, HUB_PORT_COUNT + 1);
+		dprintf(3, "virtual hub: addr=%d ports=%s",
+		    virthub_dev.address, ports);
+		
+		link_t *first_transaction_link = transaction_list.next;
+		transaction_t *transaction
+		    = transaction_get_instance(first_transaction_link);
+		list_remove(first_transaction_link);
+		
+		dprintf(3, "processing transaction " TRANSACTION_FORMAT "",
+		    TRANSACTION_PRINTF(*transaction));
+		
+		usb_transaction_outcome_t outcome;
+		outcome = virtdev_send_to_all(transaction);
+		
+		process_transaction_with_outcome(transaction, outcome);
+		
+		free(transaction);
+	}
+}
+
+/** Create new transaction
+ */
+static transaction_t *transaction_create(usbvirt_transaction_type_t type,
+    usb_target_t target,
+    void * buffer, size_t len,
+    hc_transaction_done_callback_t callback, void * arg)
+{
+	transaction_t * transaction = malloc(sizeof(transaction_t));
+	
+	list_initialize(&transaction->link);
+	transaction->type = type;
+	transaction->target = target;
+	transaction->buffer = buffer;
+	transaction->len = len;
+	transaction->callback = callback;
+	transaction->callback_arg = arg;
+	
+	dprintf(1, "creating transaction " TRANSACTION_FORMAT,
+	    TRANSACTION_PRINTF(*transaction));
+	
+	return transaction;
+}
+
+/** Add transaction directioned towards the device.
+ */
+void hc_add_transaction_to_device(bool setup, usb_target_t target,
+    void * buffer, size_t len,
+    hc_transaction_done_callback_t callback, void * arg)
+{
+	transaction_t *transaction = transaction_create(
+	    setup ? USBVIRT_TRANSACTION_SETUP : USBVIRT_TRANSACTION_OUT, target,
+	    buffer, len, callback, arg);
+	list_append(&transaction->link, &transaction_list);
+}
+
+/** Add transaction directioned from the device.
+ */
+void hc_add_transaction_from_device(usb_target_t target,
+    void * buffer, size_t len,
+    hc_transaction_done_callback_t callback, void * arg)
+{
+	transaction_t *transaction = transaction_create(USBVIRT_TRANSACTION_IN,
+	    target, buffer, len, callback, arg);
+	list_append(&transaction->link, &transaction_list);
+}
+
+/**
+ * @}
+ */
Index: uspace/drv/vhc/hc.h
===================================================================
--- uspace/drv/vhc/hc.h	(revision 63b4f90725d28de0589f88b5750edf8a9c29b84e)
+++ uspace/drv/vhc/hc.h	(revision 63b4f90725d28de0589f88b5750edf8a9c29b84e)
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup usb
+ * @{
+ */
+/** @file
+ * @brief Virtual HC.
+ */
+#ifndef VHCD_HC_H_
+#define VHCD_HC_H_
+
+#include <usb/hcd.h>
+#include <usbvirt/hub.h>
+
+/** Callback after transaction is sent to USB.
+ *
+ * @param buffer Transaction data buffer.
+ * @param size Transaction data size.
+ * @param outcome Transaction outcome.
+ * @param arg Custom argument.
+ */
+typedef void (*hc_transaction_done_callback_t)(void *buffer, size_t size,
+    usb_transaction_outcome_t outcome, void *arg);
+
+/** Pending transaction details. */
+typedef struct {
+	/** Linked-list link. */
+	link_t link;
+	/** Transaction type. */
+	usbvirt_transaction_type_t type;
+	/** Device address. */
+	usb_target_t target;
+	/** Direction of the transaction. */
+	usb_direction_t direction;
+	/** Transaction data buffer. */
+	void * buffer;
+	/** Transaction data length. */
+	size_t len;
+	/** Callback after transaction is done. */
+	hc_transaction_done_callback_t callback;
+	/** Argument to the callback. */
+	void * callback_arg;
+} transaction_t;
+
+void hc_manager(void);
+
+void hc_add_transaction_to_device(bool setup, usb_target_t target,
+    void * buffer, size_t len,
+    hc_transaction_done_callback_t callback, void * arg);
+
+void hc_add_transaction_from_device(usb_target_t target,
+    void * buffer, size_t len,
+    hc_transaction_done_callback_t callback, void * arg);
+
+int hc_fillin_transaction_from_device(usb_target_t target,
+    void * buffer, size_t len);
+
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/vhc/hcd.c
===================================================================
--- uspace/drv/vhc/hcd.c	(revision 63b4f90725d28de0589f88b5750edf8a9c29b84e)
+++ uspace/drv/vhc/hcd.c	(revision 63b4f90725d28de0589f88b5750edf8a9c29b84e)
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup usb
+ * @{
+ */ 
+/** @file
+ * @brief Virtual host controller driver.
+ */
+
+#include <devmap.h>
+#include <ipc/ipc.h>
+#include <async.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sysinfo.h>
+#include <stdio.h>
+#include <errno.h>
+#include <str_error.h>
+#include <driver.h>
+
+#include <usb/hcd.h>
+#include "vhcd.h"
+#include "hc.h"
+#include "devices.h"
+#include "hub.h"
+#include "conn.h"
+
+static int vhc_count = 0;
+static int vhc_add_device(usb_hc_device_t *dev)
+{
+	printf("%s: new device registered.\n", NAME);
+	/*
+	 * Currently, we know how to simulate only single HC.
+	 */
+	if (vhc_count > 0) {
+		return ELIMIT;
+	}
+
+	vhc_count++;
+
+	dev->transfer_ops = &vhc_transfer_ops;
+	/* Fail because of bug in libusb that caused devman to hang. */
+	return ENOTSUP;
+}
+
+static usb_hc_driver_t vhc_driver = {
+	.name = NAME,
+	.add_hc = &vhc_add_device
+};
+
+int main(int argc, char * argv[])
+{	
+	/*
+	 * For debugging purpose to enable viewing the output
+	 * within devman tty.
+	 */
+	sleep(5);
+
+	printf("%s: virtual USB host controller driver.\n", NAME);
+
+	return usb_hcd_main(&vhc_driver);
+}
+
+
+/**
+ * @}
+ */
Index: uspace/drv/vhc/hub.c
===================================================================
--- uspace/drv/vhc/hub.c	(revision 63b4f90725d28de0589f88b5750edf8a9c29b84e)
+++ uspace/drv/vhc/hub.c	(revision 63b4f90725d28de0589f88b5750edf8a9c29b84e)
@@ -0,0 +1,256 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup usb
+ * @{
+ */
+/** @file
+ * @brief Virtual USB hub.
+ */
+#include <usb/classes.h>
+#include <usbvirt/hub.h>
+#include <usbvirt/device.h>
+#include <errno.h>
+#include <stdlib.h>
+
+#include "vhcd.h"
+#include "hub.h"
+#include "hubintern.h"
+
+
+/** Standard device descriptor. */
+usb_standard_device_descriptor_t std_device_descriptor = {
+	.length = sizeof(usb_standard_device_descriptor_t),
+	.descriptor_type = USB_DESCTYPE_DEVICE,
+	.usb_spec_version = 0x110,
+	.device_class = USB_CLASS_HUB,
+	.device_subclass = 0,
+	.device_protocol = 0,
+	.max_packet_size = 64,
+	.configuration_count = 1
+};
+
+/** Standard interface descriptor. */
+usb_standard_interface_descriptor_t std_interface_descriptor = {
+	.length = sizeof(usb_standard_interface_descriptor_t),
+	.descriptor_type = USB_DESCTYPE_INTERFACE,
+	.interface_number = 0,
+	.alternate_setting = 0,
+	.endpoint_count = 1,
+	.interface_class = USB_CLASS_HUB,
+	.interface_subclass = 0,
+	.interface_protocol = 0,
+	.str_interface = 0
+};
+
+hub_descriptor_t hub_descriptor = {
+	.length = sizeof(hub_descriptor_t),
+	.type = USB_DESCTYPE_HUB,
+	.port_count = HUB_PORT_COUNT,
+	.characteristics = 0, 
+	.power_on_warm_up = 50, /* Huh? */
+	.max_current = 100, /* Huh again. */
+	.removable_device = { 0 },
+	.port_power = { 0xFF }
+};
+
+/** Endpoint descriptor. */
+usb_standard_endpoint_descriptor_t endpoint_descriptor = {
+	.length = sizeof(usb_standard_endpoint_descriptor_t),
+	.descriptor_type = USB_DESCTYPE_ENDPOINT,
+	.endpoint_address = HUB_STATUS_CHANGE_PIPE | 128,
+	.attributes = USB_TRANSFER_INTERRUPT,
+	.max_packet_size = 8,
+	.poll_interval = 0xFF
+};
+
+/** Standard configuration descriptor. */
+usb_standard_configuration_descriptor_t std_configuration_descriptor = {
+	.length = sizeof(usb_standard_configuration_descriptor_t),
+	.descriptor_type = USB_DESCTYPE_CONFIGURATION,
+	.total_length = 
+		sizeof(usb_standard_configuration_descriptor_t)
+		+ sizeof(std_interface_descriptor)
+		+ sizeof(hub_descriptor)
+		+ sizeof(endpoint_descriptor)
+		,
+	.interface_count = 1,
+	.configuration_number = HUB_CONFIGURATION_ID,
+	.str_configuration = 0,
+	.attributes = 128, /* denotes bus-powered device */
+	.max_power = 50
+};
+
+/** All hub configuration descriptors. */
+static usbvirt_device_configuration_extras_t extra_descriptors[] = {
+	{
+		.data = (uint8_t *) &std_interface_descriptor,
+		.length = sizeof(std_interface_descriptor)
+	},
+	{
+		.data = (uint8_t *) &hub_descriptor,
+		.length = sizeof(hub_descriptor)
+	},
+	{
+		.data = (uint8_t *) &endpoint_descriptor,
+		.length = sizeof(endpoint_descriptor)
+	}
+};
+
+/** Hub configuration. */
+usbvirt_device_configuration_t configuration = {
+	.descriptor = &std_configuration_descriptor,
+	.extra = extra_descriptors,
+	.extra_count = sizeof(extra_descriptors)/sizeof(extra_descriptors[0])
+};
+
+/** Hub standard descriptors. */
+usbvirt_descriptors_t descriptors = {
+	.device = &std_device_descriptor,
+	.configuration = &configuration,
+	.configuration_count = 1,
+};
+
+/** Hub as a virtual device. */
+usbvirt_device_t virthub_dev = {
+	.ops = &hub_ops,
+	.descriptors = &descriptors,
+	.lib_debug_level = 4,
+	.lib_debug_enabled_tags = USBVIRT_DEBUGTAG_ALL
+};
+
+/** Hub device. */
+hub_device_t hub_dev;
+
+/** Initialize virtual hub. */
+void hub_init(void)
+{
+	size_t i;
+	for (i = 0; i < HUB_PORT_COUNT; i++) {
+		hub_port_t *port = &hub_dev.ports[i];
+		
+		port->device = NULL;
+		port->state = HUB_PORT_STATE_NOT_CONFIGURED;
+		port->status_change = 0;
+	}
+	
+	usbvirt_connect_local(&virthub_dev);
+	
+	dprintf(1, "virtual hub (%d ports) created", HUB_PORT_COUNT);
+}
+
+/** Connect device to the hub.
+ *
+ * @param device Device to be connected.
+ * @return Port where the device was connected to.
+ */
+size_t hub_add_device(virtdev_connection_t *device)
+{
+	size_t i;
+	for (i = 0; i < HUB_PORT_COUNT; i++) {
+		hub_port_t *port = &hub_dev.ports[i];
+		
+		if (port->device != NULL) {
+			continue;
+		}
+		
+		port->device = device;
+		
+		/*
+		 * TODO:
+		 * If the hub was configured, we can normally
+		 * announce the plug-in.
+		 * Otherwise, we will wait until hub is configured
+		 * and announce changes in single burst.
+		 */
+		//if (port->state == HUB_PORT_STATE_DISCONNECTED) {
+			port->state = HUB_PORT_STATE_DISABLED;
+			set_port_status_change(port, HUB_STATUS_C_PORT_CONNECTION);
+		//}
+		
+		return i;
+	}
+	
+	return (size_t)-1;
+}
+
+/** Disconnect device from the hub. */
+void hub_remove_device(virtdev_connection_t *device)
+{
+	size_t i;
+	for (i = 0; i < HUB_PORT_COUNT; i++) {
+		hub_port_t *port = &hub_dev.ports[i];
+		
+		if (port->device != device) {
+			continue;
+		}
+		
+		port->device = NULL;
+		port->state = HUB_PORT_STATE_DISCONNECTED;
+		
+		set_port_status_change(port, HUB_STATUS_C_PORT_CONNECTION);
+	}
+}
+
+/** Tell whether device port is open.
+ *
+ * @return Whether communication to and from the device can go through the hub.
+ */
+bool hub_can_device_signal(virtdev_connection_t * device)
+{
+	size_t i;
+	for (i = 0; i < HUB_PORT_COUNT; i++) {
+		if (hub_dev.ports[i].device == device) {
+			return hub_dev.ports[i].state == HUB_PORT_STATE_ENABLED;
+		}
+	}
+	
+	return false;
+}
+
+/** Format hub port status.
+ *
+ * @param result Buffer where to store status string.
+ * @param len Number of characters that is possible to store in @p result
+ * 	(excluding trailing zero).
+ */
+void hub_get_port_statuses(char *result, size_t len)
+{
+	if (len > HUB_PORT_COUNT) {
+		len = HUB_PORT_COUNT;
+	}
+	size_t i;
+	for (i = 0; i < len; i++) {
+		result[i] = hub_port_state_as_char(hub_dev.ports[i].state);
+	}
+	result[len] = 0;
+}
+
+/**
+ * @}
+ */
Index: uspace/drv/vhc/hub.h
===================================================================
--- uspace/drv/vhc/hub.h	(revision 63b4f90725d28de0589f88b5750edf8a9c29b84e)
+++ uspace/drv/vhc/hub.h	(revision 63b4f90725d28de0589f88b5750edf8a9c29b84e)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup usb
+ * @{
+ */
+/** @file
+ * @brief Virtual USB hub.
+ */
+#ifndef VHCD_HUB_H_
+#define VHCD_HUB_H_
+
+#include <usbvirt/device.h>
+
+#include "devices.h"
+
+#define HUB_PORT_COUNT 6
+
+#define BITS2BYTES(bits) \
+    (bits ? ((((bits)-1)>>3)+1) : 0)
+
+extern usbvirt_device_t virthub_dev;
+
+void hub_init(void);
+size_t hub_add_device(virtdev_connection_t *);
+void hub_remove_device(virtdev_connection_t *);
+bool hub_can_device_signal(virtdev_connection_t *);
+void hub_get_port_statuses(char *result, size_t len);
+
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/vhc/hubintern.h
===================================================================
--- uspace/drv/vhc/hubintern.h	(revision 63b4f90725d28de0589f88b5750edf8a9c29b84e)
+++ uspace/drv/vhc/hubintern.h	(revision 63b4f90725d28de0589f88b5750edf8a9c29b84e)
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup usb
+ * @{
+ */
+/** @file
+ * @brief
+ */
+#ifndef VHCD_HUBINTERN_H_
+#define VHCD_HUBINTERN_H_
+
+#include "hub.h"
+
+/** Endpoint number for status change pipe. */
+#define HUB_STATUS_CHANGE_PIPE 1
+/** Configuration value for hub configuration. */
+#define HUB_CONFIGURATION_ID 1
+
+/** Hub descriptor.
+ */
+typedef struct {
+	/** Size of this descriptor in bytes. */
+	uint8_t length;
+	/** Descriptor type (USB_DESCTYPE_HUB). */
+	uint8_t type;
+	/** Number of downstream ports. */
+	uint8_t port_count;
+	/** Hub characteristics. */
+	uint16_t characteristics;
+	/** Time from power-on to stabilized current.
+	 * Expressed in 2ms unit.
+	 */
+	uint8_t power_on_warm_up;
+	/** Maximum current (in mA). */
+	uint8_t max_current;
+	/** Whether device at given port is removable. */
+	uint8_t removable_device[BITS2BYTES(HUB_PORT_COUNT+1)];
+	/** Port power control.
+	 * This is USB1.0 compatibility field, all bits must be 1.
+	 */
+	uint8_t port_power[BITS2BYTES(HUB_PORT_COUNT+1)];
+} __attribute__ ((packed)) hub_descriptor_t;
+
+/** Hub port internal state.
+ * Some states (e.g. port over current) are not covered as they are not
+ * simulated at all.
+ */
+typedef enum {
+	HUB_PORT_STATE_NOT_CONFIGURED,
+	HUB_PORT_STATE_POWERED_OFF,
+	HUB_PORT_STATE_DISCONNECTED,
+	HUB_PORT_STATE_DISABLED,
+	HUB_PORT_STATE_RESETTING,
+	HUB_PORT_STATE_ENABLED,
+	HUB_PORT_STATE_SUSPENDED,
+	HUB_PORT_STATE_RESUMING,
+	/* HUB_PORT_STATE_, */
+} hub_port_state_t;
+
+/** Convert hub port state to a char. */
+static inline char hub_port_state_as_char(hub_port_state_t state) {
+	switch (state) {
+		case HUB_PORT_STATE_NOT_CONFIGURED:
+			return '-';
+		case HUB_PORT_STATE_POWERED_OFF:
+			return 'O';
+		case HUB_PORT_STATE_DISCONNECTED:
+			return 'X';
+		case HUB_PORT_STATE_DISABLED:
+			return 'D';
+		case HUB_PORT_STATE_RESETTING:
+			return 'R';
+		case HUB_PORT_STATE_ENABLED:
+			return 'E';
+		case HUB_PORT_STATE_SUSPENDED:
+			return 'S';
+		case HUB_PORT_STATE_RESUMING:
+			return 'F';
+		default:
+			return '?';
+	}
+}
+
+/** Hub status change mask bits. */
+typedef enum {
+	HUB_STATUS_C_PORT_CONNECTION = (1 << 0),
+	HUB_STATUS_C_PORT_ENABLE = (1 << 1),
+	HUB_STATUS_C_PORT_SUSPEND = (1 << 2),
+	HUB_STATUS_C_PORT_OVER_CURRENT = (1 << 3),
+	HUB_STATUS_C_PORT_RESET = (1 << 4),
+	/* HUB_STATUS_C_ = (1 << ), */
+} hub_status_change_t;
+
+/** Hub port information. */
+typedef struct {
+	virtdev_connection_t *device;
+	hub_port_state_t state;
+	uint16_t status_change;
+} hub_port_t;
+
+/** Hub device type. */
+typedef struct {
+	hub_port_t ports[HUB_PORT_COUNT];
+} hub_device_t;
+
+extern hub_device_t hub_dev;
+
+extern hub_descriptor_t hub_descriptor;
+
+extern usbvirt_device_ops_t hub_ops;
+
+void clear_port_status_change(hub_port_t *, uint16_t);
+void set_port_status_change(hub_port_t *, uint16_t);
+
+
+#endif
+/**
+ * @}
+ */
Index: uspace/drv/vhc/hubops.c
===================================================================
--- uspace/drv/vhc/hubops.c	(revision 63b4f90725d28de0589f88b5750edf8a9c29b84e)
+++ uspace/drv/vhc/hubops.c	(revision 63b4f90725d28de0589f88b5750edf8a9c29b84e)
@@ -0,0 +1,384 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup usb
+ * @{
+ */
+/** @file
+ * @brief Virtual USB hub operations.
+ */
+#include <usb/classes.h>
+#include <usb/hub.h>
+#include <usbvirt/hub.h>
+#include <usbvirt/device.h>
+#include <errno.h>
+
+#include "vhcd.h"
+#include "hub.h"
+#include "hubintern.h"
+
+/** Produce a byte from bit values.
+ */
+#define MAKE_BYTE(b0, b1, b2, b3, b4, b5, b6, b7) \
+	(( \
+		((b0) << 0) \
+		| ((b1) << 1) \
+		| ((b2) << 2) \
+		| ((b3) << 3) \
+		| ((b4) << 4) \
+		| ((b5) << 5) \
+		| ((b6) << 6) \
+		| ((b7) << 7) \
+	))
+
+static int on_get_descriptor(struct usbvirt_device *dev,
+    usb_device_request_setup_packet_t *request, uint8_t *data);
+static int on_class_request(struct usbvirt_device *dev,
+    usb_device_request_setup_packet_t *request, uint8_t *data);
+static int on_data_request(struct usbvirt_device *dev,
+    usb_endpoint_t endpoint,
+    void *buffer, size_t size, size_t *actual_size);
+
+/** Standard USB requests. */
+static usbvirt_standard_device_request_ops_t standard_request_ops = {
+	.on_get_status = NULL,
+	.on_clear_feature = NULL,
+	.on_set_feature = NULL,
+	.on_set_address = NULL,
+	.on_get_descriptor = on_get_descriptor,
+	.on_set_descriptor = NULL,
+	.on_get_configuration = NULL,
+	.on_set_configuration = NULL,
+	.on_get_interface = NULL,
+	.on_set_interface = NULL,
+	.on_synch_frame = NULL
+};
+
+/** Hub operations. */
+usbvirt_device_ops_t hub_ops = {
+	.standard_request_ops = &standard_request_ops,
+	.on_class_device_request = on_class_request,
+	.on_data = NULL,
+	.on_data_request = on_data_request
+};
+
+/** Callback for GET_DESCRIPTOR request. */
+static int on_get_descriptor(struct usbvirt_device *dev,
+    usb_device_request_setup_packet_t *request, uint8_t *data)
+{
+	if (request->value_high == USB_DESCTYPE_HUB) {
+		int rc = dev->control_transfer_reply(dev, 0,
+		    &hub_descriptor, hub_descriptor.length);
+		
+		return rc;
+	}
+	/* Let the framework handle all the rest. */
+	return EFORWARD;
+}
+
+/** Change port status and updates status change status fields.
+ */
+static void set_port_state(hub_port_t *port, hub_port_state_t state)
+{
+	port->state = state;
+	if (state == HUB_PORT_STATE_POWERED_OFF) {
+		clear_port_status_change(port, HUB_STATUS_C_PORT_CONNECTION);
+		clear_port_status_change(port, HUB_STATUS_C_PORT_ENABLE);
+		clear_port_status_change(port, HUB_STATUS_C_PORT_RESET);
+	}
+	if (state == HUB_PORT_STATE_RESUMING) {
+		async_usleep(10*1000);
+		if (port->state == state) {
+			set_port_state(port, HUB_PORT_STATE_ENABLED);
+		}
+	}
+	if (state == HUB_PORT_STATE_RESETTING) {
+		async_usleep(10*1000);
+		if (port->state == state) {
+			set_port_status_change(port, HUB_STATUS_C_PORT_RESET);
+			set_port_state(port, HUB_PORT_STATE_ENABLED);
+		}
+	}
+}
+
+/** Get access to a port or return with EINVAL. */
+#define _GET_PORT(portvar, index) \
+	do { \
+		if (virthub_dev.state != USBVIRT_STATE_CONFIGURED) { \
+			return EINVAL; \
+		} \
+		if (((index) == 0) || ((index) > HUB_PORT_COUNT)) { \
+			return EINVAL; \
+		} \
+	} while (false); \
+	hub_port_t *portvar = &hub_dev.ports[index]
+
+
+static int clear_hub_feature(uint16_t feature)
+{
+	return ENOTSUP;
+}
+
+static int clear_port_feature(uint16_t feature, uint16_t portindex)
+{	
+	_GET_PORT(port, portindex);
+	
+	switch (feature) {
+		case USB_HUB_FEATURE_PORT_ENABLE:
+			if ((port->state != HUB_PORT_STATE_NOT_CONFIGURED)
+			    && (port->state != HUB_PORT_STATE_POWERED_OFF)) {
+				set_port_state(port, HUB_PORT_STATE_DISABLED);
+			}
+			return EOK;
+		
+		case USB_HUB_FEATURE_PORT_SUSPEND:
+			if (port->state != HUB_PORT_STATE_SUSPENDED) {
+				return EOK;
+			}
+			set_port_state(port, HUB_PORT_STATE_RESUMING);
+			return EOK;
+			
+		case USB_HUB_FEATURE_PORT_POWER:
+			if (port->state != HUB_PORT_STATE_NOT_CONFIGURED) {
+				set_port_state(port, HUB_PORT_STATE_POWERED_OFF);
+			}
+			return EOK;
+		
+		case USB_HUB_FEATURE_C_PORT_CONNECTION:
+			clear_port_status_change(port, HUB_STATUS_C_PORT_CONNECTION);
+			return EOK;
+		
+		case USB_HUB_FEATURE_C_PORT_ENABLE:
+			clear_port_status_change(port, HUB_STATUS_C_PORT_ENABLE);
+			return EOK;
+		
+		case USB_HUB_FEATURE_C_PORT_SUSPEND:
+			clear_port_status_change(port, HUB_STATUS_C_PORT_SUSPEND);
+			return EOK;
+			
+		case USB_HUB_FEATURE_C_PORT_OVER_CURRENT:
+			clear_port_status_change(port, HUB_STATUS_C_PORT_OVER_CURRENT);
+			return EOK;
+	}
+	
+	return ENOTSUP;
+}
+
+static int get_bus_state(uint16_t portindex)
+{
+	return ENOTSUP;
+}
+
+static int get_hub_descriptor(uint8_t descriptor_type,
+    uint8_t descriptor_index, uint16_t length)
+{
+	return ENOTSUP;
+}
+
+static int get_hub_status(void)
+{
+	uint32_t hub_status = 0;
+	
+	return virthub_dev.control_transfer_reply(&virthub_dev, 0,
+	    &hub_status, 4);
+}
+
+static int get_port_status(uint16_t portindex)
+{
+	_GET_PORT(port, portindex);
+	
+	uint32_t status;
+	status = MAKE_BYTE(
+	    /* Current connect status. */
+	    port->device == NULL ? 0 : 1,
+	    /* Port enabled/disabled. */
+	    port->state == HUB_PORT_STATE_ENABLED ? 1 : 0,
+	    /* Suspend. */
+	    (port->state == HUB_PORT_STATE_SUSPENDED)
+	        || (port->state == HUB_PORT_STATE_RESUMING) ? 1 : 0,
+	    /* Over-current. */
+	    0,
+	    /* Reset. */
+	    port->state == HUB_PORT_STATE_RESETTING ? 1 : 0,
+	    /* Reserved. */
+	    0, 0, 0)
+	    
+	    | (MAKE_BYTE(
+	    /* Port power. */
+	    port->state == HUB_PORT_STATE_POWERED_OFF ? 0 : 1,
+	    /* Full-speed device. */
+	    0,
+	    /* Reserved. */
+	    0, 0, 0, 0, 0, 0
+	    )) << 8;
+	    
+	status |= (port->status_change << 16);
+	
+	return virthub_dev.control_transfer_reply(&virthub_dev, 0, &status, 4);
+}
+
+
+static int set_hub_feature(uint16_t feature)
+{
+	return ENOTSUP;
+}
+
+static int set_port_feature(uint16_t feature, uint16_t portindex)
+{
+	_GET_PORT(port, portindex);
+	
+	switch (feature) {
+		case USB_HUB_FEATURE_PORT_RESET:
+			if (port->state != HUB_PORT_STATE_POWERED_OFF) {
+				set_port_state(port, HUB_PORT_STATE_RESETTING);
+			}
+			return EOK;
+		
+		case USB_HUB_FEATURE_PORT_SUSPEND:
+			if (port->state == HUB_PORT_STATE_ENABLED) {
+				set_port_state(port, HUB_PORT_STATE_SUSPENDED);
+			}
+			return EOK;
+		
+		case USB_HUB_FEATURE_PORT_POWER:
+			if (port->state == HUB_PORT_STATE_POWERED_OFF) {
+				set_port_state(port, HUB_PORT_STATE_DISCONNECTED);
+			}
+			return EOK;
+	}
+	return ENOTSUP;
+}
+
+#undef _GET_PORT
+
+
+/** Callback for class request. */
+static int on_class_request(struct usbvirt_device *dev,
+    usb_device_request_setup_packet_t *request, uint8_t *data)
+{	
+	dprintf(2, "hub class request (%d)\n", (int) request->request);
+	
+	uint8_t recipient = request->request_type & 31;
+	uint8_t direction = request->request_type >> 7;
+	
+#define _VERIFY(cond) \
+	do { \
+		if (!(cond)) { \
+			dprintf(0, "WARN: invalid class request (%s not met).\n", \
+			    NAME, #cond); \
+			return EINVAL; \
+		} \
+	} while (0)
+	
+	switch (request->request) {
+		case USB_HUB_REQUEST_CLEAR_FEATURE:
+			_VERIFY(direction == 0);
+			_VERIFY(request->length == 0);
+			if (recipient == 0) {
+				_VERIFY(request->index == 0);
+				return clear_hub_feature(request->value);
+			} else {
+				_VERIFY(recipient == 3);
+				return clear_port_feature(request->value,
+				    request->index);
+			}
+			
+		case USB_HUB_REQUEST_GET_STATE:
+			return get_bus_state(request->index);
+			
+		case USB_HUB_REQUEST_GET_DESCRIPTOR:
+			return get_hub_descriptor(request->value_low,
+			    request->value_high, request->length);
+			
+		case USB_HUB_REQUEST_GET_STATUS:
+			if (recipient == 0) {
+				return get_hub_status();
+			} else {
+				return get_port_status(request->index);
+			}
+			
+		case USB_HUB_REQUEST_SET_FEATURE:
+			if (recipient == 0) {
+				return set_hub_feature(request->value);
+			} else {
+				return set_port_feature(request->value, request->index);
+			}
+			
+		default:
+			break;
+	}
+	
+#undef _VERIFY	
+
+
+	return EOK;
+}
+
+void clear_port_status_change(hub_port_t *port, uint16_t change)
+{
+	port->status_change &= (~change);
+}
+
+void set_port_status_change(hub_port_t *port, uint16_t change)
+{
+	port->status_change |= change;
+}
+
+/** Callback for data request. */
+static int on_data_request(struct usbvirt_device *dev,
+    usb_endpoint_t endpoint,
+    void *buffer, size_t size, size_t *actual_size)
+{
+	if (endpoint != HUB_STATUS_CHANGE_PIPE) {
+		return EINVAL;
+	}
+	
+	uint8_t change_map = 0;
+	
+	size_t i;
+	for (i = 0; i < HUB_PORT_COUNT; i++) {
+		hub_port_t *port = &hub_dev.ports[i];
+		
+		if (port->status_change != 0) {
+			change_map |= (1 << (i + 1));
+		}
+	}
+	
+	uint8_t *b = (uint8_t *) buffer;
+	if (size > 0) {
+		*b = change_map;
+		*actual_size = 1;
+	}
+	
+	return EOK;
+}
+
+
+/**
+ * @}
+ */
Index: uspace/drv/vhc/vhc.ma
===================================================================
--- uspace/drv/vhc/vhc.ma	(revision 63b4f90725d28de0589f88b5750edf8a9c29b84e)
+++ uspace/drv/vhc/vhc.ma	(revision 63b4f90725d28de0589f88b5750edf8a9c29b84e)
@@ -0,0 +1,2 @@
+10 usb&hc=vhc
+10 usb&hc=vhc&hub
Index: uspace/drv/vhc/vhcd.h
===================================================================
--- uspace/drv/vhc/vhcd.h	(revision 63b4f90725d28de0589f88b5750edf8a9c29b84e)
+++ uspace/drv/vhc/vhcd.h	(revision 63b4f90725d28de0589f88b5750edf8a9c29b84e)
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2010 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup usb
+ * @{
+ */
+/** @file
+ * @brief Virtual USB host controller common definitions.
+ */
+#ifndef VHCD_VHCD_H_
+#define VHCD_VHCD_H_
+
+#define NAME "vhc"
+#define NAME_DEV "hcd-virt-dev"
+#define NAMESPACE "usb"
+
+#define DEVMAP_PATH_HC NAMESPACE "/" NAME
+#define DEVMAP_PATH_DEV NAMESPACE "/" NAME_DEV
+
+extern int debug_level;
+void dprintf(int, const char *, ...);
+void dprintf_inval_call(int, ipc_call_t, ipcarg_t);
+
+#endif
+/**
+ * @}
+ */
Index: pace/srv/hw/bus/usb/hcd/virtual/Makefile
===================================================================
--- uspace/srv/hw/bus/usb/hcd/virtual/Makefile	(revision 3f0a7971b0a7536c06012fdd2835873631dfa824)
+++ 	(revision )
@@ -1,44 +1,0 @@
-#
-# Copyright (c) 2010 Vojtech Horky
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# - Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# - Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the distribution.
-# - The name of the author may not be used to endorse or promote products
-#   derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-USPACE_PREFIX = ../../../../../..
-LIBS = $(LIBUSB_PREFIX)/libusb.a $(LIBUSBVIRT_PREFIX)/libusbvirt.a
-EXTRA_CFLAGS = -I$(LIB_PREFIX)
-BINARY = vhcd
-
-SOURCES = \
-	conndev.c \
-	connhost.c \
-	debug.c \
-	devices.c \
-	hc.c \
-	hcd.c \
-	hub.c \
-	hubops.c
-
-include $(USPACE_PREFIX)/Makefile.common
Index: pace/srv/hw/bus/usb/hcd/virtual/conn.h
===================================================================
--- uspace/srv/hw/bus/usb/hcd/virtual/conn.h	(revision 3f0a7971b0a7536c06012fdd2835873631dfa824)
+++ 	(revision )
@@ -1,48 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup usb
- * @{
- */
-/** @file
- * @brief Connection handling of incoming calls.
- */
-#ifndef VHCD_CONN_H_
-#define VHCD_CONN_H_
-
-#include <usb/hcd.h>
-#include "vhcd.h"
-#include "devices.h"
-
-void connection_handler_host(ipcarg_t);
-void connection_handler_device(ipcarg_t, virtdev_connection_t *);
-
-#endif
-/**
- * @}
- */
Index: pace/srv/hw/bus/usb/hcd/virtual/conndev.c
===================================================================
--- uspace/srv/hw/bus/usb/hcd/virtual/conndev.c	(revision 3f0a7971b0a7536c06012fdd2835873631dfa824)
+++ 	(revision )
@@ -1,122 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup usb
- * @{
- */
-/** @file
- * @brief Connection handling of calls from virtual device (implementation).
- */
-
-#include <assert.h>
-#include <errno.h>
-#include <usbvirt/hub.h>
-
-#include "conn.h"
-#include "hc.h"
-#include "hub.h"
-
-#define DEVICE_NAME_MAXLENGTH 32
-
-static int get_device_name(int phone, char *buffer, size_t len)
-{
-	ipc_call_t answer_data;
-	ipcarg_t answer_rc;
-	aid_t req;
-	int rc;
-	
-	req = async_send_0(phone,
-	    IPC_M_USBVIRT_GET_NAME,
-	    &answer_data);
-	
-	rc = async_data_read_start(phone, buffer, len);
-	if (rc != EOK) {
-		async_wait_for(req, NULL);
-		return EINVAL;
-	}
-	
-	async_wait_for(req, &answer_rc);
-	rc = (int)answer_rc;
-	
-	if (IPC_GET_ARG1(answer_data) < len) {
-		len = IPC_GET_ARG1(answer_data);
-	} else {
-		len--;
-	}
-	buffer[len] = 0;
-	
-	return rc;
-}
-
-/** Connection handler for communcation with virtual device.
- *
- * This function also takes care of proper phone hung-up.
- *
- * @param phone_hash Incoming phone hash.
- * @param dev Virtual device handle.
- */
-void connection_handler_device(ipcarg_t phone_hash, virtdev_connection_t *dev)
-{
-	assert(dev != NULL);
-	
-	char devname[DEVICE_NAME_MAXLENGTH + 1];
-	int rc = get_device_name(dev->phone, devname, DEVICE_NAME_MAXLENGTH);
-	
-	dprintf(0, "virtual device connected (phone: %#x, name: %s)",
-	    phone_hash, rc == EOK ? devname : "<unknown>");
-	
-	
-	while (true) {
-		ipc_callid_t callid; 
-		ipc_call_t call; 
-		
-		callid = async_get_call(&call);
-		
-		switch (IPC_GET_METHOD(call)) {
-			case IPC_M_PHONE_HUNGUP:
-				ipc_hangup(dev->phone);
-				ipc_answer_0(callid, EOK);
-				dprintf(0, "phone%#x: device hung-up",
-				    phone_hash);
-				return;
-			
-			case IPC_M_CONNECT_TO_ME:
-				ipc_answer_0(callid, ELIMIT);
-				break;
-			
-			default:
-				dprintf_inval_call(2, call, phone_hash);
-				ipc_answer_0(callid, EINVAL);
-				break;
-		}
-	}
-}
-
-/**
- * @}
- */
Index: pace/srv/hw/bus/usb/hcd/virtual/connhost.c
===================================================================
--- uspace/srv/hw/bus/usb/hcd/virtual/connhost.c	(revision 3f0a7971b0a7536c06012fdd2835873631dfa824)
+++ 	(revision )
@@ -1,268 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup usb
- * @{
- */
-/** @file
- * @brief Connection handling of calls from host (implementation).
- */
-#include <assert.h>
-#include <errno.h>
-#include <usb/hcd.h>
-
-#include "vhcd.h"
-#include "conn.h"
-#include "hc.h"
-
-typedef struct {
-	ipc_callid_t caller;
-	void *buffer;
-	size_t size;
-} async_transaction_t;
-
-static void async_out_callback(void * buffer, size_t len,
-    usb_transaction_outcome_t outcome, void * arg)
-{
-	async_transaction_t * trans = (async_transaction_t *)arg;
-	
-	dprintf(2, "async_out_callback(buffer, %u, %d, %p) -> %x",
-	    len, outcome, arg, trans->caller);
-	
-	// FIXME - answer according to outcome
-	ipc_answer_1(trans->caller, EOK, 0);
-	
-	free(trans);
-	if (buffer) {
-		free(buffer);
-	}
-	dprintf(4, "async_out_callback answered");
-}
-
-static void async_to_device(ipc_callid_t iid, ipc_call_t icall, bool setup_transaction)
-{
-	size_t expected_len = IPC_GET_ARG3(icall);
-	usb_target_t target = {
-		.address = IPC_GET_ARG1(icall),
-		.endpoint = IPC_GET_ARG2(icall)
-	};
-	
-	dprintf(1, "async_to_device: dev=%d:%d, size=%d, iid=%x",
-	    target.address, target.endpoint, expected_len, iid);
-	
-	size_t len = 0;
-	void * buffer = NULL;
-	if (expected_len > 0) {
-		int rc = async_data_write_accept(&buffer, false,
-		    1, USB_MAX_PAYLOAD_SIZE,
-		    0, &len);
-		
-		if (rc != EOK) {
-			ipc_answer_0(iid, rc);
-			return;
-		}
-	}
-	
-	async_transaction_t * trans = malloc(sizeof(async_transaction_t));
-	trans->caller = iid;
-	trans->buffer = NULL;
-	trans->size = 0;
-	
-	hc_add_transaction_to_device(setup_transaction, target,
-	    buffer, len,
-	    async_out_callback, trans);
-	
-	dprintf(2, "async transaction to device scheduled (%p)", trans);
-}
-
-static void async_in_callback(void * buffer, size_t len,
-    usb_transaction_outcome_t outcome, void * arg)
-{	
-	async_transaction_t * trans = (async_transaction_t *)arg;
-	
-	dprintf(2, "async_in_callback(buffer, %u, %d, %p) -> %x",
-	    len, outcome, arg, trans->caller);
-	
-	trans->buffer = buffer;
-	trans->size = len;
-	
-	ipc_callid_t caller = trans->caller;
-	
-	if (buffer == NULL) {
-		free(trans);
-		trans = NULL;
-	}
-	
-	
-	// FIXME - answer according to outcome
-	ipc_answer_1(caller, EOK, (ipcarg_t)trans);
-	dprintf(4, "async_in_callback answered (%#x)", (ipcarg_t)trans);
-}
-
-static void async_from_device(ipc_callid_t iid, ipc_call_t icall)
-{
-	usb_target_t target = {
-		.address = IPC_GET_ARG1(icall),
-		.endpoint = IPC_GET_ARG2(icall)
-	};
-	size_t len = IPC_GET_ARG3(icall);
-	
-	dprintf(1, "async_from_device: dev=%d:%d, size=%d, iid=%x",
-	    target.address, target.endpoint, len, iid);
-	
-	void * buffer = NULL;
-	if (len > 0) {
-		buffer = malloc(len);
-	}
-	
-	async_transaction_t * trans = malloc(sizeof(async_transaction_t));
-	trans->caller = iid;
-	trans->buffer = NULL;
-	trans->size = 0;
-	
-	hc_add_transaction_from_device(target,
-	    buffer, len,
-	    async_in_callback, trans);
-	
-	dprintf(2, "async transfer from device scheduled (%p)", trans);
-}
-
-static void async_get_buffer(ipc_callid_t iid, ipc_call_t icall)
-{
-	ipcarg_t buffer_hash = IPC_GET_ARG1(icall);
-	async_transaction_t * trans = (async_transaction_t *)buffer_hash;
-	if (trans == NULL) {
-		ipc_answer_0(iid, ENOENT);
-		return;
-	}
-	if (trans->buffer == NULL) {
-		ipc_answer_0(iid, EINVAL);
-		free(trans);
-		return;
-	}
-	
-	ipc_callid_t callid;
-	size_t accepted_size;
-	if (!async_data_read_receive(&callid, &accepted_size)) {
-		ipc_answer_0(iid, EINVAL);
-		return;
-	}
-	
-	if (accepted_size > trans->size) {
-		accepted_size = trans->size;
-	}
-	async_data_read_finalize(callid, trans->buffer, accepted_size);
-	
-	ipc_answer_1(iid, EOK, accepted_size);
-	
-	free(trans->buffer);
-	free(trans);
-}
-
-
-/** Connection handler for communcation with host.
- * By host is typically meant top-level USB driver.
- *
- * This function also takes care of proper phone hung-up.
- *
- * @param phone_hash Incoming phone hash.
- */
-void connection_handler_host(ipcarg_t phone_hash)
-{
-	dprintf(0, "host connected through phone %#x", phone_hash);
-	
-	
-	while (true) {
-		ipc_callid_t callid;
-		ipc_call_t call;
-		
-		callid = async_get_call(&call);
-		
-		dprintf(6, "host on %#x calls [%x: %u (%u, %u, %u, %u, %u)]",
-		    phone_hash,
-		    callid,
-		    IPC_GET_METHOD(call),
-		    IPC_GET_ARG1(call), IPC_GET_ARG2(call), IPC_GET_ARG3(call),
-		    IPC_GET_ARG4(call), IPC_GET_ARG5(call));
-		
-		switch (IPC_GET_METHOD(call)) {
-
-			/* standard IPC methods */
-
-			case IPC_M_PHONE_HUNGUP:
-				ipc_answer_0(callid, EOK);
-				dprintf(0, "phone%#x: host hung-up",
-				    phone_hash);
-				return;
-			
-			case IPC_M_CONNECT_TO_ME:
-				ipc_answer_0(callid, ELIMIT);
-				break;
-			
-
-			/* USB methods */
-
-			case IPC_M_USB_HCD_TRANSACTION_SIZE:
-				ipc_answer_1(callid, EOK, USB_MAX_PAYLOAD_SIZE);
-				break;
-			
-			case IPC_M_USB_HCD_GET_BUFFER_ASYNC:
-				async_get_buffer(callid, call);
-				break;
-	
-			case IPC_M_USB_HCD_INTERRUPT_OUT_ASYNC:
-			case IPC_M_USB_HCD_CONTROL_WRITE_DATA_ASYNC:
-			case IPC_M_USB_HCD_CONTROL_READ_STATUS_ASYNC:
-				async_to_device(callid, call, false);
-				break;
-			
-			case IPC_M_USB_HCD_CONTROL_WRITE_SETUP_ASYNC:
-			case IPC_M_USB_HCD_CONTROL_READ_SETUP_ASYNC:
-				async_to_device(callid, call, true);
-				break;
-			
-			case IPC_M_USB_HCD_INTERRUPT_IN_ASYNC:
-			case IPC_M_USB_HCD_CONTROL_WRITE_STATUS_ASYNC:
-			case IPC_M_USB_HCD_CONTROL_READ_DATA_ASYNC:
-				async_from_device(callid, call);
-				break;
-			
-
-			/* end of known methods */
-			
-			default:
-				dprintf_inval_call(2, call, phone_hash);
-				ipc_answer_0(callid, EINVAL);
-				break;
-		}
-	}
-}
-
-/**
- * @}
- */
Index: pace/srv/hw/bus/usb/hcd/virtual/debug.c
===================================================================
--- uspace/srv/hw/bus/usb/hcd/virtual/debug.c	(revision 3f0a7971b0a7536c06012fdd2835873631dfa824)
+++ 	(revision )
@@ -1,78 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup usb
- * @{
- */
-/** @file
- * @brief Debugging support.
- */
-#include <stdio.h>
-#include <ipc/ipc.h>
-
-#include "vhcd.h"
-
-/** Current debug level. */
-int debug_level = 0;
-
-/** Debugging printf.
- * This function is intended for single-line messages as it
- * automatically prints debugging prefix at the beginning of the
- * line.
- *
- * @see printf
- * @param level Debugging level.
- */
-void dprintf(int level, const char *format, ...)
-{
-	if (level > debug_level) {
-		return;
-	}
-	
-	printf("%s(%d): ", NAME, level);
-	va_list args;
-	va_start(args, format);
-	vprintf(format, args);
-	va_end(args);
-	printf("\n");
-}
-
-/** Debug print informing of invalid call.
- */
-void dprintf_inval_call(int level, ipc_call_t call, ipcarg_t phone_hash)
-{
-	dprintf(level, "phone%#x: invalid call [%u (%u, %u, %u, %u, %u)]",
-	    phone_hash,
-	    IPC_GET_METHOD(call),
-	    IPC_GET_ARG1(call), IPC_GET_ARG2(call), IPC_GET_ARG3(call),
-	    IPC_GET_ARG4(call), IPC_GET_ARG5(call));
-}
-
-/**
- * @}
- */
Index: pace/srv/hw/bus/usb/hcd/virtual/devices.c
===================================================================
--- uspace/srv/hw/bus/usb/hcd/virtual/devices.c	(revision 3f0a7971b0a7536c06012fdd2835873631dfa824)
+++ 	(revision )
@@ -1,186 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup usb
- * @{
- */
-/** @file
- * @brief Virtual device management (implementation).
- */
-
-#include <ipc/ipc.h>
-#include <adt/list.h>
-#include <bool.h>
-#include <async.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <errno.h>
-#include <str_error.h>
-
-#include <usbvirt/hub.h>
-
-#include "devices.h"
-#include "hub.h"
-#include "vhcd.h"
-
-#define list_foreach(pos, head) \
-	for (pos = (head)->next; pos != (head); \
-        	pos = pos->next)
-
-LIST_INITIALIZE(devices);
-
-/** Create virtual device.
- *
- * @param address USB address.
- * @param phone Callback phone.
- * @return New device.
- * @retval NULL Out of memory or address already occupied.
- */
-virtdev_connection_t *virtdev_add_device(int phone)
-{
-	virtdev_connection_t *dev = (virtdev_connection_t *)
-	    malloc(sizeof(virtdev_connection_t));
-	dev->phone = phone;
-	list_append(&dev->link, &devices);
-	
-	hub_add_device(dev);
-	
-	return dev;
-}
-
-/** Destroy virtual device.
- */
-void virtdev_destroy_device(virtdev_connection_t *dev)
-{
-	hub_remove_device(dev);
-	list_remove(&dev->link);
-	free(dev);
-}
-
-/** Send data to all connected devices.
- *
- * @param transaction Transaction to be sent over the bus.
- */
-usb_transaction_outcome_t virtdev_send_to_all(transaction_t *transaction)
-{
-	link_t *pos;
-	list_foreach(pos, &devices) {
-		virtdev_connection_t *dev
-		    = list_get_instance(pos, virtdev_connection_t, link);
-		
-		if (!hub_can_device_signal(dev)) {
-			continue;
-		}
-		
-		ipc_call_t answer_data;
-		ipcarg_t answer_rc;
-		aid_t req;
-		int rc = EOK;
-		int method = IPC_M_USBVIRT_TRANSACTION_SETUP;
-		
-		switch (transaction->type) {
-			case USBVIRT_TRANSACTION_SETUP:
-				method = IPC_M_USBVIRT_TRANSACTION_SETUP;
-				break;
-			case USBVIRT_TRANSACTION_IN:
-				method = IPC_M_USBVIRT_TRANSACTION_IN;
-				break;
-			case USBVIRT_TRANSACTION_OUT:
-				method = IPC_M_USBVIRT_TRANSACTION_OUT;
-				break;
-		}
-		
-		req = async_send_3(dev->phone,
-		    method,
-		    transaction->target.address,
-		    transaction->target.endpoint,
-		    transaction->len,
-		    &answer_data);
-		
-		if (transaction->len > 0) {
-			if (transaction->type == USBVIRT_TRANSACTION_IN) {
-				rc = async_data_read_start(dev->phone,
-				    transaction->buffer, transaction->len);
-			} else {
-				rc = async_data_write_start(dev->phone,
-				    transaction->buffer, transaction->len);
-			}
-		}
-		
-		if (rc != EOK) {
-			async_wait_for(req, NULL);
-		} else {
-			async_wait_for(req, &answer_rc);
-			rc = (int)answer_rc;
-		}
-	}
-	
-	/*
-	 * Send the data to the virtual hub as well
-	 * (if the address matches).
-	 */
-	if (virthub_dev.address == transaction->target.address) {
-		size_t tmp;
-		dprintf(3, "sending `%s' transaction to hub",
-		    usbvirt_str_transaction_type(transaction->type));
-		switch (transaction->type) {
-			case USBVIRT_TRANSACTION_SETUP:
-				virthub_dev.transaction_setup(&virthub_dev,
-				    transaction->target.endpoint,
-				    transaction->buffer, transaction->len);
-				break;
-				
-			case USBVIRT_TRANSACTION_IN:
-				virthub_dev.transaction_in(&virthub_dev,
-				    transaction->target.endpoint,
-				    transaction->buffer, transaction->len,
-				    &tmp);
-				if (tmp < transaction->len) {
-					transaction->len = tmp;
-				}
-				break;
-				
-			case USBVIRT_TRANSACTION_OUT:
-				virthub_dev.transaction_out(&virthub_dev,
-				    transaction->target.endpoint,
-				    transaction->buffer, transaction->len);
-				break;
-		}
-		dprintf(4, "transaction on hub processed...");
-	}
-	
-	/*
-	 * TODO: maybe screw some transactions to get more
-	 * real-life image.
-	 */
-	return USB_OUTCOME_OK;
-}
-
-/**
- * @}
- */
Index: pace/srv/hw/bus/usb/hcd/virtual/devices.h
===================================================================
--- uspace/srv/hw/bus/usb/hcd/virtual/devices.h	(revision 3f0a7971b0a7536c06012fdd2835873631dfa824)
+++ 	(revision )
@@ -1,58 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup usb
- * @{
- */ 
-/** @file
- * @brief Virtual device management.
- */
-#ifndef VHCD_DEVICES_H_
-#define VHCD_DEVICES_H_
-
-#include <adt/list.h>
-#include <usb/hcd.h>
-
-#include "hc.h"
-
-/** Connected virtual device. */
-typedef struct {
-	/** Phone used when sending data to device. */
-	int phone;
-	/** Linked-list handle. */
-	link_t link;
-} virtdev_connection_t;
-
-virtdev_connection_t *virtdev_add_device(int);
-void virtdev_destroy_device(virtdev_connection_t *);
-usb_transaction_outcome_t virtdev_send_to_all(transaction_t *);
-
-#endif
-/**
- * @}
- */
Index: pace/srv/hw/bus/usb/hcd/virtual/hc.c
===================================================================
--- uspace/srv/hw/bus/usb/hcd/virtual/hc.c	(revision 3f0a7971b0a7536c06012fdd2835873631dfa824)
+++ 	(revision )
@@ -1,186 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup usb
- * @{
- */
-/** @file
- * @brief Virtual HC (implementation).
- */
-
-#include <ipc/ipc.h>
-#include <adt/list.h>
-#include <bool.h>
-#include <async.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <errno.h>
-#include <str_error.h>
-
-#include <usbvirt/hub.h>
-
-#include "vhcd.h"
-#include "hc.h"
-#include "devices.h"
-#include "hub.h"
-
-#define USLEEP_BASE (500 * 1000)
-
-#define USLEEP_VAR 5000
-
-#define SHORTENING_VAR 15
-
-#define PROB_OUTCOME_BABBLE 5
-#define PROB_OUTCOME_CRCERROR 7
-
-#define PROB_TEST(var, new_value, prob, number) \
-	do { \
-		if (((number) % (prob)) == 0) { \
-			var = (new_value); \
-		} \
-	} while (0)
-
-static link_t transaction_list;
-
-#define TRANSACTION_FORMAT "T[%d:%d %s (%d)]"
-#define TRANSACTION_PRINTF(t) \
-	(t).target.address, (t).target.endpoint, \
-	usbvirt_str_transaction_type((t).type), \
-	(int)(t).len
-
-#define transaction_get_instance(lnk) \
-	list_get_instance(lnk, transaction_t, link)
-
-static inline unsigned int pseudo_random(unsigned int *seed)
-{
-	*seed = ((*seed) * 873511) % 22348977 + 7;
-	return ((*seed) >> 8);
-}
-
-/** Call transaction callback.
- * Calling this callback informs the backend that transaction was processed.
- */
-static void process_transaction_with_outcome(transaction_t * transaction,
-    usb_transaction_outcome_t outcome)
-{
-	dprintf(3, "processing transaction " TRANSACTION_FORMAT ", outcome: %s",
-	    TRANSACTION_PRINTF(*transaction),
-	    usb_str_transaction_outcome(outcome));
-	
-	transaction->callback(transaction->buffer, transaction->len, outcome,
-	    transaction->callback_arg);
-}
-
-/** Host controller manager main function.
- */
-void hc_manager(void)
-{
-	list_initialize(&transaction_list);
-	
-	static unsigned int seed = 4573;
-	
-	printf("%s: transaction processor ready.\n", NAME);
-	
-	while (true) {
-		async_usleep(USLEEP_BASE + (pseudo_random(&seed) % USLEEP_VAR));
-		
-		if (list_empty(&transaction_list)) {
-			continue;
-		}
-		
-		char ports[HUB_PORT_COUNT + 2];
-		hub_get_port_statuses(ports, HUB_PORT_COUNT + 1);
-		dprintf(3, "virtual hub: addr=%d ports=%s",
-		    virthub_dev.address, ports);
-		
-		link_t *first_transaction_link = transaction_list.next;
-		transaction_t *transaction
-		    = transaction_get_instance(first_transaction_link);
-		list_remove(first_transaction_link);
-		
-		dprintf(3, "processing transaction " TRANSACTION_FORMAT "",
-		    TRANSACTION_PRINTF(*transaction));
-		
-		usb_transaction_outcome_t outcome;
-		outcome = virtdev_send_to_all(transaction);
-		
-		process_transaction_with_outcome(transaction, outcome);
-		
-		free(transaction);
-	}
-}
-
-/** Create new transaction
- */
-static transaction_t *transaction_create(usbvirt_transaction_type_t type,
-    usb_target_t target,
-    void * buffer, size_t len,
-    hc_transaction_done_callback_t callback, void * arg)
-{
-	transaction_t * transaction = malloc(sizeof(transaction_t));
-	
-	list_initialize(&transaction->link);
-	transaction->type = type;
-	transaction->target = target;
-	transaction->buffer = buffer;
-	transaction->len = len;
-	transaction->callback = callback;
-	transaction->callback_arg = arg;
-	
-	dprintf(1, "creating transaction " TRANSACTION_FORMAT,
-	    TRANSACTION_PRINTF(*transaction));
-	
-	return transaction;
-}
-
-/** Add transaction directioned towards the device.
- */
-void hc_add_transaction_to_device(bool setup, usb_target_t target,
-    void * buffer, size_t len,
-    hc_transaction_done_callback_t callback, void * arg)
-{
-	transaction_t *transaction = transaction_create(
-	    setup ? USBVIRT_TRANSACTION_SETUP : USBVIRT_TRANSACTION_OUT, target,
-	    buffer, len, callback, arg);
-	list_append(&transaction->link, &transaction_list);
-}
-
-/** Add transaction directioned from the device.
- */
-void hc_add_transaction_from_device(usb_target_t target,
-    void * buffer, size_t len,
-    hc_transaction_done_callback_t callback, void * arg)
-{
-	transaction_t *transaction = transaction_create(USBVIRT_TRANSACTION_IN,
-	    target, buffer, len, callback, arg);
-	list_append(&transaction->link, &transaction_list);
-}
-
-/**
- * @}
- */
Index: pace/srv/hw/bus/usb/hcd/virtual/hc.h
===================================================================
--- uspace/srv/hw/bus/usb/hcd/virtual/hc.h	(revision 3f0a7971b0a7536c06012fdd2835873631dfa824)
+++ 	(revision )
@@ -1,87 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup usb
- * @{
- */
-/** @file
- * @brief Virtual HC.
- */
-#ifndef VHCD_HC_H_
-#define VHCD_HC_H_
-
-#include <usb/hcd.h>
-#include <usbvirt/hub.h>
-
-/** Callback after transaction is sent to USB.
- *
- * @param buffer Transaction data buffer.
- * @param size Transaction data size.
- * @param outcome Transaction outcome.
- * @param arg Custom argument.
- */
-typedef void (*hc_transaction_done_callback_t)(void *buffer, size_t size,
-    usb_transaction_outcome_t outcome, void *arg);
-
-/** Pending transaction details. */
-typedef struct {
-	/** Linked-list link. */
-	link_t link;
-	/** Transaction type. */
-	usbvirt_transaction_type_t type;
-	/** Device address. */
-	usb_target_t target;
-	/** Direction of the transaction. */
-	usb_direction_t direction;
-	/** Transaction data buffer. */
-	void * buffer;
-	/** Transaction data length. */
-	size_t len;
-	/** Callback after transaction is done. */
-	hc_transaction_done_callback_t callback;
-	/** Argument to the callback. */
-	void * callback_arg;
-} transaction_t;
-
-void hc_manager(void);
-
-void hc_add_transaction_to_device(bool setup, usb_target_t target,
-    void * buffer, size_t len,
-    hc_transaction_done_callback_t callback, void * arg);
-
-void hc_add_transaction_from_device(usb_target_t target,
-    void * buffer, size_t len,
-    hc_transaction_done_callback_t callback, void * arg);
-
-int hc_fillin_transaction_from_device(usb_target_t target,
-    void * buffer, size_t len);
-
-#endif
-/**
- * @}
- */
Index: pace/srv/hw/bus/usb/hcd/virtual/hcd.c
===================================================================
--- uspace/srv/hw/bus/usb/hcd/virtual/hcd.c	(revision 3f0a7971b0a7536c06012fdd2835873631dfa824)
+++ 	(revision )
@@ -1,172 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup usb
- * @{
- */ 
-/** @file
- * @brief Virtual host controller driver.
- */
-
-#include <devmap.h>
-#include <ipc/ipc.h>
-#include <async.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <sysinfo.h>
-#include <stdio.h>
-#include <errno.h>
-#include <str_error.h>
-
-#include <usb/hcd.h>
-#include "vhcd.h"
-#include "hc.h"
-#include "devices.h"
-#include "hub.h"
-#include "conn.h"
-
-
-static devmap_handle_t handle_virtual_device;
-static devmap_handle_t handle_host_driver;
-
-static void client_connection(ipc_callid_t iid, ipc_call_t *icall)
-{
-	ipcarg_t phone_hash = icall->in_phone_hash;
-	devmap_handle_t handle = (devmap_handle_t)IPC_GET_ARG1(*icall);
-	
-	if (handle == handle_host_driver) {
-		/*
-		 * We can connect host controller driver immediately.
-		 */
-		ipc_answer_0(iid, EOK);
-		connection_handler_host(phone_hash);
-	} else if (handle == handle_virtual_device) {
-		ipc_answer_0(iid, EOK);
-
-		while (true) {
-			/*
-			 * We need to wait for callback request to allow
-			 * connection of virtual device.
-			 */
-			ipc_callid_t callid;
-			ipc_call_t call;
-
-			callid = async_get_call(&call);
-
-			/*
-			 * We can do nothing until we have the callback phone.
-			 * Thus, we will wait for the callback and start processing
-			 * after that.
-			 */
-			int method = (int) IPC_GET_METHOD(call);
-
-			if (method == IPC_M_PHONE_HUNGUP) {
-				ipc_answer_0(callid, EOK);
-				return;
-			}
-
-			if (method == IPC_M_CONNECT_TO_ME) {
-				int callback = IPC_GET_ARG5(call);
-				virtdev_connection_t *dev
-				    = virtdev_add_device(callback);
-				if (!dev) {
-					ipc_answer_0(callid, EEXISTS);
-					ipc_hangup(callback);
-					return;
-				}
-				ipc_answer_0(callid, EOK);
-				connection_handler_device(phone_hash, dev);
-				virtdev_destroy_device(dev);
-				return;
-			}
-
-			/*
-			 * No other methods could be served now.
-			 */
-			dprintf_inval_call(1, call, phone_hash);
-			ipc_answer_0(callid, ENOTSUP);
-		}
-	} else {
-		/*
-		 * Hmmm, someone else just tried to connect to us.
-		 * Kick him out ;-).
-		 */
-		ipc_answer_0(iid, ENOTSUP);
-		return;
-	}
-}
-
-int main(int argc, char * argv[])
-{	
-	printf("%s: virtual USB host controller driver.\n", NAME);
-	
-	int i;
-	for (i = 1; i < argc; i++) {
-		if (str_cmp(argv[i], "-d") == 0) {
-			debug_level++;
-		}
-	}
-	
-	int rc;
-	
-	rc = devmap_driver_register(NAME, client_connection); 
-	if (rc != EOK) {
-		printf("%s: unable to register driver (%s).\n",
-		    NAME, str_error(rc));
-		return 1;
-	}
-
-	rc = devmap_device_register(DEVMAP_PATH_HC, &handle_host_driver);
-	if (rc != EOK) {
-		printf("%s: unable to register device %s (%s).\n",
-		    NAME, DEVMAP_PATH_HC, str_error(rc));
-		return 1;
-	}
-	
-	rc = devmap_device_register(DEVMAP_PATH_DEV, &handle_virtual_device);
-	if (rc != EOK) {
-		printf("%s: unable to register device %s (%s).\n",
-		    NAME, DEVMAP_PATH_DEV, str_error(rc));
-		return 1;
-	}
-
-	hub_init();
-	
-	printf("%s: accepting connections [debug=%d]\n", NAME, debug_level);
-	printf("%s:  -> host controller at %s\n", NAME, DEVMAP_PATH_HC);
-	printf("%s:  -> virtual hub at %s\n", NAME, DEVMAP_PATH_DEV);
-
-	hc_manager();
-	
-	return 0;
-}
-
-
-/**
- * @}
- */
Index: pace/srv/hw/bus/usb/hcd/virtual/hub.c
===================================================================
--- uspace/srv/hw/bus/usb/hcd/virtual/hub.c	(revision 3f0a7971b0a7536c06012fdd2835873631dfa824)
+++ 	(revision )
@@ -1,256 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup usb
- * @{
- */
-/** @file
- * @brief Virtual USB hub.
- */
-#include <usb/classes.h>
-#include <usbvirt/hub.h>
-#include <usbvirt/device.h>
-#include <errno.h>
-#include <stdlib.h>
-
-#include "vhcd.h"
-#include "hub.h"
-#include "hubintern.h"
-
-
-/** Standard device descriptor. */
-usb_standard_device_descriptor_t std_device_descriptor = {
-	.length = sizeof(usb_standard_device_descriptor_t),
-	.descriptor_type = USB_DESCTYPE_DEVICE,
-	.usb_spec_version = 0x110,
-	.device_class = USB_CLASS_HUB,
-	.device_subclass = 0,
-	.device_protocol = 0,
-	.max_packet_size = 64,
-	.configuration_count = 1
-};
-
-/** Standard interface descriptor. */
-usb_standard_interface_descriptor_t std_interface_descriptor = {
-	.length = sizeof(usb_standard_interface_descriptor_t),
-	.descriptor_type = USB_DESCTYPE_INTERFACE,
-	.interface_number = 0,
-	.alternate_setting = 0,
-	.endpoint_count = 1,
-	.interface_class = USB_CLASS_HUB,
-	.interface_subclass = 0,
-	.interface_protocol = 0,
-	.str_interface = 0
-};
-
-hub_descriptor_t hub_descriptor = {
-	.length = sizeof(hub_descriptor_t),
-	.type = USB_DESCTYPE_HUB,
-	.port_count = HUB_PORT_COUNT,
-	.characteristics = 0, 
-	.power_on_warm_up = 50, /* Huh? */
-	.max_current = 100, /* Huh again. */
-	.removable_device = { 0 },
-	.port_power = { 0xFF }
-};
-
-/** Endpoint descriptor. */
-usb_standard_endpoint_descriptor_t endpoint_descriptor = {
-	.length = sizeof(usb_standard_endpoint_descriptor_t),
-	.descriptor_type = USB_DESCTYPE_ENDPOINT,
-	.endpoint_address = HUB_STATUS_CHANGE_PIPE | 128,
-	.attributes = USB_TRANSFER_INTERRUPT,
-	.max_packet_size = 8,
-	.poll_interval = 0xFF
-};
-
-/** Standard configuration descriptor. */
-usb_standard_configuration_descriptor_t std_configuration_descriptor = {
-	.length = sizeof(usb_standard_configuration_descriptor_t),
-	.descriptor_type = USB_DESCTYPE_CONFIGURATION,
-	.total_length = 
-		sizeof(usb_standard_configuration_descriptor_t)
-		+ sizeof(std_interface_descriptor)
-		+ sizeof(hub_descriptor)
-		+ sizeof(endpoint_descriptor)
-		,
-	.interface_count = 1,
-	.configuration_number = HUB_CONFIGURATION_ID,
-	.str_configuration = 0,
-	.attributes = 128, /* denotes bus-powered device */
-	.max_power = 50
-};
-
-/** All hub configuration descriptors. */
-static usbvirt_device_configuration_extras_t extra_descriptors[] = {
-	{
-		.data = (uint8_t *) &std_interface_descriptor,
-		.length = sizeof(std_interface_descriptor)
-	},
-	{
-		.data = (uint8_t *) &hub_descriptor,
-		.length = sizeof(hub_descriptor)
-	},
-	{
-		.data = (uint8_t *) &endpoint_descriptor,
-		.length = sizeof(endpoint_descriptor)
-	}
-};
-
-/** Hub configuration. */
-usbvirt_device_configuration_t configuration = {
-	.descriptor = &std_configuration_descriptor,
-	.extra = extra_descriptors,
-	.extra_count = sizeof(extra_descriptors)/sizeof(extra_descriptors[0])
-};
-
-/** Hub standard descriptors. */
-usbvirt_descriptors_t descriptors = {
-	.device = &std_device_descriptor,
-	.configuration = &configuration,
-	.configuration_count = 1,
-};
-
-/** Hub as a virtual device. */
-usbvirt_device_t virthub_dev = {
-	.ops = &hub_ops,
-	.descriptors = &descriptors,
-	.lib_debug_level = 4,
-	.lib_debug_enabled_tags = USBVIRT_DEBUGTAG_ALL
-};
-
-/** Hub device. */
-hub_device_t hub_dev;
-
-/** Initialize virtual hub. */
-void hub_init(void)
-{
-	size_t i;
-	for (i = 0; i < HUB_PORT_COUNT; i++) {
-		hub_port_t *port = &hub_dev.ports[i];
-		
-		port->device = NULL;
-		port->state = HUB_PORT_STATE_NOT_CONFIGURED;
-		port->status_change = 0;
-	}
-	
-	usbvirt_connect_local(&virthub_dev);
-	
-	dprintf(1, "virtual hub (%d ports) created", HUB_PORT_COUNT);
-}
-
-/** Connect device to the hub.
- *
- * @param device Device to be connected.
- * @return Port where the device was connected to.
- */
-size_t hub_add_device(virtdev_connection_t *device)
-{
-	size_t i;
-	for (i = 0; i < HUB_PORT_COUNT; i++) {
-		hub_port_t *port = &hub_dev.ports[i];
-		
-		if (port->device != NULL) {
-			continue;
-		}
-		
-		port->device = device;
-		
-		/*
-		 * TODO:
-		 * If the hub was configured, we can normally
-		 * announce the plug-in.
-		 * Otherwise, we will wait until hub is configured
-		 * and announce changes in single burst.
-		 */
-		//if (port->state == HUB_PORT_STATE_DISCONNECTED) {
-			port->state = HUB_PORT_STATE_DISABLED;
-			set_port_status_change(port, HUB_STATUS_C_PORT_CONNECTION);
-		//}
-		
-		return i;
-	}
-	
-	return (size_t)-1;
-}
-
-/** Disconnect device from the hub. */
-void hub_remove_device(virtdev_connection_t *device)
-{
-	size_t i;
-	for (i = 0; i < HUB_PORT_COUNT; i++) {
-		hub_port_t *port = &hub_dev.ports[i];
-		
-		if (port->device != device) {
-			continue;
-		}
-		
-		port->device = NULL;
-		port->state = HUB_PORT_STATE_DISCONNECTED;
-		
-		set_port_status_change(port, HUB_STATUS_C_PORT_CONNECTION);
-	}
-}
-
-/** Tell whether device port is open.
- *
- * @return Whether communication to and from the device can go through the hub.
- */
-bool hub_can_device_signal(virtdev_connection_t * device)
-{
-	size_t i;
-	for (i = 0; i < HUB_PORT_COUNT; i++) {
-		if (hub_dev.ports[i].device == device) {
-			return hub_dev.ports[i].state == HUB_PORT_STATE_ENABLED;
-		}
-	}
-	
-	return false;
-}
-
-/** Format hub port status.
- *
- * @param result Buffer where to store status string.
- * @param len Number of characters that is possible to store in @p result
- * 	(excluding trailing zero).
- */
-void hub_get_port_statuses(char *result, size_t len)
-{
-	if (len > HUB_PORT_COUNT) {
-		len = HUB_PORT_COUNT;
-	}
-	size_t i;
-	for (i = 0; i < len; i++) {
-		result[i] = hub_port_state_as_char(hub_dev.ports[i].state);
-	}
-	result[len] = 0;
-}
-
-/**
- * @}
- */
Index: pace/srv/hw/bus/usb/hcd/virtual/hub.h
===================================================================
--- uspace/srv/hw/bus/usb/hcd/virtual/hub.h	(revision 3f0a7971b0a7536c06012fdd2835873631dfa824)
+++ 	(revision )
@@ -1,58 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup usb
- * @{
- */
-/** @file
- * @brief Virtual USB hub.
- */
-#ifndef VHCD_HUB_H_
-#define VHCD_HUB_H_
-
-#include <usbvirt/device.h>
-
-#include "devices.h"
-
-#define HUB_PORT_COUNT 6
-
-#define BITS2BYTES(bits) \
-    (bits ? ((((bits)-1)>>3)+1) : 0)
-
-extern usbvirt_device_t virthub_dev;
-
-void hub_init(void);
-size_t hub_add_device(virtdev_connection_t *);
-void hub_remove_device(virtdev_connection_t *);
-bool hub_can_device_signal(virtdev_connection_t *);
-void hub_get_port_statuses(char *result, size_t len);
-
-#endif
-/**
- * @}
- */
Index: pace/srv/hw/bus/usb/hcd/virtual/hubintern.h
===================================================================
--- uspace/srv/hw/bus/usb/hcd/virtual/hubintern.h	(revision 3f0a7971b0a7536c06012fdd2835873631dfa824)
+++ 	(revision )
@@ -1,145 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup usb
- * @{
- */
-/** @file
- * @brief
- */
-#ifndef VHCD_HUBINTERN_H_
-#define VHCD_HUBINTERN_H_
-
-#include "hub.h"
-
-/** Endpoint number for status change pipe. */
-#define HUB_STATUS_CHANGE_PIPE 1
-/** Configuration value for hub configuration. */
-#define HUB_CONFIGURATION_ID 1
-
-/** Hub descriptor.
- */
-typedef struct {
-	/** Size of this descriptor in bytes. */
-	uint8_t length;
-	/** Descriptor type (USB_DESCTYPE_HUB). */
-	uint8_t type;
-	/** Number of downstream ports. */
-	uint8_t port_count;
-	/** Hub characteristics. */
-	uint16_t characteristics;
-	/** Time from power-on to stabilized current.
-	 * Expressed in 2ms unit.
-	 */
-	uint8_t power_on_warm_up;
-	/** Maximum current (in mA). */
-	uint8_t max_current;
-	/** Whether device at given port is removable. */
-	uint8_t removable_device[BITS2BYTES(HUB_PORT_COUNT+1)];
-	/** Port power control.
-	 * This is USB1.0 compatibility field, all bits must be 1.
-	 */
-	uint8_t port_power[BITS2BYTES(HUB_PORT_COUNT+1)];
-} __attribute__ ((packed)) hub_descriptor_t;
-
-/** Hub port internal state.
- * Some states (e.g. port over current) are not covered as they are not
- * simulated at all.
- */
-typedef enum {
-	HUB_PORT_STATE_NOT_CONFIGURED,
-	HUB_PORT_STATE_POWERED_OFF,
-	HUB_PORT_STATE_DISCONNECTED,
-	HUB_PORT_STATE_DISABLED,
-	HUB_PORT_STATE_RESETTING,
-	HUB_PORT_STATE_ENABLED,
-	HUB_PORT_STATE_SUSPENDED,
-	HUB_PORT_STATE_RESUMING,
-	/* HUB_PORT_STATE_, */
-} hub_port_state_t;
-
-/** Convert hub port state to a char. */
-static inline char hub_port_state_as_char(hub_port_state_t state) {
-	switch (state) {
-		case HUB_PORT_STATE_NOT_CONFIGURED:
-			return '-';
-		case HUB_PORT_STATE_POWERED_OFF:
-			return 'O';
-		case HUB_PORT_STATE_DISCONNECTED:
-			return 'X';
-		case HUB_PORT_STATE_DISABLED:
-			return 'D';
-		case HUB_PORT_STATE_RESETTING:
-			return 'R';
-		case HUB_PORT_STATE_ENABLED:
-			return 'E';
-		case HUB_PORT_STATE_SUSPENDED:
-			return 'S';
-		case HUB_PORT_STATE_RESUMING:
-			return 'F';
-		default:
-			return '?';
-	}
-}
-
-/** Hub status change mask bits. */
-typedef enum {
-	HUB_STATUS_C_PORT_CONNECTION = (1 << 0),
-	HUB_STATUS_C_PORT_ENABLE = (1 << 1),
-	HUB_STATUS_C_PORT_SUSPEND = (1 << 2),
-	HUB_STATUS_C_PORT_OVER_CURRENT = (1 << 3),
-	HUB_STATUS_C_PORT_RESET = (1 << 4),
-	/* HUB_STATUS_C_ = (1 << ), */
-} hub_status_change_t;
-
-/** Hub port information. */
-typedef struct {
-	virtdev_connection_t *device;
-	hub_port_state_t state;
-	uint16_t status_change;
-} hub_port_t;
-
-/** Hub device type. */
-typedef struct {
-	hub_port_t ports[HUB_PORT_COUNT];
-} hub_device_t;
-
-extern hub_device_t hub_dev;
-
-extern hub_descriptor_t hub_descriptor;
-
-extern usbvirt_device_ops_t hub_ops;
-
-void clear_port_status_change(hub_port_t *, uint16_t);
-void set_port_status_change(hub_port_t *, uint16_t);
-
-
-#endif
-/**
- * @}
- */
Index: pace/srv/hw/bus/usb/hcd/virtual/hubops.c
===================================================================
--- uspace/srv/hw/bus/usb/hcd/virtual/hubops.c	(revision 3f0a7971b0a7536c06012fdd2835873631dfa824)
+++ 	(revision )
@@ -1,384 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup usb
- * @{
- */
-/** @file
- * @brief Virtual USB hub operations.
- */
-#include <usb/classes.h>
-#include <usb/hub.h>
-#include <usbvirt/hub.h>
-#include <usbvirt/device.h>
-#include <errno.h>
-
-#include "vhcd.h"
-#include "hub.h"
-#include "hubintern.h"
-
-/** Produce a byte from bit values.
- */
-#define MAKE_BYTE(b0, b1, b2, b3, b4, b5, b6, b7) \
-	(( \
-		((b0) << 0) \
-		| ((b1) << 1) \
-		| ((b2) << 2) \
-		| ((b3) << 3) \
-		| ((b4) << 4) \
-		| ((b5) << 5) \
-		| ((b6) << 6) \
-		| ((b7) << 7) \
-	))
-
-static int on_get_descriptor(struct usbvirt_device *dev,
-    usb_device_request_setup_packet_t *request, uint8_t *data);
-static int on_class_request(struct usbvirt_device *dev,
-    usb_device_request_setup_packet_t *request, uint8_t *data);
-static int on_data_request(struct usbvirt_device *dev,
-    usb_endpoint_t endpoint,
-    void *buffer, size_t size, size_t *actual_size);
-
-/** Standard USB requests. */
-static usbvirt_standard_device_request_ops_t standard_request_ops = {
-	.on_get_status = NULL,
-	.on_clear_feature = NULL,
-	.on_set_feature = NULL,
-	.on_set_address = NULL,
-	.on_get_descriptor = on_get_descriptor,
-	.on_set_descriptor = NULL,
-	.on_get_configuration = NULL,
-	.on_set_configuration = NULL,
-	.on_get_interface = NULL,
-	.on_set_interface = NULL,
-	.on_synch_frame = NULL
-};
-
-/** Hub operations. */
-usbvirt_device_ops_t hub_ops = {
-	.standard_request_ops = &standard_request_ops,
-	.on_class_device_request = on_class_request,
-	.on_data = NULL,
-	.on_data_request = on_data_request
-};
-
-/** Callback for GET_DESCRIPTOR request. */
-static int on_get_descriptor(struct usbvirt_device *dev,
-    usb_device_request_setup_packet_t *request, uint8_t *data)
-{
-	if (request->value_high == USB_DESCTYPE_HUB) {
-		int rc = dev->control_transfer_reply(dev, 0,
-		    &hub_descriptor, hub_descriptor.length);
-		
-		return rc;
-	}
-	/* Let the framework handle all the rest. */
-	return EFORWARD;
-}
-
-/** Change port status and updates status change status fields.
- */
-static void set_port_state(hub_port_t *port, hub_port_state_t state)
-{
-	port->state = state;
-	if (state == HUB_PORT_STATE_POWERED_OFF) {
-		clear_port_status_change(port, HUB_STATUS_C_PORT_CONNECTION);
-		clear_port_status_change(port, HUB_STATUS_C_PORT_ENABLE);
-		clear_port_status_change(port, HUB_STATUS_C_PORT_RESET);
-	}
-	if (state == HUB_PORT_STATE_RESUMING) {
-		async_usleep(10*1000);
-		if (port->state == state) {
-			set_port_state(port, HUB_PORT_STATE_ENABLED);
-		}
-	}
-	if (state == HUB_PORT_STATE_RESETTING) {
-		async_usleep(10*1000);
-		if (port->state == state) {
-			set_port_status_change(port, HUB_STATUS_C_PORT_RESET);
-			set_port_state(port, HUB_PORT_STATE_ENABLED);
-		}
-	}
-}
-
-/** Get access to a port or return with EINVAL. */
-#define _GET_PORT(portvar, index) \
-	do { \
-		if (virthub_dev.state != USBVIRT_STATE_CONFIGURED) { \
-			return EINVAL; \
-		} \
-		if (((index) == 0) || ((index) > HUB_PORT_COUNT)) { \
-			return EINVAL; \
-		} \
-	} while (false); \
-	hub_port_t *portvar = &hub_dev.ports[index]
-
-
-static int clear_hub_feature(uint16_t feature)
-{
-	return ENOTSUP;
-}
-
-static int clear_port_feature(uint16_t feature, uint16_t portindex)
-{	
-	_GET_PORT(port, portindex);
-	
-	switch (feature) {
-		case USB_HUB_FEATURE_PORT_ENABLE:
-			if ((port->state != HUB_PORT_STATE_NOT_CONFIGURED)
-			    && (port->state != HUB_PORT_STATE_POWERED_OFF)) {
-				set_port_state(port, HUB_PORT_STATE_DISABLED);
-			}
-			return EOK;
-		
-		case USB_HUB_FEATURE_PORT_SUSPEND:
-			if (port->state != HUB_PORT_STATE_SUSPENDED) {
-				return EOK;
-			}
-			set_port_state(port, HUB_PORT_STATE_RESUMING);
-			return EOK;
-			
-		case USB_HUB_FEATURE_PORT_POWER:
-			if (port->state != HUB_PORT_STATE_NOT_CONFIGURED) {
-				set_port_state(port, HUB_PORT_STATE_POWERED_OFF);
-			}
-			return EOK;
-		
-		case USB_HUB_FEATURE_C_PORT_CONNECTION:
-			clear_port_status_change(port, HUB_STATUS_C_PORT_CONNECTION);
-			return EOK;
-		
-		case USB_HUB_FEATURE_C_PORT_ENABLE:
-			clear_port_status_change(port, HUB_STATUS_C_PORT_ENABLE);
-			return EOK;
-		
-		case USB_HUB_FEATURE_C_PORT_SUSPEND:
-			clear_port_status_change(port, HUB_STATUS_C_PORT_SUSPEND);
-			return EOK;
-			
-		case USB_HUB_FEATURE_C_PORT_OVER_CURRENT:
-			clear_port_status_change(port, HUB_STATUS_C_PORT_OVER_CURRENT);
-			return EOK;
-	}
-	
-	return ENOTSUP;
-}
-
-static int get_bus_state(uint16_t portindex)
-{
-	return ENOTSUP;
-}
-
-static int get_hub_descriptor(uint8_t descriptor_type,
-    uint8_t descriptor_index, uint16_t length)
-{
-	return ENOTSUP;
-}
-
-static int get_hub_status(void)
-{
-	uint32_t hub_status = 0;
-	
-	return virthub_dev.control_transfer_reply(&virthub_dev, 0,
-	    &hub_status, 4);
-}
-
-static int get_port_status(uint16_t portindex)
-{
-	_GET_PORT(port, portindex);
-	
-	uint32_t status;
-	status = MAKE_BYTE(
-	    /* Current connect status. */
-	    port->device == NULL ? 0 : 1,
-	    /* Port enabled/disabled. */
-	    port->state == HUB_PORT_STATE_ENABLED ? 1 : 0,
-	    /* Suspend. */
-	    (port->state == HUB_PORT_STATE_SUSPENDED)
-	        || (port->state == HUB_PORT_STATE_RESUMING) ? 1 : 0,
-	    /* Over-current. */
-	    0,
-	    /* Reset. */
-	    port->state == HUB_PORT_STATE_RESETTING ? 1 : 0,
-	    /* Reserved. */
-	    0, 0, 0)
-	    
-	    | (MAKE_BYTE(
-	    /* Port power. */
-	    port->state == HUB_PORT_STATE_POWERED_OFF ? 0 : 1,
-	    /* Full-speed device. */
-	    0,
-	    /* Reserved. */
-	    0, 0, 0, 0, 0, 0
-	    )) << 8;
-	    
-	status |= (port->status_change << 16);
-	
-	return virthub_dev.control_transfer_reply(&virthub_dev, 0, &status, 4);
-}
-
-
-static int set_hub_feature(uint16_t feature)
-{
-	return ENOTSUP;
-}
-
-static int set_port_feature(uint16_t feature, uint16_t portindex)
-{
-	_GET_PORT(port, portindex);
-	
-	switch (feature) {
-		case USB_HUB_FEATURE_PORT_RESET:
-			if (port->state != HUB_PORT_STATE_POWERED_OFF) {
-				set_port_state(port, HUB_PORT_STATE_RESETTING);
-			}
-			return EOK;
-		
-		case USB_HUB_FEATURE_PORT_SUSPEND:
-			if (port->state == HUB_PORT_STATE_ENABLED) {
-				set_port_state(port, HUB_PORT_STATE_SUSPENDED);
-			}
-			return EOK;
-		
-		case USB_HUB_FEATURE_PORT_POWER:
-			if (port->state == HUB_PORT_STATE_POWERED_OFF) {
-				set_port_state(port, HUB_PORT_STATE_DISCONNECTED);
-			}
-			return EOK;
-	}
-	return ENOTSUP;
-}
-
-#undef _GET_PORT
-
-
-/** Callback for class request. */
-static int on_class_request(struct usbvirt_device *dev,
-    usb_device_request_setup_packet_t *request, uint8_t *data)
-{	
-	dprintf(2, "hub class request (%d)\n", (int) request->request);
-	
-	uint8_t recipient = request->request_type & 31;
-	uint8_t direction = request->request_type >> 7;
-	
-#define _VERIFY(cond) \
-	do { \
-		if (!(cond)) { \
-			dprintf(0, "WARN: invalid class request (%s not met).\n", \
-			    NAME, #cond); \
-			return EINVAL; \
-		} \
-	} while (0)
-	
-	switch (request->request) {
-		case USB_HUB_REQUEST_CLEAR_FEATURE:
-			_VERIFY(direction == 0);
-			_VERIFY(request->length == 0);
-			if (recipient == 0) {
-				_VERIFY(request->index == 0);
-				return clear_hub_feature(request->value);
-			} else {
-				_VERIFY(recipient == 3);
-				return clear_port_feature(request->value,
-				    request->index);
-			}
-			
-		case USB_HUB_REQUEST_GET_STATE:
-			return get_bus_state(request->index);
-			
-		case USB_HUB_REQUEST_GET_DESCRIPTOR:
-			return get_hub_descriptor(request->value_low,
-			    request->value_high, request->length);
-			
-		case USB_HUB_REQUEST_GET_STATUS:
-			if (recipient == 0) {
-				return get_hub_status();
-			} else {
-				return get_port_status(request->index);
-			}
-			
-		case USB_HUB_REQUEST_SET_FEATURE:
-			if (recipient == 0) {
-				return set_hub_feature(request->value);
-			} else {
-				return set_port_feature(request->value, request->index);
-			}
-			
-		default:
-			break;
-	}
-	
-#undef _VERIFY	
-
-
-	return EOK;
-}
-
-void clear_port_status_change(hub_port_t *port, uint16_t change)
-{
-	port->status_change &= (~change);
-}
-
-void set_port_status_change(hub_port_t *port, uint16_t change)
-{
-	port->status_change |= change;
-}
-
-/** Callback for data request. */
-static int on_data_request(struct usbvirt_device *dev,
-    usb_endpoint_t endpoint,
-    void *buffer, size_t size, size_t *actual_size)
-{
-	if (endpoint != HUB_STATUS_CHANGE_PIPE) {
-		return EINVAL;
-	}
-	
-	uint8_t change_map = 0;
-	
-	size_t i;
-	for (i = 0; i < HUB_PORT_COUNT; i++) {
-		hub_port_t *port = &hub_dev.ports[i];
-		
-		if (port->status_change != 0) {
-			change_map |= (1 << (i + 1));
-		}
-	}
-	
-	uint8_t *b = (uint8_t *) buffer;
-	if (size > 0) {
-		*b = change_map;
-		*actual_size = 1;
-	}
-	
-	return EOK;
-}
-
-
-/**
- * @}
- */
Index: pace/srv/hw/bus/usb/hcd/virtual/vhcd.h
===================================================================
--- uspace/srv/hw/bus/usb/hcd/virtual/vhcd.h	(revision 3f0a7971b0a7536c06012fdd2835873631dfa824)
+++ 	(revision )
@@ -1,52 +1,0 @@
-/*
- * Copyright (c) 2010 Vojtech Horky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup usb
- * @{
- */
-/** @file
- * @brief Virtual USB host controller common definitions.
- */
-#ifndef VHCD_VHCD_H_
-#define VHCD_VHCD_H_
-
-#define NAME "hcd-virt"
-#define NAME_DEV "hcd-virt-dev"
-#define NAMESPACE "usb"
-
-#define DEVMAP_PATH_HC NAMESPACE "/" NAME
-#define DEVMAP_PATH_DEV NAMESPACE "/" NAME_DEV
-
-extern int debug_level;
-void dprintf(int, const char *, ...);
-void dprintf_inval_call(int, ipc_call_t, ipcarg_t);
-
-#endif
-/**
- * @}
- */
