Changeset 664a331c in mainline for uspace/drv/vhc/main.c
- Timestamp:
- 2011-04-29T11:43:28Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2571089
- Parents:
- 28d7185 (diff), f19f1b7 (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. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/vhc/main.c
r28d7185 r664a331c 1 1 /* 2 * Copyright (c) 201 0Vojtech Horky2 * Copyright (c) 2011 Vojtech Horky 3 3 * All rights reserved. 4 4 * … … 31 31 */ 32 32 /** @file 33 * @brief Virtual host controller driver.33 * Virtual host controller. 34 34 */ 35 35 … … 48 48 #include <usb_iface.h> 49 49 #include "vhcd.h" 50 #include "hc.h"51 #include "devices.h"52 50 #include "hub.h" 53 51 #include "conn.h" … … 65 63 int rc; 66 64 67 /*68 * Currently, we know how to simulate only single HC.69 */70 65 if (vhc_count > 0) { 71 66 return ELIMIT; 72 67 } 73 68 74 /* 75 * Create exposed function representing the host controller 76 * itself. 77 */ 69 vhc_data_t *data = malloc(sizeof(vhc_data_t)); 70 if (data == NULL) { 71 usb_log_fatal("Failed to allocate memory.\n"); 72 return ENOMEM; 73 } 74 data->magic = 0xDEADBEEF; 75 rc = usb_endpoint_manager_init(&data->ep_manager, (size_t) -1); 76 if (rc != EOK) { 77 usb_log_fatal("Failed to initialize endpoint manager.\n"); 78 free(data); 79 return rc; 80 } 81 usb_device_keeper_init(&data->dev_keeper); 82 78 83 ddf_fun_t *hc = ddf_fun_create(dev, fun_exposed, "hc"); 79 84 if (hc == NULL) { 80 85 usb_log_fatal("Failed to create device function.\n"); 86 free(data); 81 87 return ENOMEM; 82 88 } 83 89 84 90 hc->ops = &vhc_ops; 91 list_initialize(&data->devices); 92 fibril_mutex_initialize(&data->guard); 93 data->hub = &virtual_hub_device; 94 data->hc_fun = hc; 95 96 dev->driver_data = data; 85 97 86 98 rc = ddf_fun_bind(hc); … … 88 100 usb_log_fatal("Failed to bind HC function: %s.\n", 89 101 str_error(rc)); 102 free(data); 90 103 return rc; 91 104 } … … 93 106 ddf_fun_add_to_class(hc, "usbhc"); 94 107 95 /*96 * Initialize our hub and announce its presence.97 */98 108 virtual_hub_device_init(hc); 99 109 100 110 usb_log_info("Virtual USB host controller ready (dev %zu, hc %zu).\n", 101 111 (size_t) dev->handle, (size_t) hc->handle); 112 113 114 115 rc = vhc_virtdev_plug_hub(data, data->hub, NULL); 116 if (rc != EOK) { 117 usb_log_fatal("Failed to plug root hub: %s.\n", str_error(rc)); 118 free(data); 119 return rc; 120 } 102 121 103 122 return EOK; … … 116 135 int main(int argc, char * argv[]) 117 136 { 118 /*119 * Temporary workaround. Wait a little bit to be the last driver120 * in devman output.121 */122 //sleep(5);123 124 137 usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME); 125 138 126 139 printf(NAME ": virtual USB host controller driver.\n"); 127 140 128 /*129 * Initialize address management.130 */131 address_init();132 133 /*134 * Run the transfer scheduler.135 */136 hc_manager();137 138 /*139 * We are also a driver within devman framework.140 */141 141 return ddf_driver_main(&vhc_driver); 142 142 }
Note:
See TracChangeset
for help on using the changeset viewer.