This repository has been archived by the owner on Jan 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
memory_manage.S
156 lines (134 loc) · 2.27 KB
/
memory_manage.S
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#include "sctlr.h"
#include "hcr.h"
.text
.balign 4
.globl FlushTLB
.type FlushTLB, %function
FlushTLB:
ISB
DSB
mcr p15, 4, r0, c8, c7, 0 // invalid all hyp tlb entries
mcr p15, 4, r0, c8, c7, 4 // invalid all hyp tlb entries
mcr p15, 0, r0, c7, c5, 6 // invalid branch predictor
DSB
ISB
bx lr
.text
.balign 4
.globl EnableMMU
.type EnableMMU, %function
EnableMMU:
mrc p15, 0, r0, c1, c0, 0
orr r0, r0, #SCTLR_M
mcr p15, 0, r0, c1, c0, 0
DSB
ISB
bx lr
.text
.balign 4
.globl DisableMMU
.type DisableMMU, %function
DisableMMU:
mrc p15, 0, r0, c1, c0, 0
bic r0, r0, #SCTLR_M
mcr p15, 0, r0, c1, c0, 0
DSB
ISB
bx lr
.text
.balign 4
.globl EnableHMMU
.type EnableHMMU, %function
EnableHMMU:
mrc p15, 4, r0, c1, c0, 0
orr r0, r0, #SCTLR_M
mcr p15, 4, r0, c1, c0, 0
DSB
ISB
bx lr
.text
.balign 4
.globl SetVTTBR
.type SetVTTBR, %function
SetVTTBR:
mcrr p15, 6, r0, r1, c2 // write VTTBR
bx lr
.text
.balign 4
.globl SetTTBCR
.type SetTTBCR, %function
SetTTBCR:
mcr p15, 0, r0, c2, c0, 2
bx lr
.text
.balign 4
.globl GetTTBCR
.type GetTTBCR, %function
GetTTBCR:
mrc p15, 0, r0, c2, c0, 2
bx lr
.text
.balign 4
.globl SetTTBR
.type SetTTBR, %function
SetTTBR:
mcrr p15, 0, r0, r1, c2
mcrr p15, 1, r2, r3, c2
bx lr
.text
.balign 4
.globl GetTTBR0
.type GetTTBR0, %function
GetTTBR0:
mrrc p15, 0, r0, r1, c2
bx lr
.text
.balign 4
.globl GetTTBR1
.type GetTTBR1, %function
GetTTBR1:
mrrc p15, 1, r0, r1, c2
bx lr
.text
.balign 4
.globl EnableVMMU
.type EnableVMMU, %function
EnableVMMU:
DSB
push {lr}
mcr p15, 4, r0, c8, c7, 0 // invalid all hyp tlb entries
mcr p15, 0, r0, c8, c7, 0 // invalid all tlb entries
mcr p15, 0, r0, c7, c5, 6 // invalid branch predictor
DSB
ISB
bl flush_cache
bl FlushTLB
mrc p15, 4, r0, c1, c1, 0
orr r0, r0, #HCR_VM
//orr r0, r0, #HCR_DC
mcr p15, 4, r0, c1, c1, 0
DSB
ISB
bl FlushTLB
pop {lr}
bx lr
.text
.balign 4
.globl EnableCache
.type EnableCache, %function
EnableCache:
mrc p15, 0, r0, c1, c0, 0
orr r0, r0, #(SCTLR_C)
orr r0, r0, #(SCTLR_I)
mcr p15, 0, r0, c1, c0, 0
bx lr
.text
.balign 4
.globl DisableCache
.type DisableCache, %function
DisableCache:
mrc p15, 0, r0, c1, c0, 0
bic r0, r0, #(SCTLR_C)
bic r0, r0, #(SCTLR_I)
mcr p15, 0, r0, c1, c0, 0
bx lr