source: mainline/uspace/lib/usbhost/include/usb/host/hcd.h@ df6ded8

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since df6ded8 was ae3a941, checked in by Ondřej Hlavatý <aearsis@…>, 8 years ago

usb: cstyle

  • Property mode set to 100644
File size: 3.3 KB
Line 
1/*
2 * Copyright (c) 2011 Jan Vesely
3 * Copyright (c) 2018 Ondrej Hlavaty
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 libusbhost
31 * @{
32 */
33/** @file
34 *
35 */
36
37#ifndef LIBUSBHOST_HOST_HCD_H
38#define LIBUSBHOST_HOST_HCD_H
39
40#include <ddf/driver.h>
41#include <usb/request.h>
42
43typedef struct hw_resource_list_parsed hw_res_list_parsed_t;
44typedef struct bus bus_t;
45typedef struct device device_t;
46
47/* Treat this header as read-only in driver code.
48 * It could be opaque, but why to complicate matters.
49 */
50typedef struct hc_device {
51 /* Bus instance */
52 bus_t *bus;
53
54 /* Managed DDF device */
55 ddf_dev_t *ddf_dev;
56
57 /* Control function */
58 ddf_fun_t *ctl_fun;
59
60 /* Result of enabling HW IRQs */
61 int irq_cap;
62
63 /** Interrupt replacement fibril */
64 fid_t polling_fibril;
65
66 /* This structure is meant to be extended by driver code. */
67} hc_device_t;
68
69typedef struct hc_driver {
70 const char *name;
71
72 /** Size of the device data to be allocated, and passed as the
73 * hc_device_t. */
74 size_t hc_device_size;
75
76 /** Initialize device structures. */
77 int (*hc_add)(hc_device_t *, const hw_res_list_parsed_t *);
78
79 /** Generate IRQ code to handle interrupts. */
80 int (*irq_code_gen)(irq_code_t *, hc_device_t *,
81 const hw_res_list_parsed_t *, int *);
82
83 /** Claim device from BIOS. */
84 int (*claim)(hc_device_t *);
85
86 /** Start the host controller. */
87 int (*start)(hc_device_t *);
88
89 /** Setup the virtual roothub. */
90 int (*setup_root_hub)(hc_device_t *);
91
92 /** Stop the host controller (after start has been called) */
93 int (*stop)(hc_device_t *);
94
95 /** HC was asked to be removed (after hc_add has been called) */
96 int (*hc_remove)(hc_device_t *);
97
98 /** HC is gone. */
99 int (*hc_gone)(hc_device_t *);
100} hc_driver_t;
101
102/* Drivers should call this before leaving hc_add */
103static inline void hc_device_setup(hc_device_t *hcd, bus_t *bus)
104{
105 hcd->bus = bus;
106}
107
108static inline hc_device_t *dev_to_hcd(ddf_dev_t *dev)
109{
110 return ddf_dev_data_get(dev);
111}
112
113extern errno_t hc_driver_main(const hc_driver_t *);
114
115#endif
116
117/**
118 * @}
119 */
Note: See TracBrowser for help on using the repository browser.