aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver O'Halloran <oohall@gmail.com>2017-08-17 16:44:41 +1000
committerStewart Smith <stewart@linux.vnet.ibm.com>2017-08-21 11:58:19 +1000
commit2a54e4f87be5c39baecf9403f0faac5121d23358 (patch)
tree329ed2e85eb6cd40aa29fc25367191046e8cf3e1
parentb503dcf16d28f75f145f022c3e9c0ca97dd240e0 (diff)
downloadskiboot-2a54e4f87be5c39baecf9403f0faac5121d23358.zip
skiboot-2a54e4f87be5c39baecf9403f0faac5121d23358.tar.gz
skiboot-2a54e4f87be5c39baecf9403f0faac5121d23358.tar.bz2
external/xscom-utils: Add --list-bits
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 <oohall@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
-rw-r--r--external/xscom-utils/getscom.c27
-rw-r--r--external/xscom-utils/putscom.c25
-rw-r--r--external/xscom-utils/sram.c3
-rw-r--r--external/xscom-utils/xscom.h4
4 files changed, 50 insertions, 9 deletions
diff --git a/external/xscom-utils/getscom.c b/external/xscom-utils/getscom.c
index a46c82b..8c96634 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 ca8c0da..84b6f89 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 74ad996..721adee 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 5f9edbc..4932315 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 */