xref: /aosp_15_r20/external/pciutils/pciutils.h (revision c2e0c6b56a71da9abe8df5c8348fb3eb5c2c9251)
1 /*
2  *	The PCI Utilities -- Declarations
3  *
4  *	Copyright (c) 1997--2018 Martin Mares <[email protected]>
5  *
6  *	Can be freely distributed and used under the terms of the GNU GPL v2+
7  *
8  *	SPDX-License-Identifier: GPL-2.0-or-later
9  */
10 
11 #include "lib/pci.h"
12 #include "lib/sysdep.h"
13 #include "bitops.h"
14 
15 /*
16  * gcc predefines macro __MINGW32__ for all MinGW targets.
17  * Including some MinGW header (e.g. windef.h) defines additional
18  * macro __MINGW32_MAJOR_VERSION (available for all MinGW targets).
19  */
20 #if defined(PCI_OS_WINDOWS) && defined(__MINGW32__)
21 #include <windef.h>
22 #endif
23 
24 /*
25  * On Windows only MinGW 3.0 and higher versions provides <getopt.h>
26  * header file. Older MinGW versions and MSVC do not have it.
27  * DJGPP does not provide <getopt.h>.
28  */
29 #if defined(PCI_OS_DJGPP) || (defined(PCI_OS_WINDOWS) && !(defined(__MINGW32_MAJOR_VERSION) && __MINGW32_MAJOR_VERSION >= 3))
30 #include "compat/getopt.h"
31 #else
32 #include <getopt.h>
33 #endif
34 
35 #define PCIUTILS_VERSION PCILIB_VERSION
36 
37 extern const char program_name[];
38 
39 void die(char *msg, ...) NONRET PCI_PRINTF(1,2);
40 void *xmalloc(size_t howmuch);
41 void *xrealloc(void *ptr, size_t howmuch);
42 char *xstrdup(const char *str);
43 int parse_generic_option(int i, struct pci_access *pacc, char *arg);
44 
45 #ifdef PCI_HAVE_PM_INTEL_CONF
46 #define GENOPT_INTEL "H:"
47 #define GENHELP_INTEL "-H <mode>\tUse direct hardware access (<mode> = 1 or 2)\n"
48 #else
49 #define GENOPT_INTEL
50 #define GENHELP_INTEL
51 #endif
52 #if defined(PCI_HAVE_PM_DUMP) && !defined(PCIUTILS_SETPCI)
53 #define GENOPT_DUMP "F:"
54 #define GENHELP_DUMP "-F <file>\tRead PCI configuration dump from a given file\n"
55 #else
56 #define GENOPT_DUMP
57 #define GENHELP_DUMP
58 #endif
59 
60 #define GENERIC_OPTIONS "A:GO:" GENOPT_INTEL GENOPT_DUMP
61 #define GENERIC_HELP \
62 	"-A <method>\tUse the specified PCI access method (see `-A help' for a list)\n" \
63 	"-O <par>=<val>\tSet PCI access parameter (see `-O help' for a list)\n" \
64 	"-G\t\tEnable PCI access debugging\n" \
65 	GENHELP_INTEL GENHELP_DUMP
66