sysreg_helpers.S 11.2 KB
Newer Older
1
/*
2
 * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved.
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
 *
 * 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.
 */

31
#include <arch.h>
32
#include <asm_macros.S>
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

	.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	read_ttbr1_el2
	.globl	write_ttbr1
	.globl	write_ttbr1_el1
	.globl	write_ttbr1_el2

	.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_scr
	.globl	write_scr

	.globl	read_hcr
	.globl	write_hcr

	.globl	read_midr
	.globl	read_mpidr

	.globl	read_current_el
	.globl	read_id_pfr1_el1
	.globl	read_id_aa64pfr0_el1

#if SUPPORT_VFP
	.globl	enable_vfp
	.globl	read_fpexc
	.globl	write_fpexc
#endif


168
func read_current_el
169
170
171
172
	mrs	x0, CurrentEl
	ret


173
func read_id_pfr1_el1
174
175
176
177
	mrs	x0, id_pfr1_el1
	ret


178
func read_id_aa64pfr0_el1
179
180
181
182
183
184
185
186
	mrs	x0, id_aa64pfr0_el1
	ret


	/* -----------------------------------------------------
	 * VBAR accessors
	 * -----------------------------------------------------
	 */
187
func read_vbar_el1
188
189
190
191
	mrs	x0, vbar_el1
	ret


192
func read_vbar_el2
193
194
195
196
	mrs	x0, vbar_el2
	ret


197
func read_vbar_el3
198
199
200
201
	mrs	x0, vbar_el3
	ret


202
func write_vbar_el1
203
204
205
206
207
	msr	vbar_el1, x0
	isb
	ret


208
func write_vbar_el2
209
210
211
212
213
	msr	vbar_el2, x0
	isb
	ret


214
func write_vbar_el3
215
216
217
218
219
220
221
222
223
	msr	vbar_el3, x0
	isb
	ret


	/* -----------------------------------------------------
	 * AFSR0 accessors
	 * -----------------------------------------------------
	 */
224
func read_afsr0_el1
225
226
227
228
	mrs	x0, afsr0_el1
	ret


229
func read_afsr0_el2
230
231
232
233
	mrs	x0, afsr0_el2
	ret


234
func read_afsr0_el3
235
236
237
238
	mrs	x0, afsr0_el3
	ret


239
func write_afsr0_el1
240
241
242
243
244
	msr	afsr0_el1, x0
	isb
	ret


245
func write_afsr0_el2
246
247
248
249
250
	msr	afsr0_el2, x0
	isb
	ret


251
func write_afsr0_el3
252
253
254
255
256
257
258
259
260
	msr	afsr0_el3, x0
	isb
	ret


	/* -----------------------------------------------------
	 * FAR accessors
	 * -----------------------------------------------------
	 */
261
func read_far_el1
262
263
264
265
	mrs	x0, far_el1
	ret


266
func read_far_el2
267
268
269
270
	mrs	x0, far_el2
	ret


271
func read_far_el3
272
273
274
275
	mrs	x0, far_el3
	ret


276
func write_far_el1
277
278
279
280
281
	msr	far_el1, x0
	isb
	ret


282
func write_far_el2
283
284
285
286
287
	msr	far_el2, x0
	isb
	ret


288
func write_far_el3
289
290
291
292
293
294
295
296
297
	msr	far_el3, x0
	isb
	ret


	/* -----------------------------------------------------
	 * MAIR accessors
	 * -----------------------------------------------------
	 */
298
func read_mair_el1
299
300
301
302
	mrs	x0, mair_el1
	ret


303
func read_mair_el2
304
305
306
307
	mrs	x0, mair_el2
	ret


308
func read_mair_el3
309
310
311
312
	mrs	x0, mair_el3
	ret


313
func write_mair_el1
314
315
316
317
318
	msr	mair_el1, x0
	isb
	ret


319
func write_mair_el2
320
321
322
323
324
	msr	mair_el2, x0
	isb
	ret


325
func write_mair_el3
326
327
328
329
330
331
332
333
334
	msr	mair_el3, x0
	isb
	ret


	/* -----------------------------------------------------
	 * AMAIR accessors
	 * -----------------------------------------------------
	 */
335
func read_amair_el1
336
337
338
339
	mrs	x0, amair_el1
	ret


340
func read_amair_el2
341
342
343
344
	mrs	x0, amair_el2
	ret


345
func read_amair_el3
346
347
348
349
	mrs	x0, amair_el3
	ret


350
func write_amair_el1
351
352
353
354
355
	msr	amair_el1, x0
	isb
	ret


356
func write_amair_el2
357
358
359
360
361
	msr	amair_el2, x0
	isb
	ret


