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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
|
/*
* @Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
*
* @FilePath: fgic_cpu_interface.S
* @Date: 2022-03-29 18:04:23
* @LastEditTime: 2022-03-29 18:04:27
* @Description: This file is Mapping of MSR and MRS to physical and virtual CPU interface registers.
*
* Modify History:
* Ver Who Date Changes
* ----- ------ -------- --------------------------------------
* 1.0 huanghe 2022/4/16 init commit
*/
#ifdef __aarch64__
/*
* Mapping of MSR and MRS to physical and virtual CPU interface registers
*
* ARM Generic Interrupt Controller Architecture Specification
* GIC architecture version 3.0 and version 4.0
* Table 8-5
*/
#define ICC_AP0R0_EL1 S3_0_C12_C8_4
#define ICC_AP0R1_EL1 S3_0_C12_C8_5
#define ICC_AP0R2_EL1 S3_0_C12_C8_6
#define ICC_AP0R3_EL1 S3_0_C12_C8_7
#define ICC_AP1R0_EL1 S3_0_C12_C9_0
#define ICC_AP1R1_EL1 S3_0_C12_C9_1
#define ICC_AP1R2_EL1 S3_0_C12_C9_2
#define ICC_AP1R3_EL1 S3_0_C12_C9_3
#define ICC_ASGI1R_EL1 S3_0_C12_C11_6
#define ICC_BPR0_EL1 S3_0_C12_C8_3
#define ICC_BPR1_EL1 S3_0_C12_C12_3
#define ICC_CTLR_EL1 S3_0_C12_C12_4
#define ICC_CTLR_EL3 S3_6_C12_C12_4
#define ICC_DIR_EL1 S3_0_C12_C11_1
#define ICC_EOIR0_EL1 S3_0_C12_C8_1
#define ICC_EOIR1_EL1 S3_0_C12_C12_1
#define ICC_HPPIR0_EL1 S3_0_C12_C8_2
#define ICC_HPPIR1_EL1 S3_0_C12_C12_2
#define ICC_IAR0_EL1 S3_0_C12_C8_0
#define ICC_IAR1_EL1 S3_0_C12_C12_0
#define ICC_IGRPEN0_EL1 S3_0_C12_C12_6
#define ICC_IGRPEN1_EL1 S3_0_C12_C12_7
#define ICC_IGRPEN1_EL3 S3_6_C12_C12_7
#define ICC_PMR_EL1 S3_0_C4_C6_0
#define ICC_RPR_EL1 S3_0_C12_C11_3
#define ICC_SGI0R_EL1 S3_0_C12_C11_7
#define ICC_SGI1R_EL1 S3_0_C12_C11_5
#define ICC_SRE_EL1 S3_0_C12_C12_5
#define ICC_SRE_EL2 S3_4_C12_C9_5
#define ICC_SRE_EL3 S3_6_C12_C12_5
/*
* Mapping of MSR and MRS to virtual interface control registers
*
* ARM Generic Interrupt Controller Architecture Specification
* GIC architecture version 3.0 and version 4.0
* Table 8-6
*/
#define ICH_AP0R0_EL2 S3_4_C12_C8_0
#define ICH_AP0R1_EL2 S3_4_C12_C8_1
#define ICH_AP0R2_EL2 S3_4_C12_C8_2
#define ICH_AP0R3_EL2 S3_4_C12_C8_3
#define ICH_AP1R0_EL2 S3_4_C12_C9_0
#define ICH_AP1R1_EL2 S3_4_C12_C9_1
#define ICH_AP1R2_EL2 S3_4_C12_C9_2
#define ICH_AP1R3_EL2 S3_4_C12_C9_3
#define ICH_HCR_EL2 S3_4_C12_C11_0
#define ICH_VTR_EL2 S3_4_C12_C11_1
#define ICH_MISR_EL2 S3_4_C12_C11_2
#define ICH_EISR_EL2 S3_4_C12_C11_3
#define ICH_ELRSR_EL2 S3_4_C12_C11_5
#define ICH_VMCR_EL2 S3_4_C12_C11_7
#define ICH_LR0_EL2 S3_4_C12_C12_0
#define ICH_LR1_EL2 S3_4_C12_C12_1
#define ICH_LR2_EL2 S3_4_C12_C12_2
#define ICH_LR3_EL2 S3_4_C12_C12_3
#define ICH_LR4_EL2 S3_4_C12_C12_4
#define ICH_LR5_EL2 S3_4_C12_C12_5
#define ICH_LR6_EL2 S3_4_C12_C12_6
#define ICH_LR7_EL2 S3_4_C12_C12_7
#define ICH_LR8_EL2 S3_4_C12_C13_0
#define ICH_LR9_EL2 S3_4_C12_C13_1
#define ICH_LR10_EL2 S3_4_C12_C13_2
#define ICH_LR11_EL2 S3_4_C12_C13_3
#define ICH_LR12_EL2 S3_4_C12_C13_4
#define ICH_LR13_EL2 S3_4_C12_C13_5
#define ICH_LR14_EL2 S3_4_C12_C13_6
#define ICH_LR15_EL2 S3_4_C12_C13_7
#define FUNC_DEFINE(name) .global name ;\
.type name, @function ;\
name:
/**
* @name:
* @msg: void FGicSetICC_SRE_EL3(GICC_SRE_BITS bits) --- Interrupt Controller System Register Enable
* @return {*}
*/
FUNC_DEFINE(FGicSetICC_SRE_EL3)
MSR ICC_SRE_EL3, x0
ISB
RET
/**
* @name:
* @msg: void FGicSetICC_SRE_EL2(GICC_SRE_BITS bits)
* @return {*}
*/
FUNC_DEFINE(FGicSetICC_SRE_EL2)
MSR ICC_SRE_EL2, x0
ISB
RET
/**
* @name:
* @msg: void FGicSetICC_SRE_EL1(GICC_SRE_BITS bits)
* @return {*}
*/
FUNC_DEFINE(FGicSetICC_SRE_EL1)
MSR ICC_SRE_EL1, x0
ISB
RET
/**
* @name:
* @msg: u32 FGicGetICC_SRE_EL3(void) -- Interrupt Controller System Register Enable
* @return {*}
*/
FUNC_DEFINE(FGicGetICC_SRE_EL3)
MRS x0, ICC_SRE_EL3
RET
/**
* @name:
* @msg: u32 FGicGetICC_SRE_EL2(void)
* @return {*}
*/
FUNC_DEFINE(FGicGetICC_SRE_EL2)
MRS x0, ICC_SRE_EL2
RET
/**
* @name:
* @msg: u32 FGicGetICC_SRE_EL1(void)
* @return {*}
*/
FUNC_DEFINE(FGicGetICC_SRE_EL1)
MRS x0, ICC_SRE_EL1
RET
/**
* @name:
* @msg: void FGicEnableGroup0(void)
* @return {*}
*/
FUNC_DEFINE(FGicEnableGroup0)
MOV w0, #1
MSR ICC_IGRPEN0_EL1, x0
ISB
RET
/**
* @name:
* @msg: void FGicDisableGroup0(void)
* @return {*}
*/
FUNC_DEFINE(FGicDisableGroup0)
MOV w0, #0
MSR ICC_IGRPEN0_EL1, x0
ISB
RET
/**
* @name:
* @msg:
* @return {*}
*/
FUNC_DEFINE(FGicEnableGroup1_EL3)
MOV w0, #1
MSR ICC_IGRPEN1_EL3, x0
ISB
RET
/**
* @name:
* @msg:
* @return {*}
*/
FUNC_DEFINE(FGicEnableGroup1_EL1)
MOV w0, #1
MSR ICC_IGRPEN1_EL1, x0
ISB
RET
/**
* @name:
* @msg: void FGicDisableGroup1_EL1(void)
* @return {*}
*/
FUNC_DEFINE(FGicDisableGroup1_EL1)
MOV w0, #0
MSR ICC_IGRPEN1_EL1, x0
ISB
RET
/**
* @name:
* @msg: void FGicDisableGroup1_EL3(void)
* @return {*}
*/
FUNC_DEFINE(FGicDisableGroup1_EL3)
MOV w0, #0
MSR ICC_IGRPEN1_EL3, x0
ISB
RET
/**
* @name:
* @msg: void FGicSetICC_CTLR_EL3(GICC_CTLR_BITS reg_bits)
* @return {*}
*/
FUNC_DEFINE(FGicSetICC_CTLR_EL3)
MSR ICC_CTLR_EL3, x0
ISB
RET
/**
* @name:
* @msg: void FGicSetICC_CTLR_EL1(GICC_CTLR_BITS reg_bits)
* @return {*}
*/
FUNC_DEFINE(FGicSetICC_CTLR_EL1)
MSR ICC_CTLR_EL1, x0
ISB
RET
/**
* @name:
* @msg: u32 FGicGetICC_CTLR_EL3(void) -- Controls aspects of the behavior of the GIC CPU interface and provides information about the features implemented.
* @return {*}
*/
FUNC_DEFINE(FGicGetICC_CTLR_EL3)
MRS x0, ICC_CTLR_EL3
RET
/**
* @name:
* @msg: u32 FGicGetICC_CTLR_EL1(void) -- Controls aspects of the behavior of the GIC CPU interface and provides information about the features implemented.
* @return {*}
*/
FUNC_DEFINE(FGicGetICC_CTLR_EL1)
MRS x0, ICC_CTLR_EL1
RET
/**
* @name:
* @msg: u32 FGicWriteICC_APR0(void) -- The PE reads this register to obtain the INTID of the signaled Group 0 interrupt.
* @return {*}
*/
FUNC_DEFINE(FGicGetICC_APR0)
MRS x0, ICC_IAR0_EL1
RET
/**
* @name:
* @msg: u32 FGicGetICC_APR1(void) -- The PE reads this register to obtain the INTID of the signaled Group 1 interrupt.
* @return {*}
*/
FUNC_DEFINE(FGicGetICC_APR1)
MRS x0, ICC_IAR1_EL1
RET
/**
* @name:
* @msg: void FGicSetICC_EOIR0(u32 intnum) -- /* A PE writes to this register to inform the CPU interface that it has completed the processing of the specified Group 0 interrupt
* @return {*}
*/
FUNC_DEFINE(FGicSetICC_EOIR0)
MSR ICC_EOIR0_EL1, x0
ISB
RET
/**
* @name:
* @msg: void FGicSetICC_EOIR1(u32 intnum) -- /* A PE writes to this register to inform the CPU interface that it has completed the processing of the specified Group 1 interrupt
* @return {*}
*/
FUNC_DEFINE(FGicSetICC_EOIR1)
MSR ICC_EOIR1_EL1, x0
ISB
RET
/**
* @name:
* @msg: void FGicSetICC_DIR(u32 intnum) -- When interrupt priority drop is separated from interrupt deactivation, a write to this register deactivates the specified interrupt.
* @return {*}
*/
FUNC_DEFINE(FGicSetICC_DIR)
MSR ICC_DIR_EL1, x0
ISB
RET
/**
* @name:
* @msg: void FGicSetICC_PMR(u32 priority_mask) -- Provides an interrupt priority filter.
* @return {*}
*/
FUNC_DEFINE(FGicSetICC_PMR)
MSR ICC_PMR_EL1, x0
ISB
RET
/**
* @name:
* @msg: u32 FGicGetICC_PMR(void)
* @return {*}
*/
FUNC_DEFINE(FGicGetICC_PMR)
MRS x0,ICC_PMR_EL1
RET
/**
* @name:
* @msg: u32 FGicGetICC_BPR1(void) --- Defines the point at which the priority value fields split into two parts, the group priority field and the subpriority field. The group priority field determines Group 1 interrupt preemption.
* @return {*}
*/
FUNC_DEFINE(FGicGetICC_BPR1)
MRS x0,ICC_BPR1_EL1
RET
/**
* @name:
* @msg: void FGicSetICC_BPR1(u32 binary_point)
* @return {*}
*/
FUNC_DEFINE(FGicSetICC_BPR1)
MSR ICC_BPR1_EL1, x0
ISB
RET
/**
* @name:
* @msg: u32 FGicGetICC_BPR0(void) --- Defines the point at which the priority value fields split into two parts, the group priority field and the subpriority field. The group priority field determines Group 0 interrupt preemption.
* @return {*}
*/
FUNC_DEFINE(FGicGetICC_BPR0)
MRS x0,ICC_BPR0_EL1
RET
/**
* @name:
* @msg: void FGicSetICC_BPR0(u32 binary_point)
* @return {*}
*/
FUNC_DEFINE(FGicSetICC_BPR0)
MSR ICC_BPR0_EL1, x0
ISB
RET
/**
* @name:
* @msg: u32 FGicGetICC_HPPIR1(void) --- Indicates the highest priority pending Group 1 interrupt on the CPU interface.
* @return {*}
*/
FUNC_DEFINE(FGicGetICC_HPPIR1)
MRS x0,ICC_HPPIR1_EL1
RET
/**
* @name:
* @msg: void FGicSetICC_HPPIR1(u32 binary_point)
* @return {*}
*/
FUNC_DEFINE(FGicSetICC_HPPIR1)
MSR ICC_HPPIR1_EL1, x0
ISB
RET
/**
* @name:
* @msg: u32 FGicGetICC_HPPIR0(void) --- Indicates the highest priority pending Group 0 interrupt on the CPU interface.
* @return {*}
*/
FUNC_DEFINE(FGicGetICC_HPPIR0)
MRS x0,ICC_HPPIR0_EL1
RET
/**
* @name:
* @msg: void FGicSetICC_HPPIR0(u32 binary_point)
* @return {*}
*/
FUNC_DEFINE(FGicSetICC_HPPIR0)
MSR ICC_HPPIR0_EL1, x0
ISB
RET
/**
* @name:
* @msg: u32 FGicGetICC_RPR(void) --- Indicates the Running priority of the CPU interface.
* @return {*}
*/
FUNC_DEFINE(FGicGetICC_RPR)
MRS x0,ICC_RPR_EL1
RET
/* SGI interface */
/**
* @name:
* @msg: void FGicSetICC_SGI0R(u32 intnum,u32 target_list,GICC_SGIR_IRM_BITS mode,u64 affinity_list) --- Generates Secure Group 0 SGIs
* @return {*}
*/
FUNC_DEFINE(FGicSetICC_SGI0R)
ORR x0, x0, x1
ORR x0, x0, x2
ORR x0, x0, x3
MSR ICC_SGI0R_EL1, x0
ISB
RET
/**
* @name:
* @msg: void FGicSetICC_SGI1R(u32 intnum,u32 target_list,GICC_SGIR_IRM_BITS mode,u64 affinity_list)
* @return {*}
*/
FUNC_DEFINE(FGicSetICC_SGI1R)
ORR x0, x0, x1
ORR x0, x0, x2
ORR x0, x0, x3
MSR ICC_SGI1R_EL1, x0
ISB
RET
/**
* @name:
* @msg: void FGicSetICC_ASGI1R(u32 intnum,u32 target_list,GICC_SGIR_IRM_BITS mode,u64 affinity_list)
* @return {*}
*/
FUNC_DEFINE(FGicSetICC_ASGI1R)
ORR x0, x0, x1
ORR x0, x0, x2
ORR x0, x0, x3
MSR ICC_ASGI1R_EL1, x0
ISB
RET
#else
#endif
|