Merged PR 5288: Updated PL011UartLib.c to not wait indefinitely during read

Updated PL011UartLib.c to not wait indefinitely during read
This commit is contained in:
Arti Gupta 2022-05-06 22:38:43 +00:00 коммит произвёл Ken Lautner
Родитель 3ebf3fb612
Коммит 4113f017d3
1 изменённых файлов: 20 добавлений и 21 удалений

Просмотреть файл

@ -404,6 +404,22 @@ PL011UartGetControl (
return RETURN_SUCCESS;
}
/**
Check to see if any data is available to be read from the debug device.
@retval TRUE At least one byte of data is available to be read
@retval FALSE No data is available to be read
**/
BOOLEAN
EFIAPI
PL011UartPoll (
IN UINTN UartBase
)
{
return ((MmioRead32 (UartBase + UARTFR) & UART_RX_EMPTY_FLAG_MASK) == 0);
}
/**
Write data to serial device.
@ -455,28 +471,11 @@ PL011UartRead (
{
UINTN Count;
for (Count = 0; Count < NumberOfBytes; Count++, Buffer++) {
while ((MmioRead32 (UartBase + UARTFR) & UART_RX_EMPTY_FLAG_MASK) != 0) {
}
// MU_CHANGE Starts: Do not wait indefinitely for the receive buffer to get filled.
for (Count = 0; (Count < NumberOfBytes) && PL011UartPoll (UartBase); Count++, Buffer++) {
*Buffer = MmioRead8 (UartBase + UARTDR);
}
return NumberOfBytes;
}
/**
Check to see if any data is available to be read from the debug device.
@retval TRUE At least one byte of data is available to be read
@retval FALSE No data is available to be read
**/
BOOLEAN
EFIAPI
PL011UartPoll (
IN UINTN UartBase
)
{
return ((MmioRead32 (UartBase + UARTFR) & UART_RX_EMPTY_FLAG_MASK) == 0);
// MU_CHANGE Ends
return Count;
}