1 #ifndef __i386_PCI_H
2 #define __i386_PCI_H
3
4 #ifdef __KERNEL__
5
6 /* Can be used to override the logic in pci_scan_bus for skipping
7 already-configured bus numbers - to be used for buggy BIOSes
8 or architectures with incomplete PCI setup by the loader */
9
10 #define pcibios_assign_all_busses() 0
11
12 #define PCIBIOS_MIN_IO 0x1000
13 #define PCIBIOS_MIN_MEM 0x10000000
14
15 void pcibios_set_master(struct pci_dev *dev);
16 void pcibios_penalize_isa_irq(int irq);
17
18 /* Dynamic DMA mapping stuff.
19 * i386 has everything mapped statically.
20 */
21
22 #include <linux/types.h>
23 #include <linux/slab.h>
24 #include <asm/scatterlist.h>
25 #include <linux/string.h>
26 #include <asm/io.h>
27
28 struct pci_dev;
29
30 /* Allocate and map kernel buffer using consistent mode DMA for a device.
31 * hwdev should be valid struct pci_dev pointer for PCI devices,
32 * NULL for PCI-like buses (ISA, EISA).
33 * Returns non-NULL cpu-view pointer to the buffer if successful and
34 * sets *dma_addrp to the pci side dma address as well, else *dma_addrp
35 * is undefined.
36 */
37 extern void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
38 dma_addr_t *dma_handle);
39
40 /* Free and unmap a consistent DMA buffer.
41 * cpu_addr is what was returned from pci_alloc_consistent,
42 * size must be the same as what as passed into pci_alloc_consistent,
43 * and likewise dma_addr must be the same as what *dma_addrp was set to.
44 *
45 * References to the memory and mappings associated with cpu_addr/dma_addr
46 * past this call are illegal.
47 */
48 extern void pci_free_consistent(struct pci_dev *hwdev, size_t size,
49 void *vaddr, dma_addr_t dma_handle);
50
51 /* Map a single buffer of the indicated size for DMA in streaming mode.
52 * The 32-bit bus address to use is returned.
53 *
54 * Once the device is given the dma address, the device owns this memory
55 * until either pci_unmap_single or pci_dma_sync_single is performed.
56 */
57 extern inline dma_addr_t pci_map_single(struct pci_dev *hwdev, void *ptr,
58 size_t size, int direction)
59 {
60 if (direction == PCI_DMA_NONE)
61 BUG();
62 return virt_to_bus(ptr);
63 }
64
65 /* Unmap a single streaming mode DMA translation. The dma_addr and size
66 * must match what was provided for in a previous pci_map_single call. All
67 * other usages are undefined.
68 *
69 * After this call, reads by the cpu to the buffer are guarenteed to see
70 * whatever the device wrote there.
71 */
72 extern inline void pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr,
73 size_t size, int direction)
74 {
75 if (direction == PCI_DMA_NONE)
76 BUG();
77 /* Nothing to do */
78 }
79
80 /* Map a set of buffers described by scatterlist in streaming
81 * mode for DMA. This is the scather-gather version of the
82 * above pci_map_single interface. Here the scatter gather list
83 * elements are each tagged with the appropriate dma address
84 * and length. They are obtained via sg_dma_{address,length}(SG).
85 *
86 * NOTE: An implementation may be able to use a smaller number of
87 * DMA address/length pairs than there are SG table elements.
88 * (for example via virtual mapping capabilities)
89 * The routine returns the number of addr/length pairs actually
90 * used, at most nents.
91 *
92 * Device ownership issues as mentioned above for pci_map_single are
93 * the same here.
94 */
95 extern inline int pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg,
96 int nents, int direction)
97 {
98 if (direction == PCI_DMA_NONE)
99 BUG();
100 return nents;
101 }
102
103 /* Unmap a set of streaming mode DMA translations.
104 * Again, cpu read rules concerning calls here are the same as for
105 * pci_unmap_single() above.
106 */
107 extern inline void pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg,
108 int nents, int direction)
109 {
110 if (direction == PCI_DMA_NONE)
111 BUG();
112 /* Nothing to do */
113 }
114
115 /* Make physical memory consistent for a single
116 * streaming mode DMA translation after a transfer.
117 *
118 * If you perform a pci_map_single() but wish to interrogate the
119 * buffer using the cpu, yet do not wish to teardown the PCI dma
120 * mapping, you must call this function before doing so. At the
121 * next point you give the PCI dma address back to the card, the
122 * device again owns the buffer.
123 */
124 extern inline void pci_dma_sync_single(struct pci_dev *hwdev,
125 dma_addr_t dma_handle,
126 size_t size, int direction)
127 {
128 if (direction == PCI_DMA_NONE)
129 BUG();
130 /* Nothing to do */
131 }
132
133 /* Make physical memory consistent for a set of streaming
134 * mode DMA translations after a transfer.
135 *
136 * The same as pci_dma_sync_single but for a scatter-gather list,
137 * same rules and usage.
138 */
139 extern inline void pci_dma_sync_sg(struct pci_dev *hwdev,
140 struct scatterlist *sg,
141 int nelems, int direction)
142 {
143 if (direction == PCI_DMA_NONE)
144 BUG();
145 /* Nothing to do */
146 }
147
148 /* Return whether the given PCI device DMA address mask can
149 * be supported properly. For example, if your device can
150 * only drive the low 24-bits during PCI bus mastering, then
151 * you would pass 0x00ffffff as the mask to this function.
152 */
153 extern inline int pci_dma_supported(struct pci_dev *hwdev, dma_addr_t mask)
154 {
155 return 1;
156 }
157
158 /* These macros should be used after a pci_map_sg call has been done
159 * to get bus addresses of each of the SG entries and their lengths.
160 * You should only work with the number of sg entries pci_map_sg
161 * returns, or alternatively stop on the first sg_dma_len(sg) which
162 * is 0.
163 */
164 #define sg_dma_address(sg) (virt_to_bus((sg)->address))
165 #define sg_dma_len(sg) ((sg)->length)
166
167 #endif /* __KERNEL__ */
168
169 #endif /* __i386_PCI_H */
170
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.