source: mainline/uspace/drv/usbhid/descdump.c@ 5d4d98b

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

Merge mainline changes (DDF refactoring)

This merge includes DDF refactoring that brought multifunctional devices
(i.e. ddf_dev_t and ddf_fun_t). Please, see ticket #295 at HelenOS
upstream Trac.

The conflicts themselves were easy to solve (merely several renamings).

Changes to USB subsystem:

  • drivers uses ddf_dev_t and ddf_fun_t
  • different signatures of many library functions
  • several hacks around communication with parent device (now the communication is clearer and somehow what we have now is hack about other hacks)
    • will repair and clean later
  • maybe added some extra debugging messages (the diff has about 240K, and I admit I have no energy to double check that)

WARNING:

  • the diff is VERY long, recommended is viewing partial diffs of the merge (i.e. merges in mainline branch that lead to the parent one)
  • merging with your branches might involve huge renamings, sorry, no other way is possible

BUGS:

  • hub driver will not work (no function created)

GOOD NEWS:

  • QEMU keyboard seems to work with QEMU 0.13 and 0.14
  • we are up-to-date with mainline again
  • Property mode set to 100644
File size: 5.4 KB
Line 
1/*
2 * Copyright (c) 2010 Lubos Slovak
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 drvusbhid
30 * @{
31 */
32/** @file
33 * Descriptor dumping.
34 */
35
36#include <usb/classes/hid.h>
37#include <stdio.h>
38#include <assert.h>
39
40#include "descdump.h"
41
42/*----------------------------------------------------------------------------*/
43
44#define BYTES_PER_LINE 12
45
46static void dump_buffer(const char *msg, const uint8_t *buffer, size_t length)
47{
48 printf("%s\n", msg);
49
50 size_t i;
51 for (i = 0; i < length; i++) {
52 printf(" 0x%02X", buffer[i]);
53 if (((i > 0) && (((i+1) % BYTES_PER_LINE) == 0))
54 || (i + 1 == length)) {
55 printf("\n");
56 }
57 }
58}
59
60/*----------------------------------------------------------------------------*/
61
62#define INDENT " "
63
64void dump_standard_configuration_descriptor(
65 int index, const usb_standard_configuration_descriptor_t *d)
66{
67 bool self_powered = d->attributes & 64;
68 bool remote_wakeup = d->attributes & 32;
69
70 printf("Standard configuration descriptor #%d\n", index);
71 printf(INDENT "bLength = %d\n", d->length);
72 printf(INDENT "bDescriptorType = 0x%02x\n", d->descriptor_type);
73 printf(INDENT "wTotalLength = %d\n", d->total_length);
74 printf(INDENT "bNumInterfaces = %d\n", d->interface_count);
75 printf(INDENT "bConfigurationValue = %d\n", d->configuration_number);
76 printf(INDENT "iConfiguration = %d\n", d->str_configuration);
77 printf(INDENT "bmAttributes = %d [%s%s%s]\n", d->attributes,
78 self_powered ? "self-powered" : "",
79 (self_powered & remote_wakeup) ? ", " : "",
80 remote_wakeup ? "remote-wakeup" : "");
81 printf(INDENT "MaxPower = %d (%dmA)\n", d->max_power,
82 2 * d->max_power);
83 // printf(INDENT " = %d\n", d->);
84}
85
86void dump_standard_interface_descriptor(
87 const usb_standard_interface_descriptor_t *d)
88{
89 printf("Standard interface descriptor\n");
90 printf(INDENT "bLength = %d\n", d->length);
91 printf(INDENT "bDescriptorType = 0x%02x\n", d->descriptor_type);
92 printf(INDENT "bInterfaceNumber = %d\n", d->interface_number);
93 printf(INDENT "bAlternateSetting = %d\n", d->alternate_setting);
94 printf(INDENT "bNumEndpoints = %d\n", d->endpoint_count);
95 printf(INDENT "bInterfaceClass = %d\n", d->interface_class);
96 printf(INDENT "bInterfaceSubClass = %d\n", d->interface_subclass);
97 printf(INDENT "bInterfaceProtocol = %d\n", d->interface_protocol);
98 printf(INDENT "iInterface = %d\n", d->str_interface);
99}
100
101void dump_standard_endpoint_descriptor(
102 const usb_standard_endpoint_descriptor_t *d)
103{
104 const char *transfer_type;
105 switch (d->attributes & 3) {
106 case USB_TRANSFER_CONTROL:
107 transfer_type = "control";
108 break;
109 case USB_TRANSFER_ISOCHRONOUS:
110 transfer_type = "isochronous";
111 break;
112 case USB_TRANSFER_BULK:
113 transfer_type = "bulk";
114 break;
115 case USB_TRANSFER_INTERRUPT:
116 transfer_type = "interrupt";
117 break;
118 }
119
120 printf("Standard endpoint descriptor\n");
121 printf(INDENT "bLength = %d\n", d->length);
122 printf(INDENT "bDescriptorType = 0x%02x\n", d->descriptor_type);
123 printf(INDENT "bmAttributes = %d [%s]\n", d->attributes, transfer_type);
124 printf(INDENT "wMaxPacketSize = %d\n", d->max_packet_size);
125 printf(INDENT "bInterval = %d\n", d->poll_interval);
126}
127
128void dump_standard_hid_descriptor_header(
129 const usb_standard_hid_descriptor_t *d)
130{
131 printf("Standard HID descriptor\n");
132 printf(INDENT "bLength = %d\n", d->length);
133 printf(INDENT "bDescriptorType = 0x%02x\n", d->descriptor_type);
134 printf(INDENT "bcdHID = %d\n", d->spec_release);
135 printf(INDENT "bCountryCode = %d\n", d->country_code);
136 printf(INDENT "bNumDescriptors = %d\n", d->class_desc_count);
137 printf(INDENT "bDescriptorType = %d\n", d->report_desc_info.type);
138 printf(INDENT "wDescriptorLength = %d\n", d->report_desc_info.length);
139}
140
141void dump_standard_hid_class_descriptor_info(
142 const usb_standard_hid_class_descriptor_info_t *d)
143{
144 printf(INDENT "bDescriptorType = %d\n", d->type);
145 printf(INDENT "wDescriptorLength = %d\n", d->length);
146}
147
148void dump_hid_class_descriptor(int index, uint8_t type,
149 const uint8_t *d, size_t size )
150{
151 printf("Class-specific descriptor #%d (type: %u)\n", index, type);
152 assert(d != NULL);
153 dump_buffer("", d, size);
154}
155
156/**
157 * @}
158 */
159
Note: See TracBrowser for help on using the repository browser.