source: mainline/uspace/lib/usbhost/include/usb/host/device_keeper.h@ a837544

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

Fix Doxygen groups of USB libraries

  • Property mode set to 100644
File size: 3.1 KB
Line 
1/*
2 * Copyright (c) 2011 Jan Vesely
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 libusbhost
30 * @{
31 */
32/** @file
33 * Device keeper structure and functions.
34 *
35 * Typical USB host controller needs to keep track of various settings for
36 * each device that is connected to it.
37 * State of toggle bit, device speed etc. etc.
38 * This structure shall simplify the management.
39 */
40#ifndef LIBUSBHOST_HOST_DEVICE_KEEPER_H
41#define LIBUSBHOST_HOST_DEVICE_KEEPER_H
42
43#include <adt/list.h>
44#include <devman.h>
45#include <fibril_synch.h>
46#include <usb/usb.h>
47#include <usb/host/endpoint.h>
48
49/** Number of USB address for array dimensions. */
50#define USB_ADDRESS_COUNT (USB11_ADDRESS_MAX + 1)
51
52/** Information about attached USB device. */
53struct usb_device_info {
54 usb_speed_t speed;
55 bool occupied;
56 devman_handle_t handle;
57};
58
59/** Host controller device keeper.
60 * You shall not access members directly but only using functions below.
61 */
62typedef struct {
63 struct usb_device_info devices[USB_ADDRESS_COUNT];
64 fibril_mutex_t guard;
65 usb_address_t last_address;
66} usb_device_keeper_t;
67
68void usb_device_keeper_init(usb_device_keeper_t *instance);
69
70usb_address_t device_keeper_get_free_address(usb_device_keeper_t *instance,
71 usb_speed_t speed);
72
73void usb_device_keeper_bind(usb_device_keeper_t *instance,
74 usb_address_t address, devman_handle_t handle);
75
76void usb_device_keeper_release(usb_device_keeper_t *instance,
77 usb_address_t address);
78
79usb_address_t usb_device_keeper_find(usb_device_keeper_t *instance,
80 devman_handle_t handle);
81
82bool usb_device_keeper_find_by_address(usb_device_keeper_t *instance,
83 usb_address_t address, devman_handle_t *handle);
84
85usb_speed_t usb_device_keeper_get_speed(usb_device_keeper_t *instance,
86 usb_address_t address);
87#endif
88/**
89 * @}
90 */
Note: See TracBrowser for help on using the repository browser.