Changeset f6577d9 in mainline for uspace/drv/bus/usb/vhc/main.c


Ignore:
Timestamp:
2012-12-22T15:48:33Z (11 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f5f0cfb
Parents:
01eeaaf
Message:

vhc: DCE

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/vhc/main.c

    r01eeaaf rf6577d9  
    3434 */
    3535
    36 #include <loc.h>
    37 #include <async.h>
    38 #include <unistd.h>
    39 #include <stdlib.h>
    40 #include <sysinfo.h>
    4136#include <stdio.h>
    4237#include <errno.h>
     
    4641#include <usb/host/ddf_helpers.h>
    4742
    48 #include <usb/usb.h>
    4943#include <usb/ddfiface.h>
    50 #include <usb_iface.h>
     44#include <usb/debug.h>
    5145#include "vhcd.h"
    52 #include "hub.h"
    53 #include "conn.h"
     46#include "hub/hub.h"
     47#include "hub/virthub.h"
     48
     49static usbvirt_device_t virtual_hub_device = {
     50        .name = "root hub",
     51        .ops = &hub_ops,
     52        .address = 0
     53};
    5454
    5555static ddf_dev_ops_t vhc_ops = {
    56 #if 0
    57         .interfaces[USBHC_DEV_IFACE] = &vhc_iface,
    58         .interfaces[USB_DEV_IFACE] = &vhc_usb_iface,
    59 #endif
    6056        .close = on_client_close,
    6157        .default_handler = default_connection_handler
     
    131127
    132128        return ret;
    133 #if 0
    134         static int vhc_count = 0;
    135         int rc;
    136 
    137         if (vhc_count > 0) {
    138                 return ELIMIT;
    139         }
    140 
    141         vhc_data_t *data = ddf_dev_data_alloc(dev, sizeof(vhc_data_t));
    142         if (data == NULL) {
    143                 usb_log_fatal("Failed to allocate memory.\n");
    144                 return ENOMEM;
    145         }
    146         data->magic = 0xDEADBEEF;
    147         rc = usb_endpoint_manager_init(&data->ep_manager, (size_t) -1,
    148             bandwidth_count_usb11);
    149         if (rc != EOK) {
    150                 usb_log_fatal("Failed to initialize endpoint manager.\n");
    151                 free(data);
    152                 return rc;
    153         }
    154         usb_device_manager_init(&data->dev_manager, USB_SPEED_MAX);
    155 
    156         ddf_fun_t *hc = ddf_fun_create(dev, fun_exposed, "hc");
    157         if (hc == NULL) {
    158                 usb_log_fatal("Failed to create device function.\n");
    159                 free(data);
    160                 return ENOMEM;
    161         }
    162 
    163         ddf_fun_set_ops(hc, &vhc_ops);
    164         list_initialize(&data->devices);
    165         fibril_mutex_initialize(&data->guard);
    166         data->hub = &virtual_hub_device;
    167         data->hc_fun = hc;
    168 
    169         rc = ddf_fun_bind(hc);
    170         if (rc != EOK) {
    171                 usb_log_fatal("Failed to bind HC function: %s.\n",
    172                     str_error(rc));
    173                 free(data);
    174                 return rc;
    175         }
    176 
    177         rc = ddf_fun_add_to_category(hc, USB_HC_CATEGORY);
    178         if (rc != EOK) {
    179                 usb_log_fatal("Failed to add function to HC class: %s.\n",
    180                     str_error(rc));
    181                 free(data);
    182                 return rc;
    183         }
    184 
    185         virtual_hub_device_init(hc);
    186 
    187         usb_log_info("Virtual USB host controller ready (dev %zu, hc %zu).\n",
    188             (size_t) ddf_dev_get_handle(dev), (size_t) ddf_fun_get_handle(hc));
    189 
    190         rc = vhc_virtdev_plug_hub(data, data->hub, NULL);
    191         if (rc != EOK) {
    192                 usb_log_fatal("Failed to plug root hub: %s.\n", str_error(rc));
    193                 free(data);
    194                 return rc;
    195         }
    196 
    197         return EOK;
    198 #endif
    199129}
    200130
     
    208138};
    209139
    210 
    211140int main(int argc, char * argv[])
    212141{
    213142        log_init(NAME);
    214 
    215143        printf(NAME ": virtual USB host controller driver.\n");
    216144
Note: See TracChangeset for help on using the changeset viewer.