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.
16 #include <Library/IoLib.h>
17 #include <Library/BaseLib.h>
18 #include <Library/BaseMemoryLib.h>
19 #include <Library/PrintLib.h>
20 #include <Library/ArmLib.h>
21 #include <Library/SerialPortLib.h>
22 #include <Chipset/ArmV7.h>
24 #include "PrePeiCore.h"
26 EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI mSecTemporaryRamSupportPpi
= {SecTemporaryRamSupport
};
28 EFI_PEI_PPI_DESCRIPTOR gSecPpiTable
[] = {
30 EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
,
31 &gEfiTemporaryRamSupportPpiGuid
,
32 &mSecTemporaryRamSupportPpi
39 IN EFI_PEI_CORE_ENTRY_POINT PeiCoreEntryPoint
43 ArmCleanInvalidateDataCache();
45 //Invalidate instruction cache
46 ArmInvalidateInstructionCache();
48 // Enable Instruction & Data caches
49 ArmEnableDataCache ();
50 ArmEnableInstructionCache ();
53 // Note: Doesn't have to Enable CPU interface in non-secure world,
54 // as Non-secure interface is already enabled in Secure world.
57 // Write VBAR - The Vector table must be 32-byte aligned
58 ASSERT(((UINT32
)PeiVectorTable
& ((1 << 5)-1)) == 0);
59 ArmWriteVBar((UINT32
)PeiVectorTable
);
61 //Note: The MMU will be enabled by MemoryPeim. Only the primary core will have the MMU on.
63 //If not primary Jump to Secondary Main
66 PrimaryMain (PeiCoreEntryPoint
);
68 SecondaryMain (CoreId
);
71 // PEI Core should always load and never return
77 SecTemporaryRamSupport (
78 IN CONST EFI_PEI_SERVICES
**PeiServices
,
79 IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase
,
80 IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase
,
85 // Migrate the whole temporary memory to permenent memory.
88 (VOID
*)(UINTN
)PermanentMemoryBase
,
89 (VOID
*)(UINTN
)TemporaryMemoryBase
,
93 SecSwitchStack((UINTN
)(PermanentMemoryBase
- TemporaryMemoryBase
));
99 PeiCommonExceptionEntry (
109 CharCount
= AsciiSPrint (Buffer
,sizeof (Buffer
),"Reset Exception at 0x%X\n\r",LR
);
112 CharCount
= AsciiSPrint (Buffer
,sizeof (Buffer
),"Undefined Exception at 0x%X\n\r",LR
);
115 CharCount
= AsciiSPrint (Buffer
,sizeof (Buffer
),"SWI Exception at 0x%X\n\r",LR
);
118 CharCount
= AsciiSPrint (Buffer
,sizeof (Buffer
),"PrefetchAbort Exception at 0x%X\n\r",LR
);
121 CharCount
= AsciiSPrint (Buffer
,sizeof (Buffer
),"DataAbort Exception at 0x%X\n\r",LR
);
124 CharCount
= AsciiSPrint (Buffer
,sizeof (Buffer
),"Reserved Exception at 0x%X\n\r",LR
);
127 CharCount
= AsciiSPrint (Buffer
,sizeof (Buffer
),"IRQ Exception at 0x%X\n\r",LR
);
130 CharCount
= AsciiSPrint (Buffer
,sizeof (Buffer
),"FIQ Exception at 0x%X\n\r",LR
);
133 CharCount
= AsciiSPrint (Buffer
,sizeof (Buffer
),"Unknown Exception at 0x%X\n\r",LR
);
136 SerialPortWrite ((UINT8
*) Buffer
, CharCount
);