-
-
Notifications
You must be signed in to change notification settings - Fork 268
Expand file tree
/
Copy pathutils_asm.S
More file actions
207 lines (186 loc) · 4 KB
/
utils_asm.S
File metadata and controls
207 lines (186 loc) · 4 KB
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
/* SPDX-License-Identifier: MIT */
#include "cpu_regs.h"
.text
.globl memcpy128
.type memcpy128, @function
memcpy128:
ands x2, x2, #~15
beq 2f
1: ldp x3, x4, [x1], #16
stp x3, x4, [x0], #16
subs x2, x2, #16
bne 1b
2:
ret
.globl memcpy64
.type memcpy64, @function
memcpy64:
ands x2, x2, #~7
beq 2f
1: ldr x3, [x1], #8
str x3, [x0], #8
subs x2, x2, #8
bne 1b
2:
ret
.globl memset64
.type memset64, @function
memset64:
ands x2, x2, #~7
beq 2f
1: str x1, [x0], #8
subs x2, x2, #8
bne 1b
2:
ret
.globl memcpy32
.type memcpy32, @function
memcpy32:
ands x2, x2, #~3
beq 2f
1: ldr w3, [x1], #4
str w3, [x0], #4
subs x2, x2, #4
bne 1b
2:
ret
.globl memset32
.type memset32, @function
memset32:
ands x2, x2, #~3
beq 2f
1: str w1, [x0], #4
subs x2, x2, #4
bne 1b
2:
ret
.globl memcpy16
.type memcpy16, @function
memcpy16:
ands x2, x2, #~1
beq 2f
1: ldrh w3, [x1], #2
strh w3, [x0], #2
subs x2, x2, #2
bne 1b
2:
ret
.globl memset16
.type memset16, @function
memset16:
ands x2, x2, #~1
beq 2f
1: strh w1, [x0], #2
subs x2, x2, #2
bne 1b
2:
ret
.globl memcpy8
.type memcpy8, @function
memcpy8:
cmp x2, #0
beq 2f
1: ldrb w3, [x1], #1
strb w3, [x0], #1
subs x2, x2, #1
bne 1b
2:
ret
.globl memset8
.type memset8, @function
memset8:
cmp x2, #0
beq 2f
1: strb w1, [x0], #1
subs x2, x2, #1
bne 1b
2:
ret
.globl get_simd_state
.type get_simd_state, @function
get_simd_state:
stp q0, q1, [x0], #32
stp q2, q3, [x0], #32
stp q4, q5, [x0], #32
stp q6, q7, [x0], #32
stp q8, q9, [x0], #32
stp q10, q11, [x0], #32
stp q12, q13, [x0], #32
stp q14, q15, [x0], #32
stp q16, q17, [x0], #32
stp q18, q19, [x0], #32
stp q20, q21, [x0], #32
stp q22, q23, [x0], #32
stp q24, q25, [x0], #32
stp q26, q27, [x0], #32
stp q28, q29, [x0], #32
stp q30, q31, [x0], #32
ret
.globl put_simd_state
.type put_simd_state, @function
put_simd_state:
ldp q0, q1, [x0], #32
ldp q2, q3, [x0], #32
ldp q4, q5, [x0], #32
ldp q6, q7, [x0], #32
ldp q8, q9, [x0], #32
ldp q10, q11, [x0], #32
ldp q12, q13, [x0], #32
ldp q14, q15, [x0], #32
ldp q16, q17, [x0], #32
ldp q18, q19, [x0], #32
ldp q20, q21, [x0], #32
ldp q22, q23, [x0], #32
ldp q24, q25, [x0], #32
ldp q26, q27, [x0], #32
ldp q28, q29, [x0], #32
ldp q30, q31, [x0], #32
ret
.globl _deep_wfi_helper
.type _deep_wfi_helper, @function
_deep_wfi_helper:
stp x30, x0, [sp, #-16]!
stp x28, x29, [sp, #-16]!
stp x26, x27, [sp, #-16]!
stp x24, x25, [sp, #-16]!
stp x22, x23, [sp, #-16]!
stp x20, x21, [sp, #-16]!
stp x18, x19, [sp, #-16]!
wfi
ldp x18, x19, [sp], #16
ldp x20, x21, [sp], #16
ldp x22, x23, [sp], #16
ldp x24, x25, [sp], #16
ldp x26, x27, [sp], #16
ldp x28, x29, [sp], #16
ldp x30, x0, [sp], #16
ret
.extern smp_do_switch_boot_cpu
.globl smp_switch_boot_cpu_entry
.type smp_switch_boot_cpu_entry, @function
smp_switch_boot_cpu_entry:
stp x29, x30, [sp, #-16]!
mov x29, sp
stp x27, x28, [sp, #-16]!
stp x25, x26, [sp, #-16]!
stp x23, x24, [sp, #-16]!
stp x21, x22, [sp, #-16]!
stp x19, x20, [sp, #-16]!
stp x17, x18, [sp, #-16]!
mov x1, sp
bl smp_do_switch_boot_cpu
// unreachable
b .
.globl smp_switch_boot_cpu_exit
.type smp_switch_boot_cpu_exit, @function
smp_switch_boot_cpu_exit:
mov sp, x1
ldp x17, x18, [sp], #16
ldp x19, x20, [sp], #16
ldp x21, x22, [sp], #16
ldp x23, x24, [sp], #16
ldp x25, x26, [sp], #16
ldp x27, x28, [sp], #16
ldp x29, x30, [sp], #16
// passes argument in x0 as return value
ret // looks like a return from smp_switch_boot_cpu_entry on the new boot cpu