Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset bc02b83 in mainline


Ignore:
Timestamp:
2011-05-07T09:59:39Z (11 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master
Children:
6fb003e, 7ab7c7f6, d38d830
Parents:
f90c0d6 (diff), beee81a (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:

Virtual USB improvements

Files:
3 added
10 deleted
14 edited
2 moved

Legend:

Unmodified
Added
Removed
  • boot/Makefile.common

    rf90c0d6 rbc02b83  
    140140        $(USPACE_PATH)/app/stats/stats \
    141141        $(USPACE_PATH)/app/sysinfo/sysinfo \
    142         $(USPACE_PATH)/app/tasks/tasks \
    143142        $(USPACE_PATH)/app/top/top \
    144143        $(USPACE_PATH)/app/usbinfo/usbinfo \
    145         $(USPACE_PATH)/app/virtusbkbd/vuk \
    146144        $(USPACE_PATH)/app/vuhid/vuh \
    147145        $(USPACE_PATH)/app/websrv/websrv
  • uspace/Makefile

    rf90c0d6 rbc02b83  
    5151        app/top \
    5252        app/usbinfo \
    53         app/virtusbkbd \
    5453        app/vuhid \
    5554        app/netecho \
  • uspace/app/vuhid/device.c

    rf90c0d6 rbc02b83  
    7777{
    7878        vuhid_interface_t *iface = arg;
     79        vuhid_data_t *hid_data = iface->vuhid_data;
    7980
    8081        if (iface->live != NULL) {
    8182                iface->live(iface);
    8283        }
     84
     85        fibril_mutex_lock(&hid_data->iface_count_mutex);
     86        hid_data->iface_died_count++;
     87        fibril_condvar_broadcast(&hid_data->iface_count_cv);
     88        fibril_mutex_unlock(&hid_data->iface_count_mutex);
    8389
    8490        return EOK;
     
    110116        if ((iface->in_data_size == 0) && (iface->out_data_size == 0)) {
    111117                return EEMPTY;
     118        }
     119
     120        // FIXME - we shall set vuhid_data to NULL in the main() rather
     121        // than to depend on individual interfaces
     122        /* Already used interface. */
     123        if (iface->vuhid_data != NULL) {
     124                return EEXISTS;
    112125        }
    113126
     
    252265
    253266        /* Launch the "life" fibril. */
     267        iface->vuhid_data = hid_data;
    254268        fid_t life_fibril = fibril_create(interface_life_fibril, iface);
    255269        if (life_fibril == 0) {
     
    310324            += total_descr_size;
    311325
     326        hid_data->iface_count++;
    312327        fibril_add_ready(life_fibril);
    313328
     
    331346}
    332347
     348void wait_for_interfaces_death(usbvirt_device_t *dev)
     349{
     350        vuhid_data_t *hid_data = dev->device_data;
     351
     352        fibril_mutex_lock(&hid_data->iface_count_mutex);
     353        while (hid_data->iface_died_count < hid_data->iface_count) {
     354                fibril_condvar_wait(&hid_data->iface_count_cv,
     355                    &hid_data->iface_count_mutex);
     356        }
     357        fibril_mutex_unlock(&hid_data->iface_count_mutex);
     358}
    333359
    334360/** @}
  • uspace/app/vuhid/hids/bootkbd.c

    rf90c0d6 rbc02b83  
    3939#include <usb/classes/hidut.h>
    4040
    41 #include "../../virtusbkbd/report.h"
     41#include "../report.h"
    4242
    4343uint8_t report_descriptor[] = {
     
    169169        .on_data_out = on_data_out,
    170170
    171         .live = live
     171        .live = live,
     172
     173        .vuhid_data = NULL
    172174};
    173175
  • uspace/app/vuhid/main.c

    rf90c0d6 rbc02b83  
    132132        .in_endpoint_first_free = 1,
    133133        .out_endpoints_mapping = { NULL },
    134         .out_endpoint_first_free = 1
    135 };
     134        .out_endpoint_first_free = 1,
     135
     136        .iface_count = 0,
     137        .iface_died_count = 0
     138        // mutex and CV must be initialized elsewhere
     139};
     140
    136141
    137142/** Keyboard device.
     
    151156
    152157        usb_log_enable(USB_LOG_LEVEL_DEBUG2, "vusbhid");
     158
     159        fibril_mutex_initialize(&vuhid_data.iface_count_mutex);
     160        fibril_condvar_initialize(&vuhid_data.iface_count_cv);
    153161
    154162        /* Determine which interfaces to initialize. */
     
    182190        printf("Connected to VHCD...\n");
    183191
    184         while (true) {
    185                 async_usleep(10 * 1000 * 1000);
    186         }
     192        wait_for_interfaces_death(&hid_dev);
    187193       
    188194        printf("Terminating...\n");
    189195       
     196        usbvirt_device_unplug(&hid_dev);
     197
    190198        return 0;
    191199}
  • uspace/app/vuhid/virthid.h

    rf90c0d6 rbc02b83  
    3838#include <usb/usb.h>
    3939#include <usbvirt/device.h>
     40#include <fibril_synch.h>
    4041
    4142#define VUHID_ENDPOINT_MAX USB11_ENDPOINT_MAX
     
    4344
    4445typedef struct vuhid_interface vuhid_interface_t;
     46
     47typedef struct {
     48        vuhid_interface_t *in_endpoints_mapping[VUHID_ENDPOINT_MAX];
     49        size_t in_endpoint_first_free;
     50        vuhid_interface_t *out_endpoints_mapping[VUHID_ENDPOINT_MAX];
     51        size_t out_endpoint_first_free;
     52        vuhid_interface_t *interface_mapping[VUHID_INTERFACE_MAX];
     53
     54        fibril_mutex_t iface_count_mutex;
     55        fibril_condvar_t iface_count_cv;
     56        size_t iface_count;
     57        size_t iface_died_count;
     58} vuhid_data_t;
    4559
    4660struct vuhid_interface {
     
    6377
    6478        void *interface_data;
     79
     80        vuhid_data_t *vuhid_data;
    6581};
    66 
    67 typedef struct {
    68         vuhid_interface_t *in_endpoints_mapping[VUHID_ENDPOINT_MAX];
    69         size_t in_endpoint_first_free;
    70         vuhid_interface_t *out_endpoints_mapping[VUHID_ENDPOINT_MAX];
    71         size_t out_endpoint_first_free;
    72         vuhid_interface_t *interface_mapping[VUHID_INTERFACE_MAX];
    73 } vuhid_data_t;
    7482
    7583typedef struct {
     
    8492
    8593int add_interface_by_id(vuhid_interface_t **, const char *, usbvirt_device_t *);
     94void wait_for_interfaces_death(usbvirt_device_t *);
    8695
    8796#endif
  • uspace/drv/vhc/transfer.c

    rf90c0d6 rbc02b83  
    135135                if (transfer->direction == USB_DIRECTION_IN) {
    136136                        rc = usbvirt_ipc_send_control_read(phone,
    137                             transfer->endpoint,
    138137                            transfer->setup_buffer, transfer->setup_buffer_size,
    139138                            transfer->data_buffer, transfer->data_buffer_size,
     
    142141                        assert(transfer->direction == USB_DIRECTION_OUT);
    143142                        rc = usbvirt_ipc_send_control_write(phone,
    144                             transfer->endpoint,
    145143                            transfer->setup_buffer, transfer->setup_buffer_size,
    146144                            transfer->data_buffer, transfer->data_buffer_size);
  • uspace/lib/usbvirt/Makefile

    rf90c0d6 rbc02b83  
    3333
    3434SOURCES = \
    35         src/ipc.c \
    3635        src/ctrltransfer.c \
     36        src/device.c \
     37        src/ipc_dev.c \
     38        src/ipc_hc.c \
    3739        src/stdreq.c \
    3840        src/transfer.c
  • uspace/lib/usbvirt/include/usbvirt/device.h

    rf90c0d6 rbc02b83  
    3131 */
    3232/** @file
    33  * @brief Virtual USB device.
     33 * Virtual USB device.
    3434 */
    3535#ifndef LIBUSBVIRT_DEVICE_H_
     
    3939#include <usb/request.h>
    4040
     41/** Maximum number of endpoints supported by virtual USB. */
    4142#define USBVIRT_ENDPOINT_MAX 16
    4243
    4344typedef struct usbvirt_device usbvirt_device_t;
    4445
    45 typedef int (*usbvirt_on_data_to_device_t)(usbvirt_device_t *, usb_endpoint_t,
    46     usb_transfer_type_t, void *, size_t);
    47 typedef int (*usbvirt_on_data_from_device_t)(usbvirt_device_t *, usb_endpoint_t,
    48     usb_transfer_type_t, void *, size_t, size_t *);
    49 typedef int (*usbvirt_on_control_t)(usbvirt_device_t *,
    50     const usb_device_request_setup_packet_t *, uint8_t *, size_t *);
    51 
    52 typedef struct {
     46/** Callback for data to device (OUT transaction).
     47 *
     48 * @param dev Virtual device to which the transaction belongs.
     49 * @param endpoint Target endpoint number.
     50 * @param transfer_type Transfer type.
     51 * @param buffer Data buffer.
     52 * @param buffer_size Size of the buffer in bytes.
     53 * @return Error code.
     54 */
     55typedef int (*usbvirt_on_data_to_device_t)(usbvirt_device_t *dev,
     56    usb_endpoint_t endpoint, usb_transfer_type_t transfer_type,
     57    void *buffer, size_t buffer_size);
     58
     59/** Callback for data from device (IN transaction).
     60 *
     61 * @param dev Virtual device to which the transaction belongs.
     62 * @param endpoint Target endpoint number.
     63 * @param transfer_type Transfer type.
     64 * @param buffer Data buffer to write answer to.
     65 * @param buffer_size Size of the buffer in bytes.
     66 * @param act_buffer_size Write here how many bytes were actually written.
     67 * @return Error code.
     68 */
     69typedef int (*usbvirt_on_data_from_device_t)(usbvirt_device_t *dev,
     70    usb_endpoint_t endpoint, usb_transfer_type_t transfer_type,
     71    void *buffer, size_t buffer_size, size_t *act_buffer_size);
     72
     73/** Callback for control transfer on endpoint zero.
     74 *
     75 * Notice that size of the data buffer is expected to be read from the
     76 * setup packet.
     77 *
     78 * @param dev Virtual device to which the transaction belongs.
     79 * @param setup_packet Standard setup packet.
     80 * @param data Data (might be NULL).
     81 * @param act_data_size Size of returned data in bytes.
     82 * @return Error code.
     83 */
     84typedef int (*usbvirt_on_control_t)(usbvirt_device_t *dev,
     85    const usb_device_request_setup_packet_t *setup_packet,
     86    uint8_t *data, size_t *act_data_size);
     87
     88/** Callback for control request on a virtual USB device.
     89 *
     90 * See usbvirt_control_reply_helper() for simple way of answering
     91 * control read requests.
     92 */
     93typedef struct {
     94        /** Request direction (in or out). */
    5395        usb_direction_t req_direction;
     96        /** Request recipient (device, interface or endpoint). */
    5497        usb_request_recipient_t req_recipient;
     98        /** Request type (standard, class or vendor). */
    5599        usb_request_type_t req_type;
     100        /** Actual request code. */
    56101        uint8_t request;
     102        /** Request handler name for debugging purposes. */
    57103        const char *name;
     104        /** Callback to be executed on matching request. */
    58105        usbvirt_on_control_t callback;
    59106} usbvirt_control_request_handler_t;
     
    77124} usbvirt_device_configuration_t;
    78125
    79 /** Standard USB descriptors. */
     126/** Standard USB descriptors for virtual device. */
    80127typedef struct {
    81128        /** Standard device descriptor.
     
    102149} usbvirt_device_state_t;
    103150
    104 typedef struct {
     151/** Ops structure for virtual USB device. */
     152typedef struct {
     153        /** Callbacks for data to device.
     154         * Index zero is ignored.
     155         */
    105156        usbvirt_on_data_to_device_t data_out[USBVIRT_ENDPOINT_MAX];
     157        /** Callbacks for data from device.
     158         * Index zero is ignored.
     159         */
    106160        usbvirt_on_data_from_device_t data_in[USBVIRT_ENDPOINT_MAX];
     161        /** Array of control handlers.
     162         * Last handler is expected to have the @c callback field set to NULL
     163         */
    107164        usbvirt_control_request_handler_t *control;
     165        /** Callback when device changes state.
     166         *
     167         * The value of @c state attribute of @p dev device is not
     168         * defined during call of this function.
     169         *
     170         * @param dev The virtual USB device.
     171         * @param old_state Old device state.
     172         * @param new_state New device state.
     173         */
    108174        void (*state_changed)(usbvirt_device_t *dev,
    109175            usbvirt_device_state_t old_state, usbvirt_device_state_t new_state);
    110176} usbvirt_device_ops_t;
    111177
     178/** Virtual USB device. */
    112179struct usbvirt_device {
     180        /** Name for debugging purposes. */
    113181        const char *name;
     182        /** Custom device data. */
    114183        void *device_data;
     184        /** Device ops. */
    115185        usbvirt_device_ops_t *ops;
     186        /** Device descriptors. */
    116187        usbvirt_descriptors_t *descriptors;
     188        /** Current device address.
     189         * You shall treat this field as read only in your code.
     190         */
    117191        usb_address_t address;
     192        /** Current device state.
     193         * You shall treat this field as read only in your code.
     194         */
    118195        usbvirt_device_state_t state;
     196        /** Phone to the host controller.
     197         * You shall treat this field as read only in your code.
     198         */
     199        int vhc_phone;
    119200};
    120201
    121202int usbvirt_device_plug(usbvirt_device_t *, const char *);
     203void usbvirt_device_unplug(usbvirt_device_t *);
    122204
    123205void usbvirt_control_reply_helper(const usb_device_request_setup_packet_t *,
  • uspace/lib/usbvirt/include/usbvirt/ipc.h

    rf90c0d6 rbc02b83  
    11/*
    2  * Copyright (c) 2010 Vojtech Horky
     2 * Copyright (c) 2011 Vojtech Horky
    33 * All rights reserved.
    44 *
     
    3131 */
    3232/** @file
    33  * @brief Virtual USB device.
     33 * IPC wrappers for virtual USB.
    3434 */
    3535#ifndef LIBUSBVIRT_IPC_H_
     
    4040#include <bool.h>
    4141
     42/** IPC methods communication between host controller and virtual device. */
    4243typedef enum {
    4344        IPC_M_USBVIRT_GET_NAME = IPC_FIRST_USER_METHOD + 80,
     
    4546        IPC_M_USBVIRT_CONTROL_WRITE,
    4647        IPC_M_USBVIRT_INTERRUPT_IN,
    47         IPC_M_USBVIRT_INTERRUPT_OUT
    48 } usbvirt_ipc_t;
     48        IPC_M_USBVIRT_INTERRUPT_OUT,
     49        IPC_M_USBVIRT_BULK_IN,
     50        IPC_M_USBVIRT_BULK_OUT
     51} usbvirt_hc_to_device_method_t;
    4952
    50 int usbvirt_ipc_send_control_read(int, usb_endpoint_t, void *, size_t,
     53int usbvirt_ipc_send_control_read(int, void *, size_t,
    5154    void *, size_t, size_t *);
    52 int usbvirt_ipc_send_control_write(int, usb_endpoint_t, void *, size_t,
     55int usbvirt_ipc_send_control_write(int, void *, size_t,
    5356    void *, size_t);
    5457int usbvirt_ipc_send_data_in(int, usb_endpoint_t, usb_transfer_type_t,
  • uspace/lib/usbvirt/src/ctrltransfer.c

    rf90c0d6 rbc02b83  
     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 libusbvirt
     30 * @{
     31 */
     32/** @file
     33 * Control transfer handling.
     34 */
    135#include "private.h"
    236#include <usb/request.h>
     
    539#include <errno.h>
    640
     41/** Find and execute control transfer handler for virtual USB device.
     42 *
     43 * @param dev Target virtual device.
     44 * @param control_handlers Array of control request handlers.
     45 * @param setup Setup packet.
     46 * @param data Extra data.
     47 * @param data_sent_size Size of extra data in bytes.
     48 * @return Error code.
     49 * @retval EFORWARD No suitable handler found.
     50 */
    751int process_control_transfer(usbvirt_device_t *dev,
    852    usbvirt_control_request_handler_t *control_handlers,
     
    5296        return EFORWARD;
    5397}
     98
     99
     100/**
     101 * @}
     102 */
  • uspace/lib/usbvirt/src/private.h

    rf90c0d6 rbc02b83  
     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 libusbvirt
     30 * @{
     31 */
     32/** @file
     33 * Private definitions.
     34 */
     35#ifndef USBVIRT_PRIVATE_H_
     36#define USBVIRT_PRIVATE_H_
     37
    138#include <usbvirt/device.h>
    239
     
    744
    845extern usbvirt_control_request_handler_t library_handlers[];
     46
     47#endif
     48/**
     49 * @}
     50 */
  • uspace/lib/usbvirt/src/stdreq.c

    rf90c0d6 rbc02b83  
     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 libusbvirt
     30 * @{
     31 */
     32/** @file
     33 * Standard control request handlers.
     34 */
    135#include "private.h"
    236#include <usb/request.h>
     
    438#include <errno.h>
    539
     40/** Helper for replying to control read transfer from virtual USB device.
     41 *
     42 * This function takes care of copying data to answer buffer taking care
     43 * of buffer sizes properly.
     44 *
     45 * @param setup_packet The setup packet.
     46 * @param data Data buffer to write to.
     47 * @param act_size Where to write actual size of returned data.
     48 * @param actual_data Data to be returned.
     49 * @param actual_data_size Size of answer data (@p actual_data) in bytes.
     50 */
    651void usbvirt_control_reply_helper(const usb_device_request_setup_packet_t *setup_packet,
    752    uint8_t *data, size_t *act_size,
     
    144189}
    145190
     191/** Standard request handlers. */
    146192usbvirt_control_request_handler_t library_handlers[] = {
    147193        {
     
    173219};
    174220
     221/**
     222 * @}
     223 */
  • uspace/lib/usbvirt/src/transfer.c

    rf90c0d6 rbc02b83  
    3131 */
    3232/** @file
    33  *
     33 * Transfer handling.
    3434 */
    3535#include <usbvirt/device.h>
     
    3939#include "private.h"
    4040
     41/** Process a control transfer to the virtual USB device.
     42 *
     43 * @param dev Target device.
     44 * @param setup Setup packet data.
     45 * @param setup_size Size of setup packet.
     46 * @param data Extra data (DATA stage).
     47 * @param data_size Size of extra data in bytes.
     48 * @param data_size_sent Number of actually send bytes during the transfer
     49 *      (only used for READ transfers).
     50 * @return Error code.
     51 */
    4152static int usbvirt_control_transfer(usbvirt_device_t *dev,
    4253    void *setup, size_t setup_size,
     
    7889}
    7990
     91/** Issue a control write transfer to virtual USB device.
     92 *
     93 * @see usbvirt_control_transfer
     94 *
     95 * @param dev Target virtual device.
     96 * @param setup Setup data.
     97 * @param setup_size Size of setup packet.
     98 * @param data Extra data (DATA stage).
     99 * @param data_size Size of extra data buffer in bytes.
     100 * @return Error code.
     101 */
    80102int usbvirt_control_write(usbvirt_device_t *dev, void *setup, size_t setup_size,
    81103    void *data, size_t data_size)
     
    85107}
    86108
     109/** Issue a control read transfer to virtual USB device.
     110 *
     111 * @see usbvirt_control_transfer
     112 *
     113 * @param dev Target virtual device.
     114 * @param setup Setup data.
     115 * @param setup_size Size of setup packet.
     116 * @param data Extra data (DATA stage).
     117 * @param data_size Size of extra data buffer in bytes.
     118 * @param data_size_sent Number of actually send bytes during the transfer.
     119 * @return Error code.
     120 */
    87121int usbvirt_control_read(usbvirt_device_t *dev, void *setup, size_t setup_size,
    88122    void *data, size_t data_size, size_t *data_size_sent)
     
    92126}
    93127
     128/** Send data to virtual USB device.
     129 *
     130 * @param dev Target virtual device.
     131 * @param transf_type Transfer type (interrupt, bulk).
     132 * @param endpoint Endpoint number.
     133 * @param data Data sent from the driver to the device.
     134 * @param data_size Size of the @p data buffer in bytes.
     135 * @return Error code.
     136 */
    94137int usbvirt_data_out(usbvirt_device_t *dev, usb_transfer_type_t transf_type,
    95138    usb_endpoint_t endpoint, void *data, size_t data_size)
     
    108151}
    109152
     153/** Request data from virtual USB device.
     154 *
     155 * @param dev Target virtual device.
     156 * @param transf_type Transfer type (interrupt, bulk).
     157 * @param endpoint Endpoint number.
     158 * @param data Where to stored data the device returns to the driver.
     159 * @param data_size Size of the @p data buffer in bytes.
     160 * @param data_size_sent Number of actually written bytes.
     161 * @return Error code.
     162 */
    110163int usbvirt_data_in(usbvirt_device_t *dev, usb_transfer_type_t transf_type,
    111164    usb_endpoint_t endpoint, void *data, size_t data_size, size_t *data_size_sent)
Note: See TracChangeset for help on using the changeset viewer.