2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Copyright (C) 2000 Ani Joshi <ajoshi@unixbox.com>
7 * Copyright (C) 2000, 2001 Ralf Baechle <ralf@gnu.org>
8 * swiped from i386, and cloned for MIPS by Geert, polished by Ralf.
10 #include <linux/config.h>
11 #include <linux/types.h>
13 #include <linux/module.h>
14 #include <linux/string.h>
15 #include <linux/pci.h>
19 #ifndef UNCAC_BASE /* Hack ... */
20 #define UNCAC_BASE 0x9000000000000000UL
23 void *dma_alloc_coherent(struct device
*dev
, size_t size
,
24 dma_addr_t
* dma_handle
, int gfp
)
27 /* ignore region specifiers */
28 gfp
&= ~(__GFP_DMA
| __GFP_HIGHMEM
);
30 if (dev
== NULL
|| (*dev
->dma_mask
< 0xffffffff))
32 ret
= (void *) __get_free_pages(gfp
, get_order(size
));
36 #if 0 /* Broken support for some platforms ... */
39 *dma_handle
= bus_to_baddr(bus
, __pa(ret
));
41 *dma_handle
= virt_to_phys(ret
);
43 #ifdef CONFIG_NONCOHERENT_IO
44 dma_cache_wback_inv((unsigned long) ret
, size
);
45 ret
= UNCAC_ADDR(ret
);
52 void dma_free_coherent(struct device
*dev
, size_t size
,
53 void *vaddr
, dma_addr_t dma_handle
)
55 unsigned long addr
= (unsigned long) vaddr
;
57 #ifdef CONFIG_NONCOHERENT_IO
58 addr
= CAC_ADDR(addr
);
60 free_pages(addr
, get_order(size
));
63 EXPORT_SYMBOL(pci_alloc_consistent
);
64 EXPORT_SYMBOL(pci_free_consistent
);