source: mainline/uspace/lib/usb/hcd.h@ fd17ab5

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

libusb: base types in separate file

Base USB types (address, protocol type etc.) are now in separate file usb.h.

Also added HID protocol type enum to hid.h.

  • Property mode set to 100644
File size: 4.7 KB
RevLine 
[c0e1be7]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 libusb usb
30 * @{
31 */
32/** @file
33 * @brief USB Host Controller Driver.
34 */
35#ifndef LIBUSB_HCD_H_
36#define LIBUSB_HCD_H_
37
[fd17ab5]38#include "usb.h"
39
[c0e1be7]40#include <ipc/ipc.h>
41#include <async.h>
42
43/** Maximum size of transaction payload. */
44#define USB_MAX_PAYLOAD_SIZE 1020
45
46/** Opaque handle of active USB transaction.
47 * This handle is when informing about transaction outcome (or status).
48 */
49typedef ipcarg_t usb_transaction_handle_t;
50
51/** USB transaction outcome. */
52typedef enum {
53 USB_OUTCOME_OK,
54 USB_OUTCOME_CRCERROR,
55 USB_OUTCOME_BABBLE
56} usb_transaction_outcome_t;
57
58const char * usb_str_transaction_outcome(usb_transaction_outcome_t o);
59
60/** IPC methods for HCD. */
61typedef enum {
62 /** Send data over USB to a function.
63 * This method initializes large data transfer that must follow
64 * immediatelly.
65 * The recipient of this method must issue immediately data reception
66 * and answer this call after data buffer was transfered.
67 *
68 * Arguments of the call:
69 * - USB address of the function
70 * - endpoint of the function
71 * - transfer type
72 * - flags (not used)
73 *
74 * Answer:
75 * - EOK - ready to accept the data buffer
76 * - ELIMIT - too many transactions for current connection
77 * - ENOENT - callback connection does not exist
78 * - EINVAL - other kind of error
79 *
80 * Arguments of the answer:
81 * - opaque transaction handle (used in callbacks)
82 */
83 IPC_M_USB_HCD_SEND_DATA = IPC_FIRST_USER_METHOD,
84
85 /** Initiate data receive from a function.
86 * This method announces the HCD that some data will come.
87 * When this data arrives, the HCD will call back with
88 * IPC_M_USB_HCD_DATA_RECEIVED.
89 *
90 * Arguments of the call:
91 * - USB address of the function
92 * - endpoint of the function
93 * - transfer type
94 * - buffer size
95 * - flags (not used)
96 *
97 * Answer:
98 * - EOK - HCD accepted the request
99 * - ELIMIT - too many transactions for current connection
100 * - ENOENT - callback connection does not exist
101 *
102 * Arguments of the answer:
103 * - opaque transaction handle (used in callbacks)
104 */
105 IPC_M_USB_HCD_RECEIVE_DATA,
106
107 /** Tell maximum size of the transaction buffer (payload).
108 *
109 * Arguments of the call:
110 * (none)
111 *
112 * Answer:
113 * - EOK - always
114 *
115 * Arguments of the answer:
116 * - buffer size (in bytes):
117 */
118 IPC_M_USB_HCD_TRANSACTION_SIZE
119} usb_hcd_method_t;
120
121/** IPC methods for callbacks from HCD. */
122typedef enum {
123 /** Confimation after data sent.
124 *
125 * Arguments of the call:
126 * - transaction handle
127 * - transaction outcome
128 */
129 IPC_M_USB_HCD_DATA_SENT = IPC_FIRST_USER_METHOD,
130
131 /** Notification of data received.
132 * This call initiates sending a data buffer from HCD to the client.
133 * See IPC_M_USB_HCD_SEND_DATA for details for buffer transfer is
134 * done.
135 *
136 * Arguments of the call:
137 * - transaction handle
138 * - transaction outcome
139 * - actual data length
140 */
141 IPC_M_USB_HCD_DATA_RECEIVED,
142
143 /** Notification about a serious trouble with HC.
144 */
145 IPC_M_USB_HCD_CONTROLLER_FAILURE
146} usb_hcd_callback_method_t;
147
148
149int usb_hcd_create_phones(const char *, async_client_conn_t);
150int usb_hcd_send_data_to_function(int, usb_target_t, usb_transfer_type_t,
151 void *, size_t, usb_transaction_handle_t *);
152int usb_hcd_prepare_data_reception(int, usb_target_t, usb_transfer_type_t,
153 size_t, usb_transaction_handle_t *);
154
155#endif
156/**
157 * @}
158 */
Note: See TracBrowser for help on using the repository browser.