Changeset 107932 in vbox for trunk/src/VBox/Devices/USB
- Timestamp:
- Jan 24, 2025 10:36:44 AM (4 weeks ago)
- svn:sync-xref-src-repo-rev:
- 167169
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/USB/DevXHCI.cpp
r107924 r107932 4546 4546 RTGCPHYS GCPhysInpSlot; 4547 4547 RTGCPHYS GCPhysOutSlot; 4548 RTGCPHYS GCPhysOutEndp;4549 4548 XHCI_INPC_CTX icc; /* Input Control Context (ICI=0). */ 4550 4549 XHCI_SLOT_CTX out_slot_ctx; /* Slot context (DCI=0). */ 4551 4550 XHCI_EP_CTX out_endp_ctx; /* Endpoint Context (DCI=1). */ 4552 4551 unsigned cc = XHCI_TCC_SUCCESS; 4553 uint32_t uAddFlags;4554 uint32_t uDropFlags;4555 unsigned num_inp_ctx;4556 unsigned num_out_ctx;4557 XHCI_DEV_CTX dc_inp;4558 XHCI_DEV_CTX dc_out;4559 4552 unsigned uDCI; 4560 4561 RT_ZERO(dc_inp);4562 4553 4563 4554 Assert(uSlotID); … … 4582 4573 4583 4574 /* Check for deconfiguration request. */ 4584 if (fDC) { 4585 if (out_slot_ctx.slot_state == XHCI_SLTST_CONFIGURED) { 4575 if (fDC) 4576 { 4577 if (out_slot_ctx.slot_state == XHCI_SLTST_CONFIGURED) 4578 { 4586 4579 /* Disable all enabled endpoints. */ 4587 uDropFlags = 0xFFFFFFFC; /** @todo r=bird: Why do you set uDropFlags and uAddFlags in a code path that doesn't use4588 * them? This is a _very_ difficult function to get the hang of the way it's written.4589 * Stuff like this looks like there's a control flow flaw (as to the do-break-while-false4590 * loop which doesn't do any clean up or logging at the end and seems only sever the very4591 * dubious purpose of making sure ther's only one return statement). The insistance on4592 * C-style variable declarations (top of function), makes checking state harder, which is4593 * why it's discouraged. */4594 uAddFlags = 0;4595 4596 /* Start with EP1. */ 4597 GCPhysOutEndp = GCPhysOutSlot + sizeof(XHCI_SLOT_CTX) + sizeof(XHCI_EP_CTX);4598 4580 /* This is a shortcut for handling the DC flag. It could also 4581 * be accomplished by setting 4582 * 4583 * uDropFlags = 0xFFFFFFFC; 4584 * uAddFlags = 0; 4585 * 4586 * and letting the generic code deal with it. However, here we minimize 4587 * memory accesses. 4588 */ 4589 4590 /* Disable EP1. */ 4591 RTGCPHYS GCPhysOutEndp = GCPhysOutSlot + sizeof(XHCI_SLOT_CTX) + sizeof(XHCI_EP_CTX); 4599 4592 PDMDevHlpPCIPhysReadMeta(pDevIns, GCPhysOutEndp, &out_endp_ctx, sizeof(out_endp_ctx)); 4600 4593 out_endp_ctx.ep_state = XHCI_EPST_DISABLED; 4601 4594 PDMDevHlpPCIPhysWriteMeta(pDevIns, GCPhysOutEndp, &out_endp_ctx, sizeof(out_endp_ctx)); 4602 GCPhysOutEndp += sizeof(XHCI_EP_CTX); /* Point to the next EP context. */4603 4595 4604 4596 /* Finally update the output slot context. */ … … 4609 4601 } 4610 4602 else 4611 /* NB: Attempts to deconfigure a slot in Addressed state are ignored. */4603 /* NB: Attempts to deconfigure a slot in Addressed state are silently ignored. */ 4612 4604 Log(("Ignoring attempt to deconfigure slot in Addressed state!\n")); 4613 4605 break; … … 4619 4611 Assert(icc.add_flags || icc.drop_flags); /* Make sure there's something to do. */ 4620 4612 4621 u AddFlags = icc.add_flags;4622 u DropFlags = icc.drop_flags;4613 uint32_t uAddFlags = icc.add_flags; 4614 uint32_t uDropFlags = icc.drop_flags; 4623 4615 LogFlowFunc(("Add Flags=%08X, Drop Flags=%08X\n", uAddFlags, uDropFlags)); 4616 4617 /* Start out with an empty input device context. */ 4618 XHCI_DEV_CTX dc_inp; 4619 RT_ZERO(dc_inp); 4624 4620 4625 4621 /* If and only if any 'add context' flag is set, fetch the corresponding … … 4633 4629 * including the one with the highest 'add' bit set. 4634 4630 */ 4635 num_inp_ctx = ASMBitLastSetU32(uAddFlags);4631 unsigned num_inp_ctx = ASMBitLastSetU32(uAddFlags); 4636 4632 Assert(num_inp_ctx); 4637 4633 PDMDevHlpPCIPhysReadMeta(pDevIns, GCPhysInpSlot, &dc_inp, num_inp_ctx * sizeof(XHCI_DS_ENTRY)); … … 4645 4641 * including the one with the highest 'add' or 'drop' bit set. 4646 4642 */ 4647 num_out_ctx = ASMBitLastSetU32(uAddFlags | uDropFlags); 4643 XHCI_DEV_CTX dc_out; 4644 unsigned num_out_ctx = ASMBitLastSetU32(uAddFlags | uDropFlags); 4648 4645 PDMDevHlpPCIPhysReadMeta(pDevIns, GCPhysOutSlot, &dc_out, num_out_ctx * sizeof(XHCI_DS_ENTRY)); 4649 4646 … … 4674 4671 4675 4672 /* Finally update the device context. */ 4676 if ( fDC ||dc_inp.entry[0].sc.ctx_ent == 1)4673 if (/*fDC ||*/ dc_inp.entry[0].sc.ctx_ent == 1) 4677 4674 { 4678 4675 dc_out.entry[0].sc.slot_state = XHCI_SLTST_ADDRESSED;
Note:
See TracChangeset
for help on using the changeset viewer.