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