From b923cb5bdfcf8d97f0780e398a1403aafe3968c0 Mon Sep 17 00:00:00 2001 From: Zhuowei Zhang Date: Mon, 25 Feb 2019 14:16:55 -0800 Subject: [PATCH] Relocate edk2 to high memory before boot This may allow Linux to boot more easily? --- Pixel3XL/Library/Pixel3XLLib/Pixel3XLHelper.S | 23 +++++++++++++++++++ Pixel3XL/Library/Pixel3XLLib/Pixel3XLLib.inf | 2 ++ Pixel3XL/Pixel3XL.fdf | 2 +- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/Pixel3XL/Library/Pixel3XLLib/Pixel3XLHelper.S b/Pixel3XL/Library/Pixel3XLLib/Pixel3XLHelper.S index eb85f67..f75d3b3 100644 --- a/Pixel3XL/Library/Pixel3XLLib/Pixel3XLHelper.S +++ b/Pixel3XL/Library/Pixel3XLLib/Pixel3XLHelper.S @@ -18,7 +18,30 @@ .align 3 ASM_FUNC(ArmPlatformPeiBootAction) +startlabel: + // check if we're located at expected location + adr x4, . + ldr x5, =ArmPlatformPeiBootAction + cmp x4, x5 + bne docopy ret +docopy: + // find our start address by getting our expected offset, then subtracting it from our actual address + ldr x6, =FixedPcdGet64 (PcdFdBaseAddress) + sub x5, x5, x6 // x5 now holds offset of ArmPlatformPeiBootAction from start of FD base + sub x4, x4, x5 // x4 now holds address of actual FD base + // tweak the return address + sub lr, lr, x4 + add lr, lr, x6 + ldr x5, =FixedPcdGet64 (PcdFdSize) + // crap memcpy +loop: + ldp x2, x3, [x4], #16 + stp x2, x3, [x6], #16 + subs x5, x5, #16 + b.ne loop + ret +.ltorg //UINTN //ArmPlatformIsPrimaryCore ( diff --git a/Pixel3XL/Library/Pixel3XLLib/Pixel3XLLib.inf b/Pixel3XL/Library/Pixel3XLLib/Pixel3XLLib.inf index 43d297e..e01b372 100644 --- a/Pixel3XL/Library/Pixel3XLLib/Pixel3XLLib.inf +++ b/Pixel3XL/Library/Pixel3XLLib/Pixel3XLLib.inf @@ -42,3 +42,5 @@ gArmTokenSpaceGuid.PcdArmPrimaryCoreMask gArmTokenSpaceGuid.PcdSystemMemoryBase gArmTokenSpaceGuid.PcdSystemMemorySize + gArmTokenSpaceGuid.PcdFdBaseAddress + gArmTokenSpaceGuid.PcdFdSize diff --git a/Pixel3XL/Pixel3XL.fdf b/Pixel3XL/Pixel3XL.fdf index 42de6ed..f4734cc 100644 --- a/Pixel3XL/Pixel3XL.fdf +++ b/Pixel3XL/Pixel3XL.fdf @@ -25,7 +25,7 @@ ################################################################################ [FD.PIXEL3XL_UEFI] -BaseAddress = 0x80080000|gArmTokenSpaceGuid.PcdFdBaseAddress # The base address of the Firmware in NOR Flash. +BaseAddress = 0xd0000000|gArmTokenSpaceGuid.PcdFdBaseAddress # The base address of the Firmware in NOR Flash. Size = 0x00200000|gArmTokenSpaceGuid.PcdFdSize # The size in bytes of the FLASH Device ErasePolarity = 1