From patchwork Mon Oct 14 05:17:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1175950 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 46s6K615lCz9sPp for ; Mon, 14 Oct 2019 16:18:18 +1100 (AEDT) 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="nbv/eMqn"; 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 46s6K54s0PzDqXK for ; Mon, 14 Oct 2019 16:18:17 +1100 (AEDT) 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 46s6Jq6G74zDqW9 for ; Mon, 14 Oct 2019 16:18:03 +1100 (AEDT) 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="nbv/eMqn"; 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 46s6Jp6VcVz9sPj; Mon, 14 Oct 2019 16:18:02 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1571030283; bh=Rs+wkkCI40JOx7ZW6SsysJbjIH+YJaDMVW/wV5/6r8E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nbv/eMqnXMsGs2lfjFuasTCiZxR0j5DWngrpkgmVCna+HidpdCPt+Xt/2QRwnH53V YQfoo4J1ukw6MmpHx91HdIUHPq5XuUTvOb4qFrdrpM5mEJJRc9NH/9Mz4QPaU5zqrj zGczCmFTBKN1Em1kEMcaPcMDAs/fILJA1jVPMaiFMEHbDVZyqJYFlv9cL2e/47H4J9 oZJuGKK3jCtyl22IW5CSxlbQpPRpleusYyQ0LAPrimjZa0M5XL/4YeH93758YxQZYq 4NHsjUbwdy0v/NFZDoeAMvf9QQ829ilIxzbn4Vr6F1KGm235UmS1DRXwHq6n6yjbTV k+vSoRfawHj6A== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Mon, 14 Oct 2019 16:17:19 +1100 Message-Id: <20191014051748.20190-2-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191014051748.20190-1-amitay@ozlabs.org> References: <20191014051748.20190-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v5 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 Mon Oct 14 05:17:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1175951 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 46s6KB4rpWz9s4Y for ; Mon, 14 Oct 2019 16:18:22 +1100 (AEDT) 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="WDLM1nmF"; 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 46s6KB3lbXzDqXK for ; Mon, 14 Oct 2019 16:18:22 +1100 (AEDT) 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 46s6Jr2tgfzDqW5 for ; Mon, 14 Oct 2019 16:18:04 +1100 (AEDT) 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="WDLM1nmF"; 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 46s6Jq4gxrz9sPp; Mon, 14 Oct 2019 16:18:03 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1571030283; bh=PJh90MpSpAmY4bHl2r2CTjfHsvzbsxsqfkSuKDrM08g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WDLM1nmFvqRs5Qnu9EErcC+wJL6YInT3yYYLU3wOPVPxe789hE7ljiQBugRqYHilz JfydGR3aQJYmFMHFB4zdBg1oqkGuExqejSV7GR4cMjJyENiZC8SpJTbBylao5MmU7X O+KYj+nTbriUcpaUrTooDL1w6g5/F1xfo6jJU650+YohydKpz1bHC1mXm015dwahpW rtTwMpvC1oLPiFdBqsHzt4YUx6YSfRP+ZbqWU2eKadnykIx7ZzxeSSXaY3yCoH9838 aWvDTTQf3sODF/Dm/KMRqWI26DcJ3GeRiEJVxJGJ/yJJlcg3NAjx6D/Pq4gM31hhhn /vCpJVqGYjUZg== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Mon, 14 Oct 2019 16:17:20 +1100 Message-Id: <20191014051748.20190-3-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191014051748.20190-1-amitay@ozlabs.org> References: <20191014051748.20190-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v5 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 Mon Oct 14 05:17:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1175952 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 46s6KG4nxLz9sPj for ; Mon, 14 Oct 2019 16:18:26 +1100 (AEDT) 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="voDK2CeV"; 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 46s6KG2PCYzDqW5 for ; Mon, 14 Oct 2019 16:18:26 +1100 (AEDT) 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 46s6Js08lzzDqW5 for ; Mon, 14 Oct 2019 16:18:05 +1100 (AEDT) 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="voDK2CeV"; 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 46s6Jr4828z9sPh; Mon, 14 Oct 2019 16:18:04 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1571030284; bh=CslzXzGu6XufWvRyJkBqih/1F9P/AhnazFxX0ZeC72s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=voDK2CeVHFg8oK7kDJxQ714ymcBtASh1b77mTOAwLOk780/aV7rtwHWUQQqv7TbQr /+IcBgsGF4EkYgmjJtTOPo91tnNewyWsmYZLIn8YIwuV5BYioraKhspo6bt4yiD/Xp IQx/vut9HpzOz1y5yKJUo+U2BnIKoWFHKWoVoYQ4NQKqTqAzNUASlZdqvrIHWld0T8 bQKsaVD2PLu4Edc+jVLhdLOn7+J2tBeRfqyutbIHGNqjnA/rjG4sTrZETLvHDgZv3h KJIOGbsZIqm8T1WNdNlOkmBhzepvSfpZ1SCfzDdy3pnz5Kg2bLhh1l8qxXZmj1VMFo LWp/vKig46sLA== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Mon, 14 Oct 2019 16:17:21 +1100 Message-Id: <20191014051748.20190-4-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191014051748.20190-1-amitay@ozlabs.org> References: <20191014051748.20190-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v5 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 Mon Oct 14 05:17:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1175953 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 46s6KM5bT0z9s4Y for ; Mon, 14 Oct 2019 16:18:31 +1100 (AEDT) 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="ElkxQUQJ"; 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 46s6KM170vzDqW5 for ; Mon, 14 Oct 2019 16:18:29 +1100 (AEDT) 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 46s6Js44vHzDqW5 for ; Mon, 14 Oct 2019 16:18:05 +1100 (AEDT) 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="ElkxQUQJ"; 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 46s6Js1Myfz9sPj; Mon, 14 Oct 2019 16:18:05 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1571030285; bh=M/CeVg7NpfDv26fsHcL+9SyWy4nXIu75VtuucoCJFd8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ElkxQUQJTt54LsNZJE2LM26x5TSfWlyRLzjI8GXaiDPBwAW9QV10wEoyBJ5FhVrEh h0dslJTTKYUW4gR1sq6juXz6rBeCV/b3O4Eq9w2/h6mYBCRmxx6snctu1QrTqGsqhm LrIDVXxECaVBhCMVC8c7c432uUOxeJsEL8Kb4ZQww22IM75Pc7KqCYtu1wqkX/LI7Y RcOeVaozyW3c/YPt/PFb2RNJ3OZ14r65baIJML18XJvhwis6Uaem61Jq+519Lr30Yd XCq25csQuBZ1k5F1gp+pP7aiKW7Y/UQ7fYmvum89lOpuV3M5L2l1CeJaxzCdsXshue ogH6slhPaQZUw== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Mon, 14 Oct 2019 16:17:22 +1100 Message-Id: <20191014051748.20190-5-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191014051748.20190-1-amitay@ozlabs.org> References: <20191014051748.20190-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v5 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 Mon Oct 14 05:17:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1175954 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 46s6KQ2136z9sPj for ; Mon, 14 Oct 2019 16:18:34 +1100 (AEDT) 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="D9rzSBpv"; 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 46s6KP6zZxzDqW9 for ; Mon, 14 Oct 2019 16:18:33 +1100 (AEDT) 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 46s6Jt0VRFzDqW9 for ; Mon, 14 Oct 2019 16:18:06 +1100 (AEDT) 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="D9rzSBpv"; 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 46s6Js4H7Vz9sPh; Mon, 14 Oct 2019 16:18:05 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1571030285; bh=vpyVrmbz0vtmj9G3JU3n3ZWJDQyDeR+9boBTUhAVR7A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D9rzSBpvnl6Z/hCOEtZw7UL0Dsyx23SOt3uzz9iVfB3UBiqm307wRwCAHoDhn9DYo sRcTAmY0YMfhO+6ca4S+njKAZZNLtcXyPUd0nFK0UeDQTgC3fug+lGO5gPHV/6zYPM 14KUbTh8GoKQ/owm2SFMCVdUOvgAnM9IDc/77Xij4PzdfvwLs9pHGo3n4ViSRSbffL ePH8Fb3HU0y4E43jaKXMpCD16CohleboJM5IRX/J9Tf9vqOPdh8egR3T34wYxf50Lc OTGkdSh8AMHkRMMmw1vpJjM1/DzUbKVdrw4JqIc8KZyvunC2tJQWJVSxLc4IatWLck q9rdyjzuxtixQ== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Mon, 14 Oct 2019 16:17:23 +1100 Message-Id: <20191014051748.20190-6-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191014051748.20190-1-amitay@ozlabs.org> References: <20191014051748.20190-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v5 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 Mon Oct 14 05:17:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1175955 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 46s6KV69Rwz9sPh for ; Mon, 14 Oct 2019 16:18:38 +1100 (AEDT) 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="odrOyfuZ"; 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 46s6KV4rsVzDqXJ for ; Mon, 14 Oct 2019 16:18:38 +1100 (AEDT) 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 46s6Jt4mP7zDqW5 for ; Mon, 14 Oct 2019 16:18:06 +1100 (AEDT) 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="odrOyfuZ"; 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 46s6Jt0qq4z9sPj; Mon, 14 Oct 2019 16:18:06 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1571030286; bh=cgL+NYvETCN4wTkwi1jm06bRhZrvzNH9SBqJpgxzZxM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=odrOyfuZghkNbjIsbqD6mp5e10e2yY/hc44v+KJj0OCYRMynIq1Xj+tUBQqsEdGWx S7t4pfjfHiE9AIAIYjjGhDA4Szc5wlWoFuCMlwqYtbAUXOqfp8qvWfnoy2wbG8KJ8k AvyEXn6d97U8M9IEcjpiQpwivcBevSkcAJF+OcNpZ0F9yx5hWF2IaV8m7HH0bhfRzv PVyqyO2twoUIP3NRLltVA06o+WG1YIDEAYmkc125II4mbSnbK7DyZF2dXfiE7Cp4ID zUdMnCg6EunY2EDQF1isCysX1Q/Vmf2ZhLmrTr71ZxkrkIINxBhrOKgzJagsD9w8dg Jbdu+uRp5Hqdg== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Mon, 14 Oct 2019 16:17:24 +1100 Message-Id: <20191014051748.20190-7-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191014051748.20190-1-amitay@ozlabs.org> References: <20191014051748.20190-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v5 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 Mon Oct 14 05:17:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1175956 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 46s6KY423Fz9sPj for ; Mon, 14 Oct 2019 16:18:41 +1100 (AEDT) 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="G84R5rgE"; 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 46s6KY2dYXzDqWY for ; Mon, 14 Oct 2019 16:18:41 +1100 (AEDT) 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 46s6Jv18XrzDqW5 for ; Mon, 14 Oct 2019 16:18:07 +1100 (AEDT) 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="G84R5rgE"; 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 46s6Jt5C7Zz9sPp; Mon, 14 Oct 2019 16:18:06 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1571030286; bh=zrZDAnfL+W5MGLCKfpIqenfLFIpHow9ox+hHAq4DiZs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G84R5rgEsPzOYa6mi87PmWpObakI/FQH/yt5kTyNOWlwGcjsJ+qqNL8II6dIc1p/g v6XrCCOi4L39UCscVE1xYoz/c6pRP9Ovt2FzI4SqzekPwDD9jmnfnHPJPfjf9xzWzA unbB0jLyY8FCoUa6w4rcv20BWCtfwN8NslMlBDZLejMcRvcde5FGJ037+UtaZ/6xP1 muRtNRF7XzwC2aGtnAebVP1DeaOwWw2A4DvsvNvNpQ7z/BSEZx9gGo5NFjddxv4/i9 k5Ddeci9/pN8D+0vc526u3T6TrrKeFNebCzW9Qr6cGlGK4TEaBUVR5I67VPk/JxKXM DOMGEKq3wlrNw== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Mon, 14 Oct 2019 16:17:25 +1100 Message-Id: <20191014051748.20190-8-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191014051748.20190-1-amitay@ozlabs.org> References: <20191014051748.20190-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v5 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 Mon Oct 14 05:17:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1175957 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 46s6Kc4bZgz9sPj for ; Mon, 14 Oct 2019 16:18:44 +1100 (AEDT) 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="ibU/yygS"; 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 46s6Kc2VPDzDqXT for ; Mon, 14 Oct 2019 16:18:44 +1100 (AEDT) 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 46s6Jv6J8CzDqW9 for ; Mon, 14 Oct 2019 16:18:07 +1100 (AEDT) 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="ibU/yygS"; 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 46s6Jv1Kxcz9sPh; Mon, 14 Oct 2019 16:18:07 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1571030287; bh=go6QYUfE0vFs6TQAf6REb5GNI4JQLto10nWW5XI2guU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ibU/yygSUNVKNdRkO19GS5D8YbiR0klK3V8p/wnpmu830fjw+A0k48xTrnOWoF9Qa qCm8Zkyh9bbPyADp4YeKFIkE/zIpOTOaRWtmqJfszZpB8iaPM9eVjoFq4uJnDlacoE u1RgIAjHO4zk5QUMXWSI/NGDNquWcr36qPNd3DWQ38HwxOphfk+cECcuuWM6QfUS1N xmQu0LrU0BjepBDNK0vzRAPfJlv4h4OtoH9c0XHbVmuHYMsTKZF3UAbKTMmrZYNYsS p/O8nns6eKdNmMv5HRvlDpd7nsQWrgcey8uAY5oUxjTDeZGqzMeszDQw4XAjXN8dDe q+5xG4X2OczEQ== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Mon, 14 Oct 2019 16:17:26 +1100 Message-Id: <20191014051748.20190-9-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191014051748.20190-1-amitay@ozlabs.org> References: <20191014051748.20190-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v5 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 | 12 ++++++++++++ libpdbg/target.h | 1 + 2 files changed, 13 insertions(+) diff --git a/libpdbg/target.c b/libpdbg/target.c index 9110b81..61deb57 100644 --- a/libpdbg/target.c +++ b/libpdbg/target.c @@ -473,3 +473,15 @@ bool target_is_virtual(struct pdbg_target *target) { return (!target->compatible); } + +/* Map virtual target to real target */ +struct pdbg_target *target_to_real(struct pdbg_target *target, bool strict) +{ + if (!target->compatible && target->vnode) + return target->vnode; + + if (strict) + return NULL; + + return target; +} diff --git a/libpdbg/target.h b/libpdbg/target.h index f5769ea..44d319e 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, bool strict); #endif From patchwork Mon Oct 14 05:17:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1175958 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 46s6Kh2Npxz9sQw for ; Mon, 14 Oct 2019 16:18:48 +1100 (AEDT) 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="N71sx+6U"; 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 46s6Kh0wvHzDqWW for ; Mon, 14 Oct 2019 16:18:48 +1100 (AEDT) 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 46s6Jw39h9zDqW5 for ; Mon, 14 Oct 2019 16:18:08 +1100 (AEDT) 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="N71sx+6U"; 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 46s6Jv6qKLz9sQr; Mon, 14 Oct 2019 16:18:07 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1571030288; bh=fGGxN2bGZNnOm3d1dqNCtmecNC7iSldFFdiOx7jdG9Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N71sx+6UQ+xJydwHGuOkBLoneK/mESU496IJgYE3QBIaeJgjHlnteHL94PkfGYkZy LXBKhxZ99Y2aQxt4Tr/5g49vG4hg34m45DQeyqmHz4FUY6ZAUNCdmotBtGveF6sP10 rbqoRtAEk9yg/BGufQxpSKKSs703MBVOsUJ4fONTwCLhmI44sn6FOGjEs5MtHLV/MO 9RzcFYmOtTkMf/CGv4+57jrcp1yQYLCp/ax/5pGO2CYi3ooPihfCPOSAW+NbDaT1qa bFlK2chJR+/MYUGIP0aZL/vOrI7e5fLvcp+KCIOEtyO98T+e0HwDfKpLPVdwvfecyN i36EERxrXlg5A== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Mon, 14 Oct 2019 16:17:27 +1100 Message-Id: <20191014051748.20190-10-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191014051748.20190-1-amitay@ozlabs.org> References: <20191014051748.20190-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v5 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 Reviewed-by: Alistair Popple --- libpdbg/target.c | 12 ++++++++++++ libpdbg/target.h | 1 + 2 files changed, 13 insertions(+) diff --git a/libpdbg/target.c b/libpdbg/target.c index 61deb57..7b8de03 100644 --- a/libpdbg/target.c +++ b/libpdbg/target.c @@ -485,3 +485,15 @@ struct pdbg_target *target_to_real(struct pdbg_target *target, bool strict) return target; } + +/* Map real target to virtual target */ +struct pdbg_target *target_to_virtual(struct pdbg_target *target, bool strict) +{ + if (target->compatible && target->vnode) + return target->vnode; + + if (strict) + return NULL; + + return target; +} diff --git a/libpdbg/target.h b/libpdbg/target.h index 44d319e..cbc5698 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, bool strict); +struct pdbg_target *target_to_virtual(struct pdbg_target *target, bool strict); #endif From patchwork Mon Oct 14 05:17:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1175960 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 46s6Kn3ZTBz9sQy for ; Mon, 14 Oct 2019 16:18:53 +1100 (AEDT) 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="mkm9YQVd"; 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 46s6Km2vRZzDqWF for ; Mon, 14 Oct 2019 16:18:52 +1100 (AEDT) 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 46s6Jw6m7dzDqW9 for ; Mon, 14 Oct 2019 16:18:08 +1100 (AEDT) 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="mkm9YQVd"; 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 46s6Jw44s3z9sPh; Mon, 14 Oct 2019 16:18:08 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1571030288; bh=/xmb6u61b7RplYTmU9YIrCh04L08QFghgYFkl4XeNZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mkm9YQVdYaeELCmxaGRCk29WFG/HVqRXznncLonB6lLfDRWEOJ2wngO/17+AFwq+U vpQUWd4Ic0sohsvv68KYWII7yHV0OY8iHoxGVxBUPceVSKT6LvloLREBs+jHVUm8DM 9o36PJpkjKpIeFlow9/yFNGYOcN7bFIQSODkQaoa5/2nTwdk6hhNRZTG9pat6SP8J6 i0qFQiLDZaBEDv44r5E+yl2nMfPvgrM3KLgetplTIhiMki9h+dWVHvT2WSIK6EqF2M dQESBdwJu/w7AI1ADZMxl46drrJB0HOguGmc31i8Ll/AOdmcZ+wCUAruwXMguK2BYv h9GCDKvNvqKXA== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Mon, 14 Oct 2019 16:17:28 +1100 Message-Id: <20191014051748.20190-11-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191014051748.20190-1-amitay@ozlabs.org> References: <20191014051748.20190-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v5 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..2776169 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, false); } static struct dt_property *dt_find_property(const struct pdbg_target *node, From patchwork Mon Oct 14 05:17:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1175962 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 46s6Kv3rz2z9sQy for ; Mon, 14 Oct 2019 16:18:59 +1100 (AEDT) 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="a4H7N5Ws"; 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 46s6Kv16SLzDqWy for ; Mon, 14 Oct 2019 16:18:59 +1100 (AEDT) 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 46s6Jx41pdzDqW5 for ; Mon, 14 Oct 2019 16:18:09 +1100 (AEDT) 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="a4H7N5Ws"; 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 46s6Jx1KgSz9sPj; Mon, 14 Oct 2019 16:18:09 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1571030289; bh=3ZhNwGmzqAsfeMKBTGBOyALa5OSRXj8VspZo1uCX2OI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a4H7N5WsurgJz2Fk8FB+NteNv9oeIfGCC9VGf42Fd6fWgcShRO0e96J7SC3AhQ+/5 1i63eFjFVcRwPi9Sh1mbtC9somljek9GdVIdoQRL2OAA6+OVT0ZcwqJDudEwntJGni mzQKkN12iUZFLJv0VGriXVCQwJ4Uq/tWRiPiVHyRDc40H+EsNTKcMPAE0XY6xWM76m sgw8V/WL8+qsLjY9VBo9gO9D4SQv67cBRxlJ8I3sU1uZ1JHqeHDo/vIHTq08HYjfRW lNRIQ8+BYFDuatl8JzamiHAPiBAUjbgVsHpMj6dclxaih++awbV1IIyn5l2KXw5VNG bH3WGhQnSuWZw== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Mon, 14 Oct 2019 16:17:29 +1100 Message-Id: <20191014051748.20190-12-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191014051748.20190-1-amitay@ozlabs.org> References: <20191014051748.20190-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v5 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 2776169..8d603e4 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, false); 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, false); len = strlen(n->dn_name); p -= len; memcpy(p, n->dn_name, len); From patchwork Mon Oct 14 05:17:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1175963 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 46s6L01ddkz9sQy for ; Mon, 14 Oct 2019 16:19:04 +1100 (AEDT) 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="v5iZeHbU"; 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 46s6Kz1B5HzDqWy for ; Mon, 14 Oct 2019 16:19:03 +1100 (AEDT) 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 46s6Jx6gP1zDqW5 for ; Mon, 14 Oct 2019 16:18:09 +1100 (AEDT) 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="v5iZeHbU"; 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 46s6Jx4GJDz9sPp; Mon, 14 Oct 2019 16:18:09 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1571030289; bh=fcLUmWRB7A9k6np9EcWpZxSJ3Siq+puiUCfmh8z1AYw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v5iZeHbU84bNe0W+CteK/wWkjwDI0l2V0+TnJyfmXkKBmnqt6/UkuUJ5uRlsxwbF3 NqtW9DvWt0QI1d/aC/8/UUT/g2j/E4qrA5zbPEg7X4v7duOOUFodhGHCWnoz2+Hnxp smrjYc+Y8n/QpDTb+6wzm7vw03cdiTs87NMmtQ5Y6+Rl+vcS4NqauQY4jqvRBCea4H jUfa7PvH2pjAHvo95scWMmOfUbXoW24HcDBh1eMZW7bqXlt2qchtc56IDaf8Vl0xdM eJW4wVQYsE32IZOYQxajpzcQObO7SoHvphkiymF+ossi+L0kG8E/7K0Y1Di40yoivo uVcWpG44ClP5Q== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Mon, 14 Oct 2019 16:17:30 +1100 Message-Id: <20191014051748.20190-13-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191014051748.20190-1-amitay@ozlabs.org> References: <20191014051748.20190-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v5 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 8d603e4..f357e99 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 Mon Oct 14 05:17:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1175965 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 46s6L85Ylkz9sR0 for ; Mon, 14 Oct 2019 16:19:12 +1100 (AEDT) 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="ph+wZoQy"; 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 46s6L83qMKzDqWy for ; Mon, 14 Oct 2019 16:19:12 +1100 (AEDT) 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 46s6Jy2zC4zDqW5 for ; Mon, 14 Oct 2019 16:18:10 +1100 (AEDT) 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="ph+wZoQy"; 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 46s6Jx6tg8z9sPh; Mon, 14 Oct 2019 16:18:09 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1571030290; bh=Duevb5mY31qJDYsoDF438B+N/TREDLz/LPoGJ8vtuYw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ph+wZoQyvGWwKaZT22q8xfqff8oqiJpw29P7loa2z7n99i6pW2nQbrBM0szpVTvSk amfZUE8OxQGKxGzLD8ujVIjOqU7BirNLUHv1QVWZ9ZQ7pgcCQJXy5iqZNETogBitPe wVOywWuwTjtjffe2XYcaujtVSbu16vYcxYnizJAFX45FetmFD4kYgJu4ot3qMDOhs1 KxoY/McZnIhKn1HdD5etZYoSMVPI09rtD94g/neeLYp9sGsXZ1jSAtVx58c4k9YOH3 9OVnwlVfCTjIWGhTQBEDJxp1rwAWfVVgg0AQH/Woe16LtViGc40u3uGORENKXGe+bc bH+txfV951jTw== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Mon, 14 Oct 2019 16:17:31 +1100 Message-Id: <20191014051748.20190-14-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191014051748.20190-1-amitay@ozlabs.org> References: <20191014051748.20190-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v5 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..0653197 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, false); + + 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 Mon Oct 14 05:17:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1175966 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 46s6LF6mDRz9sQy for ; Mon, 14 Oct 2019 16:19:17 +1100 (AEDT) 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="VyDNiQJ/"; 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 46s6LF55h4zDqW5 for ; Mon, 14 Oct 2019 16:19:17 +1100 (AEDT) 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 46s6Jz2x3tzDqWy for ; Mon, 14 Oct 2019 16:18:11 +1100 (AEDT) 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="VyDNiQJ/"; 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 46s6Jy4gg1z9sPj; Mon, 14 Oct 2019 16:18:10 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1571030290; bh=zh8jWd5zz/9w/hN44ROLNrLB3SV5bAWVdV17w33Nxe8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VyDNiQJ/Zxri+mWBUXzbKfzwM3TMTtROIqIDIBJgL8f20Gq+J6MxA9EviNRQKYhnT wcaIZfvyhnf51NRVX2VOLpJKmSzgwJXxifVWwV45icpD8LSaSI/U85gBBI+WT0SfBi jTm9A2J8blA5khPi1J+Rs/HejFHx4+0GEa0AWeO2af4G6OKohxKqJRiXWmMKyCkWrZ v2wNv7VYjXkq5y6JfkdSQ+v5XeOHBaj7ZBltrsHdgnLtNpuO1lYhGFDXJ25fqULeCH /TV39XpJhVtXJp+qDk6TAw+QRJNvEXaT1ar29TfSSWyZzHgw+jC7TVwMP4yBwi3rWJ vyiMrHfCGc2sA== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Mon, 14 Oct 2019 16:17:32 +1100 Message-Id: <20191014051748.20190-15-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191014051748.20190-1-amitay@ozlabs.org> References: <20191014051748.20190-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v5 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 0653197..9f1e887 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, false); + + parent = target->parent; + + if (!parent) + return NULL; + + return target_to_real(parent, false); +} + +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 7b8de03..627a44e 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 cbc5698..f1b5d14 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 Mon Oct 14 05:17:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1175967 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 46s6LP3QsQz9sPj for ; Mon, 14 Oct 2019 16:19:25 +1100 (AEDT) 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="KN2aANmc"; 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 46s6LM5qhczDqWy for ; Mon, 14 Oct 2019 16:19:23 +1100 (AEDT) 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 46s6Jz4xJXzDqX8 for ; Mon, 14 Oct 2019 16:18:11 +1100 (AEDT) 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="KN2aANmc"; 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 46s6Jz11VTz9sPp; Mon, 14 Oct 2019 16:18:11 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1571030291; bh=rQX77ftVlOz1+Ak40U8B8f5UwFFTCUi3hHCS1aLbzBs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KN2aANmcNXRlJtZzu/vE4kl1mAi2MUnFzpJRWOIWAnfDTqAkKz8h9R7TpRzzsaXAq Poo1sBV5+V76HD2o+O4q+fuuAel6dXhYoY6EIh4TgHPzgufxYK0asF2jheNVex+h9W k1BlNe7ru0jTqX+tppfDfxlTPpYn41T82CyWHIP6+SJQupJ7+o0XM0XMneK5ZAn5vh pbNdhUu/ri2s594XgoHoDYLJgTV2QL57IOjbfbncQqQFSMYDyFQL8lBsm/w8LC6KK0 STUG7ercnF/G65QXkIT6Soo8qHGWXL+0q6hZq3Qm/uxQzyw4KriNUp5rhb8NDuNuWb a1NgvspgCpbmw== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Mon, 14 Oct 2019 16:17:33 +1100 Message-Id: <20191014051748.20190-16-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191014051748.20190-1-amitay@ozlabs.org> References: <20191014051748.20190-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v5 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 9f1e887..913f67d 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 f1b5d14..be64142 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 Mon Oct 14 05:17:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1175968 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 46s6LS5H0Yz9sPp for ; Mon, 14 Oct 2019 16:19:28 +1100 (AEDT) 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="i6xw41NF"; 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 46s6LS3LfMzDqWY for ; Mon, 14 Oct 2019 16:19:28 +1100 (AEDT) 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 46s6K02NGszDqW9 for ; Mon, 14 Oct 2019 16:18:12 +1100 (AEDT) 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="i6xw41NF"; 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 46s6Jz6nNkz9sPh; Mon, 14 Oct 2019 16:18:11 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1571030292; bh=OzUe121+nu3L82FMBftoXxxJaw3trEMvNfclraxsOZQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i6xw41NFmxhlPXqS+QVPKJ38shbJFRAcGusFl8F34ND5I+qeNLxjt/452YASRHMMp WFwtO55UTcwKsm34McI6Lxfpzc3v3VFHiJH8T89TFirrk4ySdb3mp57RSlBKA1F68K 75SU32s3Ac9uQQ0t+0lb9GEGFX7X/RSS4LUZEj2kdPxHDiJ1DYFNZabSzuol5hUKbv Y4YrOwy5V7P27rb8qJmsa5runr9pgi89UMJOntmna1Vm5AcfG/YRZOweFmeC5VD1ND 81uwt9DENJovV0PhyIbF9mDifAl6IIXuqJUzsT68KnjoXxqEV9SYAwiyy48Mj/4FrF Jg02U9QaAr1eQ== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Mon, 14 Oct 2019 16:17:34 +1100 Message-Id: <20191014051748.20190-17-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191014051748.20190-1-amitay@ozlabs.org> References: <20191014051748.20190-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v5 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 Reviewed-by: Alistair Popple --- libpdbg/target.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libpdbg/target.c b/libpdbg/target.c index 627a44e..84aa510 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, true); + if (vnode) + 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 Mon Oct 14 05:17:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1175969 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 46s6LY355fz9sQw for ; Mon, 14 Oct 2019 16:19:33 +1100 (AEDT) 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="pdh7Bt45"; 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 46s6LY0MXyzDqW9 for ; Mon, 14 Oct 2019 16:19:33 +1100 (AEDT) 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 46s6K10P33zDqX2 for ; Mon, 14 Oct 2019 16:18:13 +1100 (AEDT) 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="pdh7Bt45"; 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 46s6K042bqz9sPj; Mon, 14 Oct 2019 16:18:12 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1571030292; bh=e9szRdHKHlcatnuku6tg40e0JCwsbxL2p264XRGsVCM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pdh7Bt45yAatOpn2WosShHJ0zly4C/WpbjMDMuQk5qEsNeCvlybAHkSu31Z2nP67C 2+7ekJo76jqyCzXkCA3/isxXBx+THlBN0ie7oVI+x3k985iu/3E/TXhSKj7cRJeyPG H2j5K5/9NH0Liu1GaGwTR2hPRXTMirh5ORpTf9R6eWKrykL5OnNCJjmEfk3eflocOq BQFPHhcVAqi6QH9QEI8hIjmbZur/OW2sAVaJLLyiuv0I8B4QbnZ1CPmeme1DGMb5i/ cD0iDMk15Lgxegpgq7+JHhTA8mOAHFoBB+xoYyDtj28oo2yolYdVHsuVlkM9ZpIzQA ySoTmO/yZZuTg== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Mon, 14 Oct 2019 16:17:35 +1100 Message-Id: <20191014051748.20190-18-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191014051748.20190-1-amitay@ozlabs.org> References: <20191014051748.20190-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v5 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 Mon Oct 14 05:17:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1175970 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 46s6Ld6VWkz9sPj for ; Mon, 14 Oct 2019 16:19:37 +1100 (AEDT) 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="Gm+tUboS"; 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 46s6Ld4VkJzDqW5 for ; Mon, 14 Oct 2019 16:19:37 +1100 (AEDT) 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 46s6K13xj9zDqX2 for ; Mon, 14 Oct 2019 16:18:13 +1100 (AEDT) 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="Gm+tUboS"; 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 46s6K11Hbqz9sPh; Mon, 14 Oct 2019 16:18:13 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1571030293; bh=6vNBj4wwobosEt2XiThD2FkKb5PYoExYsMcb1iTiCNA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gm+tUboSl5iR7e2eLaWaqXt9SbN8BTfiCP/m2DNtcbIrhg4q2MZWcyoNqOGr3OUKF JJ3wVathwPDidyPv+uYzVe0ld/StOPH8MAqruFv1WA0y3GQlTg/iOHW2TSq5blykhG WxOHeJREvLNttAK/g48Pc1p+6u1mwJRC07Ga/IhtD4n7SMaPcOuoBVNFYUM/ijSKjg gQY2cwWLlBSM0wtIlJeaEWopAvUJD2QqLawvUUJQ3Zf7DwWvt5q9s14Vf3stWquvhm ar/BgvniNTlTegWhEG4aU7/yk0+mzdfUYDCc8e4BL7AkZ5jtPUvHJArEWU75QcfvQR a7CQGkEBT3dXg== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Mon, 14 Oct 2019 16:17:36 +1100 Message-Id: <20191014051748.20190-19-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191014051748.20190-1-amitay@ozlabs.org> References: <20191014051748.20190-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v5 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 Reviewed-by: Alistair Popple --- 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 Mon Oct 14 05:17:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1175971 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 46s6Ll66x5z9sQw for ; Mon, 14 Oct 2019 16:19:43 +1100 (AEDT) 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="SYocc8JE"; 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 46s6Lj6wdXzDqXT for ; Mon, 14 Oct 2019 16:19:41 +1100 (AEDT) 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 46s6K266CpzDqXB for ; Mon, 14 Oct 2019 16:18:14 +1100 (AEDT) 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="SYocc8JE"; 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 46s6K15gZLz9sPj; Mon, 14 Oct 2019 16:18:13 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1571030294; bh=8jf5ifG8iRg48mff3bqCFPSzoIuhyfUZyjIwwyPNuNs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SYocc8JEMiNkwmXai+GsL0fUIA8t2D4oICowLuPyOQUyNFkgaNFxUofJlB3uJLV1Z 0t9N7yzlxb4DM2MEvnliD4vM1cwCJVw9Fbsg0ObNw66fnWZ1+umBureg7vmmDSV5B/ 1BUFhmcky3fTeWWW16CnEoG+yHWwt9TD+hfx0z3oSyIyk2RjvP034ygUT2whxyGGpp jDCcRFxYGhhD+Cc1cHqlzLAuviQH6iKp7Iq7njl8G3nY1x4a1PqH4R66h7TtI7zGZX DoZZQURKQSfPrKFju7zgyJZKwb0W8/FebUQRIGJfN6mvG8wYdy0JTZGISnbFu9MVbZ 6B5g0llZuIFKg== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Mon, 14 Oct 2019 16:17:37 +1100 Message-Id: <20191014051748.20190-20-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191014051748.20190-1-amitay@ozlabs.org> References: <20191014051748.20190-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v5 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: 1175972 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 46s6Lp49knz9sQr for ; Mon, 14 Oct 2019 16:19:46 +1100 (AEDT) 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="r6mwkD3e"; 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 46s6Lp1wFhzDqWF for ; Mon, 14 Oct 2019 16:19:46 +1100 (AEDT) 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 46s6K31vgGzDqW5 for ; Mon, 14 Oct 2019 16:18:15 +1100 (AEDT) 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="r6mwkD3e"; 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 46s6K24cNGz9s4Y; Mon, 14 Oct 2019 16:18:14 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1571030294; bh=4pxWD+uktFlsnIcwl+D5ozLyjMysqIe32E6UmLM5cKQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r6mwkD3edY5ePsOguxn53mE916RgeE6r8ptW/j5LI755e7u0ZVeSAz2sIb8im3qbH KmS3YgjhctWOtwwZx9LbxjgdeMP6ckJ7j2BcBEXvzagtrk1NNXoyWqKnWSmklV2kj0 OLk+GhEvzuD6kuDi/dofCGJAKjuTd4CafJX4z/EfgCO5eXSpENxuOOcN3sIHM3FJs7 jlbAbLRy90LNLb3KwhejPjLMm4HzZXEzqWM+gDgOE3+YtH0t72jQn3bysCdevO7wz7 jfxLNKJxnYkFg+taT4ofSw+IkjBVnV2LZQ+J5mBQXUOC7yoEhA1WvMJFTXZXNIC1vn Inti4MaTFmCUw== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Mon, 14 Oct 2019 16:17:38 +1100 Message-Id: <20191014051748.20190-21-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191014051748.20190-1-amitay@ozlabs.org> References: <20191014051748.20190-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v5 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 Mon Oct 14 05:17:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1175973 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 46s6Ls3Xqyz9sQr for ; Mon, 14 Oct 2019 16:19:49 +1100 (AEDT) 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="jDidwV6w"; 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 46s6Ls1GK2zDqXT for ; Mon, 14 Oct 2019 16:19:49 +1100 (AEDT) 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 46s6K36X6WzDqX8 for ; Mon, 14 Oct 2019 16:18:15 +1100 (AEDT) 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="jDidwV6w"; 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 46s6K336pcz9sPj; Mon, 14 Oct 2019 16:18:15 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1571030295; bh=AW48dfIIaSyYji+RiyeINgDh211/3KVhjHkGXdxGrMU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jDidwV6wRJ+bXVhJIRpuM+F8AzG/l5DIZNfry13K/PT8C+5NsY82eKSTPuowJdJZq v18bbyTXR/Sir9V7O6w7hvfHfPLhaUBaZimDl3cwHtfwrZz/ekX6d6LvLlN7V24Pgr VsHm/sClESQw/sSdCBVHPID5844kFhG4C7nCoWrcSJ4KbzGMZ+evCNiH0ADebXxpo0 hrm4TFms+eJH4vTjtbtfN6QTCyOeIp1oE5Xzp0wCjSeNAYhyuF+JRrdGlB6CFKPJCD 9E1eYzZGy5gu2wPrhxXwu8LLcUQsis3BsXqiQODaPRbO84gwFGapmTky4DdlvNWp/I SiNcqHK1ObdyQ== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Mon, 14 Oct 2019 16:17:39 +1100 Message-Id: <20191014051748.20190-22-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191014051748.20190-1-amitay@ozlabs.org> References: <20191014051748.20190-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v5 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: 1175974 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 46s6Lw6ks3z9sPh for ; Mon, 14 Oct 2019 16:19:52 +1100 (AEDT) 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="sf8qKp9N"; 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 46s6Lw32Q4zDqWy for ; Mon, 14 Oct 2019 16:19:52 +1100 (AEDT) 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 46s6K42y8vzDqWY for ; Mon, 14 Oct 2019 16:18:16 +1100 (AEDT) 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="sf8qKp9N"; 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 46s6K36k5fz9s4Y; Mon, 14 Oct 2019 16:18:15 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1571030296; bh=8BVnVHA9mzIo0xW7pslPSjKlD0php7qvMPmc/gH6WT8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sf8qKp9NkMTV2xS08uQywhNXuJWnWuV4MTwzlr6UWsu6/DBO4j2bZqXMxe3plkK5x AbUc8TAOjYXJRBbqpZrM9usUg7uKUVPZR6Vd99MfvMfOP0p5gGMq1QjsK5ZOQ8a8gG y7GJQlEltvFrEsUw70Wa1sgTdE0sfy6ZVED9VvHTq4ud0rqKO7L+AO225ZWvu18DB3 2QaeGa4wYpKXMmL/SW0Y1DtZQXOAZPMJVr2uaaVNBWGjLuxZoxrjOQw8JHasL6nkAf 7YfSNn4BY29QZ/1U5UFWLf50gQopAPFtKzJiFDNmAtWApKbVr7HqCq7+iGoVumk/24 zMMqhtyYwmunw== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Mon, 14 Oct 2019 16:17:40 +1100 Message-Id: <20191014051748.20190-23-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191014051748.20190-1-amitay@ozlabs.org> References: <20191014051748.20190-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v5 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 f357e99..ef09019 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 Mon Oct 14 05:17: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: 1175975 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 46s6M01Ppfz9sPp for ; Mon, 14 Oct 2019 16:19:56 +1100 (AEDT) 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="e/LlnkvS"; 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 46s6Lz6nBTzDqXJ for ; Mon, 14 Oct 2019 16:19:55 +1100 (AEDT) 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 46s6K50sb7zDqWY for ; Mon, 14 Oct 2019 16:18:17 +1100 (AEDT) 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="e/LlnkvS"; 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 46s6K43Fk0z9sPp; Mon, 14 Oct 2019 16:18:16 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1571030296; bh=PUsy93DlblNPxU6iHi3Qn9aTHNesG5OceDfzbcNTna8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e/LlnkvS6Wr2dtAOjYgojIC5oulGId9TZoh93DTjEg/g5ytPsdDpsor6UItY1jjbo oX6SUmWbIprcudTUHKBJxQf5obiLwQOkJwwJvqlrt1SJJuD0DNxZlve1FRiauqqm9b ZH3riLRWUsL80ohwRdUOVL4TAQRV33k6vPARZCuJtqzAL70mDEDJyT/lPV6EGmbDxz vK3XSsXlkzFHIZ+2lPH6kED9XRIn1gv0p1KuUu/egGdILg+4weeTfZybH4i6N9oQgJ kB3B9+qMzsYUqk4vGEo4tTCkUO3D+fMnTYvCluB8tPY1jkppeqqxwQ5AFAUdDS8PdZ 2OkxdumlF5H+w== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Mon, 14 Oct 2019 16:17:41 +1100 Message-Id: <20191014051748.20190-24-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191014051748.20190-1-amitay@ozlabs.org> References: <20191014051748.20190-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v5 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 ef09019..6d9a93a 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 Mon Oct 14 05:17: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: 1175976 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 46s6M31j16z9s4Y for ; Mon, 14 Oct 2019 16:19:59 +1100 (AEDT) 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="vBWBEkZK"; 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 46s6M30CGwzDqWN for ; Mon, 14 Oct 2019 16:19:59 +1100 (AEDT) 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 46s6K56BPjzDqWN for ; Mon, 14 Oct 2019 16:18:17 +1100 (AEDT) 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="vBWBEkZK"; 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 46s6K51F2Hz9s4Y; Mon, 14 Oct 2019 16:18:17 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1571030297; bh=ozZw8jTt1nYGYERBSteswATcBLxBl2jshGT3xwAaXiQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vBWBEkZKeKQ1r7RpOvHbqdqByI2fLHwWd/KkisNBsUfPXkc9lmkyZ+3NSXZdOYkJ3 J7FBSrQBurtgurRVwJMMw56FzoOhhReEQqNx4XjCKtXaQobFb+SO+lmjGhdBXHdOvF D7FqhTSCVCBavGV1ngEVoYh6R66CZAnnl9m5K7pUw7FhPjl5IIScMPTet5z1vfEfwX k5NTMI1Kmo66Z7+YZpEoj6jBpafEILrpao6Z/rWzw75dx7Hv3d3YQbOQsWQ6rLmke0 a3uxmRlIBNdIFtZHKrDUc1fkfJXOysRXebbdSTXNgoqmqhuvG0YazvFeZzEmKhhOZx kq9HByX7XtLqA== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Mon, 14 Oct 2019 16:17:42 +1100 Message-Id: <20191014051748.20190-25-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191014051748.20190-1-amitay@ozlabs.org> References: <20191014051748.20190-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v5 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 Mon Oct 14 05:17: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: 1175977 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 46s6M61gGwz9s4Y for ; Mon, 14 Oct 2019 16:20:02 +1100 (AEDT) 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="Qqx6HlVV"; 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 46s6M56kyGzDqWY for ; Mon, 14 Oct 2019 16:20:01 +1100 (AEDT) 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 46s6K62GNNzDqX8 for ; Mon, 14 Oct 2019 16:18:18 +1100 (AEDT) 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="Qqx6HlVV"; 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 46s6K55bk3z9sPh; Mon, 14 Oct 2019 16:18:17 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1571030297; bh=+XVmVAt4fUo1yXLzj7UwrdFrLqPLULt4b9KB369F03M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qqx6HlVVmiALJaqUJ/UZ8XzSnZJooPgfoclxVgIcm7lDhrIEaCw0pXlcYdNOnbD0Y DzziXIv4b/IXRfyY9WBv29JrZTsMO5xvDM8ZlcP841qanFfQ9fChtpxAxrmIqoIqj2 z8a43+4FG/C6GDsVNEVpySlamjme/auIlM/9wYNdEdXU6dJV39inqBBjGFiJgmOBWY ms/Fl9UgDS+rjSN+fw99ofqoGhf5wmKArSjcTK0wsF1F8KrOuSLE/LZmaUS03DGmpj +/Hl6evve9u60f1SBErKAXv1HYV+PA7zHVB1vTMyAzhUg65FOY3mjgM3GQpTDWnhyG 1ngS0Hk6pf7BA== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Mon, 14 Oct 2019 16:17:43 +1100 Message-Id: <20191014051748.20190-26-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191014051748.20190-1-amitay@ozlabs.org> References: <20191014051748.20190-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v5 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 be64142..cec8f9d 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 Mon Oct 14 05:17: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: 1175978 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 46s6M90BYbz9sPh for ; Mon, 14 Oct 2019 16:20:05 +1100 (AEDT) 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="qy+CeHzZ"; 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 46s6M85n35zDqX2 for ; Mon, 14 Oct 2019 16:20:04 +1100 (AEDT) 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 46s6K70VYWzDqWw for ; Mon, 14 Oct 2019 16:18:19 +1100 (AEDT) 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="qy+CeHzZ"; 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 46s6K6326Wz9sQr; Mon, 14 Oct 2019 16:18:18 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1571030298; bh=Vl71CIF/nO5pn6T/OYq2nZzms8Ask6WamnS4OU2QE+Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qy+CeHzZZuwh1jGZG3t5+ONYQ+zigvuZn+FT7AkvV5A+QCfe5ZMq7urTHbZY7F/dT pDiSvbXpzzO6htFwQXSQzia+b0c6FWmbUYwBrxnJ/5/SEtUA21shwElMBxDm6Gaozt Bn/xZRlM/z3yNW77QmaDgeunsyOxeiACpibeuF2M9k9NGW81d80xTK+b1mNWvA7m+n k5Lie66X94bp4mHqqV4CBxDCpAWVBQwwjzLlWXZPGeoXdL0nVt8dScNUttkynBx5c1 sAceeFlKROHKaIR0Qr1W+540xuz3Pu3/Daazp/132aHEckjD5DqRcggNisnGTROT5B +yZ3GOSzr89FA== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Mon, 14 Oct 2019 16:17:44 +1100 Message-Id: <20191014051748.20190-27-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191014051748.20190-1-amitay@ozlabs.org> References: <20191014051748.20190-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v5 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 6d9a93a..06bbeaf 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 cec8f9d..c8839a9 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 Mon Oct 14 05:17: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: 1175979 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 46s6MC4hBwz9sPj for ; Mon, 14 Oct 2019 16:20:07 +1100 (AEDT) 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="mfE54gUf"; 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 46s6MC2lrdzDqW9 for ; Mon, 14 Oct 2019 16:20:07 +1100 (AEDT) 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 46s6K75BggzDqWw for ; Mon, 14 Oct 2019 16:18:19 +1100 (AEDT) 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="mfE54gUf"; 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 46s6K72KK2z9s4Y; Mon, 14 Oct 2019 16:18:19 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1571030299; bh=7/t6QdrZw85/CsGGi2lK/Klt+D2TYsovGM9Y4OcCge0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mfE54gUfmU4QWapW0bO337TV134sG5jyazRybqvwcbK+NsNymZI8vW01+hsOQss1g LUg6l3UymBgsxh3nWLKrKalUza/vIf6caCyKQZMpnZkyoNDNarc+lAL48OIYLDDm7x UPWiESqwRr8YqZsKgfoFKf/jnslsmvkyH6/eqXGnBoNOORpRcLhoOwxmz9xjZwCj6n dRt4VLLu6CYzBx1fRcsQwo27Mf0PO2zgYBCal7FkhbQvu5bhj8iLYzzbe+EJrvXveO r6CRLaaPdWGVa2UvfLUIpBOOwPHkASBTk4BhHPH4wlyxajFPOHaZzGaCrVG+olX14T YN+JTDCp916Gg== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Mon, 14 Oct 2019 16:17:45 +1100 Message-Id: <20191014051748.20190-28-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191014051748.20190-1-amitay@ozlabs.org> References: <20191014051748.20190-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v5 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 06bbeaf..54a1d1d 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 c8839a9..35e822b 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 Mon Oct 14 05:17: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: 1175980 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 46s6MJ3tSxz9sPp for ; Mon, 14 Oct 2019 16:20:12 +1100 (AEDT) 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="IrrdMofn"; 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 46s6MH2x9VzDqWF for ; Mon, 14 Oct 2019 16:20:11 +1100 (AEDT) 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 46s6K81M58zDqX8 for ; Mon, 14 Oct 2019 16:18:20 +1100 (AEDT) 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="IrrdMofn"; 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 46s6K75MKcz9sPj; Mon, 14 Oct 2019 16:18:19 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1571030299; bh=8/wYbS6x9FKgXfmU0cXQ1Tnm9dVxIuREh+R/9y5AwVg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IrrdMofn+jT7Hs/24gzLjz+0od8XQuE6U+ulH3WbkP7p6a0hDs4BX2LpZaCiX9JJN EcI951p+4XQbNzVpN6nafNGLVs7RAA+TKHvYybw4/dmbRl+z9ezOTvx6lmr+q/w2JV FqSUc+cSfe0jMuXDopIYUgRVVjsXP8uXzLfj04tWWpSd118be/pHX4jYf+/tQ8nH2w KoL5nZB77A6R9VvOGNLMBZ9ke59DBup95tadXSNL+7dzXrjFjJloip19v47IuzHCwT W/Exn2WV4+X1ut0tppF0fLNlTltJP6P/kvd0NGxIu7cUI+A8ciSKogNlec9CTB1hzH BE2lka+CvHiBQ== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Mon, 14 Oct 2019 16:17:46 +1100 Message-Id: <20191014051748.20190-29-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191014051748.20190-1-amitay@ozlabs.org> References: <20191014051748.20190-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v5 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 Mon Oct 14 05:17: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: 1175981 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 46s6MP01JTz9sPh for ; Mon, 14 Oct 2019 16:20:17 +1100 (AEDT) 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="LC1FV2tU"; 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 46s6MN5xzmzDqW5 for ; Mon, 14 Oct 2019 16:20:16 +1100 (AEDT) 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 46s6K85q1BzDqX2 for ; Mon, 14 Oct 2019 16:18:20 +1100 (AEDT) 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="LC1FV2tU"; 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 46s6K81lFgz9sPp; Mon, 14 Oct 2019 16:18:20 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1571030300; bh=vopnkNC4EcuPPJlss0Ul8UlhC8ZaPIrCxqpC4pWyBJs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LC1FV2tU8jvoFPTNQLvh5pSm/Ftwj3WqzEMO2gP/H9jP3KV3p0X1TsZ3FC97lfI0U 7c+6YlMuFKfniq2HrjObIprmMzNsOuKUmOhESuetXPlBla5Ie20zRp4RMAVHHypZWs GQGR624g1KPmCjTpnBRgPR7Am/MRVRSYAvN7hX+HyHBORrWOUvJR4QFZ3mnFYDUFKK BrZj6UEU9PkxE6SJs+syciYBVrkpRaVvTBUvi3A0Pr1nxDu7kJ3oowBmhKty0bo0Ia du7k1fJRJqgJCiWRPMzAjj276sluAk40FXDIrt92VGwgMnZQi/8rdmvabEfyWgMu74 y7XY33nCNZN6A== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Mon, 14 Oct 2019 16:17:47 +1100 Message-Id: <20191014051748.20190-30-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191014051748.20190-1-amitay@ozlabs.org> References: <20191014051748.20190-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v5 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 Mon Oct 14 05:17: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: 1175982 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 46s6MS5H0kz9sPj for ; Mon, 14 Oct 2019 16:20:20 +1100 (AEDT) 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="poP+XbXU"; 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 46s6MS0GX2zDqWw for ; Mon, 14 Oct 2019 16:20:20 +1100 (AEDT) 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 46s6KB1sqzzDqX2 for ; Mon, 14 Oct 2019 16:18:22 +1100 (AEDT) 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="poP+XbXU"; 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 46s6K86cdGz9s4Y; Mon, 14 Oct 2019 16:18:20 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1571030301; bh=F2TCC2v69Ser7aexEfAkVCrlNh51d4yIO0vlc3MQo1g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=poP+XbXU9hLMh8K6uwoYj8BprPJaRAhwj7dn6aVjCZYMcnVssSblwesq26z98m+87 k2aPwUQccLa9SD4gmauC4PLWOrqOyYPedPmtuvIsdOGIzQ1PmIVRM44mHbQNVMgTbB +0GLKFPIx7/UwPe6BzBOH03s+evQYVosRNlUiwZY4PTXqlqcIOuy9bECNdaXC+ffbG uV1FL3yEGlZnUUYgK8TqpIeUXp0ciFQ29+ioE7SSSRflAkQ4AVdmLsvGdk3uMAcoz5 +IMPxpQr2xNFl+HWJK5l5JGCeuycAp4k7EqQPzouM/Q6lLKZtVtWscUaEmEzsiHgJT jt6JaxvfURG5A== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Mon, 14 Oct 2019 16:17:48 +1100 Message-Id: <20191014051748.20190-31-amitay@ozlabs.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191014051748.20190-1-amitay@ozlabs.org> References: <20191014051748.20190-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v5 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: