summaryrefslogtreecommitdiff
path: root/setpci.c
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>2008-11-11 01:14:35 +0100
committerMartin Mares <mj@ucw.cz>2008-11-11 01:14:35 +0100
commita82ca6381c44611ebb27ffa86b7a55a670ad6bb5 (patch)
treeecb5de6e5de5ce1a60ba858dc78419e2683c53e8 /setpci.c
parent7f0775708c7b7cee571921927c2e3aa356fe9f6c (diff)
downloadpciutils-a82ca6381c44611ebb27ffa86b7a55a670ad6bb5.tar.gz
Implemented `setpci --dumpregs'.
Diffstat (limited to 'setpci.c')
-rw-r--r--setpci.c24
1 files changed, 24 insertions, 0 deletions
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] == '-')
{