This source file includes following definitions.
- arch_dma_prep_coherent
- uncached_kernel_address
- cached_kernel_address
1
2
3
4
5
6
7
8
9 #include <linux/kernel.h>
10 #include <linux/string.h>
11 #include <linux/types.h>
12 #include <linux/mm.h>
13 #include <linux/init.h>
14 #include <linux/dma-noncoherent.h>
15 #include <asm/cpuinfo.h>
16 #include <asm/cacheflush.h>
17
18 void arch_dma_prep_coherent(struct page *page, size_t size)
19 {
20 phys_addr_t paddr = page_to_phys(page);
21
22 flush_dcache_range(paddr, paddr + size);
23 }
24
25 #ifndef CONFIG_MMU
26
27
28
29
30
31
32
33
34
35
36
37 #ifdef CONFIG_XILINX_UNCACHED_SHADOW
38 #define UNCACHED_SHADOW_MASK (cpuinfo.dcache_high - cpuinfo.dcache_base + 1)
39 #else
40 #define UNCACHED_SHADOW_MASK 0
41 #endif
42
43 void *uncached_kernel_address(void *ptr)
44 {
45 unsigned long addr = (unsigned long)ptr;
46
47 addr |= UNCACHED_SHADOW_MASK;
48 if (addr > cpuinfo.dcache_base && addr < cpuinfo.dcache_high)
49 pr_warn("ERROR: Your cache coherent area is CACHED!!!\n");
50 return (void *)addr;
51 }
52
53 void *cached_kernel_address(void *ptr)
54 {
55 unsigned long addr = (unsigned long)ptr;
56
57 return (void *)(addr & ~UNCACHED_SHADOW_MASK);
58 }
59 #endif