1
2
3
4
5
6
7#include <common.h>
8
9#include <asm/arch/cacheflush.h>
10
11void dcache_clean_range(volatile void *start, size_t size)
12{
13 unsigned long v, begin, end, linesz;
14
15 linesz = CONFIG_SYS_DCACHE_LINESZ;
16
17
18 begin = (unsigned long)start & ~(linesz - 1);
19 end = ((unsigned long)start + size + linesz - 1) & ~(linesz - 1);
20
21 for (v = begin; v < end; v += linesz)
22 dcache_clean_line((void *)v);
23
24 sync_write_buffer();
25}
26
27void invalidate_dcache_range(unsigned long start, unsigned long stop)
28{
29 unsigned long v, linesz;
30
31 linesz = CONFIG_SYS_DCACHE_LINESZ;
32
33
34 start = start & ~(linesz - 1);
35 stop = (stop + linesz - 1) & ~(linesz - 1);
36
37 for (v = start; v < stop; v += linesz)
38 dcache_invalidate_line((void *)v);
39}
40
41void flush_dcache_range(unsigned long start, unsigned long stop)
42{
43 unsigned long v, linesz;
44
45 linesz = CONFIG_SYS_DCACHE_LINESZ;
46
47
48 start = start & ~(linesz - 1);
49 stop = (stop + linesz - 1) & ~(linesz - 1);
50
51 for (v = start; v < stop; v += linesz)
52 dcache_flush_line((void *)v);
53
54 sync_write_buffer();
55}
56
57void icache_invalidate_range(volatile void *start, size_t size)
58{
59 unsigned long v, begin, end, linesz;
60
61 linesz = CONFIG_SYS_ICACHE_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 icache_invalidate_line((void *)v);
69}
70
71
72
73
74
75
76
77void flush_cache (unsigned long start_addr, unsigned long size)
78{
79 dcache_clean_range((void *)start_addr, size);
80 icache_invalidate_range((void *)start_addr, size);
81}
82