sysreg_helpers.S 10.6 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

	.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_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

158
159
160
	.globl	write_tpidr_el3
	.globl	read_tpidr_el3

161
162
163
164
165
#if SUPPORT_VFP
	.globl	enable_vfp
#endif


166
func read_current_el
167
168
169
170
	mrs	x0, CurrentEl
	ret


171
func read_id_pfr1_el1
172
173
174
175
	mrs	x0, id_pfr1_el1
	ret


176
func read_id_aa64pfr0_el1
177
178
179
180
181
182
183
184
	mrs	x0, id_aa64pfr0_el1
	ret


	/* -----------------------------------------------------
	 * VBAR accessors
	 * -----------------------------------------------------
	 */
185
func read_vbar_el1
186
187
188
189
	mrs	x0, vbar_el1
	ret


190
func read_vbar_el2
191
192
193
194
	mrs	x0, vbar_el2
	ret


195
func read_vbar_el3
196
197
198
199
	mrs	x0, vbar_el3
	ret


200
func write_vbar_el1
201
202
203
204
	msr	vbar_el1, x0
	ret


205
func write_vbar_el2
206
207
208
209
	msr	vbar_el2, x0
	ret


210
func write_vbar_el3
211
212
213
214
215
216
217
218
	msr	vbar_el3, x0
	ret


	/* -----------------------------------------------------
	 * AFSR0 accessors
	 * -----------------------------------------------------
	 */
219
func read_afsr0_el1
220
221
222
223
	mrs	x0, afsr0_el1
	ret


224
func read_afsr0_el2
225
226
227
228
	mrs	x0, afsr0_el2
	ret


229
func read_afsr0_el3
230
231
232
233
	mrs	x0, afsr0_el3
	ret


234
func write_afsr0_el1
235
236
237
238
	msr	afsr0_el1, x0
	ret


239
func write_afsr0_el2
240
241
242
243
	msr	afsr0_el2, x0
	ret


244
func write_afsr0_el3
245
246
247
248
249
250
251
252
	msr	afsr0_el3, x0
	ret


	/* -----------------------------------------------------
	 * FAR accessors
	 * -----------------------------------------------------
	 */
253
func read_far_el1
254
255
256
257
	mrs	x0, far_el1
	ret


258
func read_far_el2
259
260
261
262
	mrs	x0, far_el2
	ret


263
func read_far_el3
264
265
266
267
	mrs	x0, far_el3
	ret


268
func write_far_el1
269
270
271
272
	msr	far_el1, x0
	ret


273
func write_far_el2
274
275
276
277
	msr	far_el2, x0
	ret


278
func write_far_el3
279
280
281
282
283
284
285
286
	msr	far_el3, x0
	ret


	/* -----------------------------------------------------
	 * MAIR accessors
	 * -----------------------------------------------------
	 */
287
func read_mair_el1
288
289
290
291
	mrs	x0, mair_el1
	ret


292
func read_mair_el2
293
294
295
296
	mrs	x0, mair_el2
	ret


297
func read_mair_el3
298
299
300
301
	mrs	x0, mair_el3
	ret


302
func write_mair_el1
303
304
305
306
	msr	mair_el1, x0
	ret


307
func write_mair_el2
308
309
310
311
	msr	mair_el2, x0
	ret


312
func write_mair_el3
313
314
315
316
317
318
319
320
	msr	mair_el3, x0
	ret


	/* -----------------------------------------------------
	 * AMAIR accessors
	 * -----------------------------------------------------
	 */
321
func read_amair_el1
322
323
324
325
	mrs	x0, amair_el1
	ret


326
func read_amair_el2
327
328
329
330
	mrs	x0, amair_el2
	ret


331
func read_amair_el3
332
333
334
335
	mrs	x0, amair_el3
	ret


336
func write_amair_el1
337
338
339
340
	msr	amair_el1, x0
	ret


341
func write_amair_el2
342
343
344
345
	msr	amair_el2, x0
	ret


346
func write_amair_el3
347
348
349
350
351
352
353
354
	msr	amair_el3, x0
	ret


	/* -----------------------------------------------------
	 * RVBAR accessors
	 * -----------------------------------------------------
	 */