362
func write_amair_el3
363
364
365
366
367
368
369
370
371
	msr	amair_el3, x0
	isb
	ret


	/* -----------------------------------------------------
	 * RVBAR accessors
	 * -----------------------------------------------------
	 */
372
func read_rvbar_el1
373
374
375
376
	mrs	x0, rvbar_el1
	ret


377
func read_rvbar_el2
378
379
380
381
	mrs	x0, rvbar_el2
	ret


382
func read_rvbar_el3
383
384
385
386
387
388
389
390
	mrs	x0, rvbar_el3
	ret


	/* -----------------------------------------------------
	 * RMR accessors
	 * -----------------------------------------------------
	 */
391
func read_rmr_el1
392
393
394
395
	mrs	x0, rmr_el1
	ret


396
func read_rmr_el2
397
398
399
400
	mrs	x0, rmr_el2
	ret


401
func read_rmr_el3
402
403
404
405
	mrs	x0, rmr_el3
	ret


406
func write_rmr_el1
407
408
409
410
411
	msr	rmr_el1, x0
	isb
	ret


412
func write_rmr_el2
413
414
415
416
417
	msr	rmr_el2, x0
	isb
	ret


418
func write_rmr_el3
419
420
421
422
423
424
425
426
427
	msr	rmr_el3, x0
	isb
	ret


	/* -----------------------------------------------------
	 * AFSR1 accessors
	 * -----------------------------------------------------
	 */
428
func read_afsr1_el1
429
430
431
432
	mrs	x0, afsr1_el1
	ret


433
func read_afsr1_el2
434
435
436
437
	mrs	x0, afsr1_el2
	ret


438
func read_afsr1_el3
439
440
441
442
	mrs	x0, afsr1_el3
	ret


443
func write_afsr1_el1
444
445
446
447
448
	msr	afsr1_el1, x0
	isb
	ret


449
func write_afsr1_el2
450
451
452
453
454
	msr	afsr1_el2, x0
	isb
	ret


455
func write_afsr1_el3
456
457
458
459
460
461
462
463
464
	msr	afsr1_el3, x0
	isb
	ret


	/* -----------------------------------------------------
	 * SCTLR accessors
	 * -----------------------------------------------------
	 */
465
func read_sctlr_el1
466
467
468
469
	mrs	x0, sctlr_el1
	ret


470
func read_sctlr_el2
471
472
473
474
	mrs	x0, sctlr_el2
	ret


475
func read_sctlr_el3
476
477
478
479
	mrs	x0, sctlr_el3
	ret


480
func write_sctlr_el1
481
482
483
484
485
486
	msr	sctlr_el1, x0
	dsb	sy
	isb
	ret


487
func write_sctlr_el2
488
489
490
491
492
493
	msr	sctlr_el2, x0
	dsb	sy
	isb
	ret


494
func write_sctlr_el3
495
496
497
498
499
500
501
502
503
504
	msr	sctlr_el3, x0
	dsb	sy
	isb
	ret


	/* -----------------------------------------------------
	 * ACTLR accessors
	 * -----------------------------------------------------
	 */
505
func read_actlr_el1
506
507
508
509
	mrs	x0, actlr_el1
	ret


510
func read_actlr_el2
511
512
513
514
	mrs	x0, actlr_el2
	ret


515
func read_actlr_el3
516
517
518
519
	mrs	x0, actlr_el3
	ret


520
func write_actlr_el1
521
522
523
524
525
526
	msr	actlr_el1, x0
	dsb	sy
	isb
	ret


527
func write_actlr_el2
528
529
530
531
532
533
	msr	actlr_el2, x0
	dsb	sy
	isb
	ret


534
func write_actlr_el3
535
536
537
538
539
540
541
542
543
544
	msr	actlr_el3, x0
	dsb	sy
	isb
	ret


	/* -----------------------------------------------------
	 * ESR accessors
	 * -----------------------------------------------------
	 */
545
func read_esr_el1
546
547
548
549
	mrs	x0, esr_el1
	ret


550
func read_esr_el2
551
552
553
554
	mrs	x0, esr_el2
	ret


555
func read_esr_el3
556
557
558
559
	mrs	x0, esr_el3
	ret


560
func write_esr_el1
561
562
563
564
565
566
	msr	esr_el1, x0
	dsb	sy
	isb
	ret


567
func write_esr_el2
568
569
570
571
572
573
	msr	esr_el2, x0
	dsb	sy
	isb
	ret


574
func write_esr_el3
575
576
577
578
579
580
581
582
583
584
	msr	esr_el3, x0
	dsb	sy
	isb
	ret


	/* -----------------------------------------------------
	 * TCR accessors
	 * -----------------------------------------------------
	 */
585
func read_tcr_el1
586
587
588
589
	mrs	x0, tcr_el1
	ret


590
func read_tcr_el2
591
592
593
594
	mrs	x0, tcr_el2
	ret


