From: Duke Zhai
BZ #:4640
Initial PlatformInitPei module. This is the Platform module to initialize
whole platform on PEI phase.
Signed-off-by: Ken Yao
Cc: Eric Xing
Cc: Duke Zhai
Cc: Igniculus Fu
Cc: Abner Chang
---
.../Universal/PlatformInitPei/BootMode.c | 287 ++
.../Universal/PlatformInitPei/CommonHeader.h | 244 +
.../PlatformInitPei/MemoryCallback.c | 308 ++
.../Universal/PlatformInitPei/MemoryInstall.c | 953 ++
.../Universal/PlatformInitPei/MemoryInstall.h | 229 +
.../Universal/PlatformInitPei/MemoryPeim.c| 385 +++
.../Universal/PlatformInitPei/PlatformInit.c | 176
.../PlatformInitPei/PlatformInit.inf | 114 +++
.../Universal/PlatformInitPei/Stall.c | 122 +++
9 files changed, 2818 insertions(+)
create mode 100644
Platform/AMD/VanGoghBoard/Universal/PlatformInitPei/BootMode.c
create mode 100644
Platform/AMD/VanGoghBoard/Universal/PlatformInitPei/CommonHeader.h
create mode 100644
Platform/AMD/VanGoghBoard/Universal/PlatformInitPei/MemoryCallback.c
create mode 100644
Platform/AMD/VanGoghBoard/Universal/PlatformInitPei/MemoryInstall.c
create mode 100644
Platform/AMD/VanGoghBoard/Universal/PlatformInitPei/MemoryInstall.h
create mode 100644
Platform/AMD/VanGoghBoard/Universal/PlatformInitPei/MemoryPeim.c
create mode 100644
Platform/AMD/VanGoghBoard/Universal/PlatformInitPei/PlatformInit.c
create mode 100644
Platform/AMD/VanGoghBoard/Universal/PlatformInitPei/PlatformInit.inf
create mode 100644 Platform/AMD/VanGoghBoard/Universal/PlatformInitPei/Stall.c
diff --git a/Platform/AMD/VanGoghBoard/Universal/PlatformInitPei/BootMode.c
b/Platform/AMD/VanGoghBoard/Universal/PlatformInitPei/BootMode.c
new file mode 100644
index 00..9102ae2b86
--- /dev/null
+++ b/Platform/AMD/VanGoghBoard/Universal/PlatformInitPei/BootMode.c
@@ -0,0 +1,287 @@
+/** @file
+ Implements BootMode.C
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+/* This file includes code originally published under the following license. */
+
+/** @file
+This file provide the function to detect boot mode
+
+Copyright (c) 2013 Intel Corporation.
+
+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 "CommonHeader.h"
+
+EFI_PEI_PPI_DESCRIPTOR mPpiListRecoveryBootMode = {
+ (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
+ ,
+ NULL
+};
+STATIC EFI_PEI_PPI_DESCRIPTOR CapsulePpi = {
+ EFI_PEI_PPI_DESCRIPTOR_PPI|EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
+ ,
+ NULL
+};
+
+/**
+
+Routine Description:
+
+ This function is used to verify if the FV header is validate.
+
+ @param FwVolHeader - The FV header that to be verified.
+
+ @retval EFI_SUCCESS - The Fv header is valid.
+ @retval EFI_NOT_FOUND - The Fv header is invalid.
+
+**/
+EFI_STATUS
+ValidateFvHeader (
+ EFI_BOOT_MODE *BootMode
+ )
+{
+ UINT16 *Ptr;
+ UINT16 HeaderLength;
+ UINT16 Checksum;
+
+ EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
+
+ if (BOOT_IN_RECOVERY_MODE == *BootMode) {
+DEBUG ((EFI_D_INFO, "Boot mode recovery\n"));
+return EFI_SUCCESS;
+ }
+
+ //
+ // Let's check whether FvMain header is valid, if not enter into recovery
mode
+ //
+ //
+ // Verify the header revision, header signature, length
+ // Length of FvBlock cannot be 2**64-1
+ // HeaderLength cannot be an odd number
+ //
+ FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)PcdGet32
(PcdFlashFvMainBase);
+ if ((FwVolHeader->Revision != EFI_FVH_REVISION) ||
+ (FwVolHeader->Signature != EFI_FVH_SIGNATURE) ||
+ (FwVolHeader->FvLength == ((UINT64)-1)) ||
+ ((FwVolHeader->HeaderLength & 0x01) != 0)
+ )
+ {
+return EFI_NOT_FOUND;
+ }
+
+ //
+ // Verify the header checksum
+ //
+ HeaderLength = (UINT16)(FwVolHeader->HeaderLength / 2);
+ Ptr = (UINT16 *)FwVolHeader;
+ Checksum = 0;
+ while (HeaderLength > 0) {
+Checksum = Checksum +*Ptr;
+Ptr++;
+HeaderLength--;
+ }
+
+ if (Checksum != 0) {
+return EFI_NOT_FOUND;
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Peform the boot mode determination logic
+
+ @param PeiServices General purpose services available to every PEIM.
+
+ @param BootMode The detected boot mode.
+
+ @retval EFI_SUCCESS if the boot mode could be set
+**/
+EFI_STATUS
+UpdateBootMode (
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ OUT EFI_BOOT_MODE