1
2
3
4
5
6
7
8
9
10#include <asm-offsets.h>
11#include <config.h>
12#include <asm/macro.h>
13#include <asm/system.h>
14#include <linux/linkage.h>
15
16
17
18
19
20
21
22
23
24
25ENTRY(__asm_dcache_level)
26 lsl x12, x0,
27 msr csselr_el1, x12
28 isb
29 mrs x6, ccsidr_el1
30 and x2, x6,
31 add x2, x2,
32 mov x3,
33 and x3, x3, x6, lsr
34 clz w5, w3
35 mov x4,
36 and x4, x4, x6, lsr
37
38
39
40
41
42
43loop_set:
44 mov x6, x3
45loop_way:
46 lsl x7, x6, x5
47 orr x9, x12, x7
48 lsl x7, x4, x2
49 orr x9, x9, x7
50 tbz w1,
51 dc isw, x9
52 b 2f
531: dc cisw, x9
542: subs x6, x6,
55 b.ge loop_way
56 subs x4, x4,
57 b.ge loop_set
58
59 ret
60ENDPROC(__asm_dcache_level)
61
62
63
64
65
66
67
68
69ENTRY(__asm_dcache_all)
70 mov x1, x0
71 dsb sy
72 mrs x10, clidr_el1
73 lsr x11, x10,
74 and x11, x11,
75 cbz x11, finished
76 mov x15, lr
77 mov x0,
78
79
80
81
82
83loop_level:
84 lsl x12, x0,
85 add x12, x12, x0
86 lsr x12, x10, x12
87 and x12, x12,
88 cmp x12,
89 b.lt skip
90 bl __asm_dcache_level
91skip:
92 add x0, x0,
93 cmp x11, x0
94 b.gt loop_level
95
96 mov x0,
97 msr csselr_el1, x0
98 dsb sy
99 isb
100 mov lr, x15
101
102finished:
103 ret
104ENDPROC(__asm_dcache_all)
105
106ENTRY(__asm_flush_dcache_all)
107 mov x0,
108 b __asm_dcache_all
109ENDPROC(__asm_flush_dcache_all)
110
111ENTRY(__asm_invalidate_dcache_all)
112 mov x0,
113 b __asm_dcache_all
114ENDPROC(__asm_invalidate_dcache_all)
115
116
117
118
119
120
121
122
123
124ENTRY(__asm_flush_dcache_range)
125 mrs x3, ctr_el0
126 lsr x3, x3,
127 and x3, x3,
128 mov x2,
129 lsl x2, x2, x3
130
131
132 sub x3, x2,
133 bic x0, x0, x3
1341: dc civac, x0
135 add x0, x0, x2
136 cmp x0, x1
137 b.lo 1b
138 dsb sy
139 ret
140ENDPROC(__asm_flush_dcache_range)
141
142
143
144
145
146
147ENTRY(__asm_invalidate_icache_all)
148 ic ialluis
149 isb sy
150 ret
151ENDPROC(__asm_invalidate_icache_all)
152
153ENTRY(__asm_flush_l3_cache)
154 mov x0,
155 ret
156ENDPROC(__asm_flush_l3_cache)
157 .weak __asm_flush_l3_cache
158
159
160
161
162
163
164ENTRY(__asm_switch_ttbr)
165
166 switch_el x4, 3f, 2f, 1f
1673: mrs x2, sctlr_el3
168 b 0f
1692: mrs x2, sctlr_el2
170 b 0f
1711: mrs x2, sctlr_el1
1720:
173
174
175 movn x1,
176 and x1, x2, x1
177 switch_el x4, 3f, 2f, 1f
1783: msr sctlr_el3, x1
179 b 0f
1802: msr sctlr_el2, x1
181 b 0f
1821: msr sctlr_el1, x1
1830: isb
184
185
186 mov x3, x30
187 bl __asm_invalidate_tlb_all
188
189
190
191
192 switch_el x4, 3f, 2f, 1f
1933: msr ttbr0_el3, x0
194 b 0f
1952: msr ttbr0_el2, x0
196 b 0f
1971: msr ttbr0_el1, x0
1980: isb
199
200
201 switch_el x4, 3f, 2f, 1f
2023: msr sctlr_el3, x2
203 b 0f
2042: msr sctlr_el2, x2
205 b 0f
2061: msr sctlr_el1, x2
2070: isb
208
209 ret x3
210ENDPROC(__asm_switch_ttbr)
211