This source file includes following definitions.
- __ioremap_caller
- ioremap
- iounmap
1
2
3
4
5
6
7 #include <linux/export.h>
8 #include <linux/mm.h>
9 #include <linux/vmalloc.h>
10 #include <linux/io.h>
11
12 #include <asm/pgtable.h>
13
14
15
16
17
18
19
20
21
22
23 static void __iomem *__ioremap_caller(phys_addr_t addr, size_t size,
24 pgprot_t prot, void *caller)
25 {
26 phys_addr_t last_addr;
27 unsigned long offset, vaddr;
28 struct vm_struct *area;
29
30
31 last_addr = addr + size - 1;
32 if (!size || last_addr < addr)
33 return NULL;
34
35
36 offset = addr & (~PAGE_MASK);
37 addr -= offset;
38 size = PAGE_ALIGN(size + offset);
39
40 area = get_vm_area_caller(size, VM_IOREMAP, caller);
41 if (!area)
42 return NULL;
43 vaddr = (unsigned long)area->addr;
44
45 if (ioremap_page_range(vaddr, vaddr + size, addr, prot)) {
46 free_vm_area(area);
47 return NULL;
48 }
49
50 return (void __iomem *)(vaddr + offset);
51 }
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66 void __iomem *ioremap(phys_addr_t offset, unsigned long size)
67 {
68 return __ioremap_caller(offset, size, PAGE_KERNEL,
69 __builtin_return_address(0));
70 }
71 EXPORT_SYMBOL(ioremap);
72
73
74
75
76
77
78
79
80 void iounmap(volatile void __iomem *addr)
81 {
82 vunmap((void *)((unsigned long)addr & PAGE_MASK));
83 }
84 EXPORT_SYMBOL(iounmap);