]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPlatformPkg/PrePeiCore/PrePeiCore.c
ArmPlatformPkg: Code cleaning
[mirror_edk2.git] / ArmPlatformPkg / PrePeiCore / PrePeiCore.c
CommitLineData
1d5d0ae9 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, 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
1d5d0ae9 16#include <Library/DebugLib.h>\r
17#include <Library/PcdLib.h>\r
18#include <Library/IoLib.h>\r
19#include <Library/BaseLib.h>\r
20#include <Library/BaseMemoryLib.h>\r
f598bf12 21#include <Library/PrintLib.h>\r
1d5d0ae9 22#include <Library/ArmLib.h>\r
f598bf12 23#include <Library/SerialPortLib.h>\r
1d5d0ae9 24#include <Chipset/ArmV7.h>\r
25\r
f598bf12 26#include "PrePeiCore.h"\r
1d5d0ae9 27\r
80ddb68d 28EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI mSecTemporaryRamSupportPpi = {SecTemporaryRamSupport};\r
1d5d0ae9 29\r
30EFI_PEI_PPI_DESCRIPTOR gSecPpiTable[] = {\r
31 {\r
32 EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,\r
33 &gEfiTemporaryRamSupportPpiGuid,\r
34 &mSecTemporaryRamSupportPpi\r
35 }\r
36};\r
37\r
1d5d0ae9 38VOID\r
39CEntryPoint (\r
40 IN UINTN CoreId,\r
41 IN EFI_PEI_CORE_ENTRY_POINT PeiCoreEntryPoint\r
42 )\r
43{\r
44 //Clean Data cache\r
45 ArmCleanInvalidateDataCache();\r
46\r
47 //Invalidate instruction cache\r
48 ArmInvalidateInstructionCache();\r
49\r
50 // Enable Instruction & Data caches\r
f598bf12 51 ArmEnableDataCache ();\r
52 ArmEnableInstructionCache ();\r
1d5d0ae9 53\r
54 //\r
55 // Note: Doesn't have to Enable CPU interface in non-secure world,\r
56 // as Non-secure interface is already enabled in Secure world.\r
57 //\r
58\r
59 // Write VBAR - The Vector table must be 32-byte aligned\r
60 ASSERT(((UINT32)PeiVectorTable & ((1 << 5)-1)) == 0);\r
61 ArmWriteVBar((UINT32)PeiVectorTable);\r
62\r
63 //Note: The MMU will be enabled by MemoryPeim. Only the primary core will have the MMU on.\r
64\r
65 //If not primary Jump to Secondary Main\r
66 if(0 == CoreId) {\r
67 //Goto primary Main.\r
f598bf12 68 PrimaryMain (PeiCoreEntryPoint);\r
1d5d0ae9 69 } else {\r
f598bf12 70 SecondaryMain (CoreId);\r
1d5d0ae9 71 }\r
72\r
73 // PEI Core should always load and never return\r
74 ASSERT (FALSE);\r
75}\r
76\r
77EFI_STATUS\r
78EFIAPI\r
79SecTemporaryRamSupport (\r
80 IN CONST EFI_PEI_SERVICES **PeiServices,\r
81 IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase,\r
82 IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase,\r
83 IN UINTN CopySize\r
84 )\r
85{\r
86 //\r
87 // Migrate the whole temporary memory to permenent memory.\r
f598bf12 88 //\r
1d5d0ae9 89 CopyMem (\r
90 (VOID*)(UINTN)PermanentMemoryBase, \r
91 (VOID*)(UINTN)TemporaryMemoryBase, \r
92 CopySize\r
93 );\r
94\r
95 SecSwitchStack((UINTN)(PermanentMemoryBase - TemporaryMemoryBase));\r
96\r
97 return EFI_SUCCESS;\r
98}\r
99\r
2637d1ef 100VOID\r
101PeiCommonExceptionEntry (\r
102 IN UINT32 Entry,\r
103 IN UINT32 LR\r
104 )\r
105{\r
106 CHAR8 Buffer[100];\r
107 UINTN CharCount;\r
108\r
1d5d0ae9 109 switch (Entry) {\r
110 case 0:\r
2637d1ef 111 CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"Reset Exception at 0x%X\n\r",LR);\r
1d5d0ae9 112 break;\r
113 case 1:\r
2637d1ef 114 CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"Undefined Exception at 0x%X\n\r",LR);\r
1d5d0ae9 115 break;\r
116 case 2:\r
2637d1ef 117 CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"SWI Exception at 0x%X\n\r",LR);\r
1d5d0ae9 118 break;\r
119 case 3:\r
2637d1ef 120 CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"PrefetchAbort Exception at 0x%X\n\r",LR);\r
1d5d0ae9 121 break;\r
122 case 4:\r
2637d1ef 123 CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"DataAbort Exception at 0x%X\n\r",LR);\r
1d5d0ae9 124 break;\r
125 case 5:\r
2637d1ef 126 CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"Reserved Exception at 0x%X\n\r",LR);\r
1d5d0ae9 127 break;\r
128 case 6:\r
2637d1ef 129 CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"IRQ Exception at 0x%X\n\r",LR);\r
1d5d0ae9 130 break;\r
131 case 7:\r
2637d1ef 132 CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"FIQ Exception at 0x%X\n\r",LR);\r
1d5d0ae9 133 break;\r
134 default:\r
2637d1ef 135 CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"Unknown Exception at 0x%X\n\r",LR);\r
1d5d0ae9 136 break;\r
137 }\r
2637d1ef 138 SerialPortWrite ((UINT8 *) Buffer, CharCount);\r
1d5d0ae9 139 while(1);\r
140}\r