]> xenbits.xensource.com Git - people/aperard/ovmf.git/commitdiff
UefiPayloadPkg: Enable RiscV64 entry point to UPL
authorDhaval <dhaval@rivosinc.com>
Mon, 12 Aug 2024 12:38:46 +0000 (18:08 +0530)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sat, 14 Sep 2024 03:38:47 +0000 (03:38 +0000)
As per specification we are going to accept only one argument
at the entry point which is FDT pointer. Grab that and call
the entry point.

Signed-off-by: Dhaval Sharma <dhaval@rivosinc.com>
UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.inf
UefiPayloadPkg/UefiPayloadEntry/RiscV64/DxeLoadFunc.c [new file with mode: 0644]
UefiPayloadPkg/UefiPayloadEntry/RiscV64/DxeLoadFuncFit.c [new file with mode: 0644]

index 1838b4f33d27f10b295d4cb2b27cbdc487f5a987..5887830e3f3902fd59c7c073a7b01493f07e5b98 100644 (file)
   X64/VirtualMemory.c\r
   X64/DxeLoadFuncFit.c\r
 \r
+[Sources.RISCV64]\r
+  RiscV64/DxeLoadFunc.c\r
+  RiscV64/DxeLoadFuncFit.c\r
+\r
 [Packages]\r
   MdePkg/MdePkg.dec\r
   MdeModulePkg/MdeModulePkg.dec\r
diff --git a/UefiPayloadPkg/UefiPayloadEntry/RiscV64/DxeLoadFunc.c b/UefiPayloadPkg/UefiPayloadEntry/RiscV64/DxeLoadFunc.c
new file mode 100644 (file)
index 0000000..ecd2493
--- /dev/null
@@ -0,0 +1,74 @@
+/** @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
diff --git a/UefiPayloadPkg/UefiPayloadEntry/RiscV64/DxeLoadFuncFit.c b/UefiPayloadPkg/UefiPayloadEntry/RiscV64/DxeLoadFuncFit.c
new file mode 100644 (file)
index 0000000..e74c4fa
--- /dev/null
@@ -0,0 +1,34 @@
+/** @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