355
func read_rvbar_el1
356
357
358
359
	mrs	x0, rvbar_el1
	ret


360
func read_rvbar_el2
361
362
363
364
	mrs	x0, rvbar_el2
	ret


365
func read_rvbar_el3
366
367
368
369
370
371
372
373
	mrs	x0, rvbar_el3
	ret


	/* -----------------------------------------------------
	 * RMR accessors
	 * -----------------------------------------------------
	 */
374
func read_rmr_el1
375
376
377
378
	mrs	x0, rmr_el1
	ret


379
func read_rmr_el2
380
381
382
383
	mrs	x0, rmr_el2
	ret


384
func read_rmr_el3
385
386
387
388
	mrs	x0, rmr_el3
	ret


389
func write_rmr_el1
390
391
392
393
	msr	rmr_el1, x0
	ret


394
func write_rmr_el2
395
396
397
398
	msr	rmr_el2, x0
	ret


399
func write_rmr_el3
400
401
402
403
404
405
406
407
	msr	rmr_el3, x0
	ret


	/* -----------------------------------------------------
	 * AFSR1 accessors
	 * -----------------------------------------------------
	 */
408
func read_afsr1_el1
409
410
411
412
	mrs	x0, afsr1_el1
	ret


413
func read_afsr1_el2
414
415
416
417
	mrs	x0, afsr1_el2
	ret


418
func read_afsr1_el3
419
420
421
422
	mrs	x0, afsr1_el3
	ret


423
func write_afsr1_el1
424
425
426
427
	msr	afsr1_el1, x0
	ret


428
func write_afsr1_el2
429
430
431
432
	msr	afsr1_el2, x0
	ret


433
func write_afsr1_el3
434
435
436
437
438
439
440
441
	msr	afsr1_el3, x0
	ret


	/* -----------------------------------------------------
	 * SCTLR accessors
	 * -----------------------------------------------------
	 */
442
func read_sctlr_el1
443
444
445
446
	mrs	x0, sctlr_el1
	ret


447
func read_sctlr_el2
448
449
450
451
	mrs	x0, sctlr_el2
	ret


452
func read_sctlr_el3
453
454
455
456
	mrs	x0, sctlr_el3
	ret


457
func write_sctlr_el1
458
459
460
461
	msr	sctlr_el1, x0
	ret


462
func write_sctlr_el2
463
464
465
466
	msr	sctlr_el2, x0
	ret


467
func write_sctlr_el3
468
469
470
471
472
473
474
475
	msr	sctlr_el3, x0
	ret


	/* -----------------------------------------------------
	 * ACTLR accessors
	 * -----------------------------------------------------
	 */
476
func read_actlr_el1
477
478
479
480
	mrs	x0, actlr_el1
	ret


481
func read_actlr_el2
482
483
484
485
	mrs	x0, actlr_el2
	ret


486
func read_actlr_el3
487
488
489
490
	mrs	x0, actlr_el3
	ret


491
func write_actlr_el1
492
493
494
495
	msr	actlr_el1, x0
	ret


496
func write_actlr_el2
497
498
499
500
	msr	actlr_el2, x0
	ret


501
func write_actlr_el3
502
503
504
505
506
507
508
509
	msr	actlr_el3, x0
	ret


	/* -----------------------------------------------------
	 * ESR accessors
	 * -----------------------------------------------------
	 */
510
func read_esr_el1
511
512
513
514
	mrs	x0, esr_el1
	ret


515
func read_esr_el2
516
517
518
519
	mrs	x0, esr_el2
	ret


520
func read_esr_el3
521
522
523
524
	mrs	x0, esr_el3
	ret


525
func write_esr_el1
526
527
528
529
	msr	esr_el1, x0
	ret


530
func write_esr_el2
531
532
533
534
	msr	esr_el2, x0
	ret


535
func write_esr_el3
536
537
538
539
540
541
542
543
	msr	esr_el3, x0
	ret


	/* -----------------------------------------------------
	 * TCR accessors
	 * -----------------------------------------------------
	 */
