]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Core/DxeIplPeim/RiscV64/DxeLoadFunc.c
MdeModulePkg: Apply uncrustify changes
[mirror_edk2.git] / MdeModulePkg / Core / DxeIplPeim / RiscV64 / DxeLoadFunc.c
1 /** @file
2 RISC-V specific functionality for DxeLoad.
3
4 Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
5
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10 #include "DxeIpl.h"
11
12 /**
13 Transfers control to DxeCore.
14
15 This function performs a CPU architecture specific operations to execute
16 the entry point of DxeCore with the parameters of HobList.
17 It also installs EFI_END_OF_PEI_PPI to signal the end of PEI phase.
18
19 @param DxeCoreEntryPoint The entry point of DxeCore.
20 @param HobList The start of HobList passed to DxeCore.
21
22 **/
23 VOID
24 HandOffToDxeCore (
25 IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint,
26 IN EFI_PEI_HOB_POINTERS HobList
27 )
28 {
29 VOID *BaseOfStack;
30 VOID *TopOfStack;
31 EFI_STATUS Status;
32
33 //
34 //
35 // Allocate 128KB for the Stack
36 //
37 BaseOfStack = AllocatePages (EFI_SIZE_TO_PAGES (STACK_SIZE));
38 if (BaseOfStack == NULL) {
39 DEBUG ((DEBUG_ERROR, "%a: Can't allocate memory for stack.", __FUNCTION__));
40 ASSERT (FALSE);
41 }
42
43 //
44 // Compute the top of the stack we were allocated. Pre-allocate a UINTN
45 // for safety.
46 //
47 TopOfStack = (VOID *)((UINTN)BaseOfStack + EFI_SIZE_TO_PAGES (STACK_SIZE) * EFI_PAGE_SIZE - CPU_STACK_ALIGNMENT);
48 TopOfStack = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);
49
50 //
51 // End of PEI phase signal
52 //
53 Status = PeiServicesInstallPpi (&gEndOfPeiSignalPpi);
54 if (EFI_ERROR (Status)) {
55 DEBUG ((DEBUG_ERROR, "%a: Fail to signal End of PEI event.", __FUNCTION__));
56 ASSERT (FALSE);
57 }
58
59 //
60 // Update the contents of BSP stack HOB to reflect the real stack info passed to DxeCore.
61 //
62 UpdateStackHob ((EFI_PHYSICAL_ADDRESS)(UINTN)BaseOfStack, STACK_SIZE);
63
64 DEBUG ((DEBUG_INFO, "DXE Core new stack at %x, stack pointer at %x\n", BaseOfStack, TopOfStack));
65
66 //
67 // Transfer the control to the entry point of DxeCore.
68 //
69 SwitchStack (
70 (SWITCH_STACK_ENTRY_POINT)(UINTN)DxeCoreEntryPoint,
71 HobList.Raw,
72 NULL,
73 TopOfStack
74 );
75 }