source: mainline/uspace/drv/ehci_hcd/hc_iface.c@ c4fb5ecd

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

Less logging in USB host controller drivers

Many of the debug messages were degraded to debug2 level or
completely removed. Also added formatting string for unified
dump of USB transfer batches.

Warnings in EHCI stub use debug level now.

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