Changes in / [2e85b3c:600733e] in mainline


Ignore:
Location:
uspace
Files:
6 added
5 deleted
30 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/tester/adt/usbaddrkeep.c

    r2e85b3c r600733e  
    2929#include <stdio.h>
    3030#include <stdlib.h>
    31 #include <usb/addrkeep.h>
     31#include <usb/hcd.h>
    3232#include <errno.h>
    3333#include "../tester.h"
  • uspace/app/virtusbkbd/kbdconfig.c

    r2e85b3c r600733e  
    6161        .endpoint_count = 1,
    6262        .interface_class = USB_CLASS_HID,
    63         .interface_subclass = USB_HID_SUBCLASS_BOOT,
     63        .interface_subclass = 0,
    6464        .interface_protocol = USB_HID_PROTOCOL_KEYBOARD,
    6565        .str_interface = 0
  • uspace/drv/uhci-hcd/iface.c

    r2e85b3c r600733e  
    103103/*----------------------------------------------------------------------------*/
    104104static int interrupt_out(device_t *dev, usb_target_t target,
    105     size_t max_packet_size,
    106     void *data, size_t size,
    107     usbhc_iface_transfer_out_callback_t callback, void *arg)
    108 {
     105    void *data, size_t size,
     106    usbhc_iface_transfer_out_callback_t callback, void *arg)
     107{
     108        size_t max_packet_size = 8;
    109109        dev_speed_t speed = FULL_SPEED;
    110110
     
    118118/*----------------------------------------------------------------------------*/
    119119static int interrupt_in(device_t *dev, usb_target_t target,
    120     size_t max_packet_size,
    121     void *data, size_t size,
    122     usbhc_iface_transfer_in_callback_t callback, void *arg)
    123 {
     120    void *data, size_t size,
     121    usbhc_iface_transfer_in_callback_t callback, void *arg)
     122{
     123        size_t max_packet_size = 4;
    124124        dev_speed_t speed = FULL_SPEED;
    125125
     
    133133/*----------------------------------------------------------------------------*/
    134134static int control_write(device_t *dev, usb_target_t target,
    135     size_t max_packet_size,
    136135    void *setup_data, size_t setup_size, void *data, size_t size,
    137136    usbhc_iface_transfer_out_callback_t callback, void *arg)
    138137{
     138        size_t max_packet_size = 8;
    139139        dev_speed_t speed = FULL_SPEED;
    140140
     
    149149/*----------------------------------------------------------------------------*/
    150150static int control_read(device_t *dev, usb_target_t target,
    151     size_t max_packet_size,
    152151    void *setup_data, size_t setup_size, void *data, size_t size,
    153152    usbhc_iface_transfer_in_callback_t callback, void *arg)
    154153{
     154        size_t max_packet_size = 8;
    155155        dev_speed_t speed = FULL_SPEED;
    156156
     
    165165/*----------------------------------------------------------------------------*/
    166166static int control_write_setup(device_t *dev, usb_target_t target,
    167     size_t max_packet_size,
    168     void *data, size_t size,
    169     usbhc_iface_transfer_out_callback_t callback, void *arg)
    170 {
     167    void *data, size_t size,
     168    usbhc_iface_transfer_out_callback_t callback, void *arg)
     169{
     170        size_t max_packet_size = 8;
    171171        dev_speed_t speed = FULL_SPEED;
    172172
     
    181181/*----------------------------------------------------------------------------*/
    182182static int control_write_data(device_t *dev, usb_target_t target,
    183     size_t max_packet_size,
    184     void *data, size_t size,
    185     usbhc_iface_transfer_out_callback_t callback, void *arg)
    186 {
     183    void *data, size_t size,
     184    usbhc_iface_transfer_out_callback_t callback, void *arg)
     185{
     186        size_t max_packet_size = 8;
    187187        dev_speed_t speed = FULL_SPEED;
    188188
     
    212212/*----------------------------------------------------------------------------*/
    213213static int control_read_setup(device_t *dev, usb_target_t target,
    214     size_t max_packet_size,
    215     void *data, size_t size,
    216     usbhc_iface_transfer_out_callback_t callback, void *arg)
    217 {
     214    void *data, size_t size,
     215    usbhc_iface_transfer_out_callback_t callback, void *arg)
     216{
     217        size_t max_packet_size = 8;
    218218        dev_speed_t speed = FULL_SPEED;
    219219
     
    228228/*----------------------------------------------------------------------------*/
    229229static int control_read_data(device_t *dev, usb_target_t target,
    230     size_t max_packet_size,
    231     void *data, size_t size,
    232     usbhc_iface_transfer_in_callback_t callback, void *arg)
    233 {
     230    void *data, size_t size,
     231    usbhc_iface_transfer_in_callback_t callback, void *arg)
     232{
     233        size_t max_packet_size = 8;
    234234        dev_speed_t speed = FULL_SPEED;
    235235
  • uspace/drv/uhci-rhd/port.c

    r2e85b3c r600733e  
    3636
    3737#include <usb/usb.h>    /* usb_address_t */
    38 #include <usb/usbdevice.h>
    39 #include <usb/hub.h>
    40 #include <usb/request.h>
     38#include <usb/usbdrv.h> /* usb_drv_*     */
    4139#include <usb/debug.h>
    4240#include <usb/recognise.h>
     
    6058        port->attached_device = 0;
    6159        port->rh = rh;
    62         int rc = usb_hc_connection_initialize_from_device(
    63             &port->hc_connection, rh);
    64         if (rc != EOK) {
    65                 usb_log_error("Failed to initialize connection to HC.");
    66                 return rc;
    67         }
     60        port->hc_phone = parent_phone;
    6861
    6962        port->checker = fibril_create(uhci_port_check, port);
     
    10598
    10699                if (port_status & STATUS_CONNECTED_CHANGED) {
    107                         int rc = usb_hc_connection_open(
    108                             &port_instance->hc_connection);
    109                         if (rc != EOK) {
    110                                 usb_log_error("Failed to connect to HC.");
    111                                 goto next;
    112                         }
    113 
    114100                        if (port_status & STATUS_CONNECTED) {
    115101                                /* new device */
     
    118104                                uhci_port_remove_device(port_instance);
    119105                        }
    120 
    121                         rc = usb_hc_connection_close(
    122                             &port_instance->hc_connection);
    123                         if (rc != EOK) {
    124                                 usb_log_error("Failed to disconnect from HC.");
    125                                 goto next;
    126                         }
    127106                }
    128         next:
    129107                async_usleep(port_instance->wait_period_usec);
    130108        }
     
    135113{
    136114        assert(port);
    137         assert(usb_hc_connection_is_opened(&port->hc_connection));
     115        assert(port->hc_phone);
    138116
    139117        usb_log_info("Adding new device on port %d.\n", port->number);
    140118
    141119        /* get address of the future device */
    142         const usb_address_t usb_address = usb_hc_request_address(&port->hc_connection);
     120        const usb_address_t usb_address = usb_drv_request_address(port->hc_phone);
    143121
    144122        if (usb_address <= 0) {
     
    150128
    151129        /* get default address */
    152         int ret = usb_hc_reserve_default_address(&port->hc_connection);
     130        int ret = usb_drv_reserve_default_address(port->hc_phone);
    153131        if (ret != EOK) {
    154132                usb_log_error("Failed to reserve default address on port %d.\n",
    155133                    port->number);
    156                 int ret2 = usb_hc_unregister_device(&port->hc_connection,
    157                     usb_address);
     134                int ret2 =
     135                  usb_drv_release_address(port->hc_phone, usb_address);
    158136                if (ret2 != EOK) {
    159137                        usb_log_fatal("Failed to return requested address on port %d.\n",
     
    196174        }
    197175
    198         /*
    199          * Initialize connection to the device.
    200          */
    201         /* FIXME: check for errors. */
    202         usb_device_connection_t new_dev_connection;
    203         usb_endpoint_pipe_t new_dev_ctrl_pipe;
    204         usb_device_connection_initialize_on_default_address(
    205             &new_dev_connection, &port->hc_connection);
    206         usb_endpoint_pipe_initialize_default_control(&new_dev_ctrl_pipe,
    207             &new_dev_connection);
    208 
    209         /*
    210          * Assign new address to the device. This function updates
    211          * the backing connection to still point to the same device.
    212          */
    213         /* FIXME: check for errors. */
    214         usb_endpoint_pipe_start_session(&new_dev_ctrl_pipe);
    215         ret = usb_request_set_address(&new_dev_ctrl_pipe, usb_address);
    216         usb_endpoint_pipe_end_session(&new_dev_ctrl_pipe);
     176        /* assign address to device */
     177        ret = usb_drv_req_set_address(port->hc_phone, 0, usb_address);
    217178
    218179        if (ret != EOK) { /* address assigning went wrong */
    219180                usb_log_error("Failed(%d) to assign address to the device.\n", ret);
    220181                uhci_port_set_enabled(port, false);
    221                 int release = usb_hc_release_default_address(&port->hc_connection);
     182                int release = usb_drv_release_default_address(port->hc_phone);
    222183                if (release != EOK) {
    223184                        usb_log_error("Failed to release default address on port %d.\n",
     
    233194
    234195        /* release default address */
    235         ret = usb_hc_release_default_address(&port->hc_connection);
     196        ret = usb_drv_release_default_address(port->hc_phone);
    236197        if (ret != EOK) {
    237198                usb_log_error("Failed to release default address on port %d.\n",
     
    245206        assert(port->attached_device == 0);
    246207
    247         ret = usb_device_register_child_in_devman(new_dev_connection.address,
    248             new_dev_connection.hc_handle, port->rh, &port->attached_device);
    249 
     208        devman_handle_t hc_handle;
     209        ret = usb_drv_find_hc(port->rh, &hc_handle);
     210        if (ret != EOK) {
     211                usb_log_error("Failed to get handle of host controller: %s.\n",
     212                    str_error(ret));
     213                uhci_port_set_enabled(port, false);
     214                return ENOMEM;
     215        }
     216
     217        ret = usb_device_register_child_in_devman(usb_address, hc_handle,
     218            port->rh, &port->attached_device);
    250219        if (ret != EOK) { /* something went wrong */
    251220                usb_log_error("Failed(%d) in usb_drv_register_child.\n", ret);
     
    256225                port->number, usb_address, port->attached_device);
    257226
    258         /*
    259          * Register the device in the host controller.
    260          */
    261         usb_hc_attached_device_t new_device = {
    262                 .address = new_dev_connection.address,
    263                 .handle = port->attached_device
    264         };
    265 
    266         ret = usb_hc_register_device(&port->hc_connection, &new_device);
     227        ret =
     228          usb_drv_bind_address(port->hc_phone, usb_address, port->attached_device);
    267229        // TODO: proper error check here
    268230        assert(ret == EOK);
  • uspace/drv/uhci-rhd/port.h

    r2e85b3c r600733e  
    3838#include <driver.h> /* device_t */
    3939#include <stdint.h>
    40 #include <usb/usbdevice.h>
    4140
    4241#include "port_status.h"
     
    4746        unsigned number;
    4847        unsigned wait_period_usec;
    49         usb_hc_connection_t hc_connection;
     48        int hc_phone;
    5049        device_t *rh;
    5150        devman_handle_t attached_device;
  • uspace/drv/usbhub/usbhub.c

    r2e85b3c r600733e  
    8484        }*/
    8585
    86         result->address = addr;
     86        result->usb_device = usb_new(usb_hcd_attached_device_info_t);
     87        result->usb_device->address = addr;
    8788
    8889        // get hub descriptor
     
    154155        int opResult;
    155156        usb_target_t target;
    156         target.address = hub_info->address;
     157        target.address = hub_info->usb_device->address;
    157158        target.endpoint = 0;
    158159
     
    215216        dprintf(USB_LOG_LEVEL_INFO, "hub dev added");
    216217        dprintf(USB_LOG_LEVEL_DEBUG, "\taddress %d, has %d ports ",
    217                         hub_info->address,
     218                        hub_info->usb_device->address,
    218219                        hub_info->port_count);
    219220        dprintf(USB_LOG_LEVEL_DEBUG, "\tused configuration %d",config_descriptor.configuration_number);
     
    464465
    465466                usb_target_t target;
    466                 target.address = hub_info->address;
     467                target.address = hub_info->usb_device->address;
    467468                target.endpoint = 1;/// \TODO get from endpoint descriptor
    468469                dprintf(USB_LOG_LEVEL_INFO, "checking changes for hub at addr %d",
     
    506507                        if (interrupt) {
    507508                                usb_hub_process_interrupt(
    508                                         hub_info, hc, port, hub_info->address);
     509                                        hub_info, hc, port, hub_info->usb_device->address);
    509510                        }
    510511                }
  • uspace/drv/usbhub/usbhub.h

    r2e85b3c r600733e  
    3636#define DRV_USBHUB_USBHUB_H
    3737
    38 #include <ipc/devman.h>
    39 #include <usb/usb.h>
    40 #include <driver.h>
     38#define NAME "usbhub"
    4139
    42 #define NAME "usbhub"
     40#include "usb/hcdhubd.h"
    4341
    4442/** basic information about device attached to hub */
     
    5452        /** attached device handles */
    5553        usb_hub_attached_device_t * attached_devs;
    56         /** USB address of the hub. */
    57         usb_address_t address;
     54        /** General usb device info. */
     55        usb_hcd_attached_device_info_t * usb_device;
    5856        /** General device info*/
    5957        device_t * device;
     58
    6059} usb_hub_info_t;
    6160
  • uspace/drv/vhc/conn.h

    r2e85b3c r600733e  
    3737
    3838#include <usb/usb.h>
     39#include <usb/hcdhubd.h>
    3940#include <usbhc_iface.h>
    4041#include "vhcd.h"
     
    4344void connection_handler_host(sysarg_t);
    4445
     46usb_hcd_transfer_ops_t vhc_transfer_ops;
    4547usbhc_iface_t vhc_iface;
    4648
  • uspace/drv/vhc/connhost.c

    r2e85b3c r600733e  
    3636#include <errno.h>
    3737#include <usb/usb.h>
    38 #include <usb/addrkeep.h>
     38#include <usb/hcd.h>
    3939
    4040#include "vhcd.h"
     
    6464
    6565static void universal_callback(void *buffer, size_t size,
    66     int outcome, void *arg)
     66    usb_transaction_outcome_t outcome, void *arg)
    6767{
    6868        transfer_info_t *transfer = (transfer_info_t *) arg;
     
    107107
    108108static void control_abort_prematurely(control_transfer_info_t *transfer,
    109     size_t size, int outcome)
     109    size_t size, usb_transaction_outcome_t outcome)
    110110{
    111111        switch (transfer->direction) {
     
    127127
    128128static void control_callback_two(void *buffer, size_t size,
    129     int outcome, void *arg)
     129    usb_transaction_outcome_t outcome, void *arg)
    130130{
    131131        control_transfer_info_t *ctrl_transfer = (control_transfer_info_t *) arg;
    132132
    133         if (outcome != EOK) {
     133        if (outcome != USB_OUTCOME_OK) {
    134134                control_abort_prematurely(ctrl_transfer, outcome, size);
    135135                free(ctrl_transfer);
     
    165165
    166166static void control_callback_one(void *buffer, size_t size,
    167     int outcome, void *arg)
     167    usb_transaction_outcome_t outcome, void *arg)
    168168{
    169169        control_transfer_info_t *transfer = (control_transfer_info_t *) arg;
    170170
    171         if (outcome != EOK) {
     171        if (outcome != USB_OUTCOME_OK) {
    172172                control_abort_prematurely(transfer, outcome, size);
    173173                free(transfer);
     
    276276
    277277static int interrupt_out(device_t *dev, usb_target_t target,
    278     size_t max_packet_size,
    279278    void *data, size_t size,
    280279    usbhc_iface_transfer_out_callback_t callback, void *arg)
     
    286285
    287286static int interrupt_in(device_t *dev, usb_target_t target,
    288     size_t max_packet_size,
    289287    void *data, size_t size,
    290288    usbhc_iface_transfer_in_callback_t callback, void *arg)
     
    296294
    297295static int control_write_setup(device_t *dev, usb_target_t target,
    298     size_t max_packet_size,
    299296    void *data, size_t size,
    300297    usbhc_iface_transfer_out_callback_t callback, void *arg)
     
    306303
    307304static int control_write_data(device_t *dev, usb_target_t target,
    308     size_t max_packet_size,
    309305    void *data, size_t size,
    310306    usbhc_iface_transfer_out_callback_t callback, void *arg)
     
    324320
    325321static int control_write(device_t *dev, usb_target_t target,
    326     size_t max_packet_size,
    327322    void *setup_packet, size_t setup_packet_size,
    328323    void *data, size_t data_size,
     
    342337
    343338static int control_read_setup(device_t *dev, usb_target_t target,
    344     size_t max_packet_size,
    345339    void *data, size_t size,
    346340    usbhc_iface_transfer_out_callback_t callback, void *arg)
     
    352346
    353347static int control_read_data(device_t *dev, usb_target_t target,
    354     size_t max_packet_size,
    355348    void *data, size_t size,
    356349    usbhc_iface_transfer_in_callback_t callback, void *arg)
     
    370363
    371364static int control_read(device_t *dev, usb_target_t target,
    372     size_t max_packet_size,
    373365    void *setup_packet, size_t setup_packet_size,
    374366    void *data, size_t data_size,
  • uspace/drv/vhc/devices.c

    r2e85b3c r600733e  
    112112 * @param transaction Transaction to be sent over the bus.
    113113 */
    114 int virtdev_send_to_all(transaction_t *transaction)
     114usb_transaction_outcome_t virtdev_send_to_all(transaction_t *transaction)
    115115{
    116116        /* For easier debugging. */
     
    126126                        assert(false && "unreachable branch in switch()");
    127127        }
    128         int outcome = EBADCHECKSUM;
     128        usb_transaction_outcome_t outcome = USB_OUTCOME_BABBLE;
    129129
    130130        link_t *pos;
     
    185185                 */
    186186                if (rc == EOK) {
    187                         outcome = EOK;
     187                        outcome = USB_OUTCOME_OK;
    188188                }
    189189        }
     
    221221                                break;
    222222                }
    223                 outcome = EOK;
     223                outcome = USB_OUTCOME_OK;
    224224        }
    225225       
  • uspace/drv/vhc/devices.h

    r2e85b3c r600733e  
    5454virtdev_connection_t *virtdev_find(sysarg_t);
    5555void virtdev_destroy_device(virtdev_connection_t *);
    56 int virtdev_send_to_all(transaction_t *);
     56usb_transaction_outcome_t virtdev_send_to_all(transaction_t *);
    5757
    5858#endif
  • uspace/drv/vhc/hc.c

    r2e85b3c r600733e  
    8989 */
    9090static void process_transaction_with_outcome(transaction_t * transaction,
    91     int outcome)
     91    usb_transaction_outcome_t outcome)
    9292{
    9393        usb_log_debug2("Transaction " TRANSACTION_FORMAT " done: %s.\n",
    9494            TRANSACTION_PRINTF(*transaction),
    95             str_error(outcome));
     95            usb_str_transaction_outcome(outcome));
    9696       
    9797        transaction->callback(transaction->buffer, transaction->actual_len,
     
    127127                    TRANSACTION_PRINTF(*transaction), ports);
    128128
    129                 int outcome;
     129                usb_transaction_outcome_t outcome;
    130130                outcome = virtdev_send_to_all(transaction);
    131131               
  • uspace/drv/vhc/hc.h

    r2e85b3c r600733e  
    4747 */
    4848typedef void (*hc_transaction_done_callback_t)(void *buffer, size_t size,
    49     int outcome, void *arg);
     49    usb_transaction_outcome_t outcome, void *arg);
    5050
    5151/** Pending transaction details. */
  • uspace/lib/c/generic/str_error.c

    r2e85b3c r600733e  
    3333 */
    3434
    35 #include <errno.h>
    3635#include <str_error.h>
    3736#include <stdio.h>
     
    6463static fibril_local char noerr[NOERR_LEN];
    6564
    66 const char *str_error(const int e)
     65const char *str_error(const int errno)
    6766{
    68         if ((e <= 0) && (e >= MIN_ERRNO))
    69                 return err_desc[-e];
     67        if ((errno <= 0) && (errno >= MIN_ERRNO))
     68                return err_desc[-errno];
    7069       
    71         /* Ad hoc descriptions of error codes interesting for USB. */
    72         switch (e) {
    73                 case EBADCHECKSUM:
    74                         return "Bad checksum";
    75                 case EAGAIN:
    76                         return "Resource temporarily unavailable";
    77                 default:
    78                         break;
    79         }
    80 
    81         snprintf(noerr, NOERR_LEN, "Unkown error code %d", e);
     70        snprintf(noerr, NOERR_LEN, "Unkown error code %d", errno);
    8271        return noerr;
    8372}
  • uspace/lib/c/include/errno.h

    r2e85b3c r600733e  
    5656#define EMLINK        (-266)
    5757
    58 /** Bad checksum. */
    59 #define EBADCHECKSUM  (-300)
    60 
    6158/** An API function is called while another blocking function is in progress. */
    6259#define EINPROGRESS  (-10036)
  • uspace/lib/drv/generic/remote_usbhc.c

    r2e85b3c r600733e  
    4040
    4141#define USB_MAX_PAYLOAD_SIZE 1020
    42 #define HACK_MAX_PACKET_SIZE 8
    43 #define HACK_MAX_PACKET_SIZE_INTERRUPT_IN 4
    4442
    4543static void remote_usbhc_get_address(device_t *, void *, ipc_callid_t, ipc_call_t *);
     
    242240
    243241static void callback_out(device_t *device,
    244     int outcome, void *arg)
     242    usb_transaction_outcome_t outcome, void *arg)
    245243{
    246244        async_transaction_t *trans = (async_transaction_t *)arg;
     
    252250
    253251static void callback_in(device_t *device,
    254     int outcome, size_t actual_size, void *arg)
     252    usb_transaction_outcome_t outcome, size_t actual_size, void *arg)
    255253{
    256254        async_transaction_t *trans = (async_transaction_t *)arg;
    257255
    258         if (outcome != EOK) {
     256        if (outcome != USB_OUTCOME_OK) {
    259257                async_answer_0(trans->caller, outcome);
    260258                if (trans->data_caller) {
     
    272270        }
    273271
    274         async_answer_0(trans->caller, EOK);
     272        async_answer_0(trans->caller, USB_OUTCOME_OK);
    275273
    276274        async_transaction_destroy(trans);
     
    324322        trans->size = len;
    325323
    326         int rc = transfer_func(device, target, HACK_MAX_PACKET_SIZE,
    327             buffer, len,
     324        int rc = transfer_func(device, target, buffer, len,
    328325            callback_out, trans);
    329326
     
    371368        trans->size = len;
    372369
    373         int rc = transfer_func(device, target, HACK_MAX_PACKET_SIZE_INTERRUPT_IN,
    374             trans->buffer, len,
     370        int rc = transfer_func(device, target, trans->buffer, len,
    375371            callback_in, trans);
    376372
     
    544540                .endpoint = DEV_IPC_GET_ARG2(*call)
    545541        };
    546         size_t data_buffer_len = DEV_IPC_GET_ARG3(*call);
    547542
    548543        int rc;
     
    551546        void *data_buffer = NULL;
    552547        size_t setup_packet_len = 0;
     548        size_t data_buffer_len = 0;
    553549
    554550        rc = async_data_write_accept(&setup_packet, false,
     
    558554                return;
    559555        }
    560 
    561         if (data_buffer_len > 0) {
    562                 rc = async_data_write_accept(&data_buffer, false,
    563                     1, USB_MAX_PAYLOAD_SIZE, 0, &data_buffer_len);
    564                 if (rc != EOK) {
    565                         async_answer_0(callid, rc);
    566                         free(setup_packet);
    567                         return;
    568                 }
     556        rc = async_data_write_accept(&data_buffer, false,
     557            1, USB_MAX_PAYLOAD_SIZE, 0, &data_buffer_len);
     558        if (rc != EOK) {
     559                async_answer_0(callid, rc);
     560                free(setup_packet);
     561                return;
    569562        }
    570563
     
    580573        trans->size = data_buffer_len;
    581574
    582         rc = usb_iface->control_write(device, target, HACK_MAX_PACKET_SIZE,
     575        rc = usb_iface->control_write(device, target,
    583576            setup_packet, setup_packet_len,
    584577            data_buffer, data_buffer_len,
     
    603596        }
    604597
     598        size_t data_len = DEV_IPC_GET_ARG3(*call);
    605599        usb_target_t target = {
    606600                .address = DEV_IPC_GET_ARG1(*call),
     
    612606        void *setup_packet = NULL;
    613607        size_t setup_packet_len = 0;
    614         size_t data_len = 0;
    615608
    616609        rc = async_data_write_accept(&setup_packet, false,
     
    644637        }
    645638
    646         rc = usb_iface->control_read(device, target, HACK_MAX_PACKET_SIZE,
     639        rc = usb_iface->control_read(device, target,
    647640            setup_packet, setup_packet_len,
    648641            trans->buffer, trans->size,
  • uspace/lib/drv/include/usbhc_iface.h

    r2e85b3c r600733e  
    207207/** Callback for outgoing transfer. */
    208208typedef void (*usbhc_iface_transfer_out_callback_t)(device_t *,
    209     int, void *);
     209    usb_transaction_outcome_t, void *);
    210210
    211211/** Callback for incoming transfer. */
    212212typedef void (*usbhc_iface_transfer_in_callback_t)(device_t *,
    213     int, size_t, void *);
     213    usb_transaction_outcome_t, size_t, void *);
    214214
    215215
    216216/** Out transfer processing function prototype. */
    217 typedef int (*usbhc_iface_transfer_out_t)(device_t *, usb_target_t, size_t,
     217typedef int (*usbhc_iface_transfer_out_t)(device_t *, usb_target_t,
    218218    void *, size_t,
    219219    usbhc_iface_transfer_out_callback_t, void *);
    220220
    221 /** Setup transfer processing function prototype. @deprecated */
     221/** Setup transfer processing function prototype. */
    222222typedef usbhc_iface_transfer_out_t usbhc_iface_transfer_setup_t;
    223223
    224224/** In transfer processing function prototype. */
    225 typedef int (*usbhc_iface_transfer_in_t)(device_t *, usb_target_t, size_t,
     225typedef int (*usbhc_iface_transfer_in_t)(device_t *, usb_target_t,
    226226    void *, size_t,
    227227    usbhc_iface_transfer_in_callback_t, void *);
     
    251251
    252252        int (*control_write)(device_t *, usb_target_t,
    253             size_t,
    254253            void *, size_t, void *, size_t,
    255254            usbhc_iface_transfer_out_callback_t, void *);
    256255
    257256        int (*control_read)(device_t *, usb_target_t,
    258             size_t,
    259257            void *, size_t, void *, size_t,
    260258            usbhc_iface_transfer_in_callback_t, void *);
  • uspace/lib/usb/Makefile

    r2e85b3c r600733e  
    3939        src/drvpsync.c \
    4040        src/dump.c \
     41        src/hcdhubd.c \
     42        src/hcdrv.c \
    4143        src/hidparser.c \
    42         src/hub.c \
     44        src/localdrv.c \
    4345        src/pipes.c \
    4446        src/pipesinit.c \
    45         src/pipesio.c \
    4647        src/recognise.c \
     48        src/remotedrv.c \
    4749        src/request.c \
    4850        src/usb.c \
    49         src/usbdevice.c \
    5051        src/usbdrvreq.c \
    5152        src/usbdrv.c \
  • uspace/lib/usb/include/usb/addrkeep.h

    • Property mode changed from 100644 to 120000
    r2e85b3c r600733e  
    1 /*
    2  * Copyright (c) 2010 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 libusb
    30  * @{
    31  */
    32 /** @file
    33  * USB address keeping for host controller drivers.
    34  */
    35 #ifndef LIBUSB_ADDRKEEP_H_
    36 #define LIBUSB_ADDRKEEP_H_
    37 
    38 #include <usb/usb.h>
    39 #include <fibril_synch.h>
    40 #include <devman.h>
    41 
    42 /** Info about used address. */
    43 typedef struct {
    44         /** Linked list member. */
    45         link_t link;
    46         /** Address. */
    47         usb_address_t address;
    48         /** Corresponding devman handle. */
    49         devman_handle_t devman_handle;
    50 } usb_address_keeping_used_t;
    51 
    52 /** Structure for keeping track of free and used USB addresses. */
    53 typedef struct {
    54         /** Head of list of used addresses. */
    55         link_t used_addresses;
    56         /** Upper bound for USB addresses. */
    57         usb_address_t max_address;
    58         /** Mutex protecting used address. */
    59         fibril_mutex_t used_addresses_guard;
    60         /** Condition variable for used addresses. */
    61         fibril_condvar_t used_addresses_condvar;
    62 
    63         /** Condition variable mutex for default address. */
    64         fibril_mutex_t default_condvar_guard;
    65         /** Condition variable for default address. */
    66         fibril_condvar_t default_condvar;
    67         /** Whether is default address available. */
    68         bool default_available;
    69 } usb_address_keeping_t;
    70 
    71 void usb_address_keeping_init(usb_address_keeping_t *, usb_address_t);
    72 
    73 void usb_address_keeping_reserve_default(usb_address_keeping_t *);
    74 void usb_address_keeping_release_default(usb_address_keeping_t *);
    75 
    76 usb_address_t usb_address_keeping_request(usb_address_keeping_t *);
    77 int usb_address_keeping_release(usb_address_keeping_t *, usb_address_t);
    78 void usb_address_keeping_devman_bind(usb_address_keeping_t *, usb_address_t,
    79     devman_handle_t);
    80 usb_address_t usb_address_keeping_find(usb_address_keeping_t *,
    81     devman_handle_t);
    82 
    83 #endif
    84 /**
    85  * @}
    86  */
     1hcd.h
  • uspace/lib/usb/include/usb/classes/hub.h

    r2e85b3c r600733e  
    3737
    3838#include <sys/types.h>
     39#include <usb/hcdhubd.h>
     40
    3941
    4042/** Hub class feature selector.
     
    7880    /**
    7981            D1...D0: Logical Power Switching Mode
    80             00: Ganged power switching (all ports power at
     82            00: Ganged power switching (all ports power at
    8183            once)
    8284            01: Individual port power switching
     
    8991            00: Global Over-current Protection. The hub
    9092            reports over-current as a summation of all
    91             ports current draw, without a breakdown of
     93            ports current draw, without a breakdown of
    9294            individual port over-current status.
    9395            01: Individual Port Over-current Protection. The
  • uspace/lib/usb/include/usb/pipes.h

    r2e85b3c r600733e  
    3131 */
    3232/** @file
    33  * USB pipes representation.
     33 * Communication between device drivers and host controller driver.
    3434 */
    3535#ifndef LIBUSB_PIPES_H_
     
    3838#include <sys/types.h>
    3939#include <usb/usb.h>
    40 #include <usb/usbdevice.h>
    4140#include <usb/descriptor.h>
    4241#include <ipc/devman.h>
     
    115114} usb_endpoint_mapping_t;
    116115
    117 int usb_device_connection_initialize_on_default_address(
    118     usb_device_connection_t *, usb_hc_connection_t *);
    119116int usb_device_connection_initialize_from_device(usb_device_connection_t *,
    120117    device_t *);
     
    142139    void *, size_t);
    143140
     141
     142
     143int usb_endpoint_pipe_async_read(usb_endpoint_pipe_t *, void *, size_t,
     144    size_t *, usb_handle_t *);
     145int usb_endpoint_pipe_async_write(usb_endpoint_pipe_t *, void *, size_t,
     146    usb_handle_t *);
     147
     148int usb_endpoint_pipe_async_control_read(usb_endpoint_pipe_t *, void *, size_t,
     149    void *, size_t, size_t *, usb_handle_t *);
     150int usb_endpoint_pipe_async_control_write(usb_endpoint_pipe_t *, void *, size_t,
     151    void *, size_t, usb_handle_t *);
     152
     153int usb_endpoint_pipe_wait_for(usb_endpoint_pipe_t *, usb_handle_t);
     154
    144155#endif
    145156/**
  • uspace/lib/usb/include/usb/recognise.h

    r2e85b3c r600733e  
    3939#include <usb/usb.h>
    4040#include <usb/pipes.h>
    41 #include <ipc/devman.h>
    4241
    4342int usb_device_create_match_ids(usb_endpoint_pipe_t *, match_id_list_t *);
  • uspace/lib/usb/include/usb/usb.h

    r2e85b3c r600733e  
    8383} usb_request_recipient_t;
    8484
     85/** USB transaction outcome. */
     86typedef enum {
     87        USB_OUTCOME_OK,
     88        USB_OUTCOME_CRCERROR,
     89        USB_OUTCOME_BABBLE
     90} usb_transaction_outcome_t;
     91
     92const char * usb_str_transaction_outcome(usb_transaction_outcome_t o);
     93
    8594/** USB address type.
    8695 * Negative values could be used to indicate error.
  • uspace/lib/usb/src/addrkeep.c

    r2e85b3c r600733e  
    3333 * @brief Address keeping.
    3434 */
    35 #include <usb/addrkeep.h>
     35#include <usb/hcd.h>
    3636#include <errno.h>
    3737#include <assert.h>
  • uspace/lib/usb/src/dump.c

    r2e85b3c r600733e  
    147147        PRINTLINE("bDeviceProtocol = 0x%02x", d->device_protocol);
    148148        PRINTLINE("bMaxPacketSize0 = %d", d->max_packet_size);
    149         PRINTLINE("idVendor = 0x%04x", d->vendor_id);
    150         PRINTLINE("idProduct = 0x%04x", d->product_id);
     149        PRINTLINE("idVendor = %d", d->vendor_id);
     150        PRINTLINE("idProduct = %d", d->product_id);
    151151        PRINTLINE("bcdDevice = %d", d->device_version);
    152152        PRINTLINE("iManufacturer = %d", d->str_manufacturer);
  • uspace/lib/usb/src/pipes.c

    r2e85b3c r600733e  
    3131 */
    3232/** @file
    33  * USB endpoint pipes miscellaneous functions.
     33 * Communication between device drivers and host controller driver.
     34 *
     35 * Note on synchronousness of the operations: there is ABSOLUTELY NO
     36 * guarantee that a call to particular function will not trigger a fibril
     37 * switch.
     38 * The initialization functions may actually involve contacting some other
     39 * task, starting/ending a session might involve asynchronous IPC and since
     40 * the transfer functions uses IPC, asynchronous nature of them is obvious.
     41 * The pseudo synchronous versions for the transfers internally call the
     42 * asynchronous ones and so fibril switch is possible in them as well.
    3443 */
    3544#include <usb/usb.h>
     
    3948#include <usb/usbdrv.h>
    4049
     50#define _PREPARE_TARGET(varname, pipe) \
     51        usb_target_t varname = { \
     52                .address = (pipe)->wire->address, \
     53                .endpoint = (pipe)->endpoint_no \
     54        }
     55
    4156/** Initialize connection to USB device.
    4257 *
     
    102117}
    103118
    104 /** Initialize connection to USB device on default address.
    105  *
    106  * @param dev_connection Device connection structure to be initialized.
    107  * @param hc_connection Initialized connection to host controller.
    108  * @return Error code.
    109  */
    110 int usb_device_connection_initialize_on_default_address(
    111     usb_device_connection_t *dev_connection,
    112     usb_hc_connection_t *hc_connection)
    113 {
    114         assert(dev_connection);
    115 
    116         if (hc_connection == NULL) {
    117                 return EBADMEM;
    118         }
    119 
    120         return usb_device_connection_initialize(dev_connection,
    121             hc_connection->hc_handle, (usb_address_t) 0);
     119/** Initialize USB endpoint pipe.
     120 *
     121 * @param pipe Endpoint pipe to be initialized.
     122 * @param connection Connection to the USB device backing this pipe (the wire).
     123 * @param endpoint_no Endpoint number (in USB 1.1 in range 0 to 15).
     124 * @param transfer_type Transfer type (e.g. interrupt or bulk).
     125 * @param max_packet_size Maximum packet size in bytes.
     126 * @param direction Endpoint direction (in/out).
     127 * @return Error code.
     128 */
     129int usb_endpoint_pipe_initialize(usb_endpoint_pipe_t *pipe,
     130    usb_device_connection_t *connection, usb_endpoint_t endpoint_no,
     131    usb_transfer_type_t transfer_type, size_t max_packet_size,
     132    usb_direction_t direction)
     133{
     134        assert(pipe);
     135        assert(connection);
     136
     137        pipe->wire = connection;
     138        pipe->hc_phone = -1;
     139        pipe->endpoint_no = endpoint_no;
     140        pipe->transfer_type = transfer_type;
     141        pipe->max_packet_size = max_packet_size;
     142        pipe->direction = direction;
     143
     144        return EOK;
     145}
     146
     147
     148/** Initialize USB endpoint pipe as the default zero control pipe.
     149 *
     150 * @param pipe Endpoint pipe to be initialized.
     151 * @param connection Connection to the USB device backing this pipe (the wire).
     152 * @return Error code.
     153 */
     154int usb_endpoint_pipe_initialize_default_control(usb_endpoint_pipe_t *pipe,
     155    usb_device_connection_t *connection)
     156{
     157        assert(pipe);
     158        assert(connection);
     159
     160        int rc = usb_endpoint_pipe_initialize(pipe, connection,
     161            0, USB_TRANSFER_CONTROL, 8, USB_DIRECTION_BOTH);
     162
     163        return rc;
    122164}
    123165
     
    182224}
    183225
     226
     227/** Request a read (in) transfer on an endpoint pipe.
     228 *
     229 * @param[in] pipe Pipe used for the transfer.
     230 * @param[out] buffer Buffer where to store the data.
     231 * @param[in] size Size of the buffer (in bytes).
     232 * @param[out] size_transfered Number of bytes that were actually transfered.
     233 * @return Error code.
     234 */
     235int usb_endpoint_pipe_read(usb_endpoint_pipe_t *pipe,
     236    void *buffer, size_t size, size_t *size_transfered)
     237{
     238        assert(pipe);
     239
     240        int rc;
     241        usb_handle_t handle;
     242
     243        rc = usb_endpoint_pipe_async_read(pipe, buffer, size, size_transfered,
     244            &handle);
     245        if (rc != EOK) {
     246                return rc;
     247        }
     248
     249        rc = usb_endpoint_pipe_wait_for(pipe, handle);
     250        return rc;
     251}
     252
     253/** Request a write (out) transfer on an endpoint pipe.
     254 *
     255 * @param[in] pipe Pipe used for the transfer.
     256 * @param[in] buffer Buffer with data to transfer.
     257 * @param[in] size Size of the buffer (in bytes).
     258 * @return Error code.
     259 */
     260int usb_endpoint_pipe_write(usb_endpoint_pipe_t *pipe,
     261    void *buffer, size_t size)
     262{
     263        assert(pipe);
     264
     265        int rc;
     266        usb_handle_t handle;
     267
     268        rc = usb_endpoint_pipe_async_write(pipe, buffer, size, &handle);
     269        if (rc != EOK) {
     270                return rc;
     271        }
     272
     273        rc = usb_endpoint_pipe_wait_for(pipe, handle);
     274        return rc;
     275}
     276
     277
     278/** Request a control read transfer on an endpoint pipe.
     279 *
     280 * This function encapsulates all three stages of a control transfer.
     281 *
     282 * @param[in] pipe Pipe used for the transfer.
     283 * @param[in] setup_buffer Buffer with the setup packet.
     284 * @param[in] setup_buffer_size Size of the setup packet (in bytes).
     285 * @param[out] data_buffer Buffer for incoming data.
     286 * @param[in] data_buffer_size Size of the buffer for incoming data (in bytes).
     287 * @param[out] data_transfered_size Number of bytes that were actually
     288 *                                  transfered during the DATA stage.
     289 * @return Error code.
     290 */
     291int usb_endpoint_pipe_control_read(usb_endpoint_pipe_t *pipe,
     292    void *setup_buffer, size_t setup_buffer_size,
     293    void *data_buffer, size_t data_buffer_size, size_t *data_transfered_size)
     294{
     295        assert(pipe);
     296
     297        int rc;
     298        usb_handle_t handle;
     299
     300        rc = usb_endpoint_pipe_async_control_read(pipe,
     301            setup_buffer, setup_buffer_size,
     302            data_buffer, data_buffer_size, data_transfered_size,
     303            &handle);
     304        if (rc != EOK) {
     305                return rc;
     306        }
     307
     308        rc = usb_endpoint_pipe_wait_for(pipe, handle);
     309        return rc;
     310}
     311
     312
     313/** Request a control write transfer on an endpoint pipe.
     314 *
     315 * This function encapsulates all three stages of a control transfer.
     316 *
     317 * @param[in] pipe Pipe used for the transfer.
     318 * @param[in] setup_buffer Buffer with the setup packet.
     319 * @param[in] setup_buffer_size Size of the setup packet (in bytes).
     320 * @param[in] data_buffer Buffer with data to be sent.
     321 * @param[in] data_buffer_size Size of the buffer with outgoing data (in bytes).
     322 * @return Error code.
     323 */
     324int usb_endpoint_pipe_control_write(usb_endpoint_pipe_t *pipe,
     325    void *setup_buffer, size_t setup_buffer_size,
     326    void *data_buffer, size_t data_buffer_size)
     327{
     328        assert(pipe);
     329
     330        int rc;
     331        usb_handle_t handle;
     332
     333        rc = usb_endpoint_pipe_async_control_write(pipe,
     334            setup_buffer, setup_buffer_size,
     335            data_buffer, data_buffer_size,
     336            &handle);
     337        if (rc != EOK) {
     338                return rc;
     339        }
     340
     341        rc = usb_endpoint_pipe_wait_for(pipe, handle);
     342        return rc;
     343}
     344
     345
     346/** Request a read (in) transfer on an endpoint pipe (asynchronous version).
     347 *
     348 * @param[in] pipe Pipe used for the transfer.
     349 * @param[out] buffer Buffer where to store the data.
     350 * @param[in] size Size of the buffer (in bytes).
     351 * @param[out] size_transfered Number of bytes that were actually transfered.
     352 * @param[out] handle Handle of the transfer.
     353 * @return Error code.
     354 */
     355int usb_endpoint_pipe_async_read(usb_endpoint_pipe_t *pipe,
     356    void *buffer, size_t size, size_t *size_transfered,
     357    usb_handle_t *handle)
     358{
     359        assert(pipe);
     360
     361        if (pipe->hc_phone < 0) {
     362                return EBADF;
     363        }
     364
     365        if (pipe->direction != USB_DIRECTION_IN) {
     366                return EBADF;
     367        }
     368
     369        int rc;
     370        _PREPARE_TARGET(target, pipe);
     371
     372        switch (pipe->transfer_type) {
     373                case USB_TRANSFER_INTERRUPT:
     374                        rc = usb_drv_async_interrupt_in(pipe->hc_phone, target,
     375                            buffer, size, size_transfered, handle);
     376                        break;
     377                case USB_TRANSFER_CONTROL:
     378                        rc = EBADF;
     379                        break;
     380                default:
     381                        rc = ENOTSUP;
     382                        break;
     383        }
     384
     385        return rc;
     386}
     387
     388
     389/** Request a write (out) transfer on an endpoint pipe (asynchronous version).
     390 *
     391 * @param[in] pipe Pipe used for the transfer.
     392 * @param[in] buffer Buffer with data to transfer.
     393 * @param[in] size Size of the buffer (in bytes).
     394 * @param[out] handle Handle of the transfer.
     395 * @return Error code.
     396 */
     397int usb_endpoint_pipe_async_write(usb_endpoint_pipe_t *pipe,
     398    void *buffer, size_t size,
     399    usb_handle_t *handle)
     400{
     401        assert(pipe);
     402
     403        if (pipe->hc_phone < 0) {
     404                return EBADF;
     405        }
     406
     407        if (pipe->direction != USB_DIRECTION_OUT) {
     408                return EBADF;
     409        }
     410
     411        int rc;
     412        _PREPARE_TARGET(target, pipe);
     413
     414        switch (pipe->transfer_type) {
     415                case USB_TRANSFER_INTERRUPT:
     416                        rc = usb_drv_async_interrupt_out(pipe->hc_phone, target,
     417                            buffer, size, handle);
     418                        break;
     419                case USB_TRANSFER_CONTROL:
     420                        rc = EBADF;
     421                        break;
     422                default:
     423                        rc = ENOTSUP;
     424                        break;
     425        }
     426
     427        return rc;
     428}
     429
     430
     431/** Request a control read transfer on an endpoint pipe (asynchronous version).
     432 *
     433 * This function encapsulates all three stages of a control transfer.
     434 *
     435 * @param[in] pipe Pipe used for the transfer.
     436 * @param[in] setup_buffer Buffer with the setup packet.
     437 * @param[in] setup_buffer_size Size of the setup packet (in bytes).
     438 * @param[out] data_buffer Buffer for incoming data.
     439 * @param[in] data_buffer_size Size of the buffer for incoming data (in bytes).
     440 * @param[out] data_transfered_size Number of bytes that were actually
     441 *                                  transfered during the DATA stage.
     442 * @param[out] handle Handle of the transfer.
     443 * @return Error code.
     444 */
     445int usb_endpoint_pipe_async_control_read(usb_endpoint_pipe_t *pipe,
     446    void *setup_buffer, size_t setup_buffer_size,
     447    void *data_buffer, size_t data_buffer_size, size_t *data_transfered_size,
     448    usb_handle_t *handle)
     449{
     450        assert(pipe);
     451
     452        if (pipe->hc_phone < 0) {
     453                return EBADF;
     454        }
     455
     456        if ((pipe->direction != USB_DIRECTION_BOTH)
     457            || (pipe->transfer_type != USB_TRANSFER_CONTROL)) {
     458                return EBADF;
     459        }
     460
     461        int rc;
     462        _PREPARE_TARGET(target, pipe);
     463
     464        rc = usb_drv_async_control_read(pipe->hc_phone, target,
     465            setup_buffer, setup_buffer_size,
     466            data_buffer, data_buffer_size, data_transfered_size,
     467            handle);
     468
     469        return rc;
     470}
     471
     472
     473/** Request a control write transfer on an endpoint pipe (asynchronous version).
     474 *
     475 * This function encapsulates all three stages of a control transfer.
     476 *
     477 * @param[in] pipe Pipe used for the transfer.
     478 * @param[in] setup_buffer Buffer with the setup packet.
     479 * @param[in] setup_buffer_size Size of the setup packet (in bytes).
     480 * @param[in] data_buffer Buffer with data to be sent.
     481 * @param[in] data_buffer_size Size of the buffer with outgoing data (in bytes).
     482 * @param[out] handle Handle of the transfer.
     483 * @return Error code.
     484 */
     485int usb_endpoint_pipe_async_control_write(usb_endpoint_pipe_t *pipe,
     486    void *setup_buffer, size_t setup_buffer_size,
     487    void *data_buffer, size_t data_buffer_size,
     488    usb_handle_t *handle)
     489{
     490        assert(pipe);
     491
     492        if (pipe->hc_phone < 0) {
     493                return EBADF;
     494        }
     495
     496        if ((pipe->direction != USB_DIRECTION_BOTH)
     497            || (pipe->transfer_type != USB_TRANSFER_CONTROL)) {
     498                return EBADF;
     499        }
     500
     501        int rc;
     502        _PREPARE_TARGET(target, pipe);
     503
     504        rc = usb_drv_async_control_write(pipe->hc_phone, target,
     505            setup_buffer, setup_buffer_size,
     506            data_buffer, data_buffer_size,
     507            handle);
     508
     509        return rc;
     510}
     511
     512/** Wait for transfer completion.
     513 *
     514 * The function blocks the caller fibril until the transfer associated
     515 * with given @p handle is completed.
     516 *
     517 * @param[in] pipe Pipe the transfer executed on.
     518 * @param[in] handle Transfer handle.
     519 * @return Error code.
     520 */
     521int usb_endpoint_pipe_wait_for(usb_endpoint_pipe_t *pipe, usb_handle_t handle)
     522{
     523        return usb_drv_async_wait_for(handle);
     524}
     525
     526
    184527/**
    185528 * @}
  • uspace/lib/usb/src/pipesinit.c

    r2e85b3c r600733e  
    320320}
    321321
    322 /** Initialize USB endpoint pipe.
    323  *
    324  * @param pipe Endpoint pipe to be initialized.
    325  * @param connection Connection to the USB device backing this pipe (the wire).
    326  * @param endpoint_no Endpoint number (in USB 1.1 in range 0 to 15).
    327  * @param transfer_type Transfer type (e.g. interrupt or bulk).
    328  * @param max_packet_size Maximum packet size in bytes.
    329  * @param direction Endpoint direction (in/out).
    330  * @return Error code.
    331  */
    332 int usb_endpoint_pipe_initialize(usb_endpoint_pipe_t *pipe,
    333     usb_device_connection_t *connection, usb_endpoint_t endpoint_no,
    334     usb_transfer_type_t transfer_type, size_t max_packet_size,
    335     usb_direction_t direction)
    336 {
    337         assert(pipe);
    338         assert(connection);
    339 
    340         pipe->wire = connection;
    341         pipe->hc_phone = -1;
    342         pipe->endpoint_no = endpoint_no;
    343         pipe->transfer_type = transfer_type;
    344         pipe->max_packet_size = max_packet_size;
    345         pipe->direction = direction;
    346 
    347         return EOK;
    348 }
    349 
    350 
    351 /** Initialize USB endpoint pipe as the default zero control pipe.
    352  *
    353  * @param pipe Endpoint pipe to be initialized.
    354  * @param connection Connection to the USB device backing this pipe (the wire).
    355  * @return Error code.
    356  */
    357 int usb_endpoint_pipe_initialize_default_control(usb_endpoint_pipe_t *pipe,
    358     usb_device_connection_t *connection)
    359 {
    360         assert(pipe);
    361         assert(connection);
    362 
    363         int rc = usb_endpoint_pipe_initialize(pipe, connection,
    364             0, USB_TRANSFER_CONTROL, 8, USB_DIRECTION_BOTH);
    365 
    366         return rc;
    367 }
    368 
    369322/**
    370323 * @}
  • uspace/lib/usb/src/usb.c

    r2e85b3c r600733e  
    5454}
    5555
     56/** String representation of USB transaction outcome. */
     57const char * usb_str_transaction_outcome(usb_transaction_outcome_t o)
     58{
     59        switch (o) {
     60                case USB_OUTCOME_OK:
     61                        return "ok";
     62                case USB_OUTCOME_CRCERROR:
     63                        return "CRC error";
     64                case USB_OUTCOME_BABBLE:
     65                        return "babble";
     66                default:
     67                        return "unknown";
     68        }
     69}
     70
     71
    5672/**
    5773 * @}
  • uspace/lib/usb/src/usbdrv.c

    r2e85b3c r600733e  
    464464        assert(setup_packet != NULL);
    465465        assert(setup_packet_size > 0);
    466         assert(((buffer != NULL) && (buffer_size > 0))
    467             || ((buffer == NULL) && (buffer_size == 0)));
     466        assert(buffer != NULL);
     467        assert(buffer_size > 0);
    468468        assert(handle != NULL);
    469469
     
    494494        }
    495495
    496         if (buffer_size > 0) {
    497                 rc = async_data_write_start(phone, buffer, buffer_size);
    498                 if (rc != EOK) {
    499                         async_wait_for(transfer->request, NULL);
    500                         return rc;
    501                 }
     496        rc = async_data_write_start(phone, buffer, buffer_size);
     497        if (rc != EOK) {
     498                async_wait_for(transfer->request, NULL);
     499                return rc;
    502500        }
    503501
  • uspace/lib/usbvirt/Makefile

    r2e85b3c r600733e  
    3030LIBRARY = libusbvirt
    3131
     32LIBS = $(LIBUSB_PREFIX)/libusb.a
    3233EXTRA_CFLAGS = -I$(LIBUSB_PREFIX)/include -Iinclude
    3334
Note: See TracChangeset for help on using the changeset viewer.