544
func read_tcr_el1
545
546
547
548
	mrs	x0, tcr_el1
	ret


549
func read_tcr_el2
550
551
552
553
	mrs	x0, tcr_el2
	ret


554
func read_tcr_el3
555
556
557
558
	mrs	x0, tcr_el3
	ret


559
func write_tcr_el1
560
561
562
563
	msr	tcr_el1, x0
	ret


564
func write_tcr_el2
565
566
567
568
	msr	tcr_el2, x0
	ret


569
func write_tcr_el3
570
571
572
573
574
575
576
577
	msr	tcr_el3, x0
	ret


	/* -----------------------------------------------------
	 * CPTR accessors
	 * -----------------------------------------------------
	 */
578
func read_cptr_el2
579
580
581
582
	mrs	x0, cptr_el2
	ret


583
func read_cptr_el3
584
585
586
587
	mrs	x0, cptr_el3
	ret


588
func write_cptr_el2
589
590
591
592
	msr	cptr_el2, x0
	ret


593
func write_cptr_el3
594
595
596
597
598
599
600
601
	msr	cptr_el3, x0
	ret


	/* -----------------------------------------------------
	 * TTBR0 accessors
	 * -----------------------------------------------------
	 */
602
func read_ttbr0_el1
603
604
605
606
	mrs	x0, ttbr0_el1
	ret


607
func read_ttbr0_el2
608
609
610
611
	mrs	x0, ttbr0_el2
	ret


612
func read_ttbr0_el3
613
614
615
616
	mrs	x0, ttbr0_el3
	ret


617
func write_ttbr0_el1
618
619
620
621
	msr	ttbr0_el1, x0
	ret


622
func write_ttbr0_el2
623
624
625
626
	msr	ttbr0_el2, x0
	ret


627
func write_ttbr0_el3
628
629
630
631
632
633
634
635
	msr	ttbr0_el3, x0
	ret


	/* -----------------------------------------------------
	 * TTBR1 accessors
	 * -----------------------------------------------------
	 */
636
func read_ttbr1_el1
637
638
639
640
	mrs	x0, ttbr1_el1
	ret


641
func write_ttbr1_el1
642
643
644
645
	msr	ttbr1_el1, x0
	ret


646
func read_hcr
647
648
649
650
	mrs	x0, hcr_el2
	ret


651
func write_hcr
652
653
654
655
	msr	hcr_el2, x0
	ret


656
func read_cpacr
657
658
659
660
	mrs	x0, cpacr_el1
	ret


661
func write_cpacr
662
663
664
665
	msr	cpacr_el1, x0
	ret


666
func read_cntfrq_el0
667
668
669
670
	mrs	x0, cntfrq_el0
	ret


671
func write_cntfrq_el0
672
673
674
675
	msr	cntfrq_el0, x0
	ret


676
func read_cpuectlr
677
678
679
680
	mrs	x0, CPUECTLR_EL1
	ret


681
func write_cpuectlr
682
683
684
685
	msr	CPUECTLR_EL1, x0
	ret


686
func read_cnthctl_el2
687
688
689
690
	mrs	x0, cnthctl_el2
	ret


691
func write_cnthctl_el2
692
693
694
695
	msr	cnthctl_el2, x0
	ret


696
func read_cntfrq
697
698
699
700
	mrs	x0, cntfrq_el0
	ret


701
func write_cntfrq
702
703
704
705
	msr	cntfrq_el0, x0
	ret


706
func write_scr
707
708
709
710
	msr	scr_el3, x0
	ret


711
func read_scr
712
713
714
715
	mrs	x0, scr_el3
	ret


716
func read_midr
717
718
719
720
	mrs	x0, midr_el1
	ret


721
func read_mpidr
722
723
724
	mrs	x0, mpidr_el1
	ret

725
726
727
728
729
730
731
func write_tpidr_el3
	msr	tpidr_el3, x0
	ret

func read_tpidr_el3
	mrs	x0, tpidr_el3
	ret
732
733

#if SUPPORT_VFP
734
func enable_vfp
735
736
737
738
739
740
741
	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
742
	isb
743
744
745
	ret

#endif