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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
|
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Email: [email protected]
*
* Change Logs:
* Date Author Notes
* 2023-07-26 huanghe first commit
* 2024-07-02 zhangyan modify
*
*/
#include "fparameters.h"
#include "rtconfig.h"
#ifndef __aarch64__
.globl cpu_id_mapping
cpu_id_mapping:
#if defined(TARGET_PE2204)
cmp r0, #0 // compare cpu_id with 0
beq map_cpu_id_0
cmp r0, #1 // compare cpu_id with 1
beq map_cpu_id_1
cmp r0, #2 // compare cpu_id with 2
beq map_cpu_id_2
cmp r0, #3 // compare cpu_id with 3
beq map_cpu_id_3
mov pc, lr // no mapping needed
#endif
mov pc, lr // no mapping needed
// Mapping for PE2204
map_cpu_id_0:
mov r0, #2
mov pc, lr
map_cpu_id_1:
mov r0, #3
mov pc, lr
map_cpu_id_2:
mov r0, #0
mov pc, lr
map_cpu_id_3:
mov r0, #1
mov pc, lr
.globl rt_hw_cpu_id_early
rt_hw_cpu_id_early:
// read MPIDR
mov r9, lr
mrc p15, 0, r0, c0, c0, 5
ubfx r0, r0, #0, #12
ldr r1,= CORE0_AFF
cmp r0, r1
beq core0
#if defined(CORE1_AFF)
ldr r1,= CORE1_AFF
cmp r0, r1
beq core1
#endif
#if defined(CORE2_AFF)
ldr r1,= CORE2_AFF
cmp r0, r1
beq core2
#endif
#if defined(CORE3_AFF)
ldr r1,= CORE3_AFF
cmp r0, r1
beq core3
#endif
b default
core0:
mov r0, #0
b return
core1:
mov r0, #1
b return
core2:
mov r0, #2
b return
core3:
mov r0, #3
b return
default:
and r0, r0, #15
return:
bl cpu_id_mapping
mov pc, r9
#else
.globl cpu_id_mapping
cpu_id_mapping:
#if defined(TARGET_PE2204)
#if defined(USE_OPENAMP)
cmp x0, #0 // compare cpu_id with 0
beq map_cpu_id_0
cmp x0, #1 // compare cpu_id with 2
beq map_cpu_id_2
cmp x0, #2 // compare cpu_id with 1
beq map_cpu_id_1
cmp x0, #3 // compare cpu_id with 3
beq map_cpu_id_3
RET // no mapping needed
#else
cmp x0, #0 // compare cpu_id with 0
beq map_cpu_id_0
cmp x0, #1 // compare cpu_id with 1
beq map_cpu_id_1
cmp x0, #2 // compare cpu_id with 2
beq map_cpu_id_2
cmp x0, #3 // compare cpu_id with 3
beq map_cpu_id_3
RET // no mapping needed
#endif
#endif
RET // no mapping needed
// Mapping for PE2204
map_cpu_id_0:
mov x0, #2
RET
map_cpu_id_1:
mov x0, #3
RET
map_cpu_id_2:
mov x0, #0
RET
map_cpu_id_3:
mov x0, #1
RET
.globl rt_hw_cpu_id_set
rt_hw_cpu_id_set:
mov x9, lr
mrs x0,MPIDR_EL1
and x1, x0, #15
msr tpidr_el1, x1
mov lr, x9
RET
.globl rt_hw_cpu_id
rt_hw_cpu_id:
mrs x0,MPIDR_EL1
ubfx x0, x0, #0, #20
ldr x1,= CORE0_AFF
cmp x0, x1
beq core0
#if defined(CORE1_AFF)
ldr x1,= CORE1_AFF
cmp x0, x1
beq core1
#endif
#if defined(CORE2_AFF)
ldr x1,= CORE2_AFF
cmp x0, x1
beq core2
#endif
#if defined(CORE3_AFF)
ldr x1,= CORE3_AFF
cmp x0, x1
beq core3
#endif
#if defined(CORE4_AFF)
ldr x1,= CORE4_AFF
cmp x0, x1
beq core4
#endif
#if defined(CORE5_AFF)
ldr x1,= CORE5_AFF
cmp x0, x1
beq core5
#endif
#if defined(CORE6_AFF)
ldr x1,= CORE6_AFF
cmp x0, x1
beq core6
#endif
#if defined(CORE7_AFF)
ldr x1,= CORE7_AFF
cmp x0, x1
beq core7
#endif
core0:
mov x0, #0
b return
core1:
mov x0, #1
b return
core2:
mov x0, #2
b return
core3:
mov x0, #3
b return
core4:
mov x0, #4
b return
core5:
mov x0, #5
b return
core6:
mov x0, #6
b return
core7:
mov x0, #7
b return
return:
b cpu_id_mapping
RET
#endif
|