This source file includes following definitions.
- ioremap_wt
- __ioremap_caller
- iounmap
1
2
3 #include <linux/io.h>
4 #include <linux/slab.h>
5 #include <linux/vmalloc.h>
6
7 #include <mm/mmu_decl.h>
8
9 void __iomem *ioremap_wt(phys_addr_t addr, unsigned long size)
10 {
11 pgprot_t prot = pgprot_cached_wthru(PAGE_KERNEL);
12
13 return __ioremap_caller(addr, size, prot, __builtin_return_address(0));
14 }
15 EXPORT_SYMBOL(ioremap_wt);
16
17 void __iomem *
18 __ioremap_caller(phys_addr_t addr, unsigned long size, pgprot_t prot, void *caller)
19 {
20 unsigned long v;
21 phys_addr_t p, offset;
22 int err;
23
24
25
26
27
28
29
30 p = addr & PAGE_MASK;
31 offset = addr & ~PAGE_MASK;
32 size = PAGE_ALIGN(addr + size) - p;
33
34
35
36
37
38 if (p < 16 * 1024 * 1024)
39 p += _ISA_MEM_BASE;
40
41 #ifndef CONFIG_CRASH_DUMP
42
43
44
45
46 if (slab_is_available() && p <= virt_to_phys(high_memory - 1) &&
47 page_is_ram(__phys_to_pfn(p))) {
48 pr_warn("%s(): phys addr 0x%llx is RAM lr %ps\n", __func__,
49 (unsigned long long)p, __builtin_return_address(0));
50 return NULL;
51 }
52 #endif
53
54 if (size == 0)
55 return NULL;
56
57
58
59
60
61 v = p_block_mapped(p);
62 if (v)
63 return (void __iomem *)v + offset;
64
65 if (slab_is_available())
66 return do_ioremap(p, offset, size, prot, caller);
67
68
69
70
71
72 err = early_ioremap_range(ioremap_bot - size, p, size, prot);
73 if (err)
74 return NULL;
75 ioremap_bot -= size;
76
77 return (void __iomem *)ioremap_bot + offset;
78 }
79
80 void iounmap(volatile void __iomem *addr)
81 {
82
83
84
85
86 if (v_block_mapped((unsigned long)addr))
87 return;
88
89 if (addr > high_memory && (unsigned long)addr < ioremap_bot)
90 vunmap((void *)(PAGE_MASK & (unsigned long)addr));
91 }
92 EXPORT_SYMBOL(iounmap);