This source file includes following definitions.
- __ioremap_caller
- iomapping_nontranslatable
- __iounmap
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 #include <linux/vmalloc.h>
16 #include <linux/module.h>
17 #include <linux/slab.h>
18 #include <linux/mm.h>
19 #include <linux/pci.h>
20 #include <linux/io.h>
21 #include <asm/page.h>
22 #include <asm/pgalloc.h>
23 #include <asm/addrspace.h>
24 #include <asm/cacheflush.h>
25 #include <asm/tlbflush.h>
26 #include <asm/mmu.h>
27
28
29
30
31
32
33
34
35
36
37 void __iomem * __ref
38 __ioremap_caller(phys_addr_t phys_addr, unsigned long size,
39 pgprot_t pgprot, void *caller)
40 {
41 struct vm_struct *area;
42 unsigned long offset, last_addr, addr, orig_addr;
43 void __iomem *mapped;
44
45
46 last_addr = phys_addr + size - 1;
47 if (!size || last_addr < phys_addr)
48 return NULL;
49
50
51
52
53 if (!mem_init_done)
54 return ioremap_fixed(phys_addr, size, pgprot);
55
56
57
58
59
60 mapped = pmb_remap_caller(phys_addr, size, pgprot, caller);
61 if (mapped && !IS_ERR(mapped))
62 return mapped;
63
64
65
66
67 offset = phys_addr & ~PAGE_MASK;
68 phys_addr &= PAGE_MASK;
69 size = PAGE_ALIGN(last_addr+1) - phys_addr;
70
71
72
73
74 area = get_vm_area_caller(size, VM_IOREMAP, caller);
75 if (!area)
76 return NULL;
77 area->phys_addr = phys_addr;
78 orig_addr = addr = (unsigned long)area->addr;
79
80 if (ioremap_page_range(addr, addr + size, phys_addr, pgprot)) {
81 vunmap((void *)orig_addr);
82 return NULL;
83 }
84
85 return (void __iomem *)(offset + (char *)orig_addr);
86 }
87 EXPORT_SYMBOL(__ioremap_caller);
88
89
90
91
92 static inline int iomapping_nontranslatable(unsigned long offset)
93 {
94 #ifdef CONFIG_29BIT
95
96
97
98
99 if (PXSEG(offset) < P3SEG || offset >= P3_ADDR_MAX)
100 return 1;
101 #endif
102
103 return 0;
104 }
105
106 void __iounmap(void __iomem *addr)
107 {
108 unsigned long vaddr = (unsigned long __force)addr;
109 struct vm_struct *p;
110
111
112
113
114 if (iomapping_nontranslatable(vaddr))
115 return;
116
117
118
119
120 if (iounmap_fixed(addr) == 0)
121 return;
122
123
124
125
126 if (pmb_unmap(addr) == 0)
127 return;
128
129 p = remove_vm_area((void *)(vaddr & PAGE_MASK));
130 if (!p) {
131 printk(KERN_ERR "%s: bad address %p\n", __func__, addr);
132 return;
133 }
134
135 kfree(p);
136 }
137 EXPORT_SYMBOL(__iounmap);