]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | * Main file supporting the transition to PEI Core in Normal World for Versatile Express\r | |
3 | *\r | |
4 | * Copyright (c) 2011-2012, ARM Limited. All rights reserved.\r | |
5 | * \r | |
6 | * This program and the accompanying materials \r | |
7 | * are licensed and made available under the terms and conditions of the BSD License \r | |
8 | * which accompanies this distribution. The full text of the license may be found at \r | |
9 | * http://opensource.org/licenses/bsd-license.php \r | |
10 | *\r | |
11 | * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
12 | * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
13 | *\r | |
14 | **/\r | |
15 | \r | |
16 | #include <Library/BaseLib.h>\r | |
17 | #include <Library/DebugAgentLib.h>\r | |
18 | #include <Library/ArmLib.h>\r | |
19 | \r | |
20 | #include <Ppi/ArmGlobalVariable.h>\r | |
21 | \r | |
22 | #include "PrePeiCore.h"\r | |
23 | \r | |
24 | EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI mTemporaryRamSupportPpi = { PrePeiCoreTemporaryRamSupport };\r | |
25 | ARM_GLOBAL_VARIABLE_PPI mGlobalVariablePpi = { PrePeiCoreGetGlobalVariableMemory };\r | |
26 | \r | |
27 | EFI_PEI_PPI_DESCRIPTOR gCommonPpiTable[] = {\r | |
28 | {\r | |
29 | EFI_PEI_PPI_DESCRIPTOR_PPI,\r | |
30 | &gEfiTemporaryRamSupportPpiGuid,\r | |
31 | &mTemporaryRamSupportPpi\r | |
32 | },\r | |
33 | {\r | |
34 | EFI_PEI_PPI_DESCRIPTOR_PPI,\r | |
35 | &gArmGlobalVariablePpiGuid,\r | |
36 | &mGlobalVariablePpi\r | |
37 | }\r | |
38 | };\r | |
39 | \r | |
40 | VOID\r | |
41 | CreatePpiList (\r | |
42 | OUT UINTN *PpiListSize,\r | |
43 | OUT EFI_PEI_PPI_DESCRIPTOR **PpiList\r | |
44 | )\r | |
45 | {\r | |
46 | EFI_PEI_PPI_DESCRIPTOR *PlatformPpiList;\r | |
47 | UINTN PlatformPpiListSize;\r | |
48 | UINTN ListBase;\r | |
49 | EFI_PEI_PPI_DESCRIPTOR *LastPpi;\r | |
50 | \r | |
51 | // Get the Platform PPIs\r | |
52 | PlatformPpiListSize = 0;\r | |
53 | ArmPlatformGetPlatformPpiList (&PlatformPpiListSize, &PlatformPpiList);\r | |
54 | \r | |
55 | // Copy the Common and Platform PPis in Temporrary Memory\r | |
56 | ListBase = PcdGet32 (PcdCPUCoresStackBase);\r | |
57 | CopyMem ((VOID*)ListBase, gCommonPpiTable, sizeof(gCommonPpiTable));\r | |
58 | CopyMem ((VOID*)(ListBase + sizeof(gCommonPpiTable)), PlatformPpiList, PlatformPpiListSize);\r | |
59 | \r | |
60 | // Set the Terminate flag on the last PPI entry\r | |
61 | LastPpi = (EFI_PEI_PPI_DESCRIPTOR*)ListBase + ((sizeof(gCommonPpiTable) + PlatformPpiListSize) / sizeof(EFI_PEI_PPI_DESCRIPTOR)) - 1;\r | |
62 | LastPpi->Flags |= EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;\r | |
63 | \r | |
64 | *PpiList = (EFI_PEI_PPI_DESCRIPTOR*)ListBase;\r | |
65 | *PpiListSize = sizeof(gCommonPpiTable) + PlatformPpiListSize;\r | |
66 | }\r | |
67 | \r | |
68 | VOID\r | |
69 | CEntryPoint (\r | |
70 | IN UINTN MpId,\r | |
71 | IN EFI_PEI_CORE_ENTRY_POINT PeiCoreEntryPoint\r | |
72 | )\r | |
73 | {\r | |
74 | //Clean Data cache\r | |
75 | ArmCleanInvalidateDataCache ();\r | |
76 | \r | |
77 | //Invalidate instruction cache\r | |
78 | ArmInvalidateInstructionCache ();\r | |
79 | \r | |
80 | // Enable Instruction & Data caches\r | |
81 | ArmEnableDataCache ();\r | |
82 | ArmEnableInstructionCache ();\r | |
83 | \r | |
84 | //\r | |
85 | // Note: Doesn't have to Enable CPU interface in non-secure world,\r | |
86 | // as Non-secure interface is already enabled in Secure world.\r | |
87 | //\r | |
88 | \r | |
89 | // Write VBAR - The Exception Vector table must be aligned to its requirement\r | |
90 | ASSERT (((UINTN)PeiVectorTable & ARM_VECTOR_TABLE_ALIGNMENT) == 0);\r | |
91 | ArmWriteVBar ((UINTN)PeiVectorTable);\r | |
92 | \r | |
93 | //Note: The MMU will be enabled by MemoryPeim. Only the primary core will have the MMU on.\r | |
94 | \r | |
95 | // If not primary Jump to Secondary Main\r | |
96 | if (IS_PRIMARY_CORE(MpId)) {\r | |
97 | // Initialize the Debug Agent for Source Level Debugging\r | |
98 | InitializeDebugAgent (DEBUG_AGENT_INIT_POSTMEM_SEC, NULL, NULL);\r | |
99 | SaveAndSetDebugTimerInterrupt (TRUE);\r | |
100 | \r | |
101 | // Initialize the platform specific controllers\r | |
102 | ArmPlatformInitialize (MpId);\r | |
103 | \r | |
104 | // Goto primary Main.\r | |
105 | PrimaryMain (PeiCoreEntryPoint);\r | |
106 | } else {\r | |
107 | SecondaryMain (MpId);\r | |
108 | }\r | |
109 | \r | |
110 | // PEI Core should always load and never return\r | |
111 | ASSERT (FALSE);\r | |
112 | }\r | |
113 | \r | |
114 | EFI_STATUS\r | |
115 | EFIAPI\r | |
116 | PrePeiCoreTemporaryRamSupport (\r | |
117 | IN CONST EFI_PEI_SERVICES **PeiServices,\r | |
118 | IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase,\r | |
119 | IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase,\r | |
120 | IN UINTN CopySize\r | |
121 | )\r | |
122 | {\r | |
123 | VOID *OldHeap;\r | |
124 | VOID *NewHeap;\r | |
125 | VOID *OldStack;\r | |
126 | VOID *NewStack;\r | |
127 | \r | |
128 | OldHeap = (VOID*)(UINTN)TemporaryMemoryBase;\r | |
129 | NewHeap = (VOID*)((UINTN)PermanentMemoryBase + (CopySize >> 1));\r | |
130 | \r | |
131 | OldStack = (VOID*)((UINTN)TemporaryMemoryBase + (CopySize >> 1));\r | |
132 | NewStack = (VOID*)(UINTN)PermanentMemoryBase;\r | |
133 | \r | |
134 | //\r | |
135 | // Migrate the temporary memory stack to permanent memory stack.\r | |
136 | //\r | |
137 | CopyMem (NewStack, OldStack, CopySize >> 1);\r | |
138 | \r | |
139 | //\r | |
140 | // Migrate the temporary memory heap to permanent memory heap.\r | |
141 | //\r | |
142 | CopyMem (NewHeap, OldHeap, CopySize >> 1);\r | |
143 | \r | |
144 | SecSwitchStack ((UINTN)NewStack - (UINTN)OldStack);\r | |
145 | \r | |
146 | return EFI_SUCCESS;\r | |
147 | }\r | |
148 | \r | |
149 | EFI_STATUS\r | |
150 | PrePeiCoreGetGlobalVariableMemory (\r | |
151 | OUT EFI_PHYSICAL_ADDRESS *GlobalVariableBase\r | |
152 | )\r | |
153 | {\r | |
154 | ASSERT (GlobalVariableBase != NULL);\r | |
155 | \r | |
156 | *GlobalVariableBase = (UINTN)PcdGet32 (PcdCPUCoresStackBase) +\r | |
157 | (UINTN)PcdGet32 (PcdCPUCorePrimaryStackSize) -\r | |
158 | (UINTN)PcdGet32 (PcdPeiGlobalVariableSize);\r | |
159 | \r | |
160 | return EFI_SUCCESS;\r | |
161 | }\r | |
162 | \r |