diff --git a/FvWrapper.ld b/FvWrapper.ld new file mode 100644 index 00000000..e5fb8d00 --- /dev/null +++ b/FvWrapper.ld @@ -0,0 +1,10 @@ +ENTRY(_start); + +SECTIONS +{ + _start = 0x00200000; + . = 0x00200000; + .data : { + *(.data) + } +} \ No newline at end of file diff --git a/Library/Lumia950XLPlatformLib/Dragonboard820cPlatformLib.inf b/Library/Lumia950XLPlatformLib/Dragonboard820cPlatformLib.inf new file mode 100644 index 00000000..e69de29b diff --git a/Library/MemoryInitPeiLib/MemoryInitPeiLib.c b/Library/MemoryInitPeiLib/MemoryInitPeiLib.c new file mode 100644 index 00000000..9f19b394 --- /dev/null +++ b/Library/MemoryInitPeiLib/MemoryInitPeiLib.c @@ -0,0 +1,154 @@ +/** @file +* +* Copyright (c) 2011-2015, 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 + +#include +#include +#include +#include +#include +#include + +extern UINT64 mSystemMemoryEnd; + +VOID +BuildMemoryTypeInformationHob ( + VOID + ); + +STATIC +VOID +InitMmu ( + IN ARM_MEMORY_REGION_DESCRIPTOR *MemoryTable + ) +{ + + VOID *TranslationTableBase; + UINTN TranslationTableSize; + RETURN_STATUS Status; + + //Note: Because we called PeiServicesInstallPeiMemory() before to call InitMmu() the MMU Page Table resides in + // DRAM (even at the top of DRAM as it is the first permanent memory allocation) + Status = ArmConfigureMmu (MemoryTable, &TranslationTableBase, &TranslationTableSize); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "Error: Failed to enable MMU\n")); + } +} + +STATIC +VOID +AddAndReserved(ARM_MEMORY_REGION_DESCRIPTOR *Desc) +{ + BuildResourceDescriptorHob ( + EFI_RESOURCE_SYSTEM_MEMORY, + EFI_RESOURCE_ATTRIBUTE_PRESENT | + EFI_RESOURCE_ATTRIBUTE_INITIALIZED | + EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE | + EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE | + EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE | + EFI_RESOURCE_ATTRIBUTE_TESTED, + Desc->PhysicalBase, + Desc->Length + ); + + BuildMemoryAllocationHob ( + Desc->PhysicalBase, + Desc->Length, + EfiReservedMemoryType + ); +} + +STATIC +VOID +AddAndMmio(ARM_MEMORY_REGION_DESCRIPTOR *Desc) +{ + BuildResourceDescriptorHob ( + EFI_RESOURCE_SYSTEM_MEMORY, + (EFI_RESOURCE_ATTRIBUTE_PRESENT | + EFI_RESOURCE_ATTRIBUTE_INITIALIZED | + EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE | + EFI_RESOURCE_ATTRIBUTE_TESTED), + Desc->PhysicalBase, + Desc->Length + ); + + BuildMemoryAllocationHob ( + Desc->PhysicalBase, + Desc->Length, + EfiMemoryMappedIO + ); +} + +/*++ + +Routine Description: + + + +Arguments: + + FileHandle - Handle of the file being invoked. + PeiServices - Describes the list of possible PEI Services. + +Returns: + + Status - EFI_SUCCESS if the boot mode could be set + +--*/ +EFI_STATUS +EFIAPI +MemoryPeim ( + IN EFI_PHYSICAL_ADDRESS UefiMemoryBase, + IN UINT64 UefiMemorySize + ) +{ + ARM_MEMORY_REGION_DESCRIPTOR *MemoryTable; + + // Get Virtual Memory Map from the Platform Library + ArmPlatformGetVirtualMemoryMap (&MemoryTable); + + // Ensure PcdSystemMemorySize has been set + ASSERT (PcdGet64 (PcdSystemMemorySize) != 0); + + // Reserved FD + Trusted Firmware region + AddAndReserved(&MemoryTable[0]); + AddAndReserved(&MemoryTable[1]); + + // Usable memory. + BuildResourceDescriptorHob ( + EFI_RESOURCE_SYSTEM_MEMORY, + EFI_RESOURCE_ATTRIBUTE_PRESENT | + EFI_RESOURCE_ATTRIBUTE_INITIALIZED | + EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE | + EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE | + EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE | + EFI_RESOURCE_ATTRIBUTE_TESTED, + MemoryTable[2].PhysicalBase, + MemoryTable[2].Length + ); + + AddAndReserved(&MemoryTable[3]); + AddAndMmio(&MemoryTable[4]); + + // Build Memory Allocation Hob + InitMmu (MemoryTable); + + if (FeaturePcdGet (PcdPrePiProduceMemoryTypeInformationHob)) { + // Optional feature that helps prevent EFI memory map fragmentation. + BuildMemoryTypeInformationHob (); + } + + return EFI_SUCCESS; +} \ No newline at end of file diff --git a/Library/MemoryInitPeiLib/PeiMemoryAllocationLib.inf b/Library/MemoryInitPeiLib/PeiMemoryAllocationLib.inf new file mode 100644 index 00000000..38cc9235 --- /dev/null +++ b/Library/MemoryInitPeiLib/PeiMemoryAllocationLib.inf @@ -0,0 +1,50 @@ +#/** @file +# +# Copyright (c) 2011-2014, ARM Ltd. All rights reserved.
+# Copyright (c) 2016, Linaro, Ltd. 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. +# +#**/ + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = MemoryInitPeiLib + FILE_GUID = 4bbc9c10-a100-43fb-8311-332ba497d1b4 + MODULE_TYPE = BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = MemoryInitPeiLib|SEC PEIM + +[Sources] + MemoryInitPeiLib.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + EmbeddedPkg/EmbeddedPkg.dec + ArmPkg/ArmPkg.dec + ArmPlatformPkg/ArmPlatformPkg.dec + +[LibraryClasses] + DebugLib + HobLib + ArmMmuLib + ArmPlatformLib + +[Guids] + gEfiMemoryTypeInformationGuid + +[FeaturePcd] + gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob + +[FixedPcd] + gArmTokenSpaceGuid.PcdSystemMemoryBase + gArmTokenSpaceGuid.PcdSystemMemorySize + +[Depex] + TRUE diff --git a/Lumia950XL.dsc b/Lumia950XL.dsc new file mode 100644 index 00000000..2557f357 --- /dev/null +++ b/Lumia950XL.dsc @@ -0,0 +1,205 @@ +# +# Copyright (c) 2011-2015, ARM Limited. All rights reserved. +# Copyright (c) 2014, Linaro Limited. All rights reserved. +# Copyright (c) 2015 - 2016, Intel Corporation. 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. +# +# + +################################################################################ +# +# Defines Section - statements that will be processed to create a Makefile. +# +################################################################################ +[Defines] + PLATFORM_NAME = Lumia950XL + PLATFORM_GUID = b6325ac2-9f3f-4b1d-b129-ac7b35ddde60 + PLATFORM_VERSION = 0.1 + DSC_SPECIFICATION = 0x00010005 + OUTPUT_DIRECTORY = Build/Lumia950XL-$(ARCH) + SUPPORTED_ARCHITECTURES = AARCH64|ARM + BUILD_TARGETS = DEBUG|RELEASE + SKUID_IDENTIFIER = DEFAULT + FLASH_DEFINITION = Lumia950XLPkg/Lumia950XL.fdf + +[BuildOptions.common.EDKII.DXE_CORE,BuildOptions.common.EDKII.DXE_DRIVER,BuildOptions.common.EDKII.UEFI_DRIVER,BuildOptions.common.EDKII.UEFI_APPLICATION] + GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000 + +[BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER] + GCC:*_*_ARM_DLINK_FLAGS = -z common-page-size=0x1000 + GCC:*_*_AARCH64_DLINK_FLAGS = -z common-page-size=0x1000 + RVCT:*_*_ARM_DLINK_FLAGS = --scatter $(EDK_TOOLS_PATH)/Scripts/Rvct-Align4K.sct + +[PcdsFeatureFlag.common] + gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable|TRUE + gEfiMdePkgTokenSpaceGuid.PcdDriverDiagnosticsDisable|TRUE + gEfiMdePkgTokenSpaceGuid.PcdComponentName2Disable|TRUE + gEfiMdePkgTokenSpaceGuid.PcdDriverDiagnostics2Disable|TRUE + gEmbeddedTokenSpaceGuid.PcdCacheEnable|TRUE + gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob|TRUE + gArmTokenSpaceGuid.PcdCpuDxeProduceDebugSupport|FALSE + gEfiMdeModulePkgTokenSpaceGuid.PcdTurnOffUsbLegacySupport|TRUE + gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE + gEfiMdeModulePkgTokenSpaceGuid.PcdSupportUpdateCapsuleReset|TRUE + +[PcdsFixedAtBuild.common] + gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVendor|L"Little Moe, LLC." + gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString|L"3.50" + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemId|"QCOM " + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemTableId|0x324B44454D4F4351 + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemRevision|0x00000001 + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorId|0x4D4F4351 + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorRevision|0x00000001 + + gQcomTokenSpaceGuid.PcdSystemMfrStr|"Qualcomm Inc." + gQcomTokenSpaceGuid.PcdSystemProductNameStr|"Lumia 950 XL" + gQcomTokenSpaceGuid.PcdSystemProductFamilyStr|"MTP" + gQcomTokenSpaceGuid.DisableWriteProtect|TRUE + + # Required by UART library + gQcomTokenSpaceGuid.UartPlatform|"MSM8994" + + gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize|32 + gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize|0 + gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength|1000000 + gEfiMdePkgTokenSpaceGuid.PcdMaximumAsciiStringLength|1000000 + gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength|1000000 + gEfiMdePkgTokenSpaceGuid.PcdSpinLockTimeout|10000000 + gEfiMdePkgTokenSpaceGuid.PcdDebugClearMemoryValue|0xAF + gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask|1 + gEfiMdePkgTokenSpaceGuid.PcdPostCodePropertyMask|0 + gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|320 + gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2f + gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x800fee0f + gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x07 + gEmbeddedTokenSpaceGuid.PcdEmbeddedAutomaticBootCommand|"" + gEmbeddedTokenSpaceGuid.PcdEmbeddedDefaultTextColor|0x07 + gEmbeddedTokenSpaceGuid.PcdEmbeddedMemVariableStoreSize|0x10000 + gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory|0 + gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIMemoryNVS|0 + gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiReservedMemoryType|0 + gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData|80 + gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode|40 + gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesCode|400 + gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesData|800 + gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderCode|10 + gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderData|0 + + gQcomTokenSpaceGuid.PcdMemoryBase|0x00000000 # Starting address + gQcomTokenSpaceGuid.PcdMemorySize|0xC0000000 # 3GB + gQcomTokenSpaceGuid.PcdHLOSMemoryBaseOffset|0x0F200000 # remaining memory after this is HLOS + gQcomTokenSpaceGuid.PcdSmemBaseAddress|0x06A00000 + gQcomTokenSpaceGuid.PcdSmemSize|0x00200000 # 2MB + gQcomTokenSpaceGuid.PcdSmemInformation|0x00000002 # 2 = bear-family + gQcomTokenSpaceGuid.PcdMaxMemRegions|64 + + gEmbeddedTokenSpaceGuid.PcdPrePiStackBase|0x00C00000 + gEmbeddedTokenSpaceGuid.PcdPrePiStackSize|0x00040000 # 256K stack + + gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE + + gArmTokenSpaceGuid.PcdCpuVectorBaseAddress|0x00C40000 + gArmTokenSpaceGuid.PcdSystemMemorySize|0xC0000000 # 3GB + gArmTokenSpaceGuid.PcdArmArchTimerFreqInHz|19200000 + gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum|18 + gArmTokenSpaceGuid.PcdArmArchTimerIntrNum|19 + gEmbeddedTokenSpaceGuid.PcdInterruptBaseAddress|0x09bc0000 + gArmTokenSpaceGuid.PcdGicDistributorBase|0x09bc0000 + gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase|0x09c00000 + # gArmPlatformTokenSpaceGuid.PcdCoreCount|4 + + # According to XBL report (S - Core 0 Frequency, 1228 MHz) + gQcomTokenSpaceGuid.PcdAppsProcFrequencyMhz|1228 + +[LibraryClasses.common] + ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf + ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf + ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerPhyCounterLib/ArmGenericTimerPhyCounterLib.inf + ArmDisassemblerLib|ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf + ArmGicLib|ArmPkg/Drivers/ArmGic/ArmGicLib.inf + ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf + ArmGicArchLib|ArmPkg/Library/ArmGicArchLib/ArmGicArchLib.inf + BaseLib|MdePkg/Library/BaseLib/BaseLib.inf + BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf + BaseSynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf + BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf + BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf + CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf + CacheMaintenanceLib|ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.inf + CompilerIntrinsicsLib|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf + CpuExceptionHandlerLib|ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.inf + CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf + CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf + DefaultExceptionHandlerLib|ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf + DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf + DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf + DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf + DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf + ExtractGuidedSectionLib|EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.inf + EfiResetSystemLib|ArmPkg/Library/ArmPsciResetSystemLib/ArmPsciResetSystemLib.inf + FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf + FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf + HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf + HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf + TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf + IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf + LzmaDecompressLib|IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf + NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf + DpcLib|MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf + UdpIoLib|MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf + IpIoLib|MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.inf + PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf + PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull.inf + PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf + PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf + PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf + PrePiLib|EmbeddedPkg/Library/PrePiLib/PrePiLib.inf + PrePiHobListPointerLib|ArmPlatformPkg/Library/PrePiHobListPointerLib/PrePiHobListPointerLib.inf + PrePiMemoryAllocationLib|EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf + PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf + SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf + SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf + SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf + UefiLib|MdePkg/Library/UefiLib/UefiLib.inf + UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf + UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf + UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf + UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf + UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf + UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf + UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf + UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf + UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf + TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf + AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf + VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf + + DebugLib|DragonboardVendorPkg/Library/DebugLib/DebugLib.inf + FBPTLib|DragonboardVendorPkg/Library/FBPTLib/FBPTLib.inf + QcomBaseLib|DragonboardVendorPkg/Library/QcomBaseLib/QcomBaseLib.inf + ProcLib|DragonboardVendorPkg/Library/ProcLib/ProcLib.inf + ShLib|DragonboardVendorPkg/Library/ShLib/ShLibMgr.inf + TargetResetLib|DragonboardVendorPkg/Library/TargetResetLib/TargetResetLib.inf + SPMILib|DragonboardPkg/Library/SPMILibV2/SPMILib.inf + PmicShutdownLibBoot|DragonboardVendorPkg/Library/PmicShutdownLib/PmicShutdownBoottimeLib.inf + + SerialPortLib|Lumia950XLPkg/Library/FrameBufferSerialPortLib/FrameBufferSerialPortLib.inf + +[LibraryClasses.common.SEC] + HobLib|EmbeddedPkg/Library/PrePiHobLib/PrePiHobLib.inf + MemoryAllocationLib|EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf + PrePiMemoryAllocationLib|EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf + PrePiHobListPointerLib|ArmPlatformPkg/Library/PrePiHobListPointerLib/PrePiHobListPointerLib.inf + PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf + + +[Components.common] + # Security. To be replaced with general ARM PEI + Lumia950XLPkg/Sec/Sec.inf \ No newline at end of file diff --git a/Lumia950XL.fdf b/Lumia950XL.fdf new file mode 100644 index 00000000..f4d74543 --- /dev/null +++ b/Lumia950XL.fdf @@ -0,0 +1,104 @@ +[FD.MSM8994_EFI] +BaseAddress = 0x00200000|gArmTokenSpaceGuid.PcdFdBaseAddress #The base address of the FLASH Device. +Size = 0x00120000|gArmTokenSpaceGuid.PcdFdSize #The size in bytes of the FLASH Device +ErasePolarity = 1 +BlockSize = 0x200 +NumBlocks = 0x900 + +# 512 bytes of configuration header & 8 bytes of image header +0x00000000|0x00120000 +gArmTokenSpaceGuid.PcdFvBaseAddress|gArmTokenSpaceGuid.PcdFvSize +FV = FVMAIN_COMPACT + +[FV.FvMain] +FvNameGuid = 9a15aa37-d555-4a4e-b541-86391ff68164 +BlockSize = 0x40 +NumBlocks = 0 # This FV gets compressed so make it just big enough +FvAlignment = 8 # FV alignment and FV attributes setting. +ERASE_POLARITY = 1 +MEMORY_MAPPED = TRUE +STICKY_WRITE = TRUE +LOCK_CAP = TRUE +LOCK_STATUS = TRUE +WRITE_DISABLED_CAP = TRUE +WRITE_ENABLED_CAP = TRUE +WRITE_STATUS = TRUE +WRITE_LOCK_CAP = TRUE +WRITE_LOCK_STATUS = TRUE +READ_DISABLED_CAP = TRUE +READ_ENABLED_CAP = TRUE +READ_STATUS = TRUE +READ_LOCK_CAP = TRUE +READ_LOCK_STATUS = TRUE + +[FV.TOOLS] +BlockSize = 0x40 +NumBlocks = 0 # This FV gets compressed so make it just big enough +FvAlignment = 8 +ERASE_POLARITY = 1 +MEMORY_MAPPED = TRUE +STICKY_WRITE = TRUE +LOCK_CAP = TRUE +LOCK_STATUS = TRUE +WRITE_DISABLED_CAP = TRUE +WRITE_ENABLED_CAP = TRUE +WRITE_STATUS = TRUE +WRITE_LOCK_CAP = TRUE +WRITE_LOCK_STATUS = TRUE +READ_DISABLED_CAP = TRUE +READ_ENABLED_CAP = TRUE +READ_STATUS = TRUE +READ_LOCK_CAP = TRUE +READ_LOCK_STATUS = TRUE + +[FV.FVMAIN_COMPACT] +FvAlignment = 8 +ERASE_POLARITY = 1 +MEMORY_MAPPED = TRUE +STICKY_WRITE = TRUE +LOCK_CAP = TRUE +LOCK_STATUS = TRUE +WRITE_DISABLED_CAP = TRUE +WRITE_ENABLED_CAP = TRUE +WRITE_STATUS = TRUE +WRITE_LOCK_CAP = TRUE +WRITE_LOCK_STATUS = TRUE +READ_DISABLED_CAP = TRUE +READ_ENABLED_CAP = TRUE +READ_STATUS = TRUE +READ_LOCK_CAP = TRUE +READ_LOCK_STATUS = TRUE + + INF Lumia950XLPkg/Sec/Sec.inf + + FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 { + SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRED = TRUE { + SECTION FV_IMAGE = FVMAIN + } + } + +[FV.TOOLS_COMPACT] +FvAlignment = 8 +ERASE_POLARITY = 1 +MEMORY_MAPPED = TRUE +STICKY_WRITE = TRUE +LOCK_CAP = TRUE +LOCK_STATUS = TRUE +WRITE_DISABLED_CAP = TRUE +WRITE_ENABLED_CAP = TRUE +WRITE_STATUS = TRUE +WRITE_LOCK_CAP = TRUE +WRITE_LOCK_STATUS = TRUE +READ_DISABLED_CAP = TRUE +READ_ENABLED_CAP = TRUE +READ_STATUS = TRUE +READ_LOCK_CAP = TRUE +READ_LOCK_STATUS = TRUE + + FILE FV_IMAGE = DB708324-2C6B-4925-92E8-CCDE88DC7B62 { + SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRED = TRUE { + SECTION FV_IMAGE = TOOLS + } + } + +!include Lumia950XL.fdf.inc \ No newline at end of file diff --git a/Lumia950XL.fdf.inc b/Lumia950XL.fdf.inc new file mode 100644 index 00000000..5ff30047 --- /dev/null +++ b/Lumia950XL.fdf.inc @@ -0,0 +1,125 @@ +# +# Copyright (c) 2011-2015, ARM Limited. All rights reserved. +# Copyright (c) 2014-2016, Linaro Limited. All rights reserved. +# Copyright (c) 2015 - 2016, Intel Corporation. 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. +# + +################################################################################ +# +# Rules are use with the [FV] section's module INF type to define +# how an FFS file is created for a given INF file. The following Rule are the default +# rules for the different module type. User can add the customized rules to define the +# content of the FFS file. +# +################################################################################ + + +############################################################################ +# Example of a DXE_DRIVER FFS file with a Checksum encapsulation section # +############################################################################ +# +#[Rule.Common.DXE_DRIVER] +# FILE DRIVER = $(NAMED_GUID) { +# DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex +# COMPRESS PI_STD { +# GUIDED { +# PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi +# UI STRING="$(MODULE_NAME)" Optional +# VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) +# } +# } +# } +# +############################################################################ + +[Rule.Common.SEC] + FILE SEC = $(NAMED_GUID) RELOCS_STRIPPED FIXED { + TE TE Align = Auto $(INF_OUTPUT)/$(MODULE_NAME).efi + } + +[Rule.Common.PEI_CORE] + FILE PEI_CORE = $(NAMED_GUID) FIXED { + TE TE Align = Auto $(INF_OUTPUT)/$(MODULE_NAME).efi + UI STRING ="$(MODULE_NAME)" Optional + } + +[Rule.Common.PEIM] + FILE PEIM = $(NAMED_GUID) FIXED { + PEI_DEPEX PEI_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex + TE TE Align = Auto $(INF_OUTPUT)/$(MODULE_NAME).efi + UI STRING="$(MODULE_NAME)" Optional + } + +[Rule.Common.PEIM.TIANOCOMPRESSED] + FILE PEIM = $(NAMED_GUID) DEBUG_MYTOOLS_IA32 { + PEI_DEPEX PEI_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex + GUIDED A31280AD-481E-41B6-95E8-127F4C984779 PROCESSING_REQUIRED = TRUE { + PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi + UI STRING="$(MODULE_NAME)" Optional + } + } + +[Rule.Common.DXE_CORE] + FILE DXE_CORE = $(NAMED_GUID) { + PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi + UI STRING="$(MODULE_NAME)" Optional + } + +[Rule.Common.UEFI_DRIVER] + FILE DRIVER = $(NAMED_GUID) { + DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex + PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi + UI STRING="$(MODULE_NAME)" Optional + } + +[Rule.Common.DXE_DRIVER] + FILE DRIVER = $(NAMED_GUID) { + DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex + PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi + UI STRING="$(MODULE_NAME)" Optional + RAW ACPI Optional |.acpi + RAW ASL Optional |.aml + } + +[Rule.Common.DXE_RUNTIME_DRIVER] + FILE DRIVER = $(NAMED_GUID) { + DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex + PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi + UI STRING="$(MODULE_NAME)" Optional + } + +[Rule.Common.UEFI_APPLICATION] + FILE APPLICATION = $(NAMED_GUID) { + UI STRING ="$(MODULE_NAME)" Optional + PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi + } + +[Rule.Common.UEFI_DRIVER.BINARY] + FILE DRIVER = $(NAMED_GUID) { + DXE_DEPEX DXE_DEPEX Optional |.depex + PE32 PE32 |.efi + UI STRING="$(MODULE_NAME)" Optional + VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) + } + +[Rule.Common.UEFI_APPLICATION.BINARY] + FILE APPLICATION = $(NAMED_GUID) { + PE32 PE32 |.efi + UI STRING="$(MODULE_NAME)" Optional + VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER) + } + +[Rule.Common.USER_DEFINED.ACPITABLE] + FILE FREEFORM = $(NAMED_GUID) { + RAW ACPI |.acpi + RAW ASL |.aml + UI STRING="$(MODULE_NAME)" Optional + } diff --git a/Lumia950XLPkg.dec b/Lumia950XLPkg.dec new file mode 100644 index 00000000..44bd2d24 --- /dev/null +++ b/Lumia950XLPkg.dec @@ -0,0 +1,18 @@ +[Defines] + DEC_SPECIFICATION = 0x00010005 + PACKAGE_NAME = Lumia950XLPkg + PACKAGE_GUID = 5fd522a5-b671-429f-957f-75113dd02435 + PACKAGE_VERSION = 0.1 + +[Includes.common] + Include # Root include for the package + +[Guids.common] + gLumia950XLPkgTokenSpaceGuid = { 0x4c59628e, 0x0a8a, 0x4099, { 0x8d, 0xe5, 0xf2, 0x08, 0xff, 0x80, 0xc4, 0xbf } } + +[PcdsFixedAtBuild.common] + # Simple FrameBuffer + gLumia950XLPkgTokenSpaceGuid.PcdMipiFrameBufferAddress|0x00400000|UINT32|0x99 + gLumia950XLPkgTokenSpaceGuid.PcdMipiFrameBufferWidth|1080|UINT32|0x100 + gLumia950XLPkgTokenSpaceGuid.PcdMipiFrameBufferHeight|1920|UINT32|0x101 + gLumia950XLPkgTokenSpaceGuid.PcdMipiFrameBufferPixelBpp|32|UINT32|0x102 \ No newline at end of file diff --git a/Sec/ModuleEntryPoint.S b/Sec/ModuleEntryPoint.S new file mode 100644 index 00000000..b95b5dff --- /dev/null +++ b/Sec/ModuleEntryPoint.S @@ -0,0 +1,135 @@ +//------------------------------------------------------------------------------ +// +// Copyright (c) 2012-2014, Qualcomm Technologies Inc. All rights reserved. +// Portions Copyright (c) 2011-2013, 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. +// +//------------------------------------------------------------------------------ + +//============================================================================= +// EDIT HISTORY +// +// +// when who what, where, why +// -------- --- --------------------------------------------------------- +// 12/10/14 bh Invalidate TLB/I-cache earlier, leave data cache after stack setup +// 12/03/14 bh Invalidate TLB +// 09/18/14 na Invalidate cache prior to enabling it +// 07/28/14 lm Add PRE_SIL for 8909 +// 07/25/14 na Do not trap SIMD instructions +// 05/05/14 vk Setup exception vectors +// 04/30/14 vk Add PRE_SIL for 8916 +// 03/03/14 vk Disable MMU and interrupts first +// 02/14/14 vk Initial revision +// +//============================================================================ + + +#include +#include +#include + +#define LoadConstantToReg(Data, Reg) \ + ldr Reg, =Data + +.text +.align 3 + +GCC_ASM_IMPORT (CEntryPoint) +GCC_ASM_EXPORT (_ModuleEntryPoint) +GCC_ASM_IMPORT (ArmWriteCpacr) +GCC_ASM_IMPORT (ArmEnableInstructionCache) +GCC_ASM_IMPORT (ArmEnableDataCache) +GCC_ASM_IMPORT (ArmInvalidateTlb) + +.global _StackBase +.global _StackSize +.global CNTFRQ + +_StackBase: + .quad FixedPcdGet32(PcdPrePiStackBase) + +_StackSize: + .quad FixedPcdGet32(PcdPrePiStackSize) + +CNTFRQ: + .quad 0x0124F800 + +_ModuleEntryPoint: + mov x0, #0 + + /* First ensure all interrupts are disabled */ + bl ASM_PFX(ArmDisableInterrupts) + + /* Ensure that the MMU and caches are off */ + bl ASM_PFX(ArmDisableCachesAndMmu) + + /* Invalide I-Cache */ + bl ASM_PFX(ArmInvalidateInstructionCache) + + /* Invalidate TLB */ + bl ASM_PFX(ArmInvalidateTlb) + + /* Get current EL in x0 */ + mrs x0, CurrentEl + + /* Check if we are in EL1, if yes skip other EL init */ + cmp x0, #0x4 + b.eq _Start_EL1_NS + + cmp x0, #0x5 + b.eq _Start_EL1_NS + + /* We should have EL1 initialized */ + b dead + +_Start_EL1_NS: +_SetupExceptionVector: + LoadConstantToReg (FixedPcdGet32(PcdCpuVectorBaseAddress), x0) + ldr x1, dead + mov x2, #0 + +_FillVectors: + str x1, [x0, x2] + adds x2, x2, #8 /* Fill every 8 byte */ + cmp x2, #0x800 /* Vector Table Size */ + bne _FillVectors + + /* Update VBAR */ + msr vbar_el1, x0 /* End _SetupExceptionVector */ + +_DonNotTrap_VFP_SIMD: + mrs x0, CPACR_EL1 + orr x0, x0, #0x300000 /* Set FPEN Bits 20 and 21 for not trapping FP and Advanced SIMD instructions */ + msr CPACR_EL1, x0 + +_SetupPrimaryCoreStack: + ldr x0, _StackBase /* Stack base arg0 */ + ldr x1, _StackSize /* Stack size arg1 */ + + add x4, x0, x1 + add sp, x4, #0 + +_EnableCache: + bl ArmInvalidateDataCache + bl ASM_PFX(ArmEnableInstructionCache) + bl ASM_PFX(ArmEnableDataCache) + +_PrepareArguments: + /* x0 = _StackBase and x1 = _StackSize */ + ldr x0, _StackBase /* Stack base arg0 */ + ldr x1, _StackSize /* Stack size arg1 */ + + bl CEntryPoint + +.align 3 +dead: + b dead /* We should never get here */ + diff --git a/Sec/Pi.c b/Sec/Pi.c new file mode 100644 index 00000000..f62a7fdf --- /dev/null +++ b/Sec/Pi.c @@ -0,0 +1,144 @@ +// Pi.c: Entry point for SEC(Security). + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +// #include + +#ifndef _BGRA8888_COLORS_ +#define _BGRA8888_COLORS_ +#define BGRA8888_BLACK 0xff000000 +#define BGRA8888_WHITE 0xffffffff +#define BGRA8888_CYAN 0xff00ffff +#define BGRA8888_BLUE 0xff0000ff +#define BGRA8888_SILVER 0xffc0c0c0 +#define BGRA8888_YELLOW 0xffffff00 +#define BGRA8888_ORANGE 0xffffa500 +#define BGRA8888_RED 0xffff0000 +#define BGRA8888_GREEN 0xff00ff00 +#endif + +#ifndef _FB_ADDRESS_ +#define _FB_ADDRESS_ +#define FB_ADDR 0x400000 +#endif + +STATIC VOID +UartInit +( + VOID +) +{ + UINT32 AbsTimems; + AbsTimems = GetTimerCountms(); + SerialPortInitialize(); + DEBUG ((EFI_D_ERROR, "\nTianoCore on 950XL (AArch64)\n", AbsTimems)); + DEBUG ((EFI_D_ERROR, "UEFI Start : %d ms\n\n", AbsTimems)); +} + +/* Initialize the cycle counter to track performance */ +STATIC VOID +StartCyclCounter +( + VOID +) +{ + UINTN RegVal; + UINT64 Val; + UINT64 Scale; + UINT32 AppsProcClkMhz; + + /* User mode enable to read in non secure mode */ + WriteUserEnReg (1); + + /* Reset counters */ + RegVal = (0x41 << 24) | /* IMP */ + (4 << 11) | /* N */ + (1 << 3) | /* 1/64 */ + (1 << 2); /* Reset CCNT */ + WritePMonCtlReg (RegVal); + + ReadCycleCntReg(); + + /* Scale bootcounter running at 32KHz to CPU frequency in MHz, counting every 64 cycles. + Get the Scale to be accurate to 3 decimal places by multiplying it with 2^10. + Then divide by 2^10 (right shift by 10) to nullify the multiplication done before and + divide by 64 (Right shift 6) => Right shift by 16 to set Cycle Counter Start Value */ + AppsProcClkMhz = PcdGet32(PcdAppsProcFrequencyMhz); + Scale = (AppsProcClkMhz << 10) / 1000; + Val = Scale * BootGetTimeNanoSec(); + Val = (Val >> 16); + WriteCycleCntReg((UINT32)Val); + + /* Check if write went through */ + ReadCycleCntReg(); + + /* Enable Cycle counter */ + WriteCntEnSetReg (((UINT32)1 << 31)); + + /* Check if we start counting */ + ReadCycleCntReg(); + + /* Enable CCNT */ + RegVal = (0x41 << 24) | /* IMP */ + (4 << 11) | /* N */ + (1 << 3) | /* 1/64 */ + (1); /* Enable all counters */ + WritePMonCtlReg(RegVal); + + /* Disable User mode access */ + WriteUserEnReg(0); + + /* Write to TPIDRURW */ + WriteTPIDRURWReg(0x56430000); + + /* Write to TPIDRURO */ + WriteTPIDRUROReg(0); + + /* Example to Read the counter value, Should read small */ + ReadCycleCntReg(); +} + +VOID +Main +( + IN VOID *StackBase, + IN UINTN StackSize +) +{ + + // Initialize UART. + UartInit(); + + // We are done + CpuDeadLoop(); +} + +VOID +CEntryPoint +( + IN VOID *StackBase, + IN UINTN StackSize +) +{ + Main(StackBase, StackSize); +} \ No newline at end of file diff --git a/Sec/ReleaseInfo.S b/Sec/ReleaseInfo.S new file mode 100644 index 00000000..afeccbd4 --- /dev/null +++ b/Sec/ReleaseInfo.S @@ -0,0 +1,53 @@ +//------------------------------------------------------------------------------ +// +// Copyright (c) 2012-2014, Qualcomm Technologies Inc. All rights reserved. +// +//------------------------------------------------------------------------------ + +//============================================================================= +// EDIT HISTORY +// +// +// when who what, where, why +// -------- --- --------------------------------------------------------- +// 05/26/14 vk Add full string to info block +// 01/21/14 vk Align InfoBlkPtr using align directive +// 01/17/14 vk Align InfoBlkPtr +// 10/31/13 vk AARCH64 version +// 12/10/12 yg Add UefiInfoBlk and Format +// 11/02/12 vk Initial revision +// +//============================================================================ + +#include +#define LINE_FEED 0x0A + +#define REL_INF_STRING REL_LABEL_FIELD REL_LABEL " " \ + REL_DATE_FIELD REL_DATE " " \ + BUILD_VER_FIELD BUILD_VER1 " " \ + BUILD_DATE_FIELD BUILD_DATE " " \ + BUILD_TIME_FIELD BUILD_TIME " " + +.text +.align 3 + +.global _ReleaseInfo +.global _UefiInfoBlockPtr +.global _UefiRelInfoString + +.extern _ModuleEntryPoint + +_ReleaseInfo: + b _ModuleEntryPoint + +.align 3 +_UefiInfoBlockPtr: +.quad 0 + +.align 3 +_UefiRelInfoString: + .ascii REL_INF_STRING + +.align 3 +.quad 0 + diff --git a/Sec/Sec.inf b/Sec/Sec.inf new file mode 100644 index 00000000..a199677a --- /dev/null +++ b/Sec/Sec.inf @@ -0,0 +1,78 @@ +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = Sec + FILE_GUID = 8AF09F13-44C5-96EC-1437-DD899CB5EE5D + MODULE_TYPE = SEC + VERSION_STRING = 1.0 + +[Sources.common] + Pi.c + +[Sources.AARCH64] + ReleaseInfo.S | GCC + ModuleEntryPoint.S | GCC + +[BuildOptions.AARCH64] + GCC:*_*_*_CC_FLAGS = -Werror -Wno-error=unused-function + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + EmbeddedPkg/EmbeddedPkg.dec + ArmPkg/ArmPkg.dec + IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec + DragonboardVendorPkg/QcomPkg.dec + Dragonboard820cPkg/Dragonboard820cPkg.dec + +[LibraryClasses] + BaseLib + DebugLib + ArmLib + ArmMmuLib + IoLib + ExtractGuidedSectionLib + LzmaDecompressLib + PeCoffGetEntryPointLib + DebugAgentLib + SerialPortLib + QcomBaseLib + FBPTLib + ProcLib + MemoryAllocationLib + PrePiMemoryAllocationLib + ShLib + PerformanceLib + HobLib + CompilerIntrinsicsLib + +[FeaturePcd] + gEmbeddedTokenSpaceGuid.PcdCacheEnable + +[FixedPcd] + gArmTokenSpaceGuid.PcdCpuVectorBaseAddress + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate + gEmbeddedTokenSpaceGuid.PcdPrePiStackBase + gEmbeddedTokenSpaceGuid.PcdPrePiStackSize + gArmTokenSpaceGuid.PcdFvBaseAddress + gArmTokenSpaceGuid.PcdFvSize + gQcomTokenSpaceGuid.PcdPreAllocatedMemorySize + gQcomTokenSpaceGuid.PcdUefiMemPoolBaseOffset + gQcomTokenSpaceGuid.PcdUefiMemPoolSize + gQcomTokenSpaceGuid.PcdMaxMemRegions + gQcomTokenSpaceGuid.PcdHLOSCrashCookieAddr + gQcomTokenSpaceGuid.PcdAppsProcFrequencyMhz + gQcomTokenSpaceGuid.PcdHLOSMemoryBaseOffset + gQcomTokenSpaceGuid.PcdHLOSMemorySize + gQcomTokenSpaceGuid.PcdEmbeddedFdBaseAddress + gQcomTokenSpaceGuid.PcdUefiInfoBlockOffset + gQcomTokenSpaceGuid.PcdIMemCookiesBase + gQcomTokenSpaceGuid.PcdUefiDebugCookieOffset + gQcomTokenSpaceGuid.PcdUefiDebugCookie + gQcomTokenSpaceGuid.PcdMemorySize + +[Guids] + gQcomMemoryCaptureGuid + gEfiInfoBlkHobGuid + gQcomMemoryCaptureValueGuid + gQcomAbnormalResetOccurredValueGuid + gQcomProdmodeInfoGuid diff --git a/Tools/build-lkimage.ps1 b/Tools/build-lkimage.ps1 new file mode 100644 index 00000000..7fef6ab9 --- /dev/null +++ b/Tools/build-lkimage.ps1 @@ -0,0 +1,55 @@ +#!/usr/bin/pwsh +# This script performs LK image generation (the last step). + +Write-Host "Task: LK Image generation" + +# Check content +$BuildContent = Get-ChildItem -Path "Build/Lumia950XL-AARCH64/**/*.fd" -Recurse + +if ($BuildContent -eq $false) +{ + Write-Error -Message "Build payload is not found." + return -1 +} + +# Set environment variable for further use. +Write-Output "[PRE] Set environment." +$env:PATH="/opt/db-boot-tools:/opt/gcc-linaro-7.2.1-2017.11-x86_64_aarch64-elf/bin:/opt/gcc-linaro-7.2.1-2017.11-x86_64_arm-eabi/bin:/opt/signlk:/opt/skales:$($env:PATH)" + +if ($BuildContent -eq $null) +{ + Write-Warning -Message "Build content not found." + return +} + +# Generate Qualcomm image +$FdFileSystemPath = $BuildContent[0].FullName +$FdDirectory = [System.IO.Path]::GetDirectoryName($FdFileSystemPath) +$ElfDirectory = [System.IO.Path]::Combine($FdDirectory, "ELF") + +$ElfObjPath = [System.IO.Path]::Combine($ElfDirectory, "FD.o") +$ElfPath = [System.IO.Path]::Combine($ElfDirectory, "UEFI.elf") + +# Create directory +if ((Test-Path -Path $ElfDirectory) -eq $false) +{ + Write-Host "[LKBuild] Create ELF build directory." + New-Item -ItemType Directory -Path $ElfDirectory -ErrorAction Stop +} + +# Remove if exists +if (Test-Path -Path $ElfPath) +{ + Remove-Item -Path $ElfPath -Force -ErrorAction Stop +} + +# Run ELF build +Write-Host "[LKBuild] Build ELF image." +aarch64-elf-objcopy -I binary -O elf64-littleaarch64 --binary-architecture aarch64 $FdFileSystemPath $ElfObjPath +aarch64-elf-ld -m aarch64elf $ElfObjPath -T Lumia950XLPkg/FvWrapper.ld -o $ElfPath +Remove-Item -Path $ElfObjPath -ErrorAction SilentlyContinue +if ($ElfPath -eq $null) +{ + Write-Error "[LKBuild] Failed to build ELF image." + return -1 +} diff --git a/Tools/edk2-build.ps1 b/Tools/edk2-build.ps1 new file mode 100644 index 00000000..57f26864 --- /dev/null +++ b/Tools/edk2-build.ps1 @@ -0,0 +1,66 @@ +#!/usr/bin/pwsh +# This script builds EDK2 content. +# EDK2 setup script should be called before invoking this script. + +Param +( + [switch] $Clean, + [switch] $UseNewerGcc +) + +Write-Host "Task: EDK2 build" + +# Check path. +if ((Test-Path -Path "Lumia950XLPkg") -eq $null) +{ + Write-Error "Lumia950XLPkg is not found." + return -1 +} + +# Set environment again. +Write-Output "[EDK2Build] Set environment." +if ($UseNewerGcc) +{ + $env:PATH="/opt/db-boot-tools:/opt/gcc-linaro-7.2.1-2017.11-x86_64_aarch64-elf/bin:/opt/gcc-linaro-7.2.1-2017.11-x86_64_arm-eabi/bin:/opt/signlk:/opt/skales:$($env:PATH)" + $env:GCC5_AARCH64_PREFIX="/opt/gcc-linaro-7.2.1-2017.11-x86_64_aarch64-elf/bin/aarch64-elf-" +} +else +{ + $env:PATH="/opt/db-boot-tools:/opt/gcc-linaro-6.4.1-2017.11-x86_64_aarch64-elf/bin:/opt/gcc-linaro-7.2.1-2017.11-x86_64_arm-eabi/bin:/opt/signlk:/opt/skales:$($env:PATH)" + $env:GCC5_AARCH64_PREFIX="/opt/gcc-linaro-6.4.1-2017.11-x86_64_aarch64-elf/bin/aarch64-elf-" +} + +# Build base tools if not exist (dev). +if (((Test-Path -Path "BaseTools") -eq $false) -or ($Clean -eq $true)) +{ + Write-Output "[EDK2Build] Build base tools." + make -C BaseTools + if (-not $?) + { + Write-Error "[EDK2Build] Base tools target failed." + return $? + } +} + +if ($Clean -eq $true) +{ + Write-Output "[EDK2Build] Clean Lumia950XLPkg." + build -a AARCH64 -p Lumia950XLPkg/Lumia950XL.dsc -t GCC5 clean + + if (-not $?) + { + Write-Error "[EDK2Build] Clean target failed." + return $? + } + + # Apply workaround for "NUL" + Get-ChildItem -Path Build/**/NUL -Recurse | Remove-Item -Force +} + +Write-Output "[EDK2Build] Build Lumia950XLPkg (DEBUG)." +build -a AARCH64 -p Lumia950XLPkg/Lumia950XL.dsc -t GCC5 +if (-not $?) +{ + Write-Error "[EDK2Build] Build target failed." + return $? +} diff --git a/Tools/flash-device.ps1 b/Tools/flash-device.ps1 new file mode 100644 index 00000000..170d5308 --- /dev/null +++ b/Tools/flash-device.ps1 @@ -0,0 +1,20 @@ +#!/usr/bin/pwsh +# This script flashes device. +$Command = Get-Command -Name fastboot -ErrorAction SilentlyContinue +if ($Command -eq $null) +{ + Write-Error "Android Fastboot tool is not found." + return +} + +# Check content +$BuildContent = Get-ChildItem -Path Build/Lumia950XL-AARCH64/**/UEFI.elf -Recurse -ErrorAction SilentlyContinue +if ($BuildContent -eq $null) +{ + Write-Error "FD Payload is not found." + return +} + +# Flash image +fastboot flash boot "$($BuildContent.FullName)" +fastboot reboot