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
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
|
/*
* Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <arch.h>
#include <asm_macros.S>
.globl read_vbar_el1
.globl read_vbar_el2
.globl read_vbar_el3
.globl write_vbar_el1
.globl write_vbar_el2
.globl write_vbar_el3
.globl read_sctlr_el1
.globl read_sctlr_el2
.globl read_sctlr_el3
.globl write_sctlr_el1
.globl write_sctlr_el2
.globl write_sctlr_el3
.globl read_actlr_el1
.globl read_actlr_el2
.globl read_actlr_el3
.globl write_actlr_el1
.globl write_actlr_el2
.globl write_actlr_el3
.globl read_esr_el1
.globl read_esr_el2
.globl read_esr_el3
.globl write_esr_el1
.globl write_esr_el2
.globl write_esr_el3
.globl read_afsr0_el1
.globl read_afsr0_el2
.globl read_afsr0_el3
.globl write_afsr0_el1
.globl write_afsr0_el2
.globl write_afsr0_el3
.globl read_afsr1_el1
.globl read_afsr1_el2
.globl read_afsr1_el3
.globl write_afsr1_el1
.globl write_afsr1_el2
.globl write_afsr1_el3
.globl read_far_el1
.globl read_far_el2
.globl read_far_el3
.globl write_far_el1
.globl write_far_el2
.globl write_far_el3
.globl read_mair_el1
.globl read_mair_el2
.globl read_mair_el3
.globl write_mair_el1
.globl write_mair_el2
.globl write_mair_el3
.globl read_amair_el1
.globl read_amair_el2
.globl read_amair_el3
.globl write_amair_el1
.globl write_amair_el2
.globl write_amair_el3
.globl read_rvbar_el1
.globl read_rvbar_el2
.globl read_rvbar_el3
.globl read_rmr_el1
.globl read_rmr_el2
.globl read_rmr_el3
.globl write_rmr_el1
.globl write_rmr_el2
.globl write_rmr_el3
.globl read_tcr_el1
.globl read_tcr_el2
.globl read_tcr_el3
.globl write_tcr_el1
.globl write_tcr_el2
.globl write_tcr_el3
.globl read_cptr_el2
.globl read_cptr_el3
.globl write_cptr_el2
.globl write_cptr_el3
.globl read_ttbr0_el1
.globl read_ttbr0_el2
.globl read_ttbr0_el3
.globl write_ttbr0_el1
.globl write_ttbr0_el2
.globl write_ttbr0_el3
.globl read_ttbr1_el1
.globl write_ttbr1_el1
.globl read_cpacr
.globl write_cpacr
.globl read_cntfrq
.globl write_cntfrq
.globl read_cpuectlr
.globl write_cpuectlr
.globl read_cnthctl_el2
.globl write_cnthctl_el2
.globl read_cntfrq_el0
.globl write_cntfrq_el0
.globl read_cntps_ctl_el1
.globl write_cntps_ctl_el1
.globl read_cntps_cval_el1
.globl write_cntps_cval_el1
.globl read_cntps_tval_el1
.globl write_cntps_tval_el1
.globl read_scr
.globl write_scr
.globl read_hcr
.globl write_hcr
.globl read_midr
.globl read_mpidr
.globl read_cntpct_el0
.globl read_current_el
.globl read_id_pfr1_el1
.globl read_id_aa64pfr0_el1
.globl write_tpidr_el3
.globl read_tpidr_el3
#if SUPPORT_VFP
.globl enable_vfp
#endif
func read_current_el
mrs x0, CurrentEl
ret
func read_id_pfr1_el1
mrs x0, id_pfr1_el1
ret
func read_id_aa64pfr0_el1
mrs x0, id_aa64pfr0_el1
ret
/* -----------------------------------------------------
* VBAR accessors
* -----------------------------------------------------
*/
func read_vbar_el1
mrs x0, vbar_el1
ret
func read_vbar_el2
mrs x0, vbar_el2
ret
func read_vbar_el3
mrs x0, vbar_el3
ret
func write_vbar_el1
msr vbar_el1, x0
ret
func write_vbar_el2
msr vbar_el2, x0
ret
func write_vbar_el3
msr vbar_el3, x0
ret
/* -----------------------------------------------------
* AFSR0 accessors
* -----------------------------------------------------
*/
func read_afsr0_el1
mrs x0, afsr0_el1
ret
func read_afsr0_el2
mrs x0, afsr0_el2
ret
func read_afsr0_el3
mrs x0, afsr0_el3
ret
func write_afsr0_el1
msr afsr0_el1, x0
ret
func write_afsr0_el2
msr afsr0_el2, x0
ret
func write_afsr0_el3
msr afsr0_el3, x0
ret
/* -----------------------------------------------------
* FAR accessors
* -----------------------------------------------------
*/
func read_far_el1
mrs x0, far_el1
ret
func read_far_el2
mrs x0, far_el2
ret
func read_far_el3
mrs x0, far_el3
ret
func write_far_el1
msr far_el1, x0
ret
func write_far_el2
msr far_el2, x0
ret
func write_far_el3
msr far_el3, x0
ret
/* -----------------------------------------------------
* MAIR accessors
* -----------------------------------------------------
*/
func read_mair_el1
mrs x0, mair_el1
ret
func read_mair_el2
mrs x0, mair_el2
ret
func read_mair_el3
mrs x0, mair_el3
ret
func write_mair_el1
msr mair_el1, x0
ret
func write_mair_el2
msr mair_el2, x0
ret
func write_mair_el3
msr mair_el3, x0
ret
/* -----------------------------------------------------
* AMAIR accessors
* -----------------------------------------------------
*/
func read_amair_el1
mrs x0, amair_el1
ret
func read_amair_el2
mrs x0, amair_el2
ret
func read_amair_el3
mrs x0, amair_el3
ret
func write_amair_el1
msr amair_el1, x0
ret
func write_amair_el2
msr amair_el2, x0
ret
func write_amair_el3
msr amair_el3, x0
ret
/* -----------------------------------------------------
* RVBAR accessors
* -----------------------------------------------------
*/
func read_rvbar_el1
mrs x0, rvbar_el1
ret
func read_rvbar_el2
mrs x0, rvbar_el2
ret
func read_rvbar_el3
mrs x0, rvbar_el3
ret
/* -----------------------------------------------------
* RMR accessors
* -----------------------------------------------------
*/
func read_rmr_el1
mrs x0, rmr_el1
ret
func read_rmr_el2
mrs x0, rmr_el2
ret
func read_rmr_el3
mrs x0, rmr_el3
ret
func write_rmr_el1
msr rmr_el1, x0
ret
func write_rmr_el2
msr rmr_el2, x0
ret
func write_rmr_el3
msr rmr_el3, x0
ret
/* -----------------------------------------------------
* AFSR1 accessors
* -----------------------------------------------------
*/
func read_afsr1_el1
mrs x0, afsr1_el1
ret
func read_afsr1_el2
mrs x0, afsr1_el2
ret
func read_afsr1_el3
mrs x0, afsr1_el3
ret
func write_afsr1_el1
msr afsr1_el1, x0
ret
func write_afsr1_el2
msr afsr1_el2, x0
ret
func write_afsr1_el3
msr afsr1_el3, x0
ret
/* -----------------------------------------------------
* SCTLR accessors
* -----------------------------------------------------
*/
func read_sctlr_el1
mrs x0, sctlr_el1
ret
func read_sctlr_el2
mrs x0, sctlr_el2
ret
func read_sctlr_el3
mrs x0, sctlr_el3
ret
func write_sctlr_el1
msr sctlr_el1, x0
ret
func write_sctlr_el2
msr sctlr_el2, x0
ret
func write_sctlr_el3
msr sctlr_el3, x0
ret
/* -----------------------------------------------------
* ACTLR accessors
* -----------------------------------------------------
*/
func read_actlr_el1
mrs x0, actlr_el1
ret
func read_actlr_el2
mrs x0, actlr_el2
ret
func read_actlr_el3
mrs x0, actlr_el3
ret
func write_actlr_el1
msr actlr_el1, x0
ret
func write_actlr_el2
msr actlr_el2, x0
ret
func write_actlr_el3
msr actlr_el3, x0
ret
/* -----------------------------------------------------
* ESR accessors
* -----------------------------------------------------
*/
func read_esr_el1
mrs x0, esr_el1
ret
func read_esr_el2
mrs x0, esr_el2
ret
func read_esr_el3
mrs x0, esr_el3
ret
func write_esr_el1
msr esr_el1, x0
ret
func write_esr_el2
msr esr_el2, x0
ret
func write_esr_el3
msr esr_el3, x0
ret
/* -----------------------------------------------------
* TCR accessors
* -----------------------------------------------------
*/
func read_tcr_el1
mrs x0, tcr_el1
ret
func read_tcr_el2
mrs x0, tcr_el2
ret
func read_tcr_el3
mrs x0, tcr_el3
ret
func write_tcr_el1
msr tcr_el1, x0
ret
func write_tcr_el2
msr tcr_el2, x0
ret
func write_tcr_el3
msr tcr_el3, x0
ret
/* -----------------------------------------------------
* CPTR accessors
* -----------------------------------------------------
*/
func read_cptr_el2
mrs x0, cptr_el2
ret
func read_cptr_el3
mrs x0, cptr_el3
ret
func write_cptr_el2
msr cptr_el2, x0
ret
func write_cptr_el3
msr cptr_el3, x0
ret
/* -----------------------------------------------------
* TTBR0 accessors
* -----------------------------------------------------
*/
func read_ttbr0_el1
mrs x0, ttbr0_el1
ret
func read_ttbr0_el2
mrs x0, ttbr0_el2
ret
func read_ttbr0_el3
mrs x0, ttbr0_el3
ret
func write_ttbr0_el1
msr ttbr0_el1, x0
ret
func write_ttbr0_el2
msr ttbr0_el2, x0
ret
func write_ttbr0_el3
msr ttbr0_el3, x0
ret
/* -----------------------------------------------------
* TTBR1 accessors
* -----------------------------------------------------
*/
func read_ttbr1_el1
mrs x0, ttbr1_el1
ret
func write_ttbr1_el1
msr ttbr1_el1, x0
ret
func read_hcr
mrs x0, hcr_el2
ret
func write_hcr
msr hcr_el2, x0
ret
func read_cpacr
mrs x0, cpacr_el1
ret
func write_cpacr
msr cpacr_el1, x0
ret
func read_cntfrq_el0
mrs x0, cntfrq_el0
ret
func write_cntfrq_el0
msr cntfrq_el0, x0
ret
func read_cntps_ctl_el1
mrs x0, cntps_ctl_el1
ret
func write_cntps_ctl_el1
msr cntps_ctl_el1, x0
ret
func read_cntps_cval_el1
mrs x0, cntps_cval_el1
ret
func write_cntps_cval_el1
msr cntps_cval_el1, x0
ret
func read_cntps_tval_el1
mrs x0, cntps_tval_el1
ret
func write_cntps_tval_el1
msr cntps_tval_el1, x0
ret
func read_cntpct_el0
mrs x0, cntpct_el0
ret
func read_cpuectlr
mrs x0, CPUECTLR_EL1
ret
func write_cpuectlr
msr CPUECTLR_EL1, x0
ret
func read_cnthctl_el2
mrs x0, cnthctl_el2
ret
func write_cnthctl_el2
msr cnthctl_el2, x0
ret
func read_cntfrq
mrs x0, cntfrq_el0
ret
func write_cntfrq
msr cntfrq_el0, x0
ret
func write_scr
msr scr_el3, x0
ret
func read_scr
mrs x0, scr_el3
ret
func read_midr
mrs x0, midr_el1
ret
func read_mpidr
mrs x0, mpidr_el1
ret
func write_tpidr_el3
msr tpidr_el3, x0
ret
func read_tpidr_el3
mrs x0, tpidr_el3
ret
#if SUPPORT_VFP
func enable_vfp
mrs x0, cpacr_el1
orr x0, x0, #CPACR_VFP_BITS
msr cpacr_el1, x0
mrs x0, cptr_el3
mov x1, #AARCH64_CPTR_TFP
bic x0, x0, x1
msr cptr_el3, x0
isb
ret
#endif
|