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

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since a53ed3a was b7fd2a0, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 7 years ago

Use errno_t in all uspace and kernel code.

Change type of every variable, parameter and return value that holds an
<errno.h> constant to either errno_t (the usual case), or sys_errno_t
(some places in kernel). This is for the purpose of self-documentation,
as well as for type-checking with a bit of type definition hackery.

Although this is a massive commit, it is a simple text replacement, and thus
is very easy to verify. Simply do the following:

`
git checkout <this commit's hash>
git reset HEAD
git add .
tools/srepl '\berrno_t\b' int
git add .
tools/srepl '\bsys_errno_t\b' sysarg_t
git reset
git diff
`

While this doesn't ensure that the replacements are correct, it does ensure
that the commit doesn't do anything except those replacements. Since errno_t
is typedef'd to int in the usual case (and sys_errno_t to sysarg_t), even if
incorrect, this commit cannot change behavior.

  • Property mode set to 100644
File size: 4.6 KB
RevLine 
[6865243c]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 */
[160b75e]28/** @addtogroup libusbdev
[6865243c]29 * @{
30 */
31/** @file
[d714945]32 * USB pipes representation.
[6865243c]33 */
[7d521e24]34#ifndef LIBUSBDEV_PIPES_H_
35#define LIBUSBDEV_PIPES_H_
[6865243c]36
[1a38701]37#include <usb/usb.h>
38#include <usb/descriptor.h>
[8582076]39#include <usb_iface.h>
[6865243c]40
[c01987c]41#include <stdbool.h>
[8d2dd7f2]42#include <stddef.h>
43#include <stdint.h>
[c01987c]44
[c804484]45#define CTRL_PIPE_MIN_PACKET_SIZE 8
[a6add7a]46/** Abstraction of a logical connection to USB device endpoint.
[bdb23c63]47 * It encapsulates endpoint attributes (transfer type etc.).
[6865243c]48 * This endpoint must be bound with existing usb_device_connection_t
49 * (i.e. the wire to send data over).
50 */
51typedef struct {
52 /** Endpoint number. */
53 usb_endpoint_t endpoint_no;
54
55 /** Endpoint transfer type. */
56 usb_transfer_type_t transfer_type;
57
58 /** Endpoint direction. */
59 usb_direction_t direction;
60
[25971d2]61 /** Maximum packet size for the endpoint. */
62 size_t max_packet_size;
63
[4e732f1a]64 /** Number of packets per frame/uframe.
65 * Only valid for HS INT and ISO transfers. All others should set to 1*/
66 unsigned packets;
67
[fa0f53b]68 /** Whether to automatically reset halt on the endpoint.
69 * Valid only for control endpoint zero.
70 */
71 bool auto_reset_halt;
[8582076]72
[d93f5afb]73 /** The connection used for sending the data. */
[8582076]74 usb_dev_session_t *bus_session;
[a372663]75} usb_pipe_t;
[6865243c]76
[93ef8f6]77/** Description of endpoint characteristics. */
78typedef struct {
79 /** Transfer type (e.g. control or interrupt). */
80 usb_transfer_type_t transfer_type;
81 /** Transfer direction (to or from a device). */
82 usb_direction_t direction;
83 /** Interface class this endpoint belongs to (-1 for any). */
84 int interface_class;
85 /** Interface subclass this endpoint belongs to (-1 for any). */
86 int interface_subclass;
[1110ebd]87 /** Interface protocol this endpoint belongs to (-1 for any). */
[93ef8f6]88 int interface_protocol;
89 /** Extra endpoint flags. */
90 unsigned int flags;
91} usb_endpoint_description_t;
92
93/** Mapping of endpoint pipes and endpoint descriptions. */
94typedef struct {
95 /** Endpoint pipe. */
[b77931d]96 usb_pipe_t pipe;
[93ef8f6]97 /** Endpoint description. */
98 const usb_endpoint_description_t *description;
[18cb870]99 /** Interface number the endpoint must belong to (-1 for any). */
[6105fc0]100 int interface_no;
[159b91f4]101 /** Alternate interface setting to choose. */
102 int interface_setting;
[93ef8f6]103 /** Found descriptor fitting the description. */
[b77931d]104 const usb_standard_endpoint_descriptor_t *descriptor;
[a6add7a]105 /** Interface descriptor the endpoint belongs to. */
[b77931d]106 const usb_standard_interface_descriptor_t *interface;
[93ef8f6]107 /** Whether the endpoint was actually found. */
108 bool present;
109} usb_endpoint_mapping_t;
[6865243c]110
[b7fd2a0]111errno_t usb_pipe_initialize(usb_pipe_t *, usb_endpoint_t, usb_transfer_type_t,
[4e732f1a]112 size_t, usb_direction_t, unsigned, usb_dev_session_t *);
[b7fd2a0]113errno_t usb_pipe_initialize_default_control(usb_pipe_t *, usb_dev_session_t *);
[bd575647]114
[b7fd2a0]115errno_t usb_pipe_probe_default_control(usb_pipe_t *);
116errno_t usb_pipe_initialize_from_configuration(usb_endpoint_mapping_t *,
[d93f5afb]117 size_t, const uint8_t *, size_t, usb_dev_session_t *);
[c804484]118
[b7fd2a0]119errno_t usb_pipe_register(usb_pipe_t *, unsigned);
120errno_t usb_pipe_unregister(usb_pipe_t *);
[6865243c]121
[b7fd2a0]122errno_t usb_pipe_read(usb_pipe_t *, void *, size_t, size_t *);
123errno_t usb_pipe_write(usb_pipe_t *, const void *, size_t);
[6865243c]124
[b7fd2a0]125errno_t usb_pipe_control_read(usb_pipe_t *, const void *, size_t,
[6865243c]126 void *, size_t, size_t *);
[b7fd2a0]127errno_t usb_pipe_control_write(usb_pipe_t *, const void *, size_t,
[3875af65]128 const void *, size_t);
[6865243c]129
130#endif
131/**
132 * @}
133 */
Note: See TracBrowser for help on using the repository browser.