From nobody Sun Feb 8 19:38:17 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1658520225; cv=none; d=zohomail.com; s=zohoarc; b=blPGrivGLR90Gq6dT8kyB3ih2eEeEihXTrvCUia7N6L/6486nkKq1mVWQuC/XDgb9tYVHI1kBGf5fi0DY0yhM+//R86c5p9g/Gd10m7RlYJpuoH9ksRWFhFrjrVMSnfg8KJF+iE1XvgORqgak0JwHAV54B+zmxw4WNQwg9yGcvg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658520225; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6H1vwOGrBVg5tfAahc7TWhOpLEIjth6n4BeX2NpIabU=; b=jE1h3dm9U4LExBGS2f9yo4wwRcuTzzu29gQp6PKns82y3QkpVDhztuk3MrC+dk1WSoqoHaVAdKTFfJ7Jx+c8QnwoG4OtHyoaTxptA6khwsiM0UWSzMAkPjgpvaVF98Bx2ZnfgWsR4F+BCMxVNUVgHznU9rztp78x/Meph372ppw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1658520225630426.17523165020793; Fri, 22 Jul 2022 13:03:45 -0700 (PDT) Received: from localhost ([::1]:46592 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oEysB-00061D-M5 for importer@patchew.org; Fri, 22 Jul 2022 16:03:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51512) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEyp4-000389-Tw for qemu-devel@nongnu.org; Fri, 22 Jul 2022 16:00:30 -0400 Received: from mail-oa1-x29.google.com ([2001:4860:4864:20::29]:40723) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oEyp3-0005Gl-BZ for qemu-devel@nongnu.org; Fri, 22 Jul 2022 16:00:30 -0400 Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-10d6e8990b9so7547659fac.7 for ; Fri, 22 Jul 2022 13:00:28 -0700 (PDT) Received: from balboa.COMFAST ([152.254.206.198]) by smtp.gmail.com with ESMTPSA id n14-20020a9d740e000000b0061cae62aafcsm2388218otk.20.2022.07.22.13.00.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 13:00:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6H1vwOGrBVg5tfAahc7TWhOpLEIjth6n4BeX2NpIabU=; b=UMa18Az1uShjRtVCu9TM/5aBnT3hI9cyUcFR8ruqC3AbVyyHBnJtX71W1LGSD2WULO gUHrYxX9+EgfcdQK1rVdnmwpEBBsFYzO3V1g0+QSvfOpk+mgJhY/Hkyrsy7QIQGbJOXo NnY8qM2lvKPHYnYKrzkkcZGNOrhhEnxJJwxtR0obrT1LYf0cWD4ybw/otlanDwG0BlJ0 VjVQq068O3ut82U2ntuxBNZzPdezFESXvYJ0wGpWU8C5qzrxPRVfJPBqwnQsxe3AFX4e jJ9357AWqRh6DwNJ1GC6xudpEAF4217NIlYFotUIJowSnbeykDZRmivd7MZRvf4Gx+63 ou/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6H1vwOGrBVg5tfAahc7TWhOpLEIjth6n4BeX2NpIabU=; b=3wPEyPAKmpzqYWoN7f5A1crSKQpEKdvHnqXsDkeNrvXlNpY2zTxAA4lrRelBaysnhY z+k2JH8vEY427j2iVwL9nlvO1u4rlIJGfTgVP/wnzpbTYNZU24E0deGrxap0v5ApMT0Y Y/YTeT3oJxpJHcdo6cEN9d4ql1g+zq3WqzVIr6EBRpSlWVDS551WjxE6hR81f4FrsAwX wNXBoDNRVhXlzSwMwHRwwaMq3amhAUGPBp5oZ7w50i/uEmJ0nFI/fW8HHG6pvorhJpnD t6HE2fjp13BAtnp93Mwx1quEu7Dkh91OClrQYyfaVrrc1kqJXSsVEoVcZuDMmSOymkYL bIxg== X-Gm-Message-State: AJIora+pO3RU2Tv5x1WFYixU9gACQDzMnHpxTMdGG3Vc+Kl07PazcmHA lQc+OoKBUPfyP5+mQx3L5U477JFJ74k= X-Google-Smtp-Source: AGRyM1s9Hmw/Njzptw0G5l207V0ygJovfpp4C1Zm1xvdLKSL0RVJsrBFYSeCZA5P//yRe8AOH/4b9w== X-Received: by 2002:a05:6870:51ce:b0:10d:4691:7bd9 with SMTP id b14-20020a05687051ce00b0010d46917bd9mr8272548oaj.185.1658520028230; Fri, 22 Jul 2022 13:00:28 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: Alistair Francis , David Gibson , Daniel Henrique Barboza Subject: [PATCH for-7.2 08/10] device_node.c: enable 'info fdt' to print subnodes Date: Fri, 22 Jul 2022 17:00:05 -0300 Message-Id: <20220722200007.1602174-9-danielhb413@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220722200007.1602174-1-danielhb413@gmail.com> References: <20220722200007.1602174-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:4860:4864:20::29; envelope-from=danielhb413@gmail.com; helo=mail-oa1-x29.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1658520227576100001 Content-Type: text/plain; charset="utf-8" Printing subnodes of a given node will allow us to show a whole subtree, which the additional perk of 'info fdt /' being able to print the whole FDT. Since we're now printing more than one subnode, change 'fdt_info' to print the full path of the first node. This small tweak helps identifying which node or subnode are being displayed. To demostrate this capability without printing the whole FDT, the '/cpus/cpu-map' node from the ARM 'virt' machine has a lot of subnodes: (qemu) info fdt /cpus/cpu-map /cpus/cpu-map { socket0 { cluster0 { core0 { cpu =3D <0x8001> } } } } Signed-off-by: Daniel Henrique Barboza --- softmmu/device_tree.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/softmmu/device_tree.c b/softmmu/device_tree.c index 3a4d09483b..88b6a0c902 100644 --- a/softmmu/device_tree.c +++ b/softmmu/device_tree.c @@ -721,16 +721,24 @@ static void fdt_prop_print_val(const char *propname, = const void *data, qemu_printf("]\n"); } =20 -static void fdt_print_node(int node, int depth) +static void fdt_print_node(int node, int depth, const char *fullpath) { const struct fdt_property *prop =3D NULL; + const char *nodename =3D NULL; const char *propname =3D NULL; void *fdt =3D current_machine->fdt; int padding =3D depth * 4; int property =3D 0; + int parent =3D node; int prop_size; =20 - qemu_printf("%*s%s {\n", padding, "", fdt_get_name(fdt, node, NULL)); + if (fullpath !=3D NULL) { + nodename =3D fullpath; + } else { + nodename =3D fdt_get_name(fdt, node, NULL); + } + + qemu_printf("%*s%s {\n", padding, "", nodename); =20 padding +=3D 4; =20 @@ -754,6 +762,10 @@ static void fdt_print_node(int node, int depth) } } =20 + fdt_for_each_subnode(node, fdt, parent) { + fdt_print_node(node, depth + 1, NULL); + } + padding -=3D 4; qemu_printf("%*s}\n", padding, ""); } @@ -773,5 +785,5 @@ void fdt_info(const char *fullpath, Error **errp) return; } =20 - fdt_print_node(node, 0); + fdt_print_node(node, 0, fullpath); } --=20 2.36.1