diff --git a/MSM8909Pkg/CommonDsc.dsc.inc b/MSM8909Pkg/CommonDsc.dsc.inc index 853e08a..fc5aa24 100644 --- a/MSM8909Pkg/CommonDsc.dsc.inc +++ b/MSM8909Pkg/CommonDsc.dsc.inc @@ -87,6 +87,8 @@ SemihostLib|ArmPkg/Library/SemihostLib/SemihostLib.inf + ImagePropertiesRecordLib|MdeModulePkg/Library/ImagePropertiesRecordLib/ImagePropertiesRecordLib.inf + TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf @@ -253,7 +255,7 @@ # IO is mapped to memory space, so we use the same size of # PcdPrePiCpuMemorySize # - gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize|44 + gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize|0 gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength|1000000 gEfiMdePkgTokenSpaceGuid.PcdMaximumAsciiStringLength|1000000 gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength|1000000 diff --git a/MSM8909Pkg/Devices/goyavewifi.dsc b/MSM8909Pkg/Devices/goyavewifi.dsc index 50cfa12..8adb825 100644 --- a/MSM8909Pkg/Devices/goyavewifi.dsc +++ b/MSM8909Pkg/Devices/goyavewifi.dsc @@ -27,4 +27,4 @@ gMSM8909PkgTokenSpaceGuid.PcdMipiFrameBufferHeight|600 gMSM8909PkgTokenSpaceGuid.PcdMipiFrameBufferVisibleWidth|1024 gMSM8909PkgTokenSpaceGuid.PcdMipiFrameBufferVisibleHeight|600 - gMSM8909PkgTokenSpaceGuid.PcdMipiFrameBufferPixelBpp|32 \ No newline at end of file + gMSM8909PkgTokenSpaceGuid.PcdMipiFrameBufferPixelBpp|16 \ No newline at end of file diff --git a/MSM8909Pkg/Include/Configuration/DeviceMemoryMap.h b/MSM8909Pkg/Include/Configuration/DeviceMemoryMap.h index a916e11..0cb15a5 100644 --- a/MSM8909Pkg/Include/Configuration/DeviceMemoryMap.h +++ b/MSM8909Pkg/Include/Configuration/DeviceMemoryMap.h @@ -61,13 +61,13 @@ static ARM_MEMORY_REGION_DESCRIPTOR_EX gDeviceMemoryDescriptorEx[] = { //MemBase, MemSize, MemLabel(32 Char.), BuildHob, ResourceType, ResourceAttribute, MemoryType, CacheAttributes //------------- DDR ------}, -{0x80000000, 0x00010000, "HLOS 0", AddMem, SYS_MEM, SYS_MEM_CAP, Conv, WRITE_BACK}, +{0x80000000, 0x00010000, "HLOS 0", AddMem, SYS_MEM, SYS_MEM_CAP, Conv, WRITE_BACK_XN}, {0x80C00000, 0x00040000, "UEFI Stack", AddMem, SYS_MEM, SYS_MEM_CAP, BsData, WRITE_BACK}, {0x80C40000, 0x00010000, "CPU Vectors", AddMem, SYS_MEM, SYS_MEM_CAP, BsCode, WRITE_BACK}, {0x80024000, 0x001DC000, "HLOS 1", AddMem, SYS_MEM, SYS_MEM_CAP, Conv, WRITE_BACK}, {0x80200000, 0x00200000, "UEFI FD", AddMem, SYS_MEM, SYS_MEM_CAP, BsCode, WRITE_BACK}, -{0x9eef4000, 0x00708000, "Display Reserved", AddMem, MEM_RES, WRITE_THROUGH, MaxMem, WRITE_THROUGH_XN}, {0x80D00000, 0x03300000, "HLOS 2", AddMem, SYS_MEM, SYS_MEM_CAP, BsData, WRITE_BACK}, +{0x9eef4000, 0x00708000, "Display Reserved", AddMem, MEM_RES, WRITE_THROUGH, MaxMem, WRITE_THROUGH_XN}, // {0x87800000, 0x00240000, "SMEM", AddMem, MEM_RES, UNCACHEABLE, Reserv, UNCACHED_UNBUFFERED}, //------------- Terminator for MMU ---------- diff --git a/MSM8909Pkg/Library/FrameBufferBltLib/FrameBufferBltLib.c b/MSM8909Pkg/Library/FrameBufferBltLib/FrameBufferBltLib.c index 7f6e5d6..fc6c898 100644 --- a/MSM8909Pkg/Library/FrameBufferBltLib/FrameBufferBltLib.c +++ b/MSM8909Pkg/Library/FrameBufferBltLib/FrameBufferBltLib.c @@ -34,7 +34,7 @@ struct FRAME_BUFFER_CONFIGURE { }; CONST EFI_PIXEL_BITMASK mRgbPixelMasks = { - 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 + 0xf800, 0x07e0, 0x001f, 0x0000 }; CONST EFI_PIXEL_BITMASK mBgrPixelMasks = { diff --git a/MSM8909Pkg/Library/MSM8909PkgLib/MSM8909PkgLib.inf b/MSM8909Pkg/Library/MSM8909PkgLib/MSM8909PkgLib.inf index aa7e85b..6f7ecbe 100644 --- a/MSM8909Pkg/Library/MSM8909PkgLib/MSM8909PkgLib.inf +++ b/MSM8909Pkg/Library/MSM8909PkgLib/MSM8909PkgLib.inf @@ -35,6 +35,7 @@ [Sources.common] MSM8909Pkg.c + MSM8909PkgMem.c [Sources.Arm] Arm/ArmPlatformHelper.S | GCC diff --git a/MSM8909Pkg/Library/MSM8909PkgLib/MSM8909PkgMem.c b/MSM8909Pkg/Library/MSM8909PkgLib/MSM8909PkgMem.c new file mode 100644 index 0000000..2c93609 --- /dev/null +++ b/MSM8909Pkg/Library/MSM8909PkgLib/MSM8909PkgMem.c @@ -0,0 +1,90 @@ +/** @file +* +* Copyright (c) 2011, ARM Limited. All rights reserved. +* Copyright (c) 2019, RUIKAI LIU and MR TUNNEL. 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 +/** + Return the Virtual Memory Map of your platform + This Virtual Memory Map is used by MemoryInitPei Module to initialize the MMU on your platform. + @param[out] VirtualMemoryMap Array of ARM_MEMORY_REGION_DESCRIPTOR describing a Physical-to- + Virtual Memory mapping. This array must be ended by a zero-filled + entry +**/ + +STATIC +VOID +AddHob +( + PARM_MEMORY_REGION_DESCRIPTOR_EX Desc +) +{ + BuildResourceDescriptorHob( + Desc->ResourceType, + Desc->ResourceAttribute, + Desc->Address, + Desc->Length + ); + + BuildMemoryAllocationHob( + Desc->Address, + Desc->Length, + Desc->MemoryType + ); +} + +VOID +ArmPlatformGetVirtualMemoryMap ( + IN ARM_MEMORY_REGION_DESCRIPTOR** VirtualMemoryMap + ) +{ + //TO-DO:ADD MEMORY MAP HERE + PARM_MEMORY_REGION_DESCRIPTOR_EX MemoryDescriptorEx = gDeviceMemoryDescriptorEx; + ARM_MEMORY_REGION_DESCRIPTOR MemoryDescriptor[MAX_ARM_MEMORY_REGION_DESCRIPTOR_COUNT]; + UINTN Index = 0; + + // Run through each memory descriptor + while (MemoryDescriptorEx->Address != (EFI_PHYSICAL_ADDRESS)0xFFFFFFFF) + { + switch (MemoryDescriptorEx->HobOption) + { + case AddMem: + case AddDev: + AddHob(MemoryDescriptorEx); + break; + case NoHob: + default: + goto update; + } + + update: + ASSERT(Index < MAX_ARM_MEMORY_REGION_DESCRIPTOR_COUNT); + + MemoryDescriptor[Index].PhysicalBase = MemoryDescriptorEx->Address; + MemoryDescriptor[Index].VirtualBase = MemoryDescriptorEx->Address; + MemoryDescriptor[Index].Length = MemoryDescriptorEx->Length; + MemoryDescriptor[Index].Attributes = MemoryDescriptorEx->ArmAttributes; + + Index++; + MemoryDescriptorEx++; + } + + // Last one (terminator) + ASSERT(Index < MAX_ARM_MEMORY_REGION_DESCRIPTOR_COUNT); + + *VirtualMemoryMap = MemoryDescriptor; + //ASSERT(0); +} \ No newline at end of file diff --git a/MSM8909Pkg/MSM8909Pkg.dsc b/MSM8909Pkg/MSM8909Pkg.dsc index 02a48a6..71ee562 100644 --- a/MSM8909Pkg/MSM8909Pkg.dsc +++ b/MSM8909Pkg/MSM8909Pkg.dsc @@ -75,7 +75,7 @@ VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf # SimpleFbDxe - FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf + FrameBufferBltLib|MSM8909Pkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf # Platform Drivers SerialPortLib|MSM8909Pkg/Library/FrameBufferSerialPortLib/FrameBufferSerialPortLib.inf diff --git a/MSM8909Pkg/PrePi/Pi.c b/MSM8909Pkg/PrePi/Pi.c index da3452b..f135f9c 100644 --- a/MSM8909Pkg/PrePi/Pi.c +++ b/MSM8909Pkg/PrePi/Pi.c @@ -63,7 +63,6 @@ VOID Main (IN UINT64 StartTimeStamp) MemorySize = FixedPcdGet32(PcdSystemMemorySize); UefiMemoryBase = FixedPcdGet32(PcdUefiMemPoolBase); UefiMemorySize = FixedPcdGet32(PcdUefiMemPoolSize); - StacksSize = FixedPcdGet32(PcdPrePiStackSize); StacksBase = UefiMemoryBase + UefiMemorySize - StacksSize; DEBUG( @@ -120,23 +119,11 @@ VOID Main (IN UINT64 StartTimeStamp) // Assume the FV that contains the SEC (our code) also contains a compressed FV. Status = DecompressFirstFv (); - // ASSERT_EFI_ERROR (Status); - if (EFI_ERROR(Status)) - { - DEBUG((EFI_D_ERROR, "FV does not contains a compressed FV\n")); - }else{ - DEBUG((EFI_D_INFO | EFI_D_LOAD, "FV contains a compressed FV\n")); - } + ASSERT_EFI_ERROR (Status); // Load the DXE Core and transfer control to it Status = LoadDxeCoreFromFv (NULL, 0); - //ASSERT_EFI_ERROR (Status); - if (EFI_ERROR(Status)) - { - DEBUG((EFI_D_ERROR, "Failed to load DXE Core\n")); - }else{ - DEBUG((EFI_D_INFO | EFI_D_LOAD, "Loading DXE Core\n")); - } + ASSERT_EFI_ERROR (Status); } diff --git a/MSM8909Pkg/PrePi/PrePi.inf b/MSM8909Pkg/PrePi/PrePi.inf index d3608ee..68b7e25 100644 --- a/MSM8909Pkg/PrePi/PrePi.inf +++ b/MSM8909Pkg/PrePi/PrePi.inf @@ -24,7 +24,6 @@ [Sources.ARM] ReleaseInfo.S | GCC - ProcessorSupport.S | GCC ModuleEntryPoint.S | GCC [Packages] diff --git a/MSM8909Pkg/PrePi/ProcessorSupport.S b/MSM8909Pkg/PrePi/ProcessorSupport.S deleted file mode 100644 index 868b439..0000000 --- a/MSM8909Pkg/PrePi/ProcessorSupport.S +++ /dev/null @@ -1,117 +0,0 @@ -// ARM Platform support for bootstrapping LK - - .set CTRL_M_BIT, (1 << 0) - .set CTRL_C_BIT, (1 << 2) - .set CTRL_B_BIT, (1 << 7) - .set CTRL_I_BIT, (1 << 12) - .set CACHE_LINE, 64 - - .section "s_ArmDeInitialize", "ax" - - GCC_ASM_EXPORT (ArmDeInitialize) - GCC_ASM_EXPORT (ArmCleanInvalidateCacheRange) - GCC_ASM_EXPORT (ArmReadCntFrq2) - -ArmDeInitialize: - // Disable Branch Prediction - mrc p15, 0, r0, c1, c0, 0 - bic r0, r0, #0x00000800 - mcr p15, 0, r0, c1, c0, 0 - dsb - isb - - // Enter critical section: disable interrupt - cpsid if - isb - - // CLean, invalidate and disable data-cache - dsb - mrc p15, 1, R6, c0, c0, 1 // Read CLIDR - ands R3, R6, #0x7000000 // Mask out all but Level of Coherency (LoC) - mov R3, R3, LSR #23 // Cache level value (naturally aligned) - beq Finished - mov R10, #0 - -Loop1: - add R2, R10, R10, LSR #1 // Work out 3xcachelevel - mov R12, R6, LSR R2 // bottom 3 bits are the Cache type for this level - and R12, R12, #7 // get those 3 bits alone - cmp R12, #2 - blt Skip // no cache or only instruction cache at this level - mcr p15, 2, R10, c0, c0, 0 // write the Cache Size selection register (CSSELR) // OR in 1 for Instruction - isb // isb to sync the change to the CacheSizeID reg - mrc p15, 1, R12, c0, c0, 0 // reads current Cache Size ID register (CCSIDR) - and R2, R12, #7 // extract the line length field - add R2, R2, #4 // add 4 for the line length offset (log2 16 bytes) - ldr R4, =0x3FF - ands R4, R4, R12, LSR #3 // R4 is the max number on the way size (right aligned) - clz R5, R4 // R5 is the bit position of the way size increment - ldr R7, =0x00007FFF - ands R7, R7, R12, LSR #13 // R7 is the max number of the index size (right aligned) - -Loop2: - mov R9, R4 // R9 working copy of the max way size (right aligned) - -Loop3: - orr R0, R10, R9, LSL R5 // factor in the way number and cache number into R11 - orr R0, R0, R7, LSL R2 // factor in the index number - - // ArmCleanInvalidateDataCacheEntryBySetWay - mcr p15, 0, r0, c7, c14, 2 // Clean and Invalidate this line - - subs R9, R9, #1 // decrement the way number - bge Loop3 - subs R7, R7, #1 // decrement the index - bge Loop2 - -Skip: - add R10, R10, #2 // increment the cache number - cmp R3, R10 - bgt Loop1 - -Finished: - dsb - - // Invalidate I-Cache - mcr p15, 0, R0, c7, c5, 0 // Invalidate entire instruction cache - dsb - isb - - // Turn off MMU, I-Cache, D-Cache - mrc p15, 0, r0, c1, c0, 0 // Get control register - bic r0, r0, #CTRL_C_BIT // Disable D Cache - bic r0, r0, #CTRL_I_BIT // Disable I Cache - bic r0, r0, #CTRL_M_BIT // Disable MMU - mcr p15, 0, r0, c1, c0, 0 // Write control register - dsb - isb - - // Flush TLB - mov r0, #0 - mcr p15, 0, r0, c8, c7, 0 - mcr p15, 0, R9, c7, c5, 6 // BPIALL Invalidate Branch predictor array. R9 == NoOp - dsb - isb - - // Return - bx lr - -ArmCleanInvalidateCacheRange: - // cache-ops.S @ lk - dsb - add r2, r0, r1 // Calculate the end address - bic r0, #(CACHE_LINE-1) // Align start with cache line -ArmCleanInvalidateCacheRange0: - mcr p15, 0, r0, c7, c14, 1 // Clean & invalidate cache to PoC by MVA - add r0, r0, #CACHE_LINE - cmp r0, r2 - blo ArmCleanInvalidateCacheRange0 - - mov r0, #0 - dsb - - bx lr - -ArmReadCntFrq: - mrc p15, 0, r0, c14, c0, 0 // Read CNTFRQ - bx lr \ No newline at end of file diff --git a/MSM8909Pkg/PrePi/ProcessorSupport.h b/MSM8909Pkg/PrePi/ProcessorSupport.h deleted file mode 100644 index d497b4c..0000000 --- a/MSM8909Pkg/PrePi/ProcessorSupport.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once -#ifndef _ARM_PROC_SUPPORT_H_ -#define _ARM_PROC_SUPPORT_H_ - -#define CACHE_LINE 64 - -extern void ArmDeInitialize(void); -extern void ArmCleanInvalidateCacheRange(addr_t start, size_t len); - -#endif \ No newline at end of file diff --git a/ci-build.sh b/ci-build.sh index d5a53b2..9e95250 100644 --- a/ci-build.sh +++ b/ci-build.sh @@ -4,7 +4,7 @@ sudo apt update sudo apt install -y build-essential uuid-dev iasl git nasm crossbuild-essential-armel crossbuild-essential-armhf bc curdir="$PWD" cd .. -git clone https://github.com/tianocore/edk2.git -b edk2-stable202305 --recursive +git clone https://github.com/tianocore/edk2.git -b edk2-stable202405 --recursive git clone https://github.com/tianocore/edk2-platforms.git cd "$curdir" git submodule init