-\r
- //\r
- // Read remaining data by executing one or more usb debug transfer transactions at usb debug port hw.\r
- //\r
- while (Total < NumberOfBytes) {\r
- if (Timeout != 0) {\r
- if (TimerRound == 0) {\r
- if (IsTimerTimeout (UsbDebugPortHandle, Begin, TimeoutTicker)) {\r
- //\r
- // If time out occurs.\r
- //\r
- return 0;\r
- }\r
- } else {\r
- if (IsTimerTimeout (UsbDebugPortHandle, Begin, DivU64x32 (UsbDebugPortHandle->TimerCycle, 2))) {\r
- TimerRound --;\r
- }\r
- }\r
- }\r
- Remaining = NumberOfBytes - Total;\r
- if (Remaining >= XHCI_DEBUG_DEVICE_MAX_PACKET_SIZE) {\r
- Received = XHCI_DEBUG_DEVICE_MAX_PACKET_SIZE;\r
- Status = XhcDataTransfer (UsbDebugPortHandle, EfiUsbDataIn, Buffer + Total, &Received, DATA_TRANSFER_READ_TIMEOUT);\r
- } else {\r
- Received = XHCI_DEBUG_DEVICE_MAX_PACKET_SIZE;\r
- Status = XhcDataTransfer (UsbDebugPortHandle, EfiUsbDataIn, (VOID *)Data, &Received, DATA_TRANSFER_READ_TIMEOUT);\r
- UsbDebugPortHandle->DataCount = (UINT8) Received;\r
-\r
- if (Remaining <= Received) {\r
- //\r
- // The data received are more than required\r
- //\r
- Length = (UINT8)Remaining;\r
- } else {\r
- //\r
- // The data received are less than the remaining bytes\r
- //\r
- Length = (UINT8)Received;\r
- }\r
-\r
- //\r
- // Copy required data from the data buffer to user buffer.\r
- //\r
- for (Index = 0; Index < Length; Index++) {\r
- (Buffer + Total)[Index] = Data[Index];\r
- UsbDebugPortHandle->DataCount--;\r
- }\r
-\r
- //\r
- // reorder the data buffer to make available data arranged from the beginning of the data buffer.\r
- //\r
- for (Index = 0; Index < Received - Length; Index++) {\r
- if (Length + Index >= XHCI_DEBUG_DEVICE_MAX_PACKET_SIZE) {\r
- return 0;\r
- }\r
- Data[Index] = Data[Length + Index];\r
- }\r
- //\r
- // fixup the real required length of data.\r
- //\r
- Received = Length;\r
- }\r
- Total += Received;\r
- }\r
- return Total;\r