Changeset b4b534ac in mainline for uspace/lib/usbvirt/src/stdreq.c


Ignore:
Timestamp:
2016-07-22T08:24:47Z (8 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f76d2c2
Parents:
5b18137 (diff), 8351f9a4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge from lp:~jan.vesely/helenos/usb

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbvirt/src/stdreq.c

    r5b18137 rb4b534ac  
    5151void usbvirt_control_reply_helper(const usb_device_request_setup_packet_t *setup_packet,
    5252    uint8_t *data, size_t *act_size,
    53     void *actual_data, size_t actual_data_size)
     53    const void *actual_data, size_t actual_data_size)
    5454{
    5555        size_t expected_size = setup_packet->length;
     
    6363                *act_size = actual_data_size;
    6464        }
     65}
     66
     67/** NOP handler */
     68int req_nop(usbvirt_device_t *device,
     69    const usb_device_request_setup_packet_t *setup_packet,
     70    uint8_t *data, size_t *act_size)
     71{
     72        return EOK;
    6573}
    6674
     
    98106                }
    99107                /* Copy the data. */
    100                 usbvirt_device_configuration_t *config = &device->descriptors
    101                     ->configuration[index];
     108                const usbvirt_device_configuration_t *config =
     109                    &device->descriptors->configuration[index];
    102110                uint8_t *all_data = malloc(config->descriptor->total_length);
    103111                if (all_data == NULL) {
     
    110118                size_t i;
    111119                for (i = 0; i < config->extra_count; i++) {
    112                         usbvirt_device_configuration_extras_t *extra
     120                        const usbvirt_device_configuration_extras_t *extra
    113121                            = &config->extra[i];
    114122                        memcpy(ptr, extra->data, extra->length);
     
    189197}
    190198
     199static int req_get_dev_status(usbvirt_device_t *device,
     200    const usb_device_request_setup_packet_t *setup_packet, uint8_t *data, size_t *act_size)
     201{
     202        if (setup_packet->length != 2)
     203                return ESTALL;
     204        data[0] = (device->self_powered ? 1 : 0) | (device->remote_wakeup ? 2 : 0);
     205        data[1] = 0;
     206        *act_size = 2;
     207        return EOK;
     208}
     209static int req_get_iface_ep_status(usbvirt_device_t *device,
     210    const usb_device_request_setup_packet_t *setup_packet, uint8_t *data, size_t *act_size)
     211{
     212        if (setup_packet->length != 2)
     213                return ESTALL;
     214        data[0] = 0;
     215        data[1] = 0;
     216        *act_size = 2;
     217        return EOK;
     218}
     219
    191220/** Standard request handlers. */
    192221usbvirt_control_request_handler_t library_handlers[] = {
    193222        {
    194                 .req_direction = USB_DIRECTION_OUT,
    195                 .req_recipient = USB_REQUEST_RECIPIENT_DEVICE,
    196                 .req_type = USB_REQUEST_TYPE_STANDARD,
    197                 .request = USB_DEVREQ_SET_ADDRESS,
     223                STD_REQ_OUT(USB_REQUEST_RECIPIENT_DEVICE, USB_DEVREQ_SET_ADDRESS),
    198224                .name = "SetAddress",
    199225                .callback = req_set_address
    200226        },
    201227        {
    202                 .req_direction = USB_DIRECTION_IN,
    203                 .req_recipient = USB_REQUEST_RECIPIENT_DEVICE,
    204                 .req_type = USB_REQUEST_TYPE_STANDARD,
    205                 .request = USB_DEVREQ_GET_DESCRIPTOR,
    206                 .name = "GetDescriptor",
     228                STD_REQ_IN(USB_REQUEST_RECIPIENT_DEVICE, USB_DEVREQ_GET_DESCRIPTOR),
     229                .name = "GetStdDescriptor",
    207230                .callback = req_get_descriptor
    208231        },
    209232        {
    210                 .req_direction = USB_DIRECTION_OUT,
    211                 .req_recipient = USB_REQUEST_RECIPIENT_DEVICE,
    212                 .req_type = USB_REQUEST_TYPE_STANDARD,
    213                 .request = USB_DEVREQ_SET_CONFIGURATION,
     233                STD_REQ_OUT(USB_REQUEST_RECIPIENT_DEVICE, USB_DEVREQ_SET_CONFIGURATION),
    214234                .name = "SetConfiguration",
    215235                .callback = req_set_configuration
    216236        },
    217 
     237        {
     238                STD_REQ_IN(USB_REQUEST_RECIPIENT_DEVICE, USB_DEVREQ_GET_STATUS),
     239                .name = "GetDeviceStatus",
     240                .callback = req_get_dev_status,
     241        },
     242        {
     243                STD_REQ_IN(USB_REQUEST_RECIPIENT_INTERFACE, USB_DEVREQ_GET_STATUS),
     244                .name = "GetInterfaceStatus",
     245                .callback = req_get_iface_ep_status,
     246        },
     247        {
     248                /* virtual EPs by default cannot be stalled */
     249                STD_REQ_IN(USB_REQUEST_RECIPIENT_ENDPOINT, USB_DEVREQ_GET_STATUS),
     250                .name = "GetEndpointStatus",
     251                .callback = req_get_iface_ep_status,
     252        },
    218253        { .callback = NULL }
    219254};
Note: See TracChangeset for help on using the changeset viewer.