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

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

ddf: removed usbhc iface

As it is currently not used anywhere. It will be created again to serve its original purpose, this commit clears all invalid leftovers.

  • Property mode set to 100644
File size: 3.6 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 <usb/host/endpoint.h>
40#include <usb/host/bus.h>
41#include <usb/host/usb_transfer_batch.h>
42#include <usb/usb.h>
43
44#include <assert.h>
45#include <mem.h>
46#include <stddef.h>
47#include <stdint.h>
48
49typedef struct hcd hcd_t;
50
51typedef int (*schedule_hook_t)(hcd_t *, usb_transfer_batch_t *);
52typedef void (*interrupt_hook_t)(hcd_t *, uint32_t);
53typedef int (*status_hook_t)(hcd_t *, uint32_t *);
54typedef int (*address_device_hook_t)(hcd_t *, usb_speed_t, usb_tt_address_t, usb_address_t *);
55
56typedef struct {
57 /** Transfer scheduling, implement in device driver. */
58 schedule_hook_t schedule;
59 /** Hook to be called on device interrupt, passes ARG1 */
60 interrupt_hook_t irq_hook;
61 /** Periodic polling hook */
62 status_hook_t status_hook;
63 /** Hook to setup device address */
64 address_device_hook_t address_device;
65} hcd_ops_t;
66
67/** Generic host controller driver structure. */
68struct hcd {
69 /** Endpoint manager. */
70 bus_t *bus;
71
72 /** Interrupt replacement fibril */
73 fid_t polling_fibril;
74
75 /** Driver implementation */
76 hcd_ops_t ops;
77
78 /** Device specific driver data. */
79 void * driver_data;
80};
81
82extern void hcd_init(hcd_t *);
83
84static inline void hcd_set_implementation(hcd_t *hcd, void *data,
85 const hcd_ops_t *ops, bus_t *bus)
86{
87 assert(hcd);
88 if (ops) {
89 hcd->driver_data = data;
90 hcd->ops = *ops;
91 hcd->bus = bus;
92 } else {
93 memset(&hcd->ops, 0, sizeof(hcd->ops));
94 }
95}
96
97static inline void * hcd_get_driver_data(hcd_t *hcd)
98{
99 assert(hcd);
100 return hcd->driver_data;
101}
102
103extern usb_address_t hcd_request_address(hcd_t *, usb_speed_t);
104
105extern int hcd_add_ep(hcd_t *, usb_target_t, usb_direction_t,
106 usb_transfer_type_t, size_t, unsigned int, size_t, usb_tt_address_t);
107
108extern int hcd_remove_ep(hcd_t *, usb_target_t, usb_direction_t);
109
110extern int hcd_send_batch(hcd_t *, device_t *, usb_target_t,
111 usb_direction_t direction, char *, size_t, uint64_t,
112 usb_transfer_batch_callback_t, void *, const char *);
113
114extern ssize_t hcd_send_batch_sync(hcd_t *, device_t *, usb_target_t,
115 usb_direction_t direction, char *, size_t, uint64_t,
116 const char *);
117
118#endif
119
120/**
121 * @}
122 */
Note: See TracBrowser for help on using the repository browser.