]>
Commit | Line | Data |
---|---|---|
96226baa | 1 | /** @file\r |
91d92e25 | 2 | x64-specifc functionality for DxeLoad.\r |
95276127 | 3 | \r |
5630cdfe | 4 | Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r |
cd5ebaa0 | 5 | This program and the accompanying materials\r |
95276127 | 6 | are licensed and made available under the terms and conditions of the BSD License\r |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
96226baa | 13 | **/\r |
95276127 | 14 | \r |
95276127 | 15 | #include "DxeIpl.h"\r |
f3b33289 | 16 | #include "X64/VirtualMemory.h"\r |
95276127 | 17 | \r |
91d92e25 | 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 | |
48557c65 | 25 | It also installs EFI_END_OF_PEI_PPI to signal the end of PEI phase.\r |
91d92e25 | 26 | \r |
48557c65 | 27 | @param DxeCoreEntryPoint The entry point of DxeCore.\r |
91d92e25 | 28 | @param HobList The start of HobList passed to DxeCore.\r |
91d92e25 | 29 | \r |
30 | **/\r | |
95276127 | 31 | VOID\r |
32 | HandOffToDxeCore (\r | |
33 | IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint,\r | |
9b937a73 | 34 | IN EFI_PEI_HOB_POINTERS HobList\r |
95276127 | 35 | )\r |
36 | {\r | |
57f360f2 JF |
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 | //\r | |
46 | // Get Vector Hand-off Info PPI and build Guided HOB\r | |
47 | //\r | |
48 | Status = PeiServicesLocatePpi (\r | |
49 | &gEfiVectorHandoffInfoPpiGuid,\r | |
50 | 0,\r | |
51 | NULL,\r | |
52 | (VOID **)&VectorHandoffInfoPpi\r | |
53 | );\r | |
54 | if (Status == EFI_SUCCESS) {\r | |
55 | DEBUG ((EFI_D_INFO, "Vector Hand-off Info PPI is gotten, GUIDed HOB is created!\n"));\r | |
56 | VectorInfo = VectorHandoffInfoPpi->Info;\r | |
57 | Index = 1;\r | |
58 | while (VectorInfo->Attribute != EFI_VECTOR_HANDOFF_LAST_ENTRY) {\r | |
59 | VectorInfo ++;\r | |
60 | Index ++;\r | |
61 | }\r | |
62 | BuildGuidDataHob (\r | |
63 | &gEfiVectorHandoffInfoPpiGuid,\r | |
64 | VectorHandoffInfoPpi->Info,\r | |
65 | sizeof (EFI_VECTOR_HANDOFF_INFO) * Index\r | |
66 | );\r | |
67 | }\r | |
95276127 | 68 | \r |
69 | //\r | |
70 | // Allocate 128KB for the Stack\r | |
71 | //\r | |
72 | BaseOfStack = AllocatePages (EFI_SIZE_TO_PAGES (STACK_SIZE));\r | |
73 | ASSERT (BaseOfStack != NULL);\r | |
74 | \r | |
75 | //\r | |
76 | // Compute the top of the stack we were allocated. Pre-allocate a UINTN\r | |
77 | // for safety.\r | |
78 | //\r | |
79 | TopOfStack = (VOID *) ((UINTN) BaseOfStack + EFI_SIZE_TO_PAGES (STACK_SIZE) * EFI_PAGE_SIZE - CPU_STACK_ALIGNMENT);\r | |
80 | TopOfStack = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);\r | |
81 | \r | |
d042796c | 82 | PageTables = 0;\r |
e47f0da4 | 83 | if (FeaturePcdGet (PcdDxeIplBuildPageTables)) {\r |
84 | //\r | |
85 | // Create page table and save PageMapLevel4 to CR3\r | |
86 | //\r | |
5630cdfe SZ |
87 | PageTables = CreateIdentityMappingPageTables ((EFI_PHYSICAL_ADDRESS) (UINTN) BaseOfStack, STACK_SIZE);\r |
88 | } else {\r | |
89 | //\r | |
90 | // Set NX for stack feature also require PcdDxeIplBuildPageTables be TRUE\r | |
91 | // for the DxeIpl and the DxeCore are both X64.\r | |
92 | //\r | |
93 | ASSERT (PcdGetBool (PcdSetNxForStack) == FALSE);\r | |
e47f0da4 | 94 | }\r |
95 | \r | |
95276127 | 96 | //\r |
48557c65 | 97 | // End of PEI phase signal\r |
95276127 | 98 | //\r |
9b937a73 | 99 | Status = PeiServicesInstallPpi (&gEndOfPeiSignalPpi);\r |
95276127 | 100 | ASSERT_EFI_ERROR (Status);\r |
101 | \r | |
e47f0da4 | 102 | if (FeaturePcdGet (PcdDxeIplBuildPageTables)) {\r |
103 | AsmWriteCr3 (PageTables);\r | |
104 | }\r | |
f3b33289 | 105 | \r |
30c8f861 | 106 | //\r |
107 | // Update the contents of BSP stack HOB to reflect the real stack info passed to DxeCore.\r | |
108 | // \r | |
189575e8 | 109 | UpdateStackHob ((EFI_PHYSICAL_ADDRESS)(UINTN) BaseOfStack, STACK_SIZE);\r |
30c8f861 | 110 | \r |
b98da1b1 | 111 | //\r |
112 | // Transfer the control to the entry point of DxeCore.\r | |
113 | //\r | |
95276127 | 114 | SwitchStack (\r |
115 | (SWITCH_STACK_ENTRY_POINT)(UINTN)DxeCoreEntryPoint,\r | |
116 | HobList.Raw,\r | |
117 | NULL,\r | |
118 | TopOfStack\r | |
119 | );\r | |
120 | }\r |