Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/arch/powerpc/mm/ioremap.c
26424 views
1
// SPDX-License-Identifier: GPL-2.0-or-later
2
3
#include <linux/io.h>
4
#include <linux/slab.h>
5
#include <linux/mmzone.h>
6
#include <linux/vmalloc.h>
7
8
unsigned long ioremap_bot;
9
EXPORT_SYMBOL(ioremap_bot);
10
11
void __iomem *ioremap(phys_addr_t addr, unsigned long size)
12
{
13
pgprot_t prot = pgprot_noncached(PAGE_KERNEL);
14
void *caller = __builtin_return_address(0);
15
16
return __ioremap_caller(addr, size, prot, caller);
17
}
18
EXPORT_SYMBOL(ioremap);
19
20
void __iomem *ioremap_wc(phys_addr_t addr, unsigned long size)
21
{
22
pgprot_t prot = pgprot_noncached_wc(PAGE_KERNEL);
23
void *caller = __builtin_return_address(0);
24
25
return __ioremap_caller(addr, size, prot, caller);
26
}
27
EXPORT_SYMBOL(ioremap_wc);
28
29
void __iomem *ioremap_coherent(phys_addr_t addr, unsigned long size)
30
{
31
pgprot_t prot = pgprot_cached(PAGE_KERNEL);
32
void *caller = __builtin_return_address(0);
33
34
return __ioremap_caller(addr, size, prot, caller);
35
}
36
37
void __iomem *ioremap_prot(phys_addr_t addr, size_t size, pgprot_t prot)
38
{
39
pte_t pte = __pte(pgprot_val(prot));
40
void *caller = __builtin_return_address(0);
41
42
/* writeable implies dirty for kernel addresses */
43
if (pte_write(pte))
44
pte = pte_mkdirty(pte);
45
46
return __ioremap_caller(addr, size, pte_pgprot(pte), caller);
47
}
48
EXPORT_SYMBOL(ioremap_prot);
49
50
int early_ioremap_range(unsigned long ea, phys_addr_t pa,
51
unsigned long size, pgprot_t prot)
52
{
53
unsigned long i;
54
55
for (i = 0; i < size; i += PAGE_SIZE) {
56
int err = map_kernel_page(ea + i, pa + i, pgprot_nx(prot));
57
58
if (WARN_ON_ONCE(err)) /* Should clean up */
59
return err;
60
}
61
62
return 0;
63
}
64
65