From patchwork Tue Oct 17 13:30:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 116108 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp4899770qgn; Tue, 17 Oct 2017 06:32:35 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDoJ7s1XQ/QUxPaxxjqxyLy2XMglxJ16We1b5o0dQvRcu799mziSGuiZIiyJsNhgInmVkC2 X-Received: by 10.80.240.72 with SMTP id u8mr17311463edl.5.1508247154782; Tue, 17 Oct 2017 06:32:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508247154; cv=none; d=google.com; s=arc-20160816; b=ozv4BN9LpkxI7EAmnuLpgXLeOs5yN98Tfvt9RjStMvbjyQLpSIzLHI9AftvHhOPF9o YciUy8UZ9Jqm+tOCMnI92WSr3iaOQjsWrkppEXSXHhrzbjT7i9BP/vzSDjJ3XBEP/0Le 2pRdT17COgaJxNIRD12oRGq0dMpfxwcsMb756l2UdbANfvcVt4+FNzTI1MFVaPqoXaCE 5uN7epzVJt40pEBlifmZPRtpk4X5h3HYpI/lqsTImQREaZfnRuxvWQw7jnRIsGmgM6Tf GvkQe1NP/IszC0hM1VuymxhwuQkZVK+sqo/22HzBnDMxUohrjL5rpkEhZPSEbifvonnB POnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:dkim-filter:arc-authentication-results; bh=+y7Lv4MnAjuOdg5+YKg/OCZ0Drj56L7aCcPOGN6fMQA=; b=SPjAWyBVGOuoxUrZR8ffZ/+TwlBlhqTUhdPq7Oce0aQlAXi699XguuhwBYzz8sb6vu 1p9mGHvbXAeVETNW8eKhxsdhv57pra2cDd9lNuJ0lm777FIJgaCLc9lLfSwLtA9OwUIM +qqHIit/nIxRASKo2+af2uPiYPaEiQOVtyjs7WSNqIBdy3jo+0z7hVT0xNUJ6HDMym26 nqS60AM4HyGbmXsE7NXCUe6Rss1QA0MnlEu2yclzk83is6p4RMR/SHqlE/GZnCbY7Zqz Z17WJn2IOA7CwOh69fXquG+VPTy7hYSxPjjxF7COdGG2dodjh+vuiySnuq8V3ZHIVEFY 8jCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=S1liucjr; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id j24si256134edh.441.2017.10.17.06.32.33; Tue, 17 Oct 2017 06:32:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=S1liucjr; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 8BFF1C21E45; Tue, 17 Oct 2017 13:31:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 0212DC21D80; Tue, 17 Oct 2017 13:31:18 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 2697CC21D19; Tue, 17 Oct 2017 13:30:59 +0000 (UTC) Received: from conuserg-10.nifty.com (conuserg-10.nifty.com [210.131.2.77]) by lists.denx.de (Postfix) with ESMTPS id A9A08C21DF3 for ; Tue, 17 Oct 2017 13:30:55 +0000 (UTC) Received: from grover.sesame (FL1-122-131-185-176.osk.mesh.ad.jp [122.131.185.176]) (authenticated) by conuserg-10.nifty.com with ESMTP id v9HDUUVN009624; Tue, 17 Oct 2017 22:30:31 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com v9HDUUVN009624 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1508247031; bh=KySWCey4rPXpwM8wAgnbyze+KEiuFXVywq0PNtsqtmM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S1liucjrULdOrMwx1nx3Prj1LAgLdOxinS1rr3G4/Yi7jg+pSDXQnMPRMznLhM/T+ 94BVANTzZNNXoCX2rZftmJg5chnBloteyq65DoxUmJcipA/zK8HqVstWtEII0jKG89 JzCiH4WR/d+vTozCzY57ygEI2w7wYL4lBvIKQokcfWakvRiMhT/ahKnrqZ4MT0D3WF UM+Ogm3e+5C+7ffbVxahZwyUGZz3ldUny6DYpFLMEEHwjtX+2trVfyfPxcLxcPCV8D tKekeTaC7qsEAtw2HFZZ4dLm53HE1IxaXDxRq0P3rsKcfLl5gWvttsVB3etPad6xKE N/iYrII+5EwJA== X-Nifty-SrcIP: [122.131.185.176] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Tue, 17 Oct 2017 22:30:16 +0900 Message-Id: <1508247020-28071-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508247020-28071-1-git-send-email-yamada.masahiro@socionext.com> References: <1508247020-28071-1-git-send-email-yamada.masahiro@socionext.com> Subject: [U-Boot] [PATCH 1/5] libfdt: change fdt.h to a wrapper of scripts/dtc/libfdt/* X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Fortunately, U-Boot did not modify fdt.h locally. Change it to a wrapper of scripts/dtc/libfdt/fdt.h, which will be periodically synced with the upstream DTC (or kernel). Signed-off-by: Masahiro Yamada --- include/fdt.h | 2 +- lib/libfdt/fdt.h | 67 -------------------------------------------------------- 2 files changed, 1 insertion(+), 68 deletions(-) delete mode 100644 lib/libfdt/fdt.h diff --git a/include/fdt.h b/include/fdt.h index 7ead62e..caeadbf 100644 --- a/include/fdt.h +++ b/include/fdt.h @@ -1 +1 @@ -#include <../lib/libfdt/fdt.h> +#include <../scripts/dtc/libfdt/fdt.h> diff --git a/lib/libfdt/fdt.h b/lib/libfdt/fdt.h deleted file mode 100644 index 3134d78..0000000 --- a/lib/libfdt/fdt.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef _FDT_H -#define _FDT_H -/* - * libfdt - Flat Device Tree manipulation - * Copyright (C) 2006 David Gibson, IBM Corporation. - * Copyright 2012 Kim Phillips, Freescale Semiconductor. - * - * SPDX-License-Identifier: GPL-2.0+ BSD-2-Clause - */ - -#ifndef __ASSEMBLY__ - -struct fdt_header { - fdt32_t magic; /* magic word FDT_MAGIC */ - fdt32_t totalsize; /* total size of DT block */ - fdt32_t off_dt_struct; /* offset to structure */ - fdt32_t off_dt_strings; /* offset to strings */ - fdt32_t off_mem_rsvmap; /* offset to memory reserve map */ - fdt32_t version; /* format version */ - fdt32_t last_comp_version; /* last compatible version */ - - /* version 2 fields below */ - fdt32_t boot_cpuid_phys; /* Which physical CPU id we're - booting on */ - /* version 3 fields below */ - fdt32_t size_dt_strings; /* size of the strings block */ - - /* version 17 fields below */ - fdt32_t size_dt_struct; /* size of the structure block */ -}; - -struct fdt_reserve_entry { - fdt64_t address; - fdt64_t size; -}; - -struct fdt_node_header { - fdt32_t tag; - char name[0]; -}; - -struct fdt_property { - fdt32_t tag; - fdt32_t len; - fdt32_t nameoff; - char data[0]; -}; - -#endif /* !__ASSEMBLY */ - -#define FDT_MAGIC 0xd00dfeed /* 4: version, 4: total size */ -#define FDT_TAGSIZE sizeof(fdt32_t) - -#define FDT_BEGIN_NODE 0x1 /* Start node: full name */ -#define FDT_END_NODE 0x2 /* End node */ -#define FDT_PROP 0x3 /* Property: name off, - size, content */ -#define FDT_NOP 0x4 /* nop */ -#define FDT_END 0x9 - -#define FDT_V1_SIZE (7*sizeof(fdt32_t)) -#define FDT_V2_SIZE (FDT_V1_SIZE + sizeof(fdt32_t)) -#define FDT_V3_SIZE (FDT_V2_SIZE + sizeof(fdt32_t)) -#define FDT_V16_SIZE FDT_V3_SIZE -#define FDT_V17_SIZE (FDT_V16_SIZE + sizeof(fdt32_t)) - -#endif /* _FDT_H */ From patchwork Tue Oct 17 13:30:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 116106 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp4898702qgn; Tue, 17 Oct 2017 06:31:40 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBN+PcDU1jL78QxzZhDQ28kPLaG/REoBQFN4CPDfcrpk3hq76l5JtYntLSmxdERvPuKuUqE X-Received: by 10.80.205.155 with SMTP id p27mr14423623edi.255.1508247100436; Tue, 17 Oct 2017 06:31:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508247100; cv=none; d=google.com; s=arc-20160816; b=lB44kQVVXDRTrJCpZbzOtYuibJf1fhN3P56/lXTaEwcVFrke0IGXFrQW5YcUUrQB+J BEWiW/iHjy3e9otrfR63wVtwO9m6TqZ3+mJDCHYFfxUJGrrvpCZ6lSEUBMumtNFXHEdz 547RO2IM0PAuiATjQECNnBZCABqiQFKYhh9QaJCASmp7+wRyTNPo28kr74AQRDMgZFgp 8grqLOWTijwR3BLsaxVQTkmmx+4UtRqes4O001IBRsA0sG0K1YqThYchMZPTeaZ/0+RA 5nG2w6nACD32NWOD3d5sRqjBSggb2ctOtMVS5mdNHhvpzOasYnN1VoMGoPla9GknMmkM GwHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:dkim-filter:arc-authentication-results; bh=WgArozHUGaRFvbCSGFyK1AogRjqxNf10bmDhCbFOEPg=; b=GE2ZaEoLil8RyHDQFU03rCNkcLQRdii5R1W8+Px2DDDn5rPo6OPNOYr0FT83kFfFE3 F7pwLsl0AdxDlH5ds3cbN++rBkAK8NMSH1tALWM21zQZ7xPauA01vqhT5WO4SR6D3dQv y0QbnL/GMbKCjtL1wZ+WXPN2ikf94o7rfhVcaxay711AauaxXdGKDa3K08OhPtwcFyfY gyDGcdRkmT1sb4+tXkVPWjZiRyIXyinf/eSPcUJA1GNU/dnjy0EsOBwfi9hmHekJMUN3 zPnUKOXaxaPLq2rcBl8l203Sf6j6VmCWSC8pdxWpXnnOFNP8b9di7r+K74GHvipE6w0g hijg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=pPzAVSWv; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id a6si4873546ede.278.2017.10.17.06.31.40; Tue, 17 Oct 2017 06:31:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=pPzAVSWv; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id DC303C21DDF; Tue, 17 Oct 2017 13:31:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 027E2C21E33; Tue, 17 Oct 2017 13:31:10 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 0C752C21DA0; Tue, 17 Oct 2017 13:31:01 +0000 (UTC) Received: from conuserg-10.nifty.com (conuserg-10.nifty.com [210.131.2.77]) by lists.denx.de (Postfix) with ESMTPS id 9643BC21DE1 for ; Tue, 17 Oct 2017 13:30:56 +0000 (UTC) Received: from grover.sesame (FL1-122-131-185-176.osk.mesh.ad.jp [122.131.185.176]) (authenticated) by conuserg-10.nifty.com with ESMTP id v9HDUUVO009624; Tue, 17 Oct 2017 22:30:31 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com v9HDUUVO009624 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1508247031; bh=X9QOkN6DvRGQfq3b0SNyJ1IEvsplmsTnyuCKzYF3xRU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pPzAVSWvb6z1mclNsOLZYZ5nAODpc3+bpyS7vT0avZEdwoAEL0SNIQih6dO2RopTO lVd42DVTfrO+WisG9zU1zMgAMKHfBOpCGZWbINY68hBCOpf3Bjs+HVa1jz7Kquvu/W aLqkSLCzGdbaGOdaCAVsuMyzMkLpG5xm6A46gwrkCHIzIEQ6+cOF5EU1Q0BjiVqdPv zcT8LCSNESrLL2b63/uGDL2N8BoswdLoJVxhb3I3/ulYPsvw4DKunPDN9Ul9Yhmb1E 4FSCAVk7w9r0tycmKEGLr2nQlOu6ahwtusvOownIkiOhpybsxISf8Ya0i8l0WdWUlz R44mOBOoyAgqg== X-Nifty-SrcIP: [122.131.185.176] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Tue, 17 Oct 2017 22:30:17 +0900 Message-Id: <1508247020-28071-3-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508247020-28071-1-git-send-email-yamada.masahiro@socionext.com> References: <1508247020-28071-1-git-send-email-yamada.masahiro@socionext.com> Subject: [U-Boot] [PATCH 2/5] libfdt: change libfdt_internal.h to a wrapper of scripts/dtc/libfdt/* X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Fortunately, U-Boot did not modify libfdt_internal.h locally. Change it to a wrapper of scripts/dtc/libfdt/fdt.h, which will be periodically synced with the upstream DTC (or kernel). Signed-off-by: Masahiro Yamada --- lib/libfdt/libfdt_internal.h | 51 +------------------------------------------- 1 file changed, 1 insertion(+), 50 deletions(-) diff --git a/lib/libfdt/libfdt_internal.h b/lib/libfdt/libfdt_internal.h index 9a79fe8..5197c5d 100644 --- a/lib/libfdt/libfdt_internal.h +++ b/lib/libfdt/libfdt_internal.h @@ -1,50 +1 @@ -#ifndef _LIBFDT_INTERNAL_H -#define _LIBFDT_INTERNAL_H -/* - * libfdt - Flat Device Tree manipulation - * Copyright (C) 2006 David Gibson, IBM Corporation. - * SPDX-License-Identifier: GPL-2.0+ BSD-2-Clause - */ -#include - -#define FDT_ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1)) -#define FDT_TAGALIGN(x) (FDT_ALIGN((x), FDT_TAGSIZE)) - -#define FDT_CHECK_HEADER(fdt) \ - { \ - int __err; \ - if ((__err = fdt_check_header(fdt)) != 0) \ - return __err; \ - } - -int _fdt_check_node_offset(const void *fdt, int offset); -int _fdt_check_prop_offset(const void *fdt, int offset); -const char *_fdt_find_string(const char *strtab, int tabsize, const char *s); -int _fdt_node_end_offset(void *fdt, int nodeoffset); - -static inline const void *_fdt_offset_ptr(const void *fdt, int offset) -{ - return (const char *)fdt + fdt_off_dt_struct(fdt) + offset; -} - -static inline void *_fdt_offset_ptr_w(void *fdt, int offset) -{ - return (void *)(uintptr_t)_fdt_offset_ptr(fdt, offset); -} - -static inline const struct fdt_reserve_entry *_fdt_mem_rsv(const void *fdt, int n) -{ - const struct fdt_reserve_entry *rsv_table = - (const struct fdt_reserve_entry *) - ((const char *)fdt + fdt_off_mem_rsvmap(fdt)); - - return rsv_table + n; -} -static inline struct fdt_reserve_entry *_fdt_mem_rsv_w(void *fdt, int n) -{ - return (void *)(uintptr_t)_fdt_mem_rsv(fdt, n); -} - -#define FDT_SW_MAGIC (~FDT_MAGIC) - -#endif /* _LIBFDT_INTERNAL_H */ +#include "../../scripts/dtc/libfdt/libfdt_internal.h" From patchwork Tue Oct 17 13:30:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 116109 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp4900850qgn; Tue, 17 Oct 2017 06:33:34 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBb3nVbe7kUOJv+rpjCsWNOdHGmtOx0LfEbbhNjlDubQ1y26MaWvUgmIAcKnbXHLDR4TLjY X-Received: by 10.80.169.120 with SMTP id m53mr16791944edc.249.1508247214216; Tue, 17 Oct 2017 06:33:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508247214; cv=none; d=google.com; s=arc-20160816; b=L+UbrwalJdum2hUMYzTjSVINbo2+y78mpzeZH6ks6tZRPkdnMr0QBjs5+S9zpEy/XN BPLTx0Zj9n047FgDdk7wngliuH0T5u3Tt55n7JclT7f3rM9miO3s9CQBRjD18uIw0xsW ANH3c1QsBMtjivBgUYa6L1WpWqsk4u074/9I2+E/mFxFdOX+FQV1Yl16tJvV4A98wmYJ mHn7l2BWYni1qUh8XqdchLXCXiBH6UquxOMZexXyRXVKRrKXQKOM9Yzx3qp3XvdZgltK LlN77QV9QE5iviS8/rK56lgGbYJt8nTrq4L3cakAXFDsnuY85f8Ne8n7H7pn7h5BOGAt 8EWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:dkim-filter:arc-authentication-results; bh=56Yi1klLlS3TLZ1ZQb64Qj7wRp396G8m6S1EIoSfdNY=; b=x1dvbo/uuWTilDF2U8vgDEiO/CfweP4fwATzKmeJG/pee39uRqcJQ1sm5dYOLVV0NT XQLpZ8nhFjSmV/H2+NO9WiVmcKNOP2oXMm+yIJo6IooMq7R6IjPkU3MZxEuoPe2sCIyK zD1M3fzgQplKFAMqWhPnksugNlVPq6XtYGr8nqBREwhGX0jt0cTOp336Vu9vtcwZ3ewk flDXumZH6ya3HJdjPpOpM4XNUXj7FiCCWQQGdqQYCyUf9rsfCvTV++l6ZiSDdX4CRrvI PWYX1x+LtxxvkbSCMusJMvZNLtfhjfUUGwbCTY0c4bhvGlRpBW0sejWOBjCqrp6sJIs1 rvKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=n673AG7E; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id t18si2192888edi.64.2017.10.17.06.33.33; Tue, 17 Oct 2017 06:33:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=n673AG7E; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id D0F33C21E3B; Tue, 17 Oct 2017 13:33:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 250CFC21E37; Tue, 17 Oct 2017 13:31:57 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 35270C21DCE; Tue, 17 Oct 2017 13:31:32 +0000 (UTC) Received: from conuserg-10.nifty.com (conuserg-10.nifty.com [210.131.2.77]) by lists.denx.de (Postfix) with ESMTPS id 102E8C21DE1 for ; Tue, 17 Oct 2017 13:31:27 +0000 (UTC) Received: from grover.sesame (FL1-122-131-185-176.osk.mesh.ad.jp [122.131.185.176]) (authenticated) by conuserg-10.nifty.com with ESMTP id v9HDUUVP009624; Tue, 17 Oct 2017 22:30:32 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com v9HDUUVP009624 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1508247032; bh=quQA79TRfsVoozUgotXVZX8PVD4CyzH+aWjLATDhGUg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n673AG7E9ff7Bi9Htk6MbyWX8/Q0cH+szWJSEglhFPcjYIik/8M/YKG+fXMfkxHpe 6SJjekcyfrqBydu9vTNFRTc9wvBWR37eTTa9RgmCSZVZPgDj0h/0bb7042nlZ7xl1v 4IwIRMmnHICsHArl5ZVAibs4zNE3pPPiEuknCM7ZcmaXGC47a7TbVG47SMdCE/Q2ge WUHEgvQUhSICDA27mbe6u0Eh+B56725cMFVKZX1icsAo69AoWN4oo8NyJWW5Q+URoL xpBJJ55PpoIGrc6rx59K1WdvRzkxQhbyKZE5imN6t45h//74NuwJ7x5YjaoQt9jBPC N67cChL814iOg== X-Nifty-SrcIP: [122.131.185.176] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Tue, 17 Oct 2017 22:30:18 +0900 Message-Id: <1508247020-28071-4-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508247020-28071-1-git-send-email-yamada.masahiro@socionext.com> References: <1508247020-28071-1-git-send-email-yamada.masahiro@socionext.com> Cc: Stefan Roese , Hans de Goede , "oliver@schinagl.nl" , Olliver Schinagl Subject: [U-Boot] [PATCH 3/5] tools: use files from scripts/dtc/libfdt where possible X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Prior to this commit, tools/Makefile pulls all libfdt files from lib/libfdt. lib/libfdt/ and scripts/dtc/libfdt have the same copies for the followings 6 files: fdt.c fdt_addresses.c fdt_empty_tree.c fdt_overlay.c fdt_strerr.c fdt_sw.c This commit changes them to #include ones from scripts/dtc/libfdt. Unfortunately, U-Boot locally modified the following 3 files: fdt_ro.c fdt_wip.c fdt_rw.c I did not touch them in order to avoid unpredictable impact. The fdt_region.c is U-Boot own file. This is also borrowed from lib/libfdt/. Signed-off-by: Masahiro Yamada --- tools/Makefile | 15 ++++++++++----- tools/libfdt/fdt.c | 2 ++ tools/libfdt/fdt_addresses.c | 2 ++ tools/libfdt/fdt_empty_tree.c | 2 ++ tools/libfdt/fdt_overlay.c | 2 ++ tools/libfdt/fdt_strerror.c | 2 ++ tools/libfdt/fdt_sw.c | 2 ++ 7 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 tools/libfdt/fdt.c create mode 100644 tools/libfdt/fdt_addresses.c create mode 100644 tools/libfdt/fdt_empty_tree.c create mode 100644 tools/libfdt/fdt_overlay.c create mode 100644 tools/libfdt/fdt_strerror.c create mode 100644 tools/libfdt/fdt_sw.c diff --git a/tools/Makefile b/tools/Makefile index 2b87e18..acbcd87 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -58,12 +58,17 @@ hostprogs-y += dumpimage mkimage hostprogs-$(CONFIG_FIT_SIGNATURE) += fit_info fit_check_sign FIT_SIG_OBJS-$(CONFIG_FIT_SIGNATURE) := common/image-sig.o -# Flattened device tree objects -LIBFDT_CSRCS := fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c \ - fdt_empty_tree.c fdt_addresses.c fdt_overlay.c \ - fdt_region.c -LIBFDT_OBJS := $(addprefix lib/libfdt/, $(patsubst %.c, %.o, $(LIBFDT_CSRCS))) +# The following files are synced with upstream DTC. +# Use synced versions from scripts/dtc/libfdt/. +LIBFDT_SRCS_SYNCED := fdt.c fdt_sw.c fdt_strerror.c fdt_empty_tree.c \ + fdt_addresses.c fdt_overlay.c +# The following files are locally modified for U-Boot (unfotunately). +# Use U-Boot own versions from lib/libfdt/. +LIBFDT_SRCS_UNSYNCED := fdt_ro.c fdt_wip.c fdt_rw.c fdt_region.c + +LIBFDT_OBJS := $(addprefix libfdt/, $(patsubst %.c, %.o, $(LIBFDT_SRCS_SYNCED))) \ + $(addprefix lib/libfdt/, $(patsubst %.c, %.o, $(LIBFDT_SRCS_UNSYNCED))) RSA_OBJS-$(CONFIG_FIT_SIGNATURE) := $(addprefix lib/rsa/, \ rsa-sign.o rsa-verify.o rsa-checksum.o \ diff --git a/tools/libfdt/fdt.c b/tools/libfdt/fdt.c new file mode 100644 index 0000000..8ba8091 --- /dev/null +++ b/tools/libfdt/fdt.c @@ -0,0 +1,2 @@ +#include "fdt_host.h" +#include "../scripts/dtc/libfdt/fdt.c" diff --git a/tools/libfdt/fdt_addresses.c b/tools/libfdt/fdt_addresses.c new file mode 100644 index 0000000..242a2c0 --- /dev/null +++ b/tools/libfdt/fdt_addresses.c @@ -0,0 +1,2 @@ +#include "fdt_host.h" +#include "../scripts/dtc/libfdt/fdt_addresses.c" diff --git a/tools/libfdt/fdt_empty_tree.c b/tools/libfdt/fdt_empty_tree.c new file mode 100644 index 0000000..9ccbb1f --- /dev/null +++ b/tools/libfdt/fdt_empty_tree.c @@ -0,0 +1,2 @@ +#include "fdt_host.h" +#include "../scripts/dtc/libfdt/fdt_empty_tree.c" diff --git a/tools/libfdt/fdt_overlay.c b/tools/libfdt/fdt_overlay.c new file mode 100644 index 0000000..801ec37 --- /dev/null +++ b/tools/libfdt/fdt_overlay.c @@ -0,0 +1,2 @@ +#include "fdt_host.h" +#include "../scripts/dtc/libfdt/fdt_overlay.c" diff --git a/tools/libfdt/fdt_strerror.c b/tools/libfdt/fdt_strerror.c new file mode 100644 index 0000000..d7ed70b --- /dev/null +++ b/tools/libfdt/fdt_strerror.c @@ -0,0 +1,2 @@ +#include "fdt_host.h" +#include "../scripts/dtc/libfdt/fdt_strerror.c" diff --git a/tools/libfdt/fdt_sw.c b/tools/libfdt/fdt_sw.c new file mode 100644 index 0000000..ed6b327 --- /dev/null +++ b/tools/libfdt/fdt_sw.c @@ -0,0 +1,2 @@ +#include "fdt_host.h" +#include "../scripts/dtc/libfdt/fdt_sw.c" From patchwork Tue Oct 17 13:30:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 116105 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp4897863qgn; Tue, 17 Oct 2017 06:30:58 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCq8u/t1qCbTBBUhC5RFIfwleFzofyHQGMPDFPvhwhihW5lsM4nyf5+Qg0Cwwmu7mSg2V6M X-Received: by 10.80.167.37 with SMTP id h34mr17067760edc.223.1508247055920; Tue, 17 Oct 2017 06:30:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508247055; cv=none; d=google.com; s=arc-20160816; b=zGFM7+2pbA5/UJRL29QSt8rnN8FvuzzCcFOJYylcMs5WyEx3m0wcbORZyhf+X8Jaaf vD5Du4HXNqKseFAsqzMbw30Xs470ZSgPBfLHBJZteKKMIW8LLpG7CQ+OyZ/DGs0Lz/K7 77MirrkN9oqqW5/Eu72DgNeYg9vdUtJw3sqo2nr+oxiH8Gm3SztuHVTA4A3rbwWqyG2o ztOJ/AdosB9NMQOwNB7i4lureNJWfrKZwqF7klfIEpzNwBIoWPEKGzTy6v6dk6Tvba2/ RUzZaH39MagekPMgfGVTzBaEfDX+wMk9GDanaLX3fAfddgIGbFunc/4fZtw4/0/eD7a2 HsWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:dkim-filter:arc-authentication-results; bh=Rr5t4vI6hxTcjXri3BVzAX5YjYuDKOs68cmUFETmrqU=; b=sjq6ZThdrBixALthOzVHe65yRNi9GBnZlHQgGPSkSr4byfR4S3bUEx3aqcrTRjA+RM icBsvq7ixUpXLdp8+zOKzIEQxdUTgIYzchg+1Iw+zNELZv8ms2Z2L46o/+b8i69iXXCy LOV/sR1S0vAA8NwV4vCXNGtsYKX+KS1n2PzU/UEmE7LaYCjavS5Qr+BOuzkLJZL4But+ nD/s4b8MKkxHKinT/JWEW8ueASPG5O9zT2P4OMqQk6UU9CACzaxtEsRh4jEdtNK8xaM5 3gYmZDkFG5X/QVi0GWPSD+HHO1fCW7pC5lZWEoD6xRsFTuxj6tM6O8uXZPpMITUcr/Ct G0Tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=EIhCsgHl; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id i63si1999884edi.407.2017.10.17.06.30.55; Tue, 17 Oct 2017 06:30:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=EIhCsgHl; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 0E794C21D80; Tue, 17 Oct 2017 13:30:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 5B8C2C21C71; Tue, 17 Oct 2017 13:30:47 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id ECBF0C21C71; Tue, 17 Oct 2017 13:30:45 +0000 (UTC) Received: from conuserg-10.nifty.com (conuserg-10.nifty.com [210.131.2.77]) by lists.denx.de (Postfix) with ESMTPS id DF8A8C21C40 for ; Tue, 17 Oct 2017 13:30:44 +0000 (UTC) Received: from grover.sesame (FL1-122-131-185-176.osk.mesh.ad.jp [122.131.185.176]) (authenticated) by conuserg-10.nifty.com with ESMTP id v9HDUUVQ009624; Tue, 17 Oct 2017 22:30:33 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com v9HDUUVQ009624 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1508247033; bh=iCw7YY0HfaSkC/9MFHAwniDkUeYf6JIdG9hCUe3rj0A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EIhCsgHlzLDsv4kz+jO/weoYqph2le6Takm6rPGqBcVpdhU8sa48N6Jn7lHaO/lrK O4Sp+uBJW6MCg6acddwhfjVNFhJ/9WBdVbgcfr6C7Tqv3pwDcaSioVcWVib5tfTeo2 hz3TUj40Xqke7p4JcgYMJNyajH8h4pBYai79ZZaXmPrYAS1vzFVRKAUhh8HLKtMnQq rOBsM+KCAI8wBwkYBS8wz4gSsOFMGP9CY95Xxy2RqX+9/Wu2Uh13ASlcJY8nvRshB5 VeMXrb5DIqj8WYyybejhDbVvtD3MVftwGjBdYWf5kX04/J1UmacWhhAg76NI5yzoLD o40GLIgJwTILg== X-Nifty-SrcIP: [122.131.185.176] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Tue, 17 Oct 2017 22:30:19 +0900 Message-Id: <1508247020-28071-5-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508247020-28071-1-git-send-email-yamada.masahiro@socionext.com> References: <1508247020-28071-1-git-send-email-yamada.masahiro@socionext.com> Subject: [U-Boot] [PATCH 4/5] linux/types.h: add typedef of uintptr_t X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Add this typedef in the same place as in Linux. This is necessary to refactor libfdt inclusion. U-Boot also defines it in include/compiler.h. Of course it should not do that, but I do not want to open a can of worms. Signed-off-by: Masahiro Yamada --- include/linux/types.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/types.h b/include/linux/types.h index 416fa66..7c33e7a 100644 --- a/include/linux/types.h +++ b/include/linux/types.h @@ -24,6 +24,8 @@ typedef __kernel_gid32_t gid_t; typedef __kernel_uid16_t uid16_t; typedef __kernel_gid16_t gid16_t; +typedef unsigned long uintptr_t; + #ifdef CONFIG_UID16 /* This is defined by include/asm-{arch}/posix_types.h */ typedef __kernel_old_uid_t old_uid_t; From patchwork Tue Oct 17 13:30:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 116107 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp4899142qgn; Tue, 17 Oct 2017 06:32:02 -0700 (PDT) X-Google-Smtp-Source: AOwi7QA4gurQX+nCWF3ps9eCxRhjCm8p+1owBaAZBLdDEOJ+jFxw6T3SIpUbFn0mwMOfP634+T2J X-Received: by 10.80.135.228 with SMTP id 33mr17769075edz.210.1508247122366; Tue, 17 Oct 2017 06:32:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508247122; cv=none; d=google.com; s=arc-20160816; b=Slf+j37gjVZlFYPJQI/kJprnIlHkDmsMHBgFGUvkePJ61rYZMhIs2OfjCwHdgmKRK+ cEvZte8/6K4l+ODXo04/hsIIwF6AX6uAjgZ8VQIfym7qAyeALo52SeUXBUOarfKOJiOs R3V8BVDfsNyFfbYSmE3LvnE71QQABD+f+ZgMxS0gl6TtNB69FrxKraKMlNp4pR1CEPar endz7kLfRmF5+/OnNzuTJbS/rE80MHpgzT3wueK7VoPRRoUE8RN8PrMsTI90WTMeBdqg PUVipNiTM2upbmDV09rookWeZBYvjjvdXIEl7o6tllVPsEe9AoJQL569/+iM9kvnqYCi 82hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:dkim-filter:arc-authentication-results; bh=1hJSiF3ULj2yxu4Eq7aIjDw8z+9Rv3c+Wf8WcI2Rjbs=; b=m47Wgd4uHb/vUIbvjd2tIFuGvYljwDRT3oA3Nn9clvz867TrrDZdVQ+Mefk5JA0O2E B39WjUF2OOMa5AjA8pg5M4F7nVcvxXFmC7KTGM14N82LYr0xZZO4gw2KN4i0PgEUnPA+ UnvprK5d1kE+u3z3yX9dXQTD6u5N/d4dfkyoRDp/Sy+ajWBpO6xhif14Y4K4gJ01NQVz wMKIdoUl+YvVZPPisz+h2jT4dm+ZbGW5mErXc6giaTXp9yvLsKmHtTCZpJ3c5++PfRCe IRilw0uvhI+kpv+pQZW7NZEJCOMhEclciOOxROvu9og93UGl5XZaos3kKCm8ifnUiEDT 61gQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=Hmnh9nU8; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id e14si1594620edm.95.2017.10.17.06.32.02; Tue, 17 Oct 2017 06:32:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=Hmnh9nU8; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id CDC5FC21D8C; Tue, 17 Oct 2017 13:31:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 18E6AC21C40; Tue, 17 Oct 2017 13:31:19 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 41E5FC21C40; Tue, 17 Oct 2017 13:31:01 +0000 (UTC) Received: from conuserg-10.nifty.com (conuserg-10.nifty.com [210.131.2.77]) by lists.denx.de (Postfix) with ESMTPS id 0937BC21D8D for ; Tue, 17 Oct 2017 13:30:55 +0000 (UTC) Received: from grover.sesame (FL1-122-131-185-176.osk.mesh.ad.jp [122.131.185.176]) (authenticated) by conuserg-10.nifty.com with ESMTP id v9HDUUVR009624; Tue, 17 Oct 2017 22:30:33 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com v9HDUUVR009624 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1508247033; bh=WCHCuBtchhiyIdf7Js5ZZLKbUJEZfdpIX/idCvkoJZA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hmnh9nU8KMSsb8MvXGatINJKTysQLfgCs17Xet8gRprRNopWZVMr8lvB0FA8bj67z KaDPSbH/IWFr8VPXV4sn1u0InVLZTRPQHLiQr7kTpfKUPkRLqC0F4uuuqf4t7gtA5+ dIVkag1wAfYBGOff33eNhHEBcpIQP+YtATMwMT+FBZJzcapws7DNGwcOwdjwoSq70L /OLsdrpY7rYFOOn/rNs7Qnq1llKMjG5M0s40njn8+ru1xhN6j+d1gdbzzR8lKfRvvO blhp1JkbPHPALg3G+Jl1KLRpMiloJnr/uHozxDbJvw46NB8GiLxC6G3AzamqG4a/AQ IRVfho/LusQvA== X-Nifty-SrcIP: [122.131.185.176] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Tue, 17 Oct 2017 22:30:20 +0900 Message-Id: <1508247020-28071-6-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508247020-28071-1-git-send-email-yamada.masahiro@socionext.com> References: <1508247020-28071-1-git-send-email-yamada.masahiro@socionext.com> Subject: [U-Boot] [PATCH 5/5] lib: libfdt: wrap scripts/dtc/libfdt/* where possible X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" lib/libfdt/ and scripts/dtc/libfdt have the same copies for the followings 6 files: fdt.c fdt_addresses.c fdt_empty_tree.c fdt_overlay.c fdt_strerr.c fdt_sw.c Make them a wrapper of scripts/dtc/libfdt/*. This is exactly what Linux does to sync libfdt. In order to make is possible, import and from Linux 4.14-rc5. Unfortunately, U-Boot locally modified the following 3 files: fdt_ro.c fdt_wip.c fdt_rw.c The fdt_region.c is U-Boot own file. I did not touch them in order to avoid unpredictable impact. Signed-off-by: Masahiro Yamada --- include/libfdt_env.h | 6 - include/linux/libfdt.h | 17 + include/linux/libfdt_env.h | 22 ++ lib/libfdt/Makefile | 17 +- lib/libfdt/fdt.c | 212 +---------- lib/libfdt/fdt_addresses.c | 57 +-- lib/libfdt/fdt_empty_tree.c | 39 +- lib/libfdt/fdt_overlay.c | 863 +------------------------------------------- lib/libfdt/fdt_strerror.c | 63 +--- lib/libfdt/fdt_sw.c | 256 +------------ 10 files changed, 63 insertions(+), 1489 deletions(-) create mode 100644 include/linux/libfdt.h create mode 100644 include/linux/libfdt_env.h diff --git a/include/libfdt_env.h b/include/libfdt_env.h index 6c6845f..273b5d3 100644 --- a/include/libfdt_env.h +++ b/include/libfdt_env.h @@ -23,12 +23,6 @@ typedef __be64 fdt64_t; #define fdt64_to_cpu(x) be64_to_cpu(x) #define cpu_to_fdt64(x) cpu_to_be64(x) -#ifdef __UBOOT__ -#include - -#define strtoul(cp, endp, base) simple_strtoul(cp, endp, base) -#endif - /* adding a ramdisk needs 0x44 bytes in version 2008.10 */ #define FDT_RAMDISK_OVERHEAD 0x80 diff --git a/include/linux/libfdt.h b/include/linux/libfdt.h new file mode 100644 index 0000000..2a663c6 --- /dev/null +++ b/include/linux/libfdt.h @@ -0,0 +1,17 @@ +#ifndef _LIBFDT_ENV_H +#define _LIBFDT_ENV_H + +#include + +#include + +typedef __be16 fdt16_t; +typedef __be32 fdt32_t; +typedef __be64 fdt64_t; + +#define fdt32_to_cpu(x) be32_to_cpu(x) +#define cpu_to_fdt32(x) cpu_to_be32(x) +#define fdt64_to_cpu(x) be64_to_cpu(x) +#define cpu_to_fdt64(x) cpu_to_be64(x) + +#endif /* _LIBFDT_ENV_H */ diff --git a/include/linux/libfdt_env.h b/include/linux/libfdt_env.h new file mode 100644 index 0000000..8178f91 --- /dev/null +++ b/include/linux/libfdt_env.h @@ -0,0 +1,22 @@ +#ifndef _LIBFDT_ENV_H +#define _LIBFDT_ENV_H + +#include + +#include + +typedef __be16 fdt16_t; +typedef __be32 fdt32_t; +typedef __be64 fdt64_t; + +#define fdt32_to_cpu(x) be32_to_cpu(x) +#define cpu_to_fdt32(x) cpu_to_be32(x) +#define fdt64_to_cpu(x) be64_to_cpu(x) +#define cpu_to_fdt64(x) cpu_to_be64(x) + +/* U-Boot: for strtoul in fdt_overlay.c */ +#include + +#define strtoul(cp, endp, base) simple_strtoul(cp, endp, base) + +#endif /* _LIBFDT_ENV_H */ diff --git a/lib/libfdt/Makefile b/lib/libfdt/Makefile index 6ef8290..369bbf9 100644 --- a/lib/libfdt/Makefile +++ b/lib/libfdt/Makefile @@ -5,15 +5,22 @@ # SPDX-License-Identifier: GPL-2.0+ # +# Use upstream code. obj-y += \ fdt.o \ - fdt_ro.o \ - fdt_rw.o \ fdt_strerror.o \ fdt_sw.o \ - fdt_wip.o \ fdt_empty_tree.o \ - fdt_addresses.o \ - fdt_region.o + fdt_addresses.o obj-$(CONFIG_OF_LIBFDT_OVERLAY) += fdt_overlay.o + +# Locally modified for U-Boot. +# TODO: split out the local modifiction. +obj-y += \ + fdt_ro.o \ + fdt_rw.o \ + fdt_wip.o \ + +# U-Boot own file +obj-y += fdt_region.o diff --git a/lib/libfdt/fdt.c b/lib/libfdt/fdt.c index 2055734..0958e6ba 100644 --- a/lib/libfdt/fdt.c +++ b/lib/libfdt/fdt.c @@ -1,210 +1,2 @@ -/* - * libfdt - Flat Device Tree manipulation - * Copyright (C) 2006 David Gibson, IBM Corporation. - * SPDX-License-Identifier: GPL-2.0+ BSD-2-Clause - */ -#include - -#ifndef USE_HOSTCC -#include -#include -#else -#include "fdt_host.h" -#endif - -#include "libfdt_internal.h" - -int fdt_check_header(const void *fdt) -{ - if (fdt_magic(fdt) == FDT_MAGIC) { - /* Complete tree */ - if (fdt_version(fdt) < FDT_FIRST_SUPPORTED_VERSION) - return -FDT_ERR_BADVERSION; - if (fdt_last_comp_version(fdt) > FDT_LAST_SUPPORTED_VERSION) - return -FDT_ERR_BADVERSION; - } else if (fdt_magic(fdt) == FDT_SW_MAGIC) { - /* Unfinished sequential-write blob */ - if (fdt_size_dt_struct(fdt) == 0) - return -FDT_ERR_BADSTATE; - } else { - return -FDT_ERR_BADMAGIC; - } - - return 0; -} - -const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int len) -{ - unsigned absoffset = offset + fdt_off_dt_struct(fdt); - - if ((absoffset < offset) - || ((absoffset + len) < absoffset) - || (absoffset + len) > fdt_totalsize(fdt)) - return NULL; - - if (fdt_version(fdt) >= 0x11) - if (((offset + len) < offset) - || ((offset + len) > fdt_size_dt_struct(fdt))) - return NULL; - - return _fdt_offset_ptr(fdt, offset); -} - -uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset) -{ - const fdt32_t *tagp, *lenp; - uint32_t tag; - int offset = startoffset; - const char *p; - - *nextoffset = -FDT_ERR_TRUNCATED; - tagp = fdt_offset_ptr(fdt, offset, FDT_TAGSIZE); - if (!tagp) - return FDT_END; /* premature end */ - tag = fdt32_to_cpu(*tagp); - offset += FDT_TAGSIZE; - - *nextoffset = -FDT_ERR_BADSTRUCTURE; - switch (tag) { - case FDT_BEGIN_NODE: - /* skip name */ - do { - p = fdt_offset_ptr(fdt, offset++, 1); - } while (p && (*p != '\0')); - if (!p) - return FDT_END; /* premature end */ - break; - - case FDT_PROP: - lenp = fdt_offset_ptr(fdt, offset, sizeof(*lenp)); - if (!lenp) - return FDT_END; /* premature end */ - /* skip-name offset, length and value */ - offset += sizeof(struct fdt_property) - FDT_TAGSIZE - + fdt32_to_cpu(*lenp); - break; - - case FDT_END: - case FDT_END_NODE: - case FDT_NOP: - break; - - default: - return FDT_END; - } - - if (!fdt_offset_ptr(fdt, startoffset, offset - startoffset)) - return FDT_END; /* premature end */ - - *nextoffset = FDT_TAGALIGN(offset); - return tag; -} - -int _fdt_check_node_offset(const void *fdt, int offset) -{ - if ((offset < 0) || (offset % FDT_TAGSIZE) - || (fdt_next_tag(fdt, offset, &offset) != FDT_BEGIN_NODE)) - return -FDT_ERR_BADOFFSET; - - return offset; -} - -int _fdt_check_prop_offset(const void *fdt, int offset) -{ - if ((offset < 0) || (offset % FDT_TAGSIZE) - || (fdt_next_tag(fdt, offset, &offset) != FDT_PROP)) - return -FDT_ERR_BADOFFSET; - - return offset; -} - -int fdt_next_node(const void *fdt, int offset, int *depth) -{ - int nextoffset = 0; - uint32_t tag; - - if (offset >= 0) - if ((nextoffset = _fdt_check_node_offset(fdt, offset)) < 0) - return nextoffset; - - do { - offset = nextoffset; - tag = fdt_next_tag(fdt, offset, &nextoffset); - - switch (tag) { - case FDT_PROP: - case FDT_NOP: - break; - - case FDT_BEGIN_NODE: - if (depth) - (*depth)++; - break; - - case FDT_END_NODE: - if (depth && ((--(*depth)) < 0)) - return nextoffset; - break; - - case FDT_END: - if ((nextoffset >= 0) - || ((nextoffset == -FDT_ERR_TRUNCATED) && !depth)) - return -FDT_ERR_NOTFOUND; - else - return nextoffset; - } - } while (tag != FDT_BEGIN_NODE); - - return offset; -} - -int fdt_first_subnode(const void *fdt, int offset) -{ - int depth = 0; - - offset = fdt_next_node(fdt, offset, &depth); - if (offset < 0 || depth != 1) - return -FDT_ERR_NOTFOUND; - - return offset; -} - -int fdt_next_subnode(const void *fdt, int offset) -{ - int depth = 1; - - /* - * With respect to the parent, the depth of the next subnode will be - * the same as the last. - */ - do { - offset = fdt_next_node(fdt, offset, &depth); - if (offset < 0 || depth < 1) - return -FDT_ERR_NOTFOUND; - } while (depth > 1); - - return offset; -} - -const char *_fdt_find_string(const char *strtab, int tabsize, const char *s) -{ - int len = strlen(s) + 1; - const char *last = strtab + tabsize - len; - const char *p; - - for (p = strtab; p <= last; p++) - if (memcmp(p, s, len) == 0) - return p; - return NULL; -} - -int fdt_move(const void *fdt, void *buf, int bufsize) -{ - FDT_CHECK_HEADER(fdt); - - if (fdt_totalsize(fdt) > bufsize) - return -FDT_ERR_NOSPACE; - - memmove(buf, fdt, fdt_totalsize(fdt)); - return 0; -} +#include +#include "../../scripts/dtc/libfdt/fdt.c" diff --git a/lib/libfdt/fdt_addresses.c b/lib/libfdt/fdt_addresses.c index b6bc66e..b82a029 100644 --- a/lib/libfdt/fdt_addresses.c +++ b/lib/libfdt/fdt_addresses.c @@ -1,55 +1,2 @@ -/* - * libfdt - Flat Device Tree manipulation - * Copyright (C) 2014 David Gibson - * SPDX-License-Identifier: GPL-2.0+ BSD-2-Clause - */ -#include - -#ifndef USE_HOSTCC -#include -#include -#else -#include "fdt_host.h" -#endif - -#include "libfdt_internal.h" - -int fdt_address_cells(const void *fdt, int nodeoffset) -{ - const fdt32_t *ac; - int val; - int len; - - ac = fdt_getprop(fdt, nodeoffset, "#address-cells", &len); - if (!ac) - return 2; - - if (len != sizeof(*ac)) - return -FDT_ERR_BADNCELLS; - - val = fdt32_to_cpu(*ac); - if ((val <= 0) || (val > FDT_MAX_NCELLS)) - return -FDT_ERR_BADNCELLS; - - return val; -} - -int fdt_size_cells(const void *fdt, int nodeoffset) -{ - const fdt32_t *sc; - int val; - int len; - - sc = fdt_getprop(fdt, nodeoffset, "#size-cells", &len); - if (!sc) - return 2; - - if (len != sizeof(*sc)) - return -FDT_ERR_BADNCELLS; - - val = fdt32_to_cpu(*sc); - if ((val < 0) || (val > FDT_MAX_NCELLS)) - return -FDT_ERR_BADNCELLS; - - return val; -} +#include +#include "../../scripts/dtc/libfdt/fdt_addresses.c" diff --git a/lib/libfdt/fdt_empty_tree.c b/lib/libfdt/fdt_empty_tree.c index 6fde1eb..2b4ae10 100644 --- a/lib/libfdt/fdt_empty_tree.c +++ b/lib/libfdt/fdt_empty_tree.c @@ -1,37 +1,2 @@ -/* - * libfdt - Flat Device Tree manipulation - * Copyright (C) 2012 David Gibson, IBM Corporation. - * SPDX-License-Identifier: GPL-2.0+ BSD-2-Clause - */ -#include -#include -#include - -#include "libfdt_internal.h" - -int fdt_create_empty_tree(void *buf, int bufsize) -{ - int err; - - err = fdt_create(buf, bufsize); - if (err) - return err; - - err = fdt_finish_reservemap(buf); - if (err) - return err; - - err = fdt_begin_node(buf, ""); - if (err) - return err; - - err = fdt_end_node(buf); - if (err) - return err; - - err = fdt_finish(buf); - if (err) - return err; - - return fdt_open_into(buf, buf, bufsize); -} +#include +#include "../../scripts/dtc/libfdt/fdt_empty_tree.c" diff --git a/lib/libfdt/fdt_overlay.c b/lib/libfdt/fdt_overlay.c index bd81241..575c827 100644 --- a/lib/libfdt/fdt_overlay.c +++ b/lib/libfdt/fdt_overlay.c @@ -1,861 +1,2 @@ -#include "libfdt_env.h" - -#include -#include - -#include "libfdt_internal.h" - -/** - * overlay_get_target_phandle - retrieves the target phandle of a fragment - * @fdto: pointer to the device tree overlay blob - * @fragment: node offset of the fragment in the overlay - * - * overlay_get_target_phandle() retrieves the target phandle of an - * overlay fragment when that fragment uses a phandle (target - * property) instead of a path (target-path property). - * - * returns: - * the phandle pointed by the target property - * 0, if the phandle was not found - * -1, if the phandle was malformed - */ -static uint32_t overlay_get_target_phandle(const void *fdto, int fragment) -{ - const fdt32_t *val; - int len; - - val = fdt_getprop(fdto, fragment, "target", &len); - if (!val) - return 0; - - if ((len != sizeof(*val)) || (fdt32_to_cpu(*val) == (uint32_t)-1)) - return (uint32_t)-1; - - return fdt32_to_cpu(*val); -} - -/** - * overlay_get_target - retrieves the offset of a fragment's target - * @fdt: Base device tree blob - * @fdto: Device tree overlay blob - * @fragment: node offset of the fragment in the overlay - * @pathp: pointer which receives the path of the target (or NULL) - * - * overlay_get_target() retrieves the target offset in the base - * device tree of a fragment, no matter how the actual targetting is - * done (through a phandle or a path) - * - * returns: - * the targetted node offset in the base device tree - * Negative error code on error - */ -static int overlay_get_target(const void *fdt, const void *fdto, - int fragment, char const **pathp) -{ - uint32_t phandle; - const char *path = NULL; - int path_len = 0, ret; - - /* Try first to do a phandle based lookup */ - phandle = overlay_get_target_phandle(fdto, fragment); - if (phandle == (uint32_t)-1) - return -FDT_ERR_BADPHANDLE; - - /* no phandle, try path */ - if (!phandle) { - /* And then a path based lookup */ - path = fdt_getprop(fdto, fragment, "target-path", &path_len); - if (path) - ret = fdt_path_offset(fdt, path); - else - ret = path_len; - } else - ret = fdt_node_offset_by_phandle(fdt, phandle); - - /* - * If we haven't found either a target or a - * target-path property in a node that contains a - * __overlay__ subnode (we wouldn't be called - * otherwise), consider it a improperly written - * overlay - */ - if (ret < 0 && path_len == -FDT_ERR_NOTFOUND) - ret = -FDT_ERR_BADOVERLAY; - - /* return on error */ - if (ret < 0) - return ret; - - /* return pointer to path (if available) */ - if (pathp) - *pathp = path ? path : NULL; - - return ret; -} - -/** - * overlay_phandle_add_offset - Increases a phandle by an offset - * @fdt: Base device tree blob - * @node: Device tree overlay blob - * @name: Name of the property to modify (phandle or linux,phandle) - * @delta: offset to apply - * - * overlay_phandle_add_offset() increments a node phandle by a given - * offset. - * - * returns: - * 0 on success. - * Negative error code on error - */ -static int overlay_phandle_add_offset(void *fdt, int node, - const char *name, uint32_t delta) -{ - const fdt32_t *val; - uint32_t adj_val; - int len; - - val = fdt_getprop(fdt, node, name, &len); - if (!val) - return len; - - if (len != sizeof(*val)) - return -FDT_ERR_BADPHANDLE; - - adj_val = fdt32_to_cpu(*val); - if ((adj_val + delta) < adj_val) - return -FDT_ERR_NOPHANDLES; - - adj_val += delta; - if (adj_val == (uint32_t)-1) - return -FDT_ERR_NOPHANDLES; - - return fdt_setprop_inplace_u32(fdt, node, name, adj_val); -} - -/** - * overlay_adjust_node_phandles - Offsets the phandles of a node - * @fdto: Device tree overlay blob - * @node: Offset of the node we want to adjust - * @delta: Offset to shift the phandles of - * - * overlay_adjust_node_phandles() adds a constant to all the phandles - * of a given node. This is mainly use as part of the overlay - * application process, when we want to update all the overlay - * phandles to not conflict with the overlays of the base device tree. - * - * returns: - * 0 on success - * Negative error code on failure - */ -static int overlay_adjust_node_phandles(void *fdto, int node, - uint32_t delta) -{ - int child; - int ret; - - ret = overlay_phandle_add_offset(fdto, node, "phandle", delta); - if (ret && ret != -FDT_ERR_NOTFOUND) - return ret; - - ret = overlay_phandle_add_offset(fdto, node, "linux,phandle", delta); - if (ret && ret != -FDT_ERR_NOTFOUND) - return ret; - - fdt_for_each_subnode(child, fdto, node) { - ret = overlay_adjust_node_phandles(fdto, child, delta); - if (ret) - return ret; - } - - return 0; -} - -/** - * overlay_adjust_local_phandles - Adjust the phandles of a whole overlay - * @fdto: Device tree overlay blob - * @delta: Offset to shift the phandles of - * - * overlay_adjust_local_phandles() adds a constant to all the - * phandles of an overlay. This is mainly use as part of the overlay - * application process, when we want to update all the overlay - * phandles to not conflict with the overlays of the base device tree. - * - * returns: - * 0 on success - * Negative error code on failure - */ -static int overlay_adjust_local_phandles(void *fdto, uint32_t delta) -{ - /* - * Start adjusting the phandles from the overlay root - */ - return overlay_adjust_node_phandles(fdto, 0, delta); -} - -/** - * overlay_update_local_node_references - Adjust the overlay references - * @fdto: Device tree overlay blob - * @tree_node: Node offset of the node to operate on - * @fixup_node: Node offset of the matching local fixups node - * @delta: Offset to shift the phandles of - * - * overlay_update_local_nodes_references() update the phandles - * pointing to a node within the device tree overlay by adding a - * constant delta. - * - * This is mainly used as part of a device tree application process, - * where you want the device tree overlays phandles to not conflict - * with the ones from the base device tree before merging them. - * - * returns: - * 0 on success - * Negative error code on failure - */ -static int overlay_update_local_node_references(void *fdto, - int tree_node, - int fixup_node, - uint32_t delta) -{ - int fixup_prop; - int fixup_child; - int ret; - - fdt_for_each_property_offset(fixup_prop, fdto, fixup_node) { - const fdt32_t *fixup_val; - const char *tree_val; - const char *name; - int fixup_len; - int tree_len; - int i; - - fixup_val = fdt_getprop_by_offset(fdto, fixup_prop, - &name, &fixup_len); - if (!fixup_val) - return fixup_len; - - if (fixup_len % sizeof(uint32_t)) - return -FDT_ERR_BADOVERLAY; - - tree_val = fdt_getprop(fdto, tree_node, name, &tree_len); - if (!tree_val) { - if (tree_len == -FDT_ERR_NOTFOUND) - return -FDT_ERR_BADOVERLAY; - - return tree_len; - } - - for (i = 0; i < (fixup_len / sizeof(uint32_t)); i++) { - fdt32_t adj_val; - uint32_t poffset; - - poffset = fdt32_to_cpu(fixup_val[i]); - - /* - * phandles to fixup can be unaligned. - * - * Use a memcpy for the architectures that do - * not support unaligned accesses. - */ - memcpy(&adj_val, tree_val + poffset, sizeof(adj_val)); - - adj_val = cpu_to_fdt32(fdt32_to_cpu(adj_val) + delta); - - ret = fdt_setprop_inplace_namelen_partial(fdto, - tree_node, - name, - strlen(name), - poffset, - &adj_val, - sizeof(adj_val)); - if (ret == -FDT_ERR_NOSPACE) - return -FDT_ERR_BADOVERLAY; - - if (ret) - return ret; - } - } - - fdt_for_each_subnode(fixup_child, fdto, fixup_node) { - const char *fixup_child_name = fdt_get_name(fdto, fixup_child, - NULL); - int tree_child; - - tree_child = fdt_subnode_offset(fdto, tree_node, - fixup_child_name); - if (tree_child == -FDT_ERR_NOTFOUND) - return -FDT_ERR_BADOVERLAY; - if (tree_child < 0) - return tree_child; - - ret = overlay_update_local_node_references(fdto, - tree_child, - fixup_child, - delta); - if (ret) - return ret; - } - - return 0; -} - -/** - * overlay_update_local_references - Adjust the overlay references - * @fdto: Device tree overlay blob - * @delta: Offset to shift the phandles of - * - * overlay_update_local_references() update all the phandles pointing - * to a node within the device tree overlay by adding a constant - * delta to not conflict with the base overlay. - * - * This is mainly used as part of a device tree application process, - * where you want the device tree overlays phandles to not conflict - * with the ones from the base device tree before merging them. - * - * returns: - * 0 on success - * Negative error code on failure - */ -static int overlay_update_local_references(void *fdto, uint32_t delta) -{ - int fixups; - - fixups = fdt_path_offset(fdto, "/__local_fixups__"); - if (fixups < 0) { - /* There's no local phandles to adjust, bail out */ - if (fixups == -FDT_ERR_NOTFOUND) - return 0; - - return fixups; - } - - /* - * Update our local references from the root of the tree - */ - return overlay_update_local_node_references(fdto, 0, fixups, - delta); -} - -/** - * overlay_fixup_one_phandle - Set an overlay phandle to the base one - * @fdt: Base Device Tree blob - * @fdto: Device tree overlay blob - * @symbols_off: Node offset of the symbols node in the base device tree - * @path: Path to a node holding a phandle in the overlay - * @path_len: number of path characters to consider - * @name: Name of the property holding the phandle reference in the overlay - * @name_len: number of name characters to consider - * @poffset: Offset within the overlay property where the phandle is stored - * @label: Label of the node referenced by the phandle - * - * overlay_fixup_one_phandle() resolves an overlay phandle pointing to - * a node in the base device tree. - * - * This is part of the device tree overlay application process, when - * you want all the phandles in the overlay to point to the actual - * base dt nodes. - * - * returns: - * 0 on success - * Negative error code on failure - */ -static int overlay_fixup_one_phandle(void *fdt, void *fdto, - int symbols_off, - const char *path, uint32_t path_len, - const char *name, uint32_t name_len, - int poffset, const char *label) -{ - const char *symbol_path; - uint32_t phandle; - fdt32_t phandle_prop; - int symbol_off, fixup_off; - int prop_len; - - if (symbols_off < 0) - return symbols_off; - - symbol_path = fdt_getprop(fdt, symbols_off, label, - &prop_len); - if (!symbol_path) - return prop_len; - - symbol_off = fdt_path_offset(fdt, symbol_path); - if (symbol_off < 0) - return symbol_off; - - phandle = fdt_get_phandle(fdt, symbol_off); - if (!phandle) - return -FDT_ERR_NOTFOUND; - - fixup_off = fdt_path_offset_namelen(fdto, path, path_len); - if (fixup_off == -FDT_ERR_NOTFOUND) - return -FDT_ERR_BADOVERLAY; - if (fixup_off < 0) - return fixup_off; - - phandle_prop = cpu_to_fdt32(phandle); - return fdt_setprop_inplace_namelen_partial(fdto, fixup_off, - name, name_len, poffset, - &phandle_prop, - sizeof(phandle_prop)); -}; - -/** - * overlay_fixup_phandle - Set an overlay phandle to the base one - * @fdt: Base Device Tree blob - * @fdto: Device tree overlay blob - * @symbols_off: Node offset of the symbols node in the base device tree - * @property: Property offset in the overlay holding the list of fixups - * - * overlay_fixup_phandle() resolves all the overlay phandles pointed - * to in a __fixups__ property, and updates them to match the phandles - * in use in the base device tree. - * - * This is part of the device tree overlay application process, when - * you want all the phandles in the overlay to point to the actual - * base dt nodes. - * - * returns: - * 0 on success - * Negative error code on failure - */ -static int overlay_fixup_phandle(void *fdt, void *fdto, int symbols_off, - int property) -{ - const char *value; - const char *label; - int len; - - value = fdt_getprop_by_offset(fdto, property, - &label, &len); - if (!value) { - if (len == -FDT_ERR_NOTFOUND) - return -FDT_ERR_INTERNAL; - - return len; - } - - do { - const char *path, *name, *fixup_end; - const char *fixup_str = value; - uint32_t path_len, name_len; - uint32_t fixup_len; - char *sep, *endptr; - int poffset, ret; - - fixup_end = memchr(value, '\0', len); - if (!fixup_end) - return -FDT_ERR_BADOVERLAY; - fixup_len = fixup_end - fixup_str; - - len -= fixup_len + 1; - value += fixup_len + 1; - - path = fixup_str; - sep = memchr(fixup_str, ':', fixup_len); - if (!sep || *sep != ':') - return -FDT_ERR_BADOVERLAY; - - path_len = sep - path; - if (path_len == (fixup_len - 1)) - return -FDT_ERR_BADOVERLAY; - - fixup_len -= path_len + 1; - name = sep + 1; - sep = memchr(name, ':', fixup_len); - if (!sep || *sep != ':') - return -FDT_ERR_BADOVERLAY; - - name_len = sep - name; - if (!name_len) - return -FDT_ERR_BADOVERLAY; - - poffset = strtoul(sep + 1, &endptr, 10); - if ((*endptr != '\0') || (endptr <= (sep + 1))) - return -FDT_ERR_BADOVERLAY; - - ret = overlay_fixup_one_phandle(fdt, fdto, symbols_off, - path, path_len, name, name_len, - poffset, label); - if (ret) - return ret; - } while (len > 0); - - return 0; -} - -/** - * overlay_fixup_phandles - Resolve the overlay phandles to the base - * device tree - * @fdt: Base Device Tree blob - * @fdto: Device tree overlay blob - * - * overlay_fixup_phandles() resolves all the overlay phandles pointing - * to nodes in the base device tree. - * - * This is one of the steps of the device tree overlay application - * process, when you want all the phandles in the overlay to point to - * the actual base dt nodes. - * - * returns: - * 0 on success - * Negative error code on failure - */ -static int overlay_fixup_phandles(void *fdt, void *fdto) -{ - int fixups_off, symbols_off; - int property; - - /* We can have overlays without any fixups */ - fixups_off = fdt_path_offset(fdto, "/__fixups__"); - if (fixups_off == -FDT_ERR_NOTFOUND) - return 0; /* nothing to do */ - if (fixups_off < 0) - return fixups_off; - - /* And base DTs without symbols */ - symbols_off = fdt_path_offset(fdt, "/__symbols__"); - if ((symbols_off < 0 && (symbols_off != -FDT_ERR_NOTFOUND))) - return symbols_off; - - fdt_for_each_property_offset(property, fdto, fixups_off) { - int ret; - - ret = overlay_fixup_phandle(fdt, fdto, symbols_off, property); - if (ret) - return ret; - } - - return 0; -} - -/** - * overlay_apply_node - Merges a node into the base device tree - * @fdt: Base Device Tree blob - * @target: Node offset in the base device tree to apply the fragment to - * @fdto: Device tree overlay blob - * @node: Node offset in the overlay holding the changes to merge - * - * overlay_apply_node() merges a node into a target base device tree - * node pointed. - * - * This is part of the final step in the device tree overlay - * application process, when all the phandles have been adjusted and - * resolved and you just have to merge overlay into the base device - * tree. - * - * returns: - * 0 on success - * Negative error code on failure - */ -static int overlay_apply_node(void *fdt, int target, - void *fdto, int node) -{ - int property; - int subnode; - - fdt_for_each_property_offset(property, fdto, node) { - const char *name; - const void *prop; - int prop_len; - int ret; - - prop = fdt_getprop_by_offset(fdto, property, &name, - &prop_len); - if (prop_len == -FDT_ERR_NOTFOUND) - return -FDT_ERR_INTERNAL; - if (prop_len < 0) - return prop_len; - - ret = fdt_setprop(fdt, target, name, prop, prop_len); - if (ret) - return ret; - } - - fdt_for_each_subnode(subnode, fdto, node) { - const char *name = fdt_get_name(fdto, subnode, NULL); - int nnode; - int ret; - - nnode = fdt_add_subnode(fdt, target, name); - if (nnode == -FDT_ERR_EXISTS) { - nnode = fdt_subnode_offset(fdt, target, name); - if (nnode == -FDT_ERR_NOTFOUND) - return -FDT_ERR_INTERNAL; - } - - if (nnode < 0) - return nnode; - - ret = overlay_apply_node(fdt, nnode, fdto, subnode); - if (ret) - return ret; - } - - return 0; -} - -/** - * overlay_merge - Merge an overlay into its base device tree - * @fdt: Base Device Tree blob - * @fdto: Device tree overlay blob - * - * overlay_merge() merges an overlay into its base device tree. - * - * This is the next to last step in the device tree overlay application - * process, when all the phandles have been adjusted and resolved and - * you just have to merge overlay into the base device tree. - * - * returns: - * 0 on success - * Negative error code on failure - */ -static int overlay_merge(void *fdt, void *fdto) -{ - int fragment; - - fdt_for_each_subnode(fragment, fdto, 0) { - int overlay; - int target; - int ret; - - /* - * Each fragments will have an __overlay__ node. If - * they don't, it's not supposed to be merged - */ - overlay = fdt_subnode_offset(fdto, fragment, "__overlay__"); - if (overlay == -FDT_ERR_NOTFOUND) - continue; - - if (overlay < 0) - return overlay; - - target = overlay_get_target(fdt, fdto, fragment, NULL); - if (target < 0) - return target; - - ret = overlay_apply_node(fdt, target, fdto, overlay); - if (ret) - return ret; - } - - return 0; -} - -static int get_path_len(const void *fdt, int nodeoffset) -{ - int len = 0, namelen; - const char *name; - - FDT_CHECK_HEADER(fdt); - - for (;;) { - name = fdt_get_name(fdt, nodeoffset, &namelen); - if (!name) - return namelen; - - /* root? we're done */ - if (namelen == 0) - break; - - nodeoffset = fdt_parent_offset(fdt, nodeoffset); - if (nodeoffset < 0) - return nodeoffset; - len += namelen + 1; - } - - /* in case of root pretend it's "/" */ - if (len == 0) - len++; - return len; -} - -/** - * overlay_symbol_update - Update the symbols of base tree after a merge - * @fdt: Base Device Tree blob - * @fdto: Device tree overlay blob - * - * overlay_symbol_update() updates the symbols of the base tree with the - * symbols of the applied overlay - * - * This is the last step in the device tree overlay application - * process, allowing the reference of overlay symbols by subsequent - * overlay operations. - * - * returns: - * 0 on success - * Negative error code on failure - */ -static int overlay_symbol_update(void *fdt, void *fdto) -{ - int root_sym, ov_sym, prop, path_len, fragment, target; - int len, frag_name_len, ret, rel_path_len; - const char *s, *e; - const char *path; - const char *name; - const char *frag_name; - const char *rel_path; - const char *target_path; - char *buf; - void *p; - - ov_sym = fdt_subnode_offset(fdto, 0, "__symbols__"); - - /* if no overlay symbols exist no problem */ - if (ov_sym < 0) - return 0; - - root_sym = fdt_subnode_offset(fdt, 0, "__symbols__"); - - /* it no root symbols exist we should create them */ - if (root_sym == -FDT_ERR_NOTFOUND) - root_sym = fdt_add_subnode(fdt, 0, "__symbols__"); - - /* any error is fatal now */ - if (root_sym < 0) - return root_sym; - - /* iterate over each overlay symbol */ - fdt_for_each_property_offset(prop, fdto, ov_sym) { - path = fdt_getprop_by_offset(fdto, prop, &name, &path_len); - if (!path) - return path_len; - - /* verify it's a string property (terminated by a single \0) */ - if (path_len < 1 || memchr(path, '\0', path_len) != &path[path_len - 1]) - return -FDT_ERR_BADVALUE; - - /* keep end marker to avoid strlen() */ - e = path + path_len; - - /* format: //__overlay__/ */ - - if (*path != '/') - return -FDT_ERR_BADVALUE; - - /* get fragment name first */ - s = strchr(path + 1, '/'); - if (!s) - return -FDT_ERR_BADOVERLAY; - - frag_name = path + 1; - frag_name_len = s - path - 1; - - /* verify format; safe since "s" lies in \0 terminated prop */ - len = sizeof("/__overlay__/") - 1; - if ((e - s) < len || memcmp(s, "/__overlay__/", len)) - return -FDT_ERR_BADOVERLAY; - - rel_path = s + len; - rel_path_len = e - rel_path; - - /* find the fragment index in which the symbol lies */ - ret = fdt_subnode_offset_namelen(fdto, 0, frag_name, - frag_name_len); - /* not found? */ - if (ret < 0) - return -FDT_ERR_BADOVERLAY; - fragment = ret; - - /* an __overlay__ subnode must exist */ - ret = fdt_subnode_offset(fdto, fragment, "__overlay__"); - if (ret < 0) - return -FDT_ERR_BADOVERLAY; - - /* get the target of the fragment */ - ret = overlay_get_target(fdt, fdto, fragment, &target_path); - if (ret < 0) - return ret; - target = ret; - - /* if we have a target path use */ - if (!target_path) { - ret = get_path_len(fdt, target); - if (ret < 0) - return ret; - len = ret; - } else { - len = strlen(target_path); - } - - ret = fdt_setprop_placeholder(fdt, root_sym, name, - len + (len > 1) + rel_path_len + 1, &p); - if (ret < 0) - return ret; - - if (!target_path) { - /* again in case setprop_placeholder changed it */ - ret = overlay_get_target(fdt, fdto, fragment, &target_path); - if (ret < 0) - return ret; - target = ret; - } - - buf = p; - if (len > 1) { /* target is not root */ - if (!target_path) { - ret = fdt_get_path(fdt, target, buf, len + 1); - if (ret < 0) - return ret; - } else - memcpy(buf, target_path, len + 1); - - } else - len--; - - buf[len] = '/'; - memcpy(buf + len + 1, rel_path, rel_path_len); - buf[len + 1 + rel_path_len] = '\0'; - } - - return 0; -} - -int fdt_overlay_apply(void *fdt, void *fdto) -{ - uint32_t delta = fdt_get_max_phandle(fdt); - int ret; - - FDT_CHECK_HEADER(fdt); - FDT_CHECK_HEADER(fdto); - - ret = overlay_adjust_local_phandles(fdto, delta); - if (ret) - goto err; - - ret = overlay_update_local_references(fdto, delta); - if (ret) - goto err; - - ret = overlay_fixup_phandles(fdt, fdto); - if (ret) - goto err; - - ret = overlay_merge(fdt, fdto); - if (ret) - goto err; - - ret = overlay_symbol_update(fdt, fdto); - if (ret) - goto err; - - /* - * The overlay has been damaged, erase its magic. - */ - fdt_set_magic(fdto, ~0); - - return 0; - -err: - /* - * The overlay might have been damaged, erase its magic. - */ - fdt_set_magic(fdto, ~0); - - /* - * The base device tree might have been damaged, erase its - * magic. - */ - fdt_set_magic(fdt, ~0); - - return ret; -} +#include +#include "../../scripts/dtc/libfdt/fdt_overlay.c" diff --git a/lib/libfdt/fdt_strerror.c b/lib/libfdt/fdt_strerror.c index f89004c..408a883 100644 --- a/lib/libfdt/fdt_strerror.c +++ b/lib/libfdt/fdt_strerror.c @@ -1,61 +1,2 @@ -/* - * libfdt - Flat Device Tree manipulation - * Copyright (C) 2006 David Gibson, IBM Corporation. - * SPDX-License-Identifier: GPL-2.0+ BSD-2-Clause - */ -#include - -#ifndef USE_HOSTCC -#include -#include -#else -#include "fdt_host.h" -#endif - -#include "libfdt_internal.h" - -struct fdt_errtabent { - const char *str; -}; - -#define FDT_ERRTABENT(val) \ - [(val)] = { .str = #val, } - -static struct fdt_errtabent fdt_errtable[] = { - FDT_ERRTABENT(FDT_ERR_NOTFOUND), - FDT_ERRTABENT(FDT_ERR_EXISTS), - FDT_ERRTABENT(FDT_ERR_NOSPACE), - - FDT_ERRTABENT(FDT_ERR_BADOFFSET), - FDT_ERRTABENT(FDT_ERR_BADPATH), - FDT_ERRTABENT(FDT_ERR_BADPHANDLE), - FDT_ERRTABENT(FDT_ERR_BADSTATE), - - FDT_ERRTABENT(FDT_ERR_TRUNCATED), - FDT_ERRTABENT(FDT_ERR_BADMAGIC), - FDT_ERRTABENT(FDT_ERR_BADVERSION), - FDT_ERRTABENT(FDT_ERR_BADSTRUCTURE), - FDT_ERRTABENT(FDT_ERR_BADLAYOUT), - FDT_ERRTABENT(FDT_ERR_INTERNAL), - FDT_ERRTABENT(FDT_ERR_BADNCELLS), - FDT_ERRTABENT(FDT_ERR_BADVALUE), - FDT_ERRTABENT(FDT_ERR_BADOVERLAY), - FDT_ERRTABENT(FDT_ERR_NOPHANDLES), -}; -#define FDT_ERRTABSIZE (sizeof(fdt_errtable) / sizeof(fdt_errtable[0])) - -const char *fdt_strerror(int errval) -{ - if (errval > 0) - return ""; - else if (errval == 0) - return ""; - else if (errval > -FDT_ERRTABSIZE) { - const char *s = fdt_errtable[-errval].str; - - if (s) - return s; - } - - return ""; -} +#include +#include "../../scripts/dtc/libfdt/fdt_strerror.c" diff --git a/lib/libfdt/fdt_sw.c b/lib/libfdt/fdt_sw.c index 70fd026..0da3ed9 100644 --- a/lib/libfdt/fdt_sw.c +++ b/lib/libfdt/fdt_sw.c @@ -1,254 +1,2 @@ -/* - * libfdt - Flat Device Tree manipulation - * Copyright (C) 2006 David Gibson, IBM Corporation. - * SPDX-License-Identifier: GPL-2.0+ BSD-2-Clause - */ -#include -#include -#include - -#include "libfdt_internal.h" - -static int _fdt_sw_check_header(void *fdt) -{ - if (fdt_magic(fdt) != FDT_SW_MAGIC) - return -FDT_ERR_BADMAGIC; - /* FIXME: should check more details about the header state */ - return 0; -} - -#define FDT_SW_CHECK_HEADER(fdt) \ - { \ - int err; \ - if ((err = _fdt_sw_check_header(fdt)) != 0) \ - return err; \ - } - -static void *_fdt_grab_space(void *fdt, size_t len) -{ - int offset = fdt_size_dt_struct(fdt); - int spaceleft; - - spaceleft = fdt_totalsize(fdt) - fdt_off_dt_struct(fdt) - - fdt_size_dt_strings(fdt); - - if ((offset + len < offset) || (offset + len > spaceleft)) - return NULL; - - fdt_set_size_dt_struct(fdt, offset + len); - return _fdt_offset_ptr_w(fdt, offset); -} - -int fdt_create(void *buf, int bufsize) -{ - void *fdt = buf; - - if (bufsize < sizeof(struct fdt_header)) - return -FDT_ERR_NOSPACE; - - memset(buf, 0, bufsize); - - fdt_set_magic(fdt, FDT_SW_MAGIC); - fdt_set_version(fdt, FDT_LAST_SUPPORTED_VERSION); - fdt_set_last_comp_version(fdt, FDT_FIRST_SUPPORTED_VERSION); - fdt_set_totalsize(fdt, bufsize); - - fdt_set_off_mem_rsvmap(fdt, FDT_ALIGN(sizeof(struct fdt_header), - sizeof(struct fdt_reserve_entry))); - fdt_set_off_dt_struct(fdt, fdt_off_mem_rsvmap(fdt)); - fdt_set_off_dt_strings(fdt, bufsize); - - return 0; -} - -int fdt_resize(void *fdt, void *buf, int bufsize) -{ - size_t headsize, tailsize; - char *oldtail, *newtail; - - FDT_SW_CHECK_HEADER(fdt); - - headsize = fdt_off_dt_struct(fdt); - tailsize = fdt_size_dt_strings(fdt); - - if ((headsize + tailsize) > bufsize) - return -FDT_ERR_NOSPACE; - - oldtail = (char *)fdt + fdt_totalsize(fdt) - tailsize; - newtail = (char *)buf + bufsize - tailsize; - - /* Two cases to avoid clobbering data if the old and new - * buffers partially overlap */ - if (buf <= fdt) { - memmove(buf, fdt, headsize); - memmove(newtail, oldtail, tailsize); - } else { - memmove(newtail, oldtail, tailsize); - memmove(buf, fdt, headsize); - } - - fdt_set_off_dt_strings(buf, bufsize); - fdt_set_totalsize(buf, bufsize); - - return 0; -} - -int fdt_add_reservemap_entry(void *fdt, uint64_t addr, uint64_t size) -{ - struct fdt_reserve_entry *re; - int offset; - - FDT_SW_CHECK_HEADER(fdt); - - if (fdt_size_dt_struct(fdt)) - return -FDT_ERR_BADSTATE; - - offset = fdt_off_dt_struct(fdt); - if ((offset + sizeof(*re)) > fdt_totalsize(fdt)) - return -FDT_ERR_NOSPACE; - - re = (struct fdt_reserve_entry *)((char *)fdt + offset); - re->address = cpu_to_fdt64(addr); - re->size = cpu_to_fdt64(size); - - fdt_set_off_dt_struct(fdt, offset + sizeof(*re)); - - return 0; -} - -int fdt_finish_reservemap(void *fdt) -{ - return fdt_add_reservemap_entry(fdt, 0, 0); -} - -int fdt_begin_node(void *fdt, const char *name) -{ - struct fdt_node_header *nh; - int namelen = strlen(name) + 1; - - FDT_SW_CHECK_HEADER(fdt); - - nh = _fdt_grab_space(fdt, sizeof(*nh) + FDT_TAGALIGN(namelen)); - if (! nh) - return -FDT_ERR_NOSPACE; - - nh->tag = cpu_to_fdt32(FDT_BEGIN_NODE); - memcpy(nh->name, name, namelen); - return 0; -} - -int fdt_end_node(void *fdt) -{ - fdt32_t *en; - - FDT_SW_CHECK_HEADER(fdt); - - en = _fdt_grab_space(fdt, FDT_TAGSIZE); - if (! en) - return -FDT_ERR_NOSPACE; - - *en = cpu_to_fdt32(FDT_END_NODE); - return 0; -} - -static int _fdt_find_add_string(void *fdt, const char *s) -{ - char *strtab = (char *)fdt + fdt_totalsize(fdt); - const char *p; - int strtabsize = fdt_size_dt_strings(fdt); - int len = strlen(s) + 1; - int struct_top, offset; - - p = _fdt_find_string(strtab - strtabsize, strtabsize, s); - if (p) - return p - strtab; - - /* Add it */ - offset = -strtabsize - len; - struct_top = fdt_off_dt_struct(fdt) + fdt_size_dt_struct(fdt); - if (fdt_totalsize(fdt) + offset < struct_top) - return 0; /* no more room :( */ - - memcpy(strtab + offset, s, len); - fdt_set_size_dt_strings(fdt, strtabsize + len); - return offset; -} - -int fdt_property_placeholder(void *fdt, const char *name, int len, void **valp) -{ - struct fdt_property *prop; - int nameoff; - - FDT_SW_CHECK_HEADER(fdt); - - nameoff = _fdt_find_add_string(fdt, name); - if (nameoff == 0) - return -FDT_ERR_NOSPACE; - - prop = _fdt_grab_space(fdt, sizeof(*prop) + FDT_TAGALIGN(len)); - if (! prop) - return -FDT_ERR_NOSPACE; - - prop->tag = cpu_to_fdt32(FDT_PROP); - prop->nameoff = cpu_to_fdt32(nameoff); - prop->len = cpu_to_fdt32(len); - *valp = prop->data; - return 0; -} - -int fdt_property(void *fdt, const char *name, const void *val, int len) -{ - void *ptr; - int ret; - - ret = fdt_property_placeholder(fdt, name, len, &ptr); - if (ret) - return ret; - memcpy(ptr, val, len); - return 0; -} - -int fdt_finish(void *fdt) -{ - char *p = (char *)fdt; - fdt32_t *end; - int oldstroffset, newstroffset; - uint32_t tag; - int offset, nextoffset; - - FDT_SW_CHECK_HEADER(fdt); - - /* Add terminator */ - end = _fdt_grab_space(fdt, sizeof(*end)); - if (! end) - return -FDT_ERR_NOSPACE; - *end = cpu_to_fdt32(FDT_END); - - /* Relocate the string table */ - oldstroffset = fdt_totalsize(fdt) - fdt_size_dt_strings(fdt); - newstroffset = fdt_off_dt_struct(fdt) + fdt_size_dt_struct(fdt); - memmove(p + newstroffset, p + oldstroffset, fdt_size_dt_strings(fdt)); - fdt_set_off_dt_strings(fdt, newstroffset); - - /* Walk the structure, correcting string offsets */ - offset = 0; - while ((tag = fdt_next_tag(fdt, offset, &nextoffset)) != FDT_END) { - if (tag == FDT_PROP) { - struct fdt_property *prop = - _fdt_offset_ptr_w(fdt, offset); - int nameoff; - - nameoff = fdt32_to_cpu(prop->nameoff); - nameoff += fdt_size_dt_strings(fdt); - prop->nameoff = cpu_to_fdt32(nameoff); - } - offset = nextoffset; - } - if (nextoffset < 0) - return nextoffset; - - /* Finally, adjust the header */ - fdt_set_totalsize(fdt, newstroffset + fdt_size_dt_strings(fdt)); - fdt_set_magic(fdt, FDT_MAGIC); - return 0; -} +#include +#include "../../scripts/dtc/libfdt/fdt_sw.c"