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

Changeset a943106 in mainline


Ignore:
Timestamp:
2011-05-06T14:34:10Z (11 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master
Children:
dc06caa
Parents:
42d47f8
Message:

Add comments to libusbvirt headers

Location:
uspace/lib/usbvirt/include/usbvirt
Files:
2 edited

Legend:

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

    r42d47f8 ra943106  
    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. */
     89typedef struct {
     90        /** Request direction (in or out). */
    5391        usb_direction_t req_direction;
     92        /** Request recipient (device, interface or endpoint). */
    5493        usb_request_recipient_t req_recipient;
     94        /** Request type (standard, class or vendor). */
    5595        usb_request_type_t req_type;
     96        /** Actual request code. */
    5697        uint8_t request;
     98        /** Request handler name for debugging purposes. */
    5799        const char *name;
     100        /** Callback to be executed on matching request. */
    58101        usbvirt_on_control_t callback;
    59102} usbvirt_control_request_handler_t;
     
    77120} usbvirt_device_configuration_t;
    78121
    79 /** Standard USB descriptors. */
     122/** Standard USB descriptors for virtual device. */
    80123typedef struct {
    81124        /** Standard device descriptor.
     
    102145} usbvirt_device_state_t;
    103146
    104 typedef struct {
     147/** Ops structure for virtual USB device. */
     148typedef struct {
     149        /** Callbacks for data to device.
     150         * Index zero is ignored.
     151         */
    105152        usbvirt_on_data_to_device_t data_out[USBVIRT_ENDPOINT_MAX];
     153        /** Callbacks for data from device.
     154         * Index zero is ignored.
     155         */
    106156        usbvirt_on_data_from_device_t data_in[USBVIRT_ENDPOINT_MAX];
     157        /** Array of control handlers.
     158         * Last handler is expected to have the @c callback field set to NULL
     159         */
    107160        usbvirt_control_request_handler_t *control;
     161        /** Callback when device changes state.
     162         *
     163         * The value of @c state attribute of @p dev device is not
     164         * defined during call of this function.
     165         *
     166         * @param dev The virtual USB device.
     167         * @param old_state Old device state.
     168         * @param new_state New device state.
     169         */
    108170        void (*state_changed)(usbvirt_device_t *dev,
    109171            usbvirt_device_state_t old_state, usbvirt_device_state_t new_state);
    110172} usbvirt_device_ops_t;
    111173
     174/** Virtual USB device. */
    112175struct usbvirt_device {
     176        /** Name for debugging purposes. */
    113177        const char *name;
     178        /** Custom device data. */
    114179        void *device_data;
     180        /** Device ops. */
    115181        usbvirt_device_ops_t *ops;
     182        /** Device descriptors. */
    116183        usbvirt_descriptors_t *descriptors;
     184        /** Current device address.
     185         * You shall treat this field as read only in your code.
     186         */
    117187        usb_address_t address;
     188        /** Current device state.
     189         * You shall treat this field as read only in your code.
     190         */
    118191        usbvirt_device_state_t state;
    119192};
  • uspace/lib/usbvirt/include/usbvirt/ipc.h

    r42d47f8 ra943106  
    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,
     
    4647        IPC_M_USBVIRT_INTERRUPT_IN,
    4748        IPC_M_USBVIRT_INTERRUPT_OUT
    48 } usbvirt_ipc_t;
     49} usbvirt_hc_to_device_method_t;
    4950
    5051int usbvirt_ipc_send_control_read(int, usb_endpoint_t, void *, size_t,
Note: See TracChangeset for help on using the changeset viewer.