patch-2.4.23 linux-2.4.23/include/asm-ppc/pci.h
Next file: linux-2.4.23/include/asm-ppc/pgalloc.h
Previous file: linux-2.4.23/include/asm-ppc/page.h
Back to the patch index
Back to the overall index
- Lines: 159
- Date:
2003-11-28 10:26:21.000000000 -0800
- Orig file:
linux-2.4.22/include/asm-ppc/pci.h
- Orig date:
2003-08-25 04:44:44.000000000 -0700
diff -urN linux-2.4.22/include/asm-ppc/pci.h linux-2.4.23/include/asm-ppc/pci.h
@@ -2,6 +2,14 @@
#define __PPC_PCI_H
#ifdef __KERNEL__
+#include <linux/types.h>
+#include <linux/slab.h>
+#include <linux/string.h>
+#include <asm/scatterlist.h>
+#include <asm/io.h>
+
+struct pci_dev;
+
/* Values for the `which' argument to sys_pciconfig_iobase syscall. */
#define IOBASE_BRIDGE_NUMBER 0
#define IOBASE_MEMORY 1
@@ -16,6 +24,7 @@
extern int pci_assign_all_busses;
#define pcibios_assign_all_busses() (pci_assign_all_busses)
+#define pcibios_scan_all_fns() 0
#define PCIBIOS_MIN_IO 0x1000
#define PCIBIOS_MIN_MEM 0x10000000
@@ -43,18 +52,12 @@
extern unsigned long pci_phys_to_bus(unsigned long pa, int busnr);
extern unsigned long pci_bus_to_phys(unsigned int ba, int busnr);
-/* Dynamic DMA Mapping stuff, stolen from i386
- * ++ajoshi
+/*
+ * Dynamic DMA Mapping stuff
+ * Originally stolen from i386 by ajoshi and updated by paulus
+ * Non-consistent cache support by Dan Malek
*/
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/string.h>
-#include <asm/scatterlist.h>
-#include <asm/io.h>
-
-struct pci_dev;
-
/* The PCI address space does equal the physical memory
* address space. The networking and block device layers use
* this boolean for bounce buffer decisions.
@@ -91,8 +94,8 @@
static inline dma_addr_t pci_map_single(struct pci_dev *hwdev, void *ptr,
size_t size, int direction)
{
- if (direction == PCI_DMA_NONE)
- BUG();
+ BUG_ON(direction == PCI_DMA_NONE);
+ consistent_sync(ptr, size, direction);
return virt_to_bus(ptr);
}
@@ -117,10 +120,11 @@
* to pci_map_single, but takes a struct page instead of a virtual address
*/
static inline dma_addr_t pci_map_page(struct pci_dev *hwdev, struct page *page,
- unsigned long offset, size_t size, int direction)
+ unsigned long offset, size_t size,
+ int direction)
{
- if (direction == PCI_DMA_NONE)
- BUG();
+ BUG_ON(direction == PCI_DMA_NONE);
+ consistent_sync_page(page, offset, size, direction);
return (page - mem_map) * PAGE_SIZE + PCI_DRAM_OFFSET + offset;
}
@@ -136,7 +140,8 @@
* mode for DMA. This is the scather-gather version of the
* above pci_map_single interface. Here the scatter gather list
* elements are each tagged with the appropriate dma address
- * and length. They are obtained via sg_dma_{address,length}(SG).
+ * and length. They are obtained via sg_dma_{address,len}(SG),
+ * defined in <asm/scatterlist.h>.
*
* NOTE: An implementation may be able to use a smaller number of
* DMA address/length pairs than there are SG table elements.
@@ -164,10 +169,15 @@
else if (!sg[i].address && !sg[i].page)
BUG();
- if (sg[i].address)
+ if (sg[i].address) {
+ consistent_sync(sg[i].address, sg[i].length, direction);
sg[i].dma_address = virt_to_bus(sg[i].address);
- else
+ } else {
+ consistent_sync_page(sg[i].page, sg[i].offset,
+ sg[i].length, direction);
sg[i].dma_address = page_to_bus(sg[i].page) + sg[i].offset;
+ }
+ sg[i].dma_length = sg[i].length;
}
return nents;
@@ -180,8 +190,7 @@
static inline void pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg,
int nents, int direction)
{
- if (direction == PCI_DMA_NONE)
- BUG();
+ BUG_ON(direction == PCI_DMA_NONE);
/* nothing to do */
}
@@ -198,9 +207,9 @@
dma_addr_t dma_handle,
size_t size, int direction)
{
- if (direction == PCI_DMA_NONE)
- BUG();
- /* nothing to do */
+ BUG_ON(direction == PCI_DMA_NONE);
+
+ consistent_sync(bus_to_virt(dma_handle), size, direction);
}
/* Make physical memory consistent for a set of streaming
@@ -213,9 +222,17 @@
struct scatterlist *sg,
int nelems, int direction)
{
- if (direction == PCI_DMA_NONE)
- BUG();
- /* nothing to do */
+ int i;
+
+ BUG_ON(direction == PCI_DMA_NONE);
+
+ for (i = 0; i < nelems; i++, sg++) {
+ if (sg->address)
+ consistent_sync(sg->address, sg->length, direction);
+ else
+ consistent_sync_page(sg->page, sg->offset,
+ sg->length, direction);
+ }
}
/* Return whether the given PCI device DMA address mask can
@@ -258,14 +275,6 @@
/* Nothing to do. */
}
-/* These macros should be used after a pci_map_sg call has been done
- * to get bus addresses of each of the SG entries and their lengths.
- * You should only work with the number of sg entries pci_map_sg
- * returns.
- */
-#define sg_dma_address(sg) ((sg)->dma_address)
-#define sg_dma_len(sg) ((sg)->length)
-
/* Return the index of the PCI controller for device PDEV. */
extern int pci_controller_num(struct pci_dev *pdev);
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)