Changeset f294926 in mainline


Ignore:
Timestamp:
2011-02-15T20:21:39Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4e832d8, fa2f79d
Parents:
69b1f3d (diff), f673f60 (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:

Merged IPC phones hiding

Location:
uspace
Files:
4 added
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci-rhd/port.c

    r69b1f3d rf294926  
    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

    r69b1f3d rf294926  
    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/lib/usb/Makefile

    r69b1f3d rf294926  
    4040        src/dump.c \
    4141        src/hidparser.c \
     42        src/hub.c \
    4243        src/pipes.c \
    4344        src/pipesinit.c \
     
    4647        src/request.c \
    4748        src/usb.c \
     49        src/usbdevice.c \
    4850        src/usbdrvreq.c \
    4951        src/usbdrv.c \
  • uspace/lib/usb/include/usb/pipes.h

    r69b1f3d rf294926  
    3131 */
    3232/** @file
    33  * Communication between device drivers and host controller driver.
     33 * USB pipes representation.
    3434 */
    3535#ifndef LIBUSB_PIPES_H_
     
    3838#include <sys/types.h>
    3939#include <usb/usb.h>
     40#include <usb/usbdevice.h>
    4041#include <usb/descriptor.h>
    4142#include <ipc/devman.h>
     
    114115} usb_endpoint_mapping_t;
    115116
     117int usb_device_connection_initialize_on_default_address(
     118    usb_device_connection_t *, usb_hc_connection_t *);
    116119int usb_device_connection_initialize_from_device(usb_device_connection_t *,
    117120    device_t *);
  • uspace/lib/usb/src/pipes.c

    r69b1f3d rf294926  
    102102}
    103103
     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 */
     110int 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);
     122}
     123
    104124
    105125/** Start a session on the endpoint pipe.
Note: See TracChangeset for help on using the changeset viewer.