Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbvirt/include/usbvirt/device.h

    rd93f5afb r9d58539  
    4040#include <usb/dev/request.h>
    4141#include <async.h>
    42 #include <errno.h>
    43 
    4442
    4543/** Maximum number of endpoints supported by virtual USB. */
     
    5957typedef int (*usbvirt_on_data_to_device_t)(usbvirt_device_t *dev,
    6058    usb_endpoint_t endpoint, usb_transfer_type_t transfer_type,
    61     const void *buffer, size_t buffer_size);
     59    void *buffer, size_t buffer_size);
    6260
    6361/** Callback for data from device (IN transaction).
     
    9088    uint8_t *data, size_t *act_data_size);
    9189
    92 /** Create a class request to get data from device
    93  *
    94  * @param rec Request recipient.
    95  * @param req Request code.
    96  */
    97 #define CLASS_REQ_IN(rec, req) \
    98         .request_type = SETUP_REQUEST_TO_HOST(USB_REQUEST_TYPE_CLASS, rec), \
    99         .request = req
    100 
    101 /** Create a class request to send data to device
    102  *
    103  * @param rec Request recipient.
    104  * @param req Request code.
    105  */
    106 #define CLASS_REQ_OUT(rec, req) \
    107         .request_type = SETUP_REQUEST_TO_DEVICE(USB_REQUEST_TYPE_CLASS, rec), \
    108         .request = req
    109 
    110 /** Create a standard request to get data from device
    111  *
    112  * @param rec Request recipient.
    113  * @param req Request code.
    114  */
    115 #define STD_REQ_IN(rec, req) \
    116         .request_type = SETUP_REQUEST_TO_HOST(USB_REQUEST_TYPE_STANDARD, rec), \
    117         .request = req
    118 
    119 /** Create a standard request to send data to device
    120  *
    121  * @param rec Request recipient.
    122  * @param req Request code.
    123  */
    124 #define STD_REQ_OUT(rec, req) \
    125         .request_type = SETUP_REQUEST_TO_DEVICE(USB_REQUEST_TYPE_STANDARD, rec), \
    126         .request = req
    127 
    12890/** Callback for control request on a virtual USB device.
    12991 *
     
    13294 */
    13395typedef struct {
    134         /* Request type. See usb/request.h */
    135         uint8_t request_type;
     96        /** Request direction (in or out). */
     97        usb_direction_t req_direction;
     98        /** Request recipient (device, interface or endpoint). */
     99        usb_request_recipient_t req_recipient;
     100        /** Request type (standard, class or vendor). */
     101        usb_request_type_t req_type;
    136102        /** Actual request code. */
    137103        uint8_t request;
     
    145111typedef struct {
    146112        /** Actual data. */
    147         const uint8_t *data;
     113        uint8_t *data;
    148114        /** Data length. */
    149115        size_t length;
     
    155121        usb_standard_configuration_descriptor_t *descriptor;
    156122        /** Array of extra data. */
    157         const usbvirt_device_configuration_extras_t *extra;
     123        usbvirt_device_configuration_extras_t *extra;
    158124        /** Length of @c extra array. */
    159125        size_t extra_count;
     
    165131         * There is always only one such descriptor for the device.
    166132         */
    167         const usb_standard_device_descriptor_t *device;
     133        usb_standard_device_descriptor_t *device;
    168134
    169135        /** Configurations. */
     
    198164         * Last handler is expected to have the @c callback field set to NULL
    199165         */
    200         const usbvirt_control_request_handler_t *control;
     166        usbvirt_control_request_handler_t *control;
    201167        /** Callback when device changes state.
    202168         *
     
    214180/** Virtual USB device. */
    215181struct usbvirt_device {
    216         /** Device does not require USB bus power */
    217         bool self_powered;
    218         /** Device is allowed to signal remote wakeup */
    219         bool remote_wakeup;
    220182        /** Name for debugging purposes. */
    221183        const char *name;
     
    225187        usbvirt_device_ops_t *ops;
    226188        /** Device descriptors. */
    227         const usbvirt_descriptors_t *descriptors;
     189        usbvirt_descriptors_t *descriptors;
    228190        /** Current device address.
    229191         * You shall treat this field as read only in your code.
     
    240202};
    241203
    242 
    243 int req_nop(usbvirt_device_t *device,
    244     const usb_device_request_setup_packet_t *setup_packet,
    245     uint8_t *data, size_t *act_size);
    246 
    247204int usbvirt_device_plug(usbvirt_device_t *, const char *);
    248205void usbvirt_device_unplug(usbvirt_device_t *);
    249206
    250207void usbvirt_control_reply_helper(const usb_device_request_setup_packet_t *,
    251     uint8_t *, size_t *, const void *, size_t);
    252 
    253 int usbvirt_control_write(usbvirt_device_t *, const void *, size_t, void *, size_t);
    254 int usbvirt_control_read(usbvirt_device_t *, const void *, size_t, void *, size_t, size_t *);
     208    uint8_t *, size_t *, void *, size_t);
     209
     210int usbvirt_control_write(usbvirt_device_t *, void *, size_t, void *, size_t);
     211int usbvirt_control_read(usbvirt_device_t *, void *, size_t, void *, size_t, size_t *);
    255212int usbvirt_data_out(usbvirt_device_t *, usb_transfer_type_t, usb_endpoint_t,
    256     const void *, size_t);
     213    void *, size_t);
    257214int usbvirt_data_in(usbvirt_device_t *, usb_transfer_type_t, usb_endpoint_t,
    258215    void *, size_t, size_t *);
Note: See TracChangeset for help on using the changeset viewer.