]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Core/DxeIplPeim/Arm/DxeLoadFunc.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdeModulePkg / Core / DxeIplPeim / Arm / DxeLoadFunc.c
1 /** @file
2 ARM specifc functionality for DxeLoad.
3
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5 Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
6
7 SPDX-License-Identifier: BSD-2-Clause-Patent
8
9 **/
10
11 #include "DxeIpl.h"
12
13 #include <Library/ArmMmuLib.h>
14
15 /**
16 Transfers control to DxeCore.
17
18 This function performs a CPU architecture specific operations to execute
19 the entry point of DxeCore with the parameters of HobList.
20 It also installs EFI_END_OF_PEI_PPI to signal the end of PEI phase.
21
22 @param DxeCoreEntryPoint The entry point of DxeCore.
23 @param HobList The start of HobList passed to DxeCore.
24
25 **/
26 VOID
27 HandOffToDxeCore (
28 IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint,
29 IN EFI_PEI_HOB_POINTERS HobList
30 )
31 {
32 VOID *BaseOfStack;
33 VOID *TopOfStack;
34 EFI_STATUS Status;
35
36 //
37 // Allocate 128KB for the Stack
38 //
39 BaseOfStack = AllocatePages (EFI_SIZE_TO_PAGES (STACK_SIZE));
40 ASSERT (BaseOfStack != NULL);
41
42 if (PcdGetBool (PcdSetNxForStack)) {
43 Status = ArmSetMemoryRegionNoExec ((UINTN)BaseOfStack, STACK_SIZE);
44 ASSERT_EFI_ERROR (Status);
45 }
46
47 //
48 // Compute the top of the stack we were allocated. Pre-allocate a UINTN
49 // for safety.
50 //
51 TopOfStack = (VOID *)((UINTN)BaseOfStack + EFI_SIZE_TO_PAGES (STACK_SIZE) * EFI_PAGE_SIZE - CPU_STACK_ALIGNMENT);
52 TopOfStack = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);
53
54 //
55 // End of PEI phase singal
56 //
57 Status = PeiServicesInstallPpi (&gEndOfPeiSignalPpi);
58 ASSERT_EFI_ERROR (Status);
59
60 //
61 // Update the contents of BSP stack HOB to reflect the real stack info passed to DxeCore.
62 //
63 UpdateStackHob ((EFI_PHYSICAL_ADDRESS)(UINTN)BaseOfStack, STACK_SIZE);
64
65 SwitchStack (
66 (SWITCH_STACK_ENTRY_POINT)(UINTN)DxeCoreEntryPoint,
67 HobList.Raw,
68 NULL,
69 TopOfStack
70 );
71 }