From a89da0969efe52ca4474867966152cbe6c92ca21 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Fri, 29 Jun 2012 12:23:50 -0700 Subject: superiotool: Add support for function to dump superio chip data registers Add new function dump_data() to dump a bank of superio data registers. Change-Id: I13a58d87c14d319cfcdea1ec1d54c2b110d90f9f Signed-off-by: Guenter Roeck Reviewed-on: http://review.coreboot.org/1149 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi --- util/superiotool/superiotool.c | 29 +++++++++++++++++++++++++++++ util/superiotool/superiotool.h | 1 + 2 files changed, 30 insertions(+) (limited to 'util/superiotool') diff --git a/util/superiotool/superiotool.c b/util/superiotool/superiotool.c index 293aaa617d..538aa09074 100644 --- a/util/superiotool/superiotool.c +++ b/util/superiotool/superiotool.c @@ -34,6 +34,18 @@ int dump = 0, verbose = 0, extra_dump = 0; /* Global flag which indicates whether a chip was detected at all. */ int chip_found = 0; +static void set_bank(uint16_t port, uint8_t bank) +{ + OUTB(0x4E, port); + OUTB(bank, port + 1); +} + +static uint8_t datareg(uint16_t port, uint8_t reg) +{ + OUTB(reg, port); + return INB(port + 1); +} + uint8_t regval(uint16_t port, uint8_t reg) { OUTB(reg, port); @@ -186,6 +198,23 @@ void dump_io(uint16_t iobase, uint16_t length) printf("\n"); } +void dump_data(uint16_t iobase, int bank) +{ + uint16_t i; + + printf("Bank %d:\n", bank); + printf(" "); + for (i = 0; i < 16; i++) + printf("%02x ", i); + set_bank(iobase, bank); + for (i = 0; i < 256; i++) { + if (i % 16 == 0) + printf("\n%02x: ", i / 16); + printf("%02x ", datareg(iobase, i)); + } + printf("\n"); +} + void probing_for(const char *vendor, const char *info, uint16_t port) { if (!verbose) diff --git a/util/superiotool/superiotool.h b/util/superiotool/superiotool.h index 94918b8867..7a0b7f69c5 100644 --- a/util/superiotool/superiotool.h +++ b/util/superiotool/superiotool.h @@ -174,6 +174,7 @@ const char *get_superio_name(const struct superio_registers reg_table[], void dump_superio(const char *name, const struct superio_registers reg_table[], uint16_t port, uint16_t id, uint8_t ldn_sel); void dump_io(uint16_t iobase, uint16_t length); +void dump_data(uint16_t iobase, int bank); void probing_for(const char *vendor, const char *info, uint16_t port); void print_vendor_chips(const char *vendor, const struct superio_registers reg_table[]); -- cgit v1.2.3