+++ /dev/null
-/** @file\r
- C Entry point for the SEC. First C code after the reset vector.\r
-\r
- Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
- \r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include <PiPei.h>\r
-\r
-#include <Library/DebugLib.h>\r
-#include <Library/PrePiLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/IoLib.h>\r
-#include <Library/ArmLib.h>\r
-#include <Library/PeCoffGetEntryPointLib.h>\r
-#include <Library/DebugAgentLib.h>\r
-\r
-#include <Ppi/GuidedSectionExtraction.h>\r
-#include <Guid/LzmaDecompress.h>\r
-\r
-#include <ArmEb/ArmEb.h>\r
-\r
-#include "LzmaDecompress.h"\r
-\r
-VOID\r
-EFIAPI \r
-_ModuleEntryPoint(\r
- VOID\r
- );\r
-\r
-CHAR8 *\r
-DeCygwinPathIfNeeded (\r
- IN CHAR8 *Name\r
- );\r
-\r
-RETURN_STATUS\r
-EFIAPI\r
-SerialPortInitialize (\r
- VOID\r
- );\r
- \r
- \r
-VOID\r
-UartInit (\r
- VOID\r
- )\r
-{\r
- // SEC phase needs to run library constructors by hand.\r
- // This assumes we are linked agains the SerialLib\r
- // In non SEC modules the init call is in autogenerated code.\r
- SerialPortInitialize ();\r
-}\r
-\r
-VOID\r
-TimerInit (\r
- VOID\r
- )\r
-{\r
- // configure SP810 to use 1MHz clock and disable\r
- MmioAndThenOr32 (EB_SP810_CTRL_BASE + SP810_SYS_CTRL_REG, ~SP810_SYS_CTRL_TIMER2_EN, SP810_SYS_CTRL_TIMER2_TIMCLK);\r
- // Enable\r
- MmioOr32 (EB_SP810_CTRL_BASE + SP810_SYS_CTRL_REG, SP810_SYS_CTRL_TIMER2_EN);\r
-\r
- // configure timer 2 for one shot operation, 32 bits, no prescaler, and interrupt disabled\r
- MmioOr32 (EB_SP804_TIMER2_BASE + SP804_TIMER_CONTROL_REG, SP804_TIMER_CTRL_ONESHOT | SP804_TIMER_CTRL_32BIT | SP804_PRESCALE_DIV_1);\r
-\r
- // preload the timer count register\r
- MmioWrite32 (EB_SP804_TIMER2_BASE + SP804_TIMER_LOAD_REG, 1);\r
-\r
- // enable the timer\r
- MmioOr32 (EB_SP804_TIMER2_BASE + SP804_TIMER_CONTROL_REG, SP804_TIMER_CTRL_ENABLE);\r
-}\r
-\r
-\r
-VOID\r
-InitCache (\r
- IN UINT32 MemoryBase,\r
- IN UINT32 MemoryLength\r
- );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-ExtractGuidedSectionLibConstructor (\r
- VOID\r
- );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-LzmaDecompressLibConstructor (\r
- VOID\r
- );\r
-\r
-\r
-VOID\r
-CEntryPoint (\r
- IN VOID *MemoryBase,\r
- IN UINTN MemorySize,\r
- IN VOID *StackBase,\r
- IN UINTN StackSize\r
- )\r
-{\r
- VOID *HobBase;\r
-\r
- // Build a basic HOB list\r
- HobBase = (VOID *)(UINTN)(FixedPcdGet32(PcdEmbeddedFdBaseAddress) + FixedPcdGet32(PcdEmbeddedFdSize));\r
- CreateHobList (MemoryBase, MemorySize, HobBase, StackBase);\r
-\r
-\r
- // Enable program flow prediction, if supported.\r
- ArmEnableBranchPrediction ();\r
-\r
- // Initialize CPU cache\r
- InitCache ((UINT32)MemoryBase, (UINT32)MemorySize);\r
-\r
- // Add memory allocation hob for relocated FD\r
- BuildMemoryAllocationHob (FixedPcdGet32(PcdEmbeddedFdBaseAddress), FixedPcdGet32(PcdEmbeddedFdSize), EfiBootServicesData);\r
-\r
- // Add the FVs to the hob list\r
- BuildFvHob (PcdGet32(PcdFlashFvMainBase), PcdGet32(PcdFlashFvMainSize));\r
-\r
- // Start talking\r
- UartInit ();\r
-\r
- InitializeDebugAgent (DEBUG_AGENT_INIT_PREMEM_SEC, NULL);\r
- SaveAndSetDebugTimerInterrupt (TRUE);\r
-\r
- DEBUG ((EFI_D_ERROR, "UART Enabled\n"));\r
-\r
- // Start up a free running timer so that the timer lib will work\r
- TimerInit ();\r
-\r
- // SEC phase needs to run library constructors by hand.\r
- ExtractGuidedSectionLibConstructor ();\r
- LzmaDecompressLibConstructor ();\r
-\r
- // Build HOBs to pass up our version of stuff the DXE Core needs to save space\r
- BuildPeCoffLoaderHob ();\r
- BuildExtractSectionHob (\r
- &gLzmaCustomDecompressGuid,\r
- LzmaGuidedSectionGetInfo,\r
- LzmaGuidedSectionExtraction\r
- );\r
-\r
- // Assume the FV that contains the SEC (our code) also contains a compressed FV.\r
- DecompressFirstFv ();\r
-\r
- // Load the DXE Core and transfer control to it\r
- LoadDxeCoreFromFv (NULL, 0);\r
- \r
- // DXE Core should always load and never return\r
- ASSERT (FALSE);\r
-}\r
-\r