summaryrefslogtreecommitdiffstats
path: root/ArmVirtPkg
diff options
context:
space:
mode:
authorLaszlo Ersek <lersek@redhat.com>2017-08-16 12:45:59 +0200
committerLaszlo Ersek <lersek@redhat.com>2017-08-17 14:13:23 +0200
commit5f0f5e90ae8c57f4a0702740d5aee95ce50fc684 (patch)
treebee99c11f3b76409757f22a951c78c5364da600b /ArmVirtPkg
parentca56256d5e0b7e63325b049e90a6bd03f90e3598 (diff)
downloadedk2-5f0f5e90ae8c57f4a0702740d5aee95ce50fc684.tar.gz
edk2-5f0f5e90ae8c57f4a0702740d5aee95ce50fc684.tar.bz2
edk2-5f0f5e90ae8c57f4a0702740d5aee95ce50fc684.zip
ArmVirtPkg/FdtPL011SerialPortLib: call PL011UartLib in all SerialPortLib APIs
With the SerialDxe change in commit 4cf3f37c87ba ("MdeModulePkg SerialDxe: Process timeout consistently in SerialRead", 2017-07-18), setting EFI_SERIAL_INPUT_BUFFER_EMPTY in the "Control" output parameter, in the GetControl() SerialPortLib function, is no longer a "small optimization". Namely, due to the SerialDxe change, the GetOneKeyFromSerial() call in TerminalDxe's TerminalConInTimerHandler() can take very long if the input queue is empty, even if GetOneKeyFromSerial()'s return value causes the loop to be exited right after, in the first iteration. This issue causes a boot hang in ArmVirtQemu: with the input queue empty, TerminalConInTimerHandler() takes so long to return that, by the time it returns, there's another execution queued already (due to the associated timer event being signaled meanwhile). The boot process is stuck in the timer event handler. Therefore even the first GetOneKeyFromSerial() iteration must be prevented in TerminalConInTimerHandler() if the input queue is empty, and that requires implementing GetControl() for real. Implement the SetAttributes(), SetControl() and GetControl() APIs (of SerialPortExtLib origin) in FdtPL011SerialPortLib with calls to matching PL011UartLib functions. This follows the example of "ArmPlatformPkg/Library/PL011SerialPortLib" and also matches Star's original idea under [1]. The patch can be considered a continuation of commit ad7f6bc2e116 ("ArmVirtPkg: Use SerialDxe in MdeModulePkg instead of EmbeddedPkg", 2015-11-26), based on the mailing list threads [1] [2] [3]. [1] http://mid.mail-archive.com/1447752930-32880-12-git-send-email-star.zeng@intel.com [2] http://mid.mail-archive.com/1448243067-1880-12-git-send-email-star.zeng@intel.com [3] http://mid.mail-archive.com/b748580c-cb51-32c9-acf9-780841ef15da@redhat.com Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Brijesh Singh <brijesh.singh@amd.com> Cc: Heyi Guo <guoheyi@huawei.com> Cc: Star Zeng <star.zeng@intel.com> Originally-suggested-by: Star Zeng <star.zeng@intel.com> Reported-by: Brijesh Singh <brijesh.singh@amd.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Tested-by: Brijesh Singh <brijesh.singh@amd.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
Diffstat (limited to 'ArmVirtPkg')
-rw-r--r--ArmVirtPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.c38
1 files changed, 35 insertions, 3 deletions
diff --git a/ArmVirtPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.c b/ArmVirtPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.c
index 48a0530dcc..05d3547fda 100644
--- a/ArmVirtPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.c
+++ b/ArmVirtPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.c
@@ -200,7 +200,23 @@ SerialPortSetAttributes (
IN OUT EFI_STOP_BITS_TYPE *StopBits
)
{
- return RETURN_UNSUPPORTED;
+ RETURN_STATUS Status;
+
+ if (mSerialBaseAddress == 0) {
+ Status = RETURN_UNSUPPORTED;
+ } else {
+ Status = PL011UartInitializePort (
+ mSerialBaseAddress,
+ FixedPcdGet32 (PL011UartClkInHz),
+ BaudRate,
+ ReceiveFifoDepth,
+ Parity,
+ DataBits,
+ StopBits
+ );
+ }
+
+ return Status;
}
/**
@@ -219,7 +235,15 @@ SerialPortSetControl (
IN UINT32 Control
)
{
- return RETURN_UNSUPPORTED;
+ RETURN_STATUS Status;
+
+ if (mSerialBaseAddress == 0) {
+ Status = RETURN_UNSUPPORTED;
+ } else {
+ Status = PL011UartSetControl (mSerialBaseAddress, Control);
+ }
+
+ return Status;
}
/**
@@ -238,6 +262,14 @@ SerialPortGetControl (
OUT UINT32 *Control
)
{
- return RETURN_UNSUPPORTED;
+ RETURN_STATUS Status;
+
+ if (mSerialBaseAddress == 0) {
+ Status = RETURN_UNSUPPORTED;
+ } else {
+ Status = PL011UartGetControl (mSerialBaseAddress, Control);
+ }
+
+ return Status;
}