- Stephen Rothwell: APM updates
[davej-history.git] / arch / i386 / kernel / pci-dma.c
blob4bd1486fe690358e604a118c1dda7f8f092649ca
1 /*
2 * Dynamic DMA mapping support.
4 * On i386 there is no hardware dynamic DMA address translation,
5 * so consistent alloc/free are merely page allocation/freeing.
6 * The rest of the dynamic DMA mapping interface is implemented
7 * in asm/pci.h.
8 */
10 #include <linux/types.h>
11 #include <linux/mm.h>
12 #include <linux/string.h>
13 #include <linux/pci.h>
14 #include <asm/io.h>
16 void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
17 dma_addr_t *dma_handle)
19 void *ret;
20 int gfp = GFP_ATOMIC;
22 if (hwdev == NULL || hwdev->dma_mask != 0xffffffff)
23 gfp |= GFP_DMA;
24 ret = (void *)__get_free_pages(gfp, get_order(size));
26 if (ret != NULL) {
27 memset(ret, 0, size);
28 *dma_handle = virt_to_bus(ret);
30 return ret;
33 void pci_free_consistent(struct pci_dev *hwdev, size_t size,
34 void *vaddr, dma_addr_t dma_handle)
36 free_pages((unsigned long)vaddr, get_order(size));