Skip to content

Commit 100b667

Browse files
artgupos-d
authored andcommitted
ArmPlatformPkg: Updated PL011UartLib.c to not wait indefinitely during read
This patch updates PL011UartLib.c to not wait until the RX buffer has data in it, but return if the buffer is empty.
1 parent d46197e commit 100b667

File tree

1 file changed

+24
-19
lines changed

1 file changed

+24
-19
lines changed

ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.c

+24-19
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,24 @@ PL011UartWrite (
435435
return NumberOfBytes;
436436
}
437437

438+
// MU_CHANGE Starts: Do not wait indefinitely for the receive buffer to get filled.
439+
440+
/**
441+
Check to see if any data is available to be read from the debug device.
442+
443+
@retval TRUE At least one byte of data is available to be read
444+
@retval FALSE No data is available to be read
445+
446+
**/
447+
BOOLEAN
448+
EFIAPI
449+
PL011UartPoll (
450+
IN UINTN UartBase
451+
)
452+
{
453+
return ((MmioRead32 (UartBase + UARTFR) & UART_RX_EMPTY_FLAG_MASK) == 0);
454+
}
455+
438456
/**
439457
Read data from serial device and save the data in buffer.
440458
@@ -455,28 +473,15 @@ PL011UartRead (
455473
{
456474
UINTN Count;
457475

458-
for (Count = 0; Count < NumberOfBytes; Count++, Buffer++) {
459-
while ((MmioRead32 (UartBase + UARTFR) & UART_RX_EMPTY_FLAG_MASK) != 0) {
460-
}
476+
// for (Count = 0; Count < NumberOfBytes; Count++, Buffer++) {
477+
// while ((MmioRead32 (UartBase + UARTFR) & UART_RX_EMPTY_FLAG_MASK) != 0) {
478+
// }
461479

480+
for (Count = 0; (Count < NumberOfBytes) && PL011UartPoll (UartBase); Count++, Buffer++) {
462481
*Buffer = MmioRead8 (UartBase + UARTDR);
463482
}
464483

465-
return NumberOfBytes;
466-
}
467-
468-
/**
469-
Check to see if any data is available to be read from the debug device.
470-
471-
@retval TRUE At least one byte of data is available to be read
472-
@retval FALSE No data is available to be read
484+
return Count;
473485

474-
**/
475-
BOOLEAN
476-
EFIAPI
477-
PL011UartPoll (
478-
IN UINTN UartBase
479-
)
480-
{
481-
return ((MmioRead32 (UartBase + UARTFR) & UART_RX_EMPTY_FLAG_MASK) == 0);
486+
// MU_CHANGE Ends
482487
}

0 commit comments

Comments
 (0)