From 2d43dcfc6ccfafe1e0db09e3b0371be3b42a0f3a Mon Sep 17 00:00:00 2001 From: Sean Brogan Date: Tue, 2 Jul 2024 13:28:04 -0700 Subject: [PATCH] PcAtChipsetPkg/SerialIoLib: Allow configurable UART IO Port Base Address Today's implementation used a hardcoded value for the I/O Port Base Address. This creates a problem for platform configurability. If a platform needs to use a different I/O port address, then it requires modification of a source file. Create gPcAtChipsetPkgTokenSpaceGuid.PcdUartIoPortBaseAddress as a FixedAtBuild pcd scoped to PcAtChipsetPkg, with default value for 0x3f8 to match existing value, and update code to use PCD. Signed-off-by: Aaron Pop --- PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf | 3 +++ PcAtChipsetPkg/Library/SerialIoLib/SerialPortLib.c | 2 +- PcAtChipsetPkg/PcAtChipsetPkg.dec | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf b/PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf index d02259a07c..1c5099cdb5 100644 --- a/PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf +++ b/PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf @@ -17,6 +17,7 @@ [Packages] MdePkg/MdePkg.dec + PcAtChipsetPkg/PcAtChipsetPkg.dec [LibraryClasses] BaseLib @@ -25,3 +26,5 @@ [Sources] SerialPortLib.c +[Pcd] + gPcAtChipsetPkgTokenSpaceGuid.PcdUartIoPortBaseAddress diff --git a/PcAtChipsetPkg/Library/SerialIoLib/SerialPortLib.c b/PcAtChipsetPkg/Library/SerialIoLib/SerialPortLib.c index 11537ec276..6e25b1ba5a 100644 --- a/PcAtChipsetPkg/Library/SerialIoLib/SerialPortLib.c +++ b/PcAtChipsetPkg/Library/SerialIoLib/SerialPortLib.c @@ -43,7 +43,7 @@ // --------------------------------------------- // UART Settings // --------------------------------------------- -UINT16 gUartBase = 0x3F8; +UINT16 gUartBase = FixedPcdGet16 (PcdUartIoPortBaseAddress); UINTN gBps = 115200; UINT8 gData = 8; UINT8 gStop = 1; diff --git a/PcAtChipsetPkg/PcAtChipsetPkg.dec b/PcAtChipsetPkg/PcAtChipsetPkg.dec index 0db385fb90..8026fcd8a8 100644 --- a/PcAtChipsetPkg/PcAtChipsetPkg.dec +++ b/PcAtChipsetPkg/PcAtChipsetPkg.dec @@ -164,5 +164,10 @@ # @Prompt RTC Update Timeout Value. gPcAtChipsetPkgTokenSpaceGuid.PcdRealTimeClockUpdateTimeout|100000|UINT32|0x00000020 +[PcdsFixedAtBuild] + ## Defines the UART base address. + # @Prompt UART IO Port Base Address + gPcAtChipsetPkgTokenSpaceGuid.PcdUartIoPortBaseAddress|0x3F8|UINT16|0x00000024 + [UserExtensions.TianoCore."ExtraFiles"] PcAtChipsetPkgExtra.uni