From 553d12c87c04d1d53cc684c768ee7bab0eedd90a Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Tue, 12 Feb 2008 09:37:25 +0100 Subject: [PATCH] Added options for setting of library parameters. --- common.c | 25 +++++++++++++++++++++++++ pciutils.h | 5 +++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/common.c b/common.c index 7d52530..7e53157 100644 --- a/common.c +++ b/common.c @@ -44,6 +44,28 @@ xrealloc(void *ptr, unsigned int howmuch) return p; } +static void +set_pci_option(struct pci_access *pacc, char *arg) +{ + if (!strcmp(arg, "help")) + { + struct pci_param *p; + printf("Known PCI access parameters:\n\n"); + for (p=NULL; p=pci_walk_params(pacc, p);) + printf("%-20s %s (%s)\n", p->param, p->help, p->value); + exit(0); + } + else + { + char *sep = strchr(arg, '='); + if (!sep) + die("Invalid PCI access parameter syntax: %s", arg); + *sep++ = 0; + if (pci_set_param(pacc, arg, sep) < 0) + die("Unrecognized PCI access parameter: %s", arg); + } +} + int parse_generic_option(int i, struct pci_access *pacc, char *optarg) { @@ -74,6 +96,9 @@ parse_generic_option(int i, struct pci_access *pacc, char *optarg) case 'G': pacc->debugging++; break; + case 'O': + set_pci_option(pacc, optarg); + break; default: return 0; } diff --git a/pciutils.h b/pciutils.h index d6669af..02071ac 100644 --- a/pciutils.h +++ b/pciutils.h @@ -44,6 +44,7 @@ int parse_generic_option(int i, struct pci_access *pacc, char *optarg); #define GENHELP_DUMP #endif -#define GENERIC_OPTIONS "G" GENOPT_PROC GENOPT_INTEL GENOPT_DUMP +#define GENERIC_OPTIONS "GO:" GENOPT_PROC GENOPT_INTEL GENOPT_DUMP #define GENERIC_HELP GENHELP_PROC GENHELP_INTEL GENHELP_DUMP \ - "-G\t\tEnable PCI access debugging\n" + "-G\t\tEnable PCI access debugging\n" \ + "-O =\tSet PCI access parameter (see `-O help' for the list)\n" -- 2.39.2