Changeset 19a1800 in mainline for uspace/drv/vhc/hub.c
- Timestamp:
- 2011-03-01T22:20:56Z (14 years ago)
- 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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/vhc/hub.c
r976f546 r19a1800 27 27 */ 28 28 29 /** @addtogroup usb29 /** @addtogroup drvusbvhc 30 30 * @{ 31 31 */ … … 39 39 #include <str_error.h> 40 40 #include <stdlib.h> 41 #include <driver.h> 42 #include <usb/usbdrv.h> 41 #include <ddf/driver.h> 42 #include <devman.h> 43 #include <usb/hub.h> 44 #include <usb/recognise.h> 43 45 44 46 #include "hub.h" 45 47 #include "hub/virthub.h" 46 48 #include "vhcd.h" 49 #include "conn.h" 47 50 48 51 usbvirt_device_t virtual_hub_device; 52 static ddf_dev_ops_t rh_ops = { 53 .interfaces[USB_DEV_IFACE] = &rh_usb_iface, 54 }; 49 55 50 56 static int hub_register_in_devman_fibril(void *arg); 51 57 52 void virtual_hub_device_init(d evice_t *hc_dev)58 void virtual_hub_device_init(ddf_fun_t *hc_dev) 53 59 { 54 60 virthub_init(&virtual_hub_device); … … 63 69 = fibril_create(hub_register_in_devman_fibril, hc_dev); 64 70 if (root_hub_registration == 0) { 65 printf(NAME ": failed to register root hub\n");71 usb_log_fatal("Failed to create hub registration fibril.\n"); 66 72 return; 67 73 } 68 74 69 75 fibril_add_ready(root_hub_registration); 76 } 77 78 static int pretend_port_rest(int unused, void *unused2) 79 { 80 return EOK; 70 81 } 71 82 … … 77 88 int hub_register_in_devman_fibril(void *arg) 78 89 { 79 d evice_t *hc_dev = (device_t *) arg;90 ddf_fun_t *hc_dev = (ddf_fun_t *) arg; 80 91 81 int hc = usb_drv_hc_connect(hc_dev, hc_dev->handle, IPC_FLAG_BLOCKING); 82 if (hc < 0) { 83 printf(NAME ": failed to register root hub\n"); 84 return hc; 92 /* 93 * Wait until parent device is properly initialized. 94 */ 95 int phone; 96 do { 97 phone = devman_device_connect(hc_dev->handle, 0); 98 } while (phone < 0); 99 async_hangup(phone); 100 101 int rc; 102 103 usb_hc_connection_t hc_conn; 104 rc = usb_hc_connection_initialize(&hc_conn, hc_dev->handle); 105 assert(rc == EOK); 106 107 rc = usb_hc_connection_open(&hc_conn); 108 assert(rc == EOK); 109 110 ddf_fun_t *hub_dev; 111 rc = usb_hc_new_device_wrapper(hc_dev->dev, &hc_conn, 112 USB_SPEED_FULL, 113 pretend_port_rest, 0, NULL, 114 NULL, NULL, &rh_ops, hc_dev, &hub_dev); 115 if (rc != EOK) { 116 usb_log_fatal("Failed to create root hub: %s.\n", 117 str_error(rc)); 85 118 } 86 119 87 usb_ drv_reserve_default_address(hc);120 usb_hc_connection_close(&hc_conn); 88 121 89 usb_ address_t hub_address = usb_drv_request_address(hc);90 usb_drv_req_set_address(hc, USB_ADDRESS_DEFAULT, hub_address);122 usb_log_info("Created root hub function (handle %zu).\n", 123 (size_t) hub_dev->handle); 91 124 92 usb_drv_release_default_address(hc); 93 94 devman_handle_t hub_handle; 95 usb_drv_register_child_in_devman(hc, hc_dev, hub_address, &hub_handle); 96 usb_drv_bind_address(hc, hub_address, hub_handle); 97 98 return EOK; 125 return 0; 99 126 } 100 127
Note:
See TracChangeset
for help on using the changeset viewer.