--- /dev/null
+/** @file\r
+ RISC-V specific functionality for DxeLoad.\r
+\r
+ Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>\r
+ Copyright (c) 2023, Rivos Inc\r
+\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+#include <PiPei.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/HobLib.h>\r
+#include "UefiPayloadEntry.h"\r
+\r
+#define STACK_SIZE 0x20000\r
+\r
+/**\r
+ Transfers control to DxeCore.\r
+\r
+ This function performs a CPU architecture specific operations to execute\r
+ the entry point of DxeCore with the parameters of HobList.\r
+ It also installs EFI_END_OF_PEI_PPI to signal the end of PEI phase.\r
+\r
+ @param DxeCoreEntryPoint The entry point of DxeCore.\r
+ @param HobList The start of HobList passed to DxeCore.\r
+\r
+**/\r
+VOID\r
+HandOffToDxeCore (\r
+ IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint,\r
+ IN EFI_PEI_HOB_POINTERS HobList\r
+ )\r
+{\r
+ VOID *BaseOfStack;\r
+ VOID *TopOfStack;\r
+\r
+ //\r
+ //\r
+ // Allocate 128KB for the Stack\r
+ //\r
+ BaseOfStack = AllocatePages (EFI_SIZE_TO_PAGES (STACK_SIZE));\r
+ if (BaseOfStack == NULL) {\r
+ DEBUG ((DEBUG_ERROR, "%a: Can't allocate memory for stack.", __func__));\r
+ ASSERT (FALSE);\r
+ }\r
+\r
+ //\r
+ // Compute the top of the stack we were allocated. Pre-allocate a UINTN\r
+ // for safety.\r
+ //\r
+ TopOfStack = (VOID *)((UINTN)BaseOfStack + EFI_SIZE_TO_PAGES (STACK_SIZE) * EFI_PAGE_SIZE - CPU_STACK_ALIGNMENT);\r
+ TopOfStack = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);\r
+\r
+ //\r
+ // Update the contents of BSP stack HOB to reflect the real stack info passed to DxeCore.\r
+ //\r
+ UpdateStackHob ((EFI_PHYSICAL_ADDRESS)(UINTN)BaseOfStack, STACK_SIZE);\r
+\r
+ DEBUG ((DEBUG_INFO, "DXE Core new stack at %x, stack pointer at %x\n", BaseOfStack, TopOfStack));\r
+\r
+ //\r
+ // Transfer the control to the entry point of DxeCore.\r
+ //\r
+ SwitchStack (\r
+ (SWITCH_STACK_ENTRY_POINT)(UINTN)DxeCoreEntryPoint,\r
+ HobList.Raw,\r
+ NULL,\r
+ TopOfStack\r
+ );\r
+}\r
--- /dev/null
+/** @file\r
+ x64-specifc functionality for DxeLoad.\r
+\r
+Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#include <PiPei.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/HobLib.h>\r
+#include <Library/FdtLib.h>\r
+#include <Library/PcdLib.h>\r
+#include "UefiPayloadEntry.h"\r
+\r
+/**\r
+ Entry point to the C language phase of UEFI payload.\r
+ @param[in] Param1, Hartid which is ignored\r
+ @param[in] Param2, Device Tree\r
+ @retval It will not return if SUCCESS, and return error when passing bootloader parameter.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+_ModuleEntryPoint (\r
+ IN UINTN Param1,\r
+ IN UINTN Param2\r
+ )\r
+{\r
+ return FitUplEntryPoint (Param2);\r
+}\r