1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23#include <common.h>
24
25#include <asm/arch/cacheflush.h>
26
27void dcache_clean_range(volatile void *start, size_t size)
28{
29 unsigned long v, begin, end, linesz;
30
31 linesz = CONFIG_SYS_DCACHE_LINESZ;
32
33
34 begin = (unsigned long)start & ~(linesz - 1);
35 end = ((unsigned long)start + size + linesz - 1) & ~(linesz - 1);
36
37 for (v = begin; v < end; v += linesz)
38 dcache_clean_line((void *)v);
39
40 sync_write_buffer();
41}
42
43void dcache_invalidate_range(volatile void *start, size_t size)
44{
45 unsigned long v, begin, end, linesz;
46
47 linesz = CONFIG_SYS_DCACHE_LINESZ;
48
49
50 begin = (unsigned long)start & ~(linesz - 1);
51 end = ((unsigned long)start + size + linesz - 1) & ~(linesz - 1);
52
53 for (v = begin; v < end; v += linesz)
54 dcache_invalidate_line((void *)v);
55}
56
57void dcache_flush_range(volatile void *start, size_t size)
58{
59 unsigned long v, begin, end, linesz;
60
61 linesz = CONFIG_SYS_DCACHE_LINESZ;
62
63
64 begin = (unsigned long)start & ~(linesz - 1);
65 end = ((unsigned long)start + size + linesz - 1) & ~(linesz - 1);
66
67 for (v = begin; v < end; v += linesz)
68 dcache_flush_line((void *)v);
69
70 sync_write_buffer();
71}
72
73void icache_invalidate_range(volatile void *start, size_t size)
74{
75 unsigned long v, begin, end, linesz;
76
77 linesz = CONFIG_SYS_ICACHE_LINESZ;
78
79
80 begin = (unsigned long)start & ~(linesz - 1);
81 end = ((unsigned long)start + size + linesz - 1) & ~(linesz - 1);
82
83 for (v = begin; v < end; v += linesz)
84 icache_invalidate_line((void *)v);
85}
86
87
88
89
90
91
92
93void flush_cache (unsigned long start_addr, unsigned long size)
94{
95 dcache_clean_range((void *)start_addr, size);
96 icache_invalidate_range((void *)start_addr, size);
97}
98