source: mainline/uspace/lib/usb/include/usb/pipes.h@ 25971d2

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

Endpoint pipes has maximum packet size

  • Property mode set to 100644
File size: 5.4 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
29/** @addtogroup libusb
30 * @{
31 */
32/** @file
33 * Communication between device drivers and host controller driver.
34 */
35#ifndef LIBUSB_PIPES_H_
36#define LIBUSB_PIPES_H_
37
38#include <sys/types.h>
39#include <usb/usb.h>
40#include <usb/descriptor.h>
41#include <ipc/devman.h>
42#include <driver.h>
43
44/**
45 * Abstraction of a physical connection to the device.
46 * This type is an abstraction of the USB wire that connects the host and
47 * the function (device).
48 */
49typedef struct {
50 /** Handle of the host controller device is connected to. */
51 devman_handle_t hc_handle;
52 /** Address of the device. */
53 usb_address_t address;
54} usb_device_connection_t;
55
56/**
57 * Abstraction of a logical connection to USB device endpoint.
58 * It encapsulates endpoint attributes (transfer type etc.) as well
59 * as information about currently running sessions.
60 * This endpoint must be bound with existing usb_device_connection_t
61 * (i.e. the wire to send data over).
62 */
63typedef struct {
64 /** The connection used for sending the data. */
65 usb_device_connection_t *wire;
66
67 /** Endpoint number. */
68 usb_endpoint_t endpoint_no;
69
70 /** Endpoint transfer type. */
71 usb_transfer_type_t transfer_type;
72
73 /** Endpoint direction. */
74 usb_direction_t direction;
75
76 /** Maximum packet size for the endpoint. */
77 size_t max_packet_size;
78
79 /** Phone to the host controller.
80 * Negative when no session is active.
81 */
82 int hc_phone;
83} usb_endpoint_pipe_t;
84
85
86/** Description of endpoint characteristics. */
87typedef struct {
88 /** Transfer type (e.g. control or interrupt). */
89 usb_transfer_type_t transfer_type;
90 /** Transfer direction (to or from a device). */
91 usb_direction_t direction;
92 /** Interface class this endpoint belongs to (-1 for any). */
93 int interface_class;
94 /** Interface subclass this endpoint belongs to (-1 for any). */
95 int interface_subclass;
96 /** Interface protocol this endpoint belongs to (-1 for any). */
97 int interface_protocol;
98 /** Extra endpoint flags. */
99 unsigned int flags;
100} usb_endpoint_description_t;
101
102/** Mapping of endpoint pipes and endpoint descriptions. */
103typedef struct {
104 /** Endpoint pipe. */
105 usb_endpoint_pipe_t *pipe;
106 /** Endpoint description. */
107 const usb_endpoint_description_t *description;
108 /** Found descriptor fitting the description. */
109 usb_standard_endpoint_descriptor_t *descriptor;
110 /** Interface the endpoint belongs to. */
111 usb_standard_interface_descriptor_t *interface;
112 /** Whether the endpoint was actually found. */
113 bool present;
114} usb_endpoint_mapping_t;
115
116int usb_device_connection_initialize_from_device(usb_device_connection_t *,
117 device_t *);
118int usb_device_connection_initialize(usb_device_connection_t *,
119 devman_handle_t, usb_address_t);
120
121int usb_endpoint_pipe_initialize(usb_endpoint_pipe_t *,
122 usb_device_connection_t *,
123 usb_endpoint_t, usb_transfer_type_t, size_t, usb_direction_t);
124int usb_endpoint_pipe_initialize_default_control(usb_endpoint_pipe_t *,
125 usb_device_connection_t *);
126int usb_endpoint_pipe_initialize_from_configuration(usb_endpoint_mapping_t *,
127 size_t, uint8_t *, size_t, usb_device_connection_t *);
128
129
130int usb_endpoint_pipe_start_session(usb_endpoint_pipe_t *);
131int usb_endpoint_pipe_end_session(usb_endpoint_pipe_t *);
132
133int usb_endpoint_pipe_read(usb_endpoint_pipe_t *, void *, size_t, size_t *);
134int usb_endpoint_pipe_write(usb_endpoint_pipe_t *, void *, size_t);
135
136int usb_endpoint_pipe_control_read(usb_endpoint_pipe_t *, void *, size_t,
137 void *, size_t, size_t *);
138int usb_endpoint_pipe_control_write(usb_endpoint_pipe_t *, void *, size_t,
139 void *, size_t);
140
141
142
143int usb_endpoint_pipe_async_read(usb_endpoint_pipe_t *, void *, size_t,
144 size_t *, usb_handle_t *);
145int usb_endpoint_pipe_async_write(usb_endpoint_pipe_t *, void *, size_t,
146 usb_handle_t *);
147
148int usb_endpoint_pipe_async_control_read(usb_endpoint_pipe_t *, void *, size_t,
149 void *, size_t, size_t *, usb_handle_t *);
150int usb_endpoint_pipe_async_control_write(usb_endpoint_pipe_t *, void *, size_t,
151 void *, size_t, usb_handle_t *);
152
153int usb_endpoint_pipe_wait_for(usb_endpoint_pipe_t *, usb_handle_t);
154
155#endif
156/**
157 * @}
158 */
Note: See TracBrowser for help on using the repository browser.