From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=217.140.106.50; helo=cam-smtp0.cambridge.arm.com; envelope-from=sami.mujawar@arm.com; receiver=edk2-devel@lists.01.org Received: from cam-smtp0.cambridge.arm.com (unknown [217.140.106.50]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 82E4F2194D3AE for ; Fri, 12 Oct 2018 07:40:33 -0700 (PDT) Received: from E107187.Arm.com (e107187.arm.com [10.1.195.55]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id w9CEeDcG018284; Fri, 12 Oct 2018 15:40:15 +0100 From: Sami Mujawar To: edk2-devel@lists.01.org Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org, lersek@redhat.com, julien.grall@linaro.org, evan.lloyd@arm.com, Matteo.Carlini@arm.com, Stephanie.Hughes-Fitt@arm.com, nd@arm.com Date: Fri, 12 Oct 2018 15:40:07 +0100 Message-Id: <20181012144009.48732-5-sami.mujawar@arm.com> X-Mailer: git-send-email 2.11.0.windows.3 In-Reply-To: <20181012144009.48732-1-sami.mujawar@arm.com> References: <20181012144009.48732-1-sami.mujawar@arm.com> Subject: [PATCH v1 4/6] ArmVirtPkg: Save DT base address from X0 in PCD X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Oct 2018 14:40:33 -0000 Some virtual machine managers provide the base address of the DT in memory in the X0 register. Save the DT Base address in the PcdDeviceTreeInitialBaseAddress so that the firmware can use the PCD to parse the DT and obtain the platform information subsequently. This change also requires that the PcdDeviceTreeInitialBaseAddress be a Dynamic PCD. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Sami Mujawar --- The changes can be seen at https://github.com/samimujawar/edk2/commit/57ffa0da043fd73907b24a6833d2797ea3dae564 Notes: v1: - Enable loading of DT from base address passed in X0. [SAMI] ArmVirtPkg/ArmVirtPkg.dec | 12 ++++++++---- ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S | 9 +++++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/ArmVirtPkg/ArmVirtPkg.dec b/ArmVirtPkg/ArmVirtPkg.dec index 8f656fd2739dd1460891029f53953c765396f8fb..9d4b782a43e505079263ded2347dff2304c2a75c 100644 --- a/ArmVirtPkg/ArmVirtPkg.dec +++ b/ArmVirtPkg/ArmVirtPkg.dec @@ -42,15 +42,19 @@ [Guids.common] [Protocols] gFdtClientProtocolGuid = { 0xE11FACA0, 0x4710, 0x4C8E, { 0xA7, 0xA2, 0x01, 0xBA, 0xA2, 0x59, 0x1B, 0x4C } } -[PcdsFixedAtBuild, PcdsPatchableInModule] +[PcdsFixedAtBuild.common, PcdsDynamic.common, PcdsPatchableInModule.common] # # This is the physical address where the device tree is expected to be stored - # upon first entry into UEFI. This needs to be a FixedAtBuild PCD, so that we - # can do a first pass over the device tree in the SEC phase to discover the - # UART base address. + # upon first entry into UEFI. In some cases this needs to be a FixedAtBuild + # PCD, so that we can do a first pass over the device tree in the SEC phase + # to discover the UART base address. In other cases where the base address + # for the DT is passed in X0 (by an earlier firmware stage or by a virtual + # machine manager), this needs to be a PcdsDynamic so that the value can be + # updated. # gArmVirtTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress|0x0|UINT64|0x00000001 +[PcdsFixedAtBuild] # # Padding in bytes to add to the device tree allocation, so that the DTB can # be modified in place (default: 256 bytes) diff --git a/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S b/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S index 891cf1fcab400c0842035be6a2fb003bafd63040..b5f8c9dd3c6a2bd2c937ff3891b2f51be65094d4 100644 --- a/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S +++ b/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S @@ -1,5 +1,5 @@ // -// Copyright (c) 2011-2013, ARM Limited. All rights reserved. +// Copyright (c) 2011-2018, ARM Limited. All rights reserved. // Copyright (c) 2015-2016, Linaro Limited. All rights reserved. // // This program and the accompanying materials @@ -143,8 +143,13 @@ ASM_PFX(DiscoverDramFromDt): // cbnz x0, 0f ldr x0, PcdGet64 (PcdDeviceTreeInitialBaseAddress) + b 1f -0:mov x29, x30 // preserve LR + // Store the device tree base address. +0:adr x8, PcdGet64 (PcdDeviceTreeInitialBaseAddress) + str x0, [x8] + +1:mov x29, x30 // preserve LR mov x28, x0 // preserve DTB pointer mov x27, x1 // preserve base of image pointer -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'