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

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 5a6cc679 was 5a6cc679, checked in by Jenda <jenda.jzqk73@…>, 8 years ago

Merge commit '50f19b7ee8e94570b5c63896736c4eb49cfa18db' into forwardport

Not all ints are converted to errno_t in xhci tree yet, however it compiles and works :)

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