Linux-2.6.12-rc2
[linux-2.6/kvm.git] / arch / sh / boards / harp / pcidma.c
blob475311390fd63a7d157cd19f54f2d6d3d3ecbfa3
1 /*
2 * Copyright (C) 2001 David J. Mckay (david.mckay@st.com)
4 * May be copied or modified under the terms of the GNU General Public
5 * License. See linux/COPYING for more information.
7 * Dynamic DMA mapping support.
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>
15 #include <asm/addrspace.h>
18 void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
19 dma_addr_t * dma_handle)
21 void *ret;
22 int gfp = GFP_ATOMIC;
24 ret = (void *) __get_free_pages(gfp, get_order(size));
26 if (ret != NULL) {
27 /* Is it neccessary to do the memset? */
28 memset(ret, 0, size);
29 *dma_handle = virt_to_bus(ret);
31 /* We must flush the cache before we pass it on to the device */
32 flush_cache_all();
33 return P2SEGADDR(ret);
36 void pci_free_consistent(struct pci_dev *hwdev, size_t size,
37 void *vaddr, dma_addr_t dma_handle)
39 unsigned long p1addr=P1SEGADDR((unsigned long)vaddr);
41 free_pages(p1addr, get_order(size));