From patchwork Fri Nov 9 07:10:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 995381 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42rrt23B5bz9s1x for ; Fri, 9 Nov 2018 18:11:22 +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="LcTIgcUH"; 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 42rrt21C5tzF3bS for ; Fri, 9 Nov 2018 18:11:22 +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="LcTIgcUH"; 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 42rrrz1bCrzF3ZM for ; Fri, 9 Nov 2018 18:10:27 +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="LcTIgcUH"; 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 42rrry6LT9z9s1x; Fri, 9 Nov 2018 18:10:26 +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=1541747426; bh=d1qRh74MYhSPKvq08clRKorQzn1EnA5BucC8Jh4n1f8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LcTIgcUHIOC82w+GWPurgeGq39Fcqlvwu3BiSg8NP8QT9Zijj3CquOHm4/+FHvsOe d5UEGTZd8IjC1WHWqwL46BZxKb1t9UhRdJGLMTTx5y1DxTsm1BbFkCrFZD3jz5QQpT BnhfoBKPz2pxJX/DlvVqYXakiMguSiNr57XSxCmNvDyF4MnzTCvqRdPGWIGJqGWKCB yKBo31qgk0M8kjU7w/ibO0YOH1aTh7fkNPyOhWQp8n7JGALJSYp0Diz4Kfnr4oQ92I 4ApiCZmcIjCYCum2gr192CiwWRe+sjaStagJrXVwydMwcFfRYaqewVcmWlQkrPtwfW ziY7dBLdwDQyA== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Fri, 9 Nov 2018 18:10:10 +1100 Message-Id: <20181109071011.253734-15-amitay@ozlabs.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181109071011.253734-1-amitay@ozlabs.org> References: <20181109071011.253734-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v2 14/15] main: Convert getscom/putscom to use 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/scom.c | 87 +++++++++++++++++++++++++++++++++++--------- tests/test_hw_bmc.sh | 2 +- 2 files changed, 70 insertions(+), 19 deletions(-) diff --git a/src/scom.c b/src/scom.c index 2372e91..ad70523 100644 --- a/src/scom.c +++ b/src/scom.c @@ -18,41 +18,92 @@ #include #include #include +#include #include #include "main.h" #include "optcmd.h" +#include "path.h" -static int _getscom(struct pdbg_target *target, uint32_t index, uint64_t *addr, uint64_t *unused) +/* Check if a target has scom region */ +static bool scommable(struct pdbg_target *target) { - uint64_t value; - - if (pib_read(target, *addr, &value)) - return 0; + char *classname; - printf("p%d:0x%" PRIx64 " = 0x%016" PRIx64 "\n", index, *addr, value); + classname = pdbg_target_class_name(target); + if (!strcmp(classname, "pib") || + !strcmp(classname, "core") || + !strcmp(classname, "thread")) + return true; - return 1; + return false; } - int getscom(uint64_t addr) +int getscom(uint64_t addr) { - return for_each_target("pib", _getscom, &addr, NULL); + struct pdbg_target *target; + char *path; + uint64_t value; + int count = 0; + + for_each_path_target(target) { + if (pdbg_target_status(target) != PDBG_TARGET_ENABLED) + continue; + + path = pdbg_target_path(target); + assert(path); + + if (!scommable(target)) { + printf("%s: invalid target\n", path); + free(path); + continue; + } + + if (pib_read(target, addr, &value)) { + printf("%s: failed\n", path); + free(path); + continue; + } + + printf("%s: 0x%" PRIx64 " = 0x%016" PRIx64 "\n", path, addr, value); + free(path); + count++; + } + + return count; } OPTCMD_DEFINE_CMD_WITH_ARGS(getscom, getscom, (ADDRESS)); -static int _putscom(struct pdbg_target *target, uint32_t index, uint64_t *addr, uint64_t *data) +int putscom(uint64_t addr, uint64_t data, uint64_t mask) { - if (pib_write(target, *addr, *data)) - return 0; + struct pdbg_target *target; + char *path; + int count = 0; - return 1; -} + for_each_path_target(target) { + if (pdbg_target_status(target) != PDBG_TARGET_ENABLED) + continue; - int putscom(uint64_t addr, uint64_t data, uint64_t mask) -{ - /* TODO: Restore the functionality */ - return for_each_target("pib", _putscom, &addr, &data); + path = pdbg_target_path(target); + assert(path); + + if (!scommable(target)) { + printf("%s: invalid target\n", path); + free(path); + continue; + } + + /* TODO: Restore the functionality */ + if (pib_write(target, addr, data)) { + printf("%s: failed\n", path); + free(path); + continue; + } + + count++; + } + + return count; } OPTCMD_DEFINE_CMD_WITH_ARGS(putscom, putscom, (ADDRESS, DATA, DEFAULT_DATA("0xffffffffffffffff"))); diff --git a/tests/test_hw_bmc.sh b/tests/test_hw_bmc.sh index 9bc1deb..d656a3f 100755 --- a/tests/test_hw_bmc.sh +++ b/tests/test_hw_bmc.sh @@ -91,7 +91,7 @@ do_skip test_run $PDBG -P fsi getcfam 0xc09 test_result 0 <