]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * Copyright (C) 2000 David J. Mckay (david.mckay@st.com) | |
3 | * | |
4 | * May be copied or modified under the terms of the GNU General Public | |
5 | * License. See linux/COPYING for more information. | |
6 | * | |
7 | * Dynamic DMA mapping support. | |
8 | * | |
9 | * On the overdrive, we can only DMA from memory behind the PCI bus! | |
10 | * this means that all DMA'able memory must come from there. | |
11 | * this restriction will not apply to later boards. | |
12 | */ | |
13 | ||
14 | #include <linux/types.h> | |
15 | #include <linux/mm.h> | |
16 | #include <linux/string.h> | |
17 | #include <linux/pci.h> | |
18 | #include <asm/io.h> | |
19 | ||
20 | void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size, | |
21 | dma_addr_t * dma_handle) | |
22 | { | |
23 | void *ret; | |
24 | int gfp = GFP_ATOMIC; | |
25 | ||
26 | printk("BUG: pci_alloc_consistent() called - not yet supported\n"); | |
27 | /* We ALWAYS need DMA memory on the overdrive hardware, | |
28 | * due to it's extreme weirdness | |
29 | * Need to flush the cache here as well, since the memory | |
30 | * can still be seen through the cache! | |
31 | */ | |
32 | gfp |= GFP_DMA; | |
33 | ret = (void *) __get_free_pages(gfp, get_order(size)); | |
34 | ||
35 | if (ret != NULL) { | |
36 | memset(ret, 0, size); | |
37 | *dma_handle = virt_to_bus(ret); | |
38 | } | |
39 | return ret; | |
40 | } | |
41 | ||
42 | void pci_free_consistent(struct pci_dev *hwdev, size_t size, | |
43 | void *vaddr, dma_addr_t dma_handle) | |
44 | { | |
45 | free_pages((unsigned long) vaddr, get_order(size)); | |
46 | } |