Changeset 867b375 in mainline for uspace/drv/bus/usb/xhci/rh.c
- Timestamp:
- 2017-10-15T02:04:10Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 20eaa82
- Parents:
- d7869d7e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/rh.c
rd7869d7e r867b375 38 38 #include <usb/debug.h> 39 39 #include <usb/host/utils/malloc32.h> 40 #include <usb/host/ddf_helpers.h> 41 40 42 #include "debug.h" 41 43 #include "commands.h" … … 69 71 // TODO: Check device deallocation, we free device_ctx in hc.c, not 70 72 // sure about the other structs. 71 static int alloc_dev(xhci_hc_t *hc, uint8_t port, uint32_t route_str) 73 // TODO: This currently assumes the device is attached to rh directly. 74 // Also, we should consider moving a lot of functionailty to xhci bus 75 int xhci_rh_address_device(xhci_rh_t *rh, usb_speed_t unused_speed, usb_tt_address_t tt, usb_address_t *address) 72 76 { 73 77 int err; 78 xhci_hc_t *hc = rh->hc; 74 79 75 80 xhci_cmd_t cmd; 76 81 xhci_cmd_init(&cmd); 77 82 78 const xhci_port_speed_t *speed = xhci_rh_get_port_speed(&hc->rh, port); 83 uint8_t port = tt.port; 84 85 /* XXX Certainly not generic solution. */ 86 uint32_t route_str = 0; 87 88 const xhci_port_speed_t *speed = xhci_rh_get_port_speed(rh, port); 79 89 80 90 xhci_send_enable_slot_command(hc, &cmd); … … 127 137 XHCI_EP_ERROR_COUNT_SET(ictx->endpoint_ctx[0], 3); 128 138 129 // TODO: What's the alignment? 130 xhci_device_ctx_t *dctx = malloc(sizeof(xhci_device_ctx_t)); 139 xhci_device_ctx_t *dctx = malloc32(sizeof(xhci_device_ctx_t)); 131 140 if (!dctx) { 132 141 err = ENOMEM; … … 149 158 xhci_cmd_fini(&cmd); 150 159 151 usb_address_taddress = XHCI_SLOT_DEVICE_ADDRESS(dctx->slot_ctx);152 usb_log_debug2("Obtained USB address: %d.\n", address);160 *address = XHCI_SLOT_DEVICE_ADDRESS(dctx->slot_ctx); 161 usb_log_debug2("Obtained USB address: %d.\n", *address); 153 162 154 163 // TODO: Ask libusbhost to create a control endpoint for EP0. … … 174 183 } 175 184 185 static int rh_setup_device(xhci_rh_t *rh, uint8_t port_id) 186 { 187 /** This should ideally use the libusbhost in a clean and elegant way, 188 * to create child function. The refactoring of libusbhost is not over 189 * yet, so for now it is still quirky. 190 */ 191 192 return hcd_roothub_new_device(rh->hcd_rh, port_id); 193 } 194 176 195 static int handle_connected_device(xhci_rh_t *rh, uint8_t port_id) 177 196 { … … 186 205 if (link_state == 0) { 187 206 /* USB3 is automatically advanced to enabled. */ 188 return alloc_dev(rh->hc, port_id, 0);207 return rh_setup_device(rh, port_id); 189 208 } 190 209 else if (link_state == 5) { … … 270 289 * every time USB2 port is reset. This is a 271 290 * temporary workaround. */ 272 alloc_dev(rh->hc, i, 0);291 rh_setup_device(rh, i); 273 292 } 274 293 }
Note:
See TracChangeset
for help on using the changeset viewer.