595
func read_tcr_el3
596
597
598
599
	mrs	x0, tcr_el3
	ret


600
func write_tcr_el1
601
602
603
604
605
606
	msr	tcr_el1, x0
	dsb	sy
	isb
	ret


607
func write_tcr_el2
608
609
610
611
612
613
	msr	tcr_el2, x0
	dsb	sy
	isb
	ret


614
func write_tcr_el3
615
616
617
618
619
620
621
622
623
624
	msr	tcr_el3, x0
	dsb	sy
	isb
	ret


	/* -----------------------------------------------------
	 * CPTR accessors
	 * -----------------------------------------------------
	 */
625
func read_cptr_el1
626
627
628
629
	b	read_cptr_el1
	ret


630
func read_cptr_el2
631
632
633
634
	mrs	x0, cptr_el2
	ret


635
func read_cptr_el3
636
637
638
639
	mrs	x0, cptr_el3
	ret


640
func write_cptr_el1
641
642
643
	b	write_cptr_el1


644
func write_cptr_el2
645
646
647
648
649
650
	msr	cptr_el2, x0
	dsb	sy
	isb
	ret


651
func write_cptr_el3
652
653
654
655
656
657
658
659
660
661
	msr	cptr_el3, x0
	dsb	sy
	isb
	ret


	/* -----------------------------------------------------
	 * TTBR0 accessors
	 * -----------------------------------------------------
	 */
662
func read_ttbr0_el1
663
664
665
666
	mrs	x0, ttbr0_el1
	ret


667
func read_ttbr0_el2
668
669
670
671
	mrs	x0, ttbr0_el2
	ret


672
func read_ttbr0_el3
673
674
675
676
	mrs	x0, ttbr0_el3
	ret


677
func write_ttbr0_el1
678
679
680
681
682
	msr	ttbr0_el1, x0
	isb
	ret


683
func write_ttbr0_el2
684
685
686
687
688
	msr	ttbr0_el2, x0
	isb
	ret


689
func write_ttbr0_el3
690
691
692
693
694
695
696
697
698
	msr	ttbr0_el3, x0
	isb
	ret


	/* -----------------------------------------------------
	 * TTBR1 accessors
	 * -----------------------------------------------------
	 */
699
func read_ttbr1_el1
700
701
702
703
	mrs	x0, ttbr1_el1
	ret


704
func read_ttbr1_el2
705
706
707
	b	read_ttbr1_el2


708
func read_ttbr1_el3
709
710
711
	b	read_ttbr1_el3


712
func write_ttbr1_el1
713
714
715
716
717
	msr	ttbr1_el1, x0
	isb
	ret


718
func write_ttbr1_el2
719
720
721
	b	write_ttbr1_el2


722
func write_ttbr1_el3
723
724
725
	b	write_ttbr1_el3


726
func read_hcr
727
728
729
730
	mrs	x0, hcr_el2
	ret


731
func write_hcr
732
733
734
735
736
737
	msr	hcr_el2, x0
	dsb	sy
	isb
	ret


738
func read_cpacr
739
740
741
742
	mrs	x0, cpacr_el1
	ret


743
func write_cpacr
744
745
746
747
	msr	cpacr_el1, x0
	ret


748
func read_cntfrq_el0
749
750
751
752
	mrs	x0, cntfrq_el0
	ret


753
func write_cntfrq_el0
754
755
756
757
	msr	cntfrq_el0, x0
	ret


758
func read_cpuectlr
759
760
761
762
	mrs	x0, CPUECTLR_EL1
	ret


763
func write_cpuectlr
764
765
766
767
768
769
	msr	CPUECTLR_EL1, x0
	dsb	sy
	isb
	ret


770
func read_cnthctl_el2
771
772
773
774
	mrs	x0, cnthctl_el2
	ret


775
func write_cnthctl_el2
776
777
778
779
	msr	cnthctl_el2, x0
	ret


780
func read_cntfrq
781
782
783
784
	mrs	x0, cntfrq_el0
	ret


785
func write_cntfrq
786
787
788
789
	msr	cntfrq_el0, x0
	ret


790
func write_scr
791
792
793
794
795
796
	msr	scr_el3, x0
	dsb	sy
	isb
	ret


797
func read_scr
798
799
800
801
	mrs	x0, scr_el3
	ret


802
func read_midr
803
804
805
806
	mrs	x0, midr_el1
	ret


807
func read_mpidr
808
809
810
811
812
	mrs	x0, mpidr_el1
	ret


#if SUPPORT_VFP
813
func enable_vfp
814
815
816
817
818
819
820
821
822
823
	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
	ret


824
func read_fpexc
825
826
827
828
	b	read_fpexc
	ret


829
func write_fpexc
830
831
832
833
	b	write_fpexc
	ret

#endif