Changeset dc06caa in mainline


Ignore:
Timestamp:
2011-05-06T15:33:58Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e25a849
Parents:
a943106
Message:

More comments in libusbvirt

Location:
uspace/lib/usbvirt
Files:
6 edited

Legend:

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

    ra943106 rdc06caa  
    8686    uint8_t *data, size_t *act_data_size);
    8787
    88 /** Callback for control request on a virtual USB device. */
     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 */
    8993typedef struct {
    9094        /** Request direction (in or out). */
  • uspace/lib/usbvirt/src/ctrltransfer.c

    ra943106 rdc06caa  
     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/ipc.c

    ra943106 rdc06caa  
    273273}
    274274
     275/** Connect the device to the virtual host controller.
     276 *
     277 * @param dev The virtual device to be (virtually) plugged in.
     278 * @param vhc_path Devman path to the virtual host controller.
     279 * @return Error code.
     280 */
    275281int usbvirt_device_plug(usbvirt_device_t *dev, const char *vhc_path)
    276282{
  • uspace/lib/usbvirt/src/private.h

    ra943106 rdc06caa  
     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

    ra943106 rdc06caa  
     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

    ra943106 rdc06caa  
    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.