From patchwork Tue Jan 12 08:29:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 12012713 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3A3AC433DB for ; Tue, 12 Jan 2021 08:30:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5764E22D58 for ; Tue, 12 Jan 2021 08:30:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405134AbhALIaG (ORCPT ); Tue, 12 Jan 2021 03:30:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405121AbhALIaG (ORCPT ); Tue, 12 Jan 2021 03:30:06 -0500 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B26E4C0617A3 for ; Tue, 12 Jan 2021 00:29:12 -0800 (PST) Received: by mail-pf1-x433.google.com with SMTP id m6so971905pfk.1 for ; Tue, 12 Jan 2021 00:29:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SfqrhXJQaqJjV61wcgC7ZOTiZJR50oZXFU0ulC256Rg=; b=SSeKiG1+oGN18d1S1UvrOUNw2yc6VlsVtOpm9dV6u77sKiqJRN6MtpyEKvFQ91QWJL VSWO9fxox36y9noWQm4jBkR2wlVkE72NXF1Sj45u0PJ/QLXcNyjRu5IeZWhsW1PZeQHG YxwOhVc3+j79pyiiUhhPM3fL0EA2rubMm+3ff6PkJWTEv+dzC7dbisYrRF4d2lL4h+fY rIm7X7BGkuywk+CNe+3jtWnEHslHChb4HFq9qJV3zEXEWtgrEjErf5OpOm7h8ltimaIR jvgkLAIUuK6MiLiNrleVFOJTmGuxjI+zkIKeX1tRdtAWcO7PxZAMKcl/cCvLZhfmPUJt 2JZg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=SfqrhXJQaqJjV61wcgC7ZOTiZJR50oZXFU0ulC256Rg=; b=XvcOzySoOdo/wjSVG8SZUFCrtUViDSxU1LyM9MMCVMVIg9HT5WGaa6eWtOj8XZ9EMY KAf1Pz3qJwpeh8cgru4Y1fOe29jn0bE0AS5bSZOM9Irp4ZdON2iiveO8q3Shh96Lq6FN r+FYa2Bchc2v0bQyz5KfkEJTFRNs6JLBiplg/oVfiDEz+KC8pZ9O4wF9g916Ay1Pcwlv /5vwfI5ObT7x6LtDGW9t/OL9XsG6FyUTJq0xV4x4G0XjUWGRb8xkXl4VvwxAzyl05RIB Rj7aWK7t+hVijWWlghQI+ygav3HUTJy9pKhdh8YF/irkpprrK9NyWDuiOka+Xrz/drTP K41Q== X-Gm-Message-State: AOAM533Kn/pRVdCf32MHKEHXFQSFnerh4CNNvHtBxk6TvXEu4XFG5GUE XwLNiCRsqBE6VJhYAAgLrJ/W1o6zU4/eXg== X-Google-Smtp-Source: ABdhPJxFkHeC8OHW0Dxcc7ncPQ7CFcioS0xfREvooC1RtufXlqhwn8QMMerrJaJbijSvOERSCurUkQ== X-Received: by 2002:a63:1f18:: with SMTP id f24mr3684261pgf.133.1610440152283; Tue, 12 Jan 2021 00:29:12 -0800 (PST) Received: from localhost ([122.172.85.111]) by smtp.gmail.com with ESMTPSA id i2sm2244541pjd.21.2021.01.12.00.29.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Jan 2021 00:29:11 -0800 (PST) From: Viresh Kumar To: Pantelis Antoniou , Frank Rowand , Rob Herring Cc: Viresh Kumar , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, Vincent Guittot , Bill Mills , anmar.oueja@linaro.org, Masahiro Yamada Subject: [PATCH V4 1/3] scripts: dtc: Add fdtoverlay.c to DTC_SOURCE Date: Tue, 12 Jan 2021 13:59:00 +0530 Message-Id: X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org We will start building overlays for platforms soon in the kernel and would need fdtoverlay tool going forward. Lets start fetching it. Signed-off-by: Viresh Kumar --- scripts/dtc/update-dtc-source.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/dtc/update-dtc-source.sh b/scripts/dtc/update-dtc-source.sh index bc704e2a6a4a..f1c802011e1e 100755 --- a/scripts/dtc/update-dtc-source.sh +++ b/scripts/dtc/update-dtc-source.sh @@ -31,9 +31,9 @@ set -ev DTC_UPSTREAM_PATH=`pwd`/../dtc DTC_LINUX_PATH=`pwd`/scripts/dtc -DTC_SOURCE="checks.c data.c dtc.c dtc.h flattree.c fstree.c livetree.c srcpos.c \ - srcpos.h treesource.c util.c util.h version_gen.h yamltree.c \ - dtc-lexer.l dtc-parser.y" +DTC_SOURCE="checks.c data.c dtc.c dtc.h fdtoverlay.c flattree.c fstree.c \ + livetree.c srcpos.c srcpos.h treesource.c util.c \ + util.h version_gen.h yamltree.c dtc-lexer.l dtc-parser.y" LIBFDT_SOURCE="fdt.c fdt.h fdt_addresses.c fdt_empty_tree.c \ fdt_overlay.c fdt_ro.c fdt_rw.c fdt_strerror.c fdt_sw.c \ fdt_wip.c libfdt.h libfdt_env.h libfdt_internal.h" From patchwork Tue Jan 12 08:29:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 12012715 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65895C43381 for ; Tue, 12 Jan 2021 08:30:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 297B822E01 for ; Tue, 12 Jan 2021 08:30:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405171AbhALIaa (ORCPT ); Tue, 12 Jan 2021 03:30:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404958AbhALIaa (ORCPT ); Tue, 12 Jan 2021 03:30:30 -0500 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFE44C0617A6 for ; Tue, 12 Jan 2021 00:29:15 -0800 (PST) Received: by mail-pg1-x533.google.com with SMTP id 30so961975pgr.6 for ; Tue, 12 Jan 2021 00:29:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=R5AyTeEPJ4vRX5PQgPjGJ2ekXngPExcnmW5K8mA9ndI=; b=HNBCP45uMqAb3GYX1SPufcwilF/tFsFtyhEhjE2evQiVwZHQVWsYY7AZB49MMLxX6t hXp28EO9FPODeKvgpZZz8PvkjlWAm+0vkLRcXaGORIxWkkDxKl5JXWsOZaLXvG2gg01n /joKtPPF29ImmwZTNpGV5sHM5GZDGw9SLNiSwg5/habd551C13NN0huKn39AP7ckdjFB DKexvzeSRf9iYBGpYbXiRFEXbfeh1UzfvZab0P1gBdLCSVqoQWjNFpDsFa6rPqYI+0w1 W+GyYmeAUickV3otbA6csurB1Cht5sncN58JPYGsRG0nLf+wTbeEf0tinMuwF3iKXpqu 3y6g== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=R5AyTeEPJ4vRX5PQgPjGJ2ekXngPExcnmW5K8mA9ndI=; b=SqRM3db87xPQFaKpm4d0br74SpG2+5QWDveN6nGo4ltVcu0rDBLyPvevj1yaeq1xEu G6MPDZ9TJzvt95UqwxORBO0Cglttq1BZ1BbeUSHVfhkT+0DGltQpYVnWxU6+8ACX5O8A 9YzHOudFX96kGgf8tqlGFLL+jb6DbcSJkPAsBY0uqG/x+YqrcBTqV/9/RcAOC+SFf7+g +MYL88JdMkJ8zLeBQockzLtuBYfCVMnia3iHb/LZDPA5a4hwRTeNx7wNFlNqFpkHxwEG VdAaIl1dvv1G5tTVD84tAScZ1JDj6UwxPxNLSQP9cNzXTNEIAHuWrcvN/f6WfDpBgRSo i2VA== X-Gm-Message-State: AOAM532ZpG44+flCzrKv2Yn5FG8GvTMBzKTk+iuiNNyIYPCjk8uzOJvg KQwHCOl0ALE4125yL6blB42KpA== X-Google-Smtp-Source: ABdhPJyi6voJlQYIRaZwp95Ebobizeh5zfKRf/lsVP6Y9YJQBdQw0kKRZsuNQfs2TIbd3zEZe7XOtw== X-Received: by 2002:a62:7b86:0:b029:19d:f996:44f3 with SMTP id w128-20020a627b860000b029019df99644f3mr3562196pfc.65.1610440155263; Tue, 12 Jan 2021 00:29:15 -0800 (PST) Received: from localhost ([122.172.85.111]) by smtp.gmail.com with ESMTPSA id i67sm2258873pfc.153.2021.01.12.00.29.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Jan 2021 00:29:14 -0800 (PST) From: Viresh Kumar To: Pantelis Antoniou , Frank Rowand , Rob Herring Cc: Viresh Kumar , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, Vincent Guittot , Bill Mills , anmar.oueja@linaro.org, Masahiro Yamada Subject: [PATCH V4 2/3] scripts: dtc: Build fdtoverlay tool Date: Tue, 12 Jan 2021 13:59:01 +0530 Message-Id: X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org We will start building overlays for platforms soon in the kernel and would need fdtoverlay going forward. Lets start building it. The fdtoverlay program applies (or merges) one ore more overlay dtb blobs to a base dtb blob. The kernel build system would later use fdtoverlay to generate the overlaid blobs based on platform specific configurations. Signed-off-by: Viresh Kumar --- scripts/dtc/Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/dtc/Makefile b/scripts/dtc/Makefile index 4852bf44e913..5f19386a49eb 100644 --- a/scripts/dtc/Makefile +++ b/scripts/dtc/Makefile @@ -1,13 +1,17 @@ # SPDX-License-Identifier: GPL-2.0 # scripts/dtc makefile -hostprogs-always-$(CONFIG_DTC) += dtc +hostprogs-always-$(CONFIG_DTC) += dtc fdtoverlay hostprogs-always-$(CHECK_DT_BINDING) += dtc dtc-objs := dtc.o flattree.o fstree.o data.o livetree.o treesource.o \ srcpos.o checks.o util.o dtc-objs += dtc-lexer.lex.o dtc-parser.tab.o +libfdt-objs := fdt.o fdt_ro.o fdt_wip.o fdt_sw.o fdt_rw.o fdt_strerror.o fdt_empty_tree.o fdt_addresses.o fdt_overlay.o +libfdt = $(addprefix libfdt/,$(libfdt-objs)) +fdtoverlay-objs := $(libfdt) fdtoverlay.o util.o + # Source files need to get at the userspace version of libfdt_env.h to compile HOST_EXTRACFLAGS += -I $(srctree)/$(src)/libfdt From patchwork Tue Jan 12 08:29:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 12012717 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B32F3C433E9 for ; Tue, 12 Jan 2021 08:30:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 723CB22D58 for ; Tue, 12 Jan 2021 08:30:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405243AbhALIab (ORCPT ); Tue, 12 Jan 2021 03:30:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404959AbhALIaa (ORCPT ); Tue, 12 Jan 2021 03:30:30 -0500 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0E0CC0617A7 for ; Tue, 12 Jan 2021 00:29:18 -0800 (PST) Received: by mail-pg1-x52f.google.com with SMTP id v19so942000pgj.12 for ; Tue, 12 Jan 2021 00:29:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9FnCdmEEGSQX+RKqefc8hvZ3CGNJpcGjSObBIm4DdhU=; b=hrulJ76Tv91s7SpdhYOy9jmlFw1Fhw/qiYTAMrHBR79CBwvq6sAzjtxv5hEnUF1yXq Vn+MH/2OzfXdLH4R5B1XZsBVJ0NF9pFu4OqX5CCiPhTgaxCnUygFwsq6cQb8M69Z2dyK pD/Lzt2kiEq0cmqq31x5zlDCPAzScU/o7M6hec8Aw2HP2CX98MfZStjEgwGw+Ly7W0IU CPle+X0NZ6EvnErCZiFMbIneBrc1cWVTjm5Q7QflQ0bGrMRX8nbv5UcU812AzKU6r9DB idwrnlwnDMOYRaKg9IqNcNJuMCcT0M54mgFiZECjX7MzThKAJwsDMQU/xzBhUrkscUMS GU4A== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=9FnCdmEEGSQX+RKqefc8hvZ3CGNJpcGjSObBIm4DdhU=; b=fkp1yX2QfUuUWlJPt/rEhUQvV+krlvz+xHrhsPLkrHV6FnvIHkaV4BjOElLv2B2L05 tFwJuJfuio8k2FqGKqf+LvHX9snNWYW+Na65kqnFtyCTzMWHRix59+rzqC/xqU/wMB42 5CIlgqQEkN5EqBal00D2xALgO/fNPOpbbOMWbTrNjPiw+nUrajnr04wtqsaIgQ+tgmF9 K6aWttHNiwvmbidKfGb4E6D0Bv/qnilZngwsUPnCDXSPMtmOvMXJknhBThvaPAi3VcDw rFXzv7QqBRkYa3pwHD4nZRUi/vbBCOD87JoMcy+u83qsiTcMeS0ZYrbHlszZRvMMb2fR p56Q== X-Gm-Message-State: AOAM530tZA/d6Kty6AID00TMVnGmtG3THgOJ9oU+AP5ncnyYuM4Z2i8h 1/Jz2fiXPkA4GNJSvF+TCUatcQ== X-Google-Smtp-Source: ABdhPJy3+Z6QgkpOKB9CLurMPFoM5R15S4+aImyXeHZ/86rBAV3ZUmQwtDYFMyCYzPlSEIAQZKpKYw== X-Received: by 2002:aa7:843a:0:b029:19d:b279:73c9 with SMTP id q26-20020aa7843a0000b029019db27973c9mr3843688pfn.3.1610440158277; Tue, 12 Jan 2021 00:29:18 -0800 (PST) Received: from localhost ([122.172.85.111]) by smtp.gmail.com with ESMTPSA id t7sm2143478pfe.179.2021.01.12.00.29.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Jan 2021 00:29:17 -0800 (PST) From: Viresh Kumar To: Pantelis Antoniou , Frank Rowand , Rob Herring Cc: Viresh Kumar , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, Vincent Guittot , Bill Mills , anmar.oueja@linaro.org, Masahiro Yamada Subject: [PATCH V4 3/3] scripts: dtc: Remove the unused fdtdump.c file Date: Tue, 12 Jan 2021 13:59:02 +0530 Message-Id: <25d98b2fe9bea3fe784f8392a73b88a253c8b97a.1610431620.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org This was copied from external DTC repository long back and isn't used anymore. Over that the dtc tool can be used to generate the dts source back from the dtb. Remove the unused fdtdump.c file. Signed-off-by: Viresh Kumar --- scripts/dtc/fdtdump.c | 163 ------------------------------------------ 1 file changed, 163 deletions(-) delete mode 100644 scripts/dtc/fdtdump.c diff --git a/scripts/dtc/fdtdump.c b/scripts/dtc/fdtdump.c deleted file mode 100644 index 7d460a50b513..000000000000 --- a/scripts/dtc/fdtdump.c +++ /dev/null @@ -1,163 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * fdtdump.c - Contributed by Pantelis Antoniou - */ - -#include -#include -#include -#include -#include - -#include -#include - -#include "util.h" - -#define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1)) -#define PALIGN(p, a) ((void *)(ALIGN((unsigned long)(p), (a)))) -#define GET_CELL(p) (p += 4, *((const uint32_t *)(p-4))) - -static void print_data(const char *data, int len) -{ - int i; - const char *p = data; - - /* no data, don't print */ - if (len == 0) - return; - - if (util_is_printable_string(data, len)) { - printf(" = \"%s\"", (const char *)data); - } else if ((len % 4) == 0) { - printf(" = <"); - for (i = 0; i < len; i += 4) - printf("0x%08x%s", fdt32_to_cpu(GET_CELL(p)), - i < (len - 4) ? " " : ""); - printf(">"); - } else { - printf(" = ["); - for (i = 0; i < len; i++) - printf("%02x%s", *p++, i < len - 1 ? " " : ""); - printf("]"); - } -} - -static void dump_blob(void *blob) -{ - struct fdt_header *bph = blob; - uint32_t off_mem_rsvmap = fdt32_to_cpu(bph->off_mem_rsvmap); - uint32_t off_dt = fdt32_to_cpu(bph->off_dt_struct); - uint32_t off_str = fdt32_to_cpu(bph->off_dt_strings); - struct fdt_reserve_entry *p_rsvmap = - (struct fdt_reserve_entry *)((char *)blob + off_mem_rsvmap); - const char *p_struct = (const char *)blob + off_dt; - const char *p_strings = (const char *)blob + off_str; - uint32_t version = fdt32_to_cpu(bph->version); - uint32_t totalsize = fdt32_to_cpu(bph->totalsize); - uint32_t tag; - const char *p, *s, *t; - int depth, sz, shift; - int i; - uint64_t addr, size; - - depth = 0; - shift = 4; - - printf("/dts-v1/;\n"); - printf("// magic:\t\t0x%x\n", fdt32_to_cpu(bph->magic)); - printf("// totalsize:\t\t0x%x (%d)\n", totalsize, totalsize); - printf("// off_dt_struct:\t0x%x\n", off_dt); - printf("// off_dt_strings:\t0x%x\n", off_str); - printf("// off_mem_rsvmap:\t0x%x\n", off_mem_rsvmap); - printf("// version:\t\t%d\n", version); - printf("// last_comp_version:\t%d\n", - fdt32_to_cpu(bph->last_comp_version)); - if (version >= 2) - printf("// boot_cpuid_phys:\t0x%x\n", - fdt32_to_cpu(bph->boot_cpuid_phys)); - - if (version >= 3) - printf("// size_dt_strings:\t0x%x\n", - fdt32_to_cpu(bph->size_dt_strings)); - if (version >= 17) - printf("// size_dt_struct:\t0x%x\n", - fdt32_to_cpu(bph->size_dt_struct)); - printf("\n"); - - for (i = 0; ; i++) { - addr = fdt64_to_cpu(p_rsvmap[i].address); - size = fdt64_to_cpu(p_rsvmap[i].size); - if (addr == 0 && size == 0) - break; - - printf("/memreserve/ %llx %llx;\n", - (unsigned long long)addr, (unsigned long long)size); - } - - p = p_struct; - while ((tag = fdt32_to_cpu(GET_CELL(p))) != FDT_END) { - - /* printf("tag: 0x%08x (%d)\n", tag, p - p_struct); */ - - if (tag == FDT_BEGIN_NODE) { - s = p; - p = PALIGN(p + strlen(s) + 1, 4); - - if (*s == '\0') - s = "/"; - - printf("%*s%s {\n", depth * shift, "", s); - - depth++; - continue; - } - - if (tag == FDT_END_NODE) { - depth--; - - printf("%*s};\n", depth * shift, ""); - continue; - } - - if (tag == FDT_NOP) { - printf("%*s// [NOP]\n", depth * shift, ""); - continue; - } - - if (tag != FDT_PROP) { - fprintf(stderr, "%*s ** Unknown tag 0x%08x\n", depth * shift, "", tag); - break; - } - sz = fdt32_to_cpu(GET_CELL(p)); - s = p_strings + fdt32_to_cpu(GET_CELL(p)); - if (version < 16 && sz >= 8) - p = PALIGN(p, 8); - t = p; - - p = PALIGN(p + sz, 4); - - printf("%*s%s", depth * shift, "", s); - print_data(t, sz); - printf(";\n"); - } -} - - -int main(int argc, char *argv[]) -{ - char *buf; - - if (argc < 2) { - fprintf(stderr, "supply input filename\n"); - return 5; - } - - buf = utilfdt_read(argv[1]); - if (buf) - dump_blob(buf); - else - return 10; - - return 0; -}