2015-02-28 21:26:20 +01:00
|
|
|
/** @file
|
|
|
|
*
|
|
|
|
* Copyright (c) 2011-2014, ARM Limited. All rights reserved.
|
|
|
|
*
|
|
|
|
* This program and the accompanying materials
|
|
|
|
* are licensed and made available under the terms and conditions of the BSD License
|
|
|
|
* which accompanies this distribution. The full text of the license may be found at
|
|
|
|
* http://opensource.org/licenses/bsd-license.php
|
|
|
|
*
|
|
|
|
* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
|
|
|
|
#include <PiPei.h>
|
2017-11-13 16:13:07 +01:00
|
|
|
#include <Pi/PiBootMode.h>
|
2015-02-28 21:26:20 +01:00
|
|
|
|
|
|
|
#include <Library/PrePiLib.h>
|
|
|
|
#include <Library/PrintLib.h>
|
|
|
|
#include <Library/PrePiHobListPointerLib.h>
|
|
|
|
#include <Library/TimerLib.h>
|
|
|
|
#include <Library/PerformanceLib.h>
|
2015-04-14 13:56:56 +02:00
|
|
|
#include <Library/CacheMaintenanceLib.h>
|
2015-02-28 21:26:20 +01:00
|
|
|
|
|
|
|
#include <Ppi/GuidedSectionExtraction.h>
|
|
|
|
#include <Ppi/ArmMpCoreInfo.h>
|
|
|
|
|
|
|
|
#include "PrePi.h"
|
|
|
|
|
2017-11-13 16:09:30 +01:00
|
|
|
VOID
|
2015-02-28 21:26:20 +01:00
|
|
|
EFIAPI
|
2017-11-13 16:09:30 +01:00
|
|
|
ProcessLibraryConstructorList (
|
2015-02-28 21:26:20 +01:00
|
|
|
VOID
|
|
|
|
);
|
|
|
|
|
|
|
|
VOID
|
|
|
|
PrePiMain (
|
|
|
|
IN UINTN UefiMemoryBase,
|
|
|
|
IN UINTN StacksBase,
|
|
|
|
IN UINT64 StartTimeStamp
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_HOB_HANDOFF_INFO_TABLE* HobList;
|
|
|
|
EFI_STATUS Status;
|
|
|
|
CHAR8 Buffer[100];
|
|
|
|
UINTN CharCount;
|
|
|
|
UINTN StacksSize;
|
|
|
|
|
|
|
|
// Initialize the architecture specific bits
|
|
|
|
ArchInitialize ();
|
|
|
|
|
|
|
|
// Declare the PI/UEFI memory region
|
|
|
|
HobList = HobConstructor (
|
|
|
|
(VOID*)UefiMemoryBase,
|
|
|
|
FixedPcdGet32 (PcdSystemMemoryUefiRegionSize),
|
|
|
|
(VOID*)UefiMemoryBase,
|
|
|
|
(VOID*)StacksBase // The top of the UEFI Memory is reserved for the stacks
|
|
|
|
);
|
|
|
|
PrePeiSetHobList (HobList);
|
|
|
|
|
2015-04-14 13:56:56 +02:00
|
|
|
//
|
|
|
|
// Ensure that the loaded image is invalidated in the caches, so that any
|
|
|
|
// modifications we made with the caches and MMU off (such as the applied
|
|
|
|
// relocations) don't become invisible once we turn them on.
|
|
|
|
//
|
|
|
|
InvalidateDataCacheRange((VOID *)(UINTN)PcdGet64 (PcdFdBaseAddress), PcdGet32 (PcdFdSize));
|
|
|
|
|
2015-02-28 21:26:20 +01:00
|
|
|
// Initialize MMU and Memory HOBs (Resource Descriptor HOBs)
|
|
|
|
Status = MemoryPeim (UefiMemoryBase, FixedPcdGet32 (PcdSystemMemoryUefiRegionSize));
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
2015-04-14 13:56:56 +02:00
|
|
|
// Initialize the Serial Port
|
|
|
|
SerialPortInitialize ();
|
|
|
|
CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"UEFI firmware (version %s built at %a on %a)\n\r",
|
|
|
|
(CHAR16*)PcdGetPtr(PcdFirmwareVersionString), __TIME__, __DATE__);
|
|
|
|
SerialPortWrite ((UINT8 *) Buffer, CharCount);
|
|
|
|
|
2015-02-28 21:26:20 +01:00
|
|
|
// Create the Stacks HOB (reserve the memory for all stacks)
|
|
|
|
StacksSize = PcdGet32 (PcdCPUCorePrimaryStackSize);
|
|
|
|
BuildStackHob (StacksBase, StacksSize);
|
|
|
|
|
|
|
|
//TODO: Call CpuPei as a library
|
2018-11-26 22:35:02 +01:00
|
|
|
BuildCpuHob (ArmGetPhysicalAddressBits (), PcdGet8 (PcdPrePiCpuIoSize));
|
2015-02-28 21:26:20 +01:00
|
|
|
|
|
|
|
// Set the Boot Mode
|
2017-11-13 16:13:07 +01:00
|
|
|
SetBootMode (BOOT_WITH_FULL_CONFIGURATION);
|
2015-02-28 21:26:20 +01:00
|
|
|
|
|
|
|
// Initialize Platform HOBs (CpuHob and FvHob)
|
|
|
|
Status = PlatformPeim ();
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
|
|
|
// Now, the HOB List has been initialized, we can register performance information
|
|
|
|
PERF_START (NULL, "PEI", NULL, StartTimeStamp);
|
|
|
|
|
|
|
|
// SEC phase needs to run library constructors by hand.
|
2017-11-13 16:09:30 +01:00
|
|
|
ProcessLibraryConstructorList ();
|
2015-02-28 21:26:20 +01:00
|
|
|
|
|
|
|
// Assume the FV that contains the SEC (our code) also contains a compressed FV.
|
|
|
|
Status = DecompressFirstFv ();
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
|
|
|
// Load the DXE Core and transfer control to it
|
|
|
|
Status = LoadDxeCoreFromFv (NULL, 0);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
CEntryPoint (
|
|
|
|
IN UINTN MpId,
|
|
|
|
IN UINTN UefiMemoryBase,
|
2015-11-27 18:06:48 +01:00
|
|
|
IN UINTN StacksBase
|
2015-02-28 21:26:20 +01:00
|
|
|
)
|
|
|
|
{
|
|
|
|
UINT64 StartTimeStamp;
|
|
|
|
|
|
|
|
if (PerformanceMeasurementEnabled ()) {
|
|
|
|
// Initialize the Timer Library to setup the Timer HW controller
|
|
|
|
TimerConstructor ();
|
|
|
|
// We cannot call yet the PerformanceLib because the HOB List has not been initialized
|
|
|
|
StartTimeStamp = GetPerformanceCounter ();
|
|
|
|
} else {
|
|
|
|
StartTimeStamp = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Data Cache enabled on Primary core when MMU is enabled.
|
|
|
|
ArmDisableDataCache ();
|
|
|
|
// Invalidate instruction cache
|
|
|
|
ArmInvalidateInstructionCache ();
|
|
|
|
// Enable Instruction Caches on all cores.
|
|
|
|
ArmEnableInstructionCache ();
|
|
|
|
|
2015-11-27 18:06:48 +01:00
|
|
|
PrePiMain (UefiMemoryBase, StacksBase, StartTimeStamp);
|
2015-02-28 21:26:20 +01:00
|
|
|
|
|
|
|
// DXE Core should always load and never return
|
|
|
|
ASSERT (FALSE);
|
|
|
|
}
|