From patchwork Fri Jan 23 15:02:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 43656 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 350C6218DB for ; Fri, 23 Jan 2015 15:04:06 +0000 (UTC) Received: by mail-la0-f71.google.com with SMTP id s18sf896612lam.2 for ; Fri, 23 Jan 2015 07:04:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:subject:precedence:reply-to:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :content-type:content-transfer-encoding:errors-to:x-original-sender :x-original-authentication-results:mailing-list; bh=P3spcZxONATxT/UDQJ52N89Ym8QOtZEvDnrxUA46iB8=; b=ml0GHr+AxrOTJK/IYEQ/hOXU7tDq4+nn1oZGTrrsiWYpN/pnk/fJk3267+vpYWMrAa JU77tRENNSoYwotEnLcHsQjucFcITZ8EvQbbdIVo+IaVD26D7fPgAPFIfeVzV7ZfoNHT YhYqbkfhMWxQwAXoQYfLjirerjZtVfA+R1kT4lqnVFrtfjth5h4MlL+o9MI8WULJb1fL azBPFoUIsF8cAbIcpAxOf1ABZnF7TslJQ6tqTa/SoLjVmW8wfKQYosnS8PWL6YytfaT7 MV9owPzva/10ObD0zlB8wjWSlmVvv8UFDcLIUc98GBQfVLqML8s7xPu5rM6pfWyKtpiz XH/w== X-Gm-Message-State: ALoCoQlPkmm+L+HN2y2x7HRi+SXHW0/VNO7YfzFVzYK/r1Zop06LfH8JejDaxOBNRlLDaiVJl9ZB X-Received: by 10.152.8.67 with SMTP id p3mr417656laa.4.1422025445171; Fri, 23 Jan 2015 07:04:05 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.161.198 with SMTP id xu6ls274277lab.86.gmail; Fri, 23 Jan 2015 07:04:05 -0800 (PST) X-Received: by 10.152.18.135 with SMTP id w7mr7562194lad.47.1422025445015; Fri, 23 Jan 2015 07:04:05 -0800 (PST) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id d5si1626640lae.11.2015.01.23.07.04.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Jan 2015 07:04:04 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by mail-la0-f52.google.com with SMTP id ge10so3590923lab.11 for ; Fri, 23 Jan 2015 07:04:04 -0800 (PST) X-Received: by 10.112.131.1 with SMTP id oi1mr7741544lbb.2.1422025444849; Fri, 23 Jan 2015 07:04:04 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.9.200 with SMTP id c8csp283022lbb; Fri, 23 Jan 2015 07:04:03 -0800 (PST) X-Received: by 10.107.137.231 with SMTP id t100mr4119582ioi.78.1422025442835; Fri, 23 Jan 2015 07:04:02 -0800 (PST) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id qf10si1785802icb.72.2015.01.23.07.04.02 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 23 Jan 2015 07:04:02 -0800 (PST) Received-SPF: pass (google.com: domain of edk2-devel-bounces@lists.sourceforge.net designates 216.34.181.88 as permitted sender) client-ip=216.34.181.88; Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YEfm6-0001O5-Iw; Fri, 23 Jan 2015 15:03:54 +0000 Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YEfm5-0001Nq-2a for edk2-devel@lists.sourceforge.net; Fri, 23 Jan 2015 15:03:53 +0000 Received-SPF: pass (sog-mx-2.v43.ch3.sourceforge.com: domain of linaro.org designates 209.85.212.178 as permitted sender) client-ip=209.85.212.178; envelope-from=ard.biesheuvel@linaro.org; helo=mail-wi0-f178.google.com; Received: from mail-wi0-f178.google.com ([209.85.212.178]) by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1YEfm3-0003Xb-BJ for edk2-devel@lists.sourceforge.net; Fri, 23 Jan 2015 15:03:53 +0000 Received: by mail-wi0-f178.google.com with SMTP id em10so3404371wid.5 for ; Fri, 23 Jan 2015 07:03:45 -0800 (PST) X-Received: by 10.180.74.147 with SMTP id t19mr4821542wiv.6.1422025425326; Fri, 23 Jan 2015 07:03:45 -0800 (PST) Received: from ards-macbook-pro.local ([197.129.136.117]) by mx.google.com with ESMTPSA id pl1sm2176036wic.16.2015.01.23.07.03.42 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 23 Jan 2015 07:03:44 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.sourceforge.net, lersek@redhat.com, olivier.martin@arm.com, roy.franz@linaro.org, leif.lindholm@linaro.org, stefano.stabellini@eu.citrix.com, ian.campbell@citrix.com, anthony.perard@citrix.com, christoffer.dall@linaro.org, xen-devel@lists.xen.org, ilias.biris@linaro.org Date: Fri, 23 Jan 2015 15:02:56 +0000 Message-Id: <1422025390-8036-8-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1422025390-8036-1-git-send-email-ard.biesheuvel@linaro.org> References: <1422025390-8036-1-git-send-email-ard.biesheuvel@linaro.org> X-Spam-Score: -1.5 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_PASS SPF: sender matches SPF record X-Headers-End: 1YEfm3-0003Xb-BJ Subject: [edk2] [PATCH v1 07/21] ArmPlatformPkg/PrePi: factor out FixedPcdGetXX() and ArmIsMpCore() X-BeenThere: edk2-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list Reply-To: edk2-devel@lists.sourceforge.net List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.sourceforge.net X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 As a prepatory step towards introduction of a relocatable PrePi instance, this patch makes some code changes that should not affect operation, but will allow the relocable PrePi to work correctly. First of all, instances of FixedPcdGetXX() are replaced by their PcdGetXX() counterparts. This will ensure all code uses the variables and not the immediate constants, which allows us to poke alternate values when running from RAM. Also, the result of ArmIsMpCore() is passed into PrePiMain() as an argument, so that the new PrePi can pass FALSE explicitly, allowing the same build to run on both unicore and multicore platforms. Signed-off-by: Ard Biesheuvel --- ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S | 24 ++++++++++++------------ ArmPlatformPkg/PrePi/MainMPCore.c | 5 +++-- ArmPlatformPkg/PrePi/MainUniCore.c | 2 +- ArmPlatformPkg/PrePi/PrePi.c | 25 ++++++++++++------------- ArmPlatformPkg/PrePi/PrePi.h | 3 ++- 5 files changed, 30 insertions(+), 29 deletions(-) diff --git a/ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S b/ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S index fcea9496cbd5..45983b8d51cc 100644 --- a/ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S +++ b/ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S @@ -42,19 +42,19 @@ _SetSVCMode: // at the top of the DRAM) _SetupStackPosition: // Compute Top of System Memory - LoadConstantToReg (FixedPcdGet64 (PcdSystemMemoryBase), x1) - LoadConstantToReg (FixedPcdGet64 (PcdSystemMemorySize), x2) + ldr x1, PcdGet64 (PcdSystemMemoryBase) + ldr x2, PcdGet64 (PcdSystemMemorySize) sub x2, x2, #1 add x1, x1, x2 // x1 = SystemMemoryTop = PcdSystemMemoryBase + PcdSystemMemorySize // Calculate Top of the Firmware Device - LoadConstantToReg (FixedPcdGet32(PcdFdBaseAddress), x2) - LoadConstantToReg (FixedPcdGet32(PcdFdSize), x3) + ldr x2, PcdGet64 (PcdFdBaseAddress) + ldr w3, PcdGet32 (PcdFdSize) sub x3, x3, #1 add x3, x3, x2 // x3 = FdTop = PcdFdBaseAddress + PcdFdSize // UEFI Memory Size (stacks are allocated in this region) - LoadConstantToReg (FixedPcdGet32(PcdSystemMemoryUefiRegionSize), x4) + ldr w4, PcdGet32 (PcdSystemMemoryUefiRegionSize) // // Reserve the memory for the UEFI region (contain stacks on its top) @@ -85,7 +85,7 @@ _SetupAlignedStack: _SetupOverflowStack: // Case memory at the top of the address space. Ensure the top of the stack is EFI_PAGE_SIZE // aligned (4KB) - LoadConstantToReg (EFI_PAGE_MASK, x11) + mov x11, #EFI_PAGE_MASK and x11, x11, x1 sub x1, x1, x11 @@ -96,13 +96,13 @@ _GetBaseUefiMemory: _GetStackBase: // r1 = The top of the Mpcore Stacks // Stack for the primary core = PrimaryCoreStack - LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), x2) + ldr w2, PcdGet32 (PcdCPUCorePrimaryStackSize) sub x12, x1, x2 // Stack for the secondary core = Number of Cores - 1 - LoadConstantToReg (FixedPcdGet32(PcdCoreCount), x0) + ldr w0, PcdGet32 (PcdCoreCount) sub x0, x0, #1 - LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecondaryStackSize), x1) + ldr w1, PcdGet32 (PcdCPUCoreSecondaryStackSize) mul x1, x1, x0 sub x12, x12, x1 @@ -110,8 +110,8 @@ _GetStackBase: mov x0, x12 mov x1, x10 //ArmPlatformStackSet(StackBase, MpId, PrimaryStackSize, SecondaryStackSize) - LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), x2) - LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecondaryStackSize), x3) + ldr w2, PcdGet32 (PcdCPUCorePrimaryStackSize) + ldr w3, PcdGet32 (PcdCPUCoreSecondaryStackSize) bl ASM_PFX(ArmPlatformStackSet) // Is it the Primary Core ? @@ -121,7 +121,7 @@ _GetStackBase: bne _PrepareArguments _ReserveGlobalVariable: - LoadConstantToReg (FixedPcdGet32(PcdPeiGlobalVariableSize), x0) + ldr w0, PcdGet32(PcdPeiGlobalVariableSize) // InitializePrimaryStack($GlobalVariableSize, $Tmp1, $Tmp2) InitializePrimaryStack(x0, x1, x2) diff --git a/ArmPlatformPkg/PrePi/MainMPCore.c b/ArmPlatformPkg/PrePi/MainMPCore.c index bf813730d341..673d6adc8269 100644 --- a/ArmPlatformPkg/PrePi/MainMPCore.c +++ b/ArmPlatformPkg/PrePi/MainMPCore.c @@ -15,6 +15,7 @@ #include "PrePi.h" #include +#include #include @@ -30,12 +31,12 @@ PrimaryMain ( ArmGicEnableDistributor(PcdGet32(PcdGicDistributorBase)); // In some cases, the secondary cores are waiting for an SGI from the next stage boot loader to resume their initialization - if (!FixedPcdGet32(PcdSendSgiToBringUpSecondaryCores)) { + if (!PcdGetBool (PcdSendSgiToBringUpSecondaryCores)) { // Sending SGI to all the Secondary CPU interfaces ArmGicSendSgiTo (PcdGet32(PcdGicDistributorBase), ARM_GIC_ICDSGIR_FILTER_EVERYONEELSE, 0x0E, PcdGet32 (PcdGicSgiIntId)); } - PrePiMain (UefiMemoryBase, StacksBase, GlobalVariableBase, StartTimeStamp); + PrePiMain (UefiMemoryBase, StacksBase, GlobalVariableBase, StartTimeStamp, ArmIsMpCore()); // We must never return ASSERT(FALSE); diff --git a/ArmPlatformPkg/PrePi/MainUniCore.c b/ArmPlatformPkg/PrePi/MainUniCore.c index 43588a50ddb5..918ea4dcdf7b 100644 --- a/ArmPlatformPkg/PrePi/MainUniCore.c +++ b/ArmPlatformPkg/PrePi/MainUniCore.c @@ -27,7 +27,7 @@ PrimaryMain ( ASSERT(ArmIsMpCore() == 0); DEBUG_CODE_END(); - PrePiMain (UefiMemoryBase, StacksBase, GlobalVariableBase, StartTimeStamp); + PrePiMain (UefiMemoryBase, StacksBase, GlobalVariableBase, StartTimeStamp, ArmIsMpCore()); // We must never return ASSERT(FALSE); diff --git a/ArmPlatformPkg/PrePi/PrePi.c b/ArmPlatformPkg/PrePi/PrePi.c index 9a5e067ef537..9c669280be01 100755 --- a/ArmPlatformPkg/PrePi/PrePi.c +++ b/ArmPlatformPkg/PrePi/PrePi.c @@ -30,8 +30,8 @@ #include "PrePi.h" #include "LzmaDecompress.h" -#define IS_XIP() (((UINT32)FixedPcdGet32 (PcdFdBaseAddress) > (UINT32)(FixedPcdGet64 (PcdSystemMemoryBase) + FixedPcdGet32 (PcdSystemMemorySize))) || \ - ((FixedPcdGet32 (PcdFdBaseAddress) + FixedPcdGet32 (PcdFdSize)) < FixedPcdGet64 (PcdSystemMemoryBase))) +#define IS_XIP() (((UINT32)PcdGet64 (PcdFdBaseAddress) > (UINT32)(PcdGet64 (PcdSystemMemoryBase) + PcdGet64 (PcdSystemMemorySize))) || \ + ((PcdGet64 (PcdFdBaseAddress) + PcdGet32 (PcdFdSize)) < PcdGet64 (PcdSystemMemoryBase))) // Not used when PrePi in run in XIP mode UINTN mGlobalVariableBase = 0; @@ -94,7 +94,8 @@ PrePiMain ( IN UINTN UefiMemoryBase, IN UINTN StacksBase, IN UINTN GlobalVariableBase, - IN UINT64 StartTimeStamp + IN UINT64 StartTimeStamp, + IN BOOLEAN IsMpCore ) { EFI_HOB_HANDOFF_INFO_TABLE* HobList; @@ -108,8 +109,8 @@ PrePiMain ( // If ensure the FD is either part of the System Memory or totally outside of the System Memory (XIP) ASSERT (IS_XIP() || - ((FixedPcdGet32 (PcdFdBaseAddress) >= FixedPcdGet64 (PcdSystemMemoryBase)) && - ((UINT32)(FixedPcdGet32 (PcdFdBaseAddress) + FixedPcdGet32 (PcdFdSize)) <= (UINT32)(FixedPcdGet64 (PcdSystemMemoryBase) + FixedPcdGet64 (PcdSystemMemorySize))))); + ((PcdGet64 (PcdFdBaseAddress) >= PcdGet64 (PcdSystemMemoryBase)) && + ((UINT32)(PcdGet64 (PcdFdBaseAddress) + PcdGet32 (PcdFdSize)) <= (UINT32)(PcdGet64 (PcdSystemMemoryBase) + PcdGet64 (PcdSystemMemorySize))))); // Initialize the architecture specific bits ArchInitialize (); @@ -127,32 +128,32 @@ PrePiMain ( // Declare the PI/UEFI memory region HobList = HobConstructor ( (VOID*)UefiMemoryBase, - FixedPcdGet32 (PcdSystemMemoryUefiRegionSize), + PcdGet32 (PcdSystemMemoryUefiRegionSize), (VOID*)UefiMemoryBase, (VOID*)StacksBase // The top of the UEFI Memory is reserved for the stacks ); PrePeiSetHobList (HobList); // Initialize MMU and Memory HOBs (Resource Descriptor HOBs) - Status = MemoryPeim (UefiMemoryBase, FixedPcdGet32 (PcdSystemMemoryUefiRegionSize)); + Status = MemoryPeim (UefiMemoryBase, PcdGet32 (PcdSystemMemoryUefiRegionSize)); ASSERT_EFI_ERROR (Status); // Create the Stacks HOB (reserve the memory for all stacks) - if (ArmIsMpCore ()) { + if (IsMpCore) { StacksSize = PcdGet32 (PcdCPUCorePrimaryStackSize) + - ((FixedPcdGet32 (PcdCoreCount) - 1) * FixedPcdGet32 (PcdCPUCoreSecondaryStackSize)); + ((PcdGet32 (PcdCoreCount) - 1) * PcdGet32 (PcdCPUCoreSecondaryStackSize)); } else { StacksSize = PcdGet32 (PcdCPUCorePrimaryStackSize); } BuildStackHob (StacksBase, StacksSize); // Declare the Global Variable HOB - BuildGlobalVariableHob (GlobalVariableBase, FixedPcdGet32 (PcdPeiGlobalVariableSize)); + BuildGlobalVariableHob (GlobalVariableBase, PcdGet32 (PcdPeiGlobalVariableSize)); //TODO: Call CpuPei as a library BuildCpuHob (PcdGet8 (PcdPrePiCpuMemorySize), PcdGet8 (PcdPrePiCpuIoSize)); - if (ArmIsMpCore ()) { + if (IsMpCore) { // Only MP Core platform need to produce gArmMpCoreInfoPpiGuid Status = GetPlatformPpi (&gArmMpCoreInfoPpiGuid, (VOID**)&ArmMpCoreInfoPpi); @@ -209,8 +210,6 @@ CEntryPoint ( { UINT64 StartTimeStamp; - ASSERT(!ArmIsMpCore() || (PcdGet32 (PcdCoreCount) > 1)); - // Initialize the platform specific controllers ArmPlatformInitialize (MpId); diff --git a/ArmPlatformPkg/PrePi/PrePi.h b/ArmPlatformPkg/PrePi/PrePi.h index e67795f4490a..468569b3a28b 100644 --- a/ArmPlatformPkg/PrePi/PrePi.h +++ b/ArmPlatformPkg/PrePi/PrePi.h @@ -40,7 +40,8 @@ PrePiMain ( IN UINTN UefiMemoryBase, IN UINTN StacksBase, IN UINTN GlobalVariableBase, - IN UINT64 StartTimeStamp + IN UINT64 StartTimeStamp, + IN BOOLEAN IsMpCore ); EFI_STATUS