/** @file\r
Debug Port Library implementation based on usb3 debug port.\r
\r
- Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
// Internal buffer is used by next read.\r
//\r
Handle->DataCount = (UINT8) (Handle->UrbIn.DataLen - EvtTrb->Length);\r
- CopyMem (Handle->Data, (VOID *)(UINTN)Handle->UrbIn.Data, Handle->DataCount);\r
+ CopyMem ((VOID *)(UINTN)Handle->Data, (VOID *)(UINTN)Handle->UrbIn.Data, Handle->DataCount);\r
//\r
// Fill this TRB complete with CycleBit, otherwise next read will fail with old TRB.\r
//\r
//\r
// The length of data which were transferred.\r
//\r
- CheckedUrb->Completed += (CheckedUrb->DataLen - EvtTrb->Length);\r
+ CheckedUrb->Completed += (((TRANSFER_TRB_NORMAL*)TRBPtr)->Length - EvtTrb->Length);\r
} else {\r
CheckedUrb->Result |= EFI_USB_ERR_TIMEOUT;\r
}\r
)\r
{\r
TRANSFER_RING *Ring;\r
- UINT64 Begin;\r
- UINT64 TimeoutTicker;\r
- UINT64 TimerRound;\r
TRB_TEMPLATE *Trb;\r
+ UINTN Loop;\r
+ UINTN Index;\r
\r
- Begin = 0;\r
- TimeoutTicker = 0; \r
- TimerRound = 0;\r
-\r
- XhcRingDoorBell (Handle, Urb);\r
-\r
- if (Timeout != 0) {\r
- Begin = GetPerformanceCounter ();\r
- TimeoutTicker = DivU64x32 (\r
- MultU64x64 (\r
- Handle->TimerFrequency,\r
- Timeout\r
- ),\r
- 1000000u\r
- );\r
- TimerRound = DivU64x64Remainder (\r
- TimeoutTicker,\r
- DivU64x32 (Handle->TimerCycle, 2),\r
- &TimeoutTicker\r
- );\r
+ Loop = Timeout / XHC_DEBUG_PORT_1_MILLISECOND;\r
+ if (Timeout == 0) {\r
+ Loop = 0xFFFFFFFF;\r
}\r
-\r
+ XhcRingDoorBell (Handle, Urb);\r
//\r
// Event Ring Not Empty bit can only be set to 1 by XHC after ringing door bell with some delay.\r
//\r
- while (TRUE) {\r
- if (Timeout != 0) {\r
- if (TimerRound == 0) {\r
- if (IsTimerTimeout (Handle, Begin, TimeoutTicker)) {\r
- //\r
- // If time out occurs.\r
- //\r
- Urb->Result |= EFI_USB_ERR_TIMEOUT;\r
- break;\r
- }\r
- } else {\r
- if (IsTimerTimeout (Handle, Begin, DivU64x32 (Handle->TimerCycle, 2))) {\r
- TimerRound --;\r
- }\r
- }\r
- }\r
+ for (Index = 0; Index < Loop; Index++) {\r
XhcCheckUrbResult (Handle, Urb);\r
if (Urb->Finished) {\r
break;\r
}\r
+ MicroSecondDelay (XHC_DEBUG_PORT_1_MILLISECOND);\r
}\r
- \r
+ if (Index == Loop) {\r
+ //\r
+ // If time out occurs.\r
+ //\r
+ Urb->Result |= EFI_USB_ERR_TIMEOUT;\r
+ } \r
//\r
// If URB transfer is error, restore transfer ring to original value before URB transfer\r
// This will make the current transfer TRB is always at the latest unused one in transfer ring.\r
\r
Urb->Trb = EPRing->RingEnqueue;\r
Trb = (TRB *)(UINTN)EPRing->RingEnqueue;\r
- Trb = (TRB *)(UINTN)EPRing->RingEnqueue;\r
Trb->TrbNormal.TRBPtrLo = XHC_LOW_32BIT (Urb->Data);\r
Trb->TrbNormal.TRBPtrHi = XHC_HIGH_32BIT (Urb->Data);\r
Trb->TrbNormal.Length = Urb->DataLen;\r