1 #ifndef __X86_PCI_H__
2 #define __X86_PCI_H__
3
4 #include <xen/mm.h>
5
6 #define CF8_BDF(cf8) ( ((cf8) & 0x00ffff00U) >> 8)
7 #define CF8_ADDR_LO(cf8) ( (cf8) & 0x000000fcU)
8 #define CF8_ADDR_HI(cf8) ( ((cf8) & 0x0f000000U) >> 16)
9 #define CF8_ENABLED(cf8) (!!((cf8) & 0x80000000U))
10
11 #define IS_SNB_GFX(id) ((id) == 0x01068086 || (id) == 0x01168086 \
12 || (id) == 0x01268086 || (id) == 0x01028086 \
13 || (id) == 0x01128086 || (id) == 0x01228086 \
14 || (id) == 0x010A8086 )
15
16 struct pci_dev;
17
18 struct arch_pci_dev {
19 vmask_t used_vectors;
20 /*
21 * These fields are (de)initialized under pcidevs-lock. Other uses of
22 * them don't race (de)initialization and hence don't strictly need any
23 * locking.
24 */
25 union {
26 /* Subset of struct arch_iommu's fields, to be used in dom_io. */
27 struct {
28 uint64_t pgd_maddr;
29 } vtd;
30 struct {
31 struct page_info *root_table;
32 } amd;
33 };
34 domid_t pseudo_domid;
35 mfn_t leaf_mfn;
36 struct page_list_head pgtables_list;
37 };
38
39 int pci_conf_write_intercept(unsigned int seg, unsigned int bdf,
40 unsigned int reg, unsigned int size,
41 uint32_t *data);
42 int pci_msi_conf_write_intercept(struct pci_dev *pdev, unsigned int reg,
43 unsigned int size, uint32_t *data);
44 bool pci_mmcfg_decode(unsigned long mfn, unsigned int *seg,
45 unsigned int *bdf);
46
47 bool pci_ro_mmcfg_decode(unsigned long mfn, unsigned int *seg,
48 unsigned int *bdf);
49
50 /* MMCFG external variable defines */
51 extern int pci_mmcfg_config_num;
52 extern struct acpi_mcfg_allocation *pci_mmcfg_config;
53
54 /* Unlike ARM, PCI passthrough is always enabled for x86. */
is_pci_passthrough_enabled(void)55 static always_inline bool is_pci_passthrough_enabled(void)
56 {
57 return true;
58 }
59
60 /*
61 * Since PCI passthrough is always enabled on x86, physdevop handling doesn't
62 * need special arch-specific behavior. Current call sites work with either
63 * return value, but true is more consistent with passthrough being enabled.
64 */
arch_pci_device_physdevop(void)65 static inline bool arch_pci_device_physdevop(void)
66 {
67 return true;
68 }
69
70 void arch_pci_init_pdev(struct pci_dev *pdev);
71
72 bool pci_check_bar(const struct pci_dev *pdev, mfn_t start, mfn_t end);
73
74 struct rangeset;
75 int pci_sanitize_bar_memory(struct rangeset *r);
76
77 void pci_setup(void);
78
79 #endif /* __X86_PCI_H__ */
80