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

	.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

145
146
147
148
149
150
151
152
153
	.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

154
155
156
157
158
159
160
161
162
	.globl	read_scr
	.globl	write_scr

	.globl	read_hcr
	.globl	write_hcr

	.globl	read_midr
	.globl	read_mpidr

163
	.globl	read_cntpct_el0
164
165
166
167
	.globl	read_current_el
	.globl	read_id_pfr1_el1
	.globl	read_id_aa64pfr0_el1

168
169
170
	.globl	write_tpidr_el3
	.globl	read_tpidr_el3

171
172
173
174
175
#if SUPPORT_VFP
	.globl	enable_vfp
#endif


176
func read_current_el
177
178
179
180
	mrs	x0, CurrentEl
	ret


181
func read_id_pfr1_el1
182
183
184
185
	mrs	x0, id_pfr1_el1
	ret


186
func read_id_aa64pfr0_el1
187
188
189
190
191
192
193
194
	mrs	x0, id_aa64pfr0_el1
	ret


	/* -----------------------------------------------------
	 * VBAR accessors
	 * -----------------------------------------------------
	 */
195
func read_vbar_el1
196
197
198
199
	mrs	x0, vbar_el1
	ret


200
func read_vbar_el2
201
202
203
204
	mrs	x0, vbar_el2
	ret


205
func read_vbar_el3
206
207
208
209
	mrs	x0, vbar_el3
	ret


210
func write_vbar_el1
211
212
213
214
	msr	vbar_el1, x0
	ret


215
func write_vbar_el2
216
217
218
219
	msr	vbar_el2, x0
	ret


220
func write_vbar_el3
221
222
223
224
225
226
227
228
	msr	vbar_el3, x0
	ret


	/* -----------------------------------------------------
	 * AFSR0 accessors
	 * -----------------------------------------------------
	 */
229
func read_afsr0_el1
230
231
232
233
	mrs	x0, afsr0_el1
	ret


234
func read_afsr0_el2
235
236
237
238
	mrs	x0, afsr0_el2
	ret


239
func read_afsr0_el3
240
241
242
243
	mrs	x0, afsr0_el3
	ret


244
func write_afsr0_el1
245
246
247
248
	msr	afsr0_el1, x0
	ret


249
func write_afsr0_el2
250
251
252
253
	msr	afsr0_el2, x0
	ret


254
func write_afsr0_el3
255
256
257
258
259
260
261
262
	msr	afsr0_el3, x0
	ret


	/* -----------------------------------------------------
	 * FAR accessors
	 * -----------------------------------------------------
	 */
263
func read_far_el1
264
265
266
267
	mrs	x0, far_el1
	ret


268
func read_far_el2
269
270
271
272
	mrs	x0, far_el2
	ret


273
func read_far_el3
274
275
276
277
	mrs	x0, far_el3
	ret


278
func write_far_el1
279
280
281
282
	msr	far_el1, x0
	ret


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


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


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


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


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


312
func write_mair_el1
313
314
315
316
	msr	mair_el1, x0
	ret


317
func write_mair_el2
318
319
320
321
	msr	mair_el2, x0
	ret


322
func write_mair_el3
323
324
325
326
327
328
329
330
	msr	mair_el3, x0
	ret


	/* -----------------------------------------------------
	 * AMAIR accessors
	 * -----------------------------------------------------
	 */
331
func read_amair_el1
332
333
334
335
	mrs	x0, amair_el1
	ret


336
func read_amair_el2
337
338
339
340
	mrs	x0, amair_el2
	ret


341
func read_amair_el3
342
343
344
345
	mrs	x0, amair_el3
	ret


346
func write_amair_el1
347
348
349
350
	msr	amair_el1, x0
	ret


351
func write_amair_el2
352
353
354
355
	msr	amair_el2, x0
	ret


356
func write_amair_el3
357
358
359
360
361
362
363
364
	msr	amair_el3, x0
	ret


	/* -----------------------------------------------------
	 * RVBAR accessors
	 * -----------------------------------------------------
	 */
