source: mainline/uspace/lib/usbvirt/src/virthub_descriptors.c@ d93f5afb

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since d93f5afb was 2a5a7711, checked in by Jan Vesely <jano.vesely@…>, 12 years ago

libusbvirt, virthub: Allow drivers to set endpoint number and port count.

Using smaller max_packet_size reduces bandwidth requirements.

  • Property mode set to 100644
File size: 3.5 KB
RevLine 
[32c2c8f]1/*
2 * Copyright (c) 2013 Jan Vesely
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 libusbvirt
30 * @{
31 */
32/** @file
33 * Virtual USB device main routines.
34 */
35
36#include <usb/classes/classes.h>
37#include <usb/classes/hub.h>
38#include <usb/descriptor.h>
39#include <usb/usb.h>
40#include <usbvirt/device.h>
41
42#include "virthub_base.h"
43
44#define HUB_CONFIGURATION_ID 1
45
46/** Standard device descriptor. */
47const usb_standard_device_descriptor_t virthub_device_descriptor = {
48 .length = sizeof(usb_standard_device_descriptor_t),
49 .descriptor_type = USB_DESCTYPE_DEVICE,
50 .usb_spec_version = 0x110,
51 .device_class = USB_CLASS_HUB,
52 .device_subclass = 0,
53 .device_protocol = 0,
54 .max_packet_size = 64,
55 .configuration_count = 1
56};
57
58
59/** Standard interface descriptor. */
60const usb_standard_interface_descriptor_t virthub_interface_descriptor = {
61 .length = sizeof(usb_standard_interface_descriptor_t),
62 .descriptor_type = USB_DESCTYPE_INTERFACE,
63 .interface_number = 0,
64 .alternate_setting = 0,
65 .endpoint_count = 1,
66 .interface_class = USB_CLASS_HUB,
67 .interface_subclass = 0,
68 .interface_protocol = 0,
69 .str_interface = 0
70};
71
72/** Endpoint descriptor. */
73const usb_standard_endpoint_descriptor_t virthub_endpoint_descriptor = {
74 .length = sizeof(usb_standard_endpoint_descriptor_t),
75 .descriptor_type = USB_DESCTYPE_ENDPOINT,
[2a5a7711]76 .endpoint_address = 1 | 128,
[32c2c8f]77 .attributes = USB_TRANSFER_INTERRUPT,
78 .max_packet_size = 8,
79 .poll_interval = 0xFF,
80};
81
82/** Standard configuration descriptor. */
83const usb_standard_configuration_descriptor_t virthub_configuration_descriptor_without_hub_size = {
84 .length = sizeof(virthub_configuration_descriptor_without_hub_size),
85 .descriptor_type = USB_DESCTYPE_CONFIGURATION,
86 .total_length =
87 sizeof(virthub_configuration_descriptor_without_hub_size)
88 + sizeof(virthub_interface_descriptor)
89 + sizeof(virthub_endpoint_descriptor)
90 ,
91 .interface_count = 1,
92 .configuration_number = HUB_CONFIGURATION_ID,
93 .str_configuration = 0,
94 .attributes = 0, /* We are self-powered device */
95 .max_power = 0,
96};
97
98const usbvirt_device_configuration_extras_t virthub_interface_descriptor_ex = {
99 .data = (uint8_t *) &virthub_interface_descriptor,
100 .length = sizeof(virthub_interface_descriptor),
101};
102
103
104/**
105 * @}
106 */
Note: See TracBrowser for help on using the repository browser.