Changeset 8f8ae1fd in mainline
- Timestamp:
- 2010-12-13T09:57:22Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7feeb84
- Parents:
- 97e660e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/vhc/hub.c
r97e660e r8f8ae1fd 40 40 #include <stdlib.h> 41 41 #include <driver.h> 42 #include <usb/usbdrv.h> 42 43 43 44 #include "vhcd.h" … … 151 152 hub_device_t hub_dev; 152 153 153 static usb_address_t hub_set_address(usbvirt_device_t *hub) 154 { 155 usb_address_t new_address; 156 int rc = vhc_iface.request_address(NULL, &new_address); 157 if (rc != EOK) { 158 return rc; 159 } 160 161 usb_device_request_setup_packet_t setup_packet = { 162 .request_type = 0, 163 .request = USB_DEVREQ_SET_ADDRESS, 164 .index = 0, 165 .length = 0, 166 }; 167 setup_packet.value = new_address; 168 169 hub->transaction_setup(hub, 0, &setup_packet, sizeof(setup_packet)); 170 hub->transaction_in(hub, 0, NULL, 0, NULL); 171 172 return new_address; 154 /** Register root hub in devman. 155 * 156 * @param arg Host controller device (type <code>device_t *</code>). 157 * @return Error code. 158 */ 159 static int hub_register_in_devman_fibril(void *arg) 160 { 161 device_t *hc_dev = (device_t *) arg; 162 163 int hc = usb_drv_hc_connect(hc_dev, IPC_FLAG_BLOCKING); 164 if (hc < 0) { 165 printf(NAME ": failed to register root hub\n"); 166 return hc; 167 } 168 169 usb_drv_reserve_default_address(hc); 170 171 usb_address_t hub_address = usb_drv_request_address(hc); 172 usb_drv_req_set_address(hc, USB_ADDRESS_DEFAULT, hub_address); 173 174 usb_drv_release_default_address(hc); 175 176 devman_handle_t hub_handle; 177 usb_drv_register_child_in_devman(hc, hc_dev, hub_address, &hub_handle); 178 usb_drv_bind_address(hc, hub_address, hub_handle); 179 180 return EOK; 173 181 } 174 182 … … 190 198 usbvirt_connect_local(&virthub_dev); 191 199 192 dprintf(1, "virtual hub (%d ports) created", HUB_PORT_COUNT); 193 194 usb_address_t hub_address = hub_set_address(&virthub_dev); 195 if (hub_address < 0) { 196 dprintf(1, "problem changing hub address (%s)", 197 str_error(hub_address)); 198 } 199 200 dprintf(2, "virtual hub address changed to %d", hub_address); 201 202 char *id; 203 int rc = asprintf(&id, "usb&hub"); 204 if (rc <= 0) { 200 /* 201 * We need to register the root hub. 202 * This must be done in separate fibril because the device 203 * we are connecting to are ourselves and we cannot connect 204 * before leaving the add_device() function. 205 */ 206 fid_t root_hub_registration 207 = fibril_create(hub_register_in_devman_fibril, hc_dev); 208 if (root_hub_registration == 0) { 209 printf(NAME ": failed to register root hub\n"); 205 210 return; 206 211 } 207 devman_handle_t hub_handle; 208 rc = child_device_register_wrapper(hc_dev, "hub", id, 10, &hub_handle); 209 if (rc != EOK) { 210 free(id); 211 } 212 213 vhc_iface.bind_address(NULL, hub_address, hub_handle); 214 215 dprintf(2, "virtual hub has devman handle %d", (int) hub_handle); 212 213 fibril_add_ready(root_hub_registration); 216 214 } 217 215
Note:
See TracChangeset
for help on using the changeset viewer.