Changeset 19a1800 in mainline for uspace/drv/vhc/hcd.c


Ignore:
Timestamp:
2011-03-01T22:20:56Z (14 years ago)
Author:
Matej Klonfar <maklf@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e24e7b1
Parents:
976f546 (diff), ac8285d (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 with the current development

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/vhc/hcd.c

    r976f546 r19a1800  
    2727 */
    2828
    29 /** @addtogroup usb
     29/** @addtogroup drvusbvhc
    3030 * @{
    3131 */
     
    3535
    3636#include <devmap.h>
    37 #include <ipc/ipc.h>
    3837#include <async.h>
    3938#include <unistd.h>
     
    4342#include <errno.h>
    4443#include <str_error.h>
    45 #include <driver.h>
     44#include <ddf/driver.h>
    4645
    4746#include <usb/usb.h>
     47#include <usb/ddfiface.h>
    4848#include <usb_iface.h>
    4949#include "vhcd.h"
     
    5353#include "conn.h"
    5454
    55 static int usb_iface_get_hc_handle(device_t *dev, devman_handle_t *handle)
    56 {
    57         /* This shall be called only for VHC device. */
    58         assert(dev->parent == NULL);
    59 
    60         *handle = dev->handle;
    61         return EOK;
    62 }
    63 
    64 static usb_iface_t hc_usb_iface = {
    65         .get_hc_handle = usb_iface_get_hc_handle
    66 };
    67 
    68 static device_ops_t vhc_ops = {
     55static ddf_dev_ops_t vhc_ops = {
    6956        .interfaces[USBHC_DEV_IFACE] = &vhc_iface,
    70         .interfaces[USB_DEV_IFACE] = &hc_usb_iface,
     57        .interfaces[USB_DEV_IFACE] = &vhc_usb_iface,
     58        .close = on_client_close,
    7159        .default_handler = default_connection_handler
    7260};
    7361
    74 static int vhc_count = 0;
    75 static int vhc_add_device(device_t *dev)
     62static int vhc_add_device(ddf_dev_t *dev)
    7663{
     64        static int vhc_count = 0;
     65        int rc;
     66
    7767        /*
    7868         * Currently, we know how to simulate only single HC.
     
    8272        }
    8373
    84         vhc_count++;
     74        /*
     75         * Create exposed function representing the host controller
     76         * itself.
     77         */
     78        ddf_fun_t *hc = ddf_fun_create(dev, fun_exposed, "hc");
     79        if (hc == NULL) {
     80                usb_log_fatal("Failed to create device function.\n");
     81                return ENOMEM;
     82        }
    8583
    86         dev->ops = &vhc_ops;
     84        hc->ops = &vhc_ops;
    8785
    88         devman_add_device_to_class(dev->handle, "usbhc");
     86        rc = ddf_fun_bind(hc);
     87        if (rc != EOK) {
     88                usb_log_fatal("Failed to bind HC function: %s.\n",
     89                    str_error(rc));
     90                return rc;
     91        }
     92
     93        ddf_fun_add_to_class(hc, "usbhc");
    8994
    9095        /*
    9196         * Initialize our hub and announce its presence.
    9297         */
    93         virtual_hub_device_init(dev);
     98        virtual_hub_device_init(hc);
    9499
    95         printf("%s: virtual USB host controller ready.\n", NAME);
     100        usb_log_info("Virtual USB host controller ready (dev %zu, hc %zu).\n",
     101            (size_t) dev->handle, (size_t) hc->handle);
    96102
    97103        return EOK;
     
    114120         * in devman output.
    115121         */
    116         sleep(5);
     122        //sleep(5);
    117123
    118         usb_dprintf_enable(NAME, 0);
     124        usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
    119125
    120126        printf(NAME ": virtual USB host controller driver.\n");
     
    133139         * We are also a driver within devman framework.
    134140         */
    135         return driver_main(&vhc_driver);
     141        return ddf_driver_main(&vhc_driver);
    136142}
    137143
Note: See TracChangeset for help on using the changeset viewer.