From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=mang.guo@intel.com; receiver=edk2-devel@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 D87E9210F41F0 for ; Fri, 17 Aug 2018 02:33:15 -0700 (PDT) X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Aug 2018 02:33:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,250,1531810800"; d="dat'59?scan'59,208,59";a="254898734" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga005.fm.intel.com with ESMTP; 17 Aug 2018 02:33:15 -0700 Received: from fmsmsx114.amr.corp.intel.com (10.18.116.8) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 17 Aug 2018 02:33:14 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX114.amr.corp.intel.com (10.18.116.8) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 17 Aug 2018 02:33:13 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.240]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.205]) with mapi id 14.03.0319.002; Fri, 17 Aug 2018 17:33:12 +0800 From: "Guo, Mang" To: "edk2-devel@lists.01.org" CC: "Wei, David" Thread-Topic: [Patch][edk2-platforms/devel-IntelAtomProcessorE3900 5Common EEPROM library instance Thread-Index: AdQ2DVBc85xPMXV3QTqWjRuxP38w3Q== Date: Fri, 17 Aug 2018 09:33:11 +0000 Message-ID: <22D2C85ED001C54AA20BFE3B0E4751D1526D137E@SHSMSX103.ccr.corp.intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: <22D2C85ED001C54AA20BFE3B0E4751D1526D137E@SHSMSX103.ccr.corp.intel.com> x-originating-ip: [10.239.127.40] MIME-Version: 1.0 X-Content-Filtered-By: Mailman/MimeDel 2.1.27 Subject: [Patch][edk2-platforms/devel-IntelAtomProcessorE3900 5Common EEPROM library instance X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Aug 2018 09:33:16 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Cc: David Wei Cc: Mike Wu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Kelly Steele Signed-off-by: Guo Mang --- .../Features/Eeprom/EepromPlatformLib/EepromAcpi.c | 211 ++++++++++++ .../Eeprom/EepromPlatformLib/EepromAcpiNull.c | 32 ++ .../Eeprom/EepromPlatformLib/EepromAcpiPei.c | 32 ++ .../Eeprom/EepromPlatformLib/EepromPlatformLib.c | 359 +++++++++++++++++= ++++ .../Eeprom/EepromPlatformLib/EepromPlatformLib.h | 36 +++ .../Eeprom/EepromPlatformLib/EepromPlatformLib.inf | 59 ++++ .../EepromPlatformLib/EepromPlatformNullLib.c | 95 ++++++ .../EepromPlatformLib/EepromPlatformNullLib.inf | 57 ++++ .../EepromPlatformLib/EepromPlatformPeiLib.inf | 57 ++++ 9 files changed, 938 insertions(+) create mode 100644 Platform/BroxtonPlatformPkg/Common/Features/Eeprom/Eepr= omPlatformLib/EepromAcpi.c create mode 100644 Platform/BroxtonPlatformPkg/Common/Features/Eeprom/Eepr= omPlatformLib/EepromAcpiNull.c create mode 100644 Platform/BroxtonPlatformPkg/Common/Features/Eeprom/Eepr= omPlatformLib/EepromAcpiPei.c create mode 100644 Platform/BroxtonPlatformPkg/Common/Features/Eeprom/Eepr= omPlatformLib/EepromPlatformLib.c create mode 100644 Platform/BroxtonPlatformPkg/Common/Features/Eeprom/Eepr= omPlatformLib/EepromPlatformLib.h create mode 100644 Platform/BroxtonPlatformPkg/Common/Features/Eeprom/Eepr= omPlatformLib/EepromPlatformLib.inf create mode 100644 Platform/BroxtonPlatformPkg/Common/Features/Eeprom/Eepr= omPlatformLib/EepromPlatformNullLib.c create mode 100644 Platform/BroxtonPlatformPkg/Common/Features/Eeprom/Eepr= omPlatformLib/EepromPlatformNullLib.inf create mode 100644 Platform/BroxtonPlatformPkg/Common/Features/Eeprom/Eepr= omPlatformLib/EepromPlatformPeiLib.inf diff --git a/Platform/BroxtonPlatformPkg/Common/Features/Eeprom/EepromPlatf= ormLib/EepromAcpi.c b/Platform/BroxtonPlatformPkg/Common/Features/Eeprom/Ee= promPlatformLib/EepromAcpi.c new file mode 100644 index 0000000..7381c82 --- /dev/null +++ b/Platform/BroxtonPlatformPkg/Common/Features/Eeprom/EepromPlatformLib/= EepromAcpi.c @@ -0,0 +1,211 @@ +/** @file + Common EEPROM library instance. + + Copyright (c) 2015 - 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 + which accompanies this distribution. The full text of the license may b= e found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. + +**/ + +#include "EepromPlatformLib.h" + +#include +#include +#include +#include +#include +#include + +/*++ + +Routine Description: + +Locate the first instance of a protocol. If the protocol requested is an +FV protocol, then it will return the first FV that contains the ACPI table +storage file. + +Arguments: + +Protocol - The protocol to find. +Instance - Return pointer to the first instance of the protocol. +Type - The type of protocol to locate. + +Returns: + +EFI_SUCCESS - The function completed successfully. +EFI_NOT_FOUND - The protocol could not be located. +EFI_OUT_OF_RESOURCES - There are not enough resources to find the protoc= ol. + +--*/ +EFI_STATUS +LocateSupportProtocol( +IN EFI_GUID *Protocol, +OUT VOID **Instance, +IN UINT32 Type +) +{ + EFI_STATUS Status; + EFI_HANDLE *HandleBuffer; + UINTN NumberOfHandles; + EFI_FV_FILETYPE FileType; + UINT32 FvStatus; + EFI_FV_FILE_ATTRIBUTES Attributes; + UINTN Size; + UINTN Index; + + FvStatus =3D 0; + // + // Locate protocol. + // + Status =3D gBS->LocateHandleBuffer( + ByProtocol, + Protocol, + NULL, + &NumberOfHandles, + &HandleBuffer + ); + if (EFI_ERROR(Status)) { + // + // Defined errors at this time are not found and out of resources. + // + return Status; + } + + // + // Looking for FV with ACPI storage file + // + for (Index =3D 0; Index < NumberOfHandles; Index++) { + // + // Get the protocol on this handle + // This should not fail because of LocateHandleBuffer + // + Status =3D gBS->HandleProtocol( + HandleBuffer[Index], + Protocol, + Instance + ); + ASSERT(!EFI_ERROR(Status)); + + if (!Type) { + // + // Not looking for the FV protocol, so find the first instance= of the + // protocol. There should not be any errors because our handl= e buffer + // should always contain at least one or LocateHandleBuffer wo= uld have + // returned not found. + // + break; + } + // + // See if it has the ACPI storage file + // + Status =3D ((EFI_FIRMWARE_VOLUME2_PROTOCOL*)(*Instance))->ReadFile= ( + *Instance, + &gEfiAcpiTableStorageGuid, + NULL, + &Size, + &FileType, + &Attributes, + &FvStatus + ); + // + // If we found it, then we are done + // + if (!EFI_ERROR(Status)) { + break; + } + } + // + // Our exit status is determined by the success of the previous operat= ions + // If the protocol was found, Instance already points to it. + // + // + // Free any allocated buffers + // + gBS->FreePool(HandleBuffer); + + return Status; +} + +/** + Programs the ACPI SSDT data in $AcpiTbl + + @param[in] VOID + + @retval EFI_SUCCESS $AcpiTbl data found + @retval EFI_NOT_FOUND $AcpiTbl data not found + @retval EFI_NOT_READY $AcpiTbl data not ready to be programmed +**/ +EFI_STATUS +EepromProgramAcpi (VOID) +{ + UINT8 EepromLibrary; + UINT8 *AcpiData; + UINT32 AcpiSize; + ACPI_TABLE *AcpiStructure; + EFI_ACPI_SUPPORT_PROTOCOL *AcpiSupport; + UINT32 Size; + EFI_STATUS Status; + UINTN TableHandle; + + if (mEepromPlatformLibDebugFlag) DEBUG ((DEBUG_INFO, "%a(#%4d) - Startin= g...\n", __FUNCTION__, __LINE__)); + + // + // Find the AcpiSupport protocol + // + Status =3D LocateSupportProtocol (&gEfiAcpiSupportProtocolGuid, (VOID **= ) &AcpiSupport, 0); + if (EFI_ERROR (Status)) { + Status =3D EFI_NOT_READY; + goto Exit; + } + + // + // Program the $AcpiTbl data + // 1. Get valid EEPROM library index + // 2. Find $AcpiTbl structure + // 3. Program the $AcpiTbl data + // + EepromLibrary =3D GetValidEepromLibrary (TRUE); + if (EepromLibrary =3D=3D EEPROM_NULL) { + DEBUG ((DEBUG_ERROR, "%a(#%4d) - ERROR: Didn't find a valid EEPROM bin= ary!\n", __FUNCTION__, __LINE__)); + Status =3D EFI_NOT_FOUND; + } else { + Size =3D 0; + Status =3D GetEepromStructure (EepromLibrary, EEPROM_ACPI_TABLE_SIGNAT= URE, (UINT8 **) &AcpiStructure, &Size); + if (EFI_ERROR (Status) || (Size =3D=3D 0)) { + DEBUG ((DEBUG_ERROR, "%a(#%4d) - ERROR: Didn't find the $AcpiTbl str= ucture in the EERPOM binary!\n", __FUNCTION__, __LINE__)); + Status =3D EFI_NOT_FOUND; + } else { + AcpiSize =3D AcpiStructure->length - sizeof (ACPI_TABLE); + if (AcpiSize =3D=3D 0) { + EepromFreePool (AcpiStructure); + DEBUG ((DEBUG_ERROR, "%a(#%4d) - ERROR: Didn't find the $AcpiTbl s= tructure data in the EERPOM binary!\n", __FUNCTION__, __LINE__)); + Status =3D EFI_NOT_FOUND; + } else { + AcpiData =3D (UINT8 *) AcpiStructure + sizeof (ACPI_TABLE); + // + // publish the AcpiTable + // + TableHandle =3D 0; + Status =3D AcpiSupport->SetAcpiTable ( + AcpiSupport, + AcpiData, + TRUE, + EFI_ACPI_TABLE_VERSION_2_0, + &TableHandle + ); + // + // re-init variables + // + AcpiStructure =3D EepromFreePool (AcpiStructure); + } + } + } +Exit: + return Status; +} diff --git a/Platform/BroxtonPlatformPkg/Common/Features/Eeprom/EepromPlatf= ormLib/EepromAcpiNull.c b/Platform/BroxtonPlatformPkg/Common/Features/Eepro= m/EepromPlatformLib/EepromAcpiNull.c new file mode 100644 index 0000000..0ce136a --- /dev/null +++ b/Platform/BroxtonPlatformPkg/Common/Features/Eeprom/EepromPlatformLib/= EepromAcpiNull.c @@ -0,0 +1,32 @@ +/** @file + Common EEPROM library instance. + + Copyright (c) 2015 - 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 + which accompanies this distribution. The full text of the license may b= e found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. + +**/ + +#include "EepromPlatformLib.h" + +/** + Programs the ACPI SSDT data in $AcpiTbl + + @param[in] VOID + + @retval EFI_SUCCESS $AcpiTbl data found + @retval EFI_NOT_FOUND $AcpiTbl data not found + @retval EFI_NOT_READY $AcpiTbl data not ready to be programmed +**/ +EFI_STATUS +EepromProgramAcpi (VOID) +{ + if (mEepromPlatformLibDebugFlag) DEBUG ((DEBUG_INFO, "%a(#%4d) - Startin= g...\n", __FUNCTION__, __LINE__)); + return EFI_NOT_READY; +} diff --git a/Platform/BroxtonPlatformPkg/Common/Features/Eeprom/EepromPlatf= ormLib/EepromAcpiPei.c b/Platform/BroxtonPlatformPkg/Common/Features/Eeprom= /EepromPlatformLib/EepromAcpiPei.c new file mode 100644 index 0000000..0ce136a --- /dev/null +++ b/Platform/BroxtonPlatformPkg/Common/Features/Eeprom/EepromPlatformLib/= EepromAcpiPei.c @@ -0,0 +1,32 @@ +/** @file + Common EEPROM library instance. + + Copyright (c) 2015 - 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 + which accompanies this distribution. The full text of the license may b= e found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. + +**/ + +#include "EepromPlatformLib.h" + +/** + Programs the ACPI SSDT data in $AcpiTbl + + @param[in] VOID + + @retval EFI_SUCCESS $AcpiTbl data found + @retval EFI_NOT_FOUND $AcpiTbl data not found + @retval EFI_NOT_READY $AcpiTbl data not ready to be programmed +**/ +EFI_STATUS +EepromProgramAcpi (VOID) +{ + if (mEepromPlatformLibDebugFlag) DEBUG ((DEBUG_INFO, "%a(#%4d) - Startin= g...\n", __FUNCTION__, __LINE__)); + return EFI_NOT_READY; +} diff --git a/Platform/BroxtonPlatformPkg/Common/Features/Eeprom/EepromPlatf= ormLib/EepromPlatformLib.c b/Platform/BroxtonPlatformPkg/Common/Features/Ee= prom/EepromPlatformLib/EepromPlatformLib.c new file mode 100644 index 0000000..4ef7879 --- /dev/null +++ b/Platform/BroxtonPlatformPkg/Common/Features/Eeprom/EepromPlatformLib/= EepromPlatformLib.c @@ -0,0 +1,359 @@ +/** @file + Common EEPROM library instance. + + Copyright (c) 2015 - 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 + which accompanies this distribution. The full text of the license may b= e found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. + +**/ + +#include "EepromPlatformLib.h" + +BOOLEAN mEepromPlatformLibDebugFlag =3D TRUE; + +/** + Returns the $BrdInfo structure + + @param[out] BoardInfo Buffer containing the BOARD_INFO_TABLE stru= cture + - Up to the caller to free the buffer + + @retval EFI_SUCCESS $BrdInfo structure found + @retval EFI_NOT_FOUND $BrdInfo structure not found + @retval EFI_NOT_READY $BrdInfo structure not ready yet +**/ +EFI_STATUS +EepromGetBoardInfo ( + OUT BOARD_INFO_TABLE **BoardInfo + ) +{ + CHAR8 AsciiData[32]; + UINT8 EepromLibrary; + UINT32 Size; + EFI_STATUS Status; + + if (mEepromPlatformLibDebugFlag) DEBUG ((DEBUG_INFO, "%a(#%4d) - Startin= g...\n", __FUNCTION__, __LINE__)); + + // + // Return the $BrdInfo structure + // 1. Get valid EEPROM library index + // 2. Find $BrdInfo structure + // + EepromLibrary =3D GetValidEepromLibrary (TRUE); + if (EepromLibrary =3D=3D EEPROM_NULL) { + DEBUG ((DEBUG_ERROR, "%a(#%4d) - ERROR: Didn't find a valid EEPROM bin= ary!\n", __FUNCTION__, __LINE__)); + Status =3D EFI_NOT_FOUND; + } else { + Size =3D 0; + Status =3D GetEepromStructure (EepromLibrary, EEPROM_BOARD_INFO_SIGNAT= URE, (UINT8 **) BoardInfo, &Size); + if (EFI_ERROR (Status) || (Size =3D=3D 0)) { + DEBUG ((DEBUG_ERROR, "%a(#%4d) - ERROR: Didn't find the $BrdInfo str= ucture in the EERPOM binary!\n", __FUNCTION__, __LINE__)); + Status =3D EFI_NOT_FOUND; + } else { + if (mEepromPlatformLibDebugFlag) { + ZeroMem (AsciiData, 32); + CopyMem (AsciiData, (*BoardInfo)->signature, 8); + DEBUG ((DEBUG_INFO, "%a(#%4d) - Signature =3D %a\n", __F= UNCTION__, __LINE__, AsciiData)); + DEBUG ((DEBUG_INFO, "%a(#%4d) - Version =3D %04x:%04x\n", __F= UNCTION__, __LINE__, (*BoardInfo)->vermajor, (*BoardInfo)->verminor)); + DEBUG ((DEBUG_INFO, "%a(#%4d) - Length =3D 0x%08x\n", __F= UNCTION__, __LINE__, (*BoardInfo)->length)); + ZeroMem (AsciiData, 32); + CopyMem (AsciiData, (*BoardInfo)->manuname, 16); + DEBUG ((DEBUG_INFO, "%a(#%4d) - Manufacturer =3D %a\n", __F= UNCTION__, __LINE__, AsciiData)); + ZeroMem (AsciiData, 32); + CopyMem (AsciiData, (*BoardInfo)->brdname, 16); + DEBUG ((DEBUG_INFO, "%a(#%4d) - Board name =3D %a\n", __F= UNCTION__, __LINE__, AsciiData)); + ZeroMem (AsciiData, 32); + CopyMem (AsciiData, (*BoardInfo)->brdserial, 16); + DEBUG ((DEBUG_INFO, "%a(#%4d) - Serial # =3D %a\n", __F= UNCTION__, __LINE__, AsciiData)); + DEBUG ((DEBUG_INFO, "%a(#%4d) - Board ID =3D 0x%08x\n", __F= UNCTION__, __LINE__, (*BoardInfo)->boardid)); + DEBUG ((DEBUG_INFO, "%a(#%4d) - Fab ID =3D 0x%08x\n", __F= UNCTION__, __LINE__, (*BoardInfo)->fabid)); + DEBUG ((DEBUG_INFO, "%a(#%4d) - EC ID =3D 0x%08x\n", __F= UNCTION__, __LINE__, (*BoardInfo)->ecid)); + DEBUG ((DEBUG_INFO, "%a(#%4d) - Board type =3D %a\n", __F= UNCTION__, __LINE__, (*BoardInfo)->boardtype ? "Main board (RedBox)" : "Plu= g-in board")); + } + Status =3D EFI_SUCCESS; + } + } + if (mEepromPlatformLibDebugFlag) DEBUG ((DEBUG_INFO, "%a(#%4d) - Returni= ng %r...\n", __FUNCTION__, __LINE__, Status)); + return Status; +} + +/** + Returns the $Logo$ data + + @param[out] LogoData Buffer containing the $Logo$ data + @param[out] LogoSize Size of the LogoData buffer + + @retval EFI_SUCCESS $Logo$ data found + @retval EFI_NOT_FOUND $Logo$ data not found + @retval EFI_NOT_READY $Logo$ data not ready yet +**/ +EFI_STATUS +EepromGetLogo ( + OUT UINT8 **LogoData, + OUT UINT32 *LogoSize + ) +{ + CHAR8 AsciiData[32]; + UINT8 EepromLibrary; + LOGO_DATA *LogoStructure; + UINT32 Size; + EFI_STATUS Status; + + if (mEepromPlatformLibDebugFlag) DEBUG ((DEBUG_INFO, "%a(#%4d) - Startin= g...\n", __FUNCTION__, __LINE__)); + + // + // Return the $Logo$ data + // 1. Get valid EEPROM library index + // 2. Find $Logo$ structure + // 3. Return $Logo$ data + // + EepromLibrary =3D GetValidEepromLibrary (TRUE); + if (EepromLibrary =3D=3D EEPROM_NULL) { + DEBUG ((DEBUG_ERROR, "%a(#%4d) - ERROR: Didn't find a valid EEPROM bin= ary!\n", __FUNCTION__, __LINE__)); + Status =3D EFI_NOT_FOUND; + } else { + Size =3D 0; + Status =3D GetEepromStructure (EepromLibrary, EEPROM_LOGO_DATA_SIGNATU= RE, (UINT8 **) &LogoStructure, &Size); + if (EFI_ERROR (Status) || (Size =3D=3D 0)) { + DEBUG ((DEBUG_ERROR, "%a(#%4d) - ERROR: Didn't find the $Logo$ struc= ture in the EERPOM binary!\n", __FUNCTION__, __LINE__)); + Status =3D EFI_NOT_FOUND; + } else { + *LogoSize =3D LogoStructure->length - sizeof (LOGO_DATA); + if (*LogoSize =3D=3D 0) { + *LogoData =3D EepromFreePool (LogoStructure); + DEBUG ((DEBUG_ERROR, "%a(#%4d) - ERROR: Didn't find the $Logo$ str= ucture data in the EERPOM binary!\n", __FUNCTION__, __LINE__)); + Status =3D EFI_NOT_FOUND; + } else { + *LogoData =3D (UINT8 *) LogoStructure + sizeof (LOGO_DATA); + if (mEepromPlatformLibDebugFlag) { + ZeroMem (AsciiData, 32); + CopyMem (AsciiData, LogoStructure->signature, 8); + DEBUG ((DEBUG_INFO, "%a(#%4d) - Signature =3D %a\n", _= _FUNCTION__, __LINE__, AsciiData)); + DEBUG ((DEBUG_INFO, "%a(#%4d) - Version =3D %04x:%04x\n", _= _FUNCTION__, __LINE__, LogoStructure->vermajor, LogoStructure->verminor)); + DEBUG ((DEBUG_INFO, "%a(#%4d) - Length =3D 0x%08x\n", _= _FUNCTION__, __LINE__, LogoStructure->length)); + } + Status =3D EFI_SUCCESS; + } + } + } + if (mEepromPlatformLibDebugFlag) DEBUG ((DEBUG_INFO, "%a(#%4d) - Returni= ng %r...\n", __FUNCTION__, __LINE__, Status)); + return Status; +} + +/** + Returns the $Video$ data + + @param[out] VideoData Buffer containing the $Video$ data + @param[out] VideoSize Size of the VideoData buffer + + @retval EFI_SUCCESS $Video$ data found + @retval EFI_NOT_FOUND $Video$ data not found + @retval EFI_NOT_READY $Video$ data not ready yet +**/ + +EFI_STATUS +EepromGetVbt ( + OUT UINT8 **VideoData, + OUT UINT32 *VideoSize + ) +{ + CHAR8 AsciiData[32]; + UINT8 EepromLibrary; + VIDEO_DATA *VideoStructure; + UINT32 Size; + EFI_STATUS Status; + + if (mEepromPlatformLibDebugFlag) DEBUG ((DEBUG_INFO, "%a(#%4d) - Startin= g...\n", __FUNCTION__, __LINE__)); + + // + // Return the $Video$ data + // 1. Get valid EEPROM library index + // 2. Find $Video$ structure + // 3. Return $Video$ data + // + EepromLibrary =3D GetValidEepromLibrary (TRUE); + if (EepromLibrary =3D=3D EEPROM_NULL) { + DEBUG ((DEBUG_ERROR, "%a(#%4d) - ERROR: Didn't find a valid EEPROM bin= ary!\n", __FUNCTION__, __LINE__)); + Status =3D EFI_NOT_FOUND; + } else { + Size =3D 0; + Status =3D GetEepromStructure (EepromLibrary, EEPROM_VIDEO_DATA_SIGNAT= URE, (UINT8 **) &VideoStructure, &Size); + if (EFI_ERROR (Status) || (Size =3D=3D 0)) { + DEBUG ((DEBUG_ERROR, "%a(#%4d) - ERROR: Didn't find the $Video$ stru= cture in the EERPOM binary!\n", __FUNCTION__, __LINE__)); + Status =3D EFI_NOT_FOUND; + } else { + *VideoSize =3D VideoStructure->length - sizeof (VIDEO_DATA); + if (*VideoSize =3D=3D 0) { + *VideoData =3D EepromFreePool (VideoStructure); + DEBUG ((DEBUG_ERROR, "%a(#%4d) - ERROR: Didn't find the $Video$ st= ructure data in the EERPOM binary!\n", __FUNCTION__, __LINE__)); + Status =3D EFI_NOT_FOUND; + } else { + *VideoData =3D (UINT8 *) VideoStructure + sizeof (VIDEO_DATA); + if (mEepromPlatformLibDebugFlag) { + ZeroMem (AsciiData, 32); + CopyMem (AsciiData, VideoStructure->signature, 8); + DEBUG ((DEBUG_INFO, "%a(#%4d) - Signature =3D %a\n", _= _FUNCTION__, __LINE__, AsciiData)); + DEBUG ((DEBUG_INFO, "%a(#%4d) - Version =3D %04x:%04x\n", _= _FUNCTION__, __LINE__, VideoStructure->vermajor, VideoStructure->verminor))= ; + DEBUG ((DEBUG_INFO, "%a(#%4d) - Length =3D 0x%08x\n", _= _FUNCTION__, __LINE__, VideoStructure->length)); + } + Status =3D EFI_SUCCESS; + } + } + } + if (mEepromPlatformLibDebugFlag) DEBUG ((DEBUG_INFO, "%a(#%4d) - Returni= ng %r...\n", __FUNCTION__, __LINE__, Status)); + return Status; +} + +/** + Checks whether the PadOffset is in the platform GPIO whitelist. + + @param[in] PadOffset The PAD offset to check against the platform wh= itelist + + @retval TRUE PAD offset is in the whitelist + @retval FALSE PAD offset is not in the whitelist +**/ +BOOLEAN +EepromPadCheck ( + IN UINT32 PadOffset + ) +{ + UINT32 AlignedPadOffset; + UINTN GpioCount; + UINT32 *GpioWhiteListPtr; + UINTN GpioWhiteListLength; + BOOLEAN ReturnValue; + + if (mEepromPlatformLibDebugFlag) DEBUG ((DEBUG_INFO, "%a(#%4d) - Startin= g...\n", __FUNCTION__, __LINE__)); + + // + // Initialize variables + // + GpioCount =3D 0; + GpioWhiteListPtr =3D (UINT32 *) PcdGetPtr (PcdGpioWhiteList); + GpioWhiteListLength =3D (UINTN) PcdGetSize (PcdGpioWhiteList) / sizeof (= UINT32); + ReturnValue =3D FALSE; + + // + // Force to PAD offset so the whitelist only needs to account for the DW= 0 value and not both DW0 and DW1 + // + AlignedPadOffset =3D PadOffset - (PadOffset % 0x08); + + // + // Sanity checks + // + if (GpioWhiteListPtr =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a() - ERROR: GpioWhiteListPtr =3D=3D NULL\n", _= _FUNCTION__)); + goto Exit; + } + if (GpioWhiteListLength =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "%a() - ERROR: GpioWhiteListLength =3D=3D 0\n", _= _FUNCTION__)); + goto Exit; + } + if (AlignedPadOffset =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "%a() - ERROR: AlignedPadOffset =3D=3D 0\n", __FU= NCTION__)); + goto Exit; + } + + // + // Verify PAD offset is in white list + // + while ((GpioWhiteListPtr[GpioCount] !=3D END_OF_GPIO_ARRAY) && (GpioCoun= t < GpioWhiteListLength)) { + if (GpioWhiteListPtr[GpioCount] =3D=3D AlignedPadOffset) { + ReturnValue =3D TRUE; + break; + } + GpioCount++; + } + + if (ReturnValue =3D=3D FALSE) { + DEBUG ((DEBUG_INFO, "%a() - WARNING: 0x%08x [0x%08x] was not found in = the whitelist.\n", __FUNCTION__, AlignedPadOffset, PadOffset)); + } + +Exit: + return ReturnValue; +} + +/** + Program GPIOs per binary and whitelist. The $GpioDat structure could be = used to program things other than + GPIOs, but that is all it is used for at this point. + + @param[in] VOID + + @retval EFI_SUCCESS GPIOs programmed successfully + @retval EFI_NOT_FOUND GPIO data not found + @retval EFI_NOT_READY GPIO data not ready yet +**/ +EFI_STATUS +EepromProgramGpioPads (VOID) +{ + CHAR8 AsciiData[32]; + GPIO_DATA_RECORD *EepromGpioData; + GPIO_DATA_HEADER *EepromGpioHeader; + UINT8 EepromLibrary; + UINT32 GpioPadData; + UINT32 OldGpioPadData; + UINT32 Size; + EFI_STATUS Status; + + if (mEepromPlatformLibDebugFlag) DEBUG ((DEBUG_INFO, "%a(#%4d) - Startin= g...\n", __FUNCTION__, __LINE__)); + + // + // Program any EEPROM defined GPIOs + // 1. Get valid EEPROM library index + // 2. Find GPIO data in EEPROM binary + // 3. Loop thru GPIO data and program PADs if PAD is in whitelist + // + EepromLibrary =3D GetValidEepromLibrary (TRUE); + if (EepromLibrary =3D=3D EEPROM_NULL) { + DEBUG ((DEBUG_ERROR, "%a(#%4d) - ERROR: Didn't find a valid EEPROM bin= ary!\n", __FUNCTION__, __LINE__)); + Status =3D EFI_NOT_FOUND; + } else { + Size =3D 0; + Status =3D GetEepromStructure (EepromLibrary, EEPROM_GPIO_SIGNATURE, (= UINT8 **) &EepromGpioHeader, &Size); + if (EFI_ERROR (Status) || (Size =3D=3D 0)) { + DEBUG ((DEBUG_ERROR, "%a(#%4d) - ERROR: Didn't find any GPIO data in= the EERPOM binary!\n", __FUNCTION__, __LINE__)); + Status =3D EFI_NOT_FOUND; + } else { + EepromGpioData =3D (GPIO_DATA_RECORD *) ((UINT8 *) EepromGpioHeader = + sizeof (GPIO_DATA_HEADER)); + if (mEepromPlatformLibDebugFlag) { + ZeroMem (AsciiData, 32); + CopyMem (AsciiData, EepromGpioHeader->signature, 8); + DEBUG ((DEBUG_INFO, "%a(#%4d) - Signature =3D %a\n", __F= UNCTION__, __LINE__, AsciiData)); + DEBUG ((DEBUG_INFO, "%a(#%4d) - Version =3D %04x:%04x\n", __F= UNCTION__, __LINE__, EepromGpioHeader->vermajor, EepromGpioHeader->verminor= )); + DEBUG ((DEBUG_INFO, "%a(#%4d) - Length =3D 0x%08x\n", __F= UNCTION__, __LINE__, EepromGpioHeader->length)); + } + // + // Loop thru GPIO records. We currently only allow 32-bit PAD offset= data records that are in the white-list. + // + while ((UINT8 *) EepromGpioData < ((UINT8 *) EepromGpioHeader + Size= )) { + OldGpioPadData =3D GpioPadRead (EepromGpioData->offset); + ZeroMem (AsciiData, 32); + CopyMem (AsciiData, EepromGpioData->gpiolabel, 16); + if (EepromPadCheck (EepromGpioData->offset) && + (EepromGpioData->datatype =3D=3D EEPROM_GPIO_TYPE_PAD_OFFSET) = && + (EepromGpioData->datasize =3D=3D sizeof (UINT32))) { + GpioPadData =3D OldGpioPadData; + GpioPadData &=3D EepromGpioData->anddata; + GpioPadData |=3D EepromGpioData->ordata; + GpioPadWrite (EepromGpioData->offset, GpioPadData); + } else { + DEBUG ((DEBUG_ERROR, "%a(#%4d) - ERROR: GPIO PAD offset not in t= he whitelist, wrong GPIO Type, or wrong data size!\n", __FUNCTION__, __LINE= __)); + } + if (OldGpioPadData !=3D GpioPadRead (EepromGpioData->offset)) { + DEBUG ((DEBUG_INFO, "%a(#%4d) - WARNING: PAD programming changin= g due to EEPROM binary!\n", __FUNCTION__, __LINE__)); + } + EepromGpioData++; + } + } + EepromFreePool (EepromGpioHeader); + Status =3D EFI_SUCCESS; + } + if (mEepromPlatformLibDebugFlag) DEBUG ((DEBUG_INFO, "%a(#%4d) - Returni= ng %r...\n", __FUNCTION__, __LINE__, Status)); + return Status; +} + diff --git a/Platform/BroxtonPlatformPkg/Common/Features/Eeprom/EepromPlatf= ormLib/EepromPlatformLib.h b/Platform/BroxtonPlatformPkg/Common/Features/Ee= prom/EepromPlatformLib/EepromPlatformLib.h new file mode 100644 index 0000000..d588fcf --- /dev/null +++ b/Platform/BroxtonPlatformPkg/Common/Features/Eeprom/EepromPlatformLib/= EepromPlatformLib.h @@ -0,0 +1,36 @@ +/** @file + Copyright (c) 2015 - 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 + which accompanies this distribution. The full text of the license may b= e found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. + +**/ + +#ifndef _EEPROM_PLATFORM_LIB_COMMON_ +#define _EEPROM_PLATFORM_LIB_COMMON_ +//// +//// Header files +//// +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +extern BOOLEAN mEepromPlatformLibDebugFlag; + +#endif // _EEPROM_PLATFORM_LIB_COMMON_ diff --git a/Platform/BroxtonPlatformPkg/Common/Features/Eeprom/EepromPlatf= ormLib/EepromPlatformLib.inf b/Platform/BroxtonPlatformPkg/Common/Features/= Eeprom/EepromPlatformLib/EepromPlatformLib.inf new file mode 100644 index 0000000..d7cf14d --- /dev/null +++ b/Platform/BroxtonPlatformPkg/Common/Features/Eeprom/EepromPlatformLib/= EepromPlatformLib.inf @@ -0,0 +1,59 @@ +## @file +# Library producing EEPROM structure data functionality. +# +# Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the B= SD License +# which accompanies this distribution. The full text of the license may b= e found at +# http://opensource.org/licenses/bsd-license.php. +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +# +## + +[Defines] + INF_VERSION =3D 0x00010017 + BASE_NAME =3D EepromPlatformLib + FILE_GUID =3D E19664F9-C024-45A8-BAD0-6493B92DF71F + VERSION_STRING =3D 1.0 + MODULE_TYPE =3D BASE + LIBRARY_CLASS =3D EepromPlatformLib + +[Depex] + TRUE + +[Guids] + gEepromVariableGuid + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + EepromDataLib + EepromLib + GpioLib + I2cLib + MemoryAllocationLib + PcdLib + UefiBootServicesTableLib + UefiRuntimeServicesTableLib + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + BroxtonPlatformPkg/PlatformPkg.dec + BroxtonSiPkg/BroxtonSiPkg.dec + +[Pcd] + gEfiBxtTokenSpaceGuid.PcdPmcGcrBaseAddress ## SOMETIMES_CONSUME= S + gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress ## SOMETIMES_CONSUME= S + gPlatformModuleTokenSpaceGuid.PcdEepromAddress + gPlatformModuleTokenSpaceGuid.PcdEepromBus + gPlatformModuleTokenSpaceGuid.PcdGpioWhiteList + +[Sources] + EepromAcpi.c + EepromPlatformLib.c + EepromPlatformLib.h diff --git a/Platform/BroxtonPlatformPkg/Common/Features/Eeprom/EepromPlatf= ormLib/EepromPlatformNullLib.c b/Platform/BroxtonPlatformPkg/Common/Feature= s/Eeprom/EepromPlatformLib/EepromPlatformNullLib.c new file mode 100644 index 0000000..55a7832 --- /dev/null +++ b/Platform/BroxtonPlatformPkg/Common/Features/Eeprom/EepromPlatformLib/= EepromPlatformNullLib.c @@ -0,0 +1,95 @@ +/** @file + Common EEPROM library instance. + + Copyright (c) 2015 - 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 + which accompanies this distribution. The full text of the license may b= e found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. + +**/ + +#include "EepromPlatformLib.h" + +BOOLEAN mEepromPlatformLibDebugFlag =3D FALSE; + +/** + Returns the $BrdInfo structure + + @param[out] BoardInfo Buffer containing the BOARD_INFO_TABLE stru= cture + - Up to the caller to free the buffer + + @retval EFI_SUCCESS $BrdInfo structure found + @retval EFI_NOT_FOUND $BrdInfo structure not found + @retval EFI_NOT_READY $BrdInfo structure not ready yet +**/ +EFI_STATUS +EepromGetBoardInfo ( + OUT BOARD_INFO_TABLE **BoardInfo + ) +{ + if (mEepromPlatformLibDebugFlag) DEBUG ((DEBUG_INFO, "%a(#%4d) - Startin= g...\n", __FUNCTION__, __LINE__)); + return EFI_NOT_READY; +} + +/** + Returns the $Logo$ data + + @param[out] LogoData Buffer containing the $Logo$ data + @param[out] LogoSize Size of the LogoData buffer + + @retval EFI_SUCCESS $Logo$ data found + @retval EFI_NOT_FOUND $Logo$ data not found + @retval EFI_NOT_READY $Logo$ data not ready yet +**/ +EFI_STATUS +EepromGetLogo ( + OUT UINT8 **LogoData, + OUT UINT32 *LogoSize + ) +{ + if (mEepromPlatformLibDebugFlag) DEBUG ((DEBUG_INFO, "%a(#%4d) - Startin= g...\n", __FUNCTION__, __LINE__)); + return EFI_NOT_READY; +} + +/** + Returns the $Video$ data + + @param[out] VideoData Buffer containing the $Video$ data + @param[out] VideoSize Size of the VideoData buffer + + @retval EFI_SUCCESS $Video$ data found + @retval EFI_NOT_FOUND $Video$ data not found + @retval EFI_NOT_READY $Video$ data not ready yet +**/ + +EFI_STATUS +EepromGetVbt ( + OUT UINT8 **VideoData, + OUT UINT32 *VideoSize + ) +{ + if (mEepromPlatformLibDebugFlag) DEBUG ((DEBUG_INFO, "%a(#%4d) - Startin= g...\n", __FUNCTION__, __LINE__)); + return EFI_NOT_READY; +} + +/** + Program GPIOs per binary and whitelist. The $GpioDat structure could be = used to program things other than + GPIOs, but that is all it is used for at this point. + + @param[in] VOID + + @retval EFI_SUCCESS GPIOs programmed successfully + @retval EFI_NOT_FOUND GPIO data not found + @retval EFI_NOT_READY GPIO data not ready yet +**/ +EFI_STATUS +EepromProgramGpioPads (VOID) +{ + if (mEepromPlatformLibDebugFlag) DEBUG ((DEBUG_INFO, "%a(#%4d) - Startin= g...\n", __FUNCTION__, __LINE__)); + return EFI_NOT_READY; +} diff --git a/Platform/BroxtonPlatformPkg/Common/Features/Eeprom/EepromPlatf= ormLib/EepromPlatformNullLib.inf b/Platform/BroxtonPlatformPkg/Common/Featu= res/Eeprom/EepromPlatformLib/EepromPlatformNullLib.inf new file mode 100644 index 0000000..ee0ea19 --- /dev/null +++ b/Platform/BroxtonPlatformPkg/Common/Features/Eeprom/EepromPlatformLib/= EepromPlatformNullLib.inf @@ -0,0 +1,57 @@ +## @file +# Library producing EEPROM structure data functionality. +# +# Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the B= SD License +# which accompanies this distribution. The full text of the license may b= e found at +# http://opensource.org/licenses/bsd-license.php. +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +# +## + +[Defines] + INF_VERSION =3D 0x00010017 + BASE_NAME =3D EepromPlatformNullLib + FILE_GUID =3D BDC7CD30-F263-4A1B-9E74-CA7B903F69F3 + VERSION_STRING =3D 1.0 + MODULE_TYPE =3D BASE + LIBRARY_CLASS =3D EepromPlatformNullLib + +[Depex] + TRUE + +[Guids] + gEepromVariableGuid + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + EepromDataLib + EepromLib + GpioLib + I2cLib + MemoryAllocationLib + PcdLib + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + BroxtonPlatformPkg/PlatformPkg.dec + BroxtonSiPkg/BroxtonSiPkg.dec + +[Pcd] + gEfiBxtTokenSpaceGuid.PcdPmcGcrBaseAddress ## SOMETIMES_CONSUME= S + gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress ## SOMETIMES_CONSUME= S + gPlatformModuleTokenSpaceGuid.PcdEepromAddress + gPlatformModuleTokenSpaceGuid.PcdEepromBus + gPlatformModuleTokenSpaceGuid.PcdGpioWhiteList + +[Sources] + EepromAcpiNull.c + EepromPlatformNullLib.c + EepromPlatformLib.h diff --git a/Platform/BroxtonPlatformPkg/Common/Features/Eeprom/EepromPlatf= ormLib/EepromPlatformPeiLib.inf b/Platform/BroxtonPlatformPkg/Common/Featur= es/Eeprom/EepromPlatformLib/EepromPlatformPeiLib.inf new file mode 100644 index 0000000..9901163 --- /dev/null +++ b/Platform/BroxtonPlatformPkg/Common/Features/Eeprom/EepromPlatformLib/= EepromPlatformPeiLib.inf @@ -0,0 +1,57 @@ +## @file +# Library producing EEPROM structure data functionality. +# +# Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the B= SD License +# which accompanies this distribution. The full text of the license may b= e found at +# http://opensource.org/licenses/bsd-license.php. +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +# +## + +[Defines] + INF_VERSION =3D 0x00010017 + BASE_NAME =3D EepromPlatformPeiLib + FILE_GUID =3D 6BC636D5-AD8F-46FD-9B9B-BD53A3D5E56B + VERSION_STRING =3D 1.0 + MODULE_TYPE =3D BASE + LIBRARY_CLASS =3D EepromPlatformPeiLib + +[Depex] + TRUE + +[Guids] + gEepromVariableGuid + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + EepromDataLib + EepromLib + GpioLib + I2cLib + MemoryAllocationLib + PcdLib + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + BroxtonPlatformPkg/PlatformPkg.dec + BroxtonSiPkg/BroxtonSiPkg.dec + +[Pcd] + gEfiBxtTokenSpaceGuid.PcdPmcGcrBaseAddress ## SOMETIMES_CONSUME= S + gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress ## SOMETIMES_CONSUME= S + gPlatformModuleTokenSpaceGuid.PcdEepromAddress + gPlatformModuleTokenSpaceGuid.PcdEepromBus + gPlatformModuleTokenSpaceGuid.PcdGpioWhiteList + +[Sources] + EepromAcpiPei.c + EepromPlatformLib.c + EepromPlatformLib.h --=20 2.10.1.windows.1