]>
Commit | Line | Data |
---|---|---|
1d5d0ae9 | 1 | /** @file\r |
2 | * Main file supporting the transition to PEI Core in Normal World for Versatile Express\r | |
3 | *\r | |
6d0ca257 | 4 | * Copyright (c) 2011-2014, ARM Limited. All rights reserved.\r |
1d5d0ae9 | 5 | *\r |
f4dfad05 | 6 | * SPDX-License-Identifier: BSD-2-Clause-Patent\r |
1d5d0ae9 | 7 | *\r |
8 | **/\r | |
9 | \r | |
1d5d0ae9 | 10 | #include <Library/BaseLib.h>\r |
6c9a3d42 | 11 | #include <Library/CacheMaintenanceLib.h>\r |
a6caee65 | 12 | #include <Library/DebugAgentLib.h>\r |
1d5d0ae9 | 13 | #include <Library/ArmLib.h>\r |
8fc38a3f | 14 | \r |
f598bf12 | 15 | #include "PrePeiCore.h"\r |
1d5d0ae9 | 16 | \r |
0c7cc4fb | 17 | CONST EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI mTemporaryRamSupportPpi = { PrePeiCoreTemporaryRamSupport };\r |
1d5d0ae9 | 18 | \r |
0c7cc4fb | 19 | CONST EFI_PEI_PPI_DESCRIPTOR gCommonPpiTable[] = {\r |
1d5d0ae9 | 20 | {\r |
8fc38a3f | 21 | EFI_PEI_PPI_DESCRIPTOR_PPI,\r |
1d5d0ae9 | 22 | &gEfiTemporaryRamSupportPpiGuid,\r |
0c7cc4fb | 23 | (VOID *) &mTemporaryRamSupportPpi\r |
1d5d0ae9 | 24 | }\r |
25 | };\r | |
26 | \r | |
77de7e53 | 27 | VOID\r |
28 | CreatePpiList (\r | |
29 | OUT UINTN *PpiListSize,\r | |
30 | OUT EFI_PEI_PPI_DESCRIPTOR **PpiList\r | |
31 | )\r | |
32 | {\r | |
33 | EFI_PEI_PPI_DESCRIPTOR *PlatformPpiList;\r | |
34 | UINTN PlatformPpiListSize;\r | |
35 | UINTN ListBase;\r | |
36 | EFI_PEI_PPI_DESCRIPTOR *LastPpi;\r | |
37 | \r | |
38 | // Get the Platform PPIs\r | |
39 | PlatformPpiListSize = 0;\r | |
40 | ArmPlatformGetPlatformPpiList (&PlatformPpiListSize, &PlatformPpiList);\r | |
41 | \r | |
16f3544d | 42 | // Copy the Common and Platform PPis in Temporary Memory\r |
bb5420bb | 43 | ListBase = PcdGet64 (PcdCPUCoresStackBase);\r |
77de7e53 | 44 | CopyMem ((VOID*)ListBase, gCommonPpiTable, sizeof(gCommonPpiTable));\r |
45 | CopyMem ((VOID*)(ListBase + sizeof(gCommonPpiTable)), PlatformPpiList, PlatformPpiListSize);\r | |
46 | \r | |
47 | // Set the Terminate flag on the last PPI entry\r | |
48 | LastPpi = (EFI_PEI_PPI_DESCRIPTOR*)ListBase + ((sizeof(gCommonPpiTable) + PlatformPpiListSize) / sizeof(EFI_PEI_PPI_DESCRIPTOR)) - 1;\r | |
49 | LastPpi->Flags |= EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;\r | |
50 | \r | |
51 | *PpiList = (EFI_PEI_PPI_DESCRIPTOR*)ListBase;\r | |
52 | *PpiListSize = sizeof(gCommonPpiTable) + PlatformPpiListSize;\r | |
53 | }\r | |
54 | \r | |
1d5d0ae9 | 55 | VOID\r |
56 | CEntryPoint (\r | |
0787bc61 | 57 | IN UINTN MpId,\r |
1d5d0ae9 | 58 | IN EFI_PEI_CORE_ENTRY_POINT PeiCoreEntryPoint\r |
59 | )\r | |
60 | {\r | |
6dafb303 OM |
61 | // Data Cache enabled on Primary core when MMU is enabled.\r |
62 | ArmDisableDataCache ();\r | |
6dafb303 | 63 | // Invalidate instruction cache\r |
a9d7090f | 64 | ArmInvalidateInstructionCache ();\r |
6dafb303 | 65 | // Enable Instruction Caches on all cores.\r |
f598bf12 | 66 | ArmEnableInstructionCache ();\r |
1d5d0ae9 | 67 | \r |
6c9a3d42 AB |
68 | InvalidateDataCacheRange ((VOID *)(UINTN)PcdGet64 (PcdCPUCoresStackBase),\r |
69 | PcdGet32 (PcdCPUCorePrimaryStackSize));\r | |
70 | \r | |
1d5d0ae9 | 71 | //\r |
72 | // Note: Doesn't have to Enable CPU interface in non-secure world,\r | |
73 | // as Non-secure interface is already enabled in Secure world.\r | |
74 | //\r | |
75 | \r | |
a9d7090f | 76 | // Write VBAR - The Exception Vector table must be aligned to its requirement\r |
6d0ca257 OM |
77 | // Note: The AArch64 Vector table must be 2k-byte aligned - if this assertion fails ensure\r |
78 | // 'Align=4K' is defined into your FDF for this module.\r | |
79 | ASSERT (((UINTN)PeiVectorTable & ARM_VECTOR_TABLE_ALIGNMENT) == 0);\r | |
a9d7090f | 80 | ArmWriteVBar ((UINTN)PeiVectorTable);\r |
1d5d0ae9 | 81 | \r |
a6a835bd AB |
82 | // Enable Floating Point\r |
83 | if (FixedPcdGet32 (PcdVFPEnabled)) {\r | |
84 | ArmEnableVFP ();\r | |
85 | }\r | |
86 | \r | |
1d5d0ae9 | 87 | //Note: The MMU will be enabled by MemoryPeim. Only the primary core will have the MMU on.\r |
88 | \r | |
77de7e53 | 89 | // If not primary Jump to Secondary Main\r |
bebda7ce | 90 | if (ArmPlatformIsPrimaryCore (MpId)) {\r |
a6caee65 | 91 | // Initialize the Debug Agent for Source Level Debugging\r |
92 | InitializeDebugAgent (DEBUG_AGENT_INIT_POSTMEM_SEC, NULL, NULL);\r | |
93 | SaveAndSetDebugTimerInterrupt (TRUE);\r | |
94 | \r | |
f437141a | 95 | // Initialize the platform specific controllers\r |
96 | ArmPlatformInitialize (MpId);\r | |
97 | \r | |
a6caee65 | 98 | // Goto primary Main.\r |
f598bf12 | 99 | PrimaryMain (PeiCoreEntryPoint);\r |
1d5d0ae9 | 100 | } else {\r |
0787bc61 | 101 | SecondaryMain (MpId);\r |
1d5d0ae9 | 102 | }\r |
103 | \r | |
104 | // PEI Core should always load and never return\r | |
105 | ASSERT (FALSE);\r | |
106 | }\r | |
107 | \r | |
108 | EFI_STATUS\r | |
109 | EFIAPI\r | |
93d451c6 | 110 | PrePeiCoreTemporaryRamSupport (\r |
1d5d0ae9 | 111 | IN CONST EFI_PEI_SERVICES **PeiServices,\r |
112 | IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase,\r | |
113 | IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase,\r | |
114 | IN UINTN CopySize\r | |
115 | )\r | |
116 | {\r | |
93d451c6 | 117 | VOID *OldHeap;\r |
118 | VOID *NewHeap;\r | |
119 | VOID *OldStack;\r | |
120 | VOID *NewStack;\r | |
4960d8e0 HG |
121 | UINTN HeapSize;\r |
122 | \r | |
123 | HeapSize = ALIGN_VALUE (CopySize / 2, CPU_STACK_ALIGNMENT);\r | |
93d451c6 | 124 | \r |
125 | OldHeap = (VOID*)(UINTN)TemporaryMemoryBase;\r | |
4960d8e0 | 126 | NewHeap = (VOID*)((UINTN)PermanentMemoryBase + (CopySize - HeapSize));\r |
93d451c6 | 127 | \r |
4960d8e0 | 128 | OldStack = (VOID*)((UINTN)TemporaryMemoryBase + HeapSize);\r |
93d451c6 | 129 | NewStack = (VOID*)(UINTN)PermanentMemoryBase;\r |
130 | \r | |
131 | //\r | |
132 | // Migrate the temporary memory stack to permanent memory stack.\r | |
1d5d0ae9 | 133 | //\r |
4960d8e0 | 134 | CopyMem (NewStack, OldStack, CopySize - HeapSize);\r |
93d451c6 | 135 | \r |
136 | //\r | |
137 | // Migrate the temporary memory heap to permanent memory heap.\r | |
f598bf12 | 138 | //\r |
4960d8e0 | 139 | CopyMem (NewHeap, OldHeap, HeapSize);\r |
3402aac7 | 140 | \r |
93d451c6 | 141 | SecSwitchStack ((UINTN)NewStack - (UINTN)OldStack);\r |
1d5d0ae9 | 142 | \r |
93d451c6 | 143 | return EFI_SUCCESS;\r |
144 | }\r |