source: mainline/uspace/lib/usbdev/include/usb/dev/dp.h

Last change on this file was 8d2dd7f2, checked in by Jakub Jermar <jakub@…>, 8 years ago

Reduce the number of files that include <sys/types.h>

  • Property mode set to 100644
File size: 2.9 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 libusbdev
30 * @{
31 */
32/** @file
33 * USB descriptor parser.
34 */
35#ifndef LIBUSBDEV_DP_H_
36#define LIBUSBDEV_DP_H_
37
38#include <stddef.h>
39#include <stdint.h>
40
41/** USB descriptors nesting.
42 * The nesting describes the logical tree USB descriptors form
43 * (e.g. that endpoint descriptor belongs to interface or that
44 * interface belongs to configuration).
45 *
46 * See usb_descriptor_type_t for descriptor constants.
47 */
48typedef struct {
49 /** Child descriptor id. */
50 int child;
51 /** Parent descriptor id. */
52 int parent;
53} usb_dp_descriptor_nesting_t;
54
55extern const usb_dp_descriptor_nesting_t usb_dp_standard_descriptor_nesting[];
56
57/** Descriptor parser structure. */
58typedef struct {
59 /** Used descriptor nesting. */
60 const usb_dp_descriptor_nesting_t *nesting;
61} usb_dp_parser_t;
62
63/** Descriptor parser data. */
64typedef struct {
65 /** Data to be parsed. */
66 const uint8_t *data;
67 /** Size of input data in bytes. */
68 size_t size;
69 /** Custom argument. */
70 void *arg;
71} usb_dp_parser_data_t;
72
73typedef void (*walk_callback_t)(const uint8_t *, size_t, void *);
74
75const uint8_t *usb_dp_get_nested_descriptor(const usb_dp_parser_t *,
76 const usb_dp_parser_data_t *, const uint8_t *);
77const uint8_t *usb_dp_get_sibling_descriptor(const usb_dp_parser_t *,
78 const usb_dp_parser_data_t *, const uint8_t *, const uint8_t *);
79
80void usb_dp_walk_simple(const uint8_t *, size_t,
81 const usb_dp_descriptor_nesting_t *, walk_callback_t, void *);
82
83#endif
84/**
85 * @}
86 */
Note: See TracBrowser for help on using the repository browser.