ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / x86_64 / kernel / pci-nommu.c
1 #include <linux/mm.h>
2 #include <linux/init.h>
3 #include <linux/pci.h>
4 #include <linux/string.h>
5 #include <asm/proto.h>
6
7 int iommu_merge = 0;
8 EXPORT_SYMBOL(iommu_merge);
9
10 dma_addr_t bad_dma_address;
11 EXPORT_SYMBOL(bad_dma_address);
12
13 /* 
14  * Dummy IO MMU functions
15  */
16
17 void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
18                            dma_addr_t *dma_handle)
19 {
20         void *ret;
21         int gfp = GFP_ATOMIC;
22         
23         if (hwdev == NULL ||
24             end_pfn > (hwdev->dma_mask>>PAGE_SHIFT) ||  /* XXX */
25             (u32)hwdev->dma_mask < 0xffffffff)
26                 gfp |= GFP_DMA;
27         ret = (void *)__get_free_pages(gfp, get_order(size));
28
29         if (ret != NULL) {
30                 memset(ret, 0, size);
31                 *dma_handle = virt_to_bus(ret);
32         }
33         return ret;
34 }
35
36 void pci_free_consistent(struct pci_dev *hwdev, size_t size,
37                          void *vaddr, dma_addr_t dma_handle)
38 {
39         free_pages((unsigned long)vaddr, get_order(size));
40 }
41
42 int pci_dma_supported(struct pci_dev *hwdev, u64 mask)
43 {
44         /*
45          * we fall back to GFP_DMA when the mask isn't all 1s,
46          * so we can't guarantee allocations that must be
47          * within a tighter range than GFP_DMA..
48                  * RED-PEN this won't work for pci_map_single. Caller has to
49                  * use GFP_DMA in the first place.
50          */
51         if (mask < 0x00ffffff)
52                 return 0;
53
54         return 1;
55
56
57 EXPORT_SYMBOL(pci_dma_supported);
58
59 static int __init check_ram(void) 
60
61         if (end_pfn >= 0xffffffff>>PAGE_SHIFT) { 
62                 printk(KERN_ERR "WARNING more than 4GB of memory but no IOMMU.\n"
63                        KERN_ERR "WARNING 32bit PCI may malfunction.\n"); 
64         } 
65         return 0;
66
67 __initcall(check_ram);
68