]> git.ipfire.org Git - thirdparty/pciutils.git/blame - lib/internal.h
README.Windows: Replaced broken link to winio
[thirdparty/pciutils.git] / lib / internal.h
CommitLineData
727ce158 1/*
489233b4 2 * The PCI Library -- Internal Stuff
727ce158 3 *
c02d903c 4 * Copyright (c) 1997--2018 Martin Mares <mj@ucw.cz>
727ce158
MM
5 *
6 * Can be freely distributed and used under the terms of the GNU GPL.
7 */
8
59a0211a
MM
9#include "config.h"
10
11#ifdef PCI_SHARED_LIB
2f421184 12#define PCI_ABI __attribute__((visibility("default")))
6e4adbf5
MM
13// Functions, which are bound to externally visible symbols by the versioning
14// mechanism, have to be declared as VERSIONED. Otherwise, GCC with global
15// optimizations is happy to optimize them away, leading to linker failures.
52aecc75 16#define VERSIONED_ABI __attribute__((used)) PCI_ABI
8d1cb3d7 17#ifdef __APPLE__
35383c12 18#define STATIC_ALIAS(_decl, _for) _decl PCI_ABI { return _for; }
35383c12
MM
19#define DEFINE_ALIAS(_decl, _for)
20#define SYMBOL_VERSION(_int, _ext)
52aecc75
MM
21#else
22#define STATIC_ALIAS(_decl, _for)
23#define DEFINE_ALIAS(_decl, _for) extern _decl __attribute__((alias(#_for)))
24#define SYMBOL_VERSION(_int, _ext) asm(".symver " #_int "," #_ext)
8d1cb3d7 25#endif
89c51b98 26#else
52aecc75 27#define VERSIONED_ABI
89c51b98
MM
28#define STATIC_ALIAS(_decl, _for) _decl { return _for; }
29#define DEFINE_ALIAS(_decl, _for)
30#define SYMBOL_VERSION(_int, _ext)
2f421184
MM
31#endif
32
727ce158 33#include "pci.h"
489233b4 34#include "sysdep.h"
727ce158
MM
35
36struct pci_methods {
37 char *name;
9ff67879 38 char *help;
727ce158
MM
39 void (*config)(struct pci_access *);
40 int (*detect)(struct pci_access *);
41 void (*init)(struct pci_access *);
42 void (*cleanup)(struct pci_access *);
43 void (*scan)(struct pci_access *);
e95c8373 44 int (*fill_info)(struct pci_dev *, int flags);
727ce158
MM
45 int (*read)(struct pci_dev *, int pos, byte *buf, int len);
46 int (*write)(struct pci_dev *, int pos, byte *buf, int len);
52c81519 47 int (*read_vpd)(struct pci_dev *, int pos, byte *buf, int len);
727ce158
MM
48 void (*init_dev)(struct pci_dev *);
49 void (*cleanup_dev)(struct pci_dev *);
50};
51
6d5e39ac 52/* generic.c */
14d6c0a3 53void pci_generic_scan_bus(struct pci_access *, byte *busmap, int bus);
727ce158 54void pci_generic_scan(struct pci_access *);
e95c8373 55int pci_generic_fill_info(struct pci_dev *, int flags);
727ce158
MM
56int pci_generic_block_read(struct pci_dev *, int pos, byte *buf, int len);
57int pci_generic_block_write(struct pci_dev *, int pos, byte *buf, int len);
58
6d5e39ac 59/* init.c */
727ce158
MM
60void *pci_malloc(struct pci_access *, int);
61void pci_mfree(void *);
ac357d3b 62char *pci_strdup(struct pci_access *a, const char *s);
727ce158 63
25471140 64void pci_init_v30(struct pci_access *a) VERSIONED_ABI;
2afb0889 65void pci_init_v35(struct pci_access *a) VERSIONED_ABI;
ab61451d 66
6d5e39ac 67/* access.c */
727ce158
MM
68struct pci_dev *pci_alloc_dev(struct pci_access *);
69int pci_link_dev(struct pci_access *, struct pci_dev *);
70
52aecc75
MM
71int pci_fill_info_v30(struct pci_dev *, int flags) VERSIONED_ABI;
72int pci_fill_info_v31(struct pci_dev *, int flags) VERSIONED_ABI;
73int pci_fill_info_v32(struct pci_dev *, int flags) VERSIONED_ABI;
74int pci_fill_info_v33(struct pci_dev *, int flags) VERSIONED_ABI;
7ef7f3ec 75int pci_fill_info_v34(struct pci_dev *, int flags) VERSIONED_ABI;
3d0a6d88 76int pci_fill_info_v35(struct pci_dev *, int flags) VERSIONED_ABI;
89c51b98 77
c02d903c
MM
78struct pci_property {
79 struct pci_property *next;
80 u32 key;
81 char value[1];
82};
83
84char *pci_set_property(struct pci_dev *d, u32 key, char *value);
85
6d5e39ac 86/* params.c */
0f24ef6f 87void pci_define_param(struct pci_access *acc, char *param, char *val, char *help);
98ccf6d6 88int pci_set_param_internal(struct pci_access *acc, char *param, char *val, int copy);
d6dcc545 89void pci_free_params(struct pci_access *acc);
fa182368 90
6d5e39ac
MM
91/* caps.c */
92unsigned int pci_scan_caps(struct pci_dev *, unsigned int want_fields);
93void pci_free_caps(struct pci_dev *);
94
727ce158 95extern struct pci_methods pm_intel_conf1, pm_intel_conf2, pm_linux_proc,
94db5c82 96 pm_fbsd_device, pm_aix_device, pm_nbsd_libpci, pm_obsd_device,
83fd885b 97 pm_dump, pm_linux_sysfs, pm_darwin, pm_sylixos_device;