1 /*
2 * Copyright 2009, Colin Günther, coling@gmx.de.
3 * Copyright 2007, Hugo Santos. All Rights Reserved.
4 * Distributed under the terms of the MIT License.
5 */
6 #ifndef _FBSD_COMPAT_DEV_PCI_PCIVAR_H_
7 #define _FBSD_COMPAT_DEV_PCI_PCIVAR_H_
8
9
10 #include <sys/bus.h>
11
12
13 #define PCI_RF_DENSE 0x10000
14 // ignored on x86
15
16 #define PCI_POWERSTATE_D0 0
17 #define PCI_POWERSTATE_D1 1
18 #define PCI_POWERSTATE_D2 2
19 #define PCI_POWERSTATE_D3 3
20 #define PCI_POWERSTATE_UNKNOWN -1
21
22
23 int pci_enable_busmaster(device_t dev);
24 int pci_enable_io(device_t dev, int reg);
25
26 uint32_t pci_get_devid(device_t dev);
27 void pci_set_intpin(device_t dev, uint8_t pin);
28 uint8_t pci_get_intpin(device_t dev);
29
30 uint16_t pci_get_vendor(device_t dev);
31 uint16_t pci_get_device(device_t dev);
32 uint16_t pci_get_subvendor(device_t dev);
33 uint16_t pci_get_subdevice(device_t dev);
34 uint8_t pci_get_revid(device_t dev);
35 uint8_t pci_get_cachelnsz(device_t dev);
36 uint8_t *pci_get_ether(device_t dev);
37
38 uint32_t pci_read_config(device_t dev, int reg, int width);
39 void pci_write_config(device_t dev, int reg, uint32_t val, int width);
40
41 uint32_t pci_get_domain(device_t dev);
42 uint8_t pci_get_bus(device_t dev);
43 uint8_t pci_get_slot(device_t dev);
44 uint8_t pci_get_function(device_t dev);
45 device_t pci_find_dbsf(uint32_t domain, uint8_t bus, uint8_t slot,
46 uint8_t func);
47
48 int pci_find_cap(device_t dev, int capability, int *capreg);
49 int pci_find_extcap(device_t dev, int capability, int *capreg);
50
51 int pci_msi_count(device_t dev);
52 int pci_alloc_msi(device_t dev, int *count);
53 int pci_release_msi(device_t dev);
54
55 int pci_msix_table_bar(device_t dev);
56 int pci_msix_count(device_t dev);
57 int pci_alloc_msix(device_t dev, int *count);
58
59 int pci_get_max_read_req(device_t dev);
60 int pci_set_max_read_req(device_t dev, int size);
61
62 int pci_get_powerstate(device_t dev);
63 int pci_set_powerstate(device_t dev, int newPowerState);
64
65 static inline int
pci_get_vpd_ident(device_t dev,const char ** identptr)66 pci_get_vpd_ident(device_t dev, const char **identptr)
67 {
68 return -1;
69 }
70
71 #endif /* _FBSD_COMPAT_DEV_PCI_PCIVAR_H_ */
72