From patchwork Tue Nov 20 04:19:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1000261 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42zXYX3hp4z9s8r for ; Tue, 20 Nov 2018 15:20:16 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (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="yKfSaAqc"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42zXYX1bv6zF3Sc for ; Tue, 20 Nov 2018 15:20:16 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="yKfSaAqc"; dkim-atps=neutral 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)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42zXYG5hZTzF3RC for ; Tue, 20 Nov 2018 15:20:02 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (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="yKfSaAqc"; 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 42zXYG0bwvz9s8r; Tue, 20 Nov 2018 15:20:02 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1542687602; bh=bV0+3bYLdmQGTO7SM6uqAHKXpyR/eZrQKa0zUPToYb8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yKfSaAqc8NmnupCYFfV3sBVrOSOvVFcdlLxEp3AjraI1Yb2PL6R1NPl8GPECz6tR5 v88mxeG+0NN6A5uOxWmBcQCID7ZPNXjN/CEUL1Sem2gOy/7gwSR2sOpe7iRId/ReJ4 Hfr1HbTiD/i8+IHouhogeYBSBskZEnzrh648e7TMo4uwUVrBe3sir86VePDmw4qKjk qBNQf1zJev5slQ2xm4vxVWAfk7Nt5SVaCfyHWDHzD5mmvyaIt+g0DNY6mecFzhl9ie tTWHiY7Bdj0xDeXoiKTXeT2+zDXjYq95wFvhnGOdg2MZJD0vwRFSyIsCszlw0e+V7a fix4dX7sMt2/w== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Tue, 20 Nov 2018 15:19:46 +1100 Message-Id: <20181120041953.402413-3-amitay@ozlabs.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120041953.402413-1-amitay@ozlabs.org> References: <20181120041953.402413-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 2/9] main: Convert getring to path based targeting X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs --- src/ring.c | 56 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/src/ring.c b/src/ring.c index 58df4d1..1e40db6 100644 --- a/src/ring.c +++ b/src/ring.c @@ -24,36 +24,56 @@ #include "main.h" #include "optcmd.h" +#include "path.h" -static int pdbg_getring(struct pdbg_target *target, uint32_t index, uint64_t *addr, uint64_t *len) +static int get_ring(uint64_t ring_addr, uint64_t ring_len) { + struct pdbg_target *target; uint32_t *result; - int i, words; - int ring_len = *len; + int count = 0; + int words; - words = (ring_len + 32 - 1)/32; + words = (ring_len + 32 - 1) / 32; result = calloc(words, sizeof(*result)); assert(result); - getring(target, *addr, ring_len, result); + for_each_path_target_class("chiplet", target) { + char *path; + int rc, i, len; - for (i = 0; i < ring_len/32; i++) - printf("%08" PRIx32, result[i]); + if (pdbg_target_status(target) != PDBG_TARGET_ENABLED) + continue; - ring_len -= i*32; + path = pdbg_target_path(target); + assert(path); - /* Print out remaining bits */ - for (i = 0; i < (ring_len + 4 - 1)/4; i++) - printf("%01" PRIx32, (result[words - 1] >> (28 - i*4)) & 0xf); + printf("%s: 0x%016" PRIx64 " = ", path, ring_addr); + free(path); - printf("\n"); + rc = getring(target, ring_addr, ring_len, result); + if (rc) { + printf("failed\n"); + continue; + } - return 1; -} + printf("\n"); -static int _getring(uint64_t ring_addr, uint64_t ring_len) -{ - return for_each_target("chiplet", pdbg_getring, &ring_addr, &ring_len); + len = (int)ring_len; + for (i = 0; i < len/32; i++) + printf("%08" PRIx32, result[i]); + + len -= i*32; + + for (i=0; i < (len + 4 - 1)/4; i++) + printf("%01" PRIx32, (result[words-1] >> (28 - i*4)) & 0xf); + + printf("\n"); + + count++; + } + + free(result); + return count; } -OPTCMD_DEFINE_CMD_WITH_ARGS(getring, _getring, (ADDRESS, DATA)); +OPTCMD_DEFINE_CMD_WITH_ARGS(getring, get_ring, (ADDRESS, DATA));