[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.
|
---|
| 34 | */
|
---|
| 35 |
|
---|
| 36 | #ifndef LIBUSBVIRT_VIRTHUB_BASE_H_
|
---|
| 37 | #define LIBUSBVIRT_VIRTHUB_BASE_H_
|
---|
| 38 |
|
---|
| 39 | #include <usbvirt/device.h>
|
---|
| 40 | #include <usb/classes/hub.h>
|
---|
| 41 |
|
---|
| 42 | enum {
|
---|
| 43 | VIRTHUB_EXTR_DESC = 3,
|
---|
| 44 | };
|
---|
| 45 |
|
---|
| 46 | typedef struct {
|
---|
| 47 | usb_standard_configuration_descriptor_t config_descriptor;
|
---|
[2a5a7711] | 48 | usb_standard_endpoint_descriptor_t endpoint_descriptor;
|
---|
[32c2c8f] | 49 | usbvirt_device_configuration_extras_t extra[VIRTHUB_EXTR_DESC];
|
---|
| 50 | usbvirt_device_configuration_t configuration;
|
---|
| 51 | usbvirt_descriptors_t descriptors;
|
---|
| 52 | usbvirt_device_t device;
|
---|
| 53 | void *data;
|
---|
| 54 | } virthub_base_t;
|
---|
| 55 |
|
---|
| 56 | void *virthub_get_data(usbvirt_device_t *dev);
|
---|
| 57 |
|
---|
[b7fd2a0] | 58 | errno_t virthub_base_init(virthub_base_t *instance,
|
---|
[32c2c8f] | 59 | const char *name, usbvirt_device_ops_t *ops, void *data,
|
---|
| 60 | const usb_standard_device_descriptor_t *device_desc,
|
---|
[49f2f29] | 61 | const usb_hub_descriptor_header_t *hub_desc, usb_endpoint_t ep);
|
---|
[32c2c8f] | 62 |
|
---|
| 63 | usb_address_t virthub_base_get_address(virthub_base_t *instance);
|
---|
| 64 |
|
---|
[b7fd2a0] | 65 | errno_t virthub_base_request(virthub_base_t *instance, usb_target_t target,
|
---|
[32c2c8f] | 66 | usb_direction_t dir, const usb_device_request_setup_packet_t *setup,
|
---|
| 67 | void *buffer, size_t buffer_size, size_t *real_size);
|
---|
| 68 |
|
---|
[b7fd2a0] | 69 | errno_t virthub_base_get_hub_descriptor(usbvirt_device_t *dev,
|
---|
[32c2c8f] | 70 | const usb_device_request_setup_packet_t *request, uint8_t *data,
|
---|
| 71 | size_t *act_size);
|
---|
[b7fd2a0] | 72 | errno_t virthub_base_get_null_status(usbvirt_device_t *dev,
|
---|
[32c2c8f] | 73 | const usb_device_request_setup_packet_t *request, uint8_t *data,
|
---|
| 74 | size_t *act_size);
|
---|
| 75 |
|
---|
| 76 | #endif
|
---|
| 77 |
|
---|
| 78 | /**
|
---|
| 79 | * @}
|
---|
| 80 | */
|
---|