From a82ca6381c44611ebb27ffa86b7a55a670ad6bb5 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Tue, 11 Nov 2008 01:14:35 +0100 Subject: [PATCH] Implemented `setpci --dumpregs'. --- setpci.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/setpci.c b/setpci.c index 0aea25b..7e84acb 100644 --- a/setpci.c +++ b/setpci.c @@ -312,6 +312,24 @@ static const struct reg_name pci_reg_names[] = { { 0, 0, 0, NULL } }; +static void +dump_registers(void) +{ + const struct reg_name *r; + + printf("cap pos w name\n"); + for (r = pci_reg_names; r->name; r++) + { + if (r->cap >= 0x20000) + printf("%04x", r->cap - 0x20000); + else if (r->cap) + printf(" %02x", r->cap - 0x10000); + else + printf(" "); + printf(" %02x %c %s\n", r->offset, "-BW?L"[r->width], r->name); + } +} + static void NONRET PCI_PRINTF(1,2) usage(char *msg, ...) { @@ -330,6 +348,7 @@ usage(char *msg, ...) "-f\t\tDon't complain if there's nothing to do\n" "-v\t\tBe verbose\n" "-D\t\tList changes, don't commit them\n" +"--dumpregs\tDump all known register names and exit\n" "\n" "PCI access options:\n" GENERIC_HELP @@ -359,6 +378,11 @@ parse_options(int argc, char **argv) puts("setpci version " PCIUTILS_VERSION); exit(0); } + if (argc == 2 && !strcmp(argv[1], "--dumpregs")) + { + dump_registers(); + exit(0); + } while (i < argc && argv[i][0] == '-') { -- 2.39.2