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.
10 #include <linux/types.h>
12 #include <linux/string.h>
13 #include <linux/pci.h>
15 #include <asm/addrspace.h>
18 void *pci_alloc_consistent(struct pci_dev
*hwdev
, size_t size
,
19 dma_addr_t
* dma_handle
)
24 ret
= (void *) __get_free_pages(gfp
, get_order(size
));
27 /* Is it neccessary to do the memset? */
29 *dma_handle
= virt_to_bus(ret
);
31 /* We must flush the cache before we pass it on to the device */
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
));