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

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

Rename USB interface to USBHC

USB devices themselves could have their own interface for some
general querying. This name thus seems more apropriate.

  • Property mode set to 100644
File size: 5.8 KB
RevLine 
[91db50ac]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 usb
30 * @{
31 */
32/** @file
33 * @brief USB interface definition.
34 */
35
[cb59f787]36#ifndef LIBDRV_USBHC_IFACE_H_
37#define LIBDRV_USBHC_IFACE_H_
[91db50ac]38
39#include "driver.h"
40#include <usb/usb.h>
41
42
43/** IPC methods for communication with HC through DDF interface.
44 *
45 * Notes for async methods:
46 *
47 * Methods for sending data to device (OUT transactions)
[cb59f787]48 * - e.g. IPC_M_USBHC_INTERRUPT_OUT -
[91db50ac]49 * always use the same semantics:
50 * - first, IPC call with given method is made
51 * - argument #1 is target address
52 * - argument #2 is target endpoint
53 * - argument #3 is buffer size
54 * - this call is immediately followed by IPC data write (from caller)
55 * - the initial call (and the whole transaction) is answer after the
56 * transaction is scheduled by the HC and acknowledged by the device
57 * or immediately after error is detected
58 * - the answer carries only the error code
59 *
60 * Methods for retrieving data from device (IN transactions)
[cb59f787]61 * - e.g. IPC_M_USBHC_INTERRUPT_IN -
[91db50ac]62 * also use the same semantics:
63 * - first, IPC call with given method is made
64 * - argument #1 is target address
65 * - argument #2 is target endpoint
66 * - argument #3 is buffer size
67 * - the call is not answered until the device returns some data (or until
68 * error occurs)
69 * - if the call is answered with EOK, first argument of the answer is buffer
70 * hash that could be used to retrieve the actual data
71 *
72 * Some special methods (NO-DATA transactions) do not send any data. These
73 * might behave as both OUT or IN transactions because communication parts
74 * where actual buffers are exchanged are omitted.
75 *
76 * The mentioned data retrieval can be done any time after receiving EOK
77 * answer to IN method.
[cb59f787]78 * This retrieval is done using the IPC_M_USBHC_GET_BUFFER where
[91db50ac]79 * the first argument is buffer hash from call answer.
80 * This call must be immediately followed by data read-in and after the
[cb59f787]81 * data are transferred, the initial call (IPC_M_USBHC_GET_BUFFER)
[91db50ac]82 * is answered. Each buffer can be retrieved only once.
83 *
84 * For all these methods, wrap functions exists. Important rule: functions
85 * for IN transactions have (as parameters) buffers where retrieved data
86 * will be stored. These buffers must be already allocated and shall not be
87 * touch until the transaction is completed
88 * (e.g. not before calling usb_wait_for() with appropriate handle).
89 * OUT transactions buffers can be freed immediately after call is dispatched
90 * (i.e. after return from wrapping function).
91 *
92 */
93typedef enum {
94 /** Asks for data buffer.
[1b22bd4]95 * See explanation at usb_iface_funcs_t.
96 * This function does not have counter part in functional interface
97 * as it is handled by the remote part itself.
[91db50ac]98 */
[cb59f787]99 IPC_M_USBHC_GET_BUFFER,
[91db50ac]100
101
102 /** Send interrupt data to device.
[1b22bd4]103 * See explanation at usb_iface_funcs_t (OUT transaction).
[91db50ac]104 */
[cb59f787]105 IPC_M_USBHC_INTERRUPT_OUT,
[91db50ac]106
107 /** Get interrupt data from device.
[1b22bd4]108 * See explanation at usb_iface_funcs_t (IN transaction).
[91db50ac]109 */
[cb59f787]110 IPC_M_USBHC_INTERRUPT_IN,
[91db50ac]111
112
113 /** Start WRITE control transfer.
[1b22bd4]114 * See explanation at usb_iface_funcs_t (OUT transaction).
[91db50ac]115 */
[cb59f787]116 IPC_M_USBHC_CONTROL_WRITE_SETUP,
[91db50ac]117
118 /** Send control-transfer data to device.
[1b22bd4]119 * See explanation at usb_iface_funcs_t (OUT transaction).
[91db50ac]120 */
[cb59f787]121 IPC_M_USBHC_CONTROL_WRITE_DATA,
[91db50ac]122
123 /** Terminate WRITE control transfer.
[1b22bd4]124 * See explanation at usb_iface_funcs_t (NO-DATA transaction).
[91db50ac]125 */
[cb59f787]126 IPC_M_USBHC_CONTROL_WRITE_STATUS,
[91db50ac]127
128
129
130 /** Start READ control transfer.
[1b22bd4]131 * See explanation at usb_iface_funcs_t (OUT transaction).
[91db50ac]132 */
[cb59f787]133 IPC_M_USBHC_CONTROL_READ_SETUP,
[91db50ac]134
135 /** Get control-transfer data from device.
[1b22bd4]136 * See explanation at usb_iface_funcs_t (IN transaction).
[91db50ac]137 */
[cb59f787]138 IPC_M_USBHC_CONTROL_READ_DATA,
[91db50ac]139
140 /** Terminate READ control transfer.
[1b22bd4]141 * See explanation at usb_iface_funcs_t (NO-DATA transaction).
[91db50ac]142 */
[cb59f787]143 IPC_M_USBHC_CONTROL_READ_STATUS,
[91db50ac]144
145
146 /* IPC_M_USB_ */
[cb59f787]147} usbhc_iface_funcs_t;
[91db50ac]148
149/** Callback for outgoing transfer. */
[cb59f787]150typedef void (*usbhc_iface_transfer_out_callback_t)(device_t *,
[91db50ac]151 usb_transaction_outcome_t, void *);
152
153/** Callback for incoming transfer. */
[cb59f787]154typedef void (*usbhc_iface_transfer_in_callback_t)(device_t *,
[91db50ac]155 usb_transaction_outcome_t, size_t, void *);
156
157/** USB devices communication interface. */
158typedef struct {
[1b22bd4]159 int (*interrupt_out)(device_t *, usb_target_t,
[91db50ac]160 void *, size_t,
[cb59f787]161 usbhc_iface_transfer_out_callback_t, void *);
[1b22bd4]162 int (*interrupt_in)(device_t *, usb_target_t,
[91db50ac]163 void *, size_t,
[cb59f787]164 usbhc_iface_transfer_in_callback_t, void *);
165} usbhc_iface_t;
[91db50ac]166
167
168#endif
169/**
170 * @}
171 */
Note: See TracBrowser for help on using the repository browser.