Changeset 9e195e2c in mainline for uspace/lib


Ignore:
Timestamp:
2011-05-12T09:03:00Z (15 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d59d0bb
Parents:
456aea3 (diff), c372e03 (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 development

Location:
uspace/lib
Files:
6 added
2 deleted
19 edited
53 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/devman.c

    r456aea3 r9e195e2c  
    374374}
    375375
     376int devman_get_device_path(devman_handle_t handle, char *path, size_t path_size)
     377{
     378        int phone = devman_get_phone(DEVMAN_CLIENT, 0);
     379
     380        if (phone < 0)
     381                return phone;
     382
     383        async_serialize_start();
     384
     385        ipc_call_t answer;
     386        aid_t req = async_send_1(phone, DEVMAN_DEVICE_GET_DEVICE_PATH,
     387            handle, &answer);
     388
     389        ipc_call_t data_request_call;
     390        aid_t data_request = async_data_read(phone, path, path_size,
     391            &data_request_call);
     392        if (data_request == 0) {
     393                async_wait_for(req, NULL);
     394                async_serialize_end();
     395                return ENOMEM;
     396        }
     397
     398        sysarg_t data_request_rc;
     399        sysarg_t opening_request_rc;
     400        async_wait_for(data_request, &data_request_rc);
     401        async_wait_for(req, &opening_request_rc);
     402
     403        async_serialize_end();
     404
     405        if (data_request_rc != EOK) {
     406                /* Prefer the return code of the opening request. */
     407                if (opening_request_rc != EOK) {
     408                        return (int) opening_request_rc;
     409                } else {
     410                        return (int) data_request_rc;
     411                }
     412        }
     413        if (opening_request_rc != EOK) {
     414                return (int) opening_request_rc;
     415        }
     416
     417        path[path_size - 1] = 0;
     418
     419        if (IPC_GET_ARG2(data_request_call) >= path_size) {
     420                return ELIMIT;
     421        }
     422
     423        return EOK;
     424}
     425
    376426
    377427/** @}
  • uspace/lib/c/include/devman.h

    r456aea3 r9e195e2c  
    5555extern int devman_device_get_handle_by_class(const char *, const char *,
    5656    devman_handle_t *, unsigned int);
     57extern int devman_get_device_path(devman_handle_t, char *, size_t);
    5758
    5859extern int devman_add_device_to_class(devman_handle_t, const char *);
  • uspace/lib/c/include/ipc/devman.h

    r456aea3 r9e195e2c  
    149149typedef enum {
    150150        DEVMAN_DEVICE_GET_HANDLE = IPC_FIRST_USER_METHOD,
    151         DEVMAN_DEVICE_GET_HANDLE_BY_CLASS
     151        DEVMAN_DEVICE_GET_HANDLE_BY_CLASS,
     152        DEVMAN_DEVICE_GET_DEVICE_PATH
    152153} client_to_devman_t;
    153154
  • uspace/lib/drv/generic/remote_usbhc.c

    r456aea3 r9e195e2c  
    5252static void remote_usbhc_request_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    5353static void remote_usbhc_bind_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     54static void remote_usbhc_find_by_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    5455static void remote_usbhc_release_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    5556static void remote_usbhc_register_endpoint(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     
    6162        remote_usbhc_request_address,
    6263        remote_usbhc_bind_address,
     64        remote_usbhc_find_by_address,
    6365        remote_usbhc_release_address,
    6466
     
    163165}
    164166
     167void remote_usbhc_find_by_address(ddf_fun_t *fun, void *iface,
     168    ipc_callid_t callid, ipc_call_t *call)
     169{
     170        usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;
     171
     172        if (!usb_iface->find_by_address) {
     173                async_answer_0(callid, ENOTSUP);
     174                return;
     175        }
     176
     177        usb_address_t address = (usb_address_t) DEV_IPC_GET_ARG1(*call);
     178        devman_handle_t handle;
     179        int rc = usb_iface->find_by_address(fun, address, &handle);
     180
     181        if (rc == EOK) {
     182                async_answer_1(callid, EOK, handle);
     183        } else {
     184                async_answer_0(callid, rc);
     185        }
     186}
     187
    165188void remote_usbhc_release_address(ddf_fun_t *fun, void *iface,
    166189    ipc_callid_t callid, ipc_call_t *call)
     
    302325        async_transaction_t *trans = async_transaction_create(callid);
    303326        if (trans == NULL) {
     327                async_answer_0(data_callid, ENOMEM);
    304328                async_answer_0(callid, ENOMEM);
    305329                return;
     
    314338
    315339        if (rc != EOK) {
     340                async_answer_0(data_callid, rc);
    316341                async_answer_0(callid, rc);
    317342                async_transaction_destroy(trans);
     
    460485        async_transaction_t *trans = async_transaction_create(callid);
    461486        if (trans == NULL) {
     487                async_answer_0(data_callid, ENOMEM);
    462488                async_answer_0(callid, ENOMEM);
    463489                free(setup_packet);
     
    469495        trans->buffer = malloc(data_len);
    470496        if (trans->buffer == NULL) {
     497                async_answer_0(data_callid, ENOMEM);
    471498                async_answer_0(callid, ENOMEM);
    472499                async_transaction_destroy(trans);
     
    480507
    481508        if (rc != EOK) {
     509                async_answer_0(data_callid, rc);
    482510                async_answer_0(callid, rc);
    483511                async_transaction_destroy(trans);
  • uspace/lib/drv/include/usb_iface.h

    r456aea3 r9e195e2c  
    4949         * - arbitrary error code if returned by remote implementation
    5050         * - EOK - handle found, first parameter contains the USB address
     51         *
     52         * The handle must be the one used for binding USB address with
     53         * it (IPC_M_USBHC_BIND_ADDRESS), otherwise the host controller
     54         * (that this request would eventually reach) would not be able
     55         * to find it.
     56         * The problem is that this handle is actually assigned to the
     57         * function inside driver of the parent device (usually hub driver).
     58         * To bypass this problem, the initial caller specify handle as
     59         * zero and the first parent assigns the actual value.
     60         * See usb_iface_get_address_hub_child_impl() implementation
     61         * that could be assigned to device ops of a child device of in a
     62         * hub driver.
     63         * For example, the USB multi interface device driver (MID)
     64         * passes this initial zero without any modification because the
     65         * handle must be resolved by its parent.
    5166         */
    5267        IPC_M_USB_GET_ADDRESS,
  • uspace/lib/drv/include/usbhc_iface.h

    r456aea3 r9e195e2c  
    105105        IPC_M_USBHC_BIND_ADDRESS,
    106106
     107        /** Get handle binded with given USB address.
     108         * Parameters
     109         * - USB address
     110         * Answer:
     111         * - EOK - address binded, first parameter is the devman handle
     112         * - ENOENT - address is not in use at the moment
     113         */
     114        IPC_M_USBHC_GET_HANDLE_BY_ADDRESS,
     115
    107116        /** Release address in use.
    108117         * Arguments:
     
    207216        int (*request_address)(ddf_fun_t *, usb_speed_t, usb_address_t *);
    208217        int (*bind_address)(ddf_fun_t *, usb_address_t, devman_handle_t);
     218        int (*find_by_address)(ddf_fun_t *, usb_address_t, devman_handle_t *);
    209219        int (*release_address)(ddf_fun_t *, usb_address_t);
    210220
  • uspace/lib/usb/Makefile

    r456aea3 r9e195e2c  
    2929USPACE_PREFIX = ../..
    3030LIBRARY = libusb
    31 LIBS = $(LIBDRV_PREFIX)/libdrv.a
    32 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -Iinclude
     31EXTRA_CFLAGS += \
     32        -I$(LIBDRV_PREFIX)/include \
     33        -Iinclude
    3334
    3435SOURCES = \
    35         src/addrkeep.c \
    36         src/altiface.c \
    3736        src/class.c \
    3837        src/ddfiface.c \
    3938        src/debug.c \
    40         src/devdrv.c \
    41         src/devpoll.c \
    42         src/dp.c \
     39        src/driver.c \
    4340        src/dump.c \
    44         src/hidiface.c \
    45         src/hidpath.c \
    46         src/hidparser.c \
    47         src/hiddescriptor.c \
    48         src/hub.c \
    49         src/pipepriv.c \
    50         src/pipes.c \
    51         src/pipesinit.c \
    52         src/pipesio.c \
    53         src/recognise.c \
    54         src/request.c \
    55         src/usb.c \
    56         src/usbdevice.c \
    57         src/hidreq.c \
    58         src/hidreport.c \
    59         src/host/device_keeper.c \
    60         src/host/batch.c \
    61         src/host/endpoint.c \
    62         src/host/usb_endpoint_manager.c
     41        src/host.c \
     42        src/usb.c
    6343
    6444include $(USPACE_PREFIX)/Makefile.common
  • uspace/lib/usb/include/usb/ddfiface.h

    r456aea3 r9e195e2c  
    3737
    3838#include <sys/types.h>
    39 #include <usb/usbdevice.h>
    4039#include <usb_iface.h>
    4140
  • uspace/lib/usb/include/usb/descriptor.h

    r456aea3 r9e195e2c  
    167167} __attribute__ ((packed)) usb_standard_endpoint_descriptor_t;
    168168
     169/** Part of standard USB HID descriptor specifying one class descriptor.
     170 *
     171 * (See HID Specification, p.22)
     172 */
     173typedef struct {
     174        /** Type of class-specific descriptor (Report or Physical). */
     175        uint8_t type;
     176        /** Length of class-specific descriptor in bytes. */
     177        uint16_t length;
     178} __attribute__ ((packed)) usb_standard_hid_class_descriptor_info_t;
     179
     180/** Standard USB HID descriptor.
     181 *
     182 * (See HID Specification, p.22)
     183 *
     184 * It is actually only the "header" of the descriptor, it does not contain
     185 * the last two mandatory fields (type and length of the first class-specific
     186 * descriptor).
     187 */
     188typedef struct {
     189        /** Total size of this descriptor in bytes.
     190         *
     191         * This includes all class-specific descriptor info - type + length
     192         * for each descriptor.
     193         */
     194        uint8_t length;
     195        /** Descriptor type (USB_DESCTYPE_HID). */
     196        uint8_t descriptor_type;
     197        /** HID Class Specification release. */
     198        uint16_t spec_release;
     199        /** Country code of localized hardware. */
     200        uint8_t country_code;
     201        /** Total number of class-specific (i.e. Report and Physical)
     202         * descriptors.
     203         *
     204         * @note There is always only one Report descriptor.
     205         */
     206        uint8_t class_desc_count;
     207        /** First mandatory class descriptor (Report) info. */
     208        usb_standard_hid_class_descriptor_info_t report_desc_info;
     209} __attribute__ ((packed)) usb_standard_hid_descriptor_t;
     210
    169211#endif
    170212/**
  • uspace/lib/usb/include/usb/driver.h

    r456aea3 r9e195e2c  
    11/*
    2  * Copyright (c) 2010 Vojtech Horky
     2 * Copyright (c) 2011 Vojtech Horky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup usbvirtkbd
     29/** @addtogroup libusb
    3030 * @{
    3131 */
    3232/** @file
    33  * @brief Standard device request handlers.
     33 * Common definitions for USB drivers.
    3434 */
    35 #ifndef VUK_STDREQ_H_
    36 #define VUK_STDREQ_H_
     35#ifndef LIBUSB_DRIVER_H_
     36#define LIBUSB_DRIVER_H_
    3737
    38 #include <usbvirt/device.h>
     38#include <sys/types.h>
     39#include <ipc/devman.h>
    3940
    40 int req_get_descriptor(usbvirt_device_t *device,
    41     const usb_device_request_setup_packet_t *setup_packet,
    42     uint8_t *data, size_t *act_size);
     41int usb_hc_find(devman_handle_t, devman_handle_t *);
    4342
    4443#endif
  • uspace/lib/usb/include/usb/host.h

    r456aea3 r9e195e2c  
    11/*
    2  * Copyright (c) 2010 Vojtech Horky
     2 * Copyright (c) 2011 Vojtech Horky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup usbvirtkbd
     29/** @addtogroup libusb
    3030 * @{
    3131 */
    3232/** @file
    33  * @brief USB keyboard descriptors.
     33 * Host controller common functions.
    3434 */
    35 #ifndef VUK_DESCRIPTOR_H_
    36 #define VUK_DESCRIPTOR_H_
     35#ifndef LIBUSB_HOST_H_
     36#define LIBUSB_HOST_H_
    3737
    38 typedef struct {
    39         uint8_t length;
    40         uint8_t type;
    41         uint16_t hid_spec_release;
    42         uint8_t country_code;
    43         uint8_t descriptor_count;
    44         uint8_t descriptor1_type;
    45         uint16_t descriptor1_length;
    46 } __attribute__ ((packed)) hid_descriptor_t;
     38#include <sys/types.h>
     39#include <ipc/devman.h>
     40
     41int usb_ddf_get_hc_handle_by_class(size_t, devman_handle_t *);
    4742
    4843#endif
  • uspace/lib/usb/include/usb/usb.h

    r456aea3 r9e195e2c  
    172172} usb_packet_id;
    173173
     174/** Class name for USB host controllers. */
     175#define USB_HC_DDF_CLASS_NAME "usbhc"
     176
    174177#endif
    175178/**
  • uspace/lib/usb/src/ddfiface.c

    r456aea3 r9e195e2c  
    3737#include <async.h>
    3838#include <usb/ddfiface.h>
     39#include <usb/driver.h>
    3940#include <usb/debug.h>
    4041#include <errno.h>
  • uspace/lib/usb/src/driver.c

    r456aea3 r9e195e2c  
    11/*
    2  * Copyright (c) 2010 Vojtech Horky
     2 * Copyright (c) 2011 Vojtech Horky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 #include <stdio.h>
    30 #include <stdlib.h>
    31 #include <usb/addrkeep.h>
     29/** @addtogroup libusb
     30 * @{
     31 */
     32/** @file
     33 *
     34 */
     35#include <devman.h>
     36#include <dev_iface.h>
     37#include <usb_iface.h>
     38#include <usb/driver.h>
    3239#include <errno.h>
    33 #include "../tester.h"
    34 
    35 #define MAX_ADDRESS 5
    3640
    3741
    38 const char *test_usbaddrkeep(void)
     42/** Find host controller handle that is ancestor of given device.
     43 *
     44 * @param[in] device_handle Device devman handle.
     45 * @param[out] hc_handle Where to store handle of host controller
     46 *      controlling device with @p device_handle handle.
     47 * @return Error code.
     48 */
     49int usb_hc_find(devman_handle_t device_handle, devman_handle_t *hc_handle)
    3950{
    40         int rc;
    41         usb_address_keeping_t addresses;
    42 
    43         TPRINTF("Initializing addresses keeping structure...\n");
    44         usb_address_keeping_init(&addresses, MAX_ADDRESS);
    45        
    46         TPRINTF("Requesting address...\n");
    47         usb_address_t addr = usb_address_keeping_request(&addresses);
    48         TPRINTF("Address assigned: %d\n", (int) addr);
    49         if (addr != 1) {
    50                 return "have not received expected address 1";
     51        int parent_phone = devman_parent_device_connect(device_handle,
     52            IPC_FLAG_BLOCKING);
     53        if (parent_phone < 0) {
     54                return parent_phone;
    5155        }
    5256
    53         TPRINTF("Releasing not assigned address...\n");
    54         rc = usb_address_keeping_release(&addresses, 2);
    55         if (rc != ENOENT) {
    56                 return "have not received expected ENOENT";
     57        devman_handle_t h;
     58        int rc = async_req_1_1(parent_phone, DEV_IFACE_ID(USB_DEV_IFACE),
     59            IPC_M_USB_GET_HOST_CONTROLLER_HANDLE, &h);
     60
     61        async_hangup(parent_phone);
     62
     63        if (rc != EOK) {
     64                return rc;
    5765        }
    5866
    59         TPRINTF("Releasing acquired address...\n");
    60         rc = usb_address_keeping_release(&addresses, addr);
    61         if (rc != EOK) {
    62                 return "have not received expected EOK";
     67        if (hc_handle != NULL) {
     68                *hc_handle = h;
    6369        }
    6470
    65         return NULL;
     71        return EOK;
    6672}
     73
     74/**
     75 * @}
     76 */
  • uspace/lib/usb/src/dump.c

    r456aea3 r9e195e2c  
    4141#include <usb/descriptor.h>
    4242#include <usb/classes/classes.h>
    43 #include <usb/classes/hid.h>
    4443
    4544/** Mapping between descriptor id and dumping function. */
  • uspace/lib/usb/src/host.c

    r456aea3 r9e195e2c  
    11/*
    2  * Copyright (c) 2010 Vojtech Horky
     2 * Copyright (c) 2011 Vojtech Horky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup usbvirtkbd
     29/** @addtogroup libusb
    3030 * @{
    3131 */
    3232/**
    3333 * @file
    34  * @brief Keyboard configuration.
     34 * Host controller common functions (implementation).
    3535 */
     36#include <stdio.h>
     37#include <str_error.h>
    3638#include <errno.h>
     39#include <assert.h>
     40#include <bool.h>
     41#include <usb/host.h>
    3742#include <usb/descriptor.h>
    38 #include "stdreq.h"
    39 #include "kbdconfig.h"
     43#include <devman.h>
    4044
    41 int req_get_descriptor(usbvirt_device_t *device,
    42     const usb_device_request_setup_packet_t *setup_packet,
    43     uint8_t *data, size_t *act_size)
     45/** Get host controller handle by its class index.
     46 *
     47 * @param class_index Class index for the host controller.
     48 * @param hc_handle Where to store the HC handle
     49 *      (can be NULL for existence test only).
     50 * @return Error code.
     51 */
     52int usb_ddf_get_hc_handle_by_class(size_t class_index,
     53    devman_handle_t *hc_handle)
    4454{
    45         if (setup_packet->value_high == USB_DESCTYPE_HID_REPORT) {
    46                 /*
    47                  * For simplicity, always return the same
    48                  * report descriptor.
    49                  */
    50                 usbvirt_control_reply_helper(setup_packet,
    51                     data, act_size,
    52                     report_descriptor, report_descriptor_size);
     55        char *class_index_str;
     56        devman_handle_t hc_handle_tmp;
     57        int rc;
    5358
    54                 return EOK;
     59        rc = asprintf(&class_index_str, "%zu", class_index);
     60        if (rc < 0) {
     61                return ENOMEM;
    5562        }
    56        
    57         /* Let the framework handle all the rest. */
    58         return EFORWARD;
     63        rc = devman_device_get_handle_by_class("usbhc", class_index_str,
     64            &hc_handle_tmp, 0);
     65        free(class_index_str);
     66        if (rc != EOK) {
     67                return rc;
     68        }
     69
     70        if (hc_handle != NULL) {
     71                *hc_handle = hc_handle_tmp;
     72        }
     73
     74        return EOK;
    5975}
    60 
    61 
    6276
    6377/** @}
  • uspace/lib/usbdev/include/usb/hub.h

    r456aea3 r9e195e2c  
    6363    const usb_hc_attached_device_t *);
    6464int usb_hc_unregister_device(usb_hc_connection_t *, usb_address_t);
     65int usb_hc_get_handle_by_address(usb_hc_connection_t *, usb_address_t,
     66    devman_handle_t *);
    6567
    6668#endif
  • uspace/lib/usbdev/include/usb/request.h

    r456aea3 r9e195e2c  
    142142
    143143int usb_request_clear_endpoint_halt(usb_pipe_t *, uint16_t);
     144int usb_pipe_clear_halt(usb_pipe_t *, usb_pipe_t *);
     145int usb_request_get_endpoint_status(usb_pipe_t *, usb_pipe_t *, uint16_t *);
    144146
    145147#endif
  • uspace/lib/usbdev/include/usb/usbdevice.h

    r456aea3 r9e195e2c  
    5050} usb_hc_connection_t;
    5151
    52 int usb_hc_find(devman_handle_t, devman_handle_t *);
    53 
    5452int usb_hc_connection_initialize_from_device(usb_hc_connection_t *,
    5553    ddf_dev_t *);
  • uspace/lib/usbdev/src/hub.c

    r456aea3 r9e195e2c  
    117117            DEV_IFACE_ID(USBHC_DEV_IFACE),
    118118            IPC_M_USBHC_RELEASE_ADDRESS, address);
     119}
     120
     121/** Get handle of USB device with given address.
     122 *
     123 * @param[in] connection Opened connection to host controller.
     124 * @param[in] address Address of device in question.
     125 * @param[out] handle Where to write the device handle.
     126 * @return Error code.
     127 */
     128int usb_hc_get_handle_by_address(usb_hc_connection_t *connection,
     129    usb_address_t address, devman_handle_t *handle)
     130{
     131        CHECK_CONNECTION(connection);
     132
     133        sysarg_t tmp;
     134        int rc = async_req_2_1(connection->hc_phone,
     135            DEV_IFACE_ID(USBHC_DEV_IFACE),
     136            IPC_M_USBHC_GET_HANDLE_BY_ADDRESS,
     137            address, &tmp);
     138        if ((rc == EOK) && (handle != NULL)) {
     139                *handle = tmp;
     140        }
     141
     142        return rc;
    119143}
    120144
  • uspace/lib/usbdev/src/pipes.c

    r456aea3 r9e195e2c  
    3636#include <usb/pipes.h>
    3737#include <usb/debug.h>
     38#include <usb/driver.h>
    3839#include <usbhc_iface.h>
    3940#include <usb_iface.h>
  • uspace/lib/usbdev/src/request.c

    r456aea3 r9e195e2c  
    885885}
    886886
     887/** Clear halt bit of an endpoint pipe (after pipe stall).
     888 *
     889 * @param ctrl_pipe Control pipe.
     890 * @param target_pipe Which pipe is halted and shall be cleared.
     891 * @return Error code.
     892 */
     893int usb_pipe_clear_halt(usb_pipe_t *ctrl_pipe, usb_pipe_t *target_pipe)
     894{
     895        if ((ctrl_pipe == NULL) || (target_pipe == NULL)) {
     896                return EINVAL;
     897        }
     898        return usb_request_clear_endpoint_halt(ctrl_pipe,
     899            target_pipe->endpoint_no);
     900}
     901
     902/** Get endpoint status.
     903 *
     904 * @param[in] ctrl_pipe Control pipe.
     905 * @param[in] pipe Of which pipe the status shall be received.
     906 * @param[out] status Where to store pipe status (in native endianness).
     907 * @return Error code.
     908 */
     909int usb_request_get_endpoint_status(usb_pipe_t *ctrl_pipe, usb_pipe_t *pipe,
     910    uint16_t *status)
     911{
     912        uint16_t status_tmp;
     913        uint16_t pipe_index = (uint16_t) pipe->endpoint_no;
     914        int rc = usb_request_get_status(ctrl_pipe,
     915            USB_REQUEST_RECIPIENT_ENDPOINT, uint16_host2usb(pipe_index),
     916            &status_tmp);
     917        if (rc != EOK) {
     918                return rc;
     919        }
     920
     921        if (status != NULL) {
     922                *status = uint16_usb2host(status_tmp);
     923        }
     924
     925        return EOK;
     926}
     927
    887928/**
    888929 * @}
  • uspace/lib/usbdev/src/usbdevice.c

    r456aea3 r9e195e2c  
    3737#include <usb_iface.h>
    3838#include <usb/usbdevice.h>
     39#include <usb/driver.h>
    3940#include <usb/debug.h>
    4041#include <errno.h>
    4142#include <assert.h>
    42 
    43 /** Find host controller handle that is ancestor of given device.
    44  *
    45  * @param[in] device_handle Device devman handle.
    46  * @param[out] hc_handle Where to store handle of host controller
    47  *      controlling device with @p device_handle handle.
    48  * @return Error code.
    49  */
    50 int usb_hc_find(devman_handle_t device_handle, devman_handle_t *hc_handle)
    51 {
    52         int parent_phone = devman_parent_device_connect(device_handle,
    53             IPC_FLAG_BLOCKING);
    54         if (parent_phone < 0) {
    55                 return parent_phone;
    56         }
    57 
    58         devman_handle_t h;
    59         usb_log_debug("asking for HC handle (my handle is %zu).\n", device_handle);
    60         int rc = async_req_1_1(parent_phone, DEV_IFACE_ID(USB_DEV_IFACE),
    61             IPC_M_USB_GET_HOST_CONTROLLER_HANDLE, &h);
    62 
    63         async_hangup(parent_phone);
    64 
    65         if (rc != EOK) {
    66                 return rc;
    67         }
    68 
    69         if (hc_handle != NULL) {
    70                 *hc_handle = h;
    71         }
    72 
    73         return EOK;
    74 }
    7543
    7644/** Initialize connection to USB host controller.
  • uspace/lib/usbhid/include/usb/classes/hid.h

    r456aea3 r9e195e2c  
    2727 */
    2828
    29 /** @addtogroup usbvirtkbd
     29/** @addtogroup libusb
    3030 * @{
    3131 */
    3232/** @file
    33  * @brief USB keyboard configuration.
     33 * @brief USB HID device related types.
    3434 */
    35 #ifndef VUK_KBDCONFIG_H_
    36 #define VUK_KBDCONFIG_H_
     35#ifndef LIBUSB_HID_H_
     36#define LIBUSB_HID_H_
    3737
     38#include <usb/usb.h>
     39#include <usb/classes/hidparser.h>
    3840#include <usb/descriptor.h>
    39 #include "report.h"
    40 #include "descriptor.h"
    4141
    42 extern usb_standard_device_descriptor_t std_device_descriptor;
     42/** USB/HID device requests. */
     43typedef enum {
     44        USB_HIDREQ_GET_REPORT = 1,
     45        USB_HIDREQ_GET_IDLE = 2,
     46        USB_HIDREQ_GET_PROTOCOL = 3,
     47        /* Values 4 to 8 are reserved. */
     48        USB_HIDREQ_SET_REPORT = 9,
     49        USB_HIDREQ_SET_IDLE = 10,
     50        USB_HIDREQ_SET_PROTOCOL = 11
     51} usb_hid_request_t;
    4352
    44 extern usb_standard_configuration_descriptor_t std_configuration_descriptor;
     53typedef enum {
     54        USB_HID_PROTOCOL_BOOT = 0,
     55        USB_HID_PROTOCOL_REPORT = 1
     56} usb_hid_protocol_t;
    4557
    46 extern usb_standard_interface_descriptor_t std_interface_descriptor;
     58/** USB/HID subclass constants. */
     59typedef enum {
     60        USB_HID_SUBCLASS_NONE = 0,
     61        USB_HID_SUBCLASS_BOOT = 1
     62} usb_hid_subclass_t;
    4763
    48 extern usb_standard_endpoint_descriptor_t endpoint_descriptor;
    49 
    50 
    51 extern hid_descriptor_t hid_descriptor;
    52 
    53 extern report_descriptor_data_t report_descriptor;
    54 extern size_t report_descriptor_size;
     64/** USB/HID interface protocols. */
     65typedef enum {
     66        USB_HID_PROTOCOL_NONE = 0,
     67        USB_HID_PROTOCOL_KEYBOARD = 1,
     68        USB_HID_PROTOCOL_MOUSE = 2
     69} usb_hid_iface_protocol_t;
    5570
    5671
  • uspace/lib/usbhid/src/hiddescriptor.c

    r456aea3 r9e195e2c  
    656656
    657657                usb_log_debug("\t\tOFFSET: %X\n", report_item->offset);
    658                 usb_log_debug("\t\tSIZE: %X\n", report_item->size);                             
     658                usb_log_debug("\t\tSIZE: %zu\n", report_item->size);                           
    659659                usb_log_debug("\t\tLOGMIN: %d\n", report_item->logical_minimum);
    660660                usb_log_debug("\t\tLOGMAX: %d\n", report_item->logical_maximum);               
     
    695695                usb_log_debug("Report ID: %d\n", report_des->report_id);
    696696                usb_log_debug("\tType: %d\n", report_des->type);
    697                 usb_log_debug("\tLength: %d\n", report_des->bit_length);               
    698                 usb_log_debug("\tItems: %d\n", report_des->item_length);               
     697                usb_log_debug("\tLength: %zu\n", report_des->bit_length);               
     698                usb_log_debug("\tItems: %zu\n", report_des->item_length);               
    699699
    700700                usb_hid_descriptor_print_list(&report_des->report_items);
  • uspace/lib/usbhost/include/usb/host/device_keeper.h

    r456aea3 r9e195e2c  
    8080    devman_handle_t handle);
    8181
     82bool usb_device_keeper_find_by_address(usb_device_keeper_t *instance,
     83    usb_address_t address, devman_handle_t *handle);
     84
    8285usb_speed_t usb_device_keeper_get_speed(usb_device_keeper_t *instance,
    8386    usb_address_t address);
  • uspace/lib/usbhost/src/device_keeper.c

    r456aea3 r9e195e2c  
    157157        return ENOENT;
    158158}
     159
     160/** Find devman handled assigned to USB address.
     161 *
     162 * @param[in] instance Device keeper structure to use.
     163 * @param[in] address Address the caller wants to find.
     164 * @param[out] handle Where to store found handle.
     165 * @return Whether such address is currently occupied.
     166 */
     167bool usb_device_keeper_find_by_address(usb_device_keeper_t *instance,
     168    usb_address_t address, devman_handle_t *handle)
     169{
     170        assert(instance);
     171        fibril_mutex_lock(&instance->guard);
     172        if ((address < 0) || (address >= USB_ADDRESS_COUNT)) {
     173                fibril_mutex_unlock(&instance->guard);
     174                return false;
     175        }
     176        if (!instance->devices[address].occupied) {
     177                fibril_mutex_unlock(&instance->guard);
     178                return false;
     179        }
     180
     181        if (handle != NULL) {
     182                *handle = instance->devices[address].handle;
     183        }
     184
     185        fibril_mutex_unlock(&instance->guard);
     186        return true;
     187}
     188
    159189/*----------------------------------------------------------------------------*/
    160190/** Get speed associated with the address
  • uspace/lib/usbvirt/Makefile

    r456aea3 r9e195e2c  
    3030LIBRARY = libusbvirt
    3131
    32 EXTRA_CFLAGS = -I$(LIBUSB_PREFIX)/include -I$(LIBDRV_PREFIX)/include -Iinclude
     32EXTRA_CFLAGS = \
     33        -I$(LIBDRV_PREFIX)/include \
     34        -I$(LIBUSB_PREFIX)/include \
     35        -I$(LIBUSBDEV_PREFIX)/include \
     36        -Iinclude
    3337
    3438SOURCES = \
    35         src/ipc.c \
    3639        src/ctrltransfer.c \
     40        src/device.c \
     41        src/ipc_dev.c \
     42        src/ipc_hc.c \
    3743        src/stdreq.c \
    3844        src/transfer.c
  • uspace/lib/usbvirt/include/usbvirt/device.h

    r456aea3 r9e195e2c  
    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

    r456aea3 r9e195e2c  
    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

    r456aea3 r9e195e2c  
     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

    r456aea3 r9e195e2c  
     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

    r456aea3 r9e195e2c  
     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

    r456aea3 r9e195e2c  
    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.