]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Core/DxeIplPeim/X64/DxeLoadFunc.c
IntelSiliconPkg: Clean up source files
[mirror_edk2.git] / MdeModulePkg / Core / DxeIplPeim / X64 / DxeLoadFunc.c
... / ...
CommitLineData
1/** @file\r
2 x64-specifc functionality for DxeLoad.\r
3\r
4Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
5This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include "DxeIpl.h"\r
16#include "X64/VirtualMemory.h"\r
17\r
18\r
19\r
20/**\r
21 Transfers control to DxeCore.\r
22\r
23 This function performs a CPU architecture specific operations to execute\r
24 the entry point of DxeCore with the parameters of HobList.\r
25 It also installs EFI_END_OF_PEI_PPI to signal the end of PEI phase.\r
26\r
27 @param DxeCoreEntryPoint The entry point of DxeCore.\r
28 @param HobList The start of HobList passed to DxeCore.\r
29\r
30**/\r
31VOID\r
32HandOffToDxeCore (\r
33 IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint,\r
34 IN EFI_PEI_HOB_POINTERS HobList\r
35 )\r
36{\r
37 VOID *BaseOfStack;\r
38 VOID *TopOfStack;\r
39 EFI_STATUS Status;\r
40 UINTN PageTables;\r
41 UINT32 Index;\r
42 EFI_VECTOR_HANDOFF_INFO *VectorInfo;\r
43 EFI_PEI_VECTOR_HANDOFF_INFO_PPI *VectorHandoffInfoPpi;\r
44\r
45 if (IsNullDetectionEnabled ()) {\r
46 ClearFirst4KPage (HobList.Raw);\r
47 }\r
48\r
49 //\r
50 // Get Vector Hand-off Info PPI and build Guided HOB\r
51 //\r
52 Status = PeiServicesLocatePpi (\r
53 &gEfiVectorHandoffInfoPpiGuid,\r
54 0,\r
55 NULL,\r
56 (VOID **)&VectorHandoffInfoPpi\r
57 );\r
58 if (Status == EFI_SUCCESS) {\r
59 DEBUG ((EFI_D_INFO, "Vector Hand-off Info PPI is gotten, GUIDed HOB is created!\n"));\r
60 VectorInfo = VectorHandoffInfoPpi->Info;\r
61 Index = 1;\r
62 while (VectorInfo->Attribute != EFI_VECTOR_HANDOFF_LAST_ENTRY) {\r
63 VectorInfo ++;\r
64 Index ++;\r
65 }\r
66 BuildGuidDataHob (\r
67 &gEfiVectorHandoffInfoPpiGuid,\r
68 VectorHandoffInfoPpi->Info,\r
69 sizeof (EFI_VECTOR_HANDOFF_INFO) * Index\r
70 );\r
71 }\r
72\r
73 //\r
74 // Allocate 128KB for the Stack\r
75 //\r
76 BaseOfStack = AllocatePages (EFI_SIZE_TO_PAGES (STACK_SIZE));\r
77 ASSERT (BaseOfStack != NULL);\r
78\r
79 //\r
80 // Compute the top of the stack we were allocated. Pre-allocate a UINTN\r
81 // for safety.\r
82 //\r
83 TopOfStack = (VOID *) ((UINTN) BaseOfStack + EFI_SIZE_TO_PAGES (STACK_SIZE) * EFI_PAGE_SIZE - CPU_STACK_ALIGNMENT);\r
84 TopOfStack = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);\r
85\r
86 PageTables = 0;\r
87 if (FeaturePcdGet (PcdDxeIplBuildPageTables)) {\r
88 //\r
89 // Create page table and save PageMapLevel4 to CR3\r
90 //\r
91 PageTables = CreateIdentityMappingPageTables ((EFI_PHYSICAL_ADDRESS) (UINTN) BaseOfStack, STACK_SIZE);\r
92 } else {\r
93 //\r
94 // Set NX for stack feature also require PcdDxeIplBuildPageTables be TRUE\r
95 // for the DxeIpl and the DxeCore are both X64.\r
96 //\r
97 ASSERT (PcdGetBool (PcdSetNxForStack) == FALSE);\r
98 ASSERT (PcdGetBool (PcdCpuStackGuard) == FALSE);\r
99 }\r
100 \r
101 //\r
102 // End of PEI phase signal\r
103 //\r
104 Status = PeiServicesInstallPpi (&gEndOfPeiSignalPpi);\r
105 ASSERT_EFI_ERROR (Status);\r
106\r
107 if (FeaturePcdGet (PcdDxeIplBuildPageTables)) {\r
108 AsmWriteCr3 (PageTables);\r
109 }\r
110\r
111 //\r
112 // Update the contents of BSP stack HOB to reflect the real stack info passed to DxeCore.\r
113 // \r
114 UpdateStackHob ((EFI_PHYSICAL_ADDRESS)(UINTN) BaseOfStack, STACK_SIZE);\r
115\r
116 //\r
117 // Transfer the control to the entry point of DxeCore.\r
118 //\r
119 SwitchStack (\r
120 (SWITCH_STACK_ENTRY_POINT)(UINTN)DxeCoreEntryPoint,\r
121 HobList.Raw,\r
122 NULL,\r
123 TopOfStack\r
124 );\r
125}\r