summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorEugeni Dodonov <eugeni.dodonov@intel.com>2012-02-28 17:40:32 -0300
committerEugeni Dodonov <eugeni.dodonov@intel.com>2012-03-13 17:55:51 -0300
commitbe7ca950d7d4d18744a76abab091eb032835fb82 (patch)
tree31ba08ac94b82df6b233371312750d338a0bd862 /tools
parent8d4545642835cb66f84739b9384f31920feacdba (diff)
intel_reg_read: add a flag to simplify bit decoding
This allows to specify '-d' parameter which will decode individual bits in each register being read. The register bits are printed horizontally for space reasons. This requires more than 80x25 terminal to see them all. An alternative solution would be to print them vertically, but this will become much more difficult to read when printing multiple registers at the same time. v2: fix spacing to get us a bit closer to the code nirvana. Signed-off-by: Eugeni Dodonov <eugeni.dodonov@intel.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/intel_reg_read.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/tools/intel_reg_read.c b/tools/intel_reg_read.c
index 5f94fed1..6187a4be 100644
--- a/tools/intel_reg_read.c
+++ b/tools/intel_reg_read.c
@@ -32,6 +32,19 @@
#include <string.h>
#include "intel_gpu_tools.h"
+static void bit_decode(uint32_t reg)
+{
+ int i;
+
+ for (i=31; i >= 0; i--)
+ printf(" %2d", i);
+ printf("\n");
+
+ for (i=31; i >= 0; i--)
+ printf(" %2d", (reg & (1 << i)) && 1);
+ printf("\n");
+}
+
static void dump_range(uint32_t start, uint32_t end)
{
int i;
@@ -43,9 +56,10 @@ static void dump_range(uint32_t start, uint32_t end)
static void usage(char *cmdname)
{
- printf("Usage: %s [-f] [addr1] [addr2] .. [addrN]\n", cmdname);
+ printf("Usage: %s [-f|-d] [addr1] [addr2] .. [addrN]\n", cmdname);
printf("\t -f : read back full range of registers.\n");
printf("\t WARNING! This option may result in a machine hang!\n");
+ printf("\t -d : decode register bits.\n");
printf("\t addr : in 0xXXXX format\n");
}
@@ -56,9 +70,13 @@ int main(int argc, char** argv)
int i, ch;
char *cmdname = strdup(argv[0]);
int full_dump = 0;
+ int decode_bits = 0;
- while ((ch = getopt(argc, argv, "fh")) != -1) {
+ while ((ch = getopt(argc, argv, "dfh")) != -1) {
switch(ch) {
+ case 'd':
+ decode_bits = 1;
+ break;
case 'f':
full_dump = 1;
break;
@@ -98,6 +116,9 @@ int main(int argc, char** argv)
for (i=0; i < argc; i++) {
sscanf(argv[i], "0x%x", &reg);
dump_range(reg, reg + 4);
+
+ if (decode_bits)
+ bit_decode(*(volatile uint32_t *)((volatile char*)mmio + reg));
}
}