This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / include / asm-x86_64 / mach-xen / asm / pci.h
1 #ifndef __x8664_PCI_H
2 #define __x8664_PCI_H
3
4 #include <linux/config.h>
5 #include <asm/io.h>
6
7 #ifdef __KERNEL__
8
9 #include <linux/mm.h> /* for struct page */
10
11 /* Can be used to override the logic in pci_scan_bus for skipping
12    already-configured bus numbers - to be used for buggy BIOSes
13    or architectures with incomplete PCI setup by the loader */
14
15 #ifdef CONFIG_PCI
16 extern unsigned int pcibios_assign_all_busses(void);
17 #else
18 #define pcibios_assign_all_busses()     0
19 #endif
20 #define pcibios_scan_all_fns(a, b)      0
21
22 extern unsigned long pci_mem_start;
23 #define PCIBIOS_MIN_IO          0x1000
24 #define PCIBIOS_MIN_MEM         (pci_mem_start)
25
26 #define PCIBIOS_MIN_CARDBUS_IO  0x4000
27
28 void pcibios_config_init(void);
29 struct pci_bus * pcibios_scan_root(int bus);
30 extern int (*pci_config_read)(int seg, int bus, int dev, int fn, int reg, int len, u32 *value);
31 extern int (*pci_config_write)(int seg, int bus, int dev, int fn, int reg, int len, u32 value);
32
33 void pcibios_set_master(struct pci_dev *dev);
34 void pcibios_penalize_isa_irq(int irq, int active);
35 struct irq_routing_table *pcibios_get_irq_routing_table(void);
36 int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq);
37
38 #include <linux/types.h>
39 #include <linux/slab.h>
40 #include <asm/scatterlist.h>
41 #include <linux/string.h>
42 #include <asm/page.h>
43 #include <linux/dma-mapping.h> /* for have_iommu */
44
45 extern int iommu_setup(char *opt);
46
47 /* The PCI address space does equal the physical memory
48  * address space.  The networking and block device layers use
49  * this boolean for bounce buffer decisions
50  *
51  * On AMD64 it mostly equals, but we set it to zero if a hardware
52  * IOMMU (gart) of sotware IOMMU (swiotlb) is available.
53  */
54 #define PCI_DMA_BUS_IS_PHYS (dma_ops->is_phys)
55
56 #ifdef CONFIG_GART_IOMMU
57
58 /*
59  * x86-64 always supports DAC, but sometimes it is useful to force
60  * devices through the IOMMU to get automatic sg list merging.
61  * Optional right now.
62  */
63 extern int iommu_sac_force;
64 #define pci_dac_dma_supported(pci_dev, mask)    (!iommu_sac_force)
65
66 #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)       \
67         dma_addr_t ADDR_NAME;
68 #define DECLARE_PCI_UNMAP_LEN(LEN_NAME)         \
69         __u32 LEN_NAME;
70 #define pci_unmap_addr(PTR, ADDR_NAME)                  \
71         ((PTR)->ADDR_NAME)
72 #define pci_unmap_addr_set(PTR, ADDR_NAME, VAL)         \
73         (((PTR)->ADDR_NAME) = (VAL))
74 #define pci_unmap_len(PTR, LEN_NAME)                    \
75         ((PTR)->LEN_NAME)
76 #define pci_unmap_len_set(PTR, LEN_NAME, VAL)           \
77         (((PTR)->LEN_NAME) = (VAL))
78
79 #elif defined(CONFIG_SWIOTLB)
80
81 #define pci_dac_dma_supported(pci_dev, mask)    1
82
83 #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)       \
84         dma_addr_t ADDR_NAME;
85 #define DECLARE_PCI_UNMAP_LEN(LEN_NAME)         \
86         __u32 LEN_NAME;
87 #define pci_unmap_addr(PTR, ADDR_NAME)                  \
88         ((PTR)->ADDR_NAME)
89 #define pci_unmap_addr_set(PTR, ADDR_NAME, VAL)         \
90         (((PTR)->ADDR_NAME) = (VAL))
91 #define pci_unmap_len(PTR, LEN_NAME)                    \
92         ((PTR)->LEN_NAME)
93 #define pci_unmap_len_set(PTR, LEN_NAME, VAL)           \
94         (((PTR)->LEN_NAME) = (VAL))
95
96 #else
97 /* No IOMMU */
98
99 #define pci_dac_dma_supported(pci_dev, mask)    1
100
101 #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
102 #define DECLARE_PCI_UNMAP_LEN(LEN_NAME)
103 #define pci_unmap_addr(PTR, ADDR_NAME)          (0)
104 #define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) do { } while (0)
105 #define pci_unmap_len(PTR, LEN_NAME)            (0)
106 #define pci_unmap_len_set(PTR, LEN_NAME, VAL)   do { } while (0)
107
108 #endif
109
110 #include <asm-generic/pci-dma-compat.h>
111
112 static inline dma64_addr_t
113 pci_dac_page_to_dma(struct pci_dev *pdev, struct page *page, unsigned long offset, int direction)
114 {
115         return ((dma64_addr_t) page_to_phys(page) +
116                 (dma64_addr_t) offset);
117 }
118
119 static inline struct page *
120 pci_dac_dma_to_page(struct pci_dev *pdev, dma64_addr_t dma_addr)
121 {
122         return virt_to_page(__va(dma_addr));    
123 }
124
125 static inline unsigned long
126 pci_dac_dma_to_offset(struct pci_dev *pdev, dma64_addr_t dma_addr)
127 {
128         return (dma_addr & ~PAGE_MASK);
129 }
130
131 static inline void
132 pci_dac_dma_sync_single_for_cpu(struct pci_dev *pdev, dma64_addr_t dma_addr, size_t len, int direction)
133 {
134 }
135
136 static inline void
137 pci_dac_dma_sync_single_for_device(struct pci_dev *pdev, dma64_addr_t dma_addr, size_t len, int direction)
138 {
139         flush_write_buffers();
140 }
141
142 #ifdef CONFIG_PCI
143 static inline void pci_dma_burst_advice(struct pci_dev *pdev,
144                                         enum pci_dma_burst_strategy *strat,
145                                         unsigned long *strategy_parameter)
146 {
147         *strat = PCI_DMA_BURST_INFINITY;
148         *strategy_parameter = ~0UL;
149 }
150 #endif
151
152 #define HAVE_PCI_MMAP
153 extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
154                                enum pci_mmap_state mmap_state, int write_combine);
155
156 static inline void pcibios_add_platform_entries(struct pci_dev *dev)
157 {
158 }
159
160 #endif /* __KERNEL__ */
161
162 /* generic pci stuff */
163 #ifdef CONFIG_PCI
164 #include <asm-generic/pci.h>
165 #endif
166
167 /* On Xen we have to scan all functions since Xen hides bridges from
168  * us.  If a bridge is at fn=0 and that slot has a multifunction
169  * device, we won't find the additional devices without scanning all
170  * functions. */
171 #undef pcibios_scan_all_fns
172 #define pcibios_scan_all_fns(a, b)      1
173
174 #endif /* __x8664_PCI_H */