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

	.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

#if SUPPORT_VFP
	.globl	enable_vfp
#endif


163
func read_current_el
164
165
166
167
	mrs	x0, CurrentEl
	ret


168
func read_id_pfr1_el1
169
170
171
172
	mrs	x0, id_pfr1_el1
	ret


173
func read_id_aa64pfr0_el1
174
175
176
177
178
179
180
181
	mrs	x0, id_aa64pfr0_el1
	ret


	/* -----------------------------------------------------
	 * VBAR accessors
	 * -----------------------------------------------------
	 */
182
func read_vbar_el1
183
184
185
186
	mrs	x0, vbar_el1
	ret


187
func read_vbar_el2
188
189
190
191
	mrs	x0, vbar_el2
	ret


192
func read_vbar_el3
193
194
195
196
	mrs	x0, vbar_el3
	ret


197
func write_vbar_el1
198
199
200
201
	msr	vbar_el1, x0
	ret


202
func write_vbar_el2
203
204
205
206
	msr	vbar_el2, x0
	ret


207
func write_vbar_el3
208
209
210
211
212
213
214
215
	msr	vbar_el3, x0
	ret


	/* -----------------------------------------------------
	 * AFSR0 accessors
	 * -----------------------------------------------------
	 */
216
func read_afsr0_el1
217
218
219
220
	mrs	x0, afsr0_el1
	ret


221
func read_afsr0_el2
222
223
224
225
	mrs	x0, afsr0_el2
	ret


226
func read_afsr0_el3
227
228
229
230
	mrs	x0, afsr0_el3
	ret


231
func write_afsr0_el1
232
233
234
235
	msr	afsr0_el1, x0
	ret


236
func write_afsr0_el2
237
238
239
240
	msr	afsr0_el2, x0
	ret


241
func write_afsr0_el3
242
243
244
245
246
247
248
249
	msr	afsr0_el3, x0
	ret


	/* -----------------------------------------------------
	 * FAR accessors
	 * -----------------------------------------------------
	 */
250
func read_far_el1
251
252
253
254
	mrs	x0, far_el1
	ret


255
func read_far_el2
256
257
258
259
	mrs	x0, far_el2
	ret


260
func read_far_el3
261
262
263
264
	mrs	x0, far_el3
	ret


265
func write_far_el1
266
267
268
269
	msr	far_el1, x0
	ret


270
func write_far_el2
271
272
273
274
	msr	far_el2, x0
	ret


275
func write_far_el3
276
277
278
279
280
281
282
283
	msr	far_el3, x0
	ret


	/* -----------------------------------------------------
	 * MAIR accessors
	 * -----------------------------------------------------
	 */
284
func read_mair_el1
285
286
287
288
	mrs	x0, mair_el1
	ret


289
func read_mair_el2
290
291
292
293
	mrs	x0, mair_el2
	ret


294
func read_mair_el3
295
296
297
298
	mrs	x0, mair_el3
	ret


299
func write_mair_el1
300
301
302
303
	msr	mair_el1, x0
	ret


304
func write_mair_el2
305
306
307
308
	msr	mair_el2, x0
	ret


309
func write_mair_el3
310
311
312
313
314
315
316
317
	msr	mair_el3, x0
	ret


	/* -----------------------------------------------------
	 * AMAIR accessors
	 * -----------------------------------------------------
	 */
318
func read_amair_el1
319
320
321
322
	mrs	x0, amair_el1
	ret


323
func read_amair_el2
324
325
326
327
	mrs	x0, amair_el2
	ret


328
func read_amair_el3
329
330
331
332
	mrs	x0, amair_el3
	ret


333
func write_amair_el1
334
335
336
337
	msr	amair_el1, x0
	ret


338
func write_amair_el2
339
340
341
342
	msr	amair_el2, x0
	ret


343
func write_amair_el3
344
345
346
347
348
349
350
351
	msr	amair_el3, x0
	ret


	/* -----------------------------------------------------
	 * RVBAR accessors
	 * -----------------------------------------------------
	 */
