From patchwork Thu Oct 3 04:18:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1171039 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46kKXN0Qk2z9s7T for ; Thu, 3 Oct 2019 14:19:32 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="QQyc1c2m"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46kKXM3RjhzDqWn for ; Thu, 3 Oct 2019 14:19:31 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46kKX10B5RzDqWn for ; Thu, 3 Oct 2019 14:19:13 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="QQyc1c2m"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 46kKX02hy3z9sDB; Thu, 3 Oct 2019 14:19:12 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1570076352; bh=JMqv5taXsuJ8y/46UbpPSYZZmXPF75VfQQ5iVQJiyDo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QQyc1c2mGVsaI2P9ee8GLPN0Jova0LrFTZ66EL2Axh/pvOEu/O5fH+zvfJpyzJuep vB9HNpMm3VF58dyOM5Oz7IJBKZVFp4sMlbyZPLBShyIleSJx70TnxiTggpypQb+1+3 aqp3ZJvMOUjnz9Ymc+9xCr04wt93A709oVuOB4ov27X/XdfeQf5ASphKPLagkWa2XI LN+o/vLO+QeoaYFCeIXBbnE/TMwkacHLU2Ygd59KvKO4c+JZMB/nCU4BtOnG1jHVbe +Qok+a6dxG7L7fUG+PLS9og4+15qZZJjMdgyKv51/6P+ZyE4MmHZSISq4+Npkf7aK9 7Pk4G9N6HsD6g== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 3 Oct 2019 14:18:40 +1000 Message-Id: <20191003041909.23187-2-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191003041909.23187-1-amitay@ozlabs.org> References: <20191003041909.23187-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v4 01/30] libpdbg: Do not assume device tree hierarchy X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Always get the parent of required class explicitly. Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- libpdbg/p9chip.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libpdbg/p9chip.c b/libpdbg/p9chip.c index f86a529..37cc93b 100644 --- a/libpdbg/p9chip.c +++ b/libpdbg/p9chip.c @@ -80,14 +80,14 @@ static uint64_t thread_read(struct thread *thread, uint64_t addr, uint64_t *data) { - struct pdbg_target *chip = require_target_parent(&thread->target); + struct pdbg_target *chip = pdbg_target_require_parent("core", &thread->target); return pib_read(chip, addr, data); } static uint64_t thread_write(struct thread *thread, uint64_t addr, uint64_t data) { - struct pdbg_target *chip = require_target_parent(&thread->target); + struct pdbg_target *chip = pdbg_target_require_parent("core", &thread->target); return pib_write(chip, addr, data); } From patchwork Thu Oct 3 04:18:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1171037 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46kKXC1PQhz9sDB for ; Thu, 3 Oct 2019 14:19:23 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="FDHEOlzt"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46kKXB5kxyzDqX8 for ; Thu, 3 Oct 2019 14:19:22 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46kKX13WtrzDqWq for ; Thu, 3 Oct 2019 14:19:13 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="FDHEOlzt"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 46kKX05LjXz9sP7; Thu, 3 Oct 2019 14:19:12 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1570076352; bh=LD8h/A6d8Z0hhpP/9hF/6OVC1Mn1ka0P8JlAfsYdSec=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FDHEOlzt55lVmfXoixPkS/VhgqMNPmGd8ix7LU5oq1+nvRKUSjDUSAJa+zKN1xu1x 48iKgB63LzAMEG1buh1tMzCJHdeXKySexTf4TEzXvZY6PHBTMU/ocvkv5cvchXQ37l AcVugkAT5tG98Byvek7D4cr4mb8dLK5t+ZxG4AtwTyjPNEFwoBazJtBv1R3YUIgrB1 jtMS9+LK0SUlayspf6vwn8jQs5TPG5cEwAQ1JIK8P2tw665dKkuUYXZNgSb0pgc+uM IHgvDas03sDq6noC6gmnXGybi6fM/3eAqQNJ5X4Sobec/SX4gCXWu0FWuCPwzDkD9E /tUDD8VLDfCKw== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 3 Oct 2019 14:18:41 +1000 Message-Id: <20191003041909.23187-3-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191003041909.23187-1-amitay@ozlabs.org> References: <20191003041909.23187-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v4 02/30] libpdbg: Drop unused function require_target_parent X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- libpdbg/target.c | 6 ------ libpdbg/target.h | 1 - 2 files changed, 7 deletions(-) diff --git a/libpdbg/target.c b/libpdbg/target.c index da24ba0..f803ab2 100644 --- a/libpdbg/target.c +++ b/libpdbg/target.c @@ -312,12 +312,6 @@ uint32_t sbe_ffdc_get(struct pdbg_target *target, const uint8_t **ffdc, uint32_t return sbefifo->ffdc_get(sbefifo, ffdc, ffdc_len); } -struct pdbg_target *require_target_parent(struct pdbg_target *target) -{ - assert(target->parent); - return target->parent; -} - /* Finds the given class. Returns NULL if not found. */ struct pdbg_target_class *find_target_class(const char *name) { diff --git a/libpdbg/target.h b/libpdbg/target.h index 2ecbf98..4c24251 100644 --- a/libpdbg/target.h +++ b/libpdbg/target.h @@ -52,7 +52,6 @@ struct pdbg_target { void *priv; }; -struct pdbg_target *require_target_parent(struct pdbg_target *target); struct pdbg_target_class *find_target_class(const char *name); struct pdbg_target_class *require_target_class(const char *name); struct pdbg_target_class *get_target_class(struct pdbg_target *target); From patchwork Thu Oct 3 04:18:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1171040 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46kKXR16KWz9sP7 for ; Thu, 3 Oct 2019 14:19:35 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="QTk4scY9"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46kKXQ4cNTzDqXK for ; Thu, 3 Oct 2019 14:19:34 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46kKX14BCszDqWs for ; Thu, 3 Oct 2019 14:19:13 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="QTk4scY9"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 46kKX06xMRz9sPJ; Thu, 3 Oct 2019 14:19:12 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1570076353; bh=CslzXzGu6XufWvRyJkBqih/1F9P/AhnazFxX0ZeC72s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QTk4scY9gBhNRmlRd++vi+OnV5loQOTU7LR5MOS+5pqi8ta0n8KU3H922upRyKFls 9O5EQDtHX/3SIFPl9bGc1x6GYnnVx/f+llQhb92d5X0A6WkU7dGabQrDRKqqWR5wii pkJOZt7xD+vpjV58dyD3eY2WkL6QWEp/1EYmZ/P77RQifCiYbp660t/H/UHhS+WZNq ybO99WYO+ls9rLFOeF0uZeyqtqbURMRm2ggphq3G1sUMGYhA5di6Y7/4H/Of8PToyB 8eI2Fh3VfILdJGkZF4mw7xajR5bhcy14xA2s7fESa+WfvOdLhgkVvpwGonxHCO9Gnj vrSNWNbxofAXg== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 3 Oct 2019 14:18:42 +1000 Message-Id: <20191003041909.23187-4-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191003041909.23187-1-amitay@ozlabs.org> References: <20191003041909.23187-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v4 03/30] libpdbg: class name and name should be const X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Each function returns a pointer to the actual name. User must not be able to modify that. Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- libpdbg/libpdbg.c | 4 ++-- libpdbg/libpdbg.h | 4 ++-- src/main.c | 2 +- src/scom.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libpdbg/libpdbg.c b/libpdbg/libpdbg.c index 0c5a451..aade5d3 100644 --- a/libpdbg/libpdbg.c +++ b/libpdbg/libpdbg.c @@ -120,12 +120,12 @@ uint32_t pdbg_parent_index(struct pdbg_target *target, char *class) return -1; } -char *pdbg_target_class_name(struct pdbg_target *target) +const char *pdbg_target_class_name(struct pdbg_target *target) { return target->class; } -char *pdbg_target_name(struct pdbg_target *target) +const char *pdbg_target_name(struct pdbg_target *target) { return target->name; } diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h index 468553b..c91afb2 100644 --- a/libpdbg/libpdbg.h +++ b/libpdbg/libpdbg.h @@ -113,8 +113,8 @@ uint32_t pdbg_target_index(struct pdbg_target *target); char *pdbg_target_path(const struct pdbg_target *target); struct pdbg_target *pdbg_target_from_path(struct pdbg_target *target, const char *path); uint32_t pdbg_parent_index(struct pdbg_target *target, char *klass); -char *pdbg_target_class_name(struct pdbg_target *target); -char *pdbg_target_name(struct pdbg_target *target); +const char *pdbg_target_class_name(struct pdbg_target *target); +const char *pdbg_target_name(struct pdbg_target *target); const char *pdbg_target_dn_name(struct pdbg_target *target); void *pdbg_target_priv(struct pdbg_target *target); void pdbg_target_priv_set(struct pdbg_target *target, void *priv); diff --git a/src/main.c b/src/main.c index efdc4bb..44d1c55 100644 --- a/src/main.c +++ b/src/main.c @@ -518,7 +518,7 @@ static void print_target(struct pdbg_target *target, int level) int i; struct pdbg_target *next; enum pdbg_target_status status; - char *classname; + const char *classname; /* Does this target actually exist? */ status = pdbg_target_status(target); diff --git a/src/scom.c b/src/scom.c index 8d8e988..c747f3d 100644 --- a/src/scom.c +++ b/src/scom.c @@ -29,7 +29,7 @@ /* Check if a target has scom region */ static bool scommable(struct pdbg_target *target) { - char *classname; + const char *classname; classname = pdbg_target_class_name(target); if (!strcmp(classname, "pib") || From patchwork Thu Oct 3 04:18:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1171038 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46kKXJ4fg7z9sDB for ; Thu, 3 Oct 2019 14:19:28 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="Ia9U4CsW"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46kKXH483yzDqXV for ; Thu, 3 Oct 2019 14:19:27 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46kKX14BwSzDqX1 for ; Thu, 3 Oct 2019 14:19:13 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="Ia9U4CsW"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 46kKX11SmXz9sPL; Thu, 3 Oct 2019 14:19:13 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1570076353; bh=M/CeVg7NpfDv26fsHcL+9SyWy4nXIu75VtuucoCJFd8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ia9U4CsW0OxqUe/6rQEJuLwETEaxmkfVULLXN6O8veJeCPT4OHL9fVunzlYnhTZXw nRsw3I1ZBcNnwsHIApHTPCv38ccx+hwfXS7Z2+0Zt69rl8s9KaEJSe6CTJTm4hQqHo Al78AmCELWT48pduAIIJr/rbjnaOLHBjNObigzAhFJVKP+lEL44iRGwOpwUuoXw18l pkYGhcemYUYnoThnROOKZU7PYzPdv5e26JeDWzQOoRXlG72KGBT5TnlH+FGuuP+H1E 9bWxzRCU0E/meqA87F2CO2pCqUdPoXq2+IZ58y1QeOrUE8LpmHHABSqhGTkxwkXhtB gpx5xZsTI3O+A== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 3 Oct 2019 14:18:43 +1000 Message-Id: <20191003041909.23187-5-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191003041909.23187-1-amitay@ozlabs.org> References: <20191003041909.23187-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v4 04/30] libpdbg: Drop const from pdbg_target_path() argument X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- libpdbg/device.c | 8 ++++---- libpdbg/libpdbg.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libpdbg/device.c b/libpdbg/device.c index efa9ce4..6c3b769 100644 --- a/libpdbg/device.c +++ b/libpdbg/device.c @@ -208,10 +208,10 @@ static bool dt_attach_root(struct pdbg_target *parent, struct pdbg_target *root) return true; } -static char *dt_get_path(const struct pdbg_target *node) +static char *dt_get_path(struct pdbg_target *node) { unsigned int len = 0; - const struct pdbg_target *n; + struct pdbg_target *n; char *path, *p; /* Dealing with NULL is for test/debug purposes */ @@ -445,7 +445,7 @@ static struct pdbg_target *dt_next(const struct pdbg_target *root, return NULL; } -static const struct dt_property *dt_require_property(const struct pdbg_target *node, +static const struct dt_property *dt_require_property(struct pdbg_target *node, const char *name, int wanted_len) { const struct dt_property *p = dt_find_property(node, name); @@ -656,7 +656,7 @@ void pdbg_targets_init(void *fdt) dt_expand(pdbg_dt_root, fdt); } -char *pdbg_target_path(const struct pdbg_target *target) +char *pdbg_target_path(struct pdbg_target *target) { return dt_get_path(target); } diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h index c91afb2..722ddc2 100644 --- a/libpdbg/libpdbg.h +++ b/libpdbg/libpdbg.h @@ -110,7 +110,7 @@ void pdbg_target_status_set(struct pdbg_target *target, enum pdbg_target_status int pdbg_set_backend(enum pdbg_backend backend, const char *backend_option); void *pdbg_default_dtb(void); uint32_t pdbg_target_index(struct pdbg_target *target); -char *pdbg_target_path(const struct pdbg_target *target); +char *pdbg_target_path(struct pdbg_target *target); struct pdbg_target *pdbg_target_from_path(struct pdbg_target *target, const char *path); uint32_t pdbg_parent_index(struct pdbg_target *target, char *klass); const char *pdbg_target_class_name(struct pdbg_target *target); From patchwork Thu Oct 3 04:18:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1171042 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46kKXb0rFbz9sPJ for ; Thu, 3 Oct 2019 14:19:43 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="MsUkCGjd"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46kKXZ74DtzDqXJ for ; Thu, 3 Oct 2019 14:19:42 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46kKX172gmzDqX2 for ; Thu, 3 Oct 2019 14:19:13 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="MsUkCGjd"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 46kKX13mltz9sPZ; Thu, 3 Oct 2019 14:19:13 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1570076353; bh=vpyVrmbz0vtmj9G3JU3n3ZWJDQyDeR+9boBTUhAVR7A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MsUkCGjdhPCsvSZHgdT8W5ZogwtL072aGDULP6FmdC+Hj+w/jLiSKlvedFqbvsPgG uaAWKQx8meDM5YzRm3IIxQQe0fLk4anMecv7WNuUg4NHHAtGf+k4Vi0WTC7hhhAZfA QdbwA6fRSkzcPQnxZaNJ3PjIC+Dj+VLC6MPPiJ6BXVAIfIC82kd4esZagqUx8g0GXT LQ0pzv4QSJjNxbtSnk0wY5omB9+OfqXZuQMw6sjjiz3K9Ss9/VpUvi7gP7y9kt/YgU kVqbMfxLPoVKphgjoDvH0FcvmrjqG0Uja/nBonGR+A1UdW9hAMfjHfTFI1rQEyAd0h ac47vGGnrKipQ== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 3 Oct 2019 14:18:44 +1000 Message-Id: <20191003041909.23187-6-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191003041909.23187-1-amitay@ozlabs.org> References: <20191003041909.23187-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v4 05/30] libpdbg: Rename function to reflect the functionality X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- libpdbg/device.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libpdbg/device.c b/libpdbg/device.c index 6c3b769..6e2e7bb 100644 --- a/libpdbg/device.c +++ b/libpdbg/device.c @@ -173,26 +173,26 @@ static int dt_cmp_subnodes(const struct pdbg_target *a, const struct pdbg_target return strcmp(a->dn_name, b->dn_name); } -static bool dt_attach_root(struct pdbg_target *parent, struct pdbg_target *root) +static bool dt_attach_node(struct pdbg_target *parent, struct pdbg_target *child) { struct pdbg_target *node = NULL; - assert(!root->parent); + assert(!child->parent); if (list_empty(&parent->children)) { - list_add(&parent->children, &root->list); - root->parent = parent; + list_add(&parent->children, &child->list); + child->parent = parent; return true; } dt_for_each_child(parent, node) { - int cmp = dt_cmp_subnodes(node, root); + int cmp = dt_cmp_subnodes(node, child); /* Look for duplicates */ if (cmp == 0) { prerror("DT: %s failed, duplicate %s\n", - __func__, root->dn_name); + __func__, child->dn_name); return false; } @@ -202,8 +202,8 @@ static bool dt_attach_root(struct pdbg_target *parent, struct pdbg_target *root) break; } - list_add_before(&parent->children, &root->list, &node->list); - root->parent = parent; + list_add_before(&parent->children, &child->list, &node->list); + child->parent = parent; return true; } @@ -583,7 +583,7 @@ static int dt_expand_node(struct pdbg_target *node, const void *fdt, int fdt_nod * going for now, we may ultimately want to * assert */ - (void)dt_attach_root(node, child); + (void)dt_attach_node(node, child); break; case FDT_END: return -1; From patchwork Thu Oct 3 04:18:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1171044 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46kKXl4xCmz9sPJ for ; Thu, 3 Oct 2019 14:19:51 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="B5nwwuEe"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46kKXl1qf8zDqWs for ; Thu, 3 Oct 2019 14:19:51 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46kKX20RTqzDqX3 for ; Thu, 3 Oct 2019 14:19:14 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="B5nwwuEe"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 46kKX15Zpnz9sPc; Thu, 3 Oct 2019 14:19:13 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1570076353; bh=cgL+NYvETCN4wTkwi1jm06bRhZrvzNH9SBqJpgxzZxM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B5nwwuEeU9y7MNOCXtNEgvM/px344803IRYduF+RgCPwz/Y5YRs6xpjj7IAwGVp+1 LZrc6XaHaA/D+HcEc25mv1fgsaHlyErS7qwHW16ZZZRzz5pBTRSgAe1AipWsphmZk+ h0BpocYq0SUqSKYCVzQGxmfZCJJjuQd7gy8/00NdyS7/dWqK8Ab4LN7el7lqqHouWp Gxsupp5CfbzHih6qc64oWsqpr+ORX96fuvOLSG0f7V6fAE2TO5D8142yNwKRXfmm/T IIVuZCV/I8WPIXkITKBMuOplVD6QHe8BonZDPsWE2Uam9buLBZQL/vCcCGFZzXTqPS nndPOO0Be0OzA== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 3 Oct 2019 14:18:45 +1000 Message-Id: <20191003041909.23187-7-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191003041909.23187-1-amitay@ozlabs.org> References: <20191003041909.23187-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v4 06/30] libpdbg: Add virtual node target X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" This is used to construct system device tree representation. Currently there are multiple device trees for a system (e.g. P9) based on the backend where it's used. This means one cannot refer to a hwunit by specific path which is independent of backend. System device tree is a system representation that allows to identify hwunits uniquely by device tree path. However, the backend device trees are still separate. To avoid keeping two different device trees (system device tree and backend device tree) in memory, a system device tree view is created on top of the backend device tree. This system device tree view is created using virtual nodes. A virtual nodes denotes the attachment point for a hw-unit in a system device tree view. With multiple virtual nodes a system device tree view is overlaid on top of the backend device tree. Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- libpdbg/target.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libpdbg/target.h b/libpdbg/target.h index 4c24251..71ffd2f 100644 --- a/libpdbg/target.h +++ b/libpdbg/target.h @@ -50,6 +50,7 @@ struct pdbg_target { bool probed; struct list_node class_link; void *priv; + struct pdbg_target *vnode; }; struct pdbg_target_class *find_target_class(const char *name); From patchwork Thu Oct 3 04:18:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1171043 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46kKXg2hk4z9sP7 for ; Thu, 3 Oct 2019 14:19:47 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="KYP5S84A"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46kKXg1ZYSzDqWn for ; Thu, 3 Oct 2019 14:19:47 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46kKX22ZhKzDqWq for ; Thu, 3 Oct 2019 14:19:14 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="KYP5S84A"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 46kKX204Wwz9s7T; Thu, 3 Oct 2019 14:19:14 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1570076354; bh=Y2FXYIIw9U8tL6758y+lfftNrp/riwoP1doQTezh8Zw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KYP5S84AkgCrQlJxVWZ3s8xsgWUU8SR+F1Ox5HocwG0oCPgL39gYQEN3rDzYwyd2E /coivcxIWRZZVWmkKydCSfts+6I4+WPtoThJZocpA5JcKcn4JCMkOZVc56UaZ3mc5z hDxQrdpH2pW0WJNpq7cwLAat8F8aJ9faFyHW2aQuU4mQdmXCD37FVo/6QdBh/IgBrS iT1AMnEisS8BvTsmLU0uM0gr/OZfUEFZzu1dxpfmz9Cod+nlrpIOJaKwaoGB1JI/VE VpNElFA0FGPrYj8Z+H8h0OUYP5xF73l0fmmC+clVNgahDI/mkeaYYeXhcAnxY+m9AB wtiX2ZDT2jjow== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 3 Oct 2019 14:18:46 +1000 Message-Id: <20191003041909.23187-8-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191003041909.23187-1-amitay@ozlabs.org> References: <20191003041909.23187-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v4 07/30] libpdbg: Add a function to check if a target is virtual X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" All targets without "compatible" property are treated as virtual targets. Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- libpdbg/target.c | 6 ++++++ libpdbg/target.h | 1 + 2 files changed, 7 insertions(+) diff --git a/libpdbg/target.c b/libpdbg/target.c index f803ab2..9110b81 100644 --- a/libpdbg/target.c +++ b/libpdbg/target.c @@ -467,3 +467,9 @@ void pdbg_target_priv_set(struct pdbg_target *target, void *priv) { target->priv = priv; } + +/* For virtual nodes, compatible property is not set */ +bool target_is_virtual(struct pdbg_target *target) +{ + return (!target->compatible); +} diff --git a/libpdbg/target.h b/libpdbg/target.h index 71ffd2f..f5769ea 100644 --- a/libpdbg/target.h +++ b/libpdbg/target.h @@ -64,5 +64,6 @@ extern struct list_head target_classes; const char *pdbg_get_backend_option(void); struct sbefifo *pib_to_sbefifo(struct pdbg_target *target); +bool target_is_virtual(struct pdbg_target *target); #endif From patchwork Thu Oct 3 04:18:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1171045 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46kKXq0f13z9sDB for ; Thu, 3 Oct 2019 14:19:55 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="slyhMT93"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46kKXp45qMzDqXN for ; Thu, 3 Oct 2019 14:19:54 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46kKX243LQzDqWn for ; Thu, 3 Oct 2019 14:19:14 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="slyhMT93"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 46kKX22DpLz9sDB; Thu, 3 Oct 2019 14:19:14 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1570076354; bh=33DgEl2V71kPJdHQ8MGRA0m767g4xZ16J1mqaUcCxkE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=slyhMT937US4NKxsuYh41Axi/AuOj2ei4/aZ2S5Fnh0Mh6CEd4Bvf3ECOSInG0k69 o+ePwYXzlzV6k4Zyytw+ZfOe/ikX8F7HAVoaoxd0232IkITdFCETWKN6eDhXBe6kwL FJ2CZf9BZSQ1U+AxgLXJ/I14KQxgefNu0/0dYaUAjRrRbYyxp8XZw8gTKATJVz/xbU nlAWLg8h+uvY2gTVu+F06kQQg7ggu4qjh2jsHqDx4NxS70taJnNrlhrjfXVRBjpU9J 0ZukehG8yk2vUpJSax5nAw+TnIdEIBeTE7Sf77hMvOaQnYS+1Ytt5bhGPNX83/Csla jkgyCg7wxHsog== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 3 Oct 2019 14:18:47 +1000 Message-Id: <20191003041909.23187-9-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191003041909.23187-1-amitay@ozlabs.org> References: <20191003041909.23187-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v4 08/30] libpdbg: Add a function to map virtual target to real X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- libpdbg/target.c | 8 ++++++++ libpdbg/target.h | 1 + 2 files changed, 9 insertions(+) diff --git a/libpdbg/target.c b/libpdbg/target.c index 9110b81..20f292f 100644 --- a/libpdbg/target.c +++ b/libpdbg/target.c @@ -473,3 +473,11 @@ bool target_is_virtual(struct pdbg_target *target) { return (!target->compatible); } + +struct pdbg_target *target_to_real(struct pdbg_target *target) +{ + if (!target->compatible && target->vnode) + return target->vnode; + + return target; +} diff --git a/libpdbg/target.h b/libpdbg/target.h index f5769ea..5d04117 100644 --- a/libpdbg/target.h +++ b/libpdbg/target.h @@ -65,5 +65,6 @@ const char *pdbg_get_backend_option(void); struct sbefifo *pib_to_sbefifo(struct pdbg_target *target); bool target_is_virtual(struct pdbg_target *target); +struct pdbg_target *target_to_real(struct pdbg_target *target); #endif From patchwork Thu Oct 3 04:18:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1171046 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46kKXy142mz9sDB for ; Thu, 3 Oct 2019 14:20:02 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="d33LmfqR"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46kKXx5PyvzDqWm for ; Thu, 3 Oct 2019 14:20:01 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46kKX26TP1zDqWm for ; Thu, 3 Oct 2019 14:19:14 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="d33LmfqR"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 46kKX23k8zz9sP7; Thu, 3 Oct 2019 14:19:14 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1570076354; bh=LpM+MP/6GKQcP1h/rsv4Gow4eWeIOaPpw248RwIFYaE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d33LmfqR5230bc9ZweblBQRmomz0h82bQyH79dL//imdTz+4ENSrdo3xK04CoDpHA UhaDqEiP4S9YinsFHCRQNrbzuVgWEmnEc6IKgezl4BsSuzK4RvkvTXdsCxAjR9TrW1 WtvT5xOrSXeXFNmDwFn2Axk4pDlOnhKAbTKe+J/7y7ri0JAbAzo789sY/vrBFjhw+W /S0OAVagJoMO0c2XXsddwpxVPspMKQpdH+riXE0qUK9QecZyt9Xrhi9lpBJRyk9duV XHJebqIFibmJ5hrE/4AaigGJ9S8wi8wrCFZ4IUP6lBeAYZStbKOlHo7QXSOzNndqRG ny6eUTwGQ7/Zw== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 3 Oct 2019 14:18:48 +1000 Message-Id: <20191003041909.23187-10-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191003041909.23187-1-amitay@ozlabs.org> References: <20191003041909.23187-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v4 09/30] libpdbg: Add a function to map real target to virtual X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs --- libpdbg/target.c | 8 ++++++++ libpdbg/target.h | 1 + 2 files changed, 9 insertions(+) diff --git a/libpdbg/target.c b/libpdbg/target.c index 20f292f..f3d4db8 100644 --- a/libpdbg/target.c +++ b/libpdbg/target.c @@ -481,3 +481,11 @@ struct pdbg_target *target_to_real(struct pdbg_target *target) return target; } + +struct pdbg_target *target_to_virtual(struct pdbg_target *target) +{ + if (target->compatible && target->vnode) + return target->vnode; + + return target; +} diff --git a/libpdbg/target.h b/libpdbg/target.h index 5d04117..8148f83 100644 --- a/libpdbg/target.h +++ b/libpdbg/target.h @@ -66,5 +66,6 @@ const char *pdbg_get_backend_option(void); struct sbefifo *pib_to_sbefifo(struct pdbg_target *target); bool target_is_virtual(struct pdbg_target *target); struct pdbg_target *target_to_real(struct pdbg_target *target); +struct pdbg_target *target_to_virtual(struct pdbg_target *target); #endif From patchwork Thu Oct 3 04:18:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1171047 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46kKY23pKcz9sP7 for ; Thu, 3 Oct 2019 14:20:06 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="l+AZMVVd"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46kKY21nJjzDqX2 for ; Thu, 3 Oct 2019 14:20:06 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46kKX3143qzDqWq for ; Thu, 3 Oct 2019 14:19:15 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="l+AZMVVd"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 46kKX26TP1z9sPJ; Thu, 3 Oct 2019 14:19:14 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1570076354; bh=n3gwN85Acq5rx8P4tCCz82hq4m+V4I2RJTq1Tup93bk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l+AZMVVdcQnz30ApJ7l6QbByEZoh5YJeBZUcDU8O3Egq4eDAwE7M61TJduRMWx9pQ prOQK3Jsp4kqJGxqu/emfuCM1a0Zb22tNdyD5ovsebQQ5ELkrC+KcRfzOJmUmf9VXE MFqKl9KG1XWojBScoVmuadraHbvcfJEaw7YBNe3q3OtcFEN9FBd8SvJGR1RXzQLi+t 88B6H8q5QzMVBAyidxO1dmMqwnjOskWPpPm1zJRLuggyGH1+Qo7HCbxthzM6g6fmUq wsnNsjs22fN9dH3n4ouIcG594q+FP6x5JxAzSQwT/KydC9UsZK1xF0jcDVRCTXDzFG kbRVlbs4sAnqg== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 3 Oct 2019 14:18:49 +1000 Message-Id: <20191003041909.23187-11-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191003041909.23187-1-amitay@ozlabs.org> References: <20191003041909.23187-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v4 10/30] libpdbg: Support paths including virtual nodes X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" With the presence of virtual nodes, some of the nodes can be reached from the root using different paths: - using virtual nodes (which provide the system device tree view) - using the actual hwunits present in the backend (backend device tree) Both device tree paths should result in the same target. Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- libpdbg/device.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/libpdbg/device.c b/libpdbg/device.c index 6e2e7bb..2a02504 100644 --- a/libpdbg/device.c +++ b/libpdbg/device.c @@ -275,7 +275,7 @@ static struct pdbg_target *dt_find_by_path(struct pdbg_target *root, const char struct pdbg_target *n; const char *pn, *pa = NULL, *p = path, *nn = NULL, *na = NULL; unsigned int pnl, pal, nnl, nal; - bool match; + bool match, vnode; /* Walk path components */ while (*p) { @@ -284,6 +284,9 @@ static struct pdbg_target *dt_find_by_path(struct pdbg_target *root, const char if (pnl == 0 && pal == 0) break; + vnode = false; + +again: /* Compare with each child node */ match = false; list_for_each(&root->children, n, list) { @@ -300,10 +303,16 @@ static struct pdbg_target *dt_find_by_path(struct pdbg_target *root, const char } /* No child match */ - if (!match) + if (!match) { + if (!vnode && root->vnode) { + vnode = true; + root = root->vnode; + goto again; + } return NULL; + } } - return root; + return target_to_real(root); } static struct dt_property *dt_find_property(const struct pdbg_target *node, From patchwork Thu Oct 3 04:18:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1171048 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46kKY83VJCz9sP7 for ; Thu, 3 Oct 2019 14:20:12 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="wCrpv7FE"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46kKY817JTzDqX1 for ; Thu, 3 Oct 2019 14:20:12 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46kKX3385gzDqWm for ; Thu, 3 Oct 2019 14:19:15 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="wCrpv7FE"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 46kKX30pF7z9s7T; Thu, 3 Oct 2019 14:19:15 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1570076355; bh=i1J2rBX9/VHAgeVIq1bqdHEjRnQCnOLXwe2ivteQUkM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wCrpv7FErdURSDeYMqeIViOFNtWTkbRVeIMRECvg2J761mgJXz7BuMG1FER03wwJP 7qTxW9+AXIRlT8HY3309FuwUHarPyzJhOwVnMY3FLt3765uTIToXE0vxhAyrU6PyEu xSztyLPXukLNd2Nx7VhPaywydg55jWq4BRXL1HdtqsFqGZuf76wrDvr8sFeaBIUIXd E9wfuCt4ogMKyuKv+3Ck+rh5pxyPagTT7JYK5IX7Wa4VM1pQZbFdc0jf9Z7hKCH3Ju J/45N+a/31stimKuGlCcVstOeeYeHIWuV8DIgiquOmWhpVC6c7KTggMJa5tAQ6yuXR rgphllvRkVbAg== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 3 Oct 2019 14:18:50 +1000 Message-Id: <20191003041909.23187-12-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191003041909.23187-1-amitay@ozlabs.org> References: <20191003041909.23187-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v4 11/30] libpdbg: Construct unique path based on virtual nodes X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Even though there can be two different paths to a node, libpdbg users should always see the path as defined in system device tree (view) which is the same and independent of the backend device tree. Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- libpdbg/device.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libpdbg/device.c b/libpdbg/device.c index 2a02504..2f3d677 100644 --- a/libpdbg/device.c +++ b/libpdbg/device.c @@ -219,6 +219,7 @@ static char *dt_get_path(struct pdbg_target *node) return strdup(""); for (n = node; n; n = n->parent) { + n = target_to_virtual(n); len += strlen(n->dn_name); if (n->parent || n == node) len++; @@ -227,6 +228,7 @@ static char *dt_get_path(struct pdbg_target *node) assert(path); p = path + len; for (n = node; n; n = n->parent) { + n = target_to_virtual(n); len = strlen(n->dn_name); p -= len; memcpy(p, n->dn_name, len); From patchwork Thu Oct 3 04:18:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1171049 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46kKYF2ZNLz9sPJ for ; Thu, 3 Oct 2019 14:20:17 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="B+QplVqC"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46kKYF0lWZzDqXK for ; Thu, 3 Oct 2019 14:20:17 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46kKX3594FzDqWn for ; Thu, 3 Oct 2019 14:19:15 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="B+QplVqC"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 46kKX32pT5z9sDB; Thu, 3 Oct 2019 14:19:15 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1570076355; bh=J7ZJiesXNgKxUPN7hOhpmzwq9oA20o+yCFEUuzOJkag=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B+QplVqCOmiAg8gABYLQMnDmYJa9ixfd0BGdaYtPsymIFl48kwfCCtAHhhcTdP9n2 8X32juaeQJvbZbgpoAH7NthjcDVhiM+erSXGVvQ+j6g8DYWKNd7iKJWZBUWPFHrNIw XqEYpAjUibztzifU4cByR38w6+m2TpdtQfVEp/LgmxINDU6D933U2xLhQmZasTxSpz ILtLFf6wJ/q1s5kNuvZ6AHiwfjLqFJiSza4dmVzWR2uxov1OTOEbbJL15BFlN7QbuV lVYWTUKjxVASX4xAx7BB4jjacZMg/7NzyTqPx+DlI/5wbUIDJM83yl9pSrX/j0lrfZ fHnPwvwXWT+Aw== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 3 Oct 2019 14:18:51 +1000 Message-Id: <20191003041909.23187-13-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191003041909.23187-1-amitay@ozlabs.org> References: <20191003041909.23187-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v4 12/30] libpdbg: Create virtual nodes based on system-path property X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" To create a virtual node, "system-path" property is used to denote the attachment point in the system device tree view. It's also possible to create virtual nodes from backend device tree as nodes without compatible property. If a virtual node is mapped to a real node, then copy any properties (except #address-cells and #size-cells) to the real node. Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- libpdbg/device.c | 97 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/libpdbg/device.c b/libpdbg/device.c index 2f3d677..d7cd980 100644 --- a/libpdbg/device.c +++ b/libpdbg/device.c @@ -651,6 +651,102 @@ uint64_t pdbg_target_address(struct pdbg_target *target, uint64_t *out_size) return dt_get_number(p->prop, na); } +static struct pdbg_target *dt_new_virtual(struct pdbg_target *root, const char *system_path) +{ + char *parent_path, *sep; + struct pdbg_target *parent, *vnode; + + parent_path = strdup(system_path); + assert(parent_path); + + sep = strrchr(parent_path, '/'); + if (!sep || sep[1] == '\0') { + PR_ERROR("Invalid path reference \"%s\"\n", system_path); + free(parent_path); + return NULL; + } + + *sep = '\0'; + + parent = dt_find_by_path(root, parent_path); + if (!parent) { + PR_ERROR("Invalid path reference \"%s\"\n", system_path); + free(parent_path); + return NULL; + } + + vnode = dt_new_node(sep+1, NULL, 0); + assert(vnode); + + free(parent_path); + + if (!dt_attach_node(parent, vnode)) { + free(vnode); + return NULL; + } + + PR_DEBUG("Created virtual node %s\n", system_path); + return vnode; +} + +static void dt_link_virtual(struct pdbg_target *node, struct pdbg_target *vnode) +{ + struct dt_property *prop = NULL, *next; + + node->vnode = vnode; + vnode->vnode = node; + + /* Move any properties on virtual node to real node */ + list_for_each_safe(&vnode->properties, prop, next, list) { + if (!strcmp(prop->name, "#address-cells") || !strcmp(prop->name, "#size-cells")) + continue; + + list_del(&prop->list); + list_add_tail(&node->properties, &prop->list); + } +} + +static void pdbg_targets_init_virtual(struct pdbg_target *node, struct pdbg_target *root) +{ + struct pdbg_target *vnode, *child = NULL; + const char *system_path; + size_t len; + + system_path = (const char *)pdbg_target_property(node, "system-path", &len); + if (!system_path) + goto skip; + + /* + * A virtual node identifies the attachment point of a node in the + * system tree. + */ + vnode = dt_find_by_path(root, system_path); + if (!vnode) + vnode = dt_new_virtual(root, system_path); + + /* If virtual node does not exist, or cannot be created, skip */ + if (!vnode) + goto skip; + + assert(target_is_virtual(vnode)); + + /* + * If virtual node is not linked, then link with node; + * otherwise skip + */ + if (!vnode->vnode) + dt_link_virtual(node, vnode); + +skip: + list_for_each(&node->children, child, list) { + /* If a virtual node is already linked, skip */ + if (target_is_virtual(child) && child->vnode) + continue; + + pdbg_targets_init_virtual(child, root); + } +} + void pdbg_targets_init(void *fdt) { /* Root node needs to be valid when this function returns */ @@ -665,6 +761,7 @@ void pdbg_targets_init(void *fdt) } dt_expand(pdbg_dt_root, fdt); + pdbg_targets_init_virtual(pdbg_dt_root, pdbg_dt_root); } char *pdbg_target_path(struct pdbg_target *target) From patchwork Thu Oct 3 04:18:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1171050 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46kKYK5D2Sz9sPJ for ; Thu, 3 Oct 2019 14:20:21 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="r2/0iVEg"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46kKYK0yHSzDqWm for ; Thu, 3 Oct 2019 14:20:21 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46kKX36YfPzDqWm for ; Thu, 3 Oct 2019 14:19:15 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="r2/0iVEg"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 46kKX34sBmz9sP7; Thu, 3 Oct 2019 14:19:15 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1570076355; bh=M7CHI/Rl/8hHLrX745Ktz7eyGOfR6wyJJkcHjEhSy+U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r2/0iVEgp6KNG35cpwP/SGQoP81gG5r6du9jvUxh6ZTV8mjEXNQZWdXsrvMEPMlAm VCFtIsJpbs5uFYor5ggLIr41irJCT+iqF8jIi+m7YR9jBS8mX+KDYskixL0p9+y6w7 pva5TX72MAaEnR5+PVcuSssdhvae3uTN+Mry8MFOYwsH8tn/Qa4M9LIXxWDg18ZCDF yd760qmnFwwWq/MBXonAlen1SCEjopFC3B87lS8VcBvdrkeG7Hlttlqc3ZG4Zf6bJt dKFYqGBMgB5gtbItw2D8RWGG5x7BvBVIQqjsA7HiaLhlSmE43aDYOmYhFnhHPUHfxW Pj+LIPu17lXYQ== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 3 Oct 2019 14:18:52 +1000 Message-Id: <20191003041909.23187-14-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191003041909.23187-1-amitay@ozlabs.org> References: <20191003041909.23187-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v4 13/30] libpdbg: Child traversal should handle virtual nodes correctly X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" When traversing system device tree view (system == true), the children are calculated based on the system device tree view (using the virtual node attachments). When traversing backend device tree (system == false), the virtual nodes are ignored except if they are part of the backend device tree itself. Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- libpdbg/libpdbg.c | 96 ++++++++++++++++++++++++++++++++++++++++++++--- libpdbg/libpdbg.h | 6 +-- 2 files changed, 93 insertions(+), 9 deletions(-) diff --git a/libpdbg/libpdbg.c b/libpdbg/libpdbg.c index aade5d3..158c63e 100644 --- a/libpdbg/libpdbg.c +++ b/libpdbg/libpdbg.c @@ -43,18 +43,102 @@ retry: } } -struct pdbg_target *__pdbg_next_child_target(struct pdbg_target *parent, struct pdbg_target *last) +static struct pdbg_target *target_map_child(struct pdbg_target *next, bool system) { - if (!parent || list_empty(&parent->children)) + /* + * Map a target in system tree: + * + * - If there is no virtual node assiociated, then return the target + * (the target itself can be virtual or real) + * + * - If there is virtual node associated, + * - If the target is virtual, return the associated node + * - If the target is real, return NULL + * (this target is already covered by previous condition) + * + * Map a target in backend tree: + * + * - If the target is real, return the target + * + * - If the target is virtual, return NULL + * (no virtual nodes in backend tree) + */ + if (system) { + if (!next->vnode) + return next; + else + if (target_is_virtual(next)) + return next->vnode; + } else { + if (!target_is_virtual(next)) + return next; + } + + return NULL; +} + +struct pdbg_target *__pdbg_next_child_target(struct pdbg_target *parent, struct pdbg_target *last, bool system) +{ + struct pdbg_target *next, *child = NULL; + + if (!parent) return NULL; - if (!last) - return list_top(&parent->children, struct pdbg_target, list); + /* + * Parent node can be virtual or real. + * + * If the parent node doesn't have any children, + * - If there is associated virtual node, + * Use that node as parent + * + * - If there is no associated virtual node, + * No children + */ + if (list_empty(&parent->children)) { + if (parent->vnode) + parent = parent->vnode; + else + return NULL; + } + + /* + * If the parent node has children, + * - Traverse the children + * (map the children in system or backend tree) + */ + if (!last) { + list_for_each(&parent->children, child, list) + if ((next = target_map_child(child, system))) + return next; - if (last->list.next == &parent->children.n) return NULL; + } - return list_entry(last->list.next, struct pdbg_target, list); + /* + * In a system tree traversal, virtual targets with associated + * nodes, get mapped to real targets. + * + * When the last child is specified: + * - If in a system tree traverse, and + * the last child has associated node, and + * the last child is real + * Then the last child is not the actual child of the parent + * (the associated virtual node is the actual child) + */ + if (system) + last = target_to_virtual(last); + + if (last == list_tail(&parent->children, struct pdbg_target, list)) + return NULL; + + child = last; + do { + child = list_entry(child->list.next, struct pdbg_target, list); + if ((next = target_map_child(child, system))) + return next; + } while (child != list_tail(&parent->children, struct pdbg_target, list)); + + return NULL; } enum pdbg_target_status pdbg_target_status(struct pdbg_target *target) diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h index 722ddc2..4eec123 100644 --- a/libpdbg/libpdbg.h +++ b/libpdbg/libpdbg.h @@ -20,7 +20,7 @@ struct pdbg_target *__pdbg_next_compatible_node(struct pdbg_target *root, struct pdbg_target *prev, const char *compat); struct pdbg_target *__pdbg_next_target(const char *klass, struct pdbg_target *parent, struct pdbg_target *last); -struct pdbg_target *__pdbg_next_child_target(struct pdbg_target *parent, struct pdbg_target *last); +struct pdbg_target *__pdbg_next_child_target(struct pdbg_target *parent, struct pdbg_target *last, bool system); /* * Each target has a status associated with it. This is what each status means: @@ -71,9 +71,9 @@ enum pdbg_backend { PDBG_DEFAULT_BACKEND = 0, PDBG_BACKEND_FSI, PDBG_BACKEND_I2C target = __pdbg_next_target(class, NULL, target)) #define pdbg_for_each_child_target(parent, target) \ - for (target = __pdbg_next_child_target(parent, NULL); \ + for (target = __pdbg_next_child_target(parent, NULL, true); \ target; \ - target = __pdbg_next_child_target(parent, target)) + target = __pdbg_next_child_target(parent, target, true)) /* Return the first parent target of the given class, or NULL if the given * target does not have a parent of the given class. */ From patchwork Thu Oct 3 04:18:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1171051 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46kKYQ44wfz9sPJ for ; Thu, 3 Oct 2019 14:20:26 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="vQqxVYcP"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46kKYP2f7CzDqXK for ; Thu, 3 Oct 2019 14:20:25 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46kKX42PqvzDqWm for ; Thu, 3 Oct 2019 14:19:16 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="vQqxVYcP"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 46kKX36Q00z9s7T; Thu, 3 Oct 2019 14:19:15 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1570076356; bh=eTvIUSoVDpDdTcfjeIRfA4Z4rBqkqpEAOUBNvfVshjw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vQqxVYcP12nNeUo8QJErDHrD40A7VFX6t7bZUmSmjdRreZXmR+2mWWOmyWKVQIU6T tIzp3GeHF4qQhjPQUQaUybQrhBiB3XnjkrVuVSiE/FqMAEyEF3JlyGmS6cEZma+TAi jprlub8J1RuNra7DqZLyKzbgDJQ5SbK257Ad8M5X6WWZppwIGRsrOP6V9RlMV0JFVN GD0kEb+ZON98PUxO4aSO4IQvyc4WkOwOxKElQEBkXbvY+ObjLG8fkCAZijLyofF8iF wZo9scMIMXUxSYJ+MLkcmSKzuh0vgvAt4ns6wn82USfOsOImTgThjXhItJvMcFmJRe NwAc1e5tzE+sg== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 3 Oct 2019 14:18:53 +1000 Message-Id: <20191003041909.23187-15-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191003041909.23187-1-amitay@ozlabs.org> References: <20191003041909.23187-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v4 14/30] libpdbg: Parent retrieval should handle virtual nodes correctly X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" When traversing system device tree view (system == true), parent of a node can be a virtual node. When traversing backend device tree, parent of a node will not be a virtual node unless it's part of the backend device tree itself. Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- libpdbg/libpdbg.c | 46 ++++++++++++++++++++++++++++++++++++++++------ libpdbg/libpdbg.h | 10 +++++----- libpdbg/target.c | 2 +- libpdbg/target.h | 1 + src/thread.c | 4 ++-- 5 files changed, 49 insertions(+), 14 deletions(-) diff --git a/libpdbg/libpdbg.c b/libpdbg/libpdbg.c index 158c63e..7e72024 100644 --- a/libpdbg/libpdbg.c +++ b/libpdbg/libpdbg.c @@ -6,7 +6,36 @@ static pdbg_progress_tick_t progress_tick; -struct pdbg_target *__pdbg_next_target(const char *class, struct pdbg_target *parent, struct pdbg_target *last) +struct pdbg_target *get_parent(struct pdbg_target *target, bool system) +{ + struct pdbg_target *parent; + + if (!target) + return NULL; + + /* + * To find a parent in the system tree: + * - If a target is real, map it to possible virtual target + * - Calculate the parent + * - If the parent is virtual, map it to real target + * + * To find a parent in the backend tree: + * - Target will be real or virtual without mapped real node + * - Calculate the parent + * - If the parent is virtual, map it to real target + */ + if (system) + target = target_to_virtual(target); + + parent = target->parent; + + if (!parent) + return NULL; + + return target_to_real(parent); +} + +struct pdbg_target *__pdbg_next_target(const char *class, struct pdbg_target *parent, struct pdbg_target *last, bool system) { struct pdbg_target *next, *tmp; struct pdbg_target_class *target_class; @@ -33,7 +62,7 @@ retry: return next; else { /* Check if this target is a child of the given parent */ - for (tmp = next; tmp && next->parent && tmp != parent; tmp = tmp->parent) {} + for (tmp = next; tmp && get_parent(tmp, system) && tmp != parent; tmp = get_parent(tmp, system)) {} if (tmp == parent) return next; else { @@ -160,7 +189,7 @@ uint32_t pdbg_target_index(struct pdbg_target *target) { struct pdbg_target *dn; - for (dn = target; dn && dn->index == -1; dn = dn->parent); + for (dn = target; dn && dn->index == -1; dn = get_parent(dn, true)); if (!dn) return -1; @@ -174,10 +203,15 @@ struct pdbg_target *pdbg_target_parent(const char *class, struct pdbg_target *ta struct pdbg_target *parent; if (!class) - return target->parent; + return get_parent(target, true); + + for (parent = get_parent(target, true); parent && get_parent(parent, true); parent = get_parent(parent, true)) { + const char *tclass = pdbg_target_class_name(parent); + + if (!tclass) + continue; - for (parent = target->parent; parent && parent->parent; parent = parent->parent) { - if (!strcmp(class, pdbg_target_class_name(parent))) + if (!strcmp(class, tclass)) return parent; } diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h index 4eec123..ca4f951 100644 --- a/libpdbg/libpdbg.h +++ b/libpdbg/libpdbg.h @@ -19,7 +19,7 @@ struct pdbg_target_class; struct pdbg_target *__pdbg_next_compatible_node(struct pdbg_target *root, struct pdbg_target *prev, const char *compat); -struct pdbg_target *__pdbg_next_target(const char *klass, struct pdbg_target *parent, struct pdbg_target *last); +struct pdbg_target *__pdbg_next_target(const char *klass, struct pdbg_target *parent, struct pdbg_target *last, bool system); struct pdbg_target *__pdbg_next_child_target(struct pdbg_target *parent, struct pdbg_target *last, bool system); /* @@ -61,14 +61,14 @@ enum pdbg_backend { PDBG_DEFAULT_BACKEND = 0, PDBG_BACKEND_FSI, PDBG_BACKEND_I2C (target = __pdbg_next_compatible_node(parent, target, compat)) != NULL;) #define pdbg_for_each_target(class, parent, target) \ - for (target = __pdbg_next_target(class, parent, NULL); \ + for (target = __pdbg_next_target(class, parent, NULL, true); \ target; \ - target = __pdbg_next_target(class, parent, target)) + target = __pdbg_next_target(class, parent, target, true)) #define pdbg_for_each_class_target(class, target) \ - for (target = __pdbg_next_target(class, NULL, NULL); \ + for (target = __pdbg_next_target(class, NULL, NULL, true); \ target; \ - target = __pdbg_next_target(class, NULL, target)) + target = __pdbg_next_target(class, NULL, target, true)) #define pdbg_for_each_child_target(parent, target) \ for (target = __pdbg_next_child_target(parent, NULL, true); \ diff --git a/libpdbg/target.c b/libpdbg/target.c index f3d4db8..a68cb6c 100644 --- a/libpdbg/target.c +++ b/libpdbg/target.c @@ -27,7 +27,7 @@ static struct pdbg_target *get_class_target_addr(struct pdbg_target *target, con *addr += pdbg_target_address(target, NULL); /* Keep walking the tree translating addresses */ - target = target->parent; + target = get_parent(target, false); /* The root node doesn't have an address space so it's * an error in the device tree if we hit this. */ diff --git a/libpdbg/target.h b/libpdbg/target.h index 8148f83..a8b0d3d 100644 --- a/libpdbg/target.h +++ b/libpdbg/target.h @@ -53,6 +53,7 @@ struct pdbg_target { struct pdbg_target *vnode; }; +struct pdbg_target *get_parent(struct pdbg_target *target, bool system); struct pdbg_target_class *find_target_class(const char *name); struct pdbg_target_class *require_target_class(const char *name); struct pdbg_target_class *get_target_class(struct pdbg_target *target); diff --git a/src/thread.c b/src/thread.c index 663f290..8ddf4ae 100644 --- a/src/thread.c +++ b/src/thread.c @@ -277,10 +277,10 @@ static int thread_status_print(void) assert(path_target_add(pib)); } - pib = __pdbg_next_target("pib", pdbg_target_root(), NULL); + pib = __pdbg_next_target("pib", pdbg_target_root(), NULL, true); assert(pib); - core = __pdbg_next_target("core", pib, NULL); + core = __pdbg_next_target("core", pib, NULL, true); assert(core); pdbg_for_each_target("thread", core, thread) From patchwork Thu Oct 3 04:18:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1171052 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46kKYV2XyWz9sDB for ; Thu, 3 Oct 2019 14:20:30 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="BHYY9dqe"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46kKYV11txzDqX7 for ; Thu, 3 Oct 2019 14:20:30 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46kKX43fgtzDqWn for ; Thu, 3 Oct 2019 14:19:16 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="BHYY9dqe"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 46kKX425q8z9sDB; Thu, 3 Oct 2019 14:19:16 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1570076356; bh=H6kTVOhKrWvLB3TIkDR8NzOUsNRaN5A7t50jqH3ucnk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BHYY9dqeSahBLHjzlivp5EegmKuRM387GWJpz2xO+kwiP9qXPGw61Se8rFbqa+ck+ 3/gkROlDBTgzyyETfeWj4xZNYYiBFqbuhnWrp1KHHJeeLFqxbNUgOUAoR9UT27x45s wxbeE/yxbmknUwBDrVf3NgRFvnvkBBxIKMWIk5ouUHGS1QAF/1LuzyNpfBj2cjAlvm ArHgSJnJnFoCJdk15tRjQXZJnBgZqY7qbRdnbOsIhAW7wXyyFa1Z/b3oA8Z7LnKBMn p5/mQ8QA/qalNy9E2ZbtWBJqq7Zbcp/DCZlIZ7VI84ygDgnhI61PzS0iaBXQ+GEDOv kHi8rqtPI5DIQ== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 3 Oct 2019 14:18:54 +1000 Message-Id: <20191003041909.23187-16-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191003041909.23187-1-amitay@ozlabs.org> References: <20191003041909.23187-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v4 15/30] libpdbg: Add functions to get parent in backend or system tree X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" When using backend targets, the parent should be calculated based on backend tree and not system tree (e.g. cfam). Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- libpdbg/cfam.c | 4 ++-- libpdbg/libpdbg.c | 24 +++++++++++++++++------- libpdbg/target.h | 2 ++ 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/libpdbg/cfam.c b/libpdbg/cfam.c index 868ca76..da4c5fc 100644 --- a/libpdbg/cfam.c +++ b/libpdbg/cfam.c @@ -294,7 +294,7 @@ DECLARE_HW_UNIT(p8_opb_hmfsi); static int cfam_hmfsi_read(struct fsi *fsi, uint32_t addr, uint32_t *data) { - struct pdbg_target *parent_fsi = pdbg_target_require_parent("fsi", &fsi->target); + struct pdbg_target *parent_fsi = require_target_parent("fsi", &fsi->target, false); addr += pdbg_target_address(&fsi->target, NULL); @@ -303,7 +303,7 @@ static int cfam_hmfsi_read(struct fsi *fsi, uint32_t addr, uint32_t *data) static int cfam_hmfsi_write(struct fsi *fsi, uint32_t addr, uint32_t data) { - struct pdbg_target *parent_fsi = pdbg_target_require_parent("fsi", &fsi->target); + struct pdbg_target *parent_fsi = require_target_parent("fsi", &fsi->target, false); addr += pdbg_target_address(&fsi->target, NULL); diff --git a/libpdbg/libpdbg.c b/libpdbg/libpdbg.c index 7e72024..eaf2782 100644 --- a/libpdbg/libpdbg.c +++ b/libpdbg/libpdbg.c @@ -198,34 +198,44 @@ uint32_t pdbg_target_index(struct pdbg_target *target) } /* Find a target parent from the given class */ -struct pdbg_target *pdbg_target_parent(const char *class, struct pdbg_target *target) +struct pdbg_target *target_parent(const char *klass, struct pdbg_target *target, bool system) { struct pdbg_target *parent; - if (!class) - return get_parent(target, true); + if (!klass) + return get_parent(target, system); - for (parent = get_parent(target, true); parent && get_parent(parent, true); parent = get_parent(parent, true)) { + for (parent = get_parent(target, system); parent && get_parent(parent, system); parent = get_parent(parent, system)) { const char *tclass = pdbg_target_class_name(parent); if (!tclass) continue; - if (!strcmp(class, tclass)) + if (!strcmp(klass, tclass)) return parent; } return NULL; } -struct pdbg_target *pdbg_target_require_parent(const char *class, struct pdbg_target *target) +struct pdbg_target *pdbg_target_parent(const char *klass, struct pdbg_target *target) { - struct pdbg_target *parent = pdbg_target_parent(class, target); + return target_parent(klass, target, true); +} + +struct pdbg_target *require_target_parent(const char *klass, struct pdbg_target *target, bool system) +{ + struct pdbg_target *parent = target_parent(klass, target, system); assert(parent); return parent; } +struct pdbg_target *pdbg_target_require_parent(const char *klass, struct pdbg_target *target) +{ + return require_target_parent(klass, target, true); +} + /* Searched up the tree for the first target of the right class and returns its index */ uint32_t pdbg_parent_index(struct pdbg_target *target, char *class) { diff --git a/libpdbg/target.h b/libpdbg/target.h index a8b0d3d..df4f3f8 100644 --- a/libpdbg/target.h +++ b/libpdbg/target.h @@ -54,6 +54,8 @@ struct pdbg_target { }; struct pdbg_target *get_parent(struct pdbg_target *target, bool system); +struct pdbg_target *target_parent(const char *klass, struct pdbg_target *target, bool system); +struct pdbg_target *require_target_parent(const char *klass, struct pdbg_target *target, bool system); struct pdbg_target_class *find_target_class(const char *name); struct pdbg_target_class *require_target_class(const char *name); struct pdbg_target_class *get_target_class(struct pdbg_target *target); From patchwork Thu Oct 3 04:18:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1171053 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46kKYZ25JFz9sPJ for ; Thu, 3 Oct 2019 14:20:34 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="Imy5awU9"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46kKYY67s6zDqWs for ; Thu, 3 Oct 2019 14:20:33 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46kKX45090zDqWq for ; Thu, 3 Oct 2019 14:19:16 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="Imy5awU9"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 46kKX43Mq5z9sP7; Thu, 3 Oct 2019 14:19:16 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1570076356; bh=GbtU+uEU4CHpqrdmikKOmItrbOsHDEjLDtPjx5qpAEc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Imy5awU9chWcmein8eih/vs2LRh5hArMfdZPa5OJUz9A971Z5YSY9tHVVx2Zl2mTr 6WXAqLCEui9zN4KZssXM1QbaPVYGzyNbZVmkZbCj7Sq87GaZc0ymVYqitJH1X6JAda APFVQuK3r4bBifJLk/iFXz7HKL7gCS2Da39H2eR1P/wh1yBe2dfSdq+5iCS382p9xn D6ZtDmGBDWeIvY49zkWzdEzZ4A/MLDnnXePOkL5EZV5C2wCElFwPvdJSYt5Kf1aB/D kOr2AlEI6aT6NXwKlvWiG+lwoOuMnnrub07RoLvBrV5REnr4O0lWCFX+/uWFxkNiDx CZLNK0pDuIF+g== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 3 Oct 2019 14:18:55 +1000 Message-Id: <20191003041909.23187-17-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191003041909.23187-1-amitay@ozlabs.org> References: <20191003041909.23187-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v4 16/30] libpdbg: Probe should traverse virtual nodes also X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" This ensures that the virtual nodes have correct status in the system device tree view. Signed-off-by: Amitay Isaacs --- libpdbg/target.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libpdbg/target.c b/libpdbg/target.c index a68cb6c..ca2bdb6 100644 --- a/libpdbg/target.c +++ b/libpdbg/target.c @@ -360,7 +360,7 @@ struct pdbg_target_class *get_target_class(struct pdbg_target *target) * exist but don't */ enum pdbg_target_status pdbg_target_probe(struct pdbg_target *target) { - struct pdbg_target *parent; + struct pdbg_target *parent, *vnode; enum pdbg_target_status status; assert(target); @@ -374,7 +374,7 @@ enum pdbg_target_status pdbg_target_probe(struct pdbg_target *target) * it's status won't have changed */ return status; - parent = target->parent; + parent = get_parent(target, false); if (parent) { /* Recurse up the tree to probe and set parent target status */ pdbg_target_probe(parent); @@ -406,6 +406,11 @@ enum pdbg_target_status pdbg_target_probe(struct pdbg_target *target) } } + /* Make sure any virtual nodes are also probed */ + vnode = target_to_virtual(target); + if (vnode && vnode != target) + pdbg_target_probe(vnode); + /* At this point any parents must exist and have already been probed */ if (target->probe && target->probe(target)) { /* Could not find the target */ From patchwork Thu Oct 3 04:18:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1171054 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46kKYh39dsz9sDB for ; Thu, 3 Oct 2019 14:20:40 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="hHCn36Ug"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46kKYg6CVYzDqWm for ; Thu, 3 Oct 2019 14:20:39 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46kKX46MFSzDqWm for ; Thu, 3 Oct 2019 14:19:16 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="hHCn36Ug"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 46kKX44h8Kz9s7T; Thu, 3 Oct 2019 14:19:16 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1570076356; bh=e9szRdHKHlcatnuku6tg40e0JCwsbxL2p264XRGsVCM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hHCn36Ugc8N8P+Y/FK45j4LLKjjyhqo9mvhjoxB7j7E9qYIDutBlPB3dX9fVYTWHb rrLHxEfOtndingRMniGZvB9RWNbMWDKF0tRRvug9UNL6G01CbVXZFJr5xScdOGAopD 1QC/OsS8y/G2t9oWwGSyL1msgWxQOQEYrtMqfdQv0PmAG/Mh4A9OfOW5a4H7iMi4+n lafoo4HCFi3xgK9IIqyNesSXRIDPzxjqNg5DCarX+c6jNxHtlvHqYhS7qqyKf8MgiJ lTc4oSwTlWBbCk1JwnlxMoS+dUQBKvhCKYAaZPAkeWeIFRZujWN+879m8TLi6G5Xhu DxCFnIqFkag8Q== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 3 Oct 2019 14:18:56 +1000 Message-Id: <20191003041909.23187-18-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191003041909.23187-1-amitay@ozlabs.org> References: <20191003041909.23187-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v4 17/30] main: Use dn_name for printing virtual nodes X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Virtual nodes do not have a class name. When traversing system device tree view, virtual nodes need to be handled correctly. So instead of skipping the nodes if classname is not set, print dn name for virtual nodes. Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- src/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main.c b/src/main.c index 44d1c55..f7f891a 100644 --- a/src/main.c +++ b/src/main.c @@ -529,10 +529,10 @@ static void print_target(struct pdbg_target *target, int level) printf(" "); classname = pdbg_target_class_name(target); - if (!classname) - return; - - printf("%s%d: %s", classname, pdbg_target_index(target), pdbg_target_name(target)); + if (classname) + printf("%s%d: %s", classname, pdbg_target_index(target), pdbg_target_name(target)); + else + printf("%s:", pdbg_target_dn_name(target)); if (path_target_selected(target)) printf(" (*)"); printf("\n"); From patchwork Thu Oct 3 04:18:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1171055 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46kKYl4FmYz9sP7 for ; Thu, 3 Oct 2019 14:20:43 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="IKFiWuzw"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46kKYk5Gb1zDqXS for ; Thu, 3 Oct 2019 14:20:42 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46kKX50v6zzDqWn for ; Thu, 3 Oct 2019 14:19:17 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="IKFiWuzw"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 46kKX468fDz9sPJ; Thu, 3 Oct 2019 14:19:16 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1570076356; bh=6vNBj4wwobosEt2XiThD2FkKb5PYoExYsMcb1iTiCNA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IKFiWuzw7ilKrfzl5+MNmzOOi4gHYBArXG5ArISXqirKBVZ/avKK7GQLhfUo7VEwU QalR9t/NmIxsrspsR3T6g0HeUlU6IHa/90H0NsSSUZU0099c6YI8SD+bfcJ/+eYa/v 5RUSSzA4bVKg1MZTkrEL70pMFvNjgYWUkwXn3s+ECzBnwGBKpZiGKTDqCrEx8DIAvn jNT+sQbCkXN1r4vRyCiQm6E64L131JS4hvKTQftcHD8Q2GFJI5m3MbyY8nLZ2tr7Hi Vmv/SOdp2flrJZFQFtBBK8EjkqyOnQ8dgdOced4M//6bU/rCEMm2CkBzE+O7b25IKA btLZVThB+74sQ== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 3 Oct 2019 14:18:57 +1000 Message-Id: <20191003041909.23187-19-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191003041909.23187-1-amitay@ozlabs.org> References: <20191003041909.23187-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v4 18/30] main: Avoid printing top level "proc" if no child is enabled X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs --- src/main.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main.c b/src/main.c index f7f891a..09c236e 100644 --- a/src/main.c +++ b/src/main.c @@ -513,6 +513,21 @@ static bool parse_options(int argc, char *argv[]) return true; } +static bool child_enabled(struct pdbg_target *target) +{ + struct pdbg_target *child; + + pdbg_for_each_child_target(target, child) { + if (child_enabled(child)) + return true; + + if (pdbg_target_status(child) == PDBG_TARGET_ENABLED) + return true; + } + + return false; +} + static void print_target(struct pdbg_target *target, int level) { int i; @@ -520,6 +535,9 @@ static void print_target(struct pdbg_target *target, int level) enum pdbg_target_status status; const char *classname; + if (level == 0 && !child_enabled(target)) + return; + /* Does this target actually exist? */ status = pdbg_target_status(target); if (status != PDBG_TARGET_ENABLED) From patchwork Thu Oct 3 04:18:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1171056 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46kKYq5815z9sDB for ; Thu, 3 Oct 2019 14:20:47 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="a+H90CY8"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46kKYq3z22zDqXJ for ; Thu, 3 Oct 2019 14:20:47 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46kKX52Lb4zDqWq for ; Thu, 3 Oct 2019 14:19:17 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="a+H90CY8"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 46kKX50dTlz9sDB; Thu, 3 Oct 2019 14:19:17 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1570076357; bh=V3xnFPvrLWb55Ze9/hTXJvh/dqmDQNNhLrW6bF+3nMA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a+H90CY8wAlbcvL+fKAqqnU6aDpmhg3F6u7NmZadtulcOtERPnq22EfA6WgEJagxl pnGEesZl0Q+c26kqRdy00ijFPL6rEmfX3UOZHNtYNDIldAZJICAmY9Yqy4GK607eLp T72Oie2Sv5OfNPhqkNKP9UdOWFqaoBOs7xesDut2uQGBPs6zynAXXPSyD418g8vcwK QWliBzZBPGnID9ujcOutzW5GkfhZXD66lixAdEcIlyjG/qy/gQqim/P05T5zhujUvd pMOtETU8CgkntTiQ/VlXDB4BjpPXzDPvgHc4v1QLdtSU34vXJeFMCylP6Jp16mu5R7 Av7Q9lu+jPFcQ== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 3 Oct 2019 14:18:58 +1000 Message-Id: <20191003041909.23187-20-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191003041909.23187-1-amitay@ozlabs.org> References: <20191003041909.23187-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v4 19/30] fake: Add virtual nodes for pib targets X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- fake.dts.m4 | 68 +++++++----- src/tests/libpdbg_probe_test.c | 13 +++ src/tests/libpdbg_target_test.c | 50 ++++++--- tests/test_selection.sh | 98 +++++++++++++++--- tests/test_selection2.sh | 178 +++++++++++++++++++++++++++++--- 5 files changed, 335 insertions(+), 72 deletions(-) diff --git a/fake.dts.m4 b/fake.dts.m4 index 92697df..a099154 100644 --- a/fake.dts.m4 +++ b/fake.dts.m4 @@ -1,3 +1,5 @@ +define(`CONCAT', `$1$2')dnl + dnl dnl forloop([var], [start], [end], [iterator]) dnl @@ -47,55 +49,67 @@ forloop(`i', `0', eval(`$3-1'), `dump_thread(i)') dump_core_post()') dnl -dnl dump_processor_pre([index], [addr]) +dnl dump_processor_pre([index]) dnl -define(`dump_processor_pre', -` - pib@$2 { +define(`dump_processor_pre',`dnl + pib { #address-cells = <0x1>; - #size-cells = <0x1>; - compatible = "ibm,fake-pib"; - reg = <0x$2 0x0>; - index = <0x$1>;') + #size-cells = <0x1>;') dnl dnl dump_processor_post() dnl -define(`dump_processor_post', ` }; +define(`dump_processor_post', ` }; ')dnl dnl -dnl dump_processor([index], [addr], [num_cores], [num_threads]) +dnl dump_processor([index], [num_cores], [num_threads]) dnl define(`dump_processor',dnl -`dump_processor_pre(`$1', `$2') -forloop(`i', `0', eval(`$3-1'), `dump_core(i, eval(10000+(i+1)*10), $4)') +`dump_processor_pre(`$1') +forloop(`i', `0', eval(`$2-1'), `dump_core(i, eval(10000+(i+1)*10), $3)') dump_processor_post()') dnl -dnl dump_fsi_pre([index], [addr]) +dnl dump_backend([index], [addr]) dnl -define(`dump_fsi_pre', -` +define(`dump_backend',dnl +`define(`pib_addr', eval(`$2+100'))dnl + fsi@$2 { #address-cells = <0x1>; #size-cells = <0x1>; compatible = "ibm,fake-fsi"; - reg = <0x$2 0x0>; - index = <0x$1>;') + system-path = "/proc$1/fsi"; + reg = <0x0 0x0>; + index = <0x$1>; + + CONCAT(pib@,pib_addr) { + #address-cells = <0x1>; + #size-cells = <0x1>; + compatible = "ibm,fake-pib"; + system-path = "/proc$1/pib"; + reg = ; + index = <0x$1>; + }; + }; + +')dnl -dnl -dnl dump_fsi_post() -dnl -define(`dump_fsi_post', ` };') dnl -dnl dump_fsi([index], [addr], [num_processors], [num_cores], [num_threads]) +dnl dump_system([num_processors], [num_cores], [num_threads]) dnl -define(`dump_fsi', -`dump_fsi_pre(`$1', `$2') -forloop(`i', `0', eval(`$3-1'), `dump_processor(i, eval(10000+i*1000), $4, $5)') -dump_fsi_post()') +define(`dump_system', +`forloop(`i', `0', eval(`$1-1'), `dump_backend(i, eval(20000+i*1000))') +forloop(`i', `0', eval(`$1-1'),dnl +` + CONCAT(proc,i) { + index = < CONCAT(0x,i) >; + +dump_processor(i, $2, $3) + }; +')') divert`'dnl /dts-v1/; @@ -103,5 +117,5 @@ divert`'dnl / { #address-cells = <0x1>; #size-cells = <0x1>; -dump_fsi(0, 0, 8, 4, 2) +dump_system(8, 4, 2) }; diff --git a/src/tests/libpdbg_probe_test.c b/src/tests/libpdbg_probe_test.c index 8b78b2e..ed8a800 100644 --- a/src/tests/libpdbg_probe_test.c +++ b/src/tests/libpdbg_probe_test.c @@ -129,6 +129,12 @@ static void test2(void) for_each_target(root, check_status, PDBG_TARGET_UNKNOWN); + pdbg_for_each_class_target("fsi", target) { + status = pdbg_target_probe(target); + assert(status == PDBG_TARGET_ENABLED); + + for_target_to_root(target, check_status, PDBG_TARGET_ENABLED); + } pdbg_for_each_class_target("pib", target) { status = pdbg_target_probe(target); assert(status == PDBG_TARGET_ENABLED); @@ -172,6 +178,13 @@ static void test2(void) check_status(target, PDBG_TARGET_RELEASED); } + pdbg_for_each_class_target("pib", target) { + pdbg_target_release(target); + } + pdbg_for_each_class_target("pib", target) { + for_each_target(target, check_status, PDBG_TARGET_RELEASED); + } + pdbg_for_each_class_target("fsi", target) { pdbg_target_release(target); } diff --git a/src/tests/libpdbg_target_test.c b/src/tests/libpdbg_target_test.c index 27efb56..9806281 100644 --- a/src/tests/libpdbg_target_test.c +++ b/src/tests/libpdbg_target_test.c @@ -72,7 +72,7 @@ int main(void) assert(root); count = count_class_target("fsi"); - assert(count == 1); + assert(count == 8); count = count_class_target("pib"); assert(count == 8); @@ -83,7 +83,28 @@ int main(void) count = count_class_target("thread"); assert(count == 64); + pdbg_for_each_child_target(root, parent) { + name = pdbg_target_dn_name(parent); + assert(strncmp(name, "proc", 4) == 0); + + pdbg_for_each_target("pib", parent, target) { + name = pdbg_target_class_name(target); + assert(!strcmp(name, "pib")); + } + + pdbg_for_each_target("fsi", parent, target) { + name = pdbg_target_class_name(target); + assert(!strcmp(name, "fsi")); + } + }; + pdbg_for_each_class_target("fsi", target) { + parent = pdbg_target_parent(NULL, target); + assert(parent); + + name = pdbg_target_dn_name(parent); + assert(strncmp(name, "proc", 4) == 0); + parent = pdbg_target_parent("fsi", target); assert(parent == NULL); @@ -97,19 +118,19 @@ int main(void) assert(parent == NULL); count = count_child_target(target); - assert(count == 8); + assert(count == 0); count = count_target(target, "fsi"); assert(count == 1); count = count_target(target, "pib"); - assert(count == 8); + assert(count == 0); count = count_target(target, "core"); - assert(count == 32); + assert(count == 0); count = count_target(target, "thread"); - assert(count == 64); + assert(count == 0); name = pdbg_target_name(target); assert(!strcmp(name, "Fake FSI")); @@ -122,11 +143,14 @@ int main(void) } pdbg_for_each_class_target("pib", target) { - parent = pdbg_target_parent("fsi", target); + parent = pdbg_target_parent(NULL, target); assert(parent); - parent2 = pdbg_target_require_parent("fsi", target); - assert(parent == parent2); + name = pdbg_target_dn_name(parent); + assert(strncmp(name, "proc", 4) == 0); + + parent = pdbg_target_parent("fsi", target); + assert(parent == NULL); parent = pdbg_target_parent("pib", target); assert(parent == NULL); @@ -167,10 +191,7 @@ int main(void) uint32_t index; parent = pdbg_target_parent("fsi", target); - assert(parent); - - parent2 = pdbg_target_require_parent("fsi", target); - assert(parent == parent2); + assert(parent == NULL); parent = pdbg_target_parent("pib", target); assert(parent); @@ -216,10 +237,7 @@ int main(void) pdbg_for_each_class_target("thread", target) { parent = pdbg_target_parent("fsi", target); - assert(parent); - - parent2 = pdbg_target_require_parent("fsi", target); - assert(parent == parent2); + assert(parent == NULL); parent = pdbg_target_parent("pib", target); assert(parent); diff --git a/tests/test_selection.sh b/tests/test_selection.sh index 50db9e4..0931051 100755 --- a/tests/test_selection.sh +++ b/tests/test_selection.sh @@ -23,7 +23,8 @@ test_run pdbg -b fake probe test_result 0 < X-Patchwork-Id: 1171057 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46kKYt5SwRz9sP7 for ; Thu, 3 Oct 2019 14:20:50 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="PuBqJNZH"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46kKYt34FKzDqXC for ; Thu, 3 Oct 2019 14:20:50 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46kKX54BsmzDqWm for ; Thu, 3 Oct 2019 14:19:17 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="PuBqJNZH"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 46kKX522Plz9sP7; Thu, 3 Oct 2019 14:19:17 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1570076357; bh=qI4EI7zAkVgAW4J0Ohon1AqsuT6fNU+Nkk/uXGzm8Wc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PuBqJNZHos6kpg4Lz7+yVyEaPgIAf2Wf84tNqZFIoR9slUT1mwEg+ldH9+L1IIvDB 2XLNde42UppMcOiqa9FvgphwM/Apy6CqcbkM7rMqnzD56a2KwS6Iuna4ugJwQGbsfv QJCvK0OH2LbgNUvAA4bBQTm+bGEhw3EoKd/Kmk6e6EpeYHhgthFj4KbpXpKQPjdFX4 MwaP5BJCqkDhA6+GH2iOr5MEBBXNGd9k9kyZ8L8GbEnu4TERwLzkQXDMr3oCrMYPGm HodFzrvWabD+dH/BGpQj61piS3kMlTaoDE6cCVXR5mdSZGCMRXbo4vXOR9P/9snqPZ w34tSQ67mj+gA== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 3 Oct 2019 14:18:59 +1000 Message-Id: <20191003041909.23187-21-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191003041909.23187-1-amitay@ozlabs.org> References: <20191003041909.23187-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v4 20/30] fake: Add additional device tree for testing X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- Makefile.am | 3 +- fake2.dts.m4 | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 fake2.dts.m4 diff --git a/Makefile.am b/Makefile.am index f2c3335..9b9e04e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -35,6 +35,7 @@ AM_CFLAGS = -I$(top_srcdir)/ccan/array_size -Wall -Werror -O2 EXTRA_DIST = \ fake.dts.m4 \ + fake2.dts.m4 \ p8-fsi.dts.m4 \ p8-host.dts.m4 \ p8-i2c.dts.m4 \ @@ -63,7 +64,7 @@ if TARGET_PPC ARCH_FLAGS="-DTARGET_PPC=1" endif -DT = fake.dts p8-cronus.dts p9-cronus.dts \ +DT = fake.dts fake2.dts p8-cronus.dts p9-cronus.dts \ p8-fsi.dts p8-i2c.dts p8-kernel.dts \ p9w-fsi.dts p9r-fsi.dts p9z-fsi.dts p9-kernel.dts \ p8-host.dts p9-host.dts diff --git a/fake2.dts.m4 b/fake2.dts.m4 new file mode 100644 index 0000000..8c7b21a --- /dev/null +++ b/fake2.dts.m4 @@ -0,0 +1,108 @@ +define(`CONCAT', `$1$2')dnl + +dnl +dnl forloop([var], [start], [end], [iterator]) +dnl +divert(`-1') +define(`forloop', `pushdef(`$1', `$2')_forloop($@)popdef(`$1')') +define(`_forloop', + `$4`'ifelse($1, `$3', `', `define(`$1', incr($1))$0($@)')') + +dnl +dnl dump_thread([index]) +dnl +define(`dump_thread', +` + thread@$1 { + #address-cells = <0x0>; + #size-cells = <0x0>; + compatible = "ibm,fake-thread"; + reg = <0x$1 0x0>; + index = <0x$1>; + }; +')dnl + +dnl +dnl dump_core_pre([index], [addr]) +dnl +define(`dump_core_pre', +` + core@$2 { + #address-cells = <0x1>; + #size-cells = <0x1>; + compatible = "ibm,fake-core"; + reg = <0x$2 0x0>; + index = <0x$1>;') + +dnl +dnl dump_core_post() +dnl +define(`dump_core_post', ` }; +')dnl + +dnl +dnl dump_core([index], [addr], [num_threads]) +dnl +define(`dump_core', +`dump_core_pre(`$1', `$2') +forloop(`i', `0', eval(`$3-1'), `dump_thread(i)') +dump_core_post()') + +dnl +dnl dump_processor_pre([index], [addr]) +dnl +define(`dump_processor_pre', +`define(`pib_addr', eval(`$2+100'))dnl + fsi@$2 { + #address-cells = <0x1>; + #size-cells = <0x1>; + compatible = "ibm,fake-fsi"; + system-path = "/proc$1/fsi"; + reg = <0x0 0x0>; + index = <0x$1>; + + CONCAT(pib@,pib_addr) { + #address-cells = <0x1>; + #size-cells = <0x1>; + compatible = "ibm,fake-pib"; + system-path = "/proc$1/pib"; + reg = ; + index = <0x$1>;') + +dnl +dnl dump_processor_post() +dnl +define(`dump_processor_post', ` }; + + }; + +')dnl + +dnl +dnl dump_processor([index], [addr], [num_cores], [num_threads]) +dnl +define(`dump_processor',dnl +`dump_processor_pre(`$1', `$2') +forloop(`i', `0', eval(`$3-1'), `dump_core(i, eval(10000+(i+1)*10), $4)') +dump_processor_post()') + +dnl +dnl dump_system([num_processors], [num_cores], [num_threads]) +dnl +define(`dump_system', +`forloop(`i', `0', eval(`$1-1'),dnl +` + CONCAT(proc,i) { + index = < CONCAT(0x,i) >; + }; +') +forloop(`i', `0', eval(`$1-1'), `dump_processor(i, eval(20000+i*1000), $2, $3)')') +divert`'dnl + +/dts-v1/; + +/ { + #address-cells = <0x1>; + #size-cells = <0x1>; +dump_system(8, 4, 2) +}; From patchwork Thu Oct 3 04:19:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1171058 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46kKYz0fwkz9sPJ for ; Thu, 3 Oct 2019 14:20:55 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="h2qy7NGT"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46kKYy5rctzDqWn for ; Thu, 3 Oct 2019 14:20:54 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46kKX55rkfzDqWn for ; Thu, 3 Oct 2019 14:19:17 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="h2qy7NGT"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 46kKX53xJCz9s7T; Thu, 3 Oct 2019 14:19:17 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1570076357; bh=mV+YLhiXX0lGTfRc6K6LVTp0+ujPDLl3j2OrEBD+Unk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h2qy7NGTp19MEJcNOPcFqN51P+lcrkQUwMU7gzf3xH5dDyEt5uK8mOgaWluVkRjgU F7cIvc8HCWKu7f1ZjWfWED7tJSU48Tv+LYaWjTBHdNPhT3ZnLSyJMbaXLDuPUhkp9E Vb2IL9+KpzJhjlY2LcuDF/Ms0A93qNSW25X6qPT8MwP/V8OfkkN9iNpivYoEEy9D7+ e9ZKkBBfGxMo8Z7cU8aWUB/i4XXTgRdHAtL7V4fizSDD3ppk1oM0ygq6P6qNOiJVjc sAzPGCvP38fz0YzYHCtFo94hhoGmstHiHaHLeopSye1BadqIEAiqFxvrsEtBzsgpsP j7Sobkf7whu5A== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 3 Oct 2019 14:19:00 +1000 Message-Id: <20191003041909.23187-22-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191003041909.23187-1-amitay@ozlabs.org> References: <20191003041909.23187-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v4 21/30] tests: Add device tree traversal tests X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" This test checks system device tree (view) traverse and backend device tree traverse. Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- Makefile.am | 14 +- src/tests/libpdbg_dtree_test.c | 117 ++++++++++ tests/test_tree.sh | 387 ++++++++++++++++++++++++++++++++ tests/test_tree2.sh | 389 +++++++++++++++++++++++++++++++++ 4 files changed, 905 insertions(+), 2 deletions(-) create mode 100644 src/tests/libpdbg_dtree_test.c create mode 100755 tests/test_tree.sh create mode 100755 tests/test_tree2.sh diff --git a/Makefile.am b/Makefile.am index 9b9e04e..69a21de 100644 --- a/Makefile.am +++ b/Makefile.am @@ -15,16 +15,21 @@ libpdbg_tests = libpdbg_target_test \ libpdbg_probe_test3 bin_PROGRAMS = pdbg -check_PROGRAMS = $(libpdbg_tests) optcmd_test hexdump_test cronus_proxy +check_PROGRAMS = $(libpdbg_tests) libpdbg_dtree_test \ + optcmd_test hexdump_test cronus_proxy PDBG_TESTS = \ tests/test_selection.sh \ tests/test_selection2.sh \ tests/test_hw_bmc.sh \ - tests/test_hexdump.sh + tests/test_hexdump.sh \ + tests/test_tree.sh \ + tests/test_tree2.sh TESTS = $(libpdbg_tests) optcmd_test $(PDBG_TESTS) +tests/test_tree2.sh: fake2.dtb + test: $(libpdbg_tests) TEST_EXTENSIONS = .sh @@ -246,6 +251,11 @@ libpdbg_probe_test3_LDADD = $(libpdbg_test_ldadd) src/tests/libpdbg_probe_test.c: fake.dt.h +libpdbg_dtree_test_SOURCES = src/tests/libpdbg_dtree_test.c +libpdbg_dtree_test_CFLAGS = $(libpdbg_test_cflags) +libpdbg_dtree_test_LDFLAGS = $(libpdbg_test_ldflags) +libpdbg_dtree_test_LDADD = $(libpdbg_test_ldadd) + M4_V = $(M4_V_$(V)) M4_V_ = $(M4_V_$(AM_DEFAULT_VERBOSITY)) M4_V_0 = @echo " M4 " $@; diff --git a/src/tests/libpdbg_dtree_test.c b/src/tests/libpdbg_dtree_test.c new file mode 100644 index 0000000..f6d4cbf --- /dev/null +++ b/src/tests/libpdbg_dtree_test.c @@ -0,0 +1,117 @@ +/* Copyright 2019 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include + +#include + +extern struct pdbg_target *get_parent(struct pdbg_target *target, bool system); + +#define for_each_child(parent, target, system) \ + for (target = __pdbg_next_child_target(parent, NULL, system); \ + target; \ + target = __pdbg_next_child_target(parent, target, system)) + +static void print_tree(struct pdbg_target *target, bool system, int level) +{ + struct pdbg_target *child; + const char *name; + char *path; + int i; + + for (i=0; i\n"); + exit(1); +} + +int main(int argc, const char **argv) +{ + struct pdbg_target *target; + bool do_system; + bool do_tree; + + if (argc != 4) + usage(); + + if (strcmp(argv[1], "tree") == 0) { + do_tree = true; + } else if (strcmp(argv[1], "rtree") == 0) { + do_tree = false; + } else { + usage(); + } + + if (strcmp(argv[2], "system") == 0) { + do_system = true; + } else if (strcmp(argv[2], "backend") == 0) { + do_system = false; + } else { + usage(); + } + + pdbg_targets_init(NULL); + + target = pdbg_target_from_path(NULL, argv[3]); + if (!target) + exit(1); + + if (do_tree) { + print_tree(target, do_system, 0); + } else { + print_rtree(target, do_system, 0); + } + + return 0; +} diff --git a/tests/test_tree.sh b/tests/test_tree.sh new file mode 100755 index 0000000..8b64146 --- /dev/null +++ b/tests/test_tree.sh @@ -0,0 +1,387 @@ +#!/bin/sh + +. $(dirname "$0")/driver.sh + +test_group "tree tests for fake.dts" + +test_result 0 < X-Patchwork-Id: 1171059 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46kKZ24vqKz9sPJ for ; Thu, 3 Oct 2019 14:20:58 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="nnis2IeZ"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46kKZ20QNPzDqXN for ; Thu, 3 Oct 2019 14:20:58 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46kKX60gYpzDqWq for ; Thu, 3 Oct 2019 14:19:18 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="nnis2IeZ"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 46kKX55bPWz9sDB; Thu, 3 Oct 2019 14:19:17 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1570076357; bh=F/+U7kJZ91MV0heRqgmYmyD0dCf3HoY4dklfbtL18o4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nnis2IeZzYvrf9hyqdWIuJ6vijIJ08dLtIUpbEwYtc8s40pWB507XHz/P6+lu1umz sBG4jaM9Wb/H/Jm7nef+902dTsw1zoDyxVoMDGElD0U/5XZABB98D0P4bwPW0tLFLC 5uvnGwPfr4cXyShFas/V3ORxfcgqfQ7nNJIZDssHJV5ZQ297YLw/vLQHpjAfHHqP4x 5uwNYt1+dhJWEfvdrQOY3gAMwSfslPX1WpuFurN4toy4lXUk2e8EP8mKxXASfqWDJo cYZd5E3KRnZqS09GctA/Ua++gDkZVdXlT3mGXEJGiTlbGZo/pGl+t13SS0FdGnb/Uo xW7KOjuYIGIyw== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 3 Oct 2019 14:19:01 +1000 Message-Id: <20191003041909.23187-23-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191003041909.23187-1-amitay@ozlabs.org> References: <20191003041909.23187-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v4 22/30] libpdbg: Pass root node to dt_expand X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" This will enable parsing more than one device tree. Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- libpdbg/device.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libpdbg/device.c b/libpdbg/device.c index d7cd980..3ed113c 100644 --- a/libpdbg/device.c +++ b/libpdbg/device.c @@ -604,7 +604,7 @@ static int dt_expand_node(struct pdbg_target *node, const void *fdt, int fdt_nod return nextoffset; } -static void dt_expand(void *root, const void *fdt) +static void dt_expand(struct pdbg_target *root, const void *fdt) { PR_DEBUG("FDT: Parsing fdt @%p\n", fdt); @@ -749,9 +749,6 @@ skip: void pdbg_targets_init(void *fdt) { - /* Root node needs to be valid when this function returns */ - pdbg_dt_root = dt_new_node("", NULL, 0); - if (!fdt) fdt = pdbg_default_dtb(); @@ -760,7 +757,12 @@ void pdbg_targets_init(void *fdt) return; } + /* Root node needs to be valid when this function returns */ + pdbg_dt_root = dt_new_node("", NULL, 0); + assert(pdbg_dt_root); + dt_expand(pdbg_dt_root, fdt); + pdbg_targets_init_virtual(pdbg_dt_root, pdbg_dt_root); } From patchwork Thu Oct 3 04:19:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1171060 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46kKZ46FMhz9sPJ for ; Thu, 3 Oct 2019 14:21:00 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="RVYmhn8B"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46kKZ45KfhzDqX1 for ; Thu, 3 Oct 2019 14:21:00 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46kKX62PgszDqWm for ; Thu, 3 Oct 2019 14:19:18 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="RVYmhn8B"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 46kKX60LWgz9sPJ; Thu, 3 Oct 2019 14:19:18 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1570076358; bh=1z9/O1kGH7bJIo5dXnxU5S62kMGqCKUSR61a05Z9vac=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RVYmhn8BhBTqcqgynCp2uE7zdX6ENc15F39crLL7/I2vEd7unVunKDOxZQYmaEigx hAqDx6oF/mtPD01Hhfs3y2cenB8jWfzGLeWjmr099WLSprNTe0hLcJXAB448mbXiR0 LMPdzK6AXUYKmugxlZ5SNO//m82MnhjDMJRM+xLnz0ocSh0yDelACKtHJZtgXeQVzb inXSyJOC+D+GaZAFDRdO7aKi6V6rN+5GCdldse0n25UU0+L+D3xiIiMl9ANmk/hKLM vgidSKv65na33d6ghwug3NQJL+JSM4rZ+Bn4ec6biwHc/mpFysqQb+Y6CDRw0h9F9G wg3uMi11qfuGw== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 3 Oct 2019 14:19:02 +1000 Message-Id: <20191003041909.23187-24-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191003041909.23187-1-amitay@ozlabs.org> References: <20191003041909.23187-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v4 23/30] libpdbg: Return status from pdbg_targets_init() X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- libpdbg/device.c | 8 +++++--- libpdbg/libpdbg.h | 2 +- src/main.c | 3 ++- src/tests/libpdbg_dtree_test.c | 2 +- src/tests/libpdbg_probe_test.c | 6 +++--- src/tests/libpdbg_target_test.c | 2 +- 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/libpdbg/device.c b/libpdbg/device.c index 3ed113c..cb25c82 100644 --- a/libpdbg/device.c +++ b/libpdbg/device.c @@ -747,23 +747,25 @@ skip: } } -void pdbg_targets_init(void *fdt) +bool pdbg_targets_init(void *fdt) { if (!fdt) fdt = pdbg_default_dtb(); if (!fdt) { pdbg_log(PDBG_ERROR, "Could not find a system device tree\n"); - return; + return false; } /* Root node needs to be valid when this function returns */ pdbg_dt_root = dt_new_node("", NULL, 0); - assert(pdbg_dt_root); + if (!pdbg_dt_root) + return false; dt_expand(pdbg_dt_root, fdt); pdbg_targets_init_virtual(pdbg_dt_root, pdbg_dt_root); + return true; } char *pdbg_target_path(struct pdbg_target *target) diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h index ca4f951..14c07e4 100644 --- a/libpdbg/libpdbg.h +++ b/libpdbg/libpdbg.h @@ -101,7 +101,7 @@ uint64_t pdbg_target_address(struct pdbg_target *target, uint64_t *size); (index == 0 ? pdbg_target_address(target, size) : assert(0)) /* Misc. */ -void pdbg_targets_init(void *fdt); +bool pdbg_targets_init(void *fdt); void pdbg_target_probe_all(struct pdbg_target *parent); enum pdbg_target_status pdbg_target_probe(struct pdbg_target *target); void pdbg_target_release(struct pdbg_target *target); diff --git a/src/main.c b/src/main.c index 09c236e..d73a1b7 100644 --- a/src/main.c +++ b/src/main.c @@ -598,7 +598,8 @@ int main(int argc, char *argv[]) if (backend) pdbg_set_backend(backend, device_node); - pdbg_targets_init(NULL); + if (!pdbg_targets_init(NULL)) + return 1; if (pathsel_count) { if (!path_target_parse(pathsel, pathsel_count)) diff --git a/src/tests/libpdbg_dtree_test.c b/src/tests/libpdbg_dtree_test.c index f6d4cbf..d3c4a89 100644 --- a/src/tests/libpdbg_dtree_test.c +++ b/src/tests/libpdbg_dtree_test.c @@ -101,7 +101,7 @@ int main(int argc, const char **argv) usage(); } - pdbg_targets_init(NULL); + assert(pdbg_targets_init(NULL)); target = pdbg_target_from_path(NULL, argv[3]); if (!target) diff --git a/src/tests/libpdbg_probe_test.c b/src/tests/libpdbg_probe_test.c index ed8a800..fba7a23 100644 --- a/src/tests/libpdbg_probe_test.c +++ b/src/tests/libpdbg_probe_test.c @@ -74,7 +74,7 @@ static void test1(void) struct pdbg_target *root, *target; pdbg_set_backend(PDBG_BACKEND_FAKE, NULL); - pdbg_targets_init(NULL); + assert(pdbg_targets_init(NULL)); root = pdbg_target_root(); assert(root); @@ -122,7 +122,7 @@ static void test2(void) enum pdbg_target_status status; pdbg_set_backend(PDBG_BACKEND_FAKE, NULL); - pdbg_targets_init(NULL); + assert(pdbg_targets_init(NULL)); root = pdbg_target_root(); assert(root); @@ -199,7 +199,7 @@ static void test3(void) enum pdbg_target_status status; pdbg_set_backend(PDBG_BACKEND_FAKE, NULL); - pdbg_targets_init(NULL); + assert(pdbg_targets_init(NULL)); root = pdbg_target_root(); assert(root); diff --git a/src/tests/libpdbg_target_test.c b/src/tests/libpdbg_target_test.c index 9806281..c68590f 100644 --- a/src/tests/libpdbg_target_test.c +++ b/src/tests/libpdbg_target_test.c @@ -66,7 +66,7 @@ int main(void) int count, i; pdbg_set_backend(PDBG_BACKEND_FAKE, NULL); - pdbg_targets_init(NULL); + assert(pdbg_targets_init(NULL)); root = pdbg_target_root(); assert(root); From patchwork Thu Oct 3 04:19:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1171061 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46kKZ9033pz9sP7 for ; Thu, 3 Oct 2019 14:21:04 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="k3UFWsIL"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46kKZ84DfkzDqWs for ; Thu, 3 Oct 2019 14:21:04 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46kKX63tZGzDqWn for ; Thu, 3 Oct 2019 14:19:18 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="k3UFWsIL"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 46kKX626YTz9s7T; Thu, 3 Oct 2019 14:19:18 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1570076358; bh=ozZw8jTt1nYGYERBSteswATcBLxBl2jshGT3xwAaXiQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k3UFWsIL+Nb2DeVMgMlimDIh4jRwVyeMAn1y+noHDf4mlB5/ERzzroCw3PBxV4MnE 2Xl6W7+MpI8oNMrRsudEtiEqO3M9GV3u7ZNNcndreAnURcge22KsumwQUSYUUBu+QX /gnjiKyNvCPNon4JqTHdaI9jwsgVV5TKwFcDK8OVvqhi+lh3JfFVGlJpSysw45VafO fducprpPxDGk0scIkGGqcAZh7MaYIFyx9Y/MqhfMge8N41oq9bp2yakriqVG7YyLBX cJXQ/hW//t7GaZcgFFFiLJP7VgpkRd80cn6SRt8oUD6+GTpsHrBm0Z3BbqjOflyOrB od+X4gjkDWmqg== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 3 Oct 2019 14:19:03 +1000 Message-Id: <20191003041909.23187-25-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191003041909.23187-1-amitay@ozlabs.org> References: <20191003041909.23187-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v4 24/30] libpdbg: Make pdbg_set_backend() return boolean X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Simplify api by using boolean status instead of int. Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- libpdbg/dtb.c | 9 +++++++-- libpdbg/libpdbg.h | 2 +- src/main.c | 3 ++- src/tests/libpdbg_probe_test.c | 6 +++--- src/tests/libpdbg_target_test.c | 2 +- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/libpdbg/dtb.c b/libpdbg/dtb.c index 53e9b73..1f70d1c 100644 --- a/libpdbg/dtb.c +++ b/libpdbg/dtb.c @@ -214,12 +214,17 @@ fail: return NULL; } -int pdbg_set_backend(enum pdbg_backend backend, const char *backend_option) +bool pdbg_set_backend(enum pdbg_backend backend, const char *backend_option) { + if (pdbg_target_root()) { + pdbg_log(PDBG_ERROR, "pdbg_set_backend() must be called before pdbg_targets_init()\n"); + return false; + } + pdbg_backend = backend; pdbg_backend_option = backend_option; - return 0; + return true; } const char *pdbg_get_backend_option(void) diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h index 14c07e4..3e4d03b 100644 --- a/libpdbg/libpdbg.h +++ b/libpdbg/libpdbg.h @@ -107,7 +107,7 @@ enum pdbg_target_status pdbg_target_probe(struct pdbg_target *target); void pdbg_target_release(struct pdbg_target *target); enum pdbg_target_status pdbg_target_status(struct pdbg_target *target); void pdbg_target_status_set(struct pdbg_target *target, enum pdbg_target_status status); -int pdbg_set_backend(enum pdbg_backend backend, const char *backend_option); +bool pdbg_set_backend(enum pdbg_backend backend, const char *backend_option); void *pdbg_default_dtb(void); uint32_t pdbg_target_index(struct pdbg_target *target); char *pdbg_target_path(struct pdbg_target *target); diff --git a/src/main.c b/src/main.c index d73a1b7..81af977 100644 --- a/src/main.c +++ b/src/main.c @@ -596,7 +596,8 @@ int main(int argc, char *argv[]) } if (backend) - pdbg_set_backend(backend, device_node); + if (!pdbg_set_backend(backend, device_node)) + return 1; if (!pdbg_targets_init(NULL)) return 1; diff --git a/src/tests/libpdbg_probe_test.c b/src/tests/libpdbg_probe_test.c index fba7a23..c76f77f 100644 --- a/src/tests/libpdbg_probe_test.c +++ b/src/tests/libpdbg_probe_test.c @@ -73,7 +73,7 @@ static void test1(void) { struct pdbg_target *root, *target; - pdbg_set_backend(PDBG_BACKEND_FAKE, NULL); + assert(pdbg_set_backend(PDBG_BACKEND_FAKE, NULL)); assert(pdbg_targets_init(NULL)); root = pdbg_target_root(); @@ -121,7 +121,7 @@ static void test2(void) struct pdbg_target *root, *target; enum pdbg_target_status status; - pdbg_set_backend(PDBG_BACKEND_FAKE, NULL); + assert(pdbg_set_backend(PDBG_BACKEND_FAKE, NULL)); assert(pdbg_targets_init(NULL)); root = pdbg_target_root(); @@ -198,7 +198,7 @@ static void test3(void) struct pdbg_target *root, *target; enum pdbg_target_status status; - pdbg_set_backend(PDBG_BACKEND_FAKE, NULL); + assert(pdbg_set_backend(PDBG_BACKEND_FAKE, NULL)); assert(pdbg_targets_init(NULL)); root = pdbg_target_root(); diff --git a/src/tests/libpdbg_target_test.c b/src/tests/libpdbg_target_test.c index c68590f..36e6891 100644 --- a/src/tests/libpdbg_target_test.c +++ b/src/tests/libpdbg_target_test.c @@ -65,7 +65,7 @@ int main(void) const char *name; int count, i; - pdbg_set_backend(PDBG_BACKEND_FAKE, NULL); + assert(pdbg_set_backend(PDBG_BACKEND_FAKE, NULL)); assert(pdbg_targets_init(NULL)); root = pdbg_target_root(); From patchwork Thu Oct 3 04:19:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1171062 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46kKZC6BKtz9sPJ for ; Thu, 3 Oct 2019 14:21:07 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="LxTiaf4M"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46kKZC55jDzDqXK for ; Thu, 3 Oct 2019 14:21:07 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46kKX718S9zDqWm for ; Thu, 3 Oct 2019 14:19:19 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="LxTiaf4M"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 46kKX65Czwz9sP7; Thu, 3 Oct 2019 14:19:18 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1570076358; bh=6B17It2URfmo5uSK3wOuuVq7SDDNz8IjKfz+tB0b/Lk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LxTiaf4MlbM297kLnYhR3qto/Jku6/LenxA6jiOAuCkfg1pDph2nDEWMe0hTb1YeK vkCkDdaD1OsDejkrfH+pkRbd6WiLZgyxj/T2Sx8T5a2etmOIzqncvtau7LeypxN3Ua v0PV7IfYS0R6a5joVm/pm0FVLDhH0UQUmn0w9VHWRmD8enuUq5wwtBgAZ2cQa9eCQt fckVbBlGFffmKvpof9F5UK187u/tpK/qFFZcyr1hLca8vyHGfpmMV9lxfR6S0wRtWK FVNsy+e3aGktVVXrYcZYRAO4fQCVWee260fgBsxH5c5mp5Aw0rMf8vxizvIFHdbpEu pAmOJIJo0bJGg== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 3 Oct 2019 14:19:04 +1000 Message-Id: <20191003041909.23187-26-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191003041909.23187-1-amitay@ozlabs.org> References: <20191003041909.23187-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v4 25/30] libpdbg: Do not make pdbg_default_dtb public X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Applications should never need to know the default fdt to be used. For some reason applications need to get access to the fdt blob, we can add appropriate public api. Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- libpdbg/dtb.c | 1 + libpdbg/libpdbg.h | 1 - libpdbg/target.h | 1 + 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/libpdbg/dtb.c b/libpdbg/dtb.c index 1f70d1c..e19ce95 100644 --- a/libpdbg/dtb.c +++ b/libpdbg/dtb.c @@ -28,6 +28,7 @@ #include #include "libpdbg.h" +#include "target.h" #include "fake.dt.h" diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h index 3e4d03b..9cef3b7 100644 --- a/libpdbg/libpdbg.h +++ b/libpdbg/libpdbg.h @@ -108,7 +108,6 @@ void pdbg_target_release(struct pdbg_target *target); enum pdbg_target_status pdbg_target_status(struct pdbg_target *target); void pdbg_target_status_set(struct pdbg_target *target, enum pdbg_target_status status); bool pdbg_set_backend(enum pdbg_backend backend, const char *backend_option); -void *pdbg_default_dtb(void); uint32_t pdbg_target_index(struct pdbg_target *target); char *pdbg_target_path(struct pdbg_target *target); struct pdbg_target *pdbg_target_from_path(struct pdbg_target *target, const char *path); diff --git a/libpdbg/target.h b/libpdbg/target.h index df4f3f8..0422406 100644 --- a/libpdbg/target.h +++ b/libpdbg/target.h @@ -64,6 +64,7 @@ bool pdbg_target_is_class(struct pdbg_target *target, const char *class); extern struct list_head empty_list; extern struct list_head target_classes; +void *pdbg_default_dtb(void); const char *pdbg_get_backend_option(void); struct sbefifo *pib_to_sbefifo(struct pdbg_target *target); From patchwork Thu Oct 3 04:19:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1171063 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46kKZG457Bz9sPJ for ; Thu, 3 Oct 2019 14:21:10 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="wiiYiUxv"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46kKZG2BV9zDqWm for ; Thu, 3 Oct 2019 14:21:10 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46kKX733ZjzDqWn for ; Thu, 3 Oct 2019 14:19:19 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="wiiYiUxv"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 46kKX70hDjz9sDB; Thu, 3 Oct 2019 14:19:19 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1570076359; bh=rvyBvBRi3iPsJXTLnEF06Es8kW9L0silSpmHtMa2eNc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wiiYiUxvJxP/OxHqwHanunD9cJn54iQb7i0nqURlIp8/1cRVOpcaN85NocUapQgnH yvYyjd5MdeyHRNvkvxDIF+AnMKQpewYKaC1Jb0sMe9f3Pteu19k9ZV/ONfHc3FwVLA lk1q+fdIlp5ck3mo+mhBUXV/6aBkDFhM69Rq+vBz/CM0eQwRjp89c2XHIX4LrEexvs QEWii0UZ+d6yzE+tt++sDrcC2tSDHuxVrjyOteBIbDCJiJ9eo1F+5lIjG1HbkLig9Q xFB9AiBSwiufOZ9ThD9ULPlG2KQ4lwBk/15EDfQ2XIM4mvjXa3Y9HoTVc+Ru22fgxg CzPyRu1PB8o+A== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 3 Oct 2019 14:19:05 +1000 Message-Id: <20191003041909.23187-27-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191003041909.23187-1-amitay@ozlabs.org> References: <20191003041909.23187-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v4 26/30] libpdbg: Add a structure to hold fdt pointer X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" This enables adding a separate backend device tree later. Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- libpdbg/device.c | 10 +++++-- libpdbg/dtb.c | 75 ++++++++++++++++++++++++++---------------------- libpdbg/target.h | 6 +++- 3 files changed, 53 insertions(+), 38 deletions(-) diff --git a/libpdbg/device.c b/libpdbg/device.c index cb25c82..452e288 100644 --- a/libpdbg/device.c +++ b/libpdbg/device.c @@ -749,10 +749,14 @@ skip: bool pdbg_targets_init(void *fdt) { + struct pdbg_dtb dtb = { .system = NULL, }; + if (!fdt) - fdt = pdbg_default_dtb(); + pdbg_default_dtb(&dtb); + else + dtb.system = fdt; - if (!fdt) { + if (!dtb.system) { pdbg_log(PDBG_ERROR, "Could not find a system device tree\n"); return false; } @@ -762,7 +766,7 @@ bool pdbg_targets_init(void *fdt) if (!pdbg_dt_root) return false; - dt_expand(pdbg_dt_root, fdt); + dt_expand(pdbg_dt_root, dtb.system); pdbg_targets_init_virtual(pdbg_dt_root, pdbg_dt_root); return true; diff --git a/libpdbg/dtb.c b/libpdbg/dtb.c index e19ce95..3d0f9b4 100644 --- a/libpdbg/dtb.c +++ b/libpdbg/dtb.c @@ -78,20 +78,23 @@ static enum pdbg_backend default_backend(void) /* Try and determine what system type we are on by reading * /proc/cpuinfo */ -static void *ppc_target(void) +static void ppc_target(struct pdbg_dtb *dtb) { const char *pos = NULL; char line[256]; FILE *cpuinfo; - if (!strcmp(pdbg_backend_option, "p8")) - return &_binary_p8_host_dtb_o_start; - else if (!strcmp(pdbg_backend_option, "p9")) - return &_binary_p9_host_dtb_o_start; + if (!strcmp(pdbg_backend_option, "p8")) { + dtb->system = &_binary_p8_host_dtb_o_start; + return; + } else if (!strcmp(pdbg_backend_option, "p9")) { + dtb->system = &_binary_p9_host_dtb_o_start; + return; + } cpuinfo = fopen("/proc/cpuinfo", "r"); if (!cpuinfo) - return NULL; + return; while ((pos = fgets(line, sizeof(line), cpuinfo))) if (strncmp(line, "cpu", 3) == 0) @@ -101,32 +104,31 @@ static void *ppc_target(void) if (!pos) { /* Got to EOF without a break */ pdbg_log(PDBG_ERROR, "Unable to parse /proc/cpuinfo\n"); - return NULL; + return; } pos = strchr(line, ':'); if (!pos || (*(pos + 1) == '\0')) { pdbg_log(PDBG_ERROR, "Unable to parse /proc/cpuinfo\n"); - return NULL; + return; } pos += 2; if (strncmp(pos, "POWER8", 6) == 0) { pdbg_log(PDBG_INFO, "Found a POWER8 PPC host system\n"); - return &_binary_p8_host_dtb_o_start; + dtb->system = &_binary_p8_host_dtb_o_start; } if (strncmp(pos, "POWER9", 6) == 0) { pdbg_log(PDBG_INFO, "Found a POWER9 PPC host system\n"); - return &_binary_p9_host_dtb_o_start; + dtb->system = &_binary_p9_host_dtb_o_start; } pdbg_log(PDBG_ERROR, "Unsupported CPU type '%s'\n", pos); - return NULL; } -static void *bmc_target(void) +static void bmc_target(struct pdbg_dtb *dtb) { FILE *cfam_id_file; uint32_t cfam_id = 0; @@ -147,7 +149,7 @@ static void *bmc_target(void) free(path); if (!cfam_id_file) { pdbg_log(PDBG_ERROR, "Unabled to open CFAM ID file\n"); - return NULL; + return; } rc = fscanf(cfam_id_file, "0x%" PRIx32, &cfam_id); @@ -169,18 +171,17 @@ static void *bmc_target(void) switch(chip_id) { case CHIP_ID_P9: pdbg_log(PDBG_INFO, "Found a POWER9 OpenBMC based system\n"); - return &_binary_p9_kernel_dtb_o_start; + dtb->system = &_binary_p9_kernel_dtb_o_start; break; case CHIP_ID_P8: case CHIP_ID_P8P: pdbg_log(PDBG_INFO, "Found a POWER8/8+ OpenBMC based system\n"); - return &_binary_p8_kernel_dtb_o_start; + dtb->system = &_binary_p8_kernel_dtb_o_start; break; default: pdbg_log(PDBG_ERROR, "Unrecognised Chip ID register 0x%08" PRIx32 "\n", chip_id); - return NULL; } } @@ -235,50 +236,56 @@ const char *pdbg_get_backend_option(void) /* Determines what platform we are running on and returns a pointer to * the fdt that is most likely to work on the system. */ -void *pdbg_default_dtb(void) +void pdbg_default_dtb(struct pdbg_dtb *dtb) { - char *dtb = getenv("PDBG_DTB"); + char *fdt = getenv("PDBG_DTB"); - if (dtb) - return mmap_dtb(dtb); + *dtb = (struct pdbg_dtb) { + .system = NULL, + }; + + if (fdt) { + dtb->system = mmap_dtb(fdt); + return; + } if (!pdbg_backend) pdbg_backend = default_backend(); switch(pdbg_backend) { case PDBG_BACKEND_HOST: - return ppc_target(); + ppc_target(dtb); break; case PDBG_BACKEND_I2C: /* I2C is only supported on POWER8 */ pdbg_log(PDBG_INFO, "Found a POWER8 AMI BMC based system\n"); - return &_binary_p8_i2c_dtb_o_start; + dtb->system = &_binary_p8_i2c_dtb_o_start; break; case PDBG_BACKEND_KERNEL: - return bmc_target(); + bmc_target(dtb); break; case PDBG_BACKEND_FSI: if (!pdbg_backend_option) { pdbg_log(PDBG_ERROR, "No device type specified\n"); pdbg_log(PDBG_ERROR, "Use 'p8' or 'p9r/p9w/p9z'\n"); - return NULL; + return; } if (!strcmp(pdbg_backend_option, "p8")) - return &_binary_p8_fsi_dtb_o_start; + dtb->system = &_binary_p8_fsi_dtb_o_start; else if (!strcmp(pdbg_backend_option, "p9w")) - return &_binary_p9w_fsi_dtb_o_start; + dtb->system = &_binary_p9w_fsi_dtb_o_start; else if (!strcmp(pdbg_backend_option, "p9r")) - return &_binary_p9r_fsi_dtb_o_start; + dtb->system = &_binary_p9r_fsi_dtb_o_start; else if (!strcmp(pdbg_backend_option, "p9z")) - return &_binary_p9z_fsi_dtb_o_start; + dtb->system = &_binary_p9z_fsi_dtb_o_start; else { pdbg_log(PDBG_ERROR, "Invalid device type specified\n"); pdbg_log(PDBG_ERROR, "Use 'p8' or 'p9r/p9w/p9z'\n"); - return NULL; + return; } break; @@ -287,17 +294,17 @@ void *pdbg_default_dtb(void) if (!pdbg_backend_option) { pdbg_log(PDBG_ERROR, "No device type specified\n"); pdbg_log(PDBG_ERROR, "Use p8@ or p9@\n"); - return NULL; + return; } if (!strncmp(pdbg_backend_option, "p8", 2)) - return &_binary_p8_cronus_dtb_o_start; + dtb->system = &_binary_p8_cronus_dtb_o_start; else if (!strncmp(pdbg_backend_option, "p9", 2)) - return &_binary_p9_cronus_dtb_o_start; + dtb->system = &_binary_p9_cronus_dtb_o_start; else { pdbg_log(PDBG_ERROR, "Invalid device type specified\n"); pdbg_log(PDBG_ERROR, "Use p8@ or p9@\n"); - return NULL; + return; } break; @@ -307,7 +314,7 @@ void *pdbg_default_dtb(void) /* Fall through */ case PDBG_BACKEND_FAKE: - return &_binary_fake_dtb_o_start; + dtb->system = &_binary_fake_dtb_o_start; break; } } diff --git a/libpdbg/target.h b/libpdbg/target.h index 0422406..4f1721e 100644 --- a/libpdbg/target.h +++ b/libpdbg/target.h @@ -53,6 +53,10 @@ struct pdbg_target { struct pdbg_target *vnode; }; +struct pdbg_dtb { + void *system; +}; + struct pdbg_target *get_parent(struct pdbg_target *target, bool system); struct pdbg_target *target_parent(const char *klass, struct pdbg_target *target, bool system); struct pdbg_target *require_target_parent(const char *klass, struct pdbg_target *target, bool system); @@ -64,7 +68,7 @@ bool pdbg_target_is_class(struct pdbg_target *target, const char *class); extern struct list_head empty_list; extern struct list_head target_classes; -void *pdbg_default_dtb(void); +void pdbg_default_dtb(struct pdbg_dtb *pdtb); const char *pdbg_get_backend_option(void); struct sbefifo *pib_to_sbefifo(struct pdbg_target *target); From patchwork Thu Oct 3 04:19:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1171064 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46kKZL47qmz9sPJ for ; Thu, 3 Oct 2019 14:21:14 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="VWxa+n8o"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46kKZL3F0hzDqXQ for ; Thu, 3 Oct 2019 14:21:14 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46kKX74mK6zDqWm for ; Thu, 3 Oct 2019 14:19:19 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="VWxa+n8o"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 46kKX72fVxz9s7T; Thu, 3 Oct 2019 14:19:19 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1570076359; bh=k94Zkx2hlFxB1JlBdBw4lFe5giHqMfqS7r2hfLYmLxE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VWxa+n8oCQsuzVNWlQnJI1mPoSXZQU7jMb6gfjjM6i2WrnVjYJBboEuxOiZc7qacc jUJ5wAjq4Pjb1WKyAZMibZNfexNYkw271SuVd7uraZGR0iVdCuS7IyYmdwMXuZ5/k+ eJcLtP7rVz2TNUS4vwr7OBNszPcZDmzbkkZ3K2h2WTN2YAVWk8vhqYWOxnuouJZnSy VDjHDD1xmYsLTJSysvn/cIGaxPC18j6hFWTF2nQyv32aQ6Up9TKmgDVEKIewhCWRtS UQd6WUaT6i9qbqtxn65vppktz7LB2jlJESrcnfYNz8L921pZ/4Ca/6gWuisS1hhiTC JEFgucBWtfxZQ== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 3 Oct 2019 14:19:06 +1000 Message-Id: <20191003041909.23187-28-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191003041909.23187-1-amitay@ozlabs.org> References: <20191003041909.23187-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v4 27/30] libpdbg: Add parsing of backend device tree X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- libpdbg/device.c | 3 +++ libpdbg/dtb.c | 1 + libpdbg/target.h | 1 + 3 files changed, 5 insertions(+) diff --git a/libpdbg/device.c b/libpdbg/device.c index 452e288..203cb84 100644 --- a/libpdbg/device.c +++ b/libpdbg/device.c @@ -766,6 +766,9 @@ bool pdbg_targets_init(void *fdt) if (!pdbg_dt_root) return false; + if (dtb.backend) + dt_expand(pdbg_dt_root, dtb.backend); + dt_expand(pdbg_dt_root, dtb.system); pdbg_targets_init_virtual(pdbg_dt_root, pdbg_dt_root); diff --git a/libpdbg/dtb.c b/libpdbg/dtb.c index 3d0f9b4..b85cba2 100644 --- a/libpdbg/dtb.c +++ b/libpdbg/dtb.c @@ -241,6 +241,7 @@ void pdbg_default_dtb(struct pdbg_dtb *dtb) char *fdt = getenv("PDBG_DTB"); *dtb = (struct pdbg_dtb) { + .backend = NULL, .system = NULL, }; diff --git a/libpdbg/target.h b/libpdbg/target.h index 4f1721e..b69ab9b 100644 --- a/libpdbg/target.h +++ b/libpdbg/target.h @@ -54,6 +54,7 @@ struct pdbg_target { }; struct pdbg_dtb { + void *backend; void *system; }; From patchwork Thu Oct 3 04:19:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1171065 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46kKZP4qLJz9sPJ for ; Thu, 3 Oct 2019 14:21:17 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="W5UB+rA7"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46kKZP1hkNzDqXS for ; Thu, 3 Oct 2019 14:21:17 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46kKX80M7FzDqWn for ; Thu, 3 Oct 2019 14:19:20 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="W5UB+rA7"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 46kKX74TGdz9sPJ; Thu, 3 Oct 2019 14:19:19 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1570076359; bh=8/wYbS6x9FKgXfmU0cXQ1Tnm9dVxIuREh+R/9y5AwVg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W5UB+rA71NCavWc1EdHAcaSrLDovWgQQ2xCoWNRaAHLIpTmsgG61VnvqdemJ95nds hONuTqAvSHgxw4jxR5f0xUBLmdjKex/SnwvAeGQMu99DuTgwfGd83zBeJmLJsllVBO 6uRkw/K0SWWVbcc7IN5pwHB/VPgEbpZbS2VShqGQMNtF11sMBcKhCL3ogETUAkbsPA Ta9laKSMsVHpNfDR+gOhk1T4R75UA/YNKEmxWtA48cg1MhEYeS4C/54JgBuHF3K/vY AhRT4dSxN8D7/zW24zX91sKDrxrnvHMW2e+nUrX9LoXMsiFGDBfY2Jolhly3ukVhG3 3qS1mTXv+88MA== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 3 Oct 2019 14:19:07 +1000 Message-Id: <20191003041909.23187-29-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191003041909.23187-1-amitay@ozlabs.org> References: <20191003041909.23187-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v4 28/30] dts: Split P8 device trees into system and backend trees X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- Makefile.am | 2 +- p8-cronus.dts.m4 | 64 +++++++++++++++++------------------------------- p8-fsi.dts.m4 | 9 ++++--- p8-host.dts.m4 | 2 +- p8-i2c.dts.m4 | 8 +++--- p8-kernel.dts.m4 | 7 +++--- p8-pib.dts.m4 | 1 + p8.dts.m4 | 55 +++++++++++++++++++++++++++++++++++++++++ 8 files changed, 96 insertions(+), 52 deletions(-) create mode 100644 p8.dts.m4 diff --git a/Makefile.am b/Makefile.am index 69a21de..5829fb3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -72,7 +72,7 @@ endif DT = fake.dts fake2.dts p8-cronus.dts p9-cronus.dts \ p8-fsi.dts p8-i2c.dts p8-kernel.dts \ p9w-fsi.dts p9r-fsi.dts p9z-fsi.dts p9-kernel.dts \ - p8-host.dts p9-host.dts + p8-host.dts p9-host.dts p8.dts DT_sources = $(DT:.dts=.dtb.S) DT_headers = $(DT:.dts=.dt.h) diff --git a/p8-cronus.dts.m4 b/p8-cronus.dts.m4 index 4b62b9a..2221a68 100644 --- a/p8-cronus.dts.m4 +++ b/p8-cronus.dts.m4 @@ -1,45 +1,27 @@ /dts-v1/; / { - #address-cells = <0x1>; - #size-cells = <0x0>; - - fsi0: kernelfsi@0 { - #address-cells = <0x2>; - #size-cells = <0x1>; - compatible = "ibm,cronus-fsi"; - reg = <0x0 0x0 0x0>; - - index = <0x0>; - status = "mustexist"; - - pib@1000 { - #address-cells = <0x2>; - #size-cells = <0x1>; - reg = <0x0 0x1000 0x7>; - index = <0x0>; - compatible = "ibm,cronus-pib"; - include(p8-pib.dts.m4)dnl - }; - - hmfsi@100000 { - #address-cells = <0x2>; - #size-cells = <0x1>; - compatible = "ibm,cronus-hmfsi"; - reg = <0x0 0x100000 0x8000>; - port = <0x1>; - index = <0x1>; - - pib@1000 { - #address-cells = <0x2>; - #size-cells = <0x1>; - reg = <0x0 0x1000 0x7>; - compatible = "ibm,cronus-pib"; - index = <0x1>; - include(p8-pib.dts.m4)dnl - }; - - }; - }; + fsi0 { + compatible = "ibm,cronus-fsi"; + index = <0x0>; + system-path = "/proc0/fsi"; + }; + + pib0 { + compatible = "ibm,cronus-pib"; + index = <0x0>; + system-path = "/proc0/pib"; + }; + + fsi1 { + compatible = "ibm,cronus-fsi"; + index = <0x1>; + system-path = "/proc1/fsi"; + }; + + pib1 { + compatible = "ibm,cronus-pib"; + index = <0x1>; + system-path = "/proc1/pib"; + }; }; - diff --git a/p8-fsi.dts.m4 b/p8-fsi.dts.m4 index 406a8dc..70fdb14 100644 --- a/p8-fsi.dts.m4 +++ b/p8-fsi.dts.m4 @@ -20,6 +20,7 @@ index = <0x0>; status = "mustexist"; + system-path = "/proc0/fsi"; pib@1000 { #address-cells = <0x2>; @@ -27,7 +28,7 @@ reg = <0x0 0x1000 0x7>; compatible = "ibm,fsi-pib", "ibm,power8-fsi-pib"; index = <0x0>; - include(p8-pib.dts.m4)dnl + system-path = "/proc0/pib"; }; hmfsi@100000 { @@ -37,6 +38,7 @@ reg = <0x0 0x100000 0x8000>; port = <0x1>; index = <0x1>; + system-path = "/proc1/fsi"; pib@1000 { #address-cells = <0x2>; @@ -44,7 +46,7 @@ reg = <0x0 0x1000 0x7>; compatible = "ibm,fsi-pib", "ibm,power8-fsi-pib"; index = <0x1>; - include(p8-pib.dts.m4)dnl + system-path = "/proc1/pib"; }; }; @@ -56,6 +58,7 @@ reg = <0x0 0x180000 0x80000>; port = <0x2>; index = <0x2>; + system-path = "/proc2/fsi"; pib@1000 { #address-cells = <0x2>; @@ -63,7 +66,7 @@ reg = <0x0 0x1000 0x7>; compatible = "ibm,fsi-pib", "ibm,power8-fsi-pib"; index = <0x2>; - include(p8-pib.dts.m4)dnl + system-path = "/proc2/pib"; }; }; }; diff --git a/p8-host.dts.m4 b/p8-host.dts.m4 index 7a2d253..c3f1a45 100644 --- a/p8-host.dts.m4 +++ b/p8-host.dts.m4 @@ -4,7 +4,7 @@ define(`CHIP',`pib@$1 { compatible = "ibm,host-pib"; reg = <$1>; index = <$1>; - include(p8-pib.dts.m4)dnl + system-path = "/proc$1/pib"; }')dnl /dts-v1/; diff --git a/p8-i2c.dts.m4 b/p8-i2c.dts.m4 index f1fcbd3..3ea4b59 100644 --- a/p8-i2c.dts.m4 +++ b/p8-i2c.dts.m4 @@ -13,7 +13,7 @@ reg = <0x50>; index = <0x0>; status = "mustexist"; - include(p8-pib.dts.m4)dnl + system-path = "/proc0/pib"; opb@20010 { #address-cells = <0x1>; @@ -28,6 +28,7 @@ reg = <0x100000 0x80000>; port = <0x1>; index = <0x1>; + system-path = "/proc1/fsi"; pib@1000 { #address-cells = <0x2>; @@ -35,7 +36,7 @@ reg = <0x0 0x1000 0x7>; compatible = "ibm,fsi-pib", "ibm,power8-fsi-pib"; index = <0x1>; - include(p8-pib.dts.m4)dnl + system-path = "/proc1/pib"; }; }; @@ -46,6 +47,7 @@ reg = <0x180000 0x80000>; port = <0x2>; index = <0x2>; + system-path = "/proc2/fsi"; pib@1000 { #address-cells = <0x2>; @@ -53,7 +55,7 @@ reg = <0x0 0x1000 0x7>; compatible = "ibm,fsi-pib", "ibm,power8-fsi-pib"; index = <0x2>; - include(p8-pib.dts.m4)dnl + system-path = "/proc2/pib"; }; }; }; diff --git a/p8-kernel.dts.m4 b/p8-kernel.dts.m4 index 4a59b78..6eacb92 100644 --- a/p8-kernel.dts.m4 +++ b/p8-kernel.dts.m4 @@ -9,9 +9,9 @@ #size-cells = <0x1>; compatible = "ibm,kernel-fsi"; reg = <0x0 0x0 0x0>; - index = <0x0>; status = "mustexist"; + system-path = "/proc0/fsi"; pib@1000 { #address-cells = <0x2>; @@ -19,7 +19,7 @@ reg = <0x0 0x1000 0x7>; index = <0x0>; compatible = "ibm,fsi-pib", "ibm,power8-fsi-pib"; - include(p8-pib.dts.m4)dnl + system-path = "/proc0/pib"; }; hmfsi@100000 { @@ -29,6 +29,7 @@ reg = <0x0 0x100000 0x8000>; port = <0x1>; index = <0x1>; + system-path = "/proc1/fsi"; pib@1000 { #address-cells = <0x2>; @@ -36,7 +37,7 @@ reg = <0x0 0x1000 0x7>; compatible = "ibm,fsi-pib", "ibm,power8-fsi-pib"; index = <0x1>; - include(p8-pib.dts.m4)dnl + system-path = "/proc1/pib"; }; }; diff --git a/p8-pib.dts.m4 b/p8-pib.dts.m4 index 82d11d8..044ce2b 100644 --- a/p8-pib.dts.m4 +++ b/p8-pib.dts.m4 @@ -44,6 +44,7 @@ CORE(14, 14)')dnl adu@2020000 { compatible = "ibm,power8-adu"; reg = <0x0 0x2020000 0x4>; + device_tree_path = "CONCAT(/mem,PROC_ID)"; }; nhtm@2010880 { diff --git a/p8.dts.m4 b/p8.dts.m4 new file mode 100644 index 0000000..aff477a --- /dev/null +++ b/p8.dts.m4 @@ -0,0 +1,55 @@ +define(`PROC',` +define(`PROC_ID',`$1')dnl + proc$1 { + index = <$1>; + + fsi { + index = <$1>; + }; + + pib { + #address-cells = <0x2>; + #size-cells = <0x1>; + index = <$1>; + include(p8-pib.dts.m4)dnl + }; + }; + mem$1 { + index = <$1>; + }' +)dnl + +/dts-v1/; + +/ { + PROC(0); + PROC(1); + PROC(2); + PROC(3); + PROC(4); + PROC(5); + PROC(6); + PROC(7); + PROC(9); + PROC(10); + PROC(11); + PROC(12); + PROC(13); + PROC(14); + PROC(15); + PROC(16); + PROC(17); + PROC(18); + PROC(19); + PROC(21); + PROC(22); + PROC(23); + PROC(24); + PROC(25); + PROC(26); + PROC(27); + PROC(28); + PROC(29); + PROC(30); + PROC(31); +}; From patchwork Thu Oct 3 04:19:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1171066 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46kKZc5nvvz9sDB for ; Thu, 3 Oct 2019 14:21:28 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="Z7ncxc+d"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46kKZc30kdzDqX6 for ; Thu, 3 Oct 2019 14:21:26 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46kKX82bsQzDqWm for ; Thu, 3 Oct 2019 14:19:20 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="Z7ncxc+d"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 46kKX800KXz9sDB; Thu, 3 Oct 2019 14:19:19 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1570076360; bh=vopnkNC4EcuPPJlss0Ul8UlhC8ZaPIrCxqpC4pWyBJs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z7ncxc+d35/RfByoQ6R2anbOrAMONOFDM7ZxQwPu6Ff/kxjIAhAg9sUCTLPL77iGQ aee9aB7ZwsSI/+FqE2tgqWW2+koIlKK451UilVdtYdkCmKrLrpPSW/xyJa8da3fAWU UOeuUU5vpwLYq5gsqaiFuX3ZWWwHErFuCki7dG+8VofGmu4YopPCgvABUr597B+7Ko UNm4MLq+Iv26iFi25ALkkHu+bSsoy4Exq3Fn6lA207nge0sphqRM822uci0pQ82Ju9 M9XGQ93tTNN+pSlFv6bhvlKnej8J7C0GDT8EPbfgnBcNINwnNs3DyLsd/qbkewS9wf utUsPdJyJLnUQ== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 3 Oct 2019 14:19:08 +1000 Message-Id: <20191003041909.23187-30-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191003041909.23187-1-amitay@ozlabs.org> References: <20191003041909.23187-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v4 29/30] dts: Split P9 device trees into system and backend trees X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- Makefile.am | 2 +- p9-cronus.dts.m4 | 50 ++++++++++++++++-------------------------------- p9-fsi.dtsi.m4 | 7 ++++--- p9-host.dts.m4 | 4 ++-- p9-kernel.dts.m4 | 13 ++++++++----- p9-pib.dts.m4 | 5 +++++ p9.dts.m4 | 27 ++++++++++++++++++++++++++ 7 files changed, 64 insertions(+), 44 deletions(-) create mode 100644 p9.dts.m4 diff --git a/Makefile.am b/Makefile.am index 5829fb3..e4905b7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -72,7 +72,7 @@ endif DT = fake.dts fake2.dts p8-cronus.dts p9-cronus.dts \ p8-fsi.dts p8-i2c.dts p8-kernel.dts \ p9w-fsi.dts p9r-fsi.dts p9z-fsi.dts p9-kernel.dts \ - p8-host.dts p9-host.dts p8.dts + p8-host.dts p9-host.dts p8.dts p9.dts DT_sources = $(DT:.dts=.dtb.S) DT_headers = $(DT:.dts=.dt.h) diff --git a/p9-cronus.dts.m4 b/p9-cronus.dts.m4 index c560442..2221a68 100644 --- a/p9-cronus.dts.m4 +++ b/p9-cronus.dts.m4 @@ -1,43 +1,27 @@ /dts-v1/; / { - #address-cells = <0x1>; - #size-cells = <0x0>; - - fsi0: kernelfsi@0 { - #address-cells = <0x2>; - #size-cells = <0x1>; + fsi0 { compatible = "ibm,cronus-fsi"; - reg = <0x0 0x0 0x0>; - index = <0x0>; - status = "mustexist"; + system-path = "/proc0/fsi"; + }; - pib@1000 { - #address-cells = <0x2>; - #size-cells = <0x1>; - reg = <0x0 0x1000 0x7>; - index = <0x0>; - compatible = "ibm,cronus-pib"; - include(p9-pib.dts.m4)dnl - }; + pib0 { + compatible = "ibm,cronus-pib"; + index = <0x0>; + system-path = "/proc0/pib"; + }; - hmfsi@100000 { - #address-cells = <0x2>; - #size-cells = <0x1>; - compatible = "ibm,cronus-fsi"; - reg = <0x0 0x100000 0x8000>; - port = <0x1>; - index = <0x1>; + fsi1 { + compatible = "ibm,cronus-fsi"; + index = <0x1>; + system-path = "/proc1/fsi"; + }; - pib@1000 { - #address-cells = <0x2>; - #size-cells = <0x1>; - reg = <0x0 0x1000 0x7>; - index = <0x1>; - compatible = "ibm,cronus-pib"; - include(p9-pib.dts.m4)dnl - }; - }; + pib1 { + compatible = "ibm,cronus-pib"; + index = <0x1>; + system-path = "/proc1/pib"; }; }; diff --git a/p9-fsi.dtsi.m4 b/p9-fsi.dtsi.m4 index afa7d39..3bbe43d 100644 --- a/p9-fsi.dtsi.m4 +++ b/p9-fsi.dtsi.m4 @@ -8,9 +8,9 @@ #size-cells = <0x1>; compatible = "ibm,bmcfsi"; reg = <0x0 0x0 0x0>; - index = <0x0>; status = "mustexist"; + system-path = "/proc0/fsi"; pib@1000 { #address-cells = <0x2>; @@ -18,7 +18,7 @@ reg = <0x0 0x1000 0x7>; index = <0x0>; compatible = "ibm,fsi-pib", "ibm,power9-fsi-pib"; - include(p9-pib.dts.m4)dnl + system-path = "/proc0/pib"; }; hmfsi@100000 { @@ -28,6 +28,7 @@ reg = <0x0 0x100000 0x8000>; port = <0x1>; index = <0x1>; + system-path = "/proc1/fsi"; pib@1000 { #address-cells = <0x2>; @@ -35,7 +36,7 @@ reg = <0x0 0x1000 0x7>; index = <0x1>; compatible = "ibm,fsi-pib", "ibm,power9-fsi-pib"; - include(p9-pib.dts.m4)dnl + system-path = "/proc1/pib"; }; }; diff --git a/p9-host.dts.m4 b/p9-host.dts.m4 index 52973ff..3b4c2b2 100644 --- a/p9-host.dts.m4 +++ b/p9-host.dts.m4 @@ -11,7 +11,7 @@ compatible = "ibm,host-pib"; reg = <0x0>; index = <0x0>; - include(p9-pib.dts.m4)dnl + system-path = "/proc0/pib"; }; pib@8 { @@ -20,6 +20,6 @@ compatible = "ibm,host-pib"; reg = <0x8>; index = <0x8>; - include(p9-pib.dts.m4)dnl + system-path = "/proc1/pib"; }; }; diff --git a/p9-kernel.dts.m4 b/p9-kernel.dts.m4 index aa4bcac..8c2c35b 100644 --- a/p9-kernel.dts.m4 +++ b/p9-kernel.dts.m4 @@ -9,9 +9,9 @@ #size-cells = <0x1>; compatible = "ibm,kernel-fsi"; reg = <0x0 0x0 0x0>; - index = <0x0>; status = "mustexist"; + system-path = "/proc0/fsi"; pib@1000 { #address-cells = <0x2>; @@ -20,7 +20,7 @@ index = <0x0>; compatible = "ibm,kernel-pib"; device-path = "/dev/scom1"; - include(p9-pib.dts.m4)dnl + system-path = "/proc0/pib"; }; sbefifo@2400 { /* Bogus address */ @@ -29,8 +29,9 @@ compatible = "ibm,kernel-sbefifo"; device-path = "/dev/sbefifo1"; - sbefifo-mem@0 { + sbefifo-mem { compatible = "ibm,sbefifo-mem"; + system-path = "/mem0"; }; }; @@ -41,6 +42,7 @@ reg = <0x0 0x100000 0x8000>; port = <0x1>; index = <0x1>; + system-path = "/proc1/fsi"; pib@1000 { #address-cells = <0x2>; @@ -49,7 +51,7 @@ index = <0x1>; compatible = "ibm,kernel-pib"; device-path = "/dev/scom2"; - include(p9-pib.dts.m4)dnl + system-path = "/proc1/pib"; }; sbefifo@2400 { /* Bogus address */ @@ -58,8 +60,9 @@ compatible = "ibm,kernel-sbefifo"; device-path = "/dev/sbefifo2"; - sbefifo-mem@0 { + sbefifo-mem { compatible = "ibm,sbefifo-mem"; + system-path = "/mem1"; }; }; }; diff --git a/p9-pib.dts.m4 b/p9-pib.dts.m4 index 3a99157..8c9dfaf 100644 --- a/p9-pib.dts.m4 +++ b/p9-pib.dts.m4 @@ -35,6 +35,11 @@ index = ; reg = <0x0 HEX(CHIPLET_BASE($1)) 0xfffff>; }')dnl +adu@90000 { + compatible = "ibm-power9-adu"; + reg = <0x0 0x90000 0x50>; + system-path = "CONCAT(/mem,PROC_ID)"; +}; htm@5012880 { compatible = "ibm,power9-nhtm"; diff --git a/p9.dts.m4 b/p9.dts.m4 new file mode 100644 index 0000000..dd46ace --- /dev/null +++ b/p9.dts.m4 @@ -0,0 +1,27 @@ +define(`PROC',` +define(`PROC_ID',`$1')dnl + proc$1 { + index = <$1>; + + fsi { + index = <$1>; + }; + + pib { + #address-cells = <0x2>; + #size-cells = <0x1>; + index = <$1>; + include(p9-pib.dts.m4)dnl + }; + }; + mem$1 { + index = <$1>; + }' +)dnl + +/dts-v1/; + +/ { + PROC(0); + PROC(1); +}; From patchwork Thu Oct 3 04:19:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1171067 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46kKZg3h8Kz9sP7 for ; Thu, 3 Oct 2019 14:21:31 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="akwc0HmY"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46kKZg0DD9zDqWm for ; Thu, 3 Oct 2019 14:21:31 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46kKX84mK1zDqWn for ; Thu, 3 Oct 2019 14:19:20 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="akwc0HmY"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 46kKX82Ghdz9sP7; Thu, 3 Oct 2019 14:19:20 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1570076360; bh=F2TCC2v69Ser7aexEfAkVCrlNh51d4yIO0vlc3MQo1g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=akwc0HmYQRE4sVgf/OiHdpnLE6xg91QPO3rPn3jkNtLAWnx2p5+TgIljbH2PAqtOD CTBilfBjox374rVS1kcRTQpA+LgFI2TX0nzsTcY1fGxXd2IFNNyEr2zWxRraZJ3Hs3 oBHppwdT/q3aJOJscHAe6GHQVi+y+02xtWoDdHz/J6a/0T8FoY9eFuPFmK+G6g2yPU rliYwyzcDa5kZecTejWYT+ThTeUTRufW6mTfiR3ub4SQns0lnBROwbcmxcxsTo3hby AjSgykgUMwZVsck6bryoS40ghWVX46RMjq2DjHUpKE9ChQSVmzE2TaMRbjlrN0NjEf L1CLTRjyfS11A== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 3 Oct 2019 14:19:09 +1000 Message-Id: <20191003041909.23187-31-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191003041909.23187-1-amitay@ozlabs.org> References: <20191003041909.23187-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v4 30/30] libpdbg: Separate backend and system device trees X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- libpdbg/dtb.c | 194 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 126 insertions(+), 68 deletions(-) diff --git a/libpdbg/dtb.c b/libpdbg/dtb.c index b85cba2..d7035ad 100644 --- a/libpdbg/dtb.c +++ b/libpdbg/dtb.c @@ -44,6 +44,9 @@ #include "p8-cronus.dt.h" #include "p9-cronus.dt.h" +#include "p8.dt.h" +#include "p9.dt.h" + #define AMI_BMC "/proc/ractrends/Helper/FwInfo" #define OPENFSI_BMC "/sys/bus/platform/devices/gpio-fsi/fsi0/" #define FSI_CFAM_ID "/sys/devices/platform/gpio-fsi/fsi0/slave@00:00/cfam_id" @@ -84,11 +87,22 @@ static void ppc_target(struct pdbg_dtb *dtb) char line[256]; FILE *cpuinfo; - if (!strcmp(pdbg_backend_option, "p8")) { - dtb->system = &_binary_p8_host_dtb_o_start; - return; - } else if (!strcmp(pdbg_backend_option, "p9")) { - dtb->system = &_binary_p9_host_dtb_o_start; + if (pdbg_backend_option) { + if (!strcmp(pdbg_backend_option, "p8")) { + if (!dtb->backend) + dtb->backend = &_binary_p8_host_dtb_o_start; + if (!dtb->system) + dtb->system = &_binary_p8_dtb_o_start; + } else if (!strcmp(pdbg_backend_option, "p9")) { + if (!dtb->backend) + dtb->backend = &_binary_p9_host_dtb_o_start; + if (!dtb->system) + dtb->system = &_binary_p9_dtb_o_start; + } else { + pdbg_log(PDBG_ERROR, "Invalid system type %s\n", pdbg_backend_option); + pdbg_log(PDBG_ERROR, "Use 'p8' or 'p9'\n"); + } + return; } @@ -117,67 +131,87 @@ static void ppc_target(struct pdbg_dtb *dtb) if (strncmp(pos, "POWER8", 6) == 0) { pdbg_log(PDBG_INFO, "Found a POWER8 PPC host system\n"); - dtb->system = &_binary_p8_host_dtb_o_start; - } - - if (strncmp(pos, "POWER9", 6) == 0) { + if (!dtb->backend) + dtb->backend = &_binary_p8_host_dtb_o_start; + if (!dtb->system) + dtb->system = &_binary_p8_dtb_o_start; + } else if (strncmp(pos, "POWER9", 6) == 0) { pdbg_log(PDBG_INFO, "Found a POWER9 PPC host system\n"); - dtb->system = &_binary_p9_host_dtb_o_start; + if (!dtb->backend) + dtb->backend = &_binary_p9_host_dtb_o_start; + if (!dtb->system) + dtb->system = &_binary_p9_dtb_o_start; + } else { + pdbg_log(PDBG_ERROR, "Unsupported CPU type '%s'\n", pos); } - - pdbg_log(PDBG_ERROR, "Unsupported CPU type '%s'\n", pos); } static void bmc_target(struct pdbg_dtb *dtb) { FILE *cfam_id_file; + char *path; uint32_t cfam_id = 0; uint32_t chip_id = 0; int rc; - if (!pdbg_backend_option) { - /* Try and determine the correct device type */ - char *path; - - rc = asprintf(&path, "%s/fsi0/slave@00:00/cfam_id", kernel_get_fsi_path()); - if (rc < 0) { - pdbg_log(PDBG_ERROR, "Unable create fsi path"); - return NULL; + if (pdbg_backend_option) { + if (!strcmp(pdbg_backend_option, "p8")) { + if (!dtb->backend) + dtb->backend = &_binary_p8_kernel_dtb_o_start; + if (!dtb->system) + dtb->system = &_binary_p8_dtb_o_start; + } else if (!strcmp(pdbg_backend_option, "p9")) { + if (!dtb->backend) + dtb->backend = &_binary_p9_kernel_dtb_o_start; + if (!dtb->system) + dtb->system = &_binary_p9_dtb_o_start; + } else { + pdbg_log(PDBG_ERROR, "Invalid system type %s\n", pdbg_backend_option); + pdbg_log(PDBG_ERROR, "Use 'p8' or 'p9'\n"); } - cfam_id_file = fopen(path, "r"); - free(path); - if (!cfam_id_file) { - pdbg_log(PDBG_ERROR, "Unabled to open CFAM ID file\n"); - return; - } + return; + } - rc = fscanf(cfam_id_file, "0x%" PRIx32, &cfam_id); - if (rc != 1) { - pdbg_log(PDBG_ERROR, "Unable to read CFAM ID: %s", strerror(errno)); - } + /* Try and determine the correct device type */ + rc = asprintf(&path, "%s/fsi0/slave@00:00/cfam_id", kernel_get_fsi_path()); + if (rc < 0) { + pdbg_log(PDBG_ERROR, "Unable create fsi path"); + return; + } + + cfam_id_file = fopen(path, "r"); + free(path); + if (!cfam_id_file) { + pdbg_log(PDBG_ERROR, "Unabled to open CFAM ID file\n"); + return; + } + + rc = fscanf(cfam_id_file, "0x%" PRIx32, &cfam_id); + if (rc != 1) { + pdbg_log(PDBG_ERROR, "Unable to read CFAM ID: %s", strerror(errno)); fclose(cfam_id_file); - chip_id = (cfam_id >> 4) & 0xff; - } else { - if (!strcmp(pdbg_backend_option, "p9")) - chip_id = CHIP_ID_P9; - else if (!strcmp(pdbg_backend_option, "p8")) - chip_id = CHIP_ID_P8; - else - pdbg_log(PDBG_WARNING, "Invalid OpenBMC system type '%s' specified\n", - pdbg_backend_option); + return; } + fclose(cfam_id_file); + chip_id = (cfam_id >> 4) & 0xff; switch(chip_id) { case CHIP_ID_P9: pdbg_log(PDBG_INFO, "Found a POWER9 OpenBMC based system\n"); - dtb->system = &_binary_p9_kernel_dtb_o_start; + if (!dtb->backend) + dtb->backend = &_binary_p9_kernel_dtb_o_start; + if (!dtb->system) + dtb->system = &_binary_p9_dtb_o_start; break; case CHIP_ID_P8: case CHIP_ID_P8P: pdbg_log(PDBG_INFO, "Found a POWER8/8+ OpenBMC based system\n"); - dtb->system = &_binary_p8_kernel_dtb_o_start; + if (!dtb->backend) + dtb->backend = &_binary_p8_kernel_dtb_o_start; + if (!dtb->system) + dtb->system = &_binary_p8_dtb_o_start; break; default: @@ -238,17 +272,23 @@ const char *pdbg_get_backend_option(void) * the fdt that is most likely to work on the system. */ void pdbg_default_dtb(struct pdbg_dtb *dtb) { - char *fdt = getenv("PDBG_DTB"); + char *fdt; *dtb = (struct pdbg_dtb) { .backend = NULL, .system = NULL, }; - if (fdt) { + fdt = getenv("PDBG_BACKEND_DTB"); + if (fdt) + dtb->backend = mmap_dtb(fdt); + + fdt = getenv("PDBG_DTB"); + if (fdt) dtb->system = mmap_dtb(fdt); + + if (dtb->backend && dtb->system) return; - } if (!pdbg_backend) pdbg_backend = default_backend(); @@ -260,8 +300,12 @@ void pdbg_default_dtb(struct pdbg_dtb *dtb) case PDBG_BACKEND_I2C: /* I2C is only supported on POWER8 */ - pdbg_log(PDBG_INFO, "Found a POWER8 AMI BMC based system\n"); - dtb->system = &_binary_p8_i2c_dtb_o_start; + if (!dtb->backend) { + pdbg_log(PDBG_INFO, "Found a POWER8 AMI BMC based system\n"); + dtb->backend = &_binary_p8_i2c_dtb_o_start; + } + if (!dtb->system) + dtb->system = &_binary_p8_dtb_o_start; break; case PDBG_BACKEND_KERNEL: @@ -270,44 +314,58 @@ void pdbg_default_dtb(struct pdbg_dtb *dtb) case PDBG_BACKEND_FSI: if (!pdbg_backend_option) { - pdbg_log(PDBG_ERROR, "No device type specified\n"); + pdbg_log(PDBG_ERROR, "No system type specified\n"); pdbg_log(PDBG_ERROR, "Use 'p8' or 'p9r/p9w/p9z'\n"); return; } - if (!strcmp(pdbg_backend_option, "p8")) - dtb->system = &_binary_p8_fsi_dtb_o_start; - else if (!strcmp(pdbg_backend_option, "p9w")) - dtb->system = &_binary_p9w_fsi_dtb_o_start; - else if (!strcmp(pdbg_backend_option, "p9r")) - dtb->system = &_binary_p9r_fsi_dtb_o_start; - else if (!strcmp(pdbg_backend_option, "p9z")) - dtb->system = &_binary_p9z_fsi_dtb_o_start; - else { - pdbg_log(PDBG_ERROR, "Invalid device type specified\n"); + if (!strcmp(pdbg_backend_option, "p8")) { + if (!dtb->backend) + dtb->backend = &_binary_p8_fsi_dtb_o_start; + if (!dtb->system) + dtb->system = &_binary_p8_dtb_o_start; + } else if (!strcmp(pdbg_backend_option, "p9w")) { + if (!dtb->backend) + dtb->backend = &_binary_p9w_fsi_dtb_o_start; + if (!dtb->system) + dtb->system = &_binary_p9_dtb_o_start; + } else if (!strcmp(pdbg_backend_option, "p9r")) { + if (!dtb->backend) + dtb->backend = &_binary_p9r_fsi_dtb_o_start; + if (!dtb->system) + dtb->system = &_binary_p9_dtb_o_start; + } else if (!strcmp(pdbg_backend_option, "p9z")) { + if (!dtb->backend) + dtb->backend = &_binary_p9z_fsi_dtb_o_start; + if (!dtb->system) + dtb->system = &_binary_p9_dtb_o_start; + } else { + pdbg_log(PDBG_ERROR, "Invalid system type %s\n", pdbg_backend_option); pdbg_log(PDBG_ERROR, "Use 'p8' or 'p9r/p9w/p9z'\n"); - return; } - break; case PDBG_BACKEND_CRONUS: if (!pdbg_backend_option) { - pdbg_log(PDBG_ERROR, "No device type specified\n"); + pdbg_log(PDBG_ERROR, "No system type specified\n"); pdbg_log(PDBG_ERROR, "Use p8@ or p9@\n"); return; } - if (!strncmp(pdbg_backend_option, "p8", 2)) - dtb->system = &_binary_p8_cronus_dtb_o_start; - else if (!strncmp(pdbg_backend_option, "p9", 2)) - dtb->system = &_binary_p9_cronus_dtb_o_start; - else { - pdbg_log(PDBG_ERROR, "Invalid device type specified\n"); + if (!strncmp(pdbg_backend_option, "p8", 2)) { + if (!dtb->backend) + dtb->backend = &_binary_p8_cronus_dtb_o_start; + if (!dtb->system) + dtb->system = &_binary_p8_dtb_o_start; + } else if (!strncmp(pdbg_backend_option, "p9", 2)) { + if (!dtb->backend) + dtb->backend = &_binary_p9_cronus_dtb_o_start; + if (!dtb->system) + dtb->system = &_binary_p9_dtb_o_start; + } else { + pdbg_log(PDBG_ERROR, "Invalid system type %s\n", pdbg_backend_option); pdbg_log(PDBG_ERROR, "Use p8@ or p9@\n"); - return; } - break; default: