123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- #ifndef _PCI_LIB_H
- #define _PCI_LIB_H
- #ifndef PCI_CONFIG_H
- #include "config.h"
- #endif
- #include "header.h"
- #include "types.h"
- #define PCI_LIB_VERSION 0x030501
- #ifndef PCI_ABI
- #define PCI_ABI
- #endif
- struct pci_methods;
- enum pci_access_type {
-
- PCI_ACCESS_AUTO,
- PCI_ACCESS_SYS_BUS_PCI,
- PCI_ACCESS_PROC_BUS_PCI,
- PCI_ACCESS_I386_TYPE1,
- PCI_ACCESS_I386_TYPE2,
- PCI_ACCESS_FBSD_DEVICE,
- PCI_ACCESS_AIX_DEVICE,
- PCI_ACCESS_NBSD_LIBPCI,
- PCI_ACCESS_OBSD_DEVICE,
- PCI_ACCESS_DUMP,
- PCI_ACCESS_DARWIN,
- PCI_ACCESS_MAX
- };
- struct pci_access {
-
- unsigned int method;
- int writeable;
- int buscentric;
- char *id_file_name;
- int free_id_name;
- int numeric_ids;
- unsigned int id_lookup_mode;
-
- int debugging;
-
- void (*error)(char *msg, ...) PCI_PRINTF(1,2);
- void (*warning)(char *msg, ...) PCI_PRINTF(1,2);
- void (*debug)(char *msg, ...) PCI_PRINTF(1,2);
- struct pci_dev *devices;
-
- struct pci_methods *methods;
- struct pci_param *params;
- struct id_entry **id_hash;
- struct id_bucket *current_id_bucket;
- int id_load_failed;
- int id_cache_status;
- struct udev *id_udev;
- struct udev_hwdb *id_udev_hwdb;
- int fd;
- int fd_rw;
- int fd_pos;
- int fd_vpd;
- struct pci_dev *cached_dev;
- };
- struct pci_access *pci_alloc(void) PCI_ABI;
- void pci_init(struct pci_access *) PCI_ABI;
- void pci_cleanup(struct pci_access *) PCI_ABI;
- void pci_scan_bus(struct pci_access *acc) PCI_ABI;
- struct pci_dev *pci_get_dev(struct pci_access *acc, int domain, int bus, int dev, int func) PCI_ABI;
- void pci_free_dev(struct pci_dev *) PCI_ABI;
- int pci_lookup_method(char *name) PCI_ABI;
- char *pci_get_method_name(int index) PCI_ABI;
- struct pci_param {
- struct pci_param *next;
- char *param;
- char *value;
- int value_malloced;
- char *help;
- };
- char *pci_get_param(struct pci_access *acc, char *param) PCI_ABI;
- int pci_set_param(struct pci_access *acc, char *param, char *value) PCI_ABI;
- struct pci_param *pci_walk_params(struct pci_access *acc, struct pci_param *prev) PCI_ABI;
- struct pci_dev {
- struct pci_dev *next;
- u16 domain_16;
-
- u8 bus, dev, func;
-
- int known_fields;
- u16 vendor_id, device_id;
- u16 device_class;
- int irq;
- pciaddr_t base_addr[6];
- pciaddr_t size[6];
- pciaddr_t rom_base_addr;
- pciaddr_t rom_size;
- struct pci_cap *first_cap;
- char *phy_slot;
- char *module_alias;
- char *label;
- int numa_node;
- pciaddr_t flags[6];
- pciaddr_t rom_flags;
- int domain;
-
- struct pci_access *access;
- struct pci_methods *methods;
- u8 *cache;
- int cache_len;
- int hdrtype;
- void *aux;
- };
- #define PCI_ADDR_IO_MASK (~(pciaddr_t) 0x3)
- #define PCI_ADDR_MEM_MASK (~(pciaddr_t) 0xf)
- #define PCI_ADDR_FLAG_MASK 0xf
- u8 pci_read_byte(struct pci_dev *, int pos) PCI_ABI;
- u16 pci_read_word(struct pci_dev *, int pos) PCI_ABI;
- u32 pci_read_long(struct pci_dev *, int pos) PCI_ABI;
- int pci_read_block(struct pci_dev *, int pos, u8 *buf, int len) PCI_ABI;
- int pci_read_vpd(struct pci_dev *d, int pos, u8 *buf, int len) PCI_ABI;
- int pci_write_byte(struct pci_dev *, int pos, u8 data) PCI_ABI;
- int pci_write_word(struct pci_dev *, int pos, u16 data) PCI_ABI;
- int pci_write_long(struct pci_dev *, int pos, u32 data) PCI_ABI;
- int pci_write_block(struct pci_dev *, int pos, u8 *buf, int len) PCI_ABI;
- int pci_fill_info(struct pci_dev *, int flags) PCI_ABI;
- #define PCI_FILL_IDENT 0x0001
- #define PCI_FILL_IRQ 0x0002
- #define PCI_FILL_BASES 0x0004
- #define PCI_FILL_ROM_BASE 0x0008
- #define PCI_FILL_SIZES 0x0010
- #define PCI_FILL_CLASS 0x0020
- #define PCI_FILL_CAPS 0x0040
- #define PCI_FILL_EXT_CAPS 0x0080
- #define PCI_FILL_PHYS_SLOT 0x0100
- #define PCI_FILL_MODULE_ALIAS 0x0200
- #define PCI_FILL_LABEL 0x0400
- #define PCI_FILL_NUMA_NODE 0x0800
- #define PCI_FILL_IO_FLAGS 0x1000
- #define PCI_FILL_RESCAN 0x00010000
- void pci_setup_cache(struct pci_dev *, u8 *cache, int len) PCI_ABI;
- struct pci_cap {
- struct pci_cap *next;
- u16 id;
- u16 type;
- unsigned int addr;
- };
- #define PCI_CAP_NORMAL 1
- #define PCI_CAP_EXTENDED 2
- struct pci_cap *pci_find_cap(struct pci_dev *, unsigned int id, unsigned int type) PCI_ABI;
- struct pci_filter {
- int domain, bus, slot, func;
- int vendor, device, device_class;
- int rfu[3];
- };
- void pci_filter_init(struct pci_access *, struct pci_filter *) PCI_ABI;
- char *pci_filter_parse_slot(struct pci_filter *, char *) PCI_ABI;
- char *pci_filter_parse_id(struct pci_filter *, char *) PCI_ABI;
- int pci_filter_match(struct pci_filter *, struct pci_dev *) PCI_ABI;
- char *pci_lookup_name(struct pci_access *a, char *buf, int size, int flags, ...) PCI_ABI;
- int pci_load_name_list(struct pci_access *a) PCI_ABI;
- void pci_free_name_list(struct pci_access *a) PCI_ABI;
- void pci_set_name_list_path(struct pci_access *a, char *name, int to_be_freed) PCI_ABI;
- void pci_id_cache_flush(struct pci_access *a) PCI_ABI;
- enum pci_lookup_mode {
- PCI_LOOKUP_VENDOR = 1,
- PCI_LOOKUP_DEVICE = 2,
- PCI_LOOKUP_CLASS = 4,
- PCI_LOOKUP_SUBSYSTEM = 8,
- PCI_LOOKUP_PROGIF = 16,
- PCI_LOOKUP_NUMERIC = 0x10000,
- PCI_LOOKUP_NO_NUMBERS = 0x20000,
- PCI_LOOKUP_MIXED = 0x40000,
- PCI_LOOKUP_NETWORK = 0x80000,
- PCI_LOOKUP_SKIP_LOCAL = 0x100000,
- PCI_LOOKUP_CACHE = 0x200000,
- PCI_LOOKUP_REFRESH_CACHE = 0x400000,
- PCI_LOOKUP_NO_HWDB = 0x800000,
- };
- #endif
|