source: mainline/uspace/lib/usbdev/include/usb/dev/pipes.h@ 27de618

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 27de618 was e0a5d4c, checked in by Ondřej Hlavatý <aearsis@…>, 8 years ago

usb: update copyrights

The data was generated by a script, guided manually. If you feel your
name is missing somewhere, please add it!

The semi-automated process was roughly:

1) Changes per file and author (limited to our team) were counted
2) Trivial numbers were thrown away
3) Authors were sorted by lines added to file
4) All previous copyrights were replaced by the newly generated one
5) Hunks changing only year were discarded

It seems that a lot of my copyrights were added. It is due to me being
both sticking my nose everywhere and lazy to update the copyright right
away :)

  • Property mode set to 100644
File size: 4.6 KB
Line 
1/*
2 * Copyright (c) 2011 Vojtech Horky
3 * Copyright (c) 2018 Ondrej Hlavaty
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * - Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * - The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29/** @addtogroup libusbdev
30 * @{
31 */
32/** @file
33 * USB pipes representation.
34 */
35#ifndef LIBUSBDEV_PIPES_H_
36#define LIBUSBDEV_PIPES_H_
37
38#include <usb/usb.h>
39#include <usb/descriptor.h>
40#include <usb_iface.h>
41
42#include <stdbool.h>
43#include <stddef.h>
44#include <stdint.h>
45
46#define CTRL_PIPE_MIN_PACKET_SIZE 8
47
48/** Abstraction of a logical connection to USB device endpoint.
49 * It contains some vital information about the pipe.
50 * This endpoint must be bound with existing usb_device_connection_t
51 * (i.e. the wire to send data over).
52 */
53typedef struct {
54 /** Pipe description received from HC */
55 usb_pipe_desc_t desc;
56
57 /** Whether to automatically reset halt on the endpoint.
58 * Valid only for control endpoint zero.
59 */
60 bool auto_reset_halt;
61 /** The connection used for sending the data. */
62 usb_dev_session_t *bus_session;
63} usb_pipe_t;
64
65/** Description of endpoint characteristics. */
66typedef struct {
67 /** Transfer type (e.g. control or interrupt). */
68 usb_transfer_type_t transfer_type;
69 /** Transfer direction (to or from a device). */
70 usb_direction_t direction;
71 /** Interface class this endpoint belongs to (-1 for any). */
72 int interface_class;
73 /** Interface subclass this endpoint belongs to (-1 for any). */
74 int interface_subclass;
75 /** Interface protocol this endpoint belongs to (-1 for any). */
76 int interface_protocol;
77 /** Extra endpoint flags. */
78 unsigned int flags;
79} usb_endpoint_description_t;
80
81/** Mapping of endpoint pipes and endpoint descriptions. */
82typedef struct {
83 /** Endpoint pipe. */
84 usb_pipe_t pipe;
85 /** Endpoint description. */
86 const usb_endpoint_description_t *description;
87 /** Interface number the endpoint must belong to (-1 for any). */
88 int interface_no;
89 /** Alternate interface setting to choose. */
90 int interface_setting;
91 /** Found descriptor fitting the description. */
92 const usb_standard_endpoint_descriptor_t *descriptor;
93 /** Relevant superspeed companion descriptor. */
94 const usb_superspeed_endpoint_companion_descriptor_t *companion_descriptor;
95 /** Interface descriptor the endpoint belongs to. */
96 const usb_standard_interface_descriptor_t *interface;
97 /** Whether the endpoint was actually found. */
98 bool present;
99} usb_endpoint_mapping_t;
100
101errno_t usb_pipe_initialize(usb_pipe_t *, usb_dev_session_t *);
102errno_t usb_pipe_initialize_default_control(usb_pipe_t *, usb_dev_session_t *);
103
104errno_t usb_pipe_initialize_from_configuration(usb_endpoint_mapping_t *,
105 size_t, const uint8_t *, size_t, usb_dev_session_t *);
106
107errno_t usb_pipe_register(usb_pipe_t *, const usb_standard_endpoint_descriptor_t *, const usb_superspeed_endpoint_companion_descriptor_t *);
108errno_t usb_pipe_unregister(usb_pipe_t *);
109
110errno_t usb_pipe_read(usb_pipe_t *, void *, size_t, size_t *);
111errno_t usb_pipe_write(usb_pipe_t *, const void *, size_t);
112
113errno_t usb_pipe_read_dma(usb_pipe_t *, void *, void *, size_t, size_t *);
114errno_t usb_pipe_write_dma(usb_pipe_t *, void *, void *, size_t);
115
116errno_t usb_pipe_control_read(usb_pipe_t *, const void *, size_t,
117 void *, size_t, size_t *);
118errno_t usb_pipe_control_write(usb_pipe_t *, const void *, size_t,
119 const void *, size_t);
120
121void *usb_pipe_alloc_buffer(usb_pipe_t *, size_t);
122void usb_pipe_free_buffer(usb_pipe_t *, void *);
123#endif
124/**
125 * @}
126 */
Note: See TracBrowser for help on using the repository browser.