summaryrefslogtreecommitdiff
path: root/libcpu/aarch64/common/cache_ops.c
blob: 517845e924516c24d1beb9761707e35dcbfa3c57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2021-12-28     GuEe-GUI     the first version
 */

#include <rthw.h>
#include <rtdef.h>

void __asm_flush_dcache_all(void);
void __asm_invalidate_dcache_all(void);
void __asm_flush_dcache_range(unsigned long start, unsigned long end);
void __asm_invalidate_dcache_range(unsigned long start, unsigned long end);

void __asm_invalidate_icache_all(void);
void __asm_invalidate_icache_range(unsigned long start, unsigned long end);

void rt_hw_dcache_flush_all(void)
{
    __asm_flush_dcache_all();
}

void rt_hw_dcache_invalidate_all(void)
{
    __asm_invalidate_dcache_all();
}

void rt_hw_dcache_flush_range(unsigned long start_addr, unsigned long size)
{
    __asm_flush_dcache_range(start_addr, start_addr + size);
}

void rt_hw_dcache_invalidate_range(unsigned long start_addr,unsigned long size)
{
    __asm_invalidate_dcache_range(start_addr, start_addr + size);
}

void rt_hw_icache_invalidate_all()
{
    __asm_invalidate_icache_all();
}

void rt_hw_icache_invalidate_range(unsigned long start_addr, int size)
{
    __asm_invalidate_icache_range(start_addr, start_addr + size);
}

void rt_hw_cpu_icache_ops(int ops, void *addr, int size)
{
    if (ops == RT_HW_CACHE_INVALIDATE)
    {
        rt_hw_icache_invalidate_range((unsigned long)addr, size);
    }
}

void rt_hw_cpu_dcache_ops(int ops, void *addr, int size)
{
    if (ops == RT_HW_CACHE_FLUSH)
    {
        rt_hw_dcache_flush_range((unsigned long)addr, size);
    }
    else if (ops == RT_HW_CACHE_INVALIDATE)
    {
        rt_hw_dcache_invalidate_range((unsigned long)addr, size);
    }
}