source: mainline/uspace/drv/ehci-hcd/hc_iface.c@ 373bc2d

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

Endpoint registration sends address as well

This is the first step towards using endpoint registration instead
of reservation of default address.

  • Property mode set to 100644
File size: 11.3 KB
Line 
1/*
2 * Copyright (c) 2011 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/** @addtogroup drvusbehci
29 * @{
30 */
31/** @file
32 * USB-HC interface implementation.
33 */
34#include <ddf/driver.h>
35#include <ddf/interrupt.h>
36#include <device/hw_res.h>
37#include <errno.h>
38#include <str_error.h>
39
40#include <usb_iface.h>
41#include <usb/ddfiface.h>
42#include <usb/debug.h>
43
44#include "ehci.h"
45
46#define UNSUPPORTED(methodname) \
47 usb_log_warning("Unsupported interface method `%s()' in %s:%d.\n", \
48 methodname, __FILE__, __LINE__)
49
50/** Reserve default address.
51 *
52 * This function may block the caller.
53 *
54 * @param[in] fun Device function the action was invoked on.
55 * @param[in] speed Speed of the device for which the default address is
56 * reserved.
57 * @return Error code.
58 */
59static int reserve_default_address(ddf_fun_t *fun, usb_speed_t speed)
60{
61 UNSUPPORTED("reserve_default_address");
62
63 return ENOTSUP;
64}
65
66/** Release default address.
67 *
68 * @param[in] fun Device function the action was invoked on.
69 * @return Error code.
70 */
71static int release_default_address(ddf_fun_t *fun)
72{
73 UNSUPPORTED("release_default_address");
74
75 return ENOTSUP;
76}
77
78/** Found free USB address.
79 *
80 * @param[in] fun Device function the action was invoked on.
81 * @param[in] speed Speed of the device that will get this address.
82 * @param[out] address Non-null pointer where to store the free address.
83 * @return Error code.
84 */
85static int request_address(ddf_fun_t *fun, usb_speed_t speed,
86 usb_address_t *address)
87{
88 UNSUPPORTED("request_address");
89
90 return ENOTSUP;
91}
92
93/** Bind USB address with device devman handle.
94 *
95 * @param[in] fun Device function the action was invoked on.
96 * @param[in] address USB address of the device.
97 * @param[in] handle Devman handle of the device.
98 * @return Error code.
99 */
100static int bind_address(ddf_fun_t *fun,
101 usb_address_t address, devman_handle_t handle)
102{
103 UNSUPPORTED("bind_address");
104
105 return ENOTSUP;
106}
107
108/** Release previously requested address.
109 *
110 * @param[in] fun Device function the action was invoked on.
111 * @param[in] address USB address to be released.
112 * @return Error code.
113 */
114static int release_address(ddf_fun_t *fun, usb_address_t address)
115{
116 UNSUPPORTED("release_address");
117
118 return ENOTSUP;
119}
120
121/** Register endpoint for bandwidth reservation.
122 *
123 * @param[in] fun Device function the action was invoked on.
124 * @param[in] address USB address of the device.
125 * @param[in] speed Endpoint speed (invalid means to use device one).
126 * @param[in] endpoint Endpoint number.
127 * @param[in] transfer_type USB transfer type.
128 * @param[in] direction Endpoint data direction.
129 * @param[in] max_packet_size Max packet size of the endpoint.
130 * @param[in] interval Polling interval.
131 * @return Error code.
132 */
133static int register_endpoint(ddf_fun_t *fun,
134 usb_address_t address, usb_speed_t speed, usb_endpoint_t endpoint,
135 usb_transfer_type_t transfer_type, usb_direction_t direction,
136 size_t max_packet_size, unsigned int interval)
137{
138 UNSUPPORTED("register_endpoint");
139
140 return ENOTSUP;
141}
142
143/** Unregister endpoint (free some bandwidth reservation).
144 *
145 * @param[in] fun Device function the action was invoked on.
146 * @param[in] address USB address of the device.
147 * @param[in] endpoint Endpoint number.
148 * @param[in] direction Endpoint data direction.
149 * @return Error code.
150 */
151static int unregister_endpoint(ddf_fun_t *fun, usb_address_t address,
152 usb_endpoint_t endpoint, usb_direction_t direction)
153{
154 UNSUPPORTED("unregister_endpoint");
155
156 return ENOTSUP;
157}
158
159/** Schedule interrupt out transfer.
160 *
161 * The callback is supposed to be called once the transfer (on the wire) is
162 * complete regardless of the outcome.
163 * However, the callback could be called only when this function returns
164 * with success status (i.e. returns EOK).
165 *
166 * @param[in] fun Device function the action was invoked on.
167 * @param[in] target Target pipe (address and endpoint number) specification.
168 * @param[in] data Data to be sent (in USB endianess, allocated and deallocated
169 * by the caller).
170 * @param[in] size Size of the @p data buffer in bytes.
171 * @param[in] callback Callback to be issued once the transfer is complete.
172 * @param[in] arg Pass-through argument to the callback.
173 * @return Error code.
174 */
175static int interrupt_out(ddf_fun_t *fun, usb_target_t target,
176 void *data, size_t size,
177 usbhc_iface_transfer_out_callback_t callback, void *arg)
178{
179 UNSUPPORTED("interrupt_out");
180
181 return ENOTSUP;
182}
183
184/** Schedule interrupt in transfer.
185 *
186 * The callback is supposed to be called once the transfer (on the wire) is
187 * complete regardless of the outcome.
188 * However, the callback could be called only when this function returns
189 * with success status (i.e. returns EOK).
190 *
191 * @param[in] fun Device function the action was invoked on.
192 * @param[in] target Target pipe (address and endpoint number) specification.
193 * @param[in] data Buffer where to store the data (in USB endianess,
194 * allocated and deallocated by the caller).
195 * @param[in] size Size of the @p data buffer in bytes.
196 * @param[in] callback Callback to be issued once the transfer is complete.
197 * @param[in] arg Pass-through argument to the callback.
198 * @return Error code.
199 */
200static int interrupt_in(ddf_fun_t *fun, usb_target_t target,
201 void *data, size_t size,
202 usbhc_iface_transfer_in_callback_t callback, void *arg)
203{
204 UNSUPPORTED("interrupt_in");
205
206 return ENOTSUP;
207}
208
209/** Schedule bulk out transfer.
210 *
211 * The callback is supposed to be called once the transfer (on the wire) is
212 * complete regardless of the outcome.
213 * However, the callback could be called only when this function returns
214 * with success status (i.e. returns EOK).
215 *
216 * @param[in] fun Device function the action was invoked on.
217 * @param[in] target Target pipe (address and endpoint number) specification.
218 * @param[in] data Data to be sent (in USB endianess, allocated and deallocated
219 * by the caller).
220 * @param[in] size Size of the @p data buffer in bytes.
221 * @param[in] callback Callback to be issued once the transfer is complete.
222 * @param[in] arg Pass-through argument to the callback.
223 * @return Error code.
224 */
225static int bulk_out(ddf_fun_t *fun, usb_target_t target,
226 void *data, size_t size,
227 usbhc_iface_transfer_out_callback_t callback, void *arg)
228{
229 UNSUPPORTED("bulk_out");
230
231 return ENOTSUP;
232}
233
234/** Schedule bulk in transfer.
235 *
236 * The callback is supposed to be called once the transfer (on the wire) is
237 * complete regardless of the outcome.
238 * However, the callback could be called only when this function returns
239 * with success status (i.e. returns EOK).
240 *
241 * @param[in] fun Device function the action was invoked on.
242 * @param[in] target Target pipe (address and endpoint number) specification.
243 * @param[in] data Buffer where to store the data (in USB endianess,
244 * allocated and deallocated by the caller).
245 * @param[in] size Size of the @p data buffer in bytes.
246 * @param[in] callback Callback to be issued once the transfer is complete.
247 * @param[in] arg Pass-through argument to the callback.
248 * @return Error code.
249 */
250static int bulk_in(ddf_fun_t *fun, usb_target_t target,
251 void *data, size_t size,
252 usbhc_iface_transfer_in_callback_t callback, void *arg)
253{
254 UNSUPPORTED("bulk_in");
255
256 return ENOTSUP;
257}
258
259/** Schedule control write transfer.
260 *
261 * The callback is supposed to be called once the transfer (on the wire) is
262 * complete regardless of the outcome.
263 * However, the callback could be called only when this function returns
264 * with success status (i.e. returns EOK).
265 *
266 * @param[in] fun Device function the action was invoked on.
267 * @param[in] target Target pipe (address and endpoint number) specification.
268 * @param[in] setup_packet Setup packet buffer (in USB endianess, allocated
269 * and deallocated by the caller).
270 * @param[in] setup_packet_size Size of @p setup_packet buffer in bytes.
271 * @param[in] data_buffer Data buffer (in USB endianess, allocated and
272 * deallocated by the caller).
273 * @param[in] data_buffer_size Size of @p data_buffer buffer in bytes.
274 * @param[in] callback Callback to be issued once the transfer is complete.
275 * @param[in] arg Pass-through argument to the callback.
276 * @return Error code.
277 */
278static int control_write(ddf_fun_t *fun, usb_target_t target,
279 void *setup_packet, size_t setup_packet_size,
280 void *data_buffer, size_t data_buffer_size,
281 usbhc_iface_transfer_out_callback_t callback, void *arg)
282{
283 UNSUPPORTED("control_write");
284
285 return ENOTSUP;
286}
287
288/** Schedule control read transfer.
289 *
290 * The callback is supposed to be called once the transfer (on the wire) is
291 * complete regardless of the outcome.
292 * However, the callback could be called only when this function returns
293 * with success status (i.e. returns EOK).
294 *
295 * @param[in] fun Device function the action was invoked on.
296 * @param[in] target Target pipe (address and endpoint number) specification.
297 * @param[in] setup_packet Setup packet buffer (in USB endianess, allocated
298 * and deallocated by the caller).
299 * @param[in] setup_packet_size Size of @p setup_packet buffer in bytes.
300 * @param[in] data_buffer Buffer where to store the data (in USB endianess,
301 * allocated and deallocated by the caller).
302 * @param[in] data_buffer_size Size of @p data_buffer buffer in bytes.
303 * @param[in] callback Callback to be issued once the transfer is complete.
304 * @param[in] arg Pass-through argument to the callback.
305 * @return Error code.
306 */
307static int control_read(ddf_fun_t *fun, usb_target_t target,
308 void *setup_packet, size_t setup_packet_size,
309 void *data_buffer, size_t data_buffer_size,
310 usbhc_iface_transfer_in_callback_t callback, void *arg)
311{
312 UNSUPPORTED("control_read");
313
314 return ENOTSUP;
315}
316
317/** Host controller interface implementation for EHCI. */
318usbhc_iface_t ehci_hc_iface = {
319 .reserve_default_address = reserve_default_address,
320 .release_default_address = release_default_address,
321 .request_address = request_address,
322 .bind_address = bind_address,
323 .release_address = release_address,
324
325 .register_endpoint = register_endpoint,
326 .unregister_endpoint = unregister_endpoint,
327
328 .interrupt_out = interrupt_out,
329 .interrupt_in = interrupt_in,
330
331 .bulk_out = bulk_out,
332 .bulk_in = bulk_in,
333
334 .control_write = control_write,
335 .control_read = control_read
336};
337
338/**
339 * @}
340 */
Note: See TracBrowser for help on using the repository browser.