365
func read_rvbar_el1
366
367
368
369
	mrs	x0, rvbar_el1
	ret


370
func read_rvbar_el2
371
372
373
374
	mrs	x0, rvbar_el2
	ret


375
func read_rvbar_el3
376
377
378
379
380
381
382
383
	mrs	x0, rvbar_el3
	ret


	/* -----------------------------------------------------
	 * RMR accessors
	 * -----------------------------------------------------
	 */
384
func read_rmr_el1
385
386
387
388
	mrs	x0, rmr_el1
	ret


389
func read_rmr_el2
390
391
392
393
	mrs	x0, rmr_el2
	ret


394
func read_rmr_el3
395
396
397
398
	mrs	x0, rmr_el3
	ret


399
func write_rmr_el1
400
401
402
403
	msr	rmr_el1, x0
	ret


404
func write_rmr_el2
405
406
407
408
	msr	rmr_el2, x0
	ret


409
func write_rmr_el3
410
411
412
413
414
415
416
417
	msr	rmr_el3, x0
	ret


	/* -----------------------------------------------------
	 * AFSR1 accessors
	 * -----------------------------------------------------
	 */
418
func read_afsr1_el1
419
420
421
422
	mrs	x0, afsr1_el1
	ret


423
func read_afsr1_el2
424
425
426
427
	mrs	x0, afsr1_el2
	ret


428
func read_afsr1_el3
429
430
431
432
	mrs	x0, afsr1_el3
	ret


433
func write_afsr1_el1
434
435
436
437
	msr	afsr1_el1, x0
	ret


438
func write_afsr1_el2
439
440
441
442
	msr	afsr1_el2, x0
	ret


443
func write_afsr1_el3
444
445
446
447
448
449
450
451
	msr	afsr1_el3, x0
	ret


	/* -----------------------------------------------------
	 * SCTLR accessors
	 * -----------------------------------------------------
	 */
452
func read_sctlr_el1
453
454
455
456
	mrs	x0, sctlr_el1
	ret


457
func read_sctlr_el2
458
459
460
461
	mrs	x0, sctlr_el2
	ret


462
func read_sctlr_el3
463
464
465
466
	mrs	x0, sctlr_el3
	ret


467
func write_sctlr_el1
468
469
470
471
	msr	sctlr_el1, x0
	ret


472
func write_sctlr_el2
473
474
475
476
	msr	sctlr_el2, x0
	ret


477
func write_sctlr_el3
478
479
480
481
482
483
484
485
	msr	sctlr_el3, x0
	ret


	/* -----------------------------------------------------
	 * ACTLR accessors
	 * -----------------------------------------------------
	 */
486
func read_actlr_el1
487
488
489
490
	mrs	x0, actlr_el1
	ret


491
func read_actlr_el2
492
493
494
495
	mrs	x0, actlr_el2
	ret


496
func read_actlr_el3
497
498
499
500
	mrs	x0, actlr_el3
	ret


501
func write_actlr_el1
502
503
504
505
	msr	actlr_el1, x0
	ret


506
func write_actlr_el2
507
508
509
510
	msr	actlr_el2, x0
	ret


511
func write_actlr_el3
512
513
514
515
516
517
518
519
	msr	actlr_el3, x0
	ret


	/* -----------------------------------------------------
	 * ESR accessors
	 * -----------------------------------------------------
	 */
520
func read_esr_el1
521
522
523
524
	mrs	x0, esr_el1
	ret


525
func read_esr_el2
526
527
528
529
	mrs	x0, esr_el2
	ret


530
func read_esr_el3
531
532
533
534
	mrs	x0, esr_el3
	ret


535
func write_esr_el1
536
537
538
539
	msr	esr_el1, x0
	ret


540
func write_esr_el2
541
542
543
544
	msr	esr_el2, x0
	ret


545
func write_esr_el3
546
547
548
549
550
551
552
553
	msr	esr_el3, x0
	ret


	/* -----------------------------------------------------
	 * TCR accessors
	 * -----------------------------------------------------
	 */
554
func read_tcr_el1
555
556
557
558
	mrs	x0, tcr_el1
	ret


