[b8507a1] | 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 |
|
---|
[bd8c753d] | 29 | /** @addtogroup drvusbvhc
|
---|
[b8507a1] | 30 | * @{
|
---|
| 31 | */
|
---|
| 32 | /** @file
|
---|
[70e5ad5] | 33 | * @brief USB hub as a virtual USB device.
|
---|
[b8507a1] | 34 | */
|
---|
[774afaae] | 35 | #ifndef VHC_HUB_VIRTHUB_H_
|
---|
| 36 | #define VHC_HUB_VIRTHUB_H_
|
---|
[b8507a1] | 37 |
|
---|
[774afaae] | 38 | #include <usbvirt/device.h>
|
---|
[b8507a1] | 39 | #include "hub.h"
|
---|
| 40 |
|
---|
[95622c4] | 41 | #ifdef STANDALONE_HUB
|
---|
| 42 | #define virtdev_connection_t int
|
---|
| 43 | #else
|
---|
[6cb58e6] | 44 | #include "../vhcd.h"
|
---|
[95622c4] | 45 | #endif
|
---|
| 46 |
|
---|
[355f7c2] | 47 | /** Endpoint number for status change pipe. */
|
---|
[b8507a1] | 48 | #define HUB_STATUS_CHANGE_PIPE 1
|
---|
[355f7c2] | 49 | /** Configuration value for hub configuration. */
|
---|
[b8507a1] | 50 | #define HUB_CONFIGURATION_ID 1
|
---|
| 51 |
|
---|
[774afaae] | 52 |
|
---|
[b8507a1] | 53 | /** Hub descriptor.
|
---|
| 54 | */
|
---|
| 55 | typedef 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 |
|
---|
| 78 | extern usbvirt_device_ops_t hub_ops;
|
---|
[774afaae] | 79 | extern hub_descriptor_t hub_descriptor;
|
---|
[b8507a1] | 80 |
|
---|
[774afaae] | 81 | int virthub_init(usbvirt_device_t *);
|
---|
[6cb58e6] | 82 | int virthub_connect_device(usbvirt_device_t *, vhc_virtdev_t *);
|
---|
| 83 | int virthub_disconnect_device(usbvirt_device_t *, vhc_virtdev_t *);
|
---|
| 84 | bool virthub_is_device_enabled(usbvirt_device_t *, vhc_virtdev_t *);
|
---|
[774afaae] | 85 | void virthub_get_status(usbvirt_device_t *, char *, size_t);
|
---|
[6c741e1d] | 86 |
|
---|
[b8507a1] | 87 | #endif
|
---|
| 88 | /**
|
---|
| 89 | * @}
|
---|
| 90 | */
|
---|