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 */
10 #define pcibios_assign_all_busses() 0
12 #define PCIBIOS_MIN_IO 0x1000
13 #define PCIBIOS_MIN_MEM 0x10000000
15 void pcibios_set_master(struct pci_dev
*dev
);
16 void pcibios_penalize_isa_irq(int irq
);
18 /* Dynamic DMA mapping stuff.
19 * i386 has everything mapped statically.
22 #include <linux/types.h>
23 #include <linux/slab.h>
24 #include <asm/scatterlist.h>
25 #include <linux/string.h>
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
37 extern void *pci_alloc_consistent(struct pci_dev
*hwdev
, size_t size
,
38 dma_addr_t
*dma_handle
);
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.
45 * References to the memory and mappings associated with cpu_addr/dma_addr
46 * past this call are illegal.
48 extern void pci_free_consistent(struct pci_dev
*hwdev
, size_t size
,
49 void *vaddr
, dma_addr_t dma_handle
);
51 /* Map a single buffer of the indicated size for DMA in streaming mode.
52 * The 32-bit bus address to use is returned.
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.
57 extern inline dma_addr_t
pci_map_single(struct pci_dev
*hwdev
, void *ptr
,
58 size_t size
, int direction
)
60 if (direction
== PCI_DMA_NONE
)
62 return virt_to_bus(ptr
);
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.
69 * After this call, reads by the cpu to the buffer are guarenteed to see
70 * whatever the device wrote there.
72 extern inline void pci_unmap_single(struct pci_dev
*hwdev
, dma_addr_t dma_addr
,
73 size_t size
, int direction
)
75 if (direction
== PCI_DMA_NONE
)
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).
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.
92 * Device ownership issues as mentioned above for pci_map_single are
95 extern inline int pci_map_sg(struct pci_dev
*hwdev
, struct scatterlist
*sg
,
96 int nents
, int direction
)
98 if (direction
== PCI_DMA_NONE
)
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.
107 extern inline void pci_unmap_sg(struct pci_dev
*hwdev
, struct scatterlist
*sg
,
108 int nents
, int direction
)
110 if (direction
== PCI_DMA_NONE
)
115 /* Make physical memory consistent for a single
116 * streaming mode DMA translation after a transfer.
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.
124 extern inline void pci_dma_sync_single(struct pci_dev
*hwdev
,
125 dma_addr_t dma_handle
,
126 size_t size
, int direction
)
128 if (direction
== PCI_DMA_NONE
)
133 /* Make physical memory consistent for a set of streaming
134 * mode DMA translations after a transfer.
136 * The same as pci_dma_sync_single but for a scatter-gather list,
137 * same rules and usage.
139 extern inline void pci_dma_sync_sg(struct pci_dev
*hwdev
,
140 struct scatterlist
*sg
,
141 int nelems
, int direction
)
143 if (direction
== PCI_DMA_NONE
)
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.
153 extern inline int pci_dma_supported(struct pci_dev
*hwdev
, dma_addr_t mask
)
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
164 #define sg_dma_address(sg) (virt_to_bus((sg)->address))
165 #define sg_dma_len(sg) ((sg)->length)
167 #endif /* __KERNEL__ */
169 #endif /* __i386_PCI_H */