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/DebugLib.h>
17 #include <Library/PcdLib.h>
18 #include <Library/IoLib.h>
19 #include <Library/BaseLib.h>
20 #include <Library/BaseMemoryLib.h>
21 #include <Library/PrintLib.h>
22 #include <Library/ArmLib.h>
23 #include <Library/SerialPortLib.h>
24 #include <Chipset/ArmV7.h>
26 #include "PrePeiCore.h"
28 EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI mSecTemporaryRamSupportPpi
= {SecTemporaryRamSupport
};
30 EFI_PEI_PPI_DESCRIPTOR gSecPpiTable
[] = {
32 EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
,
33 &gEfiTemporaryRamSupportPpiGuid
,
34 &mSecTemporaryRamSupportPpi
41 IN EFI_PEI_CORE_ENTRY_POINT PeiCoreEntryPoint
45 ArmCleanInvalidateDataCache();
47 //Invalidate instruction cache
48 ArmInvalidateInstructionCache();
50 // Enable Instruction & Data caches
51 ArmEnableDataCache ();
52 ArmEnableInstructionCache ();
55 // Note: Doesn't have to Enable CPU interface in non-secure world,
56 // as Non-secure interface is already enabled in Secure world.
59 // Write VBAR - The Vector table must be 32-byte aligned
60 ASSERT(((UINT32
)PeiVectorTable
& ((1 << 5)-1)) == 0);
61 ArmWriteVBar((UINT32
)PeiVectorTable
);
63 //Note: The MMU will be enabled by MemoryPeim. Only the primary core will have the MMU on.
65 //If not primary Jump to Secondary Main
68 PrimaryMain (PeiCoreEntryPoint
);
70 SecondaryMain (CoreId
);
73 // PEI Core should always load and never return
79 SecTemporaryRamSupport (
80 IN CONST EFI_PEI_SERVICES
**PeiServices
,
81 IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase
,
82 IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase
,
87 // Migrate the whole temporary memory to permenent memory.
90 (VOID
*)(UINTN
)PermanentMemoryBase
,
91 (VOID
*)(UINTN
)TemporaryMemoryBase
,
95 SecSwitchStack((UINTN
)(PermanentMemoryBase
- TemporaryMemoryBase
));
101 PeiCommonExceptionEntry (
111 CharCount
= AsciiSPrint (Buffer
,sizeof (Buffer
),"Reset Exception at 0x%X\n\r",LR
);
114 CharCount
= AsciiSPrint (Buffer
,sizeof (Buffer
),"Undefined Exception at 0x%X\n\r",LR
);
117 CharCount
= AsciiSPrint (Buffer
,sizeof (Buffer
),"SWI Exception at 0x%X\n\r",LR
);
120 CharCount
= AsciiSPrint (Buffer
,sizeof (Buffer
),"PrefetchAbort Exception at 0x%X\n\r",LR
);
123 CharCount
= AsciiSPrint (Buffer
,sizeof (Buffer
),"DataAbort Exception at 0x%X\n\r",LR
);
126 CharCount
= AsciiSPrint (Buffer
,sizeof (Buffer
),"Reserved Exception at 0x%X\n\r",LR
);
129 CharCount
= AsciiSPrint (Buffer
,sizeof (Buffer
),"IRQ Exception at 0x%X\n\r",LR
);
132 CharCount
= AsciiSPrint (Buffer
,sizeof (Buffer
),"FIQ Exception at 0x%X\n\r",LR
);
135 CharCount
= AsciiSPrint (Buffer
,sizeof (Buffer
),"Unknown Exception at 0x%X\n\r",LR
);
138 SerialPortWrite ((UINT8
*) Buffer
, CharCount
);