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 void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
20 dma_addr_t * dma_handle)
24 struct pci_bus *bus = NULL;
27 if (hwdev == NULL || hwdev->dma_mask != 0xffffffff)
30 ret = (void *) __get_free_pages(gfp, get_order(size));
36 *dma_handle = bus_to_baddr(bus, __pa(ret));
37 #ifdef CONFIG_NONCOHERENT_IO
38 dma_cache_wback_inv((unsigned long) ret, size);
39 ret = UNCAC_ADDR(ret);
46 void pci_free_consistent(struct pci_dev *hwdev, size_t size,
47 void *vaddr, dma_addr_t dma_handle)
49 unsigned long addr = (unsigned long) vaddr;
51 #ifdef CONFIG_NONCOHERENT_IO
52 addr = CAC_ADDR(addr);
54 free_pages(addr, get_order(size));
57 EXPORT_SYMBOL(pci_alloc_consistent);
58 EXPORT_SYMBOL(pci_free_consistent);