559
func read_tcr_el2
560
561
562
563
	mrs	x0, tcr_el2
	ret


564
func read_tcr_el3
565
566
567
568
	mrs	x0, tcr_el3
	ret


569
func write_tcr_el1
570
571
572
573
	msr	tcr_el1, x0
	ret


574
func write_tcr_el2
575
576
577
578
	msr	tcr_el2, x0
	ret


579
func write_tcr_el3
580
581
582
583
584
585
586
587
	msr	tcr_el3, x0
	ret


	/* -----------------------------------------------------
	 * CPTR accessors
	 * -----------------------------------------------------
	 */
588
func read_cptr_el2
589
590
591
592
	mrs	x0, cptr_el2
	ret


593
func read_cptr_el3
594
595
596
597
	mrs	x0, cptr_el3
	ret


598
func write_cptr_el2
599
600
601
602
	msr	cptr_el2, x0
	ret


603
func write_cptr_el3
604
605
606
607
608
609
610
611
	msr	cptr_el3, x0
	ret


	/* -----------------------------------------------------
	 * TTBR0 accessors
	 * -----------------------------------------------------
	 */
612
func read_ttbr0_el1
613
614
615
616
	mrs	x0, ttbr0_el1
	ret


617
func read_ttbr0_el2
618
619
620
621
	mrs	x0, ttbr0_el2
	ret


622
func read_ttbr0_el3
623
624
625
626
	mrs	x0, ttbr0_el3
	ret


627
func write_ttbr0_el1
628
629
630
631
	msr	ttbr0_el1, x0
	ret


632
func write_ttbr0_el2
633
634
635
636
	msr	ttbr0_el2, x0
	ret


637
func write_ttbr0_el3
638
639
640
641
642
643
644
645
	msr	ttbr0_el3, x0
	ret


	/* -----------------------------------------------------
	 * TTBR1 accessors
	 * -----------------------------------------------------
	 */
646
func read_ttbr1_el1
647
648
649
650
	mrs	x0, ttbr1_el1
	ret


651
func write_ttbr1_el1
652
653
654
655
	msr	ttbr1_el1, x0
	ret


656
func read_hcr
657
658
659
660
	mrs	x0, hcr_el2
	ret


661
func write_hcr
662
663
664
665
	msr	hcr_el2, x0
	ret


666
func read_cpacr
667
668
669
670
	mrs	x0, cpacr_el1
	ret


671
func write_cpacr
672
673
674
675
	msr	cpacr_el1, x0
	ret


676
func read_cntfrq_el0
677
678
679
680
	mrs	x0, cntfrq_el0
	ret


681
func write_cntfrq_el0
682
683
684
	msr	cntfrq_el0, x0
	ret

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
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
712

713
func read_cpuectlr
714
715
716
717
	mrs	x0, CPUECTLR_EL1
	ret


718
func write_cpuectlr
719
720
721
722
	msr	CPUECTLR_EL1, x0
	ret


723
func read_cnthctl_el2
724
725
726
727
	mrs	x0, cnthctl_el2
	ret


728
func write_cnthctl_el2
729
730
731
732
	msr	cnthctl_el2, x0
	ret


733
func read_cntfrq
734
735
736
737
	mrs	x0, cntfrq_el0
	ret


738
func write_cntfrq
739
740
741
742
	msr	cntfrq_el0, x0
	ret


743
func write_scr
744
745
746
747
	msr	scr_el3, x0
	ret


748
func read_scr
749
750
751
752
	mrs	x0, scr_el3
	ret


753
func read_midr
754
755
756
757
	mrs	x0, midr_el1
	ret


758
func read_mpidr
759
760
761
	mrs	x0, mpidr_el1
	ret

762
763
764
765
766
767
768
func write_tpidr_el3
	msr	tpidr_el3, x0
	ret

func read_tpidr_el3
	mrs	x0, tpidr_el3
	ret
769
770

#if SUPPORT_VFP
771
func enable_vfp
772
773
774
775
776
777
778
	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
779
	isb
780
781
782
	ret

#endif