Changeset f6577d9 in mainline for uspace/drv/bus/usb/vhc/main.c
- Timestamp:
- 2012-12-22T15:48:33Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f5f0cfb
- Parents:
- 01eeaaf
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/vhc/main.c
r01eeaaf rf6577d9 34 34 */ 35 35 36 #include <loc.h>37 #include <async.h>38 #include <unistd.h>39 #include <stdlib.h>40 #include <sysinfo.h>41 36 #include <stdio.h> 42 37 #include <errno.h> … … 46 41 #include <usb/host/ddf_helpers.h> 47 42 48 #include <usb/usb.h>49 43 #include <usb/ddfiface.h> 50 #include <usb _iface.h>44 #include <usb/debug.h> 51 45 #include "vhcd.h" 52 #include "hub.h" 53 #include "conn.h" 46 #include "hub/hub.h" 47 #include "hub/virthub.h" 48 49 static usbvirt_device_t virtual_hub_device = { 50 .name = "root hub", 51 .ops = &hub_ops, 52 .address = 0 53 }; 54 54 55 55 static ddf_dev_ops_t vhc_ops = { 56 #if 057 .interfaces[USBHC_DEV_IFACE] = &vhc_iface,58 .interfaces[USB_DEV_IFACE] = &vhc_usb_iface,59 #endif60 56 .close = on_client_close, 61 57 .default_handler = default_connection_handler … … 131 127 132 128 return ret; 133 #if 0134 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 #endif199 129 } 200 130 … … 208 138 }; 209 139 210 211 140 int main(int argc, char * argv[]) 212 141 { 213 142 log_init(NAME); 214 215 143 printf(NAME ": virtual USB host controller driver.\n"); 216 144
Note:
See TracChangeset
for help on using the changeset viewer.