2 * Main file supporting the transition to PEI Core in Normal World for Versatile Express
4 * Copyright (c) 2011, ARM Limited. All rights reserved.
6 * This program and the accompanying materials
7 * are licensed and made available under the terms and conditions of the BSD License
8 * which accompanies this distribution. The full text of the license may be found at
9 * http://opensource.org/licenses/bsd-license.php
11 * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #include <Ppi/TemporaryRamSupport.h>
18 #include <Library/DebugLib.h>
19 #include <Library/PcdLib.h>
20 #include <Library/IoLib.h>
21 #include <Library/BaseLib.h>
22 #include <Library/BaseMemoryLib.h>
23 #include <Library/ArmLib.h>
24 #include <Chipset/ArmV7.h>
28 SecTemporaryRamSupport (
29 IN CONST EFI_PEI_SERVICES
**PeiServices
,
30 IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase
,
31 IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase
,
40 EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI mSecTemporaryRamSupportPpi
= {SecTemporaryRamSupport
};
42 EFI_PEI_PPI_DESCRIPTOR gSecPpiTable
[] = {
44 EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
,
45 &gEfiTemporaryRamSupportPpiGuid
,
46 &mSecTemporaryRamSupportPpi
50 // Vector Table for Pei Phase
51 VOID
PeiVectorTable (VOID
);
57 IN EFI_PEI_CORE_ENTRY_POINT PeiCoreEntryPoint
61 ArmCleanInvalidateDataCache();
63 //Invalidate instruction cache
64 ArmInvalidateInstructionCache();
66 // Enable Instruction & Data caches
68 ArmEnableInstructionCache();
71 // Note: Doesn't have to Enable CPU interface in non-secure world,
72 // as Non-secure interface is already enabled in Secure world.
75 // Write VBAR - The Vector table must be 32-byte aligned
76 ASSERT(((UINT32
)PeiVectorTable
& ((1 << 5)-1)) == 0);
77 ArmWriteVBar((UINT32
)PeiVectorTable
);
79 //Note: The MMU will be enabled by MemoryPeim. Only the primary core will have the MMU on.
81 //If not primary Jump to Secondary Main
84 primary_main(PeiCoreEntryPoint
);
86 secondary_main(CoreId
);
89 // PEI Core should always load and never return
95 SecTemporaryRamSupport (
96 IN CONST EFI_PEI_SERVICES
**PeiServices
,
97 IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase
,
98 IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase
,
103 // Migrate the whole temporary memory to permenent memory.
106 (VOID
*)(UINTN
)PermanentMemoryBase
,
107 (VOID
*)(UINTN
)TemporaryMemoryBase
,
111 SecSwitchStack((UINTN
)(PermanentMemoryBase
- TemporaryMemoryBase
));
117 PeiCommonExceptionEntry (
127 CharCount
= AsciiSPrint (Buffer
,sizeof (Buffer
),"Reset Exception at 0x%X\n\r",LR
);
130 CharCount
= AsciiSPrint (Buffer
,sizeof (Buffer
),"Undefined Exception at 0x%X\n\r",LR
);
133 CharCount
= AsciiSPrint (Buffer
,sizeof (Buffer
),"SWI Exception at 0x%X\n\r",LR
);
136 CharCount
= AsciiSPrint (Buffer
,sizeof (Buffer
),"PrefetchAbort Exception at 0x%X\n\r",LR
);
139 CharCount
= AsciiSPrint (Buffer
,sizeof (Buffer
),"DataAbort Exception at 0x%X\n\r",LR
);
142 CharCount
= AsciiSPrint (Buffer
,sizeof (Buffer
),"Reserved Exception at 0x%X\n\r",LR
);
145 CharCount
= AsciiSPrint (Buffer
,sizeof (Buffer
),"IRQ Exception at 0x%X\n\r",LR
);
148 CharCount
= AsciiSPrint (Buffer
,sizeof (Buffer
),"FIQ Exception at 0x%X\n\r",LR
);
151 CharCount
= AsciiSPrint (Buffer
,sizeof (Buffer
),"Unknown Exception at 0x%X\n\r",LR
);
154 SerialPortWrite ((UINT8
*) Buffer
, CharCount
);