source: mainline/uspace/drv/vhc/hub/virthub.h@ 3ee48f2

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 3ee48f2 was 95622c4, checked in by Vojtech Horky <vojtechhorky@…>, 15 years ago

Add standalone virtual hub

Similar to virtual USB keyboard (vuk'), vuh' is a virtual USB hub.

  • Property mode set to 100644
File size: 3.0 KB
Line 
1/*
2 * Copyright (c) 2010 Vojtech Horky
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup drvusbvhc
30 * @{
31 */
32/** @file
33 * @brief USB hub as a virtual USB device.
34 */
35#ifndef VHC_HUB_VIRTHUB_H_
36#define VHC_HUB_VIRTHUB_H_
37
38#include <usbvirt/device.h>
39#include "hub.h"
40
41#ifdef STANDALONE_HUB
42#define virtdev_connection_t int
43#else
44#include "../devices.h"
45#endif
46
47/** Endpoint number for status change pipe. */
48#define HUB_STATUS_CHANGE_PIPE 1
49/** Configuration value for hub configuration. */
50#define HUB_CONFIGURATION_ID 1
51
52
53/** Hub descriptor.
54 */
55typedef struct {
56 /** Size of this descriptor in bytes. */
57 uint8_t length;
58 /** Descriptor type (USB_DESCTYPE_HUB). */
59 uint8_t type;
60 /** Number of downstream ports. */
61 uint8_t port_count;
62 /** Hub characteristics. */
63 uint16_t characteristics;
64 /** Time from power-on to stabilized current.
65 * Expressed in 2ms unit.
66 */
67 uint8_t power_on_warm_up;
68 /** Maximum current (in mA). */
69 uint8_t max_current;
70 /** Whether device at given port is removable. */
71 uint8_t removable_device[BITS2BYTES(HUB_PORT_COUNT+1)];
72 /** Port power control.
73 * This is USB1.0 compatibility field, all bits must be 1.
74 */
75 uint8_t port_power[BITS2BYTES(HUB_PORT_COUNT+1)];
76} __attribute__ ((packed)) hub_descriptor_t;
77
78extern usbvirt_device_ops_t hub_ops;
79extern hub_descriptor_t hub_descriptor;
80
81int virthub_init(usbvirt_device_t *);
82int virthub_connect_device(usbvirt_device_t *, virtdev_connection_t *);
83int virthub_disconnect_device(usbvirt_device_t *, virtdev_connection_t *);
84bool virthub_is_device_enabled(usbvirt_device_t *, virtdev_connection_t *);
85void virthub_get_status(usbvirt_device_t *, char *, size_t);
86
87#endif
88/**
89 * @}
90 */
Note: See TracBrowser for help on using the repository browser.