]>
git.ipfire.org Git - thirdparty/pciutils.git/blob - common.c
ed39b87148f6c726178f206f460c39c39975c56f
2 * The PCI Utilities -- Common Functions
4 * Copyright (c) 1997--2008 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_method(struct pci_access
*pacc
, char *arg
)
53 if (!strcmp(arg
, "help"))
55 printf("Known PCI access methods:\n\n");
56 for (i
=0; name
= pci_get_method_name(i
); i
++)
63 i
= pci_lookup_method(arg
);
65 die("No such PCI access method: %s (see `-A help' for a list)", arg
);
71 set_pci_option(struct pci_access
*pacc
, char *arg
)
73 if (!strcmp(arg
, "help"))
76 printf("Known PCI access parameters:\n\n");
77 for (p
=NULL
; p
=pci_walk_params(pacc
, p
);)
78 printf("%-20s %s (%s)\n", p
->param
, p
->help
, p
->value
);
83 char *sep
= strchr(arg
, '=');
85 die("Invalid PCI access parameter syntax: %s", arg
);
87 if (pci_set_param(pacc
, arg
, sep
) < 0)
88 die("Unrecognized PCI access parameter: %s (see `-O help' for a list)", arg
);
93 parse_generic_option(int i
, struct pci_access
*pacc
, char *optarg
)
97 #ifdef PCI_HAVE_PM_INTEL_CONF
99 if (!strcmp(optarg
, "1"))
100 pacc
->method
= PCI_ACCESS_I386_TYPE1
;
101 else if (!strcmp(optarg
, "2"))
102 pacc
->method
= PCI_ACCESS_I386_TYPE2
;
104 die("Unknown hardware configuration type %s", optarg
);
107 #ifdef PCI_HAVE_PM_DUMP
109 pci_set_param(pacc
, "dump.name", optarg
);
110 pacc
->method
= PCI_ACCESS_DUMP
;
114 set_pci_method(pacc
, optarg
);
120 set_pci_option(pacc
, optarg
);