* [Patch][edk2-platforms/devel-IntelAtomProcessorE3900 5Common EEPROM library instance
@ 2018-08-17 9:33 Guo, Mang
0 siblings, 0 replies; only message in thread
From: Guo, Mang @ 2018-08-17 9:33 UTC (permalink / raw)
To: edk2-devel@lists.01.org; +Cc: Wei, David
Cc: David Wei <david.wei@intel.com>
Cc: Mike Wu <mike.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Kelly Steele <kelly.steele@intel.com>
Signed-off-by: Guo Mang <mang.guo@intel.com>
---
.../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/EepromPlatformLib/EepromAcpi.c
create mode 100644 Platform/BroxtonPlatformPkg/Common/Features/Eeprom/EepromPlatformLib/EepromAcpiNull.c
create mode 100644 Platform/BroxtonPlatformPkg/Common/Features/Eeprom/EepromPlatformLib/EepromAcpiPei.c
create mode 100644 Platform/BroxtonPlatformPkg/Common/Features/Eeprom/EepromPlatformLib/EepromPlatformLib.c
create mode 100644 Platform/BroxtonPlatformPkg/Common/Features/Eeprom/EepromPlatformLib/EepromPlatformLib.h
create mode 100644 Platform/BroxtonPlatformPkg/Common/Features/Eeprom/EepromPlatformLib/EepromPlatformLib.inf
create mode 100644 Platform/BroxtonPlatformPkg/Common/Features/Eeprom/EepromPlatformLib/EepromPlatformNullLib.c
create mode 100644 Platform/BroxtonPlatformPkg/Common/Features/Eeprom/EepromPlatformLib/EepromPlatformNullLib.inf
create mode 100644 Platform/BroxtonPlatformPkg/Common/Features/Eeprom/EepromPlatformLib/EepromPlatformPeiLib.inf
diff --git a/Platform/BroxtonPlatformPkg/Common/Features/Eeprom/EepromPlatformLib/EepromAcpi.c b/Platform/BroxtonPlatformPkg/Common/Features/Eeprom/EepromPlatformLib/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.<BR>
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be 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 IMPLIED.
+
+**/
+
+#include "EepromPlatformLib.h"
+
+#include <Guid/AcpiTableStorage.h>
+#include <Guid/PlatformInfo.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Protocol/AcpiSupport.h>
+#include <Protocol/FirmwareVolume2.h>
+
+/*++
+
+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 protocol.
+
+--*/
+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 = 0;
+ //
+ // Locate protocol.
+ //
+ Status = 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 = 0; Index < NumberOfHandles; Index++) {
+ //
+ // Get the protocol on this handle
+ // This should not fail because of LocateHandleBuffer
+ //
+ Status = 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 handle buffer
+ // should always contain at least one or LocateHandleBuffer would have
+ // returned not found.
+ //
+ break;
+ }
+ //
+ // See if it has the ACPI storage file
+ //
+ Status = ((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 operations
+ // 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) - Starting...\n", __FUNCTION__, __LINE__));
+
+ //
+ // Find the AcpiSupport protocol
+ //
+ Status = LocateSupportProtocol (&gEfiAcpiSupportProtocolGuid, (VOID **) &AcpiSupport, 0);
+ if (EFI_ERROR (Status)) {
+ Status = 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 = GetValidEepromLibrary (TRUE);
+ if (EepromLibrary == EEPROM_NULL) {
+ DEBUG ((DEBUG_ERROR, "%a(#%4d) - ERROR: Didn't find a valid EEPROM binary!\n", __FUNCTION__, __LINE__));
+ Status = EFI_NOT_FOUND;
+ } else {
+ Size = 0;
+ Status = GetEepromStructure (EepromLibrary, EEPROM_ACPI_TABLE_SIGNATURE, (UINT8 **) &AcpiStructure, &Size);
+ if (EFI_ERROR (Status) || (Size == 0)) {
+ DEBUG ((DEBUG_ERROR, "%a(#%4d) - ERROR: Didn't find the $AcpiTbl structure in the EERPOM binary!\n", __FUNCTION__, __LINE__));
+ Status = EFI_NOT_FOUND;
+ } else {
+ AcpiSize = AcpiStructure->length - sizeof (ACPI_TABLE);
+ if (AcpiSize == 0) {
+ EepromFreePool (AcpiStructure);
+ DEBUG ((DEBUG_ERROR, "%a(#%4d) - ERROR: Didn't find the $AcpiTbl structure data in the EERPOM binary!\n", __FUNCTION__, __LINE__));
+ Status = EFI_NOT_FOUND;
+ } else {
+ AcpiData = (UINT8 *) AcpiStructure + sizeof (ACPI_TABLE);
+ //
+ // publish the AcpiTable
+ //
+ TableHandle = 0;
+ Status = AcpiSupport->SetAcpiTable (
+ AcpiSupport,
+ AcpiData,
+ TRUE,
+ EFI_ACPI_TABLE_VERSION_2_0,
+ &TableHandle
+ );
+ //
+ // re-init variables
+ //
+ AcpiStructure = EepromFreePool (AcpiStructure);
+ }
+ }
+ }
+Exit:
+ return Status;
+}
diff --git a/Platform/BroxtonPlatformPkg/Common/Features/Eeprom/EepromPlatformLib/EepromAcpiNull.c b/Platform/BroxtonPlatformPkg/Common/Features/Eeprom/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.<BR>
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be 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 IMPLIED.
+
+**/
+
+#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) - Starting...\n", __FUNCTION__, __LINE__));
+ return EFI_NOT_READY;
+}
diff --git a/Platform/BroxtonPlatformPkg/Common/Features/Eeprom/EepromPlatformLib/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.<BR>
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be 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 IMPLIED.
+
+**/
+
+#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) - Starting...\n", __FUNCTION__, __LINE__));
+ return EFI_NOT_READY;
+}
diff --git a/Platform/BroxtonPlatformPkg/Common/Features/Eeprom/EepromPlatformLib/EepromPlatformLib.c b/Platform/BroxtonPlatformPkg/Common/Features/Eeprom/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.<BR>
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be 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 IMPLIED.
+
+**/
+
+#include "EepromPlatformLib.h"
+
+BOOLEAN mEepromPlatformLibDebugFlag = TRUE;
+
+/**
+ Returns the $BrdInfo structure
+
+ @param[out] BoardInfo Buffer containing the BOARD_INFO_TABLE structure
+ - 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) - Starting...\n", __FUNCTION__, __LINE__));
+
+ //
+ // Return the $BrdInfo structure
+ // 1. Get valid EEPROM library index
+ // 2. Find $BrdInfo structure
+ //
+ EepromLibrary = GetValidEepromLibrary (TRUE);
+ if (EepromLibrary == EEPROM_NULL) {
+ DEBUG ((DEBUG_ERROR, "%a(#%4d) - ERROR: Didn't find a valid EEPROM binary!\n", __FUNCTION__, __LINE__));
+ Status = EFI_NOT_FOUND;
+ } else {
+ Size = 0;
+ Status = GetEepromStructure (EepromLibrary, EEPROM_BOARD_INFO_SIGNATURE, (UINT8 **) BoardInfo, &Size);
+ if (EFI_ERROR (Status) || (Size == 0)) {
+ DEBUG ((DEBUG_ERROR, "%a(#%4d) - ERROR: Didn't find the $BrdInfo structure in the EERPOM binary!\n", __FUNCTION__, __LINE__));
+ Status = EFI_NOT_FOUND;
+ } else {
+ if (mEepromPlatformLibDebugFlag) {
+ ZeroMem (AsciiData, 32);
+ CopyMem (AsciiData, (*BoardInfo)->signature, 8);
+ DEBUG ((DEBUG_INFO, "%a(#%4d) - Signature = %a\n", __FUNCTION__, __LINE__, AsciiData));
+ DEBUG ((DEBUG_INFO, "%a(#%4d) - Version = %04x:%04x\n", __FUNCTION__, __LINE__, (*BoardInfo)->vermajor, (*BoardInfo)->verminor));
+ DEBUG ((DEBUG_INFO, "%a(#%4d) - Length = 0x%08x\n", __FUNCTION__, __LINE__, (*BoardInfo)->length));
+ ZeroMem (AsciiData, 32);
+ CopyMem (AsciiData, (*BoardInfo)->manuname, 16);
+ DEBUG ((DEBUG_INFO, "%a(#%4d) - Manufacturer = %a\n", __FUNCTION__, __LINE__, AsciiData));
+ ZeroMem (AsciiData, 32);
+ CopyMem (AsciiData, (*BoardInfo)->brdname, 16);
+ DEBUG ((DEBUG_INFO, "%a(#%4d) - Board name = %a\n", __FUNCTION__, __LINE__, AsciiData));
+ ZeroMem (AsciiData, 32);
+ CopyMem (AsciiData, (*BoardInfo)->brdserial, 16);
+ DEBUG ((DEBUG_INFO, "%a(#%4d) - Serial # = %a\n", __FUNCTION__, __LINE__, AsciiData));
+ DEBUG ((DEBUG_INFO, "%a(#%4d) - Board ID = 0x%08x\n", __FUNCTION__, __LINE__, (*BoardInfo)->boardid));
+ DEBUG ((DEBUG_INFO, "%a(#%4d) - Fab ID = 0x%08x\n", __FUNCTION__, __LINE__, (*BoardInfo)->fabid));
+ DEBUG ((DEBUG_INFO, "%a(#%4d) - EC ID = 0x%08x\n", __FUNCTION__, __LINE__, (*BoardInfo)->ecid));
+ DEBUG ((DEBUG_INFO, "%a(#%4d) - Board type = %a\n", __FUNCTION__, __LINE__, (*BoardInfo)->boardtype ? "Main board (RedBox)" : "Plug-in board"));
+ }
+ Status = EFI_SUCCESS;
+ }
+ }
+ if (mEepromPlatformLibDebugFlag) DEBUG ((DEBUG_INFO, "%a(#%4d) - Returning %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) - Starting...\n", __FUNCTION__, __LINE__));
+
+ //
+ // Return the $Logo$ data
+ // 1. Get valid EEPROM library index
+ // 2. Find $Logo$ structure
+ // 3. Return $Logo$ data
+ //
+ EepromLibrary = GetValidEepromLibrary (TRUE);
+ if (EepromLibrary == EEPROM_NULL) {
+ DEBUG ((DEBUG_ERROR, "%a(#%4d) - ERROR: Didn't find a valid EEPROM binary!\n", __FUNCTION__, __LINE__));
+ Status = EFI_NOT_FOUND;
+ } else {
+ Size = 0;
+ Status = GetEepromStructure (EepromLibrary, EEPROM_LOGO_DATA_SIGNATURE, (UINT8 **) &LogoStructure, &Size);
+ if (EFI_ERROR (Status) || (Size == 0)) {
+ DEBUG ((DEBUG_ERROR, "%a(#%4d) - ERROR: Didn't find the $Logo$ structure in the EERPOM binary!\n", __FUNCTION__, __LINE__));
+ Status = EFI_NOT_FOUND;
+ } else {
+ *LogoSize = LogoStructure->length - sizeof (LOGO_DATA);
+ if (*LogoSize == 0) {
+ *LogoData = EepromFreePool (LogoStructure);
+ DEBUG ((DEBUG_ERROR, "%a(#%4d) - ERROR: Didn't find the $Logo$ structure data in the EERPOM binary!\n", __FUNCTION__, __LINE__));
+ Status = EFI_NOT_FOUND;
+ } else {
+ *LogoData = (UINT8 *) LogoStructure + sizeof (LOGO_DATA);
+ if (mEepromPlatformLibDebugFlag) {
+ ZeroMem (AsciiData, 32);
+ CopyMem (AsciiData, LogoStructure->signature, 8);
+ DEBUG ((DEBUG_INFO, "%a(#%4d) - Signature = %a\n", __FUNCTION__, __LINE__, AsciiData));
+ DEBUG ((DEBUG_INFO, "%a(#%4d) - Version = %04x:%04x\n", __FUNCTION__, __LINE__, LogoStructure->vermajor, LogoStructure->verminor));
+ DEBUG ((DEBUG_INFO, "%a(#%4d) - Length = 0x%08x\n", __FUNCTION__, __LINE__, LogoStructure->length));
+ }
+ Status = EFI_SUCCESS;
+ }
+ }
+ }
+ if (mEepromPlatformLibDebugFlag) DEBUG ((DEBUG_INFO, "%a(#%4d) - Returning %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) - Starting...\n", __FUNCTION__, __LINE__));
+
+ //
+ // Return the $Video$ data
+ // 1. Get valid EEPROM library index
+ // 2. Find $Video$ structure
+ // 3. Return $Video$ data
+ //
+ EepromLibrary = GetValidEepromLibrary (TRUE);
+ if (EepromLibrary == EEPROM_NULL) {
+ DEBUG ((DEBUG_ERROR, "%a(#%4d) - ERROR: Didn't find a valid EEPROM binary!\n", __FUNCTION__, __LINE__));
+ Status = EFI_NOT_FOUND;
+ } else {
+ Size = 0;
+ Status = GetEepromStructure (EepromLibrary, EEPROM_VIDEO_DATA_SIGNATURE, (UINT8 **) &VideoStructure, &Size);
+ if (EFI_ERROR (Status) || (Size == 0)) {
+ DEBUG ((DEBUG_ERROR, "%a(#%4d) - ERROR: Didn't find the $Video$ structure in the EERPOM binary!\n", __FUNCTION__, __LINE__));
+ Status = EFI_NOT_FOUND;
+ } else {
+ *VideoSize = VideoStructure->length - sizeof (VIDEO_DATA);
+ if (*VideoSize == 0) {
+ *VideoData = EepromFreePool (VideoStructure);
+ DEBUG ((DEBUG_ERROR, "%a(#%4d) - ERROR: Didn't find the $Video$ structure data in the EERPOM binary!\n", __FUNCTION__, __LINE__));
+ Status = EFI_NOT_FOUND;
+ } else {
+ *VideoData = (UINT8 *) VideoStructure + sizeof (VIDEO_DATA);
+ if (mEepromPlatformLibDebugFlag) {
+ ZeroMem (AsciiData, 32);
+ CopyMem (AsciiData, VideoStructure->signature, 8);
+ DEBUG ((DEBUG_INFO, "%a(#%4d) - Signature = %a\n", __FUNCTION__, __LINE__, AsciiData));
+ DEBUG ((DEBUG_INFO, "%a(#%4d) - Version = %04x:%04x\n", __FUNCTION__, __LINE__, VideoStructure->vermajor, VideoStructure->verminor));
+ DEBUG ((DEBUG_INFO, "%a(#%4d) - Length = 0x%08x\n", __FUNCTION__, __LINE__, VideoStructure->length));
+ }
+ Status = EFI_SUCCESS;
+ }
+ }
+ }
+ if (mEepromPlatformLibDebugFlag) DEBUG ((DEBUG_INFO, "%a(#%4d) - Returning %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 whitelist
+
+ @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) - Starting...\n", __FUNCTION__, __LINE__));
+
+ //
+ // Initialize variables
+ //
+ GpioCount = 0;
+ GpioWhiteListPtr = (UINT32 *) PcdGetPtr (PcdGpioWhiteList);
+ GpioWhiteListLength = (UINTN) PcdGetSize (PcdGpioWhiteList) / sizeof (UINT32);
+ ReturnValue = FALSE;
+
+ //
+ // Force to PAD offset so the whitelist only needs to account for the DW0 value and not both DW0 and DW1
+ //
+ AlignedPadOffset = PadOffset - (PadOffset % 0x08);
+
+ //
+ // Sanity checks
+ //
+ if (GpioWhiteListPtr == NULL) {
+ DEBUG ((DEBUG_ERROR, "%a() - ERROR: GpioWhiteListPtr == NULL\n", __FUNCTION__));
+ goto Exit;
+ }
+ if (GpioWhiteListLength == 0) {
+ DEBUG ((DEBUG_ERROR, "%a() - ERROR: GpioWhiteListLength == 0\n", __FUNCTION__));
+ goto Exit;
+ }
+ if (AlignedPadOffset == 0) {
+ DEBUG ((DEBUG_ERROR, "%a() - ERROR: AlignedPadOffset == 0\n", __FUNCTION__));
+ goto Exit;
+ }
+
+ //
+ // Verify PAD offset is in white list
+ //
+ while ((GpioWhiteListPtr[GpioCount] != END_OF_GPIO_ARRAY) && (GpioCount < GpioWhiteListLength)) {
+ if (GpioWhiteListPtr[GpioCount] == AlignedPadOffset) {
+ ReturnValue = TRUE;
+ break;
+ }
+ GpioCount++;
+ }
+
+ if (ReturnValue == 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) - Starting...\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 = GetValidEepromLibrary (TRUE);
+ if (EepromLibrary == EEPROM_NULL) {
+ DEBUG ((DEBUG_ERROR, "%a(#%4d) - ERROR: Didn't find a valid EEPROM binary!\n", __FUNCTION__, __LINE__));
+ Status = EFI_NOT_FOUND;
+ } else {
+ Size = 0;
+ Status = GetEepromStructure (EepromLibrary, EEPROM_GPIO_SIGNATURE, (UINT8 **) &EepromGpioHeader, &Size);
+ if (EFI_ERROR (Status) || (Size == 0)) {
+ DEBUG ((DEBUG_ERROR, "%a(#%4d) - ERROR: Didn't find any GPIO data in the EERPOM binary!\n", __FUNCTION__, __LINE__));
+ Status = EFI_NOT_FOUND;
+ } else {
+ EepromGpioData = (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 = %a\n", __FUNCTION__, __LINE__, AsciiData));
+ DEBUG ((DEBUG_INFO, "%a(#%4d) - Version = %04x:%04x\n", __FUNCTION__, __LINE__, EepromGpioHeader->vermajor, EepromGpioHeader->verminor));
+ DEBUG ((DEBUG_INFO, "%a(#%4d) - Length = 0x%08x\n", __FUNCTION__, __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 = GpioPadRead (EepromGpioData->offset);
+ ZeroMem (AsciiData, 32);
+ CopyMem (AsciiData, EepromGpioData->gpiolabel, 16);
+ if (EepromPadCheck (EepromGpioData->offset) &&
+ (EepromGpioData->datatype == EEPROM_GPIO_TYPE_PAD_OFFSET) &&
+ (EepromGpioData->datasize == sizeof (UINT32))) {
+ GpioPadData = OldGpioPadData;
+ GpioPadData &= EepromGpioData->anddata;
+ GpioPadData |= EepromGpioData->ordata;
+ GpioPadWrite (EepromGpioData->offset, GpioPadData);
+ } else {
+ DEBUG ((DEBUG_ERROR, "%a(#%4d) - ERROR: GPIO PAD offset not in the whitelist, wrong GPIO Type, or wrong data size!\n", __FUNCTION__, __LINE__));
+ }
+ if (OldGpioPadData != GpioPadRead (EepromGpioData->offset)) {
+ DEBUG ((DEBUG_INFO, "%a(#%4d) - WARNING: PAD programming changing due to EEPROM binary!\n", __FUNCTION__, __LINE__));
+ }
+ EepromGpioData++;
+ }
+ }
+ EepromFreePool (EepromGpioHeader);
+ Status = EFI_SUCCESS;
+ }
+ if (mEepromPlatformLibDebugFlag) DEBUG ((DEBUG_INFO, "%a(#%4d) - Returning %r...\n", __FUNCTION__, __LINE__, Status));
+ return Status;
+}
+
diff --git a/Platform/BroxtonPlatformPkg/Common/Features/Eeprom/EepromPlatformLib/EepromPlatformLib.h b/Platform/BroxtonPlatformPkg/Common/Features/Eeprom/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.<BR>
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be 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 IMPLIED.
+
+**/
+
+#ifndef _EEPROM_PLATFORM_LIB_COMMON_
+#define _EEPROM_PLATFORM_LIB_COMMON_
+////
+//// Header files
+////
+#include <Uefi.h>
+
+#include <Guid/EepromVariable.h>
+
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/EepromDataLib.h>
+#include <Library/EepromLib.h>
+#include <Library/EepromPlatformLib.h>
+#include <Library/GpioLib.h>
+#include <Library/MemoryAllocationLib.h>
+
+#include <EepromStruct.h>
+
+extern BOOLEAN mEepromPlatformLibDebugFlag;
+
+#endif // _EEPROM_PLATFORM_LIB_COMMON_
diff --git a/Platform/BroxtonPlatformPkg/Common/Features/Eeprom/EepromPlatformLib/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.<BR>
+#
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be 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 IMPLIED.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010017
+ BASE_NAME = EepromPlatformLib
+ FILE_GUID = E19664F9-C024-45A8-BAD0-6493B92DF71F
+ VERSION_STRING = 1.0
+ MODULE_TYPE = BASE
+ LIBRARY_CLASS = 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_CONSUMES
+ gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress ## SOMETIMES_CONSUMES
+ gPlatformModuleTokenSpaceGuid.PcdEepromAddress
+ gPlatformModuleTokenSpaceGuid.PcdEepromBus
+ gPlatformModuleTokenSpaceGuid.PcdGpioWhiteList
+
+[Sources]
+ EepromAcpi.c
+ EepromPlatformLib.c
+ EepromPlatformLib.h
diff --git a/Platform/BroxtonPlatformPkg/Common/Features/Eeprom/EepromPlatformLib/EepromPlatformNullLib.c b/Platform/BroxtonPlatformPkg/Common/Features/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.<BR>
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be 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 IMPLIED.
+
+**/
+
+#include "EepromPlatformLib.h"
+
+BOOLEAN mEepromPlatformLibDebugFlag = FALSE;
+
+/**
+ Returns the $BrdInfo structure
+
+ @param[out] BoardInfo Buffer containing the BOARD_INFO_TABLE structure
+ - 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) - Starting...\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) - Starting...\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) - Starting...\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) - Starting...\n", __FUNCTION__, __LINE__));
+ return EFI_NOT_READY;
+}
diff --git a/Platform/BroxtonPlatformPkg/Common/Features/Eeprom/EepromPlatformLib/EepromPlatformNullLib.inf b/Platform/BroxtonPlatformPkg/Common/Features/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.<BR>
+#
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be 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 IMPLIED.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010017
+ BASE_NAME = EepromPlatformNullLib
+ FILE_GUID = BDC7CD30-F263-4A1B-9E74-CA7B903F69F3
+ VERSION_STRING = 1.0
+ MODULE_TYPE = BASE
+ LIBRARY_CLASS = 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_CONSUMES
+ gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress ## SOMETIMES_CONSUMES
+ gPlatformModuleTokenSpaceGuid.PcdEepromAddress
+ gPlatformModuleTokenSpaceGuid.PcdEepromBus
+ gPlatformModuleTokenSpaceGuid.PcdGpioWhiteList
+
+[Sources]
+ EepromAcpiNull.c
+ EepromPlatformNullLib.c
+ EepromPlatformLib.h
diff --git a/Platform/BroxtonPlatformPkg/Common/Features/Eeprom/EepromPlatformLib/EepromPlatformPeiLib.inf b/Platform/BroxtonPlatformPkg/Common/Features/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.<BR>
+#
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be 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 IMPLIED.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010017
+ BASE_NAME = EepromPlatformPeiLib
+ FILE_GUID = 6BC636D5-AD8F-46FD-9B9B-BD53A3D5E56B
+ VERSION_STRING = 1.0
+ MODULE_TYPE = BASE
+ LIBRARY_CLASS = 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_CONSUMES
+ gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress ## SOMETIMES_CONSUMES
+ gPlatformModuleTokenSpaceGuid.PcdEepromAddress
+ gPlatformModuleTokenSpaceGuid.PcdEepromBus
+ gPlatformModuleTokenSpaceGuid.PcdGpioWhiteList
+
+[Sources]
+ EepromAcpiPei.c
+ EepromPlatformLib.c
+ EepromPlatformLib.h
--
2.10.1.windows.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2018-08-17 9:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-17 9:33 [Patch][edk2-platforms/devel-IntelAtomProcessorE3900 5Common EEPROM library instance Guo, Mang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox