sysreg_helpers.S 10.9 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
	msr	vbar_el1, x0
	ret


207
func write_vbar_el2
208
209
210
211
	msr	vbar_el2, x0
	ret


212
func write_vbar_el3
213
214
215
216
217
218
219
220
	msr	vbar_el3, x0
	ret


	/* -----------------------------------------------------
	 * AFSR0 accessors
	 * -----------------------------------------------------
	 */
221
func read_afsr0_el1
222
223
224
225
	mrs	x0, afsr0_el1
	ret


226
func read_afsr0_el2
227
228
229
230
	mrs	x0, afsr0_el2
	ret


231
func read_afsr0_el3
232
233
234
235
	mrs	x0, afsr0_el3
	ret


236
func write_afsr0_el1
237
238
239
240
	msr	afsr0_el1, x0
	ret


241
func write_afsr0_el2
242
243
244
245
	msr	afsr0_el2, x0
	ret


246
func write_afsr0_el3
247
248
249
250
251
252
253
254
	msr	afsr0_el3, x0
	ret


	/* -----------------------------------------------------
	 * FAR accessors
	 * -----------------------------------------------------
	 */
255
func read_far_el1
256
257
258
259
	mrs	x0, far_el1
	ret


260
func read_far_el2
261
262
263
264
	mrs	x0, far_el2
	ret


265
func read_far_el3
266
267
268
269
	mrs	x0, far_el3
	ret


270
func write_far_el1
271
272
273
274
	msr	far_el1, x0
	ret


275
func write_far_el2
276
277
278
279
	msr	far_el2, x0
	ret


280
func write_far_el3
281
282
283
284
285
286
287
288
	msr	far_el3, x0
	ret


	/* -----------------------------------------------------
	 * MAIR accessors
	 * -----------------------------------------------------
	 */
289
func read_mair_el1
290
291
292
293
	mrs	x0, mair_el1
	ret


294
func read_mair_el2
295
296
297
298
	mrs	x0, mair_el2
	ret


299
func read_mair_el3
300
301
302
303
	mrs	x0, mair_el3
	ret


304
func write_mair_el1
305
306
307
308
	msr	mair_el1, x0
	ret


309
func write_mair_el2
310
311
312
313
	msr	mair_el2, x0
	ret


314
func write_mair_el3
315
316
317
318
319
320
321
322
	msr	mair_el3, x0
	ret


	/* -----------------------------------------------------
	 * AMAIR accessors
	 * -----------------------------------------------------
	 */
323
func read_amair_el1
324
325
326
327
	mrs	x0, amair_el1
	ret


328
func read_amair_el2
329
330
331
332
	mrs	x0, amair_el2
	ret


333
func read_amair_el3
334
335
336
337
	mrs	x0, amair_el3
	ret


338
func write_amair_el1
339
340
341
342
	msr	amair_el1, x0
	ret


343
func write_amair_el2
344
345
346
347
	msr	amair_el2, x0
	ret


348
func write_amair_el3
349
350
351
352
353
354
355
356
	msr	amair_el3, x0
	ret


	/* -----------------------------------------------------
	 * RVBAR accessors
	 * -----------------------------------------------------
	 */
357
func read_rvbar_el1
358
359
360
361
	mrs	x0, rvbar_el1
	ret


362
func read_rvbar_el2
363
364
365
366
	mrs	x0, rvbar_el2
	ret


367
func read_rvbar_el3
368
369
370
371
372
373
374
375
	mrs	x0, rvbar_el3
	ret


	/* -----------------------------------------------------
	 * RMR accessors
	 * -----------------------------------------------------
	 */
376
func read_rmr_el1
377
378
379
380
	mrs	x0, rmr_el1
	ret


381
func read_rmr_el2
382
383
384
385
	mrs	x0, rmr_el2
	ret


386
func read_rmr_el3
387
388
389
390
	mrs	x0, rmr_el3
	ret


391
func write_rmr_el1
392
393
394
395
	msr	rmr_el1, x0
	ret


396
func write_rmr_el2
397
398
399
400
	msr	rmr_el2, x0
	ret


401
func write_rmr_el3
402
403
404
405
406
407
408
409
	msr	rmr_el3, x0
	ret


	/* -----------------------------------------------------
	 * AFSR1 accessors
	 * -----------------------------------------------------
	 */
410
func read_afsr1_el1
411
412
413
414
	mrs	x0, afsr1_el1
	ret


415
func read_afsr1_el2
416
417
418
419
	mrs	x0, afsr1_el2
	ret


420
func read_afsr1_el3
421
422
423
424
	mrs	x0, afsr1_el3
	ret


425
func write_afsr1_el1
426
427
428
429
	msr	afsr1_el1, x0
	ret


430
func write_afsr1_el2
431
432
433
434
	msr	afsr1_el2, x0
	ret


435
func write_afsr1_el3
436
437
438
439
440
441
442
443
	msr	afsr1_el3, x0
	ret


	/* -----------------------------------------------------
	 * SCTLR accessors
	 * -----------------------------------------------------
	 */
444
func read_sctlr_el1
445
446
447
448
	mrs	x0, sctlr_el1
	ret


449
func read_sctlr_el2
450
451
452
453
	mrs	x0, sctlr_el2
	ret


454
func read_sctlr_el3
455
456
457
458
	mrs	x0, sctlr_el3
	ret


459
func write_sctlr_el1
460
461
462
463
	msr	sctlr_el1, x0
	ret


464
func write_sctlr_el2
465
466
467
468
	msr	sctlr_el2, x0
	ret


469
func write_sctlr_el3
470
471
472
473
474
475
476
477
	msr	sctlr_el3, x0
	ret


	/* -----------------------------------------------------
	 * ACTLR accessors
	 * -----------------------------------------------------
	 */
478
func read_actlr_el1
479
480
481
482
	mrs	x0, actlr_el1
	ret


483
func read_actlr_el2
484
485
486
487
	mrs	x0, actlr_el2
	ret


488
func read_actlr_el3
489
490
491
492
	mrs	x0, actlr_el3
	ret


493
func write_actlr_el1
494
495
496
497
	msr	actlr_el1, x0
	ret


498
func write_actlr_el2
499
500
501
502
	msr	actlr_el2, x0
	ret


503
func write_actlr_el3
504
505
506
507
508
509
510
511
	msr	actlr_el3, x0
	ret


	/* -----------------------------------------------------
	 * ESR accessors
	 * -----------------------------------------------------
	 */
512
func read_esr_el1
513
514
515
516
	mrs	x0, esr_el1
	ret


517
func read_esr_el2
518
519
520
521
	mrs	x0, esr_el2
	ret


522
func read_esr_el3
523
524
525
526
	mrs	x0, esr_el3
	ret


527
func write_esr_el1
528
529
530
531
	msr	esr_el1, x0
	ret


532
func write_esr_el2
533
534
535
536
	msr	esr_el2, x0
	ret


537
func write_esr_el3
538
539
540
541
542
543
544
545
	msr	esr_el3, x0
	ret


	/* -----------------------------------------------------
	 * TCR accessors
	 * -----------------------------------------------------
	 */
546
func read_tcr_el1
547
548
549
550
	mrs	x0, tcr_el1
	ret


551
func read_tcr_el2
552
553
554
555
	mrs	x0, tcr_el2
	ret


556
func read_tcr_el3
557
558
559
560
	mrs	x0, tcr_el3
	ret


561
func write_tcr_el1
562
563
564
565
	msr	tcr_el1, x0
	ret


566
func write_tcr_el2
567
568
569
570
	msr	tcr_el2, x0
	ret


571
func write_tcr_el3
572
573
574
575
576
577
578
579
	msr	tcr_el3, x0
	ret


	/* -----------------------------------------------------
	 * CPTR accessors
	 * -----------------------------------------------------
	 */
580
func read_cptr_el1
581
582
583
584
	b	read_cptr_el1
	ret


585
func read_cptr_el2
586
587
588
589
	mrs	x0, cptr_el2
	ret


590
func read_cptr_el3
591
592
593
594
	mrs	x0, cptr_el3
	ret


595
func write_cptr_el1
596
597
598
	b	write_cptr_el1


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


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


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


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


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


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


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


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


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


652
func read_ttbr1_el2
653
654
655
	b	read_ttbr1_el2


656
func read_ttbr1_el3
657
658
659
	b	read_ttbr1_el3


660
func write_ttbr1_el1
661
662
663
664
	msr	ttbr1_el1, x0
	ret


665
func write_ttbr1_el2
666
667
668
	b	write_ttbr1_el2


669
func write_ttbr1_el3
670
671
672
	b	write_ttbr1_el3


673
func read_hcr
674
675
676
677
	mrs	x0, hcr_el2
	ret


678
func write_hcr
679
680
681
682
	msr	hcr_el2, x0
	ret


683
func read_cpacr
684
685
686
687
	mrs	x0, cpacr_el1
	ret


688
func write_cpacr
689
690
691
692
	msr	cpacr_el1, x0
	ret


693
func read_cntfrq_el0
694
695
696
697
	mrs	x0, cntfrq_el0
	ret


698
func write_cntfrq_el0
699
700
701
702
	msr	cntfrq_el0, x0
	ret


703
func read_cpuectlr
704
705
706
707
	mrs	x0, CPUECTLR_EL1
	ret


708
func write_cpuectlr
709
710
711
712
	msr	CPUECTLR_EL1, x0
	ret


713
func read_cnthctl_el2
714
715
716
717
	mrs	x0, cnthctl_el2
	ret


718
func write_cnthctl_el2
719
720
721
722
	msr	cnthctl_el2, x0
	ret


723
func read_cntfrq
724
725
726
727
	mrs	x0, cntfrq_el0
	ret


728
func write_cntfrq
729
730
731
732
	msr	cntfrq_el0, x0
	ret


733
func write_scr
734
735
736
737
	msr	scr_el3, x0
	ret


738
func read_scr
739
740
741
742
	mrs	x0, scr_el3
	ret


743
func read_midr
744
745
746
747
	mrs	x0, midr_el1
	ret


748
func read_mpidr
749
750
751
752
753
	mrs	x0, mpidr_el1
	ret


#if SUPPORT_VFP
754
func enable_vfp
755
756
757
758
759
760
761
	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
762
	isb
763
764
765
	ret


766
func read_fpexc
767
768
769
770
	b	read_fpexc
	ret


771
func write_fpexc
772
773
774
775
	b	write_fpexc
	ret

#endif