From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.93; helo=mga11.intel.com; envelope-from=kelly.steele@intel.com; receiver=edk2-devel@lists.01.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B313621154701 for ; Fri, 21 Sep 2018 11:30:50 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Sep 2018 11:30:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,285,1534834800"; d="scan'208,217,223";a="265626878" Received: from orsmsx102.amr.corp.intel.com ([10.22.225.129]) by fmsmga006.fm.intel.com with ESMTP; 21 Sep 2018 11:30:25 -0700 Received: from orsmsx112.amr.corp.intel.com (10.22.240.13) by ORSMSX102.amr.corp.intel.com (10.22.225.129) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 21 Sep 2018 11:30:18 -0700 Received: from orsmsx114.amr.corp.intel.com ([169.254.8.8]) by ORSMSX112.amr.corp.intel.com ([169.254.3.2]) with mapi id 14.03.0319.002; Fri, 21 Sep 2018 11:30:17 -0700 From: "Steele, Kelly" To: "edk2-devel@lists.01.org" CC: "Wei, David" , "Guo, Mang" Thread-Topic: [PATCH] [edk2-platforms/devel-IntelAtomProcessorE3900] Dynamic debug UART Thread-Index: AdRR2SO8xN1wKp2LQwSRUMhks//ueg== Date: Fri, 21 Sep 2018 18:30:17 +0000 Message-ID: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYmYzYTg0YzQtODE4MC00OWQyLTllYTMtZTc3MWU5N2M2MDQ5IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiMjRZOGtNdFFsZWhZMSt2K3d5V0Zab0lsXC83cDlvWEFpczlHZXA4VU9MUUF4bWt3SjlMK2NDYmJJWENpRHp5VVEifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.22.254.139] MIME-Version: 1.0 X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: [PATCH] [edk2-platforms/devel-IntelAtomProcessorE3900] Dynamic debug UART X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Sep 2018 18:30:51 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable >>From f91d7f365c00f2c16c82431d407f6b63e23e3a5b Mon Sep 17 00:00:00 2001 From: Kelly Steele Date: Fri, 21 Sep 2018 11:09:13 -0700 Subject: [PATCH] [edk2-platforms/devel-IntelAtomProcessorE3900] Dynamic deb= ug 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 --- .../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/BoardInitPreMe= m/BoardInit.c b/Platform/BroxtonPlatformPkg/Board/AuroraGlacier/BoardInitPr= eMem/BoardInit.c index 3304f54131..08975f204e 100644 --- a/Platform/BroxtonPlatformPkg/Board/AuroraGlacier/BoardInitPreMem/Board= Init.c +++ b/Platform/BroxtonPlatformPkg/Board/AuroraGlacier/BoardInitPreMem/Board= Init.c @@ -71,16 +71,18 @@ AuroraGlacierPreMemInit ( return EFI_SUCCESS; } + PchSetDebugPort (2); + DEBUG ((EFI_D_INFO, "This is Aurora Glacier board.\n")); - - + + Status =3D AuroraGetFabId (PeiServices, &FabId); if (FabId =3D=3D FAB_ID_B) { DEBUG ((EFI_D_INFO, "This is Aurora Glacier FAB B.\n")); } else if (FabId =3D=3D 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/BoardInitPreMe= m/BoardInit.h b/Platform/BroxtonPlatformPkg/Board/AuroraGlacier/BoardInitPr= eMem/BoardInit.h index 472a7f97a6..2313e5e6f6 100644 --- a/Platform/BroxtonPlatformPkg/Board/AuroraGlacier/BoardInitPreMem/Board= Init.h +++ b/Platform/BroxtonPlatformPkg/Board/AuroraGlacier/BoardInitPreMem/Board= Init.h @@ -29,6 +29,7 @@ #include #include #include +#include #include diff --git a/Platform/BroxtonPlatformPkg/Board/AuroraGlacier/BoardInitPreMe= m/BoardInitPreMem.inf b/Platform/BroxtonPlatformPkg/Board/AuroraGlacier/Boa= rdInitPreMem/BoardInitPreMem.inf index 53312b7f01..a22d570f4c 100644 --- a/Platform/BroxtonPlatformPkg/Board/AuroraGlacier/BoardInitPreMem/Board= InitPreMem.inf +++ b/Platform/BroxtonPlatformPkg/Board/AuroraGlacier/BoardInitPreMem/Board= InitPreMem.inf @@ -30,6 +30,7 @@ [LibraryClasses] PeiServicesLib PcdLib + PchSerialIoUartLib [Packages] MdePkg/MdePkg.dec diff --git a/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPreMe= m/BoardInit.c b/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPr= eMem/BoardInit.c index d44e824728..ef8c0894e7 100644 --- a/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPreMem/Board= Init.c +++ b/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPreMem/Board= Init.c @@ -71,15 +71,17 @@ BensonGlacierPreMemInit ( return EFI_SUCCESS; } + PchSetDebugPort (2); + DEBUG ((EFI_D_INFO, "This is Benson Glacier board.\n")); - + Status =3D BensonGetFabId (PeiServices, &FabId); if (FabId =3D=3D FAB_ID_B) { DEBUG ((EFI_D_INFO, "This is Benson Glacier FAB B.\n")); } else if (FabId =3D=3D 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/BoardInitPreMe= m/BoardInit.h b/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPr= eMem/BoardInit.h index 833bf558bf..63221148f9 100644 --- a/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPreMem/Board= Init.h +++ b/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPreMem/Board= Init.h @@ -29,6 +29,7 @@ #include #include #include +#include #include diff --git a/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPreMe= m/BoardInitPreMem.inf b/Platform/BroxtonPlatformPkg/Board/BensonGlacier/Boa= rdInitPreMem/BoardInitPreMem.inf index a00a112773..445b63e10c 100644 --- a/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPreMem/Board= InitPreMem.inf +++ b/Platform/BroxtonPlatformPkg/Board/BensonGlacier/BoardInitPreMem/Board= InitPreMem.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.
+# Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BS= D License @@ -30,6 +30,7 @@ [LibraryClasses] PeiServicesLib PcdLib + PchSerialIoUartLib [Packages] MdePkg/MdePkg.dec diff --git a/Platform/BroxtonPlatformPkg/Board/LeafHill/BoardInitPreMem/Boa= rdInit.c b/Platform/BroxtonPlatformPkg/Board/LeafHill/BoardInitPreMem/Board= Init.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.
+ Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #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/Boa= rdInitPreMem.inf b/Platform/BroxtonPlatformPkg/Board/LeafHill/BoardInitPreM= em/BoardInitPreMem.inf index 12a3441d41..4cb4aeccc9 100644 --- a/Platform/BroxtonPlatformPkg/Board/LeafHill/BoardInitPreMem/BoardInitP= reMem.inf +++ b/Platform/BroxtonPlatformPkg/Board/LeafHill/BoardInitPreMem/BoardInitP= reMem.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.
+# Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BS= D 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/BoardInitPreM= em/BoardInit.c index c07d4c0445..3330f91d82 100644 --- a/Platform/BroxtonPlatformPkg/Board/MinnowBoard3/BoardInitPreMem/BoardI= nit.c +++ b/Platform/BroxtonPlatformPkg/Board/MinnowBoard3/BoardInitPreMem/BoardI= nit.c @@ -1,7 +1,7 @@ /** @file Board Init driver. - Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.
+ Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #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/Board= InitPreMem/BoardInitPreMem.inf index 9b71a571ce..c8c549c153 100644 --- a/Platform/BroxtonPlatformPkg/Board/MinnowBoard3/BoardInitPreMem/BoardI= nitPreMem.inf +++ b/Platform/BroxtonPlatformPkg/Board/MinnowBoard3/BoardInitPreMem/BoardI= nitPreMem.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.
+# Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BS= D License @@ -30,6 +30,7 @@ [LibraryClasses] PeiServicesLib PcdLib + PchSerialIoUartLib [Packages] MdePkg/MdePkg.dec diff --git a/Platform/BroxtonPlatformPkg/Board/MinnowBoard3Module/BoardInit= PreMem/BoardInit.c b/Platform/BroxtonPlatformPkg/Board/MinnowBoard3Module/B= oardInitPreMem/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 #include #include +#include #include #include #include "BoardInit.h" @@ -77,21 +78,22 @@ MinnowBoard3ModulePreMemInit ( // Pre Mem Board Init // Status =3D Minnow3ModuleGetEmbeddedBoardIdFabId (PeiServices, &BoardId, = &FabId); - if (BoardId !=3D (UINT8) BOARD_ID_MINNOW_MODULE) { - return EFI_SUCCESS; } + + if (FabId =3D=3D 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 pla= tform code // PcdSet64 (PcdUpdateFspmUpdFunc, (UINT64) (UINTN) mMb3MUpdateF= spmUpdPtr); diff --git a/Platform/BroxtonPlatformPkg/Board/MinnowBoard3Module/BoardInit= PreMem/BoardInitPreMem.inf b/Platform/BroxtonPlatformPkg/Board/MinnowBoard3= Module/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/BoardIni= t.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 #include #include +#include #include #include #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/BoardIni= tPreMem.inf b/Platform/BroxtonPlatformPkg/Board/UP2/BoardInitPreMem/BoardIn= itPreMem.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/S= erial.c b/Platform/BroxtonPlatformPkg/Common/Console/LpssUartSerialDxe/Seri= al.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.
+ Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License @@ -1652,7 +1652,7 @@ IsaSerialWrite ( CharBuffer =3D (UINT8 *) Buffer; - PchSerialIoUartOut (PcdGet8 (PcdSerialIoUartNumber), CharBuffer, *Buffer= Size); + PchSerialIoUartOut (PchGetDebugPort (), CharBuffer, *BufferSize); gBS->RestoreTPL (Tpl); @@ -1696,7 +1696,7 @@ IsaSerialRead ( Tpl =3D gBS->RaiseTPL (TPL_NOTIFY); - *BufferSize =3D PchSerialIoUartIn(PcdGet8 (PcdSerialIoUartNumber), Buffe= r, *BufferSize, FALSE); + *BufferSize =3D PchSerialIoUartIn (PchGetDebugPort (), Buffer, *BufferSi= ze, FALSE); gBS->RestoreTPL (Tpl); diff --git a/Platform/BroxtonPlatformPkg/Common/Library/BaseSerialPortLib/B= aseSerialPortLib.c b/Platform/BroxtonPlatformPkg/Common/Library/BaseSerialP= ortLib/BaseSerialPortLib.c index 7770619f97..0364e38669 100644 --- a/Platform/BroxtonPlatformPkg/Common/Library/BaseSerialPortLib/BaseSeri= alPortLib.c +++ b/Platform/BroxtonPlatformPkg/Common/Library/BaseSerialPortLib/BaseSeri= alPortLib.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.
+ Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D 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, Valu= e); -} - 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 pr= ogrammed appropriately at this point. + // We store the Debug Serial port in the scratchpad register of the UART= s. // - BaudRate =3D PcdGet32 (PcdSerialBaudRate); - if ((BaudRate =3D=3D 0) || ((BaudRate % 9600) !=3D 0)) { - // - // If Serail Baud Rate is not valid, set it to the default value - // - BaudRate =3D PcdGet32 (PcdSerialBaudRate); - } - Divisor =3D 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 =3D TRUE; - if ((SerialPortReadRegister (FCR_OFFSET) & (FCR_FIFOE | FCR_FIFO64)) != =3D - (PcdGet8 (PcdSerialFifoControl) & (FCR_FIFOE | FCR_FIFO64))) { - Initialized =3D FALSE; - } - if ((SerialPortReadRegister (LCR_OFFSET) & 0x3F) !=3D (PcdGet8 (PcdSeria= lLineControl) & 0x3F)) { - Initialized =3D FALSE; - } - SerialPortWriteRegister (LCR_OFFSET, (UINT8) (SerialPortReadRegister (LC= R_OFFSET) | DLAB)); - TempDivisor =3D (UINTN) SerialPortReadRegister (BAUD_HIGH_OFFSET); - TempDivisor =3D TempDivisor << 8; - TempDivisor |=3D (UINTN) SerialPortReadRegister (BAUD_LOW_OFFSET); - SerialPortWriteRegister (LCR_OFFSET, (UINT8) (SerialPortReadRegister (LC= R_OFFSET) & ~DLAB)); - if (TempDivisor !=3D Divisor) { - Initialized =3D 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 (PcdSerialLineCont= rol) & 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 (PcdSerialFifoCont= rol) & 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 write= d. - @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 dev= ice. - -**/ -UINTN -EFIAPI -UARTDbgOut ( - IN UINT8 *Buffer, - IN UINTN NumberOfBytes - ) -{ - UINTN Result; - UINTN FifoSize; - UINTN Index; - - if (NULL =3D=3D Buffer) { - return 0; - } - - // - // Compute the maximum size of the Tx FIFO - // - FifoSize =3D 1; - if ((PcdGet8 (PcdSerialFifoControl) & FCR_FIFOE) !=3D 0) { - if ((PcdGet8 (PcdSerialFifoControl) & FCR_FIFO64) =3D=3D 0) { - FifoSize =3D 16; - } else { - FifoSize =3D 64; - } - } - - Result =3D NumberOfBytes; - - while (NumberOfBytes !=3D 0) { - // - // Wait for the serial port to be ready, to make sure both the transmi= t FIFO - // and shift register empty. - // - while ((SerialPortReadRegister (LSR_OFFSET) & LSR_TXRDY) =3D=3D 0); - - // - // Fill then entire Tx FIFO - // - for (Index =3D 0; Index < FifoSize && NumberOfBytes !=3D 0; Index++, N= umberOfBytes--, 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 - // =3D=3D=3D =3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D - // 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. Transmi= t - // - while ((SerialPortReadRegister (MSR_OFFSET) & (MSR_DSR | MSR_CTS= )) !=3D (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 - // =3D=3D=3D =3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D - // 0 0 No cable connected. Transmi= t - // 0 1 No cable connected. Transmi= t - // 1 0 Cable connected, but not clear to send. Wait - // 1 1 Cable connected, and clar to send. Transmi= t - // - while ((SerialPortReadRegister (MSR_OFFSET) & (MSR_DSR | MSR_CTS= )) =3D=3D (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, NumberOfByt= es); + 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 writ= ed. - @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 devi= ce. - -**/ -UINTN -EFIAPI -UARTDbgIn ( - OUT UINT8 *Buffer, - IN UINTN NumberOfBytes - ) -{ - UINTN Result; - UINT8 Mcr; - - if (NULL =3D=3D Buffer) { - return 0; - } - - Result =3D NumberOfBytes; - - Mcr =3D (UINT8) (SerialPortReadRegister (MCR_OFFSET) & ~MCR_RTS); - - for (Result =3D 0; NumberOfBytes-- !=3D 0; Result ++, Buffer ++) { - // - // Wait for the serial port to have some data. - // - while ((SerialPortReadRegister (LSR_OFFSET) & LSR_RXDA) =3D=3D 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 =3D 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 write= d. @@ -374,52 +135,11 @@ SerialPortRead ( ) { - PchSerialIoUartIn (PcdGet8 (PcdSerialIoUartNumber), Buffer, NumberOfByte= s, 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 FALS= E is returned. - - @retval TRUE Data is waiting to be read from the serial devic= e. - @retval FALSE There is no data waiting to be read from the ser= ial device. - -**/ -BOOLEAN -EFIAPI -UARTDbgPoll ( - VOID - ) -{ - // - // Read the serial port status - // - if ((SerialPortReadRegister (LSR_OFFSET) & LSR_RXDA) !=3D 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 =3D FALSE; - Status |=3D PchSerialIoUartPoll (PcdGet8 (PcdSerialIoUartNumber)); + Status |=3D PchSerialIoUartPoll (PchGetDebugPort ()); return Status; } diff --git a/Platform/BroxtonPlatformPkg/Common/Library/BaseSerialPortLib/B= aseSerialPortLibNoInit.c b/Platform/BroxtonPlatformPkg/Common/Library/BaseS= erialPortLib/BaseSerialPortLibNoInit.c index f9e96338b0..199f004aaf 100644 --- a/Platform/BroxtonPlatformPkg/Common/Library/BaseSerialPortLib/BaseSeri= alPortLibNoInit.c +++ b/Platform/BroxtonPlatformPkg/Common/Library/BaseSerialPortLib/BaseSeri= alPortLibNoInit.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.
+ Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D 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, Valu= e); -} - 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 write= d. - @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 dev= ice. - -**/ -UINTN -EFIAPI -UARTDbgOut ( - IN UINT8 *Buffer, - IN UINTN NumberOfBytes -) -{ - UINTN Result; - UINTN FifoSize; - UINTN Index; - - if (NULL =3D=3D Buffer) { - return 0; - } - - // - // Compute the maximum size of the Tx FIFO - // - FifoSize =3D 1; - if ((PcdGet8 (PcdSerialFifoControl) & FCR_FIFOE) !=3D 0) { - if ((PcdGet8 (PcdSerialFifoControl) & FCR_FIFO64) =3D=3D 0) { - FifoSize =3D 16; - } else { - FifoSize =3D 64; - } - } - - Result =3D NumberOfBytes; - - while (NumberOfBytes !=3D 0) { - // - // Wait for the serial port to be ready, to make sure both the transmi= t FIFO - // and shift register empty. - // - while ((SerialPortReadRegister (LSR_OFFSET) & LSR_TXRDY) =3D=3D 0); - - // - // Fill then entire Tx FIFO - // - for (Index =3D 0; Index < FifoSize && NumberOfBytes !=3D 0; Index++, N= umberOfBytes--, 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 - // =3D=3D=3D =3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D - // 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. Transmi= t - // - while ((SerialPortReadRegister (MSR_OFFSET) & (MSR_DSR | MSR_CTS= )) !=3D (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 - // =3D=3D=3D =3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D - // 0 0 No cable connected. Transmi= t - // 0 1 No cable connected. Transmi= t - // 1 0 Cable connected, but not clear to send. Wait - // 1 1 Cable connected, and clar to send. Transmi= t - // - while ((SerialPortReadRegister (MSR_OFFSET) & (MSR_DSR | MSR_CTS= )) =3D=3D (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, NumberOfByt= es); + 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 writ= ed. - @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 devi= ce. - -**/ -UINTN -EFIAPI -UARTDbgIn ( - OUT UINT8 *Buffer, - IN UINTN NumberOfBytes - ) -{ - UINTN Result; - UINT8 Mcr; - - if (NULL =3D=3D Buffer) { - return 0; - } - - Result =3D NumberOfBytes; - - Mcr =3D (UINT8) (SerialPortReadRegister (MCR_OFFSET) & ~ MCR_RTS); - - for (Result =3D 0; NumberOfBytes-- !=3D 0; Result++, Buffer++) { - // - // Wait for the serial port to have some data. - // - while ((SerialPortReadRegister (LSR_OFFSET) & LSR_RXDA) =3D=3D 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 =3D 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, NumberOfByte= s, 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 FALS= E is returned. - - @retval TRUE Data is waiting to be read from the serial devi= ce. - @retval FALSE There is no data waiting to be read from the se= rial device. - -**/ -BOOLEAN -EFIAPI -UARTDbgPoll ( - VOID - ) -{ - // - // Read the serial port status - // - if ((SerialPortReadRegister (LSR_OFFSET) & LSR_RXDA) !=3D 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 =3D FALSE; - Status |=3D PchSerialIoUartPoll (PcdGet8 (PcdSerialIoUartNumber)); + Status |=3D PchSerialIoUartPoll (PchGetDebugPort ()); return Status; } diff --git a/Platform/BroxtonPlatformPkg/PlatformDsc/Components.dsc b/Platf= orm/BroxtonPlatformPkg/PlatformDsc/Components.dsc index f0106bc850..e6486fbca0 100644 --- a/Platform/BroxtonPlatformPkg/PlatformDsc/Components.dsc +++ b/Platform/BroxtonPlatformPkg/PlatformDsc/Components.dsc @@ -31,6 +31,7 @@ PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf + SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLib= Null.inf } !if $(SOURCE_DEBUG_ENABLE) =3D=3D 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) =3D=3D 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, 0= x90, 0x05, 0xC0, 0x00, 0xA0, 0x05, 0xC0, 0x00, 0xC8, 0x05, 0xC0, 0x00, 0xD0= , 0x05, 0xC0, 0x00, 0xE0, 0x05, 0xC0, 0x00, 0xF0, 0x05, 0xC0, 0x00, 0xF8, 0= x05, 0xC0, 0x00, 0x30, 0x05, 0xC4, 0x00, 0x48, 0x05, 0xC4, 0x00, 0x50, 0x05= , 0xC4, 0x00, 0x58, 0x05, 0xC4, 0x00, 0x60, 0x05, 0xC4, 0x00, 0x68, 0x05, 0= xC4, 0x00, 0x80, 0x05, 0xC4, 0x00, 0x88, 0x05, 0xC4, 0x00, 0x98, 0x05, 0xC4= , 0x00, 0x60, 0x06, 0xC4, 0x00, 0x60, 0x06, 0xC4, 0x00, 0x68, 0x06, 0xC4, 0= x00, 0x70, 0x06, 0xC4, 0x00, 0x78, 0x06, 0xC4, 0x00, 0x80, 0x06, 0xC4, 0x00= , 0xA8, 0x06, 0xC4, 0x00, 0xB0, 0x06, 0xC4, 0x00, 0xB8, 0x06, 0xC4, 0x00, 0= xC0, 0x06, 0xC4, 0x00, 0xD8, 0x06, 0xC4, 0x00, 0xE8, 0x06, 0xC4, 0x00, 0xF0= , 0x06, 0xC4, 0x00, 0xF8, 0x06, 0xC4, 0x00, 0x00, 0x07, 0xC4, 0x00, 0x08, 0= x07, 0xC4, 0x00, 0x18, 0x07, 0xC4, 0x00, 0x20, 0x07, 0xC4, 0x00, 0x10, 0x05= , 0xC5, 0x00, 0x18, 0x05, 0xC5, 0x00, 0x20, 0x05, 0xC5, 0x00, 0x30, 0x05, 0= xC5, 0x00, 0x38, 0x05, 0xC5, 0x00, 0x68, 0x05, 0xC5, 0x00, 0x70, 0x05, 0xC5= , 0x00, 0xA8, 0x05, 0xC5, 0x00, 0xB0, 0x05, 0xC5, 0x00, 0xB8, 0x05, 0xC5, 0= x00, 0xC0, 0x05, 0xC5, 0x00, 0xC8, 0x05, 0xC5, 0x00, 0xD0, 0x05, 0xC5, 0x00= , 0x30, 0x06, 0xC5, 0x00, 0x38, 0x06, 0xC5, 0x00, 0x40, 0x06, 0xC5, 0x00, 0= x48, 0x06, 0xC5, 0x00, 0x50, 0x06, 0xC5, 0x00, 0x58, 0x06, 0xC5, 0x00, 0x70= , 0x06, 0xC5, 0x00, 0x78, 0x06, 0xC5, 0x00, 0x80, 0x06, 0xC5, 0x00, 0x88, 0= x06, 0xC5, 0x00, 0xA0, 0x06, 0xC5, 0x00, 0xA8, 0x06, 0xC5, 0x00, 0xB0, 0x06= , 0xC5, 0x00, 0xB8, 0x06, 0xC5, 0x00, 0x10, 0x05, 0xC7, 0x00, 0x18, 0x05, 0= xC7, 0x00, 0x40, 0x05, 0xC7, 0x00, 0x48, 0x05, 0xC7, 0x00, 0x50, 0x05, 0xC7= , 0x00, 0x58, 0x05, 0xC7, 0x00, 0x60, 0x05, 0xC7, 0x00, 0x68, 0x05, 0xC7, 0= x00, 0x70, 0x05, 0xC7, 0x00, 0x78, 0x05, 0xC7, 0x00, 0x80, 0x05, 0xC7, 0x00= , 0x88, 0x05, 0xC7, 0x00, 0x90, 0x05, 0xC7, 0x00, 0x98, 0x05, 0xC7, 0x00, 0= xF0, 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/Broxton= PlatformPkg/PlatformPkg.dec index c27ac042ab..3d14109e39 100644 --- a/Platform/BroxtonPlatformPkg/PlatformPkg.dec +++ b/Platform/BroxtonPlatformPkg/PlatformPkg.dec @@ -202,8 +202,6 @@ gPlatformModuleTokenSpaceGuid.PcdTi3100AudioCodecEnable|FALSE|BOOLEAN|0x= 80000019 ## gPlatformModuleTokenSpaceGuid.PcdUpdatePcieConfigFunc|2|UINT64|0x8000001= A - ## 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 provisi= on. gClientCommonModuleTokenSpaceGuid.PcdTpm2TxtProvisionSupport|FALSE|BOOLE= AN|0x00010027 + ## Specifies maximum number of PPIs provided by SecCore. + # @Prompt Maximum number of PPIs provided by SecCore. + gPlatformModuleTokenSpaceGuid.PcdSecCoreMaxPpiSupported|0x6|UINT32|0x100= 01010 + + ## 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, 0= x49, 0x88, 0x47, 0xc5, 0xb7, 0x2a, 0xb0, 0x7d, 0xc5, 0x10, 0x60, 0xc4 }|VOI= D*|0x10001004 gPlatformModuleTokenSpaceGuid.PcdTianoCoreLogoFileGuid|{ 0x99, 0x8b, 0xB= 2, 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|0x100= 01010 - ## SerialIo Uart Configuration - gPlatformModuleTokenSpaceGuid.PcdSerialIoUartNumber|2|UINT8|0x10001011 diff --git a/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/Include/Library/S= cSerialIoUartLib.h b/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/Include/L= ibrary/ScSerialIoUartLib.h index 68c04695ac..3dd2370fba 100644 --- a/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/Include/Library/ScSerial= IoUartLib.h +++ b/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/Include/Library/ScSerial= IoUartLib.h @@ -1,7 +1,7 @@ /** @file Header file for PCH Serial IO UART Lib implementation. - Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D 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/PeiDxeSmm= PchSerialIoUartLib/PeiDxeSmmPchSerialIoUartLib.c b/Silicon/BroxtonSoC/Broxt= onSiPkg/SouthCluster/Library/PeiDxeSmmPchSerialIoUartLib/PeiDxeSmmPchSerial= IoUartLib.c index 4a3bdcc9d8..6071f077dc 100644 --- a/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/Library/PeiDxeSmmPchSeri= alIoUartLib/PeiDxeSmmPchSerialIoUartLib.c +++ b/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/Library/PeiDxeSmmPchSeri= alIoUartLib/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.
+ Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D 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 =3D FindSerialIoBar (UartNumber + PchSerialIoIndexUart0, 0); + + if ((Base =3D=3D 0xFFFFFFFF) || ((Base & 0xFFFFFF00) =3D=3D 0x0)) { + return 0xFF; // In case of invalid base + } + + return (UINT8) (MmioRead32 (Base + R_PCH_SERIAL_IO_NATIVE_UART_SCR) & 0x= FF); +} + +VOID +PchSetScratchpadRegister ( + IN UINT8 UartNumber, + IN UINT8 Value + ) +{ + volatile UINTN Base; + + if (UartNumber > 3) { + return; // In case of invalid UART device + } + + Base =3D FindSerialIoBar (UartNumber + PchSerialIoIndexUart0, 0); + + if ((Base =3D=3D 0xFFFFFFFF) || ((Base & 0xFFFFFF00) =3D=3D 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 =3D 0; UartPort <=3D 3; UartPort++) { + Scratchpad =3D PchGetScratchpadRegister (UartPort); + if ((Scratchpad !=3D 0x00) && (Scratchpad !=3D 0xFF)) { + return UartPort; + } + } + return 0xFF; +} + +VOID +PchSetDebugPort ( + IN UINT8 UartNumber + ) +{ + UINT8 UartPort; + + for (UartPort =3D 0; UartPort <=3D 3; UartPort++) { + if (UartPort =3D=3D UartNumber) { + PchSetScratchpadRegister (UartPort, 0x01); + } else { + PchSetScratchpadRegister (UartPort, 0x00); + } + } + return; +} + /** Write data to serial device. -- 2.11.0.windows.1