source: mainline/uspace/drv/bus/usb/vhc/hub/virthub.h@ b357377

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since b357377 was 58563585, checked in by Martin Decky <martin@…>, 9 years ago

code review and cstyle cleanup (no change in functionality)

  • 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
36#ifndef VHC_HUB_VIRTHUB_H_
37#define VHC_HUB_VIRTHUB_H_
38
39#include <usbvirt/device.h>
40#include "hub.h"
41
42#ifdef STANDALONE_HUB
43#define virtdev_connection_t int
44#else
45#include "../vhcd.h"
46#endif
47
48/** Endpoint number for status change pipe. */
49#define HUB_STATUS_CHANGE_PIPE 1
50/** Configuration value for hub configuration. */
51#define HUB_CONFIGURATION_ID 1
52
53
54/** Hub descriptor.
55 */
56typedef struct {
57 /** Size of this descriptor in bytes. */
58 uint8_t length;
59 /** Descriptor type (USB_DESCTYPE_HUB). */
60 uint8_t type;
61 /** Number of downstream ports. */
62 uint8_t port_count;
63 /** Hub characteristics. */
64 uint16_t characteristics;
65 /** Time from power-on to stabilized current.
66 * Expressed in 2ms unit.
67 */
68 uint8_t power_on_warm_up;
69 /** Maximum current (in mA). */
70 uint8_t max_current;
71 /** Whether device at given port is removable. */
72 uint8_t removable_device[BITS2BYTES(HUB_PORT_COUNT+1)];
73 /** Port power control.
74 * This is USB1.0 compatibility field, all bits must be 1.
75 */
76 uint8_t port_power[BITS2BYTES(HUB_PORT_COUNT+1)];
77} __attribute__ ((packed)) hub_descriptor_t;
78
79extern usbvirt_device_ops_t hub_ops;
80extern hub_descriptor_t hub_descriptor;
81
82int virthub_init(usbvirt_device_t *, const char *name);
83int virthub_connect_device(usbvirt_device_t *, vhc_virtdev_t *);
84int virthub_disconnect_device(usbvirt_device_t *, vhc_virtdev_t *);
85bool virthub_is_device_enabled(usbvirt_device_t *, vhc_virtdev_t *);
86void virthub_get_status(usbvirt_device_t *, char *, size_t);
87
88#endif
89
90/**
91 * @}
92 */
Note: See TracBrowser for help on using the repository browser.