summaryrefslogtreecommitdiff
path: root/src/pci.h
blob: fbd195a6c534ce24f78c31e798fbf63be9ce214d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
 *  Copyright (c) 2006 Dell, Inc.
 *  by Matt Domsch <Matt_Domsch@dell.com>
 *  Licensed under the GNU General Public license, version 2.
 */

#ifndef PCI_H_INCLUDED
#define PCI_H_INCLUDED

#include <pci/pci.h>
#include "list.h"
#include "state.h"
#include "config.h"

struct pci_device {
	struct list_head node;
	struct pci_dev pci_dev;
	int physical_slot;
	unsigned int index_in_slot;
	unsigned short int class;
	unsigned char smbios_type;
	unsigned char smbios_instance;
	unsigned char smbios_enabled;
};

extern int get_pci_devices(struct libbiosdevname_state *state);
extern void free_pci_devices(struct libbiosdevname_state *state);

extern struct pci_device * find_dev_by_pci(const struct libbiosdevname_state *state, const struct pci_dev *p);
extern struct pci_device * find_pci_dev_by_pci_addr(const struct libbiosdevname_state *state, const int domain, const int bus, const int device, const int func);
extern struct pci_device * find_dev_by_pci_name(const struct libbiosdevname_state *state, const char *s);
extern int unparse_pci_device(char *buf, const int size, const struct pci_device *p);
extern int unparse_pci_name(char *buf, int size, const struct pci_dev *pdev);

static inline int is_pci_network(struct pci_device *dev)
{
	return (dev->class & 0xFF00) == 0x0200;
}

#ifdef HAVE_STRUCT_PCI_DEV_DOMAIN
static inline int pci_domain_nr(const struct pci_dev *dev)
{
	return dev->domain;
}
#else
static inline int pci_domain_nr(const struct pci_dev *dev)
{
	return 0;
}
#endif


#endif /* PCI_H_INCLUDED */