From patchwork Thu Aug 17 06:44:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 802367 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.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xXxXx0VhDz9t3B for ; Thu, 17 Aug 2017 16:45:05 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="dxFE0qNa"; 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 3xXxXw6N5YzDrLL for ; Thu, 17 Aug 2017 16:45:04 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="dxFE0qNa"; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from mail-pg0-x244.google.com (mail-pg0-x244.google.com [IPv6:2607:f8b0:400e:c05::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3xXxXl0FHLzDrKm for ; Thu, 17 Aug 2017 16:44:55 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="dxFE0qNa"; dkim-atps=neutral Received: by mail-pg0-x244.google.com with SMTP id 123so8312208pga.5 for ; Wed, 16 Aug 2017 23:44:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=uCnAdVExLrMzqMWNzYUXbV4NhyA7MSUdxu9WyF+oOqE=; b=dxFE0qNa+elJN5exun0rre60bLQVXt95oxNsxILmaQkwu1Cqal38l6qBVyBmrytZT8 /wDUtDcks9gymuOVrZp94zBcfqZp5elBZ//3WI+flpUK+FwyLWFi4bBWKniqj41/6B6h TNokoF9imk5rIWquLer1H9x6xmWtb6x9Z3p+xMftgRtcpb6TjOnVG0RaTL2/MWw1YaAG 3a5ids4oX8Z4XsFRCC+6SXjVqAV9QTGTPc6tZyr976GMS8xbbeaY2xqcrzb+uYL4l93G 2WwhuFYAKBNvuH/vDOZAnWY6YWgH8LDW8OdsaFmzj46Ga1Z8vFrFao4ljttaTifzSxlu tJhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=uCnAdVExLrMzqMWNzYUXbV4NhyA7MSUdxu9WyF+oOqE=; b=Z3KysqDbbytcMuHTCbBi7p8ajLBJt6VHmau4NdMYJpFxs6026crit6/nitxQv2TLNe Tyl+dD2o8A8M4UOfR31ZdF6V69gOJ9HBxGE4hpNomi2G4aefYAM1dRsZo+3jfOtsvPcG jp+xqWajZejMO1TUKEG9/CPj0HCLxp6M+k/RhbqWCPpaiOqlLMrD0X0By8iByqoT6ihS +yITFpaswG1rJyETjdB1kGcVNW71KpeUkJIJne38OZdfhGr5gk0xM+sITs4KUxLimGyW pCzqbCFeieXERDOunIrUkjPe+oLGcQ/jX/xItPzYG27UGAYl3FqwcN9WFHKX0E43fU3D FiGA== X-Gm-Message-State: AHYfb5gmroYpFmMunl6iT59zEeBC5dUXQaL8zEC9KVmVCPflHxwXYp76 37U4UeLJ4+GDXb7x X-Received: by 10.98.22.71 with SMTP id 68mr4228362pfw.248.1502952292822; Wed, 16 Aug 2017 23:44:52 -0700 (PDT) Received: from flat-canetoad.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id v78sm5470786pfd.121.2017.08.16.23.44.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Aug 2017 23:44:52 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Thu, 17 Aug 2017 16:44:41 +1000 Message-Id: <20170817064441.19917-1-oohall@gmail.com> X-Mailer: git-send-email 2.9.4 Subject: [Skiboot] [PATCH] external/xscom-utils: Add --list-bits X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" When using getscom/putscom it's helpful to know what bits are set in the register. This patch adds an option to print out which bits are set along with the value that was read/written to the register. Note that this output indicates which bits are set using the IBM bit ordering since that's what the XSCOM documentation uses. Signed-off-by: Oliver O'Halloran --- external/xscom-utils/getscom.c | 27 ++++++++++++++++++++++++--- external/xscom-utils/putscom.c | 25 ++++++++++++++++++++++--- external/xscom-utils/sram.c | 3 --- external/xscom-utils/xscom.h | 4 ++++ 4 files changed, 50 insertions(+), 9 deletions(-) diff --git a/external/xscom-utils/getscom.c b/external/xscom-utils/getscom.c index a46c82b1f8fa..8c9663460d88 100644 --- a/external/xscom-utils/getscom.c +++ b/external/xscom-utils/getscom.c @@ -25,9 +25,11 @@ static void print_usage(int code) { - printf("usage: getscom [-c|--chip chip-id] addr\n"); + printf("usage: getscom [-c|--chip chip-id] [-b|--list-bits] addr\n"); printf(" getscom -l|--list-chips\n"); printf(" getscom -v|--version\n"); + printf("\n"); + printf(" NB: --list-bits shows which PPC bits are set\n"); exit(code); } @@ -88,6 +90,7 @@ int main(int argc, char *argv[]) uint32_t def_chip, chip_id = 0xffffffff; bool list_chips = false; bool no_work = false; + bool list_bits = false; int rc; while(1) { @@ -96,10 +99,11 @@ int main(int argc, char *argv[]) {"list-chips", no_argument, NULL, 'l'}, {"help", no_argument, NULL, 'h'}, {"version", no_argument, NULL, 'v'}, + {"list-bits", no_argument, NULL, 'b'}, }; int c, oidx = 0; - c = getopt_long(argc, argv, "-c:hlv", long_opts, &oidx); + c = getopt_long(argc, argv, "-c:bhlv", long_opts, &oidx); if (c == EOF) break; switch(c) { @@ -115,6 +119,9 @@ int main(int argc, char *argv[]) case 'l': list_chips = true; break; + case 'b': + list_bits = true; + break; case 'v': printf("xscom utils version %s\n", version); exit(0); @@ -150,7 +157,21 @@ int main(int argc, char *argv[]) fprintf(stderr,"Error %d reading XSCOM\n", rc); exit(1); } - printf("%016" PRIx64 "\n", val); + + printf("%016" PRIx64, val); + + if (list_bits) { + int i; + + printf(" - set: "); + + for (i = 0; i < 64; i++) + if (val & PPC_BIT(i)) + printf("%d ", i); + } + + putchar('\n'); + return 0; } diff --git a/external/xscom-utils/putscom.c b/external/xscom-utils/putscom.c index ca8c0da30537..84b6f897f3e5 100644 --- a/external/xscom-utils/putscom.c +++ b/external/xscom-utils/putscom.c @@ -25,8 +25,11 @@ static void print_usage(int code) { - printf("usage: putscom [-c|--chip chip-id] addr value\n"); + printf("usage: putscom [-c|--chip chip-id] [-b|--list-bits] addr value\n"); printf(" putscom -v|--version\n"); + printf("\n"); + printf(" NB: --list-bits shows which PPC bits are set\n"); + exit(code); exit(code); } @@ -37,6 +40,7 @@ int main(int argc, char *argv[]) uint64_t val = -1ull, addr = -1ull; uint32_t def_chip, chip_id = 0xffffffff; bool got_addr = false, got_val = false; + bool list_bits = false; int rc; while(1) { @@ -47,7 +51,7 @@ int main(int argc, char *argv[]) }; int c, oidx = 0; - c = getopt_long(argc, argv, "-c:hv", long_opts, &oidx); + c = getopt_long(argc, argv, "-c:bhv", long_opts, &oidx); if (c == EOF) break; switch(c) { @@ -63,6 +67,9 @@ int main(int argc, char *argv[]) case 'c': chip_id = strtoul(optarg, NULL, 16); break; + case 'b': + list_bits = true; + break; case 'v': printf("xscom utils version %s\n", version); exit(0); @@ -99,7 +106,19 @@ int main(int argc, char *argv[]) exit(1); } } - printf("%016" PRIx64 "\n", val); + + printf("%016" PRIx64, val); + if (list_bits) { + int i; + + printf(" - set: "); + + for (i = 0; i < 64; i++) + if (val & PPC_BIT(i)) + printf("%d ", i); + } + + putchar('\n'); return 0; } diff --git a/external/xscom-utils/sram.c b/external/xscom-utils/sram.c index 74ad9967c969..721adee6569d 100644 --- a/external/xscom-utils/sram.c +++ b/external/xscom-utils/sram.c @@ -24,9 +24,6 @@ #define DBG(fmt...) do { if (verbose) printf(fmt); } while(0) #define ERR(fmt...) do { fprintf(stderr, fmt); } while(0) -#define PPC_BIT(bit) (0x8000000000000000UL >> (bit)) - - #define OCB_PIB_OCBCSR0_0x0006B011 0x0006B011 #define OCB_PIB_OCBCSR0_ANDx0006B012 0x0006B012 #define OCB_PIB_OCBCSR0_ORx0006B013 0x0006B013 diff --git a/external/xscom-utils/xscom.h b/external/xscom-utils/xscom.h index 5f9edbc9b347..49323158bfbe 100644 --- a/external/xscom-utils/xscom.h +++ b/external/xscom-utils/xscom.h @@ -31,4 +31,8 @@ extern bool xscom_readable(uint64_t addr); extern uint32_t xscom_init(void); +#ifndef PPC_BIT +#define PPC_BIT(bit) (0x8000000000000000UL >> (bit)) +#endif + #endif /* __XSCOM_H */