source: mainline/uspace/drv/bus/usb/usbhub/port.h@ 621ba8c

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 621ba8c was 3b617579, checked in by Jan Vesely <jano.vesely@…>, 14 years ago

usbhub: Add license lines.

  • Property mode set to 100644
File size: 3.0 KB
RevLine 
[2ad98fd]1/*
2 * Copyright (c) 2011 Vojtech Horky
[3b617579]3 * Copyright (c) 2011 Jan Vesely
[2ad98fd]4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * - Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * - The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30/** @addtogroup drvusbhub
31 * @{
32 */
33/** @file
34 * Hub ports related functions.
35 */
36#ifndef DRV_USBHUB_PORTS_H
37#define DRV_USBHUB_PORTS_H
38
[7d521e24]39#include <usb/dev/driver.h>
40#include <usb/dev/hub.h>
[aff1880]41#include <usb/classes/hub.h>
[2ad98fd]42
43typedef struct usb_hub_info_t usb_hub_info_t;
44
45/** Information about single port on a hub. */
46typedef struct {
[c0587d90]47 size_t port_number;
48 usb_pipe_t *control_pipe;
[442fa6b]49 /** Mutex needed not only by CV for checking port reset. */
50 fibril_mutex_t mutex;
[2ad98fd]51 /** CV for waiting to port reset completion. */
52 fibril_condvar_t reset_cv;
53 /** Whether port reset is completed.
54 * Guarded by @c reset_mutex.
55 */
56 bool reset_completed;
[46e078a]57 /** Whether to announce the port reset as successful. */
58 bool reset_okay;
[2ad98fd]59
60 /** Information about attached device. */
61 usb_hc_attached_device_t attached_device;
62} usb_hub_port_t;
63
64/** Initialize hub port information.
65 *
66 * @param port Port to be initialized.
67 */
[c0587d90]68static inline void usb_hub_port_init(usb_hub_port_t *port, size_t port_number,
69 usb_pipe_t *control_pipe)
[193da9d6]70{
71 assert(port);
[2ad98fd]72 port->attached_device.address = -1;
73 port->attached_device.handle = 0;
[c0587d90]74 port->port_number = port_number;
75 port->control_pipe = control_pipe;
[442fa6b]76 fibril_mutex_initialize(&port->mutex);
[2ad98fd]77 fibril_condvar_initialize(&port->reset_cv);
78}
79
[442fa6b]80void usb_hub_port_reset_fail(usb_hub_port_t *port);
81void usb_hub_port_process_interrupt(usb_hub_info_t *hub, size_t port);
82int usb_hub_port_clear_feature(
[c0587d90]83 usb_hub_port_t *port, usb_hub_class_feature_t feature);
[442fa6b]84int usb_hub_port_set_feature(
[c0587d90]85 usb_hub_port_t *port, usb_hub_class_feature_t feature);
[2ad98fd]86
87#endif
88/**
89 * @}
90 */
Note: See TracBrowser for help on using the repository browser.