[41924f30] | 1 | /*
|
---|
| 2 | * Copyright (c) 2011 Jan Vesely
|
---|
[e0a5d4c] | 3 | * Copyright (c) 2018 Ondrej Hlavaty
|
---|
[41924f30] | 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 | /** @addtogroup libusbhost
|
---|
| 30 | * @{
|
---|
| 31 | */
|
---|
| 32 | /** @file
|
---|
| 33 | *
|
---|
| 34 | * Bus implementation common for OHCI, UHCI and EHCI.
|
---|
| 35 | */
|
---|
| 36 | #ifndef LIBUSBHOST_HOST_USB2_BUS_H
|
---|
| 37 | #define LIBUSBHOST_HOST_USB2_BUS_H
|
---|
| 38 |
|
---|
| 39 | #include <adt/list.h>
|
---|
| 40 | #include <stdbool.h>
|
---|
[64fea02] | 41 | #include <usb/usb.h>
|
---|
| 42 |
|
---|
| 43 | #include <usb/host/bus.h>
|
---|
[b357377] | 44 | #include <usb/host/bandwidth.h>
|
---|
[41924f30] | 45 |
|
---|
| 46 | typedef struct usb2_bus usb2_bus_t;
|
---|
| 47 | typedef struct endpoint endpoint_t;
|
---|
| 48 |
|
---|
[d369b3b] | 49 | /** Endpoint and bandwidth management structure */
|
---|
| 50 | typedef struct usb2_bus_helper {
|
---|
[56257ba] | 51 | /** Map of occupied addresses */
|
---|
| 52 | bool address_occupied [USB_ADDRESS_COUNT];
|
---|
[41924f30] | 53 | /** The last reserved address */
|
---|
| 54 | usb_address_t last_address;
|
---|
[56257ba] | 55 |
|
---|
| 56 | /** Size of the bandwidth pool */
|
---|
| 57 | size_t free_bw;
|
---|
[b357377] | 58 |
|
---|
| 59 | /* Configured bandwidth accounting */
|
---|
| 60 | const bandwidth_accounting_t *bw_accounting;
|
---|
[d369b3b] | 61 | } usb2_bus_helper_t;
|
---|
[41924f30] | 62 |
|
---|
[ae3a941] | 63 | extern void usb2_bus_helper_init(usb2_bus_helper_t *,
|
---|
| 64 | const bandwidth_accounting_t *);
|
---|
[6832245] | 65 |
|
---|
[d369b3b] | 66 | extern int usb2_bus_device_enumerate(usb2_bus_helper_t *, device_t *);
|
---|
[f3ae58b] | 67 | extern void usb2_bus_device_gone(usb2_bus_helper_t *, device_t *);
|
---|
| 68 |
|
---|
[d369b3b] | 69 | extern int usb2_bus_endpoint_register(usb2_bus_helper_t *, endpoint_t *);
|
---|
| 70 | extern void usb2_bus_endpoint_unregister(usb2_bus_helper_t *, endpoint_t *);
|
---|
[41924f30] | 71 |
|
---|
| 72 | #endif
|
---|
| 73 | /**
|
---|
| 74 | * @}
|
---|
| 75 | */
|
---|