Changeset 2e85b3c in mainline for uspace/drv


Ignore:
Timestamp:
2011-02-16T18:22:43Z (15 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f4c87aa9
Parents:
600733e (diff), ec59693 (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:

Development branch

Location:
uspace/drv
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci-hcd/iface.c

    r600733e r2e85b3c  
    103103/*----------------------------------------------------------------------------*/
    104104static int interrupt_out(device_t *dev, usb_target_t target,
    105     void *data, size_t size,
    106     usbhc_iface_transfer_out_callback_t callback, void *arg)
    107 {
    108         size_t max_packet_size = 8;
     105    size_t max_packet_size,
     106    void *data, size_t size,
     107    usbhc_iface_transfer_out_callback_t callback, void *arg)
     108{
    109109        dev_speed_t speed = FULL_SPEED;
    110110
     
    118118/*----------------------------------------------------------------------------*/
    119119static int interrupt_in(device_t *dev, usb_target_t target,
    120     void *data, size_t size,
    121     usbhc_iface_transfer_in_callback_t callback, void *arg)
    122 {
    123         size_t max_packet_size = 4;
     120    size_t max_packet_size,
     121    void *data, size_t size,
     122    usbhc_iface_transfer_in_callback_t callback, void *arg)
     123{
    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,
    135136    void *setup_data, size_t setup_size, void *data, size_t size,
    136137    usbhc_iface_transfer_out_callback_t callback, void *arg)
    137138{
    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,
    151152    void *setup_data, size_t setup_size, void *data, size_t size,
    152153    usbhc_iface_transfer_in_callback_t callback, void *arg)
    153154{
    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     void *data, size_t size,
    168     usbhc_iface_transfer_out_callback_t callback, void *arg)
     167    size_t max_packet_size,
     168    void *data, size_t size,
     169    usbhc_iface_transfer_out_callback_t callback, void *arg)
     170{
     171        dev_speed_t speed = FULL_SPEED;
     172
     173        usb_log_warning("Using deprecated API %s.\n", __FUNCTION__);
     174        batch_t *batch = batch_get(dev, target, USB_TRANSFER_CONTROL,
     175            max_packet_size, speed, NULL, 0, data, size, NULL, callback, arg);
     176        if (!batch)
     177                return ENOMEM;
     178        batch_control_setup_old(batch);
     179        return EOK;
     180}
     181/*----------------------------------------------------------------------------*/
     182static 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{
     187        dev_speed_t speed = FULL_SPEED;
     188
     189        usb_log_warning("Using deprecated API %s.\n", __FUNCTION__);
     190        batch_t *batch = batch_get(dev, target, USB_TRANSFER_CONTROL,
     191            max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg);
     192        if (!batch)
     193                return ENOMEM;
     194        batch_control_write_data_old(batch);
     195        return EOK;
     196}
     197/*----------------------------------------------------------------------------*/
     198static int control_write_status(device_t *dev, usb_target_t target,
     199    usbhc_iface_transfer_in_callback_t callback, void *arg)
    169200{
    170201        size_t max_packet_size = 8;
     
    173204        usb_log_warning("Using deprecated API %s.\n", __FUNCTION__);
    174205        batch_t *batch = batch_get(dev, target, USB_TRANSFER_CONTROL,
     206            max_packet_size, speed, NULL, 0, NULL, 0, callback, NULL, arg);
     207        if (!batch)
     208                return ENOMEM;
     209        batch_control_write_status_old(batch);
     210        return EOK;
     211}
     212/*----------------------------------------------------------------------------*/
     213static 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{
     218        dev_speed_t speed = FULL_SPEED;
     219
     220        usb_log_warning("Using deprecated API %s.\n", __FUNCTION__);
     221        batch_t *batch = batch_get(dev, target, USB_TRANSFER_CONTROL,
    175222            max_packet_size, speed, NULL, 0, data, size, NULL, callback, arg);
    176223        if (!batch)
     
    180227}
    181228/*----------------------------------------------------------------------------*/
    182 static int control_write_data(device_t *dev, usb_target_t target,
    183     void *data, size_t size,
    184     usbhc_iface_transfer_out_callback_t callback, void *arg)
    185 {
    186         size_t max_packet_size = 8;
    187         dev_speed_t speed = FULL_SPEED;
    188 
    189         usb_log_warning("Using deprecated API %s.\n", __FUNCTION__);
    190         batch_t *batch = batch_get(dev, target, USB_TRANSFER_CONTROL,
    191             max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg);
    192         if (!batch)
    193                 return ENOMEM;
    194         batch_control_write_data_old(batch);
    195         return EOK;
    196 }
    197 /*----------------------------------------------------------------------------*/
    198 static int control_write_status(device_t *dev, usb_target_t target,
    199     usbhc_iface_transfer_in_callback_t callback, void *arg)
    200 {
    201         size_t max_packet_size = 8;
    202         dev_speed_t speed = FULL_SPEED;
    203 
    204         usb_log_warning("Using deprecated API %s.\n", __FUNCTION__);
    205         batch_t *batch = batch_get(dev, target, USB_TRANSFER_CONTROL,
    206             max_packet_size, speed, NULL, 0, NULL, 0, callback, NULL, arg);
    207         if (!batch)
    208                 return ENOMEM;
    209         batch_control_write_status_old(batch);
    210         return EOK;
    211 }
    212 /*----------------------------------------------------------------------------*/
    213 static int control_read_setup(device_t *dev, usb_target_t target,
    214     void *data, size_t size,
    215     usbhc_iface_transfer_out_callback_t callback, void *arg)
    216 {
    217         size_t max_packet_size = 8;
    218         dev_speed_t speed = FULL_SPEED;
    219 
    220         usb_log_warning("Using deprecated API %s.\n", __FUNCTION__);
    221         batch_t *batch = batch_get(dev, target, USB_TRANSFER_CONTROL,
    222             max_packet_size, speed, NULL, 0, data, size, NULL, callback, arg);
    223         if (!batch)
    224                 return ENOMEM;
    225         batch_control_setup_old(batch);
    226         return EOK;
    227 }
    228 /*----------------------------------------------------------------------------*/
    229229static int control_read_data(device_t *dev, usb_target_t target,
    230     void *data, size_t size,
    231     usbhc_iface_transfer_in_callback_t callback, void *arg)
    232 {
    233         size_t max_packet_size = 8;
     230    size_t max_packet_size,
     231    void *data, size_t size,
     232    usbhc_iface_transfer_in_callback_t callback, void *arg)
     233{
    234234        dev_speed_t speed = FULL_SPEED;
    235235
  • uspace/drv/uhci-rhd/port.c

    r600733e r2e85b3c  
    3636
    3737#include <usb/usb.h>    /* usb_address_t */
    38 #include <usb/usbdrv.h> /* usb_drv_*     */
     38#include <usb/usbdevice.h>
     39#include <usb/hub.h>
     40#include <usb/request.h>
    3941#include <usb/debug.h>
    4042#include <usb/recognise.h>
     
    5860        port->attached_device = 0;
    5961        port->rh = rh;
    60         port->hc_phone = parent_phone;
     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        }
    6168
    6269        port->checker = fibril_create(uhci_port_check, port);
     
    98105
    99106                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
    100114                        if (port_status & STATUS_CONNECTED) {
    101115                                /* new device */
     
    104118                                uhci_port_remove_device(port_instance);
    105119                        }
     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                        }
    106127                }
     128        next:
    107129                async_usleep(port_instance->wait_period_usec);
    108130        }
     
    113135{
    114136        assert(port);
    115         assert(port->hc_phone);
     137        assert(usb_hc_connection_is_opened(&port->hc_connection));
    116138
    117139        usb_log_info("Adding new device on port %d.\n", port->number);
    118140
    119141        /* get address of the future device */
    120         const usb_address_t usb_address = usb_drv_request_address(port->hc_phone);
     142        const usb_address_t usb_address = usb_hc_request_address(&port->hc_connection);
    121143
    122144        if (usb_address <= 0) {
     
    128150
    129151        /* get default address */
    130         int ret = usb_drv_reserve_default_address(port->hc_phone);
     152        int ret = usb_hc_reserve_default_address(&port->hc_connection);
    131153        if (ret != EOK) {
    132154                usb_log_error("Failed to reserve default address on port %d.\n",
    133155                    port->number);
    134                 int ret2 =
    135                   usb_drv_release_address(port->hc_phone, usb_address);
     156                int ret2 = usb_hc_unregister_device(&port->hc_connection,
     157                    usb_address);
    136158                if (ret2 != EOK) {
    137159                        usb_log_fatal("Failed to return requested address on port %d.\n",
     
    174196        }
    175197
    176         /* assign address to device */
    177         ret = usb_drv_req_set_address(port->hc_phone, 0, usb_address);
     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);
    178217
    179218        if (ret != EOK) { /* address assigning went wrong */
    180219                usb_log_error("Failed(%d) to assign address to the device.\n", ret);
    181220                uhci_port_set_enabled(port, false);
    182                 int release = usb_drv_release_default_address(port->hc_phone);
     221                int release = usb_hc_release_default_address(&port->hc_connection);
    183222                if (release != EOK) {
    184223                        usb_log_error("Failed to release default address on port %d.\n",
     
    194233
    195234        /* release default address */
    196         ret = usb_drv_release_default_address(port->hc_phone);
     235        ret = usb_hc_release_default_address(&port->hc_connection);
    197236        if (ret != EOK) {
    198237                usb_log_error("Failed to release default address on port %d.\n",
     
    206245        assert(port->attached_device == 0);
    207246
    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);
     247        ret = usb_device_register_child_in_devman(new_dev_connection.address,
     248            new_dev_connection.hc_handle, port->rh, &port->attached_device);
     249
    219250        if (ret != EOK) { /* something went wrong */
    220251                usb_log_error("Failed(%d) in usb_drv_register_child.\n", ret);
     
    225256                port->number, usb_address, port->attached_device);
    226257
    227         ret =
    228           usb_drv_bind_address(port->hc_phone, usb_address, port->attached_device);
     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);
    229267        // TODO: proper error check here
    230268        assert(ret == EOK);
  • uspace/drv/uhci-rhd/port.h

    r600733e r2e85b3c  
    3838#include <driver.h> /* device_t */
    3939#include <stdint.h>
     40#include <usb/usbdevice.h>
    4041
    4142#include "port_status.h"
     
    4647        unsigned number;
    4748        unsigned wait_period_usec;
    48         int hc_phone;
     49        usb_hc_connection_t hc_connection;
    4950        device_t *rh;
    5051        devman_handle_t attached_device;
  • uspace/drv/usbhub/usbhub.c

    r600733e r2e85b3c  
    8484        }*/
    8585
    86         result->usb_device = usb_new(usb_hcd_attached_device_info_t);
    87         result->usb_device->address = addr;
     86        result->address = addr;
    8887
    8988        // get hub descriptor
     
    155154        int opResult;
    156155        usb_target_t target;
    157         target.address = hub_info->usb_device->address;
     156        target.address = hub_info->address;
    158157        target.endpoint = 0;
    159158
     
    216215        dprintf(USB_LOG_LEVEL_INFO, "hub dev added");
    217216        dprintf(USB_LOG_LEVEL_DEBUG, "\taddress %d, has %d ports ",
    218                         hub_info->usb_device->address,
     217                        hub_info->address,
    219218                        hub_info->port_count);
    220219        dprintf(USB_LOG_LEVEL_DEBUG, "\tused configuration %d",config_descriptor.configuration_number);
     
    465464
    466465                usb_target_t target;
    467                 target.address = hub_info->usb_device->address;
     466                target.address = hub_info->address;
    468467                target.endpoint = 1;/// \TODO get from endpoint descriptor
    469468                dprintf(USB_LOG_LEVEL_INFO, "checking changes for hub at addr %d",
     
    507506                        if (interrupt) {
    508507                                usb_hub_process_interrupt(
    509                                         hub_info, hc, port, hub_info->usb_device->address);
     508                                        hub_info, hc, port, hub_info->address);
    510509                        }
    511510                }
  • uspace/drv/usbhub/usbhub.h

    r600733e r2e85b3c  
    3636#define DRV_USBHUB_USBHUB_H
    3737
     38#include <ipc/devman.h>
     39#include <usb/usb.h>
     40#include <driver.h>
     41
    3842#define NAME "usbhub"
    39 
    40 #include "usb/hcdhubd.h"
    4143
    4244/** basic information about device attached to hub */
     
    5254        /** attached device handles */
    5355        usb_hub_attached_device_t * attached_devs;
    54         /** General usb device info. */
    55         usb_hcd_attached_device_info_t * usb_device;
     56        /** USB address of the hub. */
     57        usb_address_t address;
    5658        /** General device info*/
    5759        device_t * device;
    58 
    5960} usb_hub_info_t;
    6061
  • uspace/drv/vhc/conn.h

    r600733e r2e85b3c  
    3737
    3838#include <usb/usb.h>
    39 #include <usb/hcdhubd.h>
    4039#include <usbhc_iface.h>
    4140#include "vhcd.h"
     
    4443void connection_handler_host(sysarg_t);
    4544
    46 usb_hcd_transfer_ops_t vhc_transfer_ops;
    4745usbhc_iface_t vhc_iface;
    4846
  • uspace/drv/vhc/connhost.c

    r600733e r2e85b3c  
    3636#include <errno.h>
    3737#include <usb/usb.h>
    38 #include <usb/hcd.h>
     38#include <usb/addrkeep.h>
    3939
    4040#include "vhcd.h"
     
    6464
    6565static void universal_callback(void *buffer, size_t size,
    66     usb_transaction_outcome_t outcome, void *arg)
     66    int 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, usb_transaction_outcome_t outcome)
     109    size_t size, int outcome)
    110110{
    111111        switch (transfer->direction) {
     
    127127
    128128static void control_callback_two(void *buffer, size_t size,
    129     usb_transaction_outcome_t outcome, void *arg)
     129    int outcome, void *arg)
    130130{
    131131        control_transfer_info_t *ctrl_transfer = (control_transfer_info_t *) arg;
    132132
    133         if (outcome != USB_OUTCOME_OK) {
     133        if (outcome != EOK) {
    134134                control_abort_prematurely(ctrl_transfer, outcome, size);
    135135                free(ctrl_transfer);
     
    165165
    166166static void control_callback_one(void *buffer, size_t size,
    167     usb_transaction_outcome_t outcome, void *arg)
     167    int outcome, void *arg)
    168168{
    169169        control_transfer_info_t *transfer = (control_transfer_info_t *) arg;
    170170
    171         if (outcome != USB_OUTCOME_OK) {
     171        if (outcome != EOK) {
    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,
    278279    void *data, size_t size,
    279280    usbhc_iface_transfer_out_callback_t callback, void *arg)
     
    285286
    286287static int interrupt_in(device_t *dev, usb_target_t target,
     288    size_t max_packet_size,
    287289    void *data, size_t size,
    288290    usbhc_iface_transfer_in_callback_t callback, void *arg)
     
    294296
    295297static int control_write_setup(device_t *dev, usb_target_t target,
     298    size_t max_packet_size,
    296299    void *data, size_t size,
    297300    usbhc_iface_transfer_out_callback_t callback, void *arg)
     
    303306
    304307static int control_write_data(device_t *dev, usb_target_t target,
     308    size_t max_packet_size,
    305309    void *data, size_t size,
    306310    usbhc_iface_transfer_out_callback_t callback, void *arg)
     
    320324
    321325static int control_write(device_t *dev, usb_target_t target,
     326    size_t max_packet_size,
    322327    void *setup_packet, size_t setup_packet_size,
    323328    void *data, size_t data_size,
     
    337342
    338343static int control_read_setup(device_t *dev, usb_target_t target,
     344    size_t max_packet_size,
    339345    void *data, size_t size,
    340346    usbhc_iface_transfer_out_callback_t callback, void *arg)
     
    346352
    347353static int control_read_data(device_t *dev, usb_target_t target,
     354    size_t max_packet_size,
    348355    void *data, size_t size,
    349356    usbhc_iface_transfer_in_callback_t callback, void *arg)
     
    363370
    364371static int control_read(device_t *dev, usb_target_t target,
     372    size_t max_packet_size,
    365373    void *setup_packet, size_t setup_packet_size,
    366374    void *data, size_t data_size,
  • uspace/drv/vhc/devices.c

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

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

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

    r600733e r2e85b3c  
    4747 */
    4848typedef void (*hc_transaction_done_callback_t)(void *buffer, size_t size,
    49     usb_transaction_outcome_t outcome, void *arg);
     49    int outcome, void *arg);
    5050
    5151/** Pending transaction details. */
Note: See TracChangeset for help on using the changeset viewer.