Changeset 01eeaaf in mainline for uspace/drv/bus/usb/vhc/main.c
- Timestamp:
- 2012-12-22T15:07:29Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f6577d9
- Parents:
- 94c40ce2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/vhc/main.c
r94c40ce2 r01eeaaf 44 44 #include <ddf/driver.h> 45 45 46 #include <usb/host/ddf_helpers.h> 47 46 48 #include <usb/usb.h> 47 49 #include <usb/ddfiface.h> … … 52 54 53 55 static ddf_dev_ops_t vhc_ops = { 56 #if 0 54 57 .interfaces[USBHC_DEV_IFACE] = &vhc_iface, 55 58 .interfaces[USB_DEV_IFACE] = &vhc_usb_iface, 59 #endif 56 60 .close = on_client_close, 57 61 .default_handler = default_connection_handler 58 62 }; 59 63 64 static int vhc_control_node(ddf_dev_t *dev, ddf_fun_t **fun) 65 { 66 assert(dev); 67 assert(fun); 68 69 *fun = ddf_fun_create(dev, fun_exposed, "ctl"); 70 if (!*fun) 71 return ENOMEM; 72 73 vhc_data_t *vhc = ddf_fun_data_alloc(*fun, sizeof(vhc_data_t)); 74 if (!vhc) { 75 ddf_fun_destroy(*fun); 76 } 77 ddf_fun_set_ops(*fun, &vhc_ops); 78 const int ret = ddf_fun_bind(*fun); 79 if (ret != EOK) { 80 ddf_fun_destroy(*fun); 81 *fun = NULL; 82 return ret; 83 } 84 vhc_data_init(vhc); 85 // TODO: This limits us to single vhc instance. 86 virthub_init(&virtual_hub_device); 87 vhc->hub = &virtual_hub_device; 88 return EOK; 89 } 90 91 60 92 static int vhc_dev_add(ddf_dev_t *dev) 61 93 { 94 /* Initialize virtual structure */ 95 ddf_fun_t *ctl_fun = NULL; 96 int ret = vhc_control_node(dev, &ctl_fun); 97 if (ret != EOK) { 98 usb_log_error("Failed to setup control node.\n"); 99 return ret; 100 } 101 vhc_data_t *data = ddf_fun_data_get(ctl_fun); 102 103 /* Initialize generic structures */ 104 ret = hcd_ddf_setup_device(dev, NULL, USB_SPEED_FULL, 105 BANDWIDTH_AVAILABLE_USB11, bandwidth_count_usb11); 106 if (ret != EOK) { 107 usb_log_error("Failed to init HCD structures: %s.\n", 108 str_error(ret)); 109 free(data); 110 return ret; 111 } 112 113 hcd_set_implementation(dev_to_hcd(dev), data, vhc_schedule, NULL, NULL); 114 115 /* Add virtual hub device */ 116 usb_address_t address = 1; 117 ret = vhc_virtdev_plug_hub(data, data->hub, NULL, address); 118 if (ret != EOK) { 119 usb_log_error("Failed to plug root hub: %s.\n", str_error(ret)); 120 free(data); 121 return ret; 122 } 123 124 // TODO fix the address hack 125 ret = hcd_ddf_setup_hub(dev, &address); 126 if (ret != EOK) { 127 usb_log_error("Failed to init VHC root hub: %s\n", 128 str_error(ret)); 129 // TODO do something here... 130 } 131 132 return ret; 133 #if 0 62 134 static int vhc_count = 0; 63 135 int rc; … … 124 196 125 197 return EOK; 198 #endif 126 199 } 127 200 … … 137 210 138 211 int main(int argc, char * argv[]) 139 { 212 { 140 213 log_init(NAME); 141 214 … … 145 218 } 146 219 147 148 220 /** 149 221 * @}
Note:
See TracChangeset
for help on using the changeset viewer.