DxeLoadFunc.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /** @file
  2. LoongArch specifc functionality for DxeLoad.
  3. Copyright (c) 2022, Loongson Technology Corporation Limited. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #include "DxeIpl.h"
  7. /**
  8. Transfers control to DxeCore.
  9. This function performs a CPU architecture specific operations to execute
  10. the entry point of DxeCore with the parameters of HobList.
  11. It also installs EFI_END_OF_PEI_PPI to signal the end of PEI phase.
  12. @param[in] DxeCoreEntryPoint The entry point of DxeCore.
  13. @param[in] HobList The start of HobList passed to DxeCore.
  14. **/
  15. VOID
  16. HandOffToDxeCore (
  17. IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint,
  18. IN EFI_PEI_HOB_POINTERS HobList
  19. )
  20. {
  21. VOID *BaseOfStack;
  22. VOID *TopOfStack;
  23. EFI_STATUS Status;
  24. //
  25. // Allocate 128KB for the Stack
  26. //
  27. BaseOfStack = AllocatePages (EFI_SIZE_TO_PAGES (STACK_SIZE));
  28. ASSERT (BaseOfStack != NULL);
  29. //
  30. // Compute the top of the stack we were allocated. Pre-allocate a UINTN
  31. // for safety.
  32. //
  33. TopOfStack = (VOID *)((UINTN)BaseOfStack + EFI_SIZE_TO_PAGES (STACK_SIZE) * EFI_PAGE_SIZE - CPU_STACK_ALIGNMENT);
  34. TopOfStack = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);
  35. //
  36. // End of PEI phase signal
  37. //
  38. Status = PeiServicesInstallPpi (&gEndOfPeiSignalPpi);
  39. ASSERT_EFI_ERROR (Status);
  40. //
  41. // Update the contents of BSP stack HOB to reflect the real stack info passed to DxeCore.
  42. //
  43. UpdateStackHob ((EFI_PHYSICAL_ADDRESS)(UINTN)BaseOfStack, STACK_SIZE);
  44. SwitchStack (
  45. (SWITCH_STACK_ENTRY_POINT)(UINTN)DxeCoreEntryPoint,
  46. HobList.Raw,
  47. NULL,
  48. TopOfStack
  49. );
  50. }