[3f45993] | 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 libusb usb
|
---|
| 30 | * @{
|
---|
| 31 | */
|
---|
| 32 | /** @file
|
---|
| 33 | * @brief HC driver.
|
---|
| 34 | */
|
---|
| 35 | #ifndef LIBUSB_HCD_H_
|
---|
| 36 | #define LIBUSB_HCD_H_
|
---|
| 37 |
|
---|
| 38 | #include <usb/usb.h>
|
---|
| 39 | #include <fibril_synch.h>
|
---|
| 40 | #include <devman.h>
|
---|
| 41 |
|
---|
| 42 | /** Info about used address. */
|
---|
| 43 | typedef struct {
|
---|
| 44 | /** Linked list member. */
|
---|
| 45 | link_t link;
|
---|
| 46 | /** Address. */
|
---|
| 47 | usb_address_t address;
|
---|
| 48 | /** Corresponding devman handle. */
|
---|
| 49 | devman_handle_t devman_handle;
|
---|
| 50 | } usb_address_keeping_used_t;
|
---|
| 51 |
|
---|
| 52 | /** Structure for keeping track of free and used USB addresses. */
|
---|
| 53 | typedef struct {
|
---|
| 54 | /** Head of list of used addresses. */
|
---|
| 55 | link_t used_addresses;
|
---|
| 56 | /** Upper bound for USB addresses. */
|
---|
| 57 | usb_address_t max_address;
|
---|
| 58 | /** Mutex protecting used address. */
|
---|
| 59 | fibril_mutex_t used_addresses_guard;
|
---|
| 60 | /** Condition variable for used addresses. */
|
---|
| 61 | fibril_condvar_t used_addresses_condvar;
|
---|
| 62 |
|
---|
| 63 | /** Condition variable mutex for default address. */
|
---|
| 64 | fibril_mutex_t default_condvar_guard;
|
---|
| 65 | /** Condition variable for default address. */
|
---|
| 66 | fibril_condvar_t default_condvar;
|
---|
| 67 | /** Whether is default address available. */
|
---|
| 68 | bool default_available;
|
---|
| 69 | } usb_address_keeping_t;
|
---|
| 70 |
|
---|
| 71 | void usb_address_keeping_init(usb_address_keeping_t *, usb_address_t);
|
---|
| 72 |
|
---|
| 73 | void usb_address_keeping_reserve_default(usb_address_keeping_t *);
|
---|
| 74 | void usb_address_keeping_release_default(usb_address_keeping_t *);
|
---|
| 75 |
|
---|
| 76 | usb_address_t usb_address_keeping_request(usb_address_keeping_t *);
|
---|
| 77 | int usb_address_keeping_release(usb_address_keeping_t *, usb_address_t);
|
---|
| 78 | void usb_address_keeping_devman_bind(usb_address_keeping_t *, usb_address_t,
|
---|
| 79 | devman_handle_t);
|
---|
| 80 | usb_address_t usb_address_keeping_find(usb_address_keeping_t *,
|
---|
| 81 | devman_handle_t);
|
---|
| 82 |
|
---|
| 83 |
|
---|
| 84 | #endif
|
---|