From: "Guo, Mang" <mang.guo@intel.com>
To: "Steele, Kelly" <kelly.steele@intel.com>,
"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Wei, David" <david.wei@intel.com>
Subject: Re: [PATCH] [edk2-platforms/devel-IntelAtomProcessorE3900] Dynamic debug UART
Date: Thu, 27 Sep 2018 06:15:33 +0000 [thread overview]
Message-ID: <22D2C85ED001C54AA20BFE3B0E4751D1526FC0A1@SHSMSX103.ccr.corp.intel.com> (raw)
In-Reply-To: <E6EF8131FBAF5A44BF17D9E2B45E20755FBE669E@ORSMSX114.amr.corp.intel.com>
Reviewed-by: Guo Mang <mang.guo@intel.com<mailto:mang.guo@intel.com>>
Thanks,
Mang
From: Steele, Kelly
Sent: Saturday, September 22, 2018 2:30 AM
To: edk2-devel@lists.01.org
Cc: Wei, David; Guo, Mang
Subject: [PATCH] [edk2-platforms/devel-IntelAtomProcessorE3900] Dynamic debug UART
>From f91d7f365c00f2c16c82431d407f6b63e23e3a5b Mon Sep 17 00:00:00 2001
From: Kelly Steele <kelly.steele@intel.com>
Date: Fri, 21 Sep 2018 11:09:13 -0700
Subject: [PATCH] [edk2-platforms/devel-IntelAtomProcessorE3900] Dynamic debug
UART
Went from a static build time PCD to using the UART scrathpad registers
to determine the current debug UART. This allows the specific board
files to update the debug UART assignment during runtime. The default
debug UART is still determined through a static PCD.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Kelly Steele <kelly.steele@intel.com>
---
.../AuroraGlacier/BoardInitPreMem/BoardInit.c | 8 +-
.../AuroraGlacier/BoardInitPreMem/BoardInit.h | 1 +
.../BoardInitPreMem/BoardInitPreMem.inf | 1 +
.../BensonGlacier/BoardInitPreMem/BoardInit.c | 6 +-
.../BensonGlacier/BoardInitPreMem/BoardInit.h | 1 +
.../BoardInitPreMem/BoardInitPreMem.inf | 3 +-
.../Board/LeafHill/BoardInitPreMem/BoardInit.c | 5 +-
.../LeafHill/BoardInitPreMem/BoardInitPreMem.inf | 3 +-
.../Board/MinnowBoard3/BoardInitPreMem/BoardInit.c | 5 +-
.../BoardInitPreMem/BoardInitPreMem.inf | 3 +-
.../MinnowBoard3Module/BoardInitPreMem/BoardInit.c | 14 +-
.../BoardInitPreMem/BoardInitPreMem.inf | 2 +-
.../Board/UP2/BoardInitPreMem/BoardInit.c | 3 +
.../Board/UP2/BoardInitPreMem/BoardInitPreMem.inf | 1 +
.../Common/Console/LpssUartSerialDxe/Serial.c | 6 +-
.../Library/BaseSerialPortLib/BaseSerialPortLib.c | 340 ++-------------------
.../BaseSerialPortLib/BaseSerialPortLibNoInit.c | 226 +-------------
.../BroxtonPlatformPkg/PlatformDsc/Components.dsc | 1 +
.../PlatformDsc/PcdsFixedAtBuild.dsc | 10 +-
Platform/BroxtonPlatformPkg/PlatformPkg.dec | 16 +-
.../Include/Library/ScSerialIoUartLib.h | 23 +-
.../PeiDxeSmmPchSerialIoUartLib.c | 80 ++++-
22 files changed, 189 insertions(+), 569 deletions(-)
diff --git a/Platform/BroxtonPlatformPkg/Board/AuroraGlacier/BoardInitPreMem/BoardInit.c b/Platform/BroxtonPlatformPkg/Board/AuroraGlacier/BoardInitPreMem/BoardInit.c
index 3304f54131..08975f204e 100644
--- a/Platform/BroxtonPlatformPkg/Board/AuroraGlacier/BoardInitPreMem/BoardInit.c
+++ b/Platform/BroxtonPlatformPkg/Board/AuroraGlacier/BoardInitPreMem/BoardInit.c
@@ -71,16 +71,18 @@ AuroraGlacierPreMemInit (
return EFI_SUCCESS;
}
+ PchSetDebugPort (2);
+
DEBUG ((EFI_D_INFO, "This is Aurora Glacier board.\n"));
-
-
+
+
Status = AuroraGetFabId (PeiServices, &FabId);
if (FabId == FAB_ID_B) {
DEBUG ((EFI_D_INFO, "This is Aurora Glacier FAB B.\n"));
} else if (FabId == FAB_ID_A) {
DEBUG ((EFI_D_INFO, "This is Aurora Glacier FAB A.\n"));
}
-
+
PcdSet8 (PcdBoardId, BoardId);
PcdSet8 (PcdFabId, FabId);
diff --git a/Platform/BroxtonPlatformPkg/Board/AuroraGlacier/BoardInitPreMem/BoardInit.h b/Platform/BroxtonPlatformPkg/Board/AuroraGlacier/BoardInitPreMem/BoardInit.h
index 472a7f97a6..2313e5e6f6 100644
--- a/Platform/BroxtonPlatformPkg/Board/AuroraGlacier/BoardInitPreMem/BoardInit.h
+++ b/Platform/BroxtonPlatformPkg/Board/AuroraGlacier/BoardInitPreMem/BoardInit.h
@@ -29,6 +29,7 @@
#include <Library/PcdLib.h>
#include <Library/PeiServicesLib.h>
#include <Library/TimerLib.h>
+#include <Library/ScSerialIoUartLib.h>
#include <Ppi/BoardInitSignalling.h>
diff --git a/Platform/BroxtonPlatformPkg/Board/AuroraGlacier/BoardInitPreMem/BoardInitPreMem.inf b/Platform/BroxtonPlatformPkg/Board/AuroraGlacier/BoardInitPreMem/BoardInitPreMem.inf
index 53312b7f01..a22d570f4c 100644
--- a/Platform/BroxtonPlatformPkg/Board/AuroraGlacier/BoardInitPreMem/BoardInitPreMem.inf
+++ b/Platform/BroxtonPlatformPkg/Board/AuroraGlacier/BoardInitPreMem/BoardInitPreMem.inf
@@ -30,6 +30,7 @@
[LibraryClasses]
PeiServicesLib
PcdLib
+ PchSerialIoUartLib
[Packages]
MdePkg/MdePkg.dec
diff --git a/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPreMem/BoardInit.c b/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPreMem/BoardInit.c
index d44e824728..ef8c0894e7 100644
--- a/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPreMem/BoardInit.c
+++ b/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPreMem/BoardInit.c
@@ -71,15 +71,17 @@ BensonGlacierPreMemInit (
return EFI_SUCCESS;
}
+ PchSetDebugPort (2);
+
DEBUG ((EFI_D_INFO, "This is Benson Glacier board.\n"));
-
+
Status = BensonGetFabId (PeiServices, &FabId);
if (FabId == FAB_ID_B) {
DEBUG ((EFI_D_INFO, "This is Benson Glacier FAB B.\n"));
} else if (FabId == FAB_ID_A) {
DEBUG ((EFI_D_INFO, "This is Benson Glacier FAB A.\n"));
}
-
+
PcdSet8 (PcdBoardId, BoardId);
PcdSet8 (PcdFabId, FabId);
diff --git a/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPreMem/BoardInit.h b/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPreMem/BoardInit.h
index 833bf558bf..63221148f9 100644
--- a/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPreMem/BoardInit.h
+++ b/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPreMem/BoardInit.h
@@ -29,6 +29,7 @@
#include <Library/PcdLib.h>
#include <Library/PeiServicesLib.h>
#include <Library/TimerLib.h>
+#include <Library/ScSerialIoUartLib.h>
#include <Ppi/BoardInitSignalling.h>
diff --git a/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPreMem/BoardInitPreMem.inf b/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPreMem/BoardInitPreMem.inf
index a00a112773..445b63e10c 100644
--- a/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPreMem/BoardInitPreMem.inf
+++ b/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPreMem/BoardInitPreMem.inf
@@ -2,7 +2,7 @@
# Board detected module for Intel(R) Atom(TM) x5 Processor Series.
# It will detect the board ID.
#
-# Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -30,6 +30,7 @@
[LibraryClasses]
PeiServicesLib
PcdLib
+ PchSerialIoUartLib
[Packages]
MdePkg/MdePkg.dec
diff --git a/Platform/BroxtonPlatformPkg/Board/LeafHill/BoardInitPreMem/BoardInit.c b/Platform/BroxtonPlatformPkg/Board/LeafHill/BoardInitPreMem/BoardInit.c
index b0be91dd2b..c730a3c588 100644
--- a/Platform/BroxtonPlatformPkg/Board/LeafHill/BoardInitPreMem/BoardInit.c
+++ b/Platform/BroxtonPlatformPkg/Board/LeafHill/BoardInitPreMem/BoardInit.c
@@ -1,7 +1,7 @@
/** @file
Board Init driver.
- Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -18,6 +18,7 @@
#include <Library/PcdLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
+#include <Library/ScSerialIoUartLib.h>
#include <Guid/PlatformInfo_Aplk.h>
#include <Ppi/BoardInitSignalling.h>
#include "BoardInit.h"
@@ -79,6 +80,8 @@ LeafHillPreMemInit (
return EFI_SUCCESS;
}
+ PchSetDebugPort (2);
+
DEBUG ((EFI_D_INFO, "This is LeafHill CRB.\n"));
PcdSet8 (PcdBoardId, BoardId);
diff --git a/Platform/BroxtonPlatformPkg/Board/LeafHill/BoardInitPreMem/BoardInitPreMem.inf b/Platform/BroxtonPlatformPkg/Board/LeafHill/BoardInitPreMem/BoardInitPreMem.inf
index 12a3441d41..4cb4aeccc9 100644
--- a/Platform/BroxtonPlatformPkg/Board/LeafHill/BoardInitPreMem/BoardInitPreMem.inf
+++ b/Platform/BroxtonPlatformPkg/Board/LeafHill/BoardInitPreMem/BoardInitPreMem.inf
@@ -2,7 +2,7 @@
# Board detected module for Intel(R) Atom(TM) x5 Processor Series.
# It will detect the board ID.
#
-# Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -30,6 +30,7 @@
[LibraryClasses]
PeiServicesLib
PcdLib
+ PchSerialIoUartLib
[Packages]
MdePkg/MdePkg.dec
diff --git a/Platform/BroxtonPlatformPkg/Board/MinnowBoard3/BoardInitPreMem/BoardInit.c b/Platform/BroxtonPlatformPkg/Board/MinnowBoard3/BoardInitPreMem/BoardInit.c
index c07d4c0445..3330f91d82 100644
--- a/Platform/BroxtonPlatformPkg/Board/MinnowBoard3/BoardInitPreMem/BoardInit.c
+++ b/Platform/BroxtonPlatformPkg/Board/MinnowBoard3/BoardInitPreMem/BoardInit.c
@@ -1,7 +1,7 @@
/** @file
Board Init driver.
- Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -18,6 +18,7 @@
#include <Library/PcdLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
+#include <Library/ScSerialIoUartLib.h>
#include <Guid/PlatformInfo_Aplk.h>
#include <Ppi/BoardInitSignalling.h>
#include "BoardInit.h"
@@ -80,6 +81,8 @@ MinnowBoard3PreMemInit (
return EFI_SUCCESS;
}
+ PchSetDebugPort (2);
+
DEBUG ((EFI_D_INFO, "This is MinnowBoard 3.\n"));
PcdSet8 (PcdBoardId, BoardId);
diff --git a/Platform/BroxtonPlatformPkg/Board/MinnowBoard3/BoardInitPreMem/BoardInitPreMem.inf b/Platform/BroxtonPlatformPkg/Board/MinnowBoard3/BoardInitPreMem/BoardInitPreMem.inf
index 9b71a571ce..c8c549c153 100644
--- a/Platform/BroxtonPlatformPkg/Board/MinnowBoard3/BoardInitPreMem/BoardInitPreMem.inf
+++ b/Platform/BroxtonPlatformPkg/Board/MinnowBoard3/BoardInitPreMem/BoardInitPreMem.inf
@@ -2,7 +2,7 @@
# Board detected module for Intel(R) Atom(TM) x5 Processor Series.
# It will detect the board ID.
#
-# Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -30,6 +30,7 @@
[LibraryClasses]
PeiServicesLib
PcdLib
+ PchSerialIoUartLib
[Packages]
MdePkg/MdePkg.dec
diff --git a/Platform/BroxtonPlatformPkg/Board/MinnowBoard3Module/BoardInitPreMem/BoardInit.c b/Platform/BroxtonPlatformPkg/Board/MinnowBoard3Module/BoardInitPreMem/BoardInit.c
index 649e69df24..f103365a85 100644
--- a/Platform/BroxtonPlatformPkg/Board/MinnowBoard3Module/BoardInitPreMem/BoardInit.c
+++ b/Platform/BroxtonPlatformPkg/Board/MinnowBoard3Module/BoardInitPreMem/BoardInit.c
@@ -18,6 +18,7 @@
#include <Library/PcdLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
+#include <Library/ScSerialIoUartLib.h>
#include <Guid/PlatformInfo.h>
#include <Ppi/BoardInitSignalling.h>
#include "BoardInit.h"
@@ -77,21 +78,22 @@ MinnowBoard3ModulePreMemInit (
// Pre Mem Board Init
//
Status = Minnow3ModuleGetEmbeddedBoardIdFabId (PeiServices, &BoardId, &FabId);
-
if (BoardId != (UINT8) BOARD_ID_MINNOW_MODULE) {
-
return EFI_SUCCESS;
}
+
+ if (FabId == FAB_ID_A) {
+ PchSetDebugPort (0);
+ } else {
+ PchSetDebugPort (2);
+ }
+
DEBUG ((EFI_D_INFO, "This is MinnowBoard3 Next\n"));
PcdSet8 (PcdBoardId, BoardId);
PcdSet8 (PcdFabId, FabId);
//
- //PcdSet8 (PcdSerialIoUartNumber, 0);
- //
-
- //
// Set board specific function as dynamic PCD to be called by common platform code
//
PcdSet64 (PcdUpdateFspmUpdFunc, (UINT64) (UINTN) mMb3MUpdateFspmUpdPtr);
diff --git a/Platform/BroxtonPlatformPkg/Board/MinnowBoard3Module/BoardInitPreMem/BoardInitPreMem.inf b/Platform/BroxtonPlatformPkg/Board/MinnowBoard3Module/BoardInitPreMem/BoardInitPreMem.inf
index 5c83c120c3..73eb7e0e9e 100644
--- a/Platform/BroxtonPlatformPkg/Board/MinnowBoard3Module/BoardInitPreMem/BoardInitPreMem.inf
+++ b/Platform/BroxtonPlatformPkg/Board/MinnowBoard3Module/BoardInitPreMem/BoardInitPreMem.inf
@@ -30,6 +30,7 @@
[LibraryClasses]
PeiServicesLib
PcdLib
+ PchSerialIoUartLib
MmPciLib
IoLib
@@ -52,7 +53,6 @@
gMinnowModuleTokenSpaceGuid.PcdDefaultFabId ## CONSUMES
gMinnowModuleTokenSpaceGuid.PcdMinnowBoardDetectionRun ## CONSUMES
gMinnowModuleTokenSpaceGuid.PcdMinnowBoardDetected ## CONSUMES
- gPlatformModuleTokenSpaceGuid.PcdSerialIoUartNumber
[Guids]
diff --git a/Platform/BroxtonPlatformPkg/Board/UP2/BoardInitPreMem/BoardInit.c b/Platform/BroxtonPlatformPkg/Board/UP2/BoardInitPreMem/BoardInit.c
index ef451894b2..14b132d090 100644
--- a/Platform/BroxtonPlatformPkg/Board/UP2/BoardInitPreMem/BoardInit.c
+++ b/Platform/BroxtonPlatformPkg/Board/UP2/BoardInitPreMem/BoardInit.c
@@ -18,6 +18,7 @@
#include <Library/PcdLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
+#include <Library/ScSerialIoUartLib.h>
#include <Guid/PlatformInfo_Aplk.h>
#include <Ppi/BoardInitSignalling.h>
#include "BoardInit.h"
@@ -79,6 +80,8 @@ Up2PreMemInit (
return EFI_SUCCESS;
}
+ PchSetDebugPort (0);
+
DEBUG ((EFI_D_INFO, "This is Up2.\n"));
PcdSet8 (PcdBoardId, BoardId);
diff --git a/Platform/BroxtonPlatformPkg/Board/UP2/BoardInitPreMem/BoardInitPreMem.inf b/Platform/BroxtonPlatformPkg/Board/UP2/BoardInitPreMem/BoardInitPreMem.inf
index 7a43a20860..fe713fc63d 100644
--- a/Platform/BroxtonPlatformPkg/Board/UP2/BoardInitPreMem/BoardInitPreMem.inf
+++ b/Platform/BroxtonPlatformPkg/Board/UP2/BoardInitPreMem/BoardInitPreMem.inf
@@ -30,6 +30,7 @@
[LibraryClasses]
PeiServicesLib
PcdLib
+ PchSerialIoUartLib
[Packages]
MdePkg/MdePkg.dec
diff --git a/Platform/BroxtonPlatformPkg/Common/Console/LpssUartSerialDxe/Serial.c b/Platform/BroxtonPlatformPkg/Common/Console/LpssUartSerialDxe/Serial.c
index c273d78f8c..b26808629a 100644
--- a/Platform/BroxtonPlatformPkg/Common/Console/LpssUartSerialDxe/Serial.c
+++ b/Platform/BroxtonPlatformPkg/Common/Console/LpssUartSerialDxe/Serial.c
@@ -1,7 +1,7 @@
/** @file
Serial driver for standard UARTS on an ISA bus.
- Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -1652,7 +1652,7 @@ IsaSerialWrite (
CharBuffer = (UINT8 *) Buffer;
- PchSerialIoUartOut (PcdGet8 (PcdSerialIoUartNumber), CharBuffer, *BufferSize);
+ PchSerialIoUartOut (PchGetDebugPort (), CharBuffer, *BufferSize);
gBS->RestoreTPL (Tpl);
@@ -1696,7 +1696,7 @@ IsaSerialRead (
Tpl = gBS->RaiseTPL (TPL_NOTIFY);
- *BufferSize = PchSerialIoUartIn(PcdGet8 (PcdSerialIoUartNumber), Buffer, *BufferSize, FALSE);
+ *BufferSize = PchSerialIoUartIn (PchGetDebugPort (), Buffer, *BufferSize, FALSE);
gBS->RestoreTPL (Tpl);
diff --git a/Platform/BroxtonPlatformPkg/Common/Library/BaseSerialPortLib/BaseSerialPortLib.c b/Platform/BroxtonPlatformPkg/Common/Library/BaseSerialPortLib/BaseSerialPortLib.c
index 7770619f97..0364e38669 100644
--- a/Platform/BroxtonPlatformPkg/Common/Library/BaseSerialPortLib/BaseSerialPortLib.c
+++ b/Platform/BroxtonPlatformPkg/Common/Library/BaseSerialPortLib/BaseSerialPortLib.c
@@ -1,7 +1,7 @@
/** @file
Serial I/O Port library functions with no library constructor/destructor.
- Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -58,225 +58,48 @@
#define MAX_BAUD_RATE 115200
-UINT8
-SerialPortReadRegister (
- UINTN Offset
- )
-{
- return IoRead8 ((UINTN) PcdGet64 (PcdSerialRegisterBase) + Offset);
-}
-
-UINT8
-SerialPortWriteRegister (
- UINTN Offset,
- UINT8 Value
- )
-{
- return IoWrite8 ((UINTN) PcdGet64 (PcdSerialRegisterBase) + Offset, Value);
-}
-
RETURN_STATUS
EFIAPI
-UARTInitialize (
+SerialPortInitialize (
VOID
)
-
-/**
- Initialize Serial Port.
-
- The Baud Rate Divisor registers are programmed and the LCR
- is used to configure the communications format. Hard coded
- UART config comes from globals in DebugSerialPlatform lib.
-
- @param None
-
- @retval None
-
-**/
{
- UINTN Divisor;
- UINTN TempDivisor;
- UINT32 BaudRate;
- BOOLEAN Initialized;
-
//
- // Calculate divisor for baud generator
+ // Initialize all 4 UARTs for possible debug use. All 4 UART PADs are programmed appropriately at this point.
+ // We store the Debug Serial port in the scratchpad register of the UARTs.
//
- BaudRate = PcdGet32 (PcdSerialBaudRate);
- if ((BaudRate == 0) || ((BaudRate % 9600) != 0)) {
- //
- // If Serail Baud Rate is not valid, set it to the default value
- //
- BaudRate = PcdGet32 (PcdSerialBaudRate);
- }
- Divisor = MAX_BAUD_RATE / BaudRate;
+ PchSerialIoUartInit (0,
+ (PcdGet8 (PcdSerialFifoControl) & FCR_FIFOE) ? TRUE : FALSE,
+ PcdGet32 (PcdSerialBaudRate),
+ PcdGet8 (PcdSerialLineControl),
+ PcdGetBool (PcdSerialUseHardwareFlowControl));
- //
- // See if the serial port is already initialized
- //
- Initialized = TRUE;
- if ((SerialPortReadRegister (FCR_OFFSET) & (FCR_FIFOE | FCR_FIFO64)) !=
- (PcdGet8 (PcdSerialFifoControl) & (FCR_FIFOE | FCR_FIFO64))) {
- Initialized = FALSE;
- }
- if ((SerialPortReadRegister (LCR_OFFSET) & 0x3F) != (PcdGet8 (PcdSerialLineControl) & 0x3F)) {
- Initialized = FALSE;
- }
- SerialPortWriteRegister (LCR_OFFSET, (UINT8) (SerialPortReadRegister (LCR_OFFSET) | DLAB));
- TempDivisor = (UINTN) SerialPortReadRegister (BAUD_HIGH_OFFSET);
- TempDivisor = TempDivisor << 8;
- TempDivisor |= (UINTN) SerialPortReadRegister (BAUD_LOW_OFFSET);
- SerialPortWriteRegister (LCR_OFFSET, (UINT8) (SerialPortReadRegister (LCR_OFFSET) & ~DLAB));
- if (TempDivisor != Divisor) {
- Initialized = FALSE;
- }
- if (Initialized) {
- return RETURN_SUCCESS;
- }
+ PchSerialIoUartInit (1,
+ (PcdGet8 (PcdSerialFifoControl) & FCR_FIFOE) ? TRUE : FALSE,
+ PcdGet32 (PcdSerialBaudRate),
+ PcdGet8 (PcdSerialLineControl),
+ PcdGetBool (PcdSerialUseHardwareFlowControl));
- //
- // Set communications format
- //
- SerialPortWriteRegister (LCR_OFFSET, DLAB);
-
- //
- // Configure baud rate
- //
- SerialPortWriteRegister (BAUD_HIGH_OFFSET, (UINT8) (Divisor >> 8));
- SerialPortWriteRegister (BAUD_LOW_OFFSET, (UINT8) (Divisor & 0xff));
+ PchSerialIoUartInit (2,
+ (PcdGet8 (PcdSerialFifoControl) & FCR_FIFOE) ? TRUE : FALSE,
+ PcdGet32 (PcdSerialBaudRate),
+ PcdGet8 (PcdSerialLineControl),
+ PcdGetBool (PcdSerialUseHardwareFlowControl));
- //
- // Switch back to bank 0
- //
- SerialPortWriteRegister (LCR_OFFSET, (UINT8) (PcdGet8 (PcdSerialLineControl) & 0x3F));
+ PchSerialIoUartInit (3,
+ (PcdGet8 (PcdSerialFifoControl) & FCR_FIFOE) ? TRUE : FALSE,
+ PcdGet32 (PcdSerialBaudRate),
+ PcdGet8 (PcdSerialLineControl),
+ PcdGetBool (PcdSerialUseHardwareFlowControl));
//
- // Enable and reset FIFOs
- // Strip reserved bits from PcdSerialFifoControl
+ // Set default debug port now that we have initiazed the UARTs
//
- SerialPortWriteRegister (FCR_OFFSET, (UINT8) (PcdGet8 (PcdSerialFifoControl) & 0x27));
-
- //
- // Put Modem Control Register(MCR) into its reset state of 0x00.
- //
- SerialPortWriteRegister (MCR_OFFSET, 0x00);
+ PchSetDebugPort (PcdGet8 (PcdSerialIoUartNumber));
return RETURN_SUCCESS;
}
-
-RETURN_STATUS
-EFIAPI
-SerialPortInitialize (
- VOID
- )
-{
- //
- //PchSerialIoUartInit (PcdGet8 (PcdSerialIoUartNumber), TRUE, 115200, 3, FALSE);
- //
- PchSerialIoUartInit (0, TRUE, 115200, 3, FALSE);
- PchSerialIoUartInit (2, TRUE, 115200, 3, FALSE);
-
- return RETURN_SUCCESS;
-}
-
-
-/**
- Write data to serial device.
-
- If the buffer is NULL, then return 0;
- if NumberOfBytes is zero, then return 0.
-
- @param[in] Buffer Point of data buffer which need to be writed.
- @param[in] NumberOfBytes Number of output bytes which are cached in Buffer.
-
- @retval 0 Write data failed.
- @retval !0 Actual number of bytes writed to serial device.
-
-**/
-UINTN
-EFIAPI
-UARTDbgOut (
- IN UINT8 *Buffer,
- IN UINTN NumberOfBytes
- )
-{
- UINTN Result;
- UINTN FifoSize;
- UINTN Index;
-
- if (NULL == Buffer) {
- return 0;
- }
-
- //
- // Compute the maximum size of the Tx FIFO
- //
- FifoSize = 1;
- if ((PcdGet8 (PcdSerialFifoControl) & FCR_FIFOE) != 0) {
- if ((PcdGet8 (PcdSerialFifoControl) & FCR_FIFO64) == 0) {
- FifoSize = 16;
- } else {
- FifoSize = 64;
- }
- }
-
- Result = NumberOfBytes;
-
- while (NumberOfBytes != 0) {
- //
- // Wait for the serial port to be ready, to make sure both the transmit FIFO
- // and shift register empty.
- //
- while ((SerialPortReadRegister (LSR_OFFSET) & LSR_TXRDY) == 0);
-
- //
- // Fill then entire Tx FIFO
- //
- for (Index = 0; Index < FifoSize && NumberOfBytes != 0; Index++, NumberOfBytes--, Buffer++) {
- if (PcdGetBool (PcdSerialUseHardwareFlowControl)) {
- if (PcdGetBool (PcdSerialDetectCable)) {
- //
- // Wait for both DSR and CTS to be set
- // DSR is set if a cable is connected.
- // CTS is set if it is ok to transmit data
- //
- // DSR CTS Description Action
- // === === ======================================== ========
- // 0 0 No cable connected. Wait
- // 0 1 No cable connected. Wait
- // 1 0 Cable connected, but not clear to send. Wait
- // 1 1 Cable connected, and clear to send. Transmit
- //
- while ((SerialPortReadRegister (MSR_OFFSET) & (MSR_DSR | MSR_CTS)) != (MSR_DSR | MSR_CTS));
- } else {
- //
- // Wait for both DSR and CTS to be set OR for DSR to be clear.
- // DSR is set if a cable is connected.
- // CTS is set if it is ok to transmit data
- //
- // DSR CTS Description Action
- // === === ======================================== ========
- // 0 0 No cable connected. Transmit
- // 0 1 No cable connected. Transmit
- // 1 0 Cable connected, but not clear to send. Wait
- // 1 1 Cable connected, and clar to send. Transmit
- //
- while ((SerialPortReadRegister (MSR_OFFSET) & (MSR_DSR | MSR_CTS)) == (MSR_DSR));
- }
- }
-
- //
- // Write byte to the transmit buffer.
- //
- SerialPortWriteRegister (TXBUF_OFFSET, *Buffer);
- }
- }
-
- return Result;
-}
-
-
/**
Common function to write trace data to a chosen debug interface like
UART Serial device, USB Serial device or Trace Hub device
@@ -292,74 +115,12 @@ SerialPortWrite (
IN UINTN NumberOfBytes
)
{
-
- PchSerialIoUartOut (PcdGet8 (PcdSerialIoUartNumber), Buffer, NumberOfBytes);
+ PchSerialIoUartOut (PchGetDebugPort (), Buffer, NumberOfBytes);
return RETURN_SUCCESS;
}
/**
- Read data from serial device and save the datas in buffer.
-
- If the buffer is NULL, then return 0;
- if NumberOfBytes is zero, then return 0.
-
- @param[out] Buffer Point of data buffer which need to be writed.
- @param[in] NumberOfBytes Number of output bytes which are cached in Buffer.
-
- @retval 0 Read data failed.
- @retval !0 Actual number of bytes raed to serial device.
-
-**/
-UINTN
-EFIAPI
-UARTDbgIn (
- OUT UINT8 *Buffer,
- IN UINTN NumberOfBytes
- )
-{
- UINTN Result;
- UINT8 Mcr;
-
- if (NULL == Buffer) {
- return 0;
- }
-
- Result = NumberOfBytes;
-
- Mcr = (UINT8) (SerialPortReadRegister (MCR_OFFSET) & ~MCR_RTS);
-
- for (Result = 0; NumberOfBytes-- != 0; Result ++, Buffer ++) {
- //
- // Wait for the serial port to have some data.
- //
- while ((SerialPortReadRegister (LSR_OFFSET) & LSR_RXDA) == 0) {
- if (PcdGetBool (PcdSerialUseHardwareFlowControl)) {
- //
- // Set RTS to let the peer send some data
- //
- SerialPortWriteRegister (MCR_OFFSET, (UINT8) (Mcr | MCR_RTS));
- }
- }
-
- if (PcdGetBool (PcdSerialUseHardwareFlowControl)) {
- //
- // Clear RTS to prevent peer from sending data
- //
- SerialPortWriteRegister (MCR_OFFSET, Mcr);
- }
-
- //
- // Read byte from the receive buffer.
- //
- *Buffer = SerialPortReadRegister (RXBUF_OFFSET);
- }
-
- return Result;
-}
-
-
-/**
Common function to Read data from UART serial device, USB serial device and save the datas in buffer.
@param[in] Buffer Point of data buffer which need to be writed.
@@ -374,52 +135,11 @@ SerialPortRead (
)
{
- PchSerialIoUartIn (PcdGet8 (PcdSerialIoUartNumber), Buffer, NumberOfBytes, FALSE);
-
- return RETURN_SUCCESS;
-}
-
+ PchSerialIoUartIn (PchGetDebugPort (), Buffer, NumberOfBytes, FALSE);
-/**
- Polls a serial device to see if there is any data waiting to be read.
-
- Polls a serial device to see if there is any data waiting to be read.
- If there is data waiting to be read from the serial device, then TRUE is returned.
- If there is no data waiting to be read from the serial device, then FALSE is returned.
-
- @retval TRUE Data is waiting to be read from the serial device.
- @retval FALSE There is no data waiting to be read from the serial device.
-
-**/
-BOOLEAN
-EFIAPI
-UARTDbgPoll (
- VOID
- )
-{
- //
- // Read the serial port status
- //
- if ((SerialPortReadRegister (LSR_OFFSET) & LSR_RXDA) != 0) {
- if (PcdGetBool (PcdSerialUseHardwareFlowControl)) {
- //
- // Clear RTS to prevent peer from sending data
- //
- SerialPortWriteRegister (MCR_OFFSET, (UINT8) (SerialPortReadRegister (MCR_OFFSET) & ~ MCR_RTS));
- }
- return TRUE;
- }
-
- if (PcdGetBool (PcdSerialUseHardwareFlowControl)) {
- //
- // Set RTS to let the peer send some data
- //
- SerialPortWriteRegister (MCR_OFFSET, (UINT8) (SerialPortReadRegister (MCR_OFFSET) | MCR_RTS));
- }
- return FALSE;
+ return RETURN_SUCCESS;
}
-
/**
Polls a serial device to see if there is any data waiting to be read.
@@ -441,7 +161,7 @@ SerialPortPoll (
BOOLEAN Status;
Status = FALSE;
- Status |= PchSerialIoUartPoll (PcdGet8 (PcdSerialIoUartNumber));
+ Status |= PchSerialIoUartPoll (PchGetDebugPort ());
return Status;
}
diff --git a/Platform/BroxtonPlatformPkg/Common/Library/BaseSerialPortLib/BaseSerialPortLibNoInit.c b/Platform/BroxtonPlatformPkg/Common/Library/BaseSerialPortLib/BaseSerialPortLibNoInit.c
index f9e96338b0..199f004aaf 100644
--- a/Platform/BroxtonPlatformPkg/Common/Library/BaseSerialPortLib/BaseSerialPortLibNoInit.c
+++ b/Platform/BroxtonPlatformPkg/Common/Library/BaseSerialPortLib/BaseSerialPortLibNoInit.c
@@ -1,7 +1,7 @@
/** @file
Serial I/O Port library functions with no library constructor/destructor.
- Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -60,23 +60,6 @@
#define MAX_BAUD_RATE 115200
-UINT8
-SerialPortReadRegister (
- UINTN Offset
- )
-{
- return IoRead8 ((UINTN) PcdGet64 (PcdSerialRegisterBase) + Offset);
-}
-
-UINT8
-SerialPortWriteRegister (
- UINTN Offset,
- UINT8 Value
- )
-{
- return IoWrite8 ((UINTN) PcdGet64 (PcdSerialRegisterBase) + Offset, Value);
-}
-
RETURN_STATUS
EFIAPI
SerialPortInitialize (
@@ -86,103 +69,6 @@ SerialPortInitialize (
return RETURN_SUCCESS;
}
-
-/**
- Write data to serial device.
-
- If the buffer is NULL, then return 0;
- if NumberOfBytes is zero, then return 0.
-
- @param[in] Buffer Point of data buffer which need to be writed.
- @param[in] NumberOfBytes Number of output bytes which are cached in Buffer.
-
- @retval 0 Write data failed.
- @retval !0 Actual number of bytes writed to serial device.
-
-**/
-UINTN
-EFIAPI
-UARTDbgOut (
- IN UINT8 *Buffer,
- IN UINTN NumberOfBytes
-)
-{
- UINTN Result;
- UINTN FifoSize;
- UINTN Index;
-
- if (NULL == Buffer) {
- return 0;
- }
-
- //
- // Compute the maximum size of the Tx FIFO
- //
- FifoSize = 1;
- if ((PcdGet8 (PcdSerialFifoControl) & FCR_FIFOE) != 0) {
- if ((PcdGet8 (PcdSerialFifoControl) & FCR_FIFO64) == 0) {
- FifoSize = 16;
- } else {
- FifoSize = 64;
- }
- }
-
- Result = NumberOfBytes;
-
- while (NumberOfBytes != 0) {
- //
- // Wait for the serial port to be ready, to make sure both the transmit FIFO
- // and shift register empty.
- //
- while ((SerialPortReadRegister (LSR_OFFSET) & LSR_TXRDY) == 0);
-
- //
- // Fill then entire Tx FIFO
- //
- for (Index = 0; Index < FifoSize && NumberOfBytes != 0; Index++, NumberOfBytes--, Buffer++) {
- if (PcdGetBool (PcdSerialUseHardwareFlowControl)) {
- if (PcdGetBool (PcdSerialDetectCable)) {
- //
- // Wait for both DSR and CTS to be set
- // DSR is set if a cable is connected.
- // CTS is set if it is ok to transmit data
- //
- // DSR CTS Description Action
- // === === ======================================== ========
- // 0 0 No cable connected. Wait
- // 0 1 No cable connected. Wait
- // 1 0 Cable connected, but not clear to send. Wait
- // 1 1 Cable connected, and clear to send. Transmit
- //
- while ((SerialPortReadRegister (MSR_OFFSET) & (MSR_DSR | MSR_CTS)) != (MSR_DSR | MSR_CTS));
- } else {
- //
- // Wait for both DSR and CTS to be set OR for DSR to be clear.
- // DSR is set if a cable is connected.
- // CTS is set if it is ok to transmit data
- //
- // DSR CTS Description Action
- // === === ======================================== ========
- // 0 0 No cable connected. Transmit
- // 0 1 No cable connected. Transmit
- // 1 0 Cable connected, but not clear to send. Wait
- // 1 1 Cable connected, and clar to send. Transmit
- //
- while ((SerialPortReadRegister (MSR_OFFSET) & (MSR_DSR | MSR_CTS)) == (MSR_DSR));
- }
- }
-
- //
- // Write byte to the transmit buffer.
- //
- SerialPortWriteRegister (TXBUF_OFFSET, *Buffer);
- }
- }
-
- return Result;
-}
-
-
/**
Common function to write trace data to a chosen debug interface like
UART Serial device, USB Serial device or Trace Hub device
@@ -198,74 +84,11 @@ SerialPortWrite (
IN UINTN NumberOfBytes
)
{
-
- PchSerialIoUartOut (PcdGet8 (PcdSerialIoUartNumber), Buffer, NumberOfBytes);
+ PchSerialIoUartOut (PchGetDebugPort (), Buffer, NumberOfBytes);
return RETURN_SUCCESS;
}
-
-/**
- Read data from serial device and save the datas in buffer.
-
- If the buffer is NULL, then return 0;
- if NumberOfBytes is zero, then return 0.
-
- @param[out] Buffer Point of data buffer which need to be writed.
- @param[in] NumberOfBytes Number of output bytes which are cached in Buffer.
-
- @retval 0 Read data failed.
- @retval !0 Actual number of bytes raed to serial device.
-
-**/
-UINTN
-EFIAPI
-UARTDbgIn (
- OUT UINT8 *Buffer,
- IN UINTN NumberOfBytes
- )
-{
- UINTN Result;
- UINT8 Mcr;
-
- if (NULL == Buffer) {
- return 0;
- }
-
- Result = NumberOfBytes;
-
- Mcr = (UINT8) (SerialPortReadRegister (MCR_OFFSET) & ~ MCR_RTS);
-
- for (Result = 0; NumberOfBytes-- != 0; Result++, Buffer++) {
- //
- // Wait for the serial port to have some data.
- //
- while ((SerialPortReadRegister (LSR_OFFSET) & LSR_RXDA) == 0) {
- if (PcdGetBool (PcdSerialUseHardwareFlowControl)) {
- //
- // Set RTS to let the peer send some data
- //
- SerialPortWriteRegister (MCR_OFFSET, (UINT8) (Mcr | MCR_RTS));
- }
- }
-
- if (PcdGetBool (PcdSerialUseHardwareFlowControl)) {
- //
- // Clear RTS to prevent peer from sending data
- //
- SerialPortWriteRegister (MCR_OFFSET, Mcr);
- }
-
- //
- // Read byte from the receive buffer.
- //
- *Buffer = SerialPortReadRegister (RXBUF_OFFSET);
- }
-
- return Result;
-}
-
-
/**
Common function to Read data from UART serial device, USB serial device and save the datas in buffer.
@@ -281,52 +104,11 @@ SerialPortRead (
)
{
- PchSerialIoUartIn (PcdGet8 (PcdSerialIoUartNumber), Buffer, NumberOfBytes, FALSE);
+ PchSerialIoUartIn (PchGetDebugPort (), Buffer, NumberOfBytes, FALSE);
return RETURN_SUCCESS;
}
-
-/**
- Polls a serial device to see if there is any data waiting to be read.
-
- Polls a serial device to see if there is any data waiting to be read.
- If there is data waiting to be read from the serial device, then TRUE is returned.
- If there is no data waiting to be read from the serial device, then FALSE is returned.
-
- @retval TRUE Data is waiting to be read from the serial device.
- @retval FALSE There is no data waiting to be read from the serial device.
-
-**/
-BOOLEAN
-EFIAPI
-UARTDbgPoll (
- VOID
- )
-{
- //
- // Read the serial port status
- //
- if ((SerialPortReadRegister (LSR_OFFSET) & LSR_RXDA) != 0) {
- if (PcdGetBool (PcdSerialUseHardwareFlowControl)) {
- //
- // Clear RTS to prevent peer from sending data
- //
- SerialPortWriteRegister (MCR_OFFSET, (UINT8) (SerialPortReadRegister (MCR_OFFSET) & ~MCR_RTS));
- }
- return TRUE;
- }
-
- if (PcdGetBool (PcdSerialUseHardwareFlowControl)) {
- //
- // Set RTS to let the peer send some data
- //
- SerialPortWriteRegister (MCR_OFFSET, (UINT8) (SerialPortReadRegister (MCR_OFFSET) | MCR_RTS));
- }
- return FALSE;
-}
-
-
/**
Polls a serial device to see if there is any data waiting to be read.
@@ -349,7 +131,7 @@ SerialPortPoll (
Status = FALSE;
- Status |= PchSerialIoUartPoll (PcdGet8 (PcdSerialIoUartNumber));
+ Status |= PchSerialIoUartPoll (PchGetDebugPort ());
return Status;
}
diff --git a/Platform/BroxtonPlatformPkg/PlatformDsc/Components.dsc b/Platform/BroxtonPlatformPkg/PlatformDsc/Components.dsc
index f0106bc850..e6486fbca0 100644
--- a/Platform/BroxtonPlatformPkg/PlatformDsc/Components.dsc
+++ b/Platform/BroxtonPlatformPkg/PlatformDsc/Components.dsc
@@ -31,6 +31,7 @@
<LibraryClasses>
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
+ SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf
}
!if $(SOURCE_DEBUG_ENABLE) == TRUE
diff --git a/Platform/BroxtonPlatformPkg/PlatformDsc/PcdsFixedAtBuild.dsc b/Platform/BroxtonPlatformPkg/PlatformDsc/PcdsFixedAtBuild.dsc
index db7cba5f46..207d7243c6 100644
--- a/Platform/BroxtonPlatformPkg/PlatformDsc/PcdsFixedAtBuild.dsc
+++ b/Platform/BroxtonPlatformPkg/PlatformDsc/PcdsFixedAtBuild.dsc
@@ -83,14 +83,10 @@
gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x07
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseHardwareFlowControl|FALSE
!endif
-
+
gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStackSize|0x3000
-
- !if $(UP2_BOARD) == TRUE
- gPlatformModuleTokenSpaceGuid.PcdSerialIoUartNumber|0
- !else
- gPlatformModuleTokenSpaceGuid.PcdSerialIoUartNumber|2
- !endif
+
+ gEfiMdeModulePkgTokenSpaceGuid.PcdSerialBaudRate|115200
#
# EEPROM GPIO Whitelist
gPlatformModuleTokenSpaceGuid.PcdGpioWhiteList | {0x08, 0x05, 0xC0, 0x00, 0x78, 0x05, 0xC0, 0x00, 0x80, 0x05, 0xC0, 0x00, 0x88, 0x05, 0xC0, 0x00, 0x90, 0x05, 0xC0, 0x00, 0xA0, 0x05, 0xC0, 0x00, 0xC8, 0x05, 0xC0, 0x00, 0xD0, 0x05, 0xC0, 0x00, 0xE0, 0x05, 0xC0, 0x00, 0xF0, 0x05, 0xC0, 0x00, 0xF8, 0x05, 0xC0, 0x00, 0x30, 0x05, 0xC4, 0x00, 0x48, 0x05, 0xC4, 0x00, 0x50, 0x05, 0xC4, 0x00, 0x58, 0x05, 0xC4, 0x00, 0x60, 0x05, 0xC4, 0x00, 0x68, 0x05, 0xC4, 0x00, 0x80, 0x05, 0xC4, 0x00, 0x88, 0x05, 0xC4, 0x00, 0x98, 0x05, 0xC4, 0x00, 0x60, 0x06, 0xC4, 0x00, 0x60, 0x06, 0xC4, 0x00, 0x68, 0x06, 0xC4, 0x00, 0x70, 0x06, 0xC4, 0x00, 0x78, 0x06, 0xC4, 0x00, 0x80, 0x06, 0xC4, 0x00, 0xA8, 0x06, 0xC4, 0x00, 0xB0, 0x06, 0xC4, 0x00, 0xB8, 0x06, 0xC4, 0x00, 0xC0, 0x06, 0xC4, 0x00, 0xD8, 0x06, 0xC4, 0x00, 0xE8, 0x06, 0xC4, 0x00, 0xF0, 0x06, 0xC4, 0x00, 0xF8, 0x06, 0xC4, 0x00, 0x00, 0x07, 0xC4, 0x00, 0x08, 0x07, 0xC4, 0x00, 0x18, 0x07, 0xC4, 0x00, 0x20, 0x07, 0xC4, 0x00, 0x10, 0x05, 0xC5, 0x00, 0x18, 0x05, 0xC5, 0x00, 0x20, 0x05, 0xC5, 0x00, 0x30, 0x05, 0xC5, 0x00, 0x38, 0x05, 0xC5, 0x00, 0x68, 0x05, 0xC5, 0x00, 0x70, 0x05, 0xC5, 0x00, 0xA8, 0x05, 0xC5, 0x00, 0xB0, 0x05, 0xC5, 0x00, 0xB8, 0x05, 0xC5, 0x00, 0xC0, 0x05, 0xC5, 0x00, 0xC8, 0x05, 0xC5, 0x00, 0xD0, 0x05, 0xC5, 0x00, 0x30, 0x06, 0xC5, 0x00, 0x38, 0x06, 0xC5, 0x00, 0x40, 0x06, 0xC5, 0x00, 0x48, 0x06, 0xC5, 0x00, 0x50, 0x06, 0xC5, 0x00, 0x58, 0x06, 0xC5, 0x00, 0x70, 0x06, 0xC5, 0x00, 0x78, 0x06, 0xC5, 0x00, 0x80, 0x06, 0xC5, 0x00, 0x88, 0x06, 0xC5, 0x00, 0xA0, 0x06, 0xC5, 0x00, 0xA8, 0x06, 0xC5, 0x00, 0xB0, 0x06, 0xC5, 0x00, 0xB8, 0x06, 0xC5, 0x00, 0x10, 0x05, 0xC7, 0x00, 0x18, 0x05, 0xC7, 0x00, 0x40, 0x05, 0xC7, 0x00, 0x48, 0x05, 0xC7, 0x00, 0x50, 0x05, 0xC7, 0x00, 0x58, 0x05, 0xC7, 0x00, 0x60, 0x05, 0xC7, 0x00, 0x68, 0x05, 0xC7, 0x00, 0x70, 0x05, 0xC7, 0x00, 0x78, 0x05, 0xC7, 0x00, 0x80, 0x05, 0xC7, 0x00, 0x88, 0x05, 0xC7, 0x00, 0x90, 0x05, 0xC7, 0x00, 0x98, 0x05, 0xC7, 0x00, 0xF0, 0x05, 0xC7, 0x00, 0x18, 0x06, 0xC7, 0x00, 0x20, 0x06, 0xC7, 0x00, 0x28, 0x06, 0xC7, 0x00, 0x48, 0x06, 0xC7, 0x00, 0xFF, 0xFF, 0xFF, 0xFF}
diff --git a/Platform/BroxtonPlatformPkg/PlatformPkg.dec b/Platform/BroxtonPlatformPkg/PlatformPkg.dec
index c27ac042ab..3d14109e39 100644
--- a/Platform/BroxtonPlatformPkg/PlatformPkg.dec
+++ b/Platform/BroxtonPlatformPkg/PlatformPkg.dec
@@ -202,8 +202,6 @@
gPlatformModuleTokenSpaceGuid.PcdTi3100AudioCodecEnable|FALSE|BOOLEAN|0x80000019
##
gPlatformModuleTokenSpaceGuid.PcdUpdatePcieConfigFunc|2|UINT64|0x8000001A
- ## SerialIo Uart Configuration
- #gPlatformModuleTokenSpaceGuid.PcdSerialIoUartNumber|2|UINT8|0x8000001B
## This PCD used to select eMMCHostMaxSpeed
gPlatformModuleTokenSpaceGuid.PcdeMMCHostMaxSpeed|0x00|UINT8|0x8000001C
## This PCD points to verb table of HD audio.
@@ -336,6 +334,14 @@
## The PCD is used to specify if TrEEPlatform module support TXT provision.
gClientCommonModuleTokenSpaceGuid.PcdTpm2TxtProvisionSupport|FALSE|BOOLEAN|0x00010027
+ ## Specifies maximum number of PPIs provided by SecCore.
+ # @Prompt Maximum number of PPIs provided by SecCore.
+ gPlatformModuleTokenSpaceGuid.PcdSecCoreMaxPpiSupported|0x6|UINT32|0x10001010
+
+ ## SerialIo Uart Configuration, used for debug output and ConSplitter
+ ## NOTE: See BoardInitPreMem\BoardInit.c for individual board use.
+ gPlatformModuleTokenSpaceGuid.PcdSerialIoUartNumber|2|UINT8|0x8000001B
+
##
## SMBIOS defaults
##
@@ -391,9 +397,3 @@
gPlatformModuleTokenSpaceGuid.PcdLogoFileGuid|{0x1b, 0x9a, 0x3d, 0x71, 0x49, 0x88, 0x47, 0xc5, 0xb7, 0x2a, 0xb0, 0x7d, 0xc5, 0x10, 0x60, 0xc4 }|VOID*|0x10001004
gPlatformModuleTokenSpaceGuid.PcdTianoCoreLogoFileGuid|{ 0x99, 0x8b, 0xB2, 0x7B, 0xBB, 0x61, 0xD5, 0x11, 0x9A, 0x5D, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }|VOID*|0x10001005
-[PcdsFixedAtBuild]
- ## Specifies maximum number of PPIs provided by SecCore.
- # @Prompt Maximum number of PPIs provided by SecCore.
- gPlatformModuleTokenSpaceGuid.PcdSecCoreMaxPpiSupported|0x6|UINT32|0x10001010
- ## SerialIo Uart Configuration
- gPlatformModuleTokenSpaceGuid.PcdSerialIoUartNumber|2|UINT8|0x10001011
diff --git a/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/Include/Library/ScSerialIoUartLib.h b/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/Include/Library/ScSerialIoUartLib.h
index 68c04695ac..3dd2370fba 100644
--- a/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/Include/Library/ScSerialIoUartLib.h
+++ b/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/Include/Library/ScSerialIoUartLib.h
@@ -1,7 +1,7 @@
/** @file
Header file for PCH Serial IO UART Lib implementation.
- Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -102,5 +102,26 @@ PchSerialIoUartPoll (
IN UINT8 UartNumber
);
+UINT8
+EFIAPI
+PchGetScratchpadRegister (
+ IN UINT8 UartNumber
+ );
+
+VOID
+PchSetScratchpadRegister (
+ IN UINT8 UartNumber,
+ IN UINT8 Value
+ );
+
+UINT8
+EFIAPI
+PchGetDebugPort (VOID);
+
+VOID
+PchSetDebugPort (
+ IN UINT8 UartNumber
+ );
+
#endif // _PEI_DXE_SMM_PCH_SERIAL_IO_UART_LIB_H_
diff --git a/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/Library/PeiDxeSmmPchSerialIoUartLib/PeiDxeSmmPchSerialIoUartLib.c b/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/Library/PeiDxeSmmPchSerialIoUartLib/PeiDxeSmmPchSerialIoUartLib.c
index 4a3bdcc9d8..6071f077dc 100644
--- a/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/Library/PeiDxeSmmPchSerialIoUartLib/PeiDxeSmmPchSerialIoUartLib.c
+++ b/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/Library/PeiDxeSmmPchSerialIoUartLib/PeiDxeSmmPchSerialIoUartLib.c
@@ -3,7 +3,7 @@
All function in this library is available for PEI, DXE, and SMM,
But do not support UEFI RUNTIME environment call.
- Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -45,6 +45,7 @@
#define R_PCH_SERIAL_IO_NATIVE_UART_LCR 0x0C
#define R_PCH_SERIAL_IO_NATIVE_UART_MCR 0x10
#define R_PCH_SERIAL_IO_NATIVE_UART_LSR 0x14
+#define R_PCH_SERIAL_IO_NATIVE_UART_SCR 0x1C
#define R_PCH_SERIAL_IO_NATIVE_UART_USR 0x7C
#define B_PCH_SERIAL_IO_UART_IIR_FIFOSE BIT7|BIT6
@@ -159,6 +160,83 @@ PchSerialIoUartInit (
return TRUE;
}
+UINT8
+EFIAPI
+PchGetScratchpadRegister (
+ IN UINT8 UartNumber
+ )
+{
+ volatile UINTN Base;
+
+ if (UartNumber > 3) {
+ return 0xFF; // In case of invalid UART device
+ }
+
+ Base = FindSerialIoBar (UartNumber + PchSerialIoIndexUart0, 0);
+
+ if ((Base == 0xFFFFFFFF) || ((Base & 0xFFFFFF00) == 0x0)) {
+ return 0xFF; // In case of invalid base
+ }
+
+ return (UINT8) (MmioRead32 (Base + R_PCH_SERIAL_IO_NATIVE_UART_SCR) & 0xFF);
+}
+
+VOID
+PchSetScratchpadRegister (
+ IN UINT8 UartNumber,
+ IN UINT8 Value
+ )
+{
+ volatile UINTN Base;
+
+ if (UartNumber > 3) {
+ return; // In case of invalid UART device
+ }
+
+ Base = FindSerialIoBar (UartNumber + PchSerialIoIndexUart0, 0);
+
+ if ((Base == 0xFFFFFFFF) || ((Base & 0xFFFFFF00) == 0x0)) {
+ return; // In case of invalid base
+ }
+
+ MmioWrite32 (Base + R_PCH_SERIAL_IO_NATIVE_UART_SCR, Value);
+
+ return;
+}
+
+UINT8
+EFIAPI
+PchGetDebugPort (VOID)
+{
+ UINT8 Scratchpad;
+ UINT8 UartPort;
+
+ for (UartPort = 0; UartPort <= 3; UartPort++) {
+ Scratchpad = PchGetScratchpadRegister (UartPort);
+ if ((Scratchpad != 0x00) && (Scratchpad != 0xFF)) {
+ return UartPort;
+ }
+ }
+ return 0xFF;
+}
+
+VOID
+PchSetDebugPort (
+ IN UINT8 UartNumber
+ )
+{
+ UINT8 UartPort;
+
+ for (UartPort = 0; UartPort <= 3; UartPort++) {
+ if (UartPort == UartNumber) {
+ PchSetScratchpadRegister (UartPort, 0x01);
+ } else {
+ PchSetScratchpadRegister (UartPort, 0x00);
+ }
+ }
+ return;
+}
+
/**
Write data to serial device.
--
2.11.0.windows.1
prev parent reply other threads:[~2018-09-27 6:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-21 18:30 [PATCH] [edk2-platforms/devel-IntelAtomProcessorE3900] Dynamic debug UART Steele, Kelly
2018-09-27 6:15 ` Guo, Mang [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=22D2C85ED001C54AA20BFE3B0E4751D1526FC0A1@SHSMSX103.ccr.corp.intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox