ReportStatusCodeLib|MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf\r
UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf\r
ExtractGuidedSectionLib|EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.inf\r
- LzmaDecompressLib|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf\r
\r
PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf\r
\r
#\r
# SEC\r
#\r
- ArmPlatformPkg/PrePi/PeiUniCore.inf\r
+ BeagleBoardPkg/PrePi/PeiUniCore.inf {\r
+ <LibraryClasses>\r
+ NULL|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf\r
+ }\r
\r
#\r
# DXE\r
READ_LOCK_CAP = TRUE\r
READ_LOCK_STATUS = TRUE\r
\r
- INF ArmPlatformPkg/PrePi/PeiUniCore.inf\r
+ INF BeagleBoardPkg/PrePi/PeiUniCore.inf\r
\r
FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {\r
SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRED = TRUE {\r
--- /dev/null
+/** @file\r
+*\r
+* Copyright (c) 2011 - 2013, ARM Limited. All rights reserved.\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 "PrePi.h"\r
+\r
+VOID\r
+ArchInitialize (\r
+ VOID\r
+ )\r
+{\r
+ // Enable program flow prediction, if supported.\r
+ ArmEnableBranchPrediction ();\r
+\r
+ if (FixedPcdGet32 (PcdVFPEnabled)) {\r
+ ArmEnableVFP ();\r
+ }\r
+}\r
+\r
--- /dev/null
+//\r
+// Copyright (c) 2011-2015, ARM Limited. All rights reserved.\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 <AsmMacroIoLib.h>\r
+\r
+#include <Chipset/ArmV7.h>\r
+\r
+ASM_FUNC(_ModuleEntryPoint)\r
+ // Do early platform specific actions\r
+ bl ASM_PFX(ArmPlatformPeiBootAction)\r
+\r
+ // Get ID of this CPU in Multicore system\r
+ bl ASM_PFX(ArmReadMpidr)\r
+ // Keep a copy of the MpId register value\r
+ mov r8, r0\r
+\r
+_SetSVCMode:\r
+ // Enter SVC mode, Disable FIQ and IRQ\r
+ mov r1, #(CPSR_MODE_SVC | CPSR_IRQ | CPSR_FIQ)\r
+ msr CPSR_c, r1\r
+\r
+// Check if we can install the stack at the top of the System Memory or if we need\r
+// to install the stacks at the bottom of the Firmware Device (case the FD is located\r
+// at the top of the DRAM)\r
+_SystemMemoryEndInit:\r
+ ADRL (r1, mSystemMemoryEnd)\r
+ ldrd r2, r3, [r1]\r
+ teq r3, #0\r
+ moveq r1, r2\r
+ mvnne r1, #0\r
+\r
+_SetupStackPosition:\r
+ // r1 = SystemMemoryTop\r
+\r
+ // Calculate Top of the Firmware Device\r
+ MOV32 (r2, FixedPcdGet32(PcdFdBaseAddress))\r
+ MOV32 (r3, FixedPcdGet32(PcdFdSize) - 1)\r
+ add r3, r3, r2 // r3 = FdTop = PcdFdBaseAddress + PcdFdSize\r
+\r
+ // UEFI Memory Size (stacks are allocated in this region)\r
+ MOV32 (r4, FixedPcdGet32(PcdSystemMemoryUefiRegionSize))\r
+\r
+ //\r
+ // Reserve the memory for the UEFI region (contain stacks on its top)\r
+ //\r
+\r
+ // Calculate how much space there is between the top of the Firmware and the Top of the System Memory\r
+ subs r0, r1, r3 // r0 = SystemMemoryTop - FdTop\r
+ bmi _SetupStack // Jump if negative (FdTop > SystemMemoryTop). Case when the PrePi is in XIP memory outside of the DRAM\r
+ cmp r0, r4\r
+ bge _SetupStack\r
+\r
+ // Case the top of stacks is the FdBaseAddress\r
+ mov r1, r2\r
+\r
+_SetupStack:\r
+ // r1 contains the top of the stack (and the UEFI Memory)\r
+\r
+ // Because the 'push' instruction is equivalent to 'stmdb' (decrement before), we need to increment\r
+ // one to the top of the stack. We check if incrementing one does not overflow (case of DRAM at the\r
+ // top of the memory space)\r
+ adds r9, r1, #1\r
+ bcs _SetupOverflowStack\r
+\r
+_SetupAlignedStack:\r
+ mov r1, r9\r
+ b _GetBaseUefiMemory\r
+\r
+_SetupOverflowStack:\r
+ // Case memory at the top of the address space. Ensure the top of the stack is EFI_PAGE_SIZE\r
+ // aligned (4KB)\r
+ MOV32 (r9, ~EFI_PAGE_MASK & 0xFFFFFFFF)\r
+ and r1, r1, r9\r
+\r
+_GetBaseUefiMemory:\r
+ // Calculate the Base of the UEFI Memory\r
+ sub r9, r1, r4\r
+\r
+_GetStackBase:\r
+ // r1 = The top of the Mpcore Stacks\r
+ // Stack for the primary core = PrimaryCoreStack\r
+ MOV32 (r2, FixedPcdGet32(PcdCPUCorePrimaryStackSize))\r
+ sub r10, r1, r2\r
+\r
+ // Stack for the secondary core = Number of Cores - 1\r
+ MOV32 (r1, (FixedPcdGet32(PcdCoreCount) - 1) * FixedPcdGet32(PcdCPUCoreSecondaryStackSize))\r
+ sub r10, r10, r1\r
+\r
+ // r10 = The base of the MpCore Stacks (primary stack & secondary stacks)\r
+ mov r0, r10\r
+ mov r1, r8\r
+ //ArmPlatformStackSet(StackBase, MpId, PrimaryStackSize, SecondaryStackSize)\r
+ MOV32 (r2, FixedPcdGet32(PcdCPUCorePrimaryStackSize))\r
+ MOV32 (r3, FixedPcdGet32(PcdCPUCoreSecondaryStackSize))\r
+ bl ASM_PFX(ArmPlatformStackSet)\r
+\r
+ // Is it the Primary Core ?\r
+ mov r0, r8\r
+ bl ASM_PFX(ArmPlatformIsPrimaryCore)\r
+ cmp r0, #1\r
+ bne _PrepareArguments\r
+\r
+_PrepareArguments:\r
+ mov r0, r8\r
+ mov r1, r9\r
+ mov r2, r10\r
+ mov r3, sp\r
+\r
+ // Move sec startup address into a data register\r
+ // Ensure we're jumping to FV version of the code (not boot remapped alias)\r
+ ldr r4, =ASM_PFX(CEntryPoint)\r
+\r
+ // Jump to PrePiCore C code\r
+ // r0 = MpId\r
+ // r1 = UefiMemoryBase\r
+ // r2 = StacksBase\r
+ blx r4\r
+\r
+_NeverReturn:\r
+ b _NeverReturn\r
--- /dev/null
+//\r
+// Copyright (c) 2011-2015, ARM Limited. All rights reserved.\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 <AutoGen.h>\r
+#include <Chipset/ArmV7.h>\r
+\r
+ INCLUDE AsmMacroIoLib.inc\r
+\r
+ IMPORT CEntryPoint\r
+ IMPORT ArmPlatformIsPrimaryCore\r
+ IMPORT ArmReadMpidr\r
+ IMPORT ArmPlatformPeiBootAction\r
+ IMPORT ArmPlatformStackSet\r
+ IMPORT mSystemMemoryEnd\r
+\r
+ EXPORT _ModuleEntryPoint\r
+\r
+ PRESERVE8\r
+ AREA PrePiCoreEntryPoint, CODE, READONLY\r
+\r
+StartupAddr DCD CEntryPoint\r
+\r
+_ModuleEntryPoint\r
+ // Do early platform specific actions\r
+ bl ArmPlatformPeiBootAction\r
+\r
+ // Get ID of this CPU in Multicore system\r
+ bl ArmReadMpidr\r
+ // Keep a copy of the MpId register value\r
+ mov r8, r0\r
+\r
+_SetSVCMode\r
+ // Enter SVC mode, Disable FIQ and IRQ\r
+ mov r1, #(CPSR_MODE_SVC :OR: CPSR_IRQ :OR: CPSR_FIQ)\r
+ msr CPSR_c, r1\r
+\r
+// Check if we can install the stack at the top of the System Memory or if we need\r
+// to install the stacks at the bottom of the Firmware Device (case the FD is located\r
+// at the top of the DRAM)\r
+_SystemMemoryEndInit\r
+ adrll r1, mSystemMemoryEnd\r
+ ldrd r2, r3, [r1]\r
+ teq r3, #0\r
+ moveq r1, r2\r
+ mvnne r1, #0\r
+\r
+_SetupStackPosition\r
+ // r1 = SystemMemoryTop\r
+\r
+ // Calculate Top of the Firmware Device\r
+ mov32 r2, FixedPcdGet32(PcdFdBaseAddress)\r
+ mov32 r3, FixedPcdGet32(PcdFdSize)\r
+ sub r3, r3, #1\r
+ add r3, r3, r2 // r3 = FdTop = PcdFdBaseAddress + PcdFdSize\r
+\r
+ // UEFI Memory Size (stacks are allocated in this region)\r
+ mov32 r4, FixedPcdGet32(PcdSystemMemoryUefiRegionSize)\r
+\r
+ //\r
+ // Reserve the memory for the UEFI region (contain stacks on its top)\r
+ //\r
+\r
+ // Calculate how much space there is between the top of the Firmware and the Top of the System Memory\r
+ subs r0, r1, r3 // r0 = SystemMemoryTop - FdTop\r
+ bmi _SetupStack // Jump if negative (FdTop > SystemMemoryTop). Case when the PrePi is in XIP memory outside of the DRAM\r
+ cmp r0, r4\r
+ bge _SetupStack\r
+\r
+ // Case the top of stacks is the FdBaseAddress\r
+ mov r1, r2\r
+\r
+_SetupStack\r
+ // r1 contains the top of the stack (and the UEFI Memory)\r
+\r
+ // Because the 'push' instruction is equivalent to 'stmdb' (decrement before), we need to increment\r
+ // one to the top of the stack. We check if incrementing one does not overflow (case of DRAM at the\r
+ // top of the memory space)\r
+ adds r9, r1, #1\r
+ bcs _SetupOverflowStack\r
+\r
+_SetupAlignedStack\r
+ mov r1, r9\r
+ b _GetBaseUefiMemory\r
+\r
+_SetupOverflowStack\r
+ // Case memory at the top of the address space. Ensure the top of the stack is EFI_PAGE_SIZE\r
+ // aligned (4KB)\r
+ mov32 r9, EFI_PAGE_MASK\r
+ and r9, r9, r1\r
+ sub r1, r1, r9\r
+\r
+_GetBaseUefiMemory\r
+ // Calculate the Base of the UEFI Memory\r
+ sub r9, r1, r4\r
+\r
+_GetStackBase\r
+ // r1 = The top of the Mpcore Stacks\r
+ // Stack for the primary core = PrimaryCoreStack\r
+ mov32 r2, FixedPcdGet32(PcdCPUCorePrimaryStackSize)\r
+ sub r10, r1, r2\r
+\r
+ // Stack for the secondary core = Number of Cores - 1\r
+ mov32 r1, (FixedPcdGet32(PcdCoreCount) - 1) * FixedPcdGet32(PcdCPUCoreSecondaryStackSize)\r
+ sub r10, r10, r1\r
+\r
+ // r10 = The base of the MpCore Stacks (primary stack & secondary stacks)\r
+ mov r0, r10\r
+ mov r1, r8\r
+ //ArmPlatformStackSet(StackBase, MpId, PrimaryStackSize, SecondaryStackSize)\r
+ mov32 r2, FixedPcdGet32(PcdCPUCorePrimaryStackSize)\r
+ mov32 r3, FixedPcdGet32(PcdCPUCoreSecondaryStackSize)\r
+ bl ArmPlatformStackSet\r
+\r
+ // Is it the Primary Core ?\r
+ mov r0, r8\r
+ bl ArmPlatformIsPrimaryCore\r
+ cmp r0, #1\r
+ bne _PrepareArguments\r
+\r
+_PrepareArguments\r
+ mov r0, r8\r
+ mov r1, r9\r
+ mov r2, r10\r
+\r
+ // Move sec startup address into a data register\r
+ // Ensure we're jumping to FV version of the code (not boot remapped alias)\r
+ ldr r4, StartupAddr\r
+\r
+ // Jump to PrePiCore C code\r
+ // r0 = MpId\r
+ // r1 = UefiMemoryBase\r
+ // r2 = StacksBase\r
+ blx r4\r
+\r
+_NeverReturn\r
+ b _NeverReturn\r
+\r
+ END\r
--- /dev/null
+/** @file\r
+ LZMA Decompress Library header file\r
+\r
+ Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\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
+#ifndef __LZMA_DECOMPRESS_H___\r
+#define __LZMA_DECOMPRESS_H___\r
+\r
+/**\r
+ Examines a GUIDed section and returns the size of the decoded buffer and the\r
+ size of an scratch buffer required to actually decode the data in a GUIDed section.\r
+\r
+ Examines a GUIDed section specified by InputSection.\r
+ If GUID for InputSection does not match the GUID that this handler supports,\r
+ then RETURN_UNSUPPORTED is returned.\r
+ If the required information can not be retrieved from InputSection,\r
+ then RETURN_INVALID_PARAMETER is returned.\r
+ If the GUID of InputSection does match the GUID that this handler supports,\r
+ then the size required to hold the decoded buffer is returned in OututBufferSize,\r
+ the size of an optional scratch buffer is returned in ScratchSize, and the Attributes field\r
+ from EFI_GUID_DEFINED_SECTION header of InputSection is returned in SectionAttribute.\r
+\r
+ If InputSection is NULL, then ASSERT().\r
+ If OutputBufferSize is NULL, then ASSERT().\r
+ If ScratchBufferSize is NULL, then ASSERT().\r
+ If SectionAttribute is NULL, then ASSERT().\r
+\r
+\r
+ @param[in] InputSection A pointer to a GUIDed section of an FFS formatted file.\r
+ @param[out] OutputBufferSize A pointer to the size, in bytes, of an output buffer required\r
+ if the buffer specified by InputSection were decoded.\r
+ @param[out] ScratchBufferSize A pointer to the size, in bytes, required as scratch space\r
+ if the buffer specified by InputSection were decoded.\r
+ @param[out] SectionAttribute A pointer to the attributes of the GUIDed section. See the Attributes\r
+ field of EFI_GUID_DEFINED_SECTION in the PI Specification.\r
+\r
+ @retval RETURN_SUCCESS The information about InputSection was returned.\r
+ @retval RETURN_UNSUPPORTED The section specified by InputSection does not match the GUID this handler supports.\r
+ @retval RETURN_INVALID_PARAMETER The information can not be retrieved from the section specified by InputSection.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+LzmaGuidedSectionGetInfo (\r
+ IN CONST VOID *InputSection,\r
+ OUT UINT32 *OutputBufferSize,\r
+ OUT UINT32 *ScratchBufferSize,\r
+ OUT UINT16 *SectionAttribute\r
+ );\r
+\r
+/**\r
+ Decompress a LZAM compressed GUIDed section into a caller allocated output buffer.\r
+\r
+ Decodes the GUIDed section specified by InputSection.\r
+ If GUID for InputSection does not match the GUID that this handler supports, then RETURN_UNSUPPORTED is returned.\r
+ If the data in InputSection can not be decoded, then RETURN_INVALID_PARAMETER is returned.\r
+ If the GUID of InputSection does match the GUID that this handler supports, then InputSection\r
+ is decoded into the buffer specified by OutputBuffer and the authentication status of this\r
+ decode operation is returned in AuthenticationStatus. If the decoded buffer is identical to the\r
+ data in InputSection, then OutputBuffer is set to point at the data in InputSection. Otherwise,\r
+ the decoded data will be placed in caller allocated buffer specified by OutputBuffer.\r
+\r
+ If InputSection is NULL, then ASSERT().\r
+ If OutputBuffer is NULL, then ASSERT().\r
+ If ScratchBuffer is NULL and this decode operation requires a scratch buffer, then ASSERT().\r
+ If AuthenticationStatus is NULL, then ASSERT().\r
+\r
+\r
+ @param[in] InputSection A pointer to a GUIDed section of an FFS formatted file.\r
+ @param[out] OutputBuffer A pointer to a buffer that contains the result of a decode operation.\r
+ @param[out] ScratchBuffer A caller allocated buffer that may be required by this function\r
+ as a scratch buffer to perform the decode operation.\r
+ @param[out] AuthenticationStatus\r
+ A pointer to the authentication status of the decoded output buffer.\r
+ See the definition of authentication status in the EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI\r
+ section of the PI Specification. EFI_AUTH_STATUS_PLATFORM_OVERRIDE must\r
+ never be set by this handler.\r
+\r
+ @retval RETURN_SUCCESS The buffer specified by InputSection was decoded.\r
+ @retval RETURN_UNSUPPORTED The section specified by InputSection does not match the GUID this handler supports.\r
+ @retval RETURN_INVALID_PARAMETER The section specified by InputSection can not be decoded.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+LzmaGuidedSectionExtraction (\r
+ IN CONST VOID *InputSection,\r
+ OUT VOID **OutputBuffer,\r
+ OUT VOID *ScratchBuffer, OPTIONAL\r
+ OUT UINT32 *AuthenticationStatus\r
+ );\r
+\r
+#endif // __LZMADECOMPRESS_H__\r
+\r
--- /dev/null
+/** @file\r
+*\r
+* Copyright (c) 2011, ARM Limited. All rights reserved.\r
+* Copyright (c) 2017, Linaro, Ltd. All rights reserved.\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 "PrePi.h"\r
+\r
+VOID\r
+PrimaryMain (\r
+ IN UINTN UefiMemoryBase,\r
+ IN UINTN StacksBase,\r
+ IN UINT64 StartTimeStamp\r
+ )\r
+{\r
+ PrePiMain (UefiMemoryBase, StacksBase, StartTimeStamp);\r
+\r
+ // We must never return\r
+ ASSERT(FALSE);\r
+}\r
+\r
+VOID\r
+SecondaryMain (\r
+ IN UINTN MpId\r
+ )\r
+{\r
+ // We must never get into this function on UniCore system\r
+ ASSERT(FALSE);\r
+}\r
+\r
--- /dev/null
+#/** @file\r
+#\r
+# (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r
+# Copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>\r
+# Copyright (c) 2017, Linaro, Ltd. 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
+[Defines]\r
+ INF_VERSION = 0x0001001A\r
+ BASE_NAME = BeagleBoardPrePiUniCore\r
+ FILE_GUID = 8a5dc3de-fe31-4ad9-9c93-dd73626932e7\r
+ MODULE_TYPE = SEC\r
+ VERSION_STRING = 1.0\r
+\r
+[Sources]\r
+ PrePi.c\r
+ MainUniCore.c\r
+\r
+[Sources.ARM]\r
+ Arm/ArchPrePi.c\r
+ Arm/ModuleEntryPoint.S | GCC\r
+ Arm/ModuleEntryPoint.asm | RVCT\r
+\r
+[Packages]\r
+ ArmPkg/ArmPkg.dec\r
+ ArmPlatformPkg/ArmPlatformPkg.dec\r
+ EmbeddedPkg/EmbeddedPkg.dec\r
+ MdeModulePkg/MdeModulePkg.dec\r
+ MdePkg/MdePkg.dec\r
+\r
+[LibraryClasses]\r
+ ArmLib\r
+ ArmPlatformLib\r
+ ArmPlatformStackLib\r
+ BaseLib\r
+ DebugLib\r
+ DebugAgentLib\r
+ ExtractGuidedSectionLib\r
+ HobLib\r
+ IoLib\r
+ MemoryAllocationLib\r
+ MemoryInitPeiLib\r
+ PeCoffGetEntryPointLib\r
+ PlatformPeiLib\r
+ PrePiHobListPointerLib\r
+ PrePiLib\r
+ SerialPortLib\r
+ TimerLib\r
+\r
+[Ppis]\r
+ gArmMpCoreInfoPpiGuid\r
+\r
+[Guids]\r
+ gArmMpCoreInfoGuid\r
+ gEfiFirmwarePerformanceGuid\r
+\r
+[FeaturePcd]\r
+ gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob\r
+ gArmPlatformTokenSpaceGuid.PcdSendSgiToBringUpSecondaryCores\r
+\r
+[Pcd]\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString\r
+\r
+[FixedPcd]\r
+ gArmTokenSpaceGuid.PcdVFPEnabled\r
+\r
+ gArmTokenSpaceGuid.PcdFdBaseAddress\r
+ gArmTokenSpaceGuid.PcdFdSize\r
+\r
+ gArmTokenSpaceGuid.PcdFvBaseAddress\r
+ gArmTokenSpaceGuid.PcdFvSize\r
+\r
+ gArmPlatformTokenSpaceGuid.PcdCPUCorePrimaryStackSize\r
+ gArmPlatformTokenSpaceGuid.PcdCPUCoreSecondaryStackSize\r
+\r
+ gArmPlatformTokenSpaceGuid.PcdSystemMemoryUefiRegionSize\r
+\r
+ gArmPlatformTokenSpaceGuid.PcdCoreCount\r
+\r
+ gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize\r
+ gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize\r
+\r
+ gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory\r
+ gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIMemoryNVS\r
+ gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiReservedMemoryType\r
+ gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData\r
+ gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode\r
+ gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesCode\r
+ gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesData\r
+ gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderCode\r
+ gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderData\r
+\r
+[Pcd]\r
+ gArmTokenSpaceGuid.PcdSystemMemoryBase\r
+ gArmTokenSpaceGuid.PcdSystemMemorySize\r
--- /dev/null
+/** @file\r
+*\r
+* Copyright (c) 2011-2017, ARM Limited. All rights reserved.\r
+* Copyright (c) 2017, Linaro, Ltd. All rights reserved.\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/DebugAgentLib.h>\r
+#include <Library/PrePiLib.h>\r
+#include <Library/PrintLib.h>\r
+#include <Library/PeCoffGetEntryPointLib.h>\r
+#include <Library/PrePiHobListPointerLib.h>\r
+#include <Library/TimerLib.h>\r
+#include <Library/PerformanceLib.h>\r
+\r
+#include <Ppi/GuidedSectionExtraction.h>\r
+#include <Ppi/ArmMpCoreInfo.h>\r
+#include <Ppi/SecPerformance.h>\r
+#include <Guid/LzmaDecompress.h>\r
+\r
+#include "PrePi.h"\r
+#include "LzmaDecompress.h"\r
+\r
+#define IS_XIP() (((UINT64)FixedPcdGet64 (PcdFdBaseAddress) > mSystemMemoryEnd) || \\r
+ ((FixedPcdGet64 (PcdFdBaseAddress) + FixedPcdGet32 (PcdFdSize)) < FixedPcdGet64 (PcdSystemMemoryBase)))\r
+\r
+UINT64 mSystemMemoryEnd = FixedPcdGet64(PcdSystemMemoryBase) +\r
+ FixedPcdGet64(PcdSystemMemorySize) - 1;\r
+\r
+EFI_STATUS\r
+GetPlatformPpi (\r
+ IN EFI_GUID *PpiGuid,\r
+ OUT VOID **Ppi\r
+ )\r
+{\r
+ UINTN PpiListSize;\r
+ UINTN PpiListCount;\r
+ EFI_PEI_PPI_DESCRIPTOR *PpiList;\r
+ UINTN Index;\r
+\r
+ PpiListSize = 0;\r
+ ArmPlatformGetPlatformPpiList (&PpiListSize, &PpiList);\r
+ PpiListCount = PpiListSize / sizeof(EFI_PEI_PPI_DESCRIPTOR);\r
+ for (Index = 0; Index < PpiListCount; Index++, PpiList++) {\r
+ if (CompareGuid (PpiList->Guid, PpiGuid) == TRUE) {\r
+ *Ppi = PpiList->Ppi;\r
+ return EFI_SUCCESS;\r
+ }\r
+ }\r
+\r
+ return EFI_NOT_FOUND;\r
+}\r
+\r
+VOID\r
+PrePiMain (\r
+ IN UINTN UefiMemoryBase,\r
+ IN UINTN StacksBase,\r
+ IN UINT64 StartTimeStamp\r
+ )\r
+{\r
+ EFI_HOB_HANDOFF_INFO_TABLE* HobList;\r
+ EFI_STATUS Status;\r
+ CHAR8 Buffer[100];\r
+ UINTN CharCount;\r
+ UINTN StacksSize;\r
+ FIRMWARE_SEC_PERFORMANCE Performance;\r
+\r
+ // If ensure the FD is either part of the System Memory or totally outside of the System Memory (XIP)\r
+ ASSERT (IS_XIP() ||\r
+ ((FixedPcdGet64 (PcdFdBaseAddress) >= FixedPcdGet64 (PcdSystemMemoryBase)) &&\r
+ ((UINT64)(FixedPcdGet64 (PcdFdBaseAddress) + FixedPcdGet32 (PcdFdSize)) <= (UINT64)mSystemMemoryEnd)));\r
+\r
+ // Initialize the architecture specific bits\r
+ ArchInitialize ();\r
+\r
+ // Initialize the Serial Port\r
+ SerialPortInitialize ();\r
+ CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"UEFI firmware (version %s built at %a on %a)\n\r",\r
+ (CHAR16*)PcdGetPtr(PcdFirmwareVersionString), __TIME__, __DATE__);\r
+ SerialPortWrite ((UINT8 *) Buffer, CharCount);\r
+\r
+ // Initialize the Debug Agent for Source Level Debugging\r
+ InitializeDebugAgent (DEBUG_AGENT_INIT_POSTMEM_SEC, NULL, NULL);\r
+ SaveAndSetDebugTimerInterrupt (TRUE);\r
+\r
+ // Declare the PI/UEFI memory region\r
+ HobList = HobConstructor (\r
+ (VOID*)UefiMemoryBase,\r
+ FixedPcdGet32 (PcdSystemMemoryUefiRegionSize),\r
+ (VOID*)UefiMemoryBase,\r
+ (VOID*)StacksBase // The top of the UEFI Memory is reserved for the stacks\r
+ );\r
+ PrePeiSetHobList (HobList);\r
+\r
+ // Initialize MMU and Memory HOBs (Resource Descriptor HOBs)\r
+ Status = MemoryPeim (UefiMemoryBase, FixedPcdGet32 (PcdSystemMemoryUefiRegionSize));\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ StacksSize = PcdGet32 (PcdCPUCorePrimaryStackSize);\r
+ BuildStackHob (StacksBase, StacksSize);\r
+\r
+ //TODO: Call CpuPei as a library\r
+ BuildCpuHob (PcdGet8 (PcdPrePiCpuMemorySize), PcdGet8 (PcdPrePiCpuIoSize));\r
+\r
+ // Store timer value logged at the beginning of firmware image execution\r
+ Performance.ResetEnd = GetTimeInNanoSecond (StartTimeStamp);\r
+\r
+ // Build SEC Performance Data Hob\r
+ BuildGuidDataHob (&gEfiFirmwarePerformanceGuid, &Performance, sizeof (Performance));\r
+\r
+ // Set the Boot Mode\r
+ SetBootMode (ArmPlatformGetBootMode ());\r
+\r
+ // Initialize Platform HOBs (CpuHob and FvHob)\r
+ Status = PlatformPeim ();\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ // Now, the HOB List has been initialized, we can register performance information\r
+ PERF_START (NULL, "PEI", NULL, StartTimeStamp);\r
+\r
+ // SEC phase needs to run library constructors by hand.\r
+ ProcessLibraryConstructorList ();\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
+ Status = DecompressFirstFv ();\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ // Load the DXE Core and transfer control to it\r
+ Status = LoadDxeCoreFromFv (NULL, 0);\r
+ ASSERT_EFI_ERROR (Status);\r
+}\r
+\r
+VOID\r
+CEntryPoint (\r
+ IN UINTN MpId,\r
+ IN UINTN UefiMemoryBase,\r
+ IN UINTN StacksBase\r
+ )\r
+{\r
+ UINT64 StartTimeStamp;\r
+\r
+ // Initialize the platform specific controllers\r
+ ArmPlatformInitialize (MpId);\r
+\r
+ if (PerformanceMeasurementEnabled ()) {\r
+ // Initialize the Timer Library to setup the Timer HW controller\r
+ TimerConstructor ();\r
+ // We cannot call yet the PerformanceLib because the HOB List has not been initialized\r
+ StartTimeStamp = GetPerformanceCounter ();\r
+ } else {\r
+ StartTimeStamp = 0;\r
+ }\r
+\r
+ // Data Cache enabled on Primary core when MMU is enabled.\r
+ ArmDisableDataCache ();\r
+ // Invalidate Data cache\r
+ ArmInvalidateDataCache ();\r
+ // Invalidate instruction cache\r
+ ArmInvalidateInstructionCache ();\r
+ // Enable Instruction Caches on all cores.\r
+ ArmEnableInstructionCache ();\r
+\r
+ PrimaryMain (UefiMemoryBase, StacksBase, StartTimeStamp);\r
+\r
+ // DXE Core should always load and never return\r
+ ASSERT (FALSE);\r
+}\r
--- /dev/null
+/** @file\r
+*\r
+* Copyright (c) 2011-2015, ARM Limited. All rights reserved.\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
+#ifndef _PREPI_H_\r
+#define _PREPI_H_\r
+\r
+#include <PiPei.h>\r
+\r
+#include <Library/PcdLib.h>\r
+#include <Library/ArmLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/IoLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/HobLib.h>\r
+#include <Library/SerialPortLib.h>\r
+#include <Library/ArmPlatformLib.h>\r
+\r
+#define SerialPrint(txt) SerialPortWrite (txt, AsciiStrLen(txt)+1);\r
+\r
+extern UINT64 mSystemMemoryEnd;\r
+\r
+RETURN_STATUS\r
+EFIAPI\r
+TimerConstructor (\r
+ VOID\r
+ );\r
+\r
+VOID\r
+PrePiMain (\r
+ IN UINTN UefiMemoryBase,\r
+ IN UINTN StacksBase,\r
+ IN UINT64 StartTimeStamp\r
+ );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+MemoryPeim (\r
+ IN EFI_PHYSICAL_ADDRESS UefiMemoryBase,\r
+ IN UINT64 UefiMemorySize\r
+ );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PlatformPeim (\r
+ VOID\r
+ );\r
+\r
+VOID\r
+PrimaryMain (\r
+ IN UINTN UefiMemoryBase,\r
+ IN UINTN StacksBase,\r
+ IN UINT64 StartTimeStamp\r
+ );\r
+\r
+VOID\r
+SecondaryMain (\r
+ IN UINTN MpId\r
+ );\r
+\r
+// Either implemented by PrePiLib or by MemoryInitPei\r
+VOID\r
+BuildMemoryTypeInformationHob (\r
+ VOID\r
+ );\r
+\r
+EFI_STATUS\r
+GetPlatformPpi (\r
+ IN EFI_GUID *PpiGuid,\r
+ OUT VOID **Ppi\r
+ );\r
+\r
+// Initialize the Architecture specific controllers\r
+VOID\r
+ArchInitialize (\r
+ VOID\r
+ );\r
+\r
+VOID\r
+EFIAPI\r
+ProcessLibraryConstructorList (\r
+ VOID\r
+ );\r
+\r
+#endif /* _PREPI_H_ */\r