source: mainline/uspace/lib/drv/include/usbhc_iface.h@ 049eb87

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

Add IPC layer for endpoint (bandwidth) reservation

No HC driver currently implements this and no device driver uses this.
Some adjustments might be needed later.

  • Property mode set to 100644
File size: 8.2 KB
Line 
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 libdrv
30 * @addtogroup usb
31 * @{
32 */
33/** @file
34 * @brief USB host controller interface definition.
35 */
36
37#ifndef LIBDRV_USBHC_IFACE_H_
38#define LIBDRV_USBHC_IFACE_H_
39
40#include "ddf/driver.h"
41#include <usb/usb.h>
42#include <bool.h>
43
44
45/** IPC methods for communication with HC through DDF interface.
46 *
47 * Notes for async methods:
48 *
49 * Methods for sending data to device (OUT transactions)
50 * - e.g. IPC_M_USBHC_INTERRUPT_OUT -
51 * always use the same semantics:
52 * - first, IPC call with given method is made
53 * - argument #1 is target address
54 * - argument #2 is target endpoint
55 * - argument #3 is max packet size of the endpoint
56 * - this call is immediately followed by IPC data write (from caller)
57 * - the initial call (and the whole transaction) is answer after the
58 * transaction is scheduled by the HC and acknowledged by the device
59 * or immediately after error is detected
60 * - the answer carries only the error code
61 *
62 * Methods for retrieving data from device (IN transactions)
63 * - e.g. IPC_M_USBHC_INTERRUPT_IN -
64 * also use the same semantics:
65 * - first, IPC call with given method is made
66 * - argument #1 is target address
67 * - argument #2 is target endpoint
68 * - argument #3 is max packet size of the endpoint
69 * - this call is immediately followed by IPC data read (async version)
70 * - the call is not answered until the device returns some data (or until
71 * error occurs)
72 *
73 * Some special methods (NO-DATA transactions) do not send any data. These
74 * might behave as both OUT or IN transactions because communication parts
75 * where actual buffers are exchanged are omitted.
76 **
77 * For all these methods, wrap functions exists. Important rule: functions
78 * for IN transactions have (as parameters) buffers where retrieved data
79 * will be stored. These buffers must be already allocated and shall not be
80 * touch until the transaction is completed
81 * (e.g. not before calling usb_wait_for() with appropriate handle).
82 * OUT transactions buffers can be freed immediately after call is dispatched
83 * (i.e. after return from wrapping function).
84 *
85 */
86typedef enum {
87 /** Reserve usage of default address.
88 * This call informs the host controller that the caller will be
89 * using default USB address. It is duty of the HC driver to ensure
90 * that only single entity will have it reserved.
91 * The address is returned via IPC_M_USBHC_RELEASE_DEFAULT_ADDRESS.
92 * The caller can start using the address after receiving EOK
93 * answer.
94 */
95 IPC_M_USBHC_RESERVE_DEFAULT_ADDRESS,
96
97 /** Release usage of default address.
98 * @see IPC_M_USBHC_RESERVE_DEFAULT_ADDRESS
99 */
100 IPC_M_USBHC_RELEASE_DEFAULT_ADDRESS,
101
102 /** Asks for address assignment by host controller.
103 * Answer:
104 * - ELIMIT - host controller run out of address
105 * - EOK - address assigned
106 * Answer arguments:
107 * - assigned address
108 *
109 * The address must be released by via IPC_M_USBHC_RELEASE_ADDRESS.
110 */
111 IPC_M_USBHC_REQUEST_ADDRESS,
112
113 /** Bind USB address with devman handle.
114 * Parameters:
115 * - USB address
116 * - devman handle
117 * Answer:
118 * - EOK - address binded
119 * - ENOENT - address is not in use
120 */
121 IPC_M_USBHC_BIND_ADDRESS,
122
123 /** Release address in use.
124 * Arguments:
125 * - address to be released
126 * Answer:
127 * - ENOENT - address not in use
128 * - EPERM - trying to release default USB address
129 */
130 IPC_M_USBHC_RELEASE_ADDRESS,
131
132
133 /** Send interrupt data to device.
134 * See explanation at usb_iface_funcs_t (OUT transaction).
135 */
136 IPC_M_USBHC_INTERRUPT_OUT,
137
138 /** Get interrupt data from device.
139 * See explanation at usb_iface_funcs_t (IN transaction).
140 */
141 IPC_M_USBHC_INTERRUPT_IN,
142
143 /** Send bulk data to device.
144 * See explanation at usb_iface_funcs_t (OUT transaction).
145 */
146 IPC_M_USBHC_BULK_OUT,
147
148 /** Get bulk data from device.
149 * See explanation at usb_iface_funcs_t (IN transaction).
150 */
151 IPC_M_USBHC_BULK_IN,
152
153 /** Issue control WRITE transfer.
154 * See explanation at usb_iface_funcs_t (OUT transaction) for
155 * call parameters.
156 * This call is immediately followed by two IPC data writes
157 * from the caller (setup packet and actual data).
158 */
159 IPC_M_USBHC_CONTROL_WRITE,
160
161 /** Issue control READ transfer.
162 * See explanation at usb_iface_funcs_t (IN transaction) for
163 * call parameters.
164 * This call is immediately followed by IPC data write from the caller
165 * (setup packet) and IPC data read (buffer that was read).
166 */
167 IPC_M_USBHC_CONTROL_READ,
168
169 /** Register endpoint attributes at host controller.
170 * This is used to reserve portion of USB bandwidth.
171 * Parameters:
172 * - USB address + endpoint number (ADDR * 256 + EP)
173 * - transfer type + direction (TYPE * 256 + DIR)
174 * - maximum packet size
175 * - interval (in milliseconds)
176 * Answer:
177 * - EOK - reservation successful
178 * - ELIMIT - not enough bandwidth to satisfy the request
179 */
180 IPC_M_USBHC_REGISTER_ENDPOINT,
181
182 /** Revert endpoint registration.
183 * Parameters:
184 * - USB address
185 * - endpoint number
186 * - data direction
187 * Answer:
188 * - EOK - endpoint unregistered
189 * - ENOENT - unknown endpoint
190 */
191 IPC_M_USBHC_UNREGISTER_ENDPOINT
192} usbhc_iface_funcs_t;
193
194/** Callback for outgoing transfer. */
195typedef void (*usbhc_iface_transfer_out_callback_t)(ddf_fun_t *,
196 int, void *);
197
198/** Callback for incoming transfer. */
199typedef void (*usbhc_iface_transfer_in_callback_t)(ddf_fun_t *,
200 int, size_t, void *);
201
202
203/** Out transfer processing function prototype. */
204typedef int (*usbhc_iface_transfer_out_t)(ddf_fun_t *, usb_target_t, size_t,
205 void *, size_t,
206 usbhc_iface_transfer_out_callback_t, void *);
207
208/** Setup transfer processing function prototype. @deprecated */
209typedef usbhc_iface_transfer_out_t usbhc_iface_transfer_setup_t;
210
211/** In transfer processing function prototype. */
212typedef int (*usbhc_iface_transfer_in_t)(ddf_fun_t *, usb_target_t, size_t,
213 void *, size_t,
214 usbhc_iface_transfer_in_callback_t, void *);
215
216/** USB host controller communication interface. */
217typedef struct {
218 int (*reserve_default_address)(ddf_fun_t *, usb_speed_t);
219 int (*release_default_address)(ddf_fun_t *);
220 int (*request_address)(ddf_fun_t *, usb_speed_t, usb_address_t *);
221 int (*bind_address)(ddf_fun_t *, usb_address_t, devman_handle_t);
222 int (*release_address)(ddf_fun_t *, usb_address_t);
223
224 int (*register_endpoint)(ddf_fun_t *, usb_address_t, usb_endpoint_t,
225 usb_transfer_type_t, usb_direction_t, size_t, unsigned int);
226 int (*unregister_endpoint)(ddf_fun_t *, usb_address_t, usb_endpoint_t,
227 usb_direction_t);
228
229 usbhc_iface_transfer_out_t interrupt_out;
230 usbhc_iface_transfer_in_t interrupt_in;
231
232 usbhc_iface_transfer_out_t bulk_out;
233 usbhc_iface_transfer_in_t bulk_in;
234
235 int (*control_write)(ddf_fun_t *, usb_target_t,
236 size_t,
237 void *, size_t, void *, size_t,
238 usbhc_iface_transfer_out_callback_t, void *);
239
240 int (*control_read)(ddf_fun_t *, usb_target_t,
241 size_t,
242 void *, size_t, void *, size_t,
243 usbhc_iface_transfer_in_callback_t, void *);
244} usbhc_iface_t;
245
246
247#endif
248/**
249 * @}
250 */
Note: See TracBrowser for help on using the repository browser.