From nobody Thu Dec 26 12:50:02 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1504013828728374.2429741354367; Tue, 29 Aug 2017 06:37:08 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 7373421E47D69; Tue, 29 Aug 2017 06:34:26 -0700 (PDT) Received: from mail-wr0-x22c.google.com (mail-wr0-x22c.google.com [IPv6:2a00:1450:400c:c0c::22c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5670421E11D2D for ; Tue, 29 Aug 2017 06:34:24 -0700 (PDT) Received: by mail-wr0-x22c.google.com with SMTP id p14so10308116wrg.3 for ; Tue, 29 Aug 2017 06:37:04 -0700 (PDT) Received: from localhost.localdomain ([105.133.189.215]) by smtp.gmail.com with ESMTPSA id w6sm2524217wra.25.2017.08.29.06.37.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Aug 2017 06:37:02 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=k+cpOjPiXRBmiRoqhBVBoIWexcsjSMsH8KvI+8w6kuk=; b=g0PbD2hfh/fJravKh7cuI7W0gik9tdsxNzX7S/uohF+A1/yXmEblGzVxt9A7XXDsf6 lxNAZa4sIfSjUBH4JTCQYFTYhbqJwO8V/nBTIxGclAPhq1B5sioQabmd6L2cOPUBvfxe qvH5qFyAEIh8m3ahY2Z4YEXyTOSLgHjiV+Kus= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=k+cpOjPiXRBmiRoqhBVBoIWexcsjSMsH8KvI+8w6kuk=; b=EfYFxcv2WRWT8ZB/q2zCLAHJFcF2qjbSONNaedJAIL/NSXQGA0LNLuXbr0GvOnZdCO RAORvEMwPtMD+myvEMpz/GmwlBNUaBkIUPr6KVht9EDxbzvNEXfc7hLkzKPTk64i5UOj PH/nXgRqHDr5/vH6kfHGK2FMvE8l0zUeSPKmKxlXtJ87v3TWx1wLQcmzWiJGK6C7C8ta in9mWP506verMIfpJnnT6gz+PvByCtYxVb8Ny2rXHXHs0Kf22rryuCdX6ZA15dZrF5G+ aPHzVxzK5MTkkCl0q99Iwe6xa9zOzlrj2l7w62gmjEpjMCcTM158WVc92OLr0IJxv9q0 1MPw== X-Gm-Message-State: AHYfb5jAG8JmEVVZRHJMxL2Rh1xc7VbljoaZLYsKs9gYKhi1runiVFxf im2hG+uzjmvHwu/hoVImeg== X-Received: by 10.223.183.70 with SMTP id n6mr238602wre.161.1504013823145; Tue, 29 Aug 2017 06:37:03 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, yonghong.zhu@intel.com Date: Tue, 29 Aug 2017 14:36:51 +0100 Message-Id: <20170829133651.30909-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 Subject: [edk2] [PATCH] BaseTools/Gcc ARM AARCH64: add support for building device tree binaries X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lersek@redhat.com, liming.gao@intel.com, Ard Biesheuvel MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" While modern AARCH64 server systems use ACPI for describing the platform topology to the OS, ARM systems and AARCH64 outside of the server space mostly use device tree binaries, which are compiled from device tree source files using the device tree compiler. Currently, such source files and binaries may be kept in the EDK2 platform trees, but are not integrated with the build, which means they need to be kept in sync and recompiled manually, which is cumbersome. So let's wire up BaseTools support for them: add tool definitions for the DTC compiler and preprocessor flags that allow these source files to use FixedPcd expressions and other macros defined by AutoGen.h This way, a device tree binary can be built from source and emitted into a FFS file automatically using something like: DeviceTree.inf: [Defines] INF_VERSION =3D 0x00010019 BASE_NAME =3D SomePlatformDeviceTree FILE_GUID =3D 25462CDA-221F-47DF-AC1D-259CFAA4E326 # gDtPlatform= DefaultDtbFileGuid MODULE_TYPE =3D USER_DEFINED VERSION_STRING =3D 1.0 [Sources] SomePlatform.dts [Packages] MdePkg/MdePkg.dec SomePlatform.fdf: INF RuleOverride =3D DTB xxx/yyy/DeviceTree.inf [Rule.Common.USER_DEFINED.DTB] FILE FREEFORM =3D $(NAMED_GUID) { RAW BIN |.dtb } where it can be picked at runtime by the DTB loader that may refer to it using gDtPlatformDefaultDtbFileGuid. Note that this is very similar to how ACPI tables may be emitted into a FFS file with a known GUID and picked up by AcpiTableDxe at runtime. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Acked-by: Laszlo Ersek Reviewed-by: Leif Lindholm Reviewed-by: Liming Gao --- BaseTools/Conf/build_rule.template | 14 ++++++++++++++ BaseTools/Conf/tools_def.template | 19 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/BaseTools/Conf/build_rule.template b/BaseTools/Conf/build_rule= .template index 1db94b696f89..2684c8c990a1 100755 --- a/BaseTools/Conf/build_rule.template +++ b/BaseTools/Conf/build_rule.template @@ -238,6 +238,20 @@ # For RVCTCYGWIN ASM_FLAGS must be first to work around pathing is= sues "$(ASM)" $(ASM_FLAGS) -o ${dst} ${d_path}(+)${s_base}.iii =20 +[Device-Tree-Source-File] + + ?.dts + + + $(MAKE_FILE) + + + $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dtb + + + "$(PP)" $(DTCPP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i + "$(DTC)" -I dts -O dtb -o ${dst} ${d_path}(+)${s_base}.i + [Visual-Form-Representation-File] ?.vfr diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.t= emplate index 1fa3ca3ceae9..3102488a03d7 100755 --- a/BaseTools/Conf/tools_def.template +++ b/BaseTools/Conf/tools_def.template @@ -227,6 +227,8 @@ DEFINE IPHONE_TOOLS =3D /Developer/Platforms= /iPhoneOS.platform/Develope =20 DEFINE SOURCERY_CYGWIN_TOOLS =3D /cygdrive/c/Program Files/CodeSourcery/So= urcery G++ Lite/bin =20 +DEFINE DTC_BIN =3D ENV(DTC_PREFIX)dtc + ##########################################################################= ########## # # format: TARGET_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE =3D @@ -4362,6 +4364,7 @@ DEFINE GCC_VFRPP_FLAGS =3D -x c -E -P -DV= FRCOMPILE --include $(DEST_DI DEFINE GCC_ASLPP_FLAGS =3D -x c -E -include AutoGen.h DEFINE GCC_ASLCC_FLAGS =3D -x c DEFINE GCC_WINDRES_FLAGS =3D -J rc -O coff +DEFINE GCC_DTCPP_FLAGS =3D -E -x assembler-with-cpp -imacros $= (DEST_DIR_DEBUG)/AutoGen.h -nostdinc DEFINE GCC_IA32_RC_FLAGS =3D -I binary -O elf32-i386 -B= i386 --rename-section .data=3D.hii DEFINE GCC_X64_RC_FLAGS =3D -I binary -O elf64-x86-64 -B= i386 --rename-section .data=3D.hii DEFINE GCC_IPF_RC_FLAGS =3D -I binary -O elf64-ia64-little -B= ia64 --rename-section .data=3D.hii @@ -4745,6 +4748,7 @@ RELEASE_GCC45_X64_CC_FLAGS =3D DEF(GCC45_X64_CC= _FLAGS) -Os *_GCC46_*_MAKE_PATH =3D DEF(GCC46_IA32_PREFIX)make *_GCC46_*_*_DLL =3D ENV(GCC46_DLL) *_GCC46_*_ASL_PATH =3D DEF(UNIX_IASL_BIN) +*_GCC46_*_DTC_PATH =3D DEF(DTC_BIN) =20 *_GCC46_*_PP_FLAGS =3D DEF(GCC_PP_FLAGS) *_GCC46_*_ASLPP_FLAGS =3D DEF(GCC_ASLPP_FLAGS) @@ -4833,6 +4837,7 @@ RELEASE_GCC46_X64_CC_FLAGS =3D DEF(GCC46_X64_CC= _FLAGS) -Os -Wno-unused-but-s *_GCC46_ARM_ASM_FLAGS =3D DEF(GCC46_ARM_ASM_FLAGS) *_GCC46_ARM_DLINK_FLAGS =3D DEF(GCC46_ARM_DLINK_FLAGS) *_GCC46_ARM_DLINK2_FLAGS =3D DEF(GCC46_ARM_DLINK2_FLAGS) +*_GCC46_ARM_DTCPP_FLAGS =3D DEF(GCC_DTCPP_FLAGS) *_GCC46_ARM_PLATFORM_FLAGS =3D -march=3Darmv7-a *_GCC46_ARM_PP_FLAGS =3D $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF= (GCC_PP_FLAGS) *_GCC46_ARM_RC_FLAGS =3D DEF(GCC_ARM_RC_FLAGS) @@ -4854,6 +4859,7 @@ RELEASE_GCC46_ARM_CC_FLAGS =3D DEF(GCC46_ARM_CC= _FLAGS) -Wno-unused-but-set-v *_GCC47_*_MAKE_PATH =3D DEF(GCC47_IA32_PREFIX)make *_GCC47_*_*_DLL =3D ENV(GCC47_DLL) *_GCC47_*_ASL_PATH =3D DEF(UNIX_IASL_BIN) +*_GCC47_*_DTC_PATH =3D DEF(DTC_BIN) =20 *_GCC47_*_PP_FLAGS =3D DEF(GCC_PP_FLAGS) *_GCC47_*_ASLPP_FLAGS =3D DEF(GCC_ASLPP_FLAGS) @@ -4941,6 +4947,7 @@ RELEASE_GCC47_X64_CC_FLAGS =3D DEF(GCC47_X64_CC= _FLAGS) -Os -Wno-unused-but-s *_GCC47_ARM_ASM_FLAGS =3D DEF(GCC47_ARM_ASM_FLAGS) *_GCC47_ARM_DLINK_FLAGS =3D DEF(GCC47_ARM_DLINK_FLAGS) *_GCC47_ARM_DLINK2_FLAGS =3D DEF(GCC47_ARM_DLINK2_FLAGS) +*_GCC47_ARM_DTCPP_FLAGS =3D DEF(GCC_DTCPP_FLAGS) *_GCC47_ARM_PLATFORM_FLAGS =3D -march=3Darmv7-a *_GCC47_ARM_PP_FLAGS =3D $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF= (GCC_PP_FLAGS) *_GCC47_ARM_RC_FLAGS =3D DEF(GCC_ARM_RC_FLAGS) @@ -4970,6 +4977,7 @@ RELEASE_GCC47_ARM_CC_FLAGS =3D DEF(GCC47_ARM_CC= _FLAGS) -Wno-unused-but-set-v *_GCC47_AARCH64_ASM_FLAGS =3D DEF(GCC47_AARCH64_ASM_FLAGS) *_GCC47_AARCH64_DLINK_FLAGS =3D DEF(GCC47_AARCH64_DLINK_FLAGS) *_GCC47_AARCH64_DLINK2_FLAGS =3D DEF(GCC47_AARCH64_DLINK2_FLAGS) +*_GCC47_AARCH64_DTCPP_FLAGS =3D DEF(GCC_DTCPP_FLAGS) *_GCC47_AARCH64_PLATFORM_FLAGS =3D *_GCC47_AARCH64_PP_FLAGS =3D $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF= (GCC_PP_FLAGS) *_GCC47_AARCH64_RC_FLAGS =3D DEF(GCC_AARCH64_RC_FLAGS) @@ -4991,6 +4999,7 @@ RELEASE_GCC47_AARCH64_CC_FLAGS =3D DEF(GCC47_AARCH6= 4_CC_FLAGS) -Wno-unused-but-s *_GCC48_*_MAKE_PATH =3D DEF(GCC48_IA32_PREFIX)make *_GCC48_*_*_DLL =3D ENV(GCC48_DLL) *_GCC48_*_ASL_PATH =3D DEF(UNIX_IASL_BIN) +*_GCC48_*_DTC_PATH =3D DEF(DTC_BIN) =20 *_GCC48_*_PP_FLAGS =3D DEF(GCC_PP_FLAGS) *_GCC48_*_ASLPP_FLAGS =3D DEF(GCC_ASLPP_FLAGS) @@ -5078,6 +5087,7 @@ RELEASE_GCC48_X64_CC_FLAGS =3D DEF(GCC48_X64_CC= _FLAGS) -Os -Wno-unused-but-s *_GCC48_ARM_ASM_FLAGS =3D DEF(GCC48_ARM_ASM_FLAGS) *_GCC48_ARM_DLINK_FLAGS =3D DEF(GCC48_ARM_DLINK_FLAGS) *_GCC48_ARM_DLINK2_FLAGS =3D DEF(GCC48_ARM_DLINK2_FLAGS) +*_GCC48_ARM_DTCPP_FLAGS =3D DEF(GCC_DTCPP_FLAGS) *_GCC48_ARM_PLATFORM_FLAGS =3D -march=3Darmv7-a *_GCC48_ARM_PP_FLAGS =3D $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF= (GCC_PP_FLAGS) *_GCC48_ARM_RC_FLAGS =3D DEF(GCC_ARM_RC_FLAGS) @@ -5107,6 +5117,7 @@ RELEASE_GCC48_ARM_CC_FLAGS =3D DEF(GCC48_ARM_CC= _FLAGS) -Wno-unused-but-set-v *_GCC48_AARCH64_ASM_FLAGS =3D DEF(GCC48_AARCH64_ASM_FLAGS) *_GCC48_AARCH64_DLINK_FLAGS =3D DEF(GCC48_AARCH64_DLINK_FLAGS) *_GCC48_AARCH64_DLINK2_FLAGS =3D DEF(GCC48_AARCH64_DLINK2_FLAGS) +*_GCC48_AARCH64_DTCPP_FLAGS =3D DEF(GCC_DTCPP_FLAGS) *_GCC48_AARCH64_PLATFORM_FLAGS =3D *_GCC48_AARCH64_PP_FLAGS =3D $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF= (GCC_PP_FLAGS) *_GCC48_AARCH64_RC_FLAGS =3D DEF(GCC_AARCH64_RC_FLAGS) @@ -5128,6 +5139,7 @@ RELEASE_GCC48_AARCH64_CC_FLAGS =3D DEF(GCC48_AARCH6= 4_CC_FLAGS) -Wno-unused-but-s *_GCC49_*_MAKE_PATH =3D DEF(GCC49_IA32_PREFIX)make *_GCC49_*_*_DLL =3D ENV(GCC49_DLL) *_GCC49_*_ASL_PATH =3D DEF(UNIX_IASL_BIN) +*_GCC49_*_DTC_PATH =3D DEF(DTC_BIN) =20 *_GCC49_*_PP_FLAGS =3D DEF(GCC_PP_FLAGS) *_GCC49_*_ASLPP_FLAGS =3D DEF(GCC_ASLPP_FLAGS) @@ -5215,6 +5227,7 @@ RELEASE_GCC49_X64_CC_FLAGS =3D DEF(GCC49_X64_CC= _FLAGS) -Os -Wno-unused-but-s *_GCC49_ARM_ASM_FLAGS =3D DEF(GCC49_ARM_ASM_FLAGS) *_GCC49_ARM_DLINK_FLAGS =3D DEF(GCC49_ARM_DLINK_FLAGS) *_GCC49_ARM_DLINK2_FLAGS =3D DEF(GCC49_ARM_DLINK2_FLAGS) +*_GCC49_ARM_DTCPP_FLAGS =3D DEF(GCC_DTCPP_FLAGS) *_GCC49_ARM_PLATFORM_FLAGS =3D -march=3Darmv7-a *_GCC49_ARM_PP_FLAGS =3D $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF= (GCC_PP_FLAGS) *_GCC49_ARM_RC_FLAGS =3D DEF(GCC_ARM_RC_FLAGS) @@ -5243,6 +5256,7 @@ RELEASE_GCC49_ARM_CC_FLAGS =3D DEF(GCC49_ARM_CC= _FLAGS) -Wno-unused-but-set-v *_GCC49_AARCH64_ASLDLINK_FLAGS =3D DEF(GCC49_AARCH64_ASLDLINK_FLAGS) *_GCC49_AARCH64_ASM_FLAGS =3D DEF(GCC49_AARCH64_ASM_FLAGS) *_GCC49_AARCH64_DLINK2_FLAGS =3D DEF(GCC49_AARCH64_DLINK2_FLAGS) +*_GCC49_AARCH64_DTCPP_FLAGS =3D DEF(GCC_DTCPP_FLAGS) *_GCC49_AARCH64_PLATFORM_FLAGS =3D *_GCC49_AARCH64_PP_FLAGS =3D $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF= (GCC_PP_FLAGS) *_GCC49_AARCH64_RC_FLAGS =3D DEF(GCC_AARCH64_RC_FLAGS) @@ -5271,6 +5285,7 @@ RELEASE_GCC49_AARCH64_DLINK_FLAGS =3D DEF(GCC49_AARC= H64_DLINK_FLAGS) *_GCC5_*_MAKE_PATH =3D DEF(GCC5_IA32_PREFIX)make *_GCC5_*_*_DLL =3D ENV(GCC5_DLL) *_GCC5_*_ASL_PATH =3D DEF(UNIX_IASL_BIN) +*_GCC5_*_DTC_PATH =3D DEF(DTC_BIN) =20 *_GCC5_*_PP_FLAGS =3D DEF(GCC_PP_FLAGS) *_GCC5_*_ASLPP_FLAGS =3D DEF(GCC_ASLPP_FLAGS) @@ -5363,6 +5378,7 @@ RELEASE_GCC5_X64_DLINK_FLAGS =3D DEF(GCC5_X64_DLI= NK_FLAGS) -flto -Os *_GCC5_ARM_ASLDLINK_FLAGS =3D DEF(GCC5_ARM_ASLDLINK_FLAGS) *_GCC5_ARM_ASM_FLAGS =3D DEF(GCC5_ARM_ASM_FLAGS) *_GCC5_ARM_DLINK2_FLAGS =3D DEF(GCC5_ARM_DLINK2_FLAGS) +*_GCC5_ARM_DTCPP_FLAGS =3D DEF(GCC_DTCPP_FLAGS) *_GCC5_ARM_PLATFORM_FLAGS =3D -march=3Darmv7-a *_GCC5_ARM_PP_FLAGS =3D $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF= (GCC_PP_FLAGS) *_GCC5_ARM_RC_FLAGS =3D DEF(GCC_ARM_RC_FLAGS) @@ -5396,6 +5412,7 @@ RELEASE_GCC5_ARM_DLINK_FLAGS =3D DEF(GCC5_ARM_DLI= NK_FLAGS) -flto -Os -L$(WORKS *_GCC5_AARCH64_ASLDLINK_FLAGS =3D DEF(GCC5_AARCH64_ASLDLINK_FLAGS) *_GCC5_AARCH64_ASM_FLAGS =3D DEF(GCC5_AARCH64_ASM_FLAGS) *_GCC5_AARCH64_DLINK2_FLAGS =3D DEF(GCC5_AARCH64_DLINK2_FLAGS) +*_GCC5_AARCH64_DTCPP_FLAGS =3D DEF(GCC_DTCPP_FLAGS) *_GCC5_AARCH64_PLATFORM_FLAGS =3D *_GCC5_AARCH64_PP_FLAGS =3D $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF= (GCC_PP_FLAGS) *_GCC5_AARCH64_RC_FLAGS =3D DEF(GCC_AARCH64_RC_FLAGS) @@ -5425,12 +5442,14 @@ RELEASE_GCC5_AARCH64_DLINK_FLAGS =3D DEF(GCC5_AARCH= 64_DLINK_FLAGS) -flto -Os -L$(W *_CLANG35_*_MAKE_PATH =3D make *_CLANG35_*_*_DLL =3D ENV(CLANG35_DLL) *_CLANG35_*_ASL_PATH =3D DEF(UNIX_IASL_BIN) +*_CLANG35_*_DTC_PATH =3D DEF(DTC_BIN) =20 *_CLANG35_*_PP_FLAGS =3D DEF(GCC_PP_FLAGS) *_CLANG35_*_ASLCC_FLAGS =3D DEF(GCC_ASLCC_FLAGS) *_CLANG35_*_APP_FLAGS =3D *_CLANG35_*_ASL_FLAGS =3D DEF(IASL_FLAGS) *_CLANG35_*_ASL_OUTFLAGS =3D DEF(IASL_OUTFLAGS) +*_CLANG35_*_DTCPP_FLAGS =3D DEF(GCC_DTCPP_FLAGS) =20 *_CLANG35_*_CC_PATH =3D ENV(CLANG35_BIN)clang *_CLANG35_*_ASM_PATH =3D ENV(CLANG35_BIN)clang --=20 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel