Changeset 04df063 in mainline for uspace/drv/bus/usb/xhci/commands.c
- Timestamp:
- 2017-10-02T19:16:29Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1f76b7d
- Parents:
- 370a1c8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/commands.c
r370a1c8 r04df063 73 73 // Note: Untested. 74 74 assert(hc); 75 76 // We assume that the hc is dying/stopping, so we ignore 77 // the ownership of the commands. 78 list_foreach(hc->commands, link, xhci_cmd_t, cmd) { 79 xhci_free_command(cmd); 80 } 81 } 82 83 int xhci_wait_for_command(xhci_cmd_t *cmd, suseconds_t timeout) 75 } 76 77 int xhci_cmd_wait(xhci_cmd_t *cmd, suseconds_t timeout) 84 78 { 85 79 int rv = EOK; … … 99 93 } 100 94 101 xhci_cmd_t *xhci_ alloc_command(void)95 xhci_cmd_t *xhci_cmd_alloc(void) 102 96 { 103 97 xhci_cmd_t *cmd = malloc32(sizeof(xhci_cmd_t)); 104 98 xhci_cmd_init(cmd); 99 100 usb_log_debug2("Allocating cmd on the heap. Don't forget to deallocate it!"); 105 101 return cmd; 106 102 } … … 114 110 fibril_mutex_initialize(&cmd->completed_mtx); 115 111 fibril_condvar_initialize(&cmd->completed_cv); 116 117 /** 118 * Internal functions will set this to false, other are implicit 119 * owners unless they overwrite this field. 120 * TODO: Is this wise? 121 */ 122 cmd->has_owner = true; 123 } 124 125 void xhci_free_command(xhci_cmd_t *cmd) 112 } 113 114 void xhci_cmd_fini(xhci_cmd_t *cmd) 126 115 { 127 116 list_remove(&cmd->link); 128 129 if (cmd->ictx) 130 free32(cmd->ictx); 131 117 } 118 119 void xhci_cmd_free(xhci_cmd_t *cmd) 120 { 121 xhci_cmd_fini(cmd); 132 122 free32(cmd); 133 123 } … … 299 289 } 300 290 301 int xhci_send_address_device_command(xhci_hc_t *hc, xhci_cmd_t *cmd )302 { 303 assert(hc); 304 assert(cmd); 305 assert( cmd->ictx);291 int xhci_send_address_device_command(xhci_hc_t *hc, xhci_cmd_t *cmd, xhci_input_ctx_t *ictx) 292 { 293 assert(hc); 294 assert(cmd); 295 assert(ictx); 306 296 307 297 /** … … 311 301 * other should be ignored at this point (see section 4.6.5). 312 302 */ 313 xhci_trb_clean(&cmd->trb); 314 315 uint64_t phys_addr = (uint64_t) addr_to_phys(cmd->ictx); 303 304 xhci_trb_clean(&cmd->trb); 305 306 uint64_t phys_addr = (uint64_t) addr_to_phys(ictx); 316 307 TRB_SET_ICTX(cmd->trb, phys_addr); 317 308 … … 329 320 } 330 321 331 int xhci_send_configure_endpoint_command(xhci_hc_t *hc, xhci_cmd_t *cmd )332 { 333 assert(hc); 334 assert(cmd); 335 assert( cmd->ictx);336 337 xhci_trb_clean(&cmd->trb); 338 339 uint64_t phys_addr = (uint64_t) addr_to_phys( cmd->ictx);322 int xhci_send_configure_endpoint_command(xhci_hc_t *hc, xhci_cmd_t *cmd, xhci_input_ctx_t *ictx) 323 { 324 assert(hc); 325 assert(cmd); 326 assert(ictx); 327 328 xhci_trb_clean(&cmd->trb); 329 330 uint64_t phys_addr = (uint64_t) addr_to_phys(ictx); 340 331 TRB_SET_ICTX(cmd->trb, phys_addr); 341 332 … … 346 337 } 347 338 348 int xhci_send_evaluate_context_command(xhci_hc_t *hc, xhci_cmd_t *cmd )349 { 350 assert(hc); 351 assert(cmd); 352 assert( cmd->ictx);339 int xhci_send_evaluate_context_command(xhci_hc_t *hc, xhci_cmd_t *cmd, xhci_input_ctx_t *ictx) 340 { 341 assert(hc); 342 assert(cmd); 343 assert(ictx); 353 344 354 345 /** … … 360 351 xhci_trb_clean(&cmd->trb); 361 352 362 uint64_t phys_addr = (uint64_t) addr_to_phys( cmd->ictx);353 uint64_t phys_addr = (uint64_t) addr_to_phys(ictx); 363 354 TRB_SET_ICTX(cmd->trb, phys_addr); 364 355 … … 455 446 if (command == NULL) { 456 447 // TODO: STOP & ABORT may not have command structs in the list! 457 usb_log_ error("No command struct for this completion event");448 usb_log_debug("No command struct for this completion event found."); 458 449 459 450 if (code != XHCI_TRBC_SUCCESS) … … 509 500 fibril_mutex_unlock(&command->completed_mtx); 510 501 511 512 if (!command->has_owner) {513 usb_log_debug2("Command has no owner, deallocating.");514 xhci_free_command(command);515 } else {516 usb_log_debug2("Command has owner, don't forget to deallocate!");517 }518 519 502 return EOK; 520 503 }
Note:
See TracChangeset
for help on using the changeset viewer.