source: mainline/uspace/drv/vhc/hub/hub.h@ bd8c753d

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

Doxygen group for USB virtualization

Virtual host controller and libusbvirt has separate Doxygen groups because
the usb group was polluted way too much.

  • Property mode set to 100644
File size: 3.5 KB
RevLine 
[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 Representation of an USB hub.
[b8507a1]34 */
[774afaae]35#ifndef VHC_HUB_HUB_H_
36#define VHC_HUB_HUB_H_
[b8507a1]37
[1e32a63]38#include <fibril_synch.h>
[b8507a1]39
[774afaae]40#define HUB_PORT_COUNT 2
41#define BITS2BYTES(bits) (bits ? ((((bits)-1)>>3)+1) : 0)
[b8507a1]42
[355f7c2]43/** Hub port internal state.
44 * Some states (e.g. port over current) are not covered as they are not
45 * simulated at all.
46 */
[b8507a1]47typedef enum {
[774afaae]48 HUB_PORT_STATE_UNKNOWN,
[b8507a1]49 HUB_PORT_STATE_NOT_CONFIGURED,
50 HUB_PORT_STATE_POWERED_OFF,
51 HUB_PORT_STATE_DISCONNECTED,
52 HUB_PORT_STATE_DISABLED,
53 HUB_PORT_STATE_RESETTING,
54 HUB_PORT_STATE_ENABLED,
55 HUB_PORT_STATE_SUSPENDED,
56 HUB_PORT_STATE_RESUMING,
57 /* HUB_PORT_STATE_, */
58} hub_port_state_t;
59
[774afaae]60char hub_port_state_to_char(hub_port_state_t);
[355f7c2]61
62/** Hub status change mask bits. */
[6c741e1d]63typedef enum {
64 HUB_STATUS_C_PORT_CONNECTION = (1 << 0),
65 HUB_STATUS_C_PORT_ENABLE = (1 << 1),
66 HUB_STATUS_C_PORT_SUSPEND = (1 << 2),
67 HUB_STATUS_C_PORT_OVER_CURRENT = (1 << 3),
68 HUB_STATUS_C_PORT_RESET = (1 << 4),
69 /* HUB_STATUS_C_ = (1 << ), */
70} hub_status_change_t;
71
[355f7c2]72/** Hub port information. */
[b8507a1]73typedef struct {
[70e5ad5]74 /** Custom pointer to connected device. */
[774afaae]75 void *connected_device;
[70e5ad5]76 /** Port index (one based). */
[774afaae]77 size_t index;
[70e5ad5]78 /** Port state. */
[b8507a1]79 hub_port_state_t state;
[70e5ad5]80 /** Status change bitmap. */
[6c741e1d]81 uint16_t status_change;
[b8507a1]82} hub_port_t;
83
[355f7c2]84/** Hub device type. */
[b8507a1]85typedef struct {
[70e5ad5]86 /** Hub ports. */
[b8507a1]87 hub_port_t ports[HUB_PORT_COUNT];
[70e5ad5]88 /** Custom hub data. */
[774afaae]89 void *custom_data;
[70e5ad5]90 /** Access guard to the whole hub. */
[774afaae]91 fibril_mutex_t guard;
92} hub_t;
[b8507a1]93
[774afaae]94void hub_init(hub_t *);
95size_t hub_connect_device(hub_t *, void *);
[68a68705]96int hub_disconnect_device(hub_t *, void *);
[774afaae]97size_t hub_find_device(hub_t *, void *);
98void hub_acquire(hub_t *);
99void hub_release(hub_t *);
100void hub_set_port_state(hub_t *, size_t, hub_port_state_t);
101void hub_set_port_state_all(hub_t *, hub_port_state_t);
102hub_port_state_t hub_get_port_state(hub_t *, size_t);
103void hub_clear_port_status_change(hub_t *, size_t, hub_status_change_t);
104uint16_t hub_get_port_status_change(hub_t *, size_t);
105uint32_t hub_get_port_status(hub_t *, size_t);
106uint8_t hub_get_status_change_bitmap(hub_t *);
[6c741e1d]107
108
[b8507a1]109#endif
110/**
111 * @}
112 */
Note: See TracBrowser for help on using the repository browser.