• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU)
3 * Licensed under the Mulan PSL v2.
4 * You can use this software according to the terms and conditions of the Mulan PSL v2.
5 * You may obtain a copy of Mulan PSL v2 at:
6 *     http://license.coscl.org.cn/MulanPSL2
7 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
8 * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
9 * PURPOSE.
10 * See the Mulan PSL v2 for more details.
11 */
12#include <common/asm.h>
13#include <common/vars.h>
14
15    .macro  read_ctr, reg
16        mrs     \reg, ctr_el0
17        nop
18    .endm
19
20    .macro  dcache_line_size, reg, tmp
21	read_ctr        \tmp
22        /* cache line size encoding */
23	ubfm            \tmp, \tmp, #16, #19
24        /* bytes per word */
25	mov             \reg, #4
26        /* actual cache line size */
27	lsl             \reg, \reg, \tmp
28    .endm
29
30    .macro dcache_by_line_op op, domain, kaddr, size, tmp1, tmp2
31        dcache_line_size \tmp1, \tmp2
32        add     \size, \kaddr, \size
33        sub     \tmp2, \tmp1, #1
34        bic     \kaddr, \kaddr, \tmp2
351:
36        dc      \op, \kaddr
37        add     \kaddr, \kaddr, \tmp1
38        cmp     \kaddr, \size
39        b.lo    1b
40        dsb     \domain
41    .endm
42
43BEGIN_FUNC(flush_dcache_area)
44	dcache_by_line_op civac, sy, x0, x1, x2, x3
45	ret
46END_FUNC(flush_dcache_area)
47
48BEGIN_FUNC(put8)
49    strb w1,[x0]
50    ret
51END_FUNC(put8)
52
53BEGIN_FUNC(get8)
54    ldrb w0,[x0]
55    ret
56END_FUNC(get8)
57
58BEGIN_FUNC(put32)
59    str w1,[x0]
60    ret
61END_FUNC(put32)
62
63BEGIN_FUNC(get32)
64    ldr w0,[x0]
65    ret
66END_FUNC(get32)
67
68BEGIN_FUNC(put64)
69    str x1,[x0]
70    ret
71END_FUNC(put64)
72
73BEGIN_FUNC(get64)
74    ldr x0,[x0]
75    ret
76END_FUNC(get64)
77