352
func read_rvbar_el1
353
354
355
356
	mrs	x0, rvbar_el1
	ret


357
func read_rvbar_el2
358
359
360
361
	mrs	x0, rvbar_el2
	ret


362
func read_rvbar_el3
363
364
365
366
367
368
369
370
	mrs	x0, rvbar_el3
	ret


	/* -----------------------------------------------------
	 * RMR accessors
	 * -----------------------------------------------------
	 */
371
func read_rmr_el1
372
373
374
375
	mrs	x0, rmr_el1
	ret


376
func read_rmr_el2
377
378
379
380
	mrs	x0, rmr_el2
	ret


381
func read_rmr_el3
382
383
384
385
	mrs	x0, rmr_el3
	ret


386
func write_rmr_el1
387
388
389
390
	msr	rmr_el1, x0
	ret


391
func write_rmr_el2
392
393
394
395
	msr	rmr_el2, x0
	ret


396
func write_rmr_el3
397
398
399
400
401
402
403
404
	msr	rmr_el3, x0
	ret


	/* -----------------------------------------------------
	 * AFSR1 accessors
	 * -----------------------------------------------------
	 */
405
func read_afsr1_el1
406
407
408
409
	mrs	x0, afsr1_el1
	ret


410
func read_afsr1_el2
411
412
413
414
	mrs	x0, afsr1_el2
	ret


415
func read_afsr1_el3
416
417
418
419
	mrs	x0, afsr1_el3
	ret


420
func write_afsr1_el1
421
422
423
424
	msr	afsr1_el1, x0
	ret


425
func write_afsr1_el2
426
427
428
429
	msr	afsr1_el2, x0
	ret


430
func write_afsr1_el3
431
432
433
434
435
436
437
438
	msr	afsr1_el3, x0
	ret


	/* -----------------------------------------------------
	 * SCTLR accessors
	 * -----------------------------------------------------
	 */
439
func read_sctlr_el1
440
441
442
443
	mrs	x0, sctlr_el1
	ret


444
func read_sctlr_el2
445
446
447
448
	mrs	x0, sctlr_el2
	ret


449
func read_sctlr_el3
450
451
452
453
	mrs	x0, sctlr_el3
	ret


454
func write_sctlr_el1
455
456
457
458
	msr	sctlr_el1, x0
	ret


459
func write_sctlr_el2
460
461
462
463
	msr	sctlr_el2, x0
	ret


464
func write_sctlr_el3
465
466
467
468
469
470
471
472
	msr	sctlr_el3, x0
	ret


	/* -----------------------------------------------------
	 * ACTLR accessors
	 * -----------------------------------------------------
	 */
473
func read_actlr_el1
474
475
476
477
	mrs	x0, actlr_el1
	ret


478
func read_actlr_el2
479
480
481
482
	mrs	x0, actlr_el2
	ret


483
func read_actlr_el3
484
485
486
487
	mrs	x0, actlr_el3
	ret


488
func write_actlr_el1
489
490
491
492
	msr	actlr_el1, x0
	ret


493
func write_actlr_el2
494
495
496
497
	msr	actlr_el2, x0
	ret


498
func write_actlr_el3
499
500
501
502
503
504
505
506
	msr	actlr_el3, x0
	ret


	/* -----------------------------------------------------
	 * ESR accessors
	 * -----------------------------------------------------
	 */
507
func read_esr_el1
508
509
510
511
	mrs	x0, esr_el1
	ret


512
func read_esr_el2
513
514
515
516
	mrs	x0, esr_el2
	ret


517
func read_esr_el3
518
519
520
521
	mrs	x0, esr_el3
	ret


522
func write_esr_el1
523
524
525
526
	msr	esr_el1, x0
	ret


527
func write_esr_el2
528
529
530
531
	msr	esr_el2, x0
	ret


