]>
git.ipfire.org Git - thirdparty/pciutils.git/blob - common.c
7e53157773dcfebacfc47428f647e0a9c3a0db67
2 * The PCI Utilities -- Common Functions
4 * Copyright (c) 1997--2006 Martin Mares <mj@ucw.cz>
6 * Can be freely distributed and used under the terms of the GNU GPL.
23 fprintf(stderr
, "%s: ", program_name
);
24 vfprintf(stderr
, msg
, args
);
30 xmalloc(unsigned int howmuch
)
32 void *p
= malloc(howmuch
);
34 die("Unable to allocate %d bytes of memory", howmuch
);
39 xrealloc(void *ptr
, unsigned int howmuch
)
41 void *p
= realloc(ptr
, howmuch
);
43 die("Unable to allocate %d bytes of memory", howmuch
);
48 set_pci_option(struct pci_access
*pacc
, char *arg
)
50 if (!strcmp(arg
, "help"))
53 printf("Known PCI access parameters:\n\n");
54 for (p
=NULL
; p
=pci_walk_params(pacc
, p
);)
55 printf("%-20s %s (%s)\n", p
->param
, p
->help
, p
->value
);
60 char *sep
= strchr(arg
, '=');
62 die("Invalid PCI access parameter syntax: %s", arg
);
64 if (pci_set_param(pacc
, arg
, sep
) < 0)
65 die("Unrecognized PCI access parameter: %s", arg
);
70 parse_generic_option(int i
, struct pci_access
*pacc
, char *optarg
)
74 #ifdef PCI_HAVE_PM_LINUX_PROC
76 pacc
->method_params
[PCI_ACCESS_PROC_BUS_PCI
] = optarg
;
77 pacc
->method
= PCI_ACCESS_PROC_BUS_PCI
;
80 #ifdef PCI_HAVE_PM_INTEL_CONF
82 if (!strcmp(optarg
, "1"))
83 pacc
->method
= PCI_ACCESS_I386_TYPE1
;
84 else if (!strcmp(optarg
, "2"))
85 pacc
->method
= PCI_ACCESS_I386_TYPE2
;
87 die("Unknown hardware configuration type %s", optarg
);
90 #ifdef PCI_HAVE_PM_DUMP
92 pacc
->method_params
[PCI_ACCESS_DUMP
] = optarg
;
93 pacc
->method
= PCI_ACCESS_DUMP
;
100 set_pci_option(pacc
, optarg
);