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