532
func write_esr_el3
533
534
535
536
537
538
539
540
	msr	esr_el3, x0
	ret


	/* -----------------------------------------------------
	 * TCR accessors
	 * -----------------------------------------------------
	 */
541
func read_tcr_el1
542
543
544
545
	mrs	x0, tcr_el1
	ret


546
func read_tcr_el2
547
548
549
550
	mrs	x0, tcr_el2
	ret


551
func read_tcr_el3
552
553
554
555
	mrs	x0, tcr_el3
	ret


556
func write_tcr_el1
557
558
559
560
	msr	tcr_el1, x0
	ret


561
func write_tcr_el2
562
563
564
565
	msr	tcr_el2, x0
	ret


566
func write_tcr_el3
567
568
569
570
571
572
573
574
	msr	tcr_el3, x0
	ret


	/* -----------------------------------------------------
	 * CPTR accessors
	 * -----------------------------------------------------
	 */
575
func read_cptr_el2
576
577
578
579
	mrs	x0, cptr_el2
	ret


580
func read_cptr_el3
581
582
583
584
	mrs	x0, cptr_el3
	ret


585
func write_cptr_el2
586
587
588
589
	msr	cptr_el2, x0
	ret


590
func write_cptr_el3
591
592
593
594
595
596
597
598
	msr	cptr_el3, x0
	ret


	/* -----------------------------------------------------
	 * TTBR0 accessors
	 * -----------------------------------------------------
	 */
599
func read_ttbr0_el1
600
601
602
603
	mrs	x0, ttbr0_el1
	ret


604
func read_ttbr0_el2
605
606
607
608
	mrs	x0, ttbr0_el2
	ret


609
func read_ttbr0_el3
610
611
612
613
	mrs	x0, ttbr0_el3
	ret


614
func write_ttbr0_el1
615
616
617
618
	msr	ttbr0_el1, x0
	ret


619
func write_ttbr0_el2
620
621
622
623
	msr	ttbr0_el2, x0
	ret


624
func write_ttbr0_el3
625
626
627
628
629
630
631
632
	msr	ttbr0_el3, x0
	ret


	/* -----------------------------------------------------
	 * TTBR1 accessors
	 * -----------------------------------------------------
	 */
633
func read_ttbr1_el1
634
635
636
637
	mrs	x0, ttbr1_el1
	ret


638
func write_ttbr1_el1
639
640
641
642
	msr	ttbr1_el1, x0
	ret


643
func read_hcr
644
645
646
647
	mrs	x0, hcr_el2
	ret


648
func write_hcr
649
650
651
652
	msr	hcr_el2, x0
	ret


653
func read_cpacr
654
655
656
657
	mrs	x0, cpacr_el1
	ret


658
func write_cpacr
659
660
661
662
	msr	cpacr_el1, x0
	ret


663
func read_cntfrq_el0
664
665
666
667
	mrs	x0, cntfrq_el0
	ret


668
func write_cntfrq_el0
669
670
671
672
	msr	cntfrq_el0, x0
	ret


673
func read_cpuectlr
674
675
676
677
	mrs	x0, CPUECTLR_EL1
	ret


678
func write_cpuectlr
679
680
681
682
	msr	CPUECTLR_EL1, x0
	ret


683
func read_cnthctl_el2
684
685
686
687
	mrs	x0, cnthctl_el2
	ret


688
func write_cnthctl_el2
689
690
691
692
	msr	cnthctl_el2, x0
	ret


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


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


703
func write_scr
704
705
706
707
	msr	scr_el3, x0
	ret


708
func read_scr
709
710
711
712
	mrs	x0, scr_el3
	ret


713
func read_midr
714
715
716
717
	mrs	x0, midr_el1
	ret


718
func read_mpidr
719
720
721
722
723
	mrs	x0, mpidr_el1
	ret


#if SUPPORT_VFP
724
func enable_vfp
725
726
727
728
729
730
731
	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
732
	isb
733
734
735
	ret

#endif