xref: /rk3399_rockchip-uboot/arch/arm/cpu/armv8/exceptions.S (revision faa7eb0f76fd6e206963e74af89afc949c2e2c17)
10ae76531SDavid Feng/*
20ae76531SDavid Feng * (C) Copyright 2013
30ae76531SDavid Feng * David Feng <fenghua@phytium.com.cn>
40ae76531SDavid Feng *
50ae76531SDavid Feng * SPDX-License-Identifier:	GPL-2.0+
60ae76531SDavid Feng */
70ae76531SDavid Feng
80ae76531SDavid Feng#include <asm-offsets.h>
90ae76531SDavid Feng#include <config.h>
100ae76531SDavid Feng#include <asm/ptrace.h>
110ae76531SDavid Feng#include <asm/macro.h>
120ae76531SDavid Feng#include <linux/linkage.h>
130ae76531SDavid Feng
140ae76531SDavid Feng/*
153bf2315fSAndre Przywara * Exception vectors.
163bf2315fSAndre Przywara */
173bf2315fSAndre Przywara	.align	11
183bf2315fSAndre Przywara	.globl	vectors
193bf2315fSAndre Przywaravectors:
203bf2315fSAndre Przywara	.align	7		/* Current EL Synchronous Thread */
213bf2315fSAndre Przywara	stp	x29, x30, [sp, #-16]!
223bf2315fSAndre Przywara	bl	_exception_entry
233bf2315fSAndre Przywara	bl	do_bad_sync
243bf2315fSAndre Przywara	b	exception_exit
253bf2315fSAndre Przywara
263bf2315fSAndre Przywara	.align	7		/* Current EL IRQ Thread */
273bf2315fSAndre Przywara	stp	x29, x30, [sp, #-16]!
283bf2315fSAndre Przywara	bl	_exception_entry
293bf2315fSAndre Przywara	bl	do_bad_irq
303bf2315fSAndre Przywara	b	exception_exit
313bf2315fSAndre Przywara
323bf2315fSAndre Przywara	.align	7		/* Current EL FIQ Thread */
333bf2315fSAndre Przywara	stp	x29, x30, [sp, #-16]!
343bf2315fSAndre Przywara	bl	_exception_entry
353bf2315fSAndre Przywara	bl	do_bad_fiq
363bf2315fSAndre Przywara	b	exception_exit
373bf2315fSAndre Przywara
383bf2315fSAndre Przywara	.align	7		/* Current EL Error Thread */
393bf2315fSAndre Przywara	stp	x29, x30, [sp, #-16]!
403bf2315fSAndre Przywara	bl	_exception_entry
413bf2315fSAndre Przywara	bl	do_bad_error
423bf2315fSAndre Przywara	b	exception_exit
433bf2315fSAndre Przywara
443bf2315fSAndre Przywara	.align	7		 /* Current EL Synchronous Handler */
453bf2315fSAndre Przywara	stp	x29, x30, [sp, #-16]!
463bf2315fSAndre Przywara	bl	_exception_entry
473bf2315fSAndre Przywara	bl	do_sync
483bf2315fSAndre Przywara	b	exception_exit
493bf2315fSAndre Przywara
503bf2315fSAndre Przywara	.align	7		 /* Current EL IRQ Handler */
513bf2315fSAndre Przywara	stp	x29, x30, [sp, #-16]!
523bf2315fSAndre Przywara	bl	_exception_entry
533bf2315fSAndre Przywara	bl	do_irq
543bf2315fSAndre Przywara	b	exception_exit
553bf2315fSAndre Przywara
563bf2315fSAndre Przywara	.align	7		 /* Current EL FIQ Handler */
573bf2315fSAndre Przywara	stp	x29, x30, [sp, #-16]!
583bf2315fSAndre Przywara	bl	_exception_entry
593bf2315fSAndre Przywara	bl	do_fiq
603bf2315fSAndre Przywara	b	exception_exit
613bf2315fSAndre Przywara
623bf2315fSAndre Przywara	.align	7		 /* Current EL Error Handler */
633bf2315fSAndre Przywara	stp	x29, x30, [sp, #-16]!
643bf2315fSAndre Przywara	bl	_exception_entry
653bf2315fSAndre Przywara	bl	do_error
663bf2315fSAndre Przywara	b	exception_exit
673bf2315fSAndre Przywara
683bf2315fSAndre Przywara/*
690ae76531SDavid Feng * Enter Exception.
700ae76531SDavid Feng * This will save the processor state that is ELR/X0~X30
710ae76531SDavid Feng * to the stack frame.
720ae76531SDavid Feng */
733bf2315fSAndre Przywara_exception_entry:
740ae76531SDavid Feng	stp	x27, x28, [sp, #-16]!
750ae76531SDavid Feng	stp	x25, x26, [sp, #-16]!
760ae76531SDavid Feng	stp	x23, x24, [sp, #-16]!
770ae76531SDavid Feng	stp	x21, x22, [sp, #-16]!
780ae76531SDavid Feng	stp	x19, x20, [sp, #-16]!
790ae76531SDavid Feng	stp	x17, x18, [sp, #-16]!
800ae76531SDavid Feng	stp	x15, x16, [sp, #-16]!
810ae76531SDavid Feng	stp	x13, x14, [sp, #-16]!
820ae76531SDavid Feng	stp	x11, x12, [sp, #-16]!
830ae76531SDavid Feng	stp	x9, x10, [sp, #-16]!
840ae76531SDavid Feng	stp	x7, x8, [sp, #-16]!
850ae76531SDavid Feng	stp	x5, x6, [sp, #-16]!
860ae76531SDavid Feng	stp	x3, x4, [sp, #-16]!
870ae76531SDavid Feng	stp	x1, x2, [sp, #-16]!
880ae76531SDavid Feng
890ae76531SDavid Feng	/* Could be running at EL3/EL2/EL1 */
900ae76531SDavid Feng	switch_el x11, 3f, 2f, 1f
910ae76531SDavid Feng3:	mrs	x1, esr_el3
920ae76531SDavid Feng	mrs	x2, elr_el3
93*faa7eb0fSJoseph Chen	mrs	x3, daif
94*faa7eb0fSJoseph Chen	mrs	x4, vbar_el3
95*faa7eb0fSJoseph Chen	mrs	x5, spsr_el3
96*faa7eb0fSJoseph Chen	sub	x6, sp, #(8*30)
97*faa7eb0fSJoseph Chen	mrs	x7, sctlr_el3
98*faa7eb0fSJoseph Chen	mrs	x8, scr_el3
99*faa7eb0fSJoseph Chen	mrs	x9, ttbr0_el3
1000ae76531SDavid Feng	b	0f
1010ae76531SDavid Feng2:	mrs	x1, esr_el2
1020ae76531SDavid Feng	mrs	x2, elr_el2
103*faa7eb0fSJoseph Chen	mrs	x3, daif
104*faa7eb0fSJoseph Chen	mrs	x4, vbar_el2
105*faa7eb0fSJoseph Chen	mrs	x5, spsr_el2
106*faa7eb0fSJoseph Chen	sub	x6, sp, #(8*30)
107*faa7eb0fSJoseph Chen	mrs	x7, sctlr_el2
108*faa7eb0fSJoseph Chen	mrs	x8, hcr_el2
109*faa7eb0fSJoseph Chen	mrs	x9, ttbr0_el2
1100ae76531SDavid Feng	b	0f
111*faa7eb0fSJoseph Chen
1120ae76531SDavid Feng1:	mrs	x1, esr_el1
1130ae76531SDavid Feng	mrs	x2, elr_el1
114*faa7eb0fSJoseph Chen	mrs	x3, daif
115*faa7eb0fSJoseph Chen	mrs	x4, vbar_el1
116*faa7eb0fSJoseph Chen	mrs	x5, spsr_el1
117*faa7eb0fSJoseph Chen	sub	x6, sp, #(8*30)
118*faa7eb0fSJoseph Chen	mrs	x7, sctlr_el1
119*faa7eb0fSJoseph Chen	mov	x8, #0	/* Not used, EL1 don't have register, like 'scr_el1' */
120*faa7eb0fSJoseph Chen	mrs	x9, ttbr0_el1
1210ae76531SDavid Feng0:
1220ae76531SDavid Feng	stp     x2, x0, [sp, #-16]!
123*faa7eb0fSJoseph Chen	stp	x3, x1, [sp, #-16]!
124*faa7eb0fSJoseph Chen	stp	x5, x4, [sp, #-16]!
125*faa7eb0fSJoseph Chen	stp	x7, x6, [sp, #-16]!
126*faa7eb0fSJoseph Chen	stp	x9, x8, [sp, #-16]!
1270ae76531SDavid Feng	mov	x0, sp
1283bf2315fSAndre Przywara	ret
1290ae76531SDavid Feng
1304c2cc7c4SAlexander Graf
1314c2cc7c4SAlexander Grafexception_exit:
132*faa7eb0fSJoseph Chen	add	sp, sp, #(8*8)/* see: sys registers size of struct pt_regs */
1334c2cc7c4SAlexander Graf	ldp	x2, x0, [sp],#16
1344c2cc7c4SAlexander Graf	switch_el x11, 3f, 2f, 1f
1354c2cc7c4SAlexander Graf3:	msr	elr_el3, x2
1364c2cc7c4SAlexander Graf	b	0f
1374c2cc7c4SAlexander Graf2:	msr	elr_el2, x2
1384c2cc7c4SAlexander Graf	b	0f
1394c2cc7c4SAlexander Graf1:	msr	elr_el1, x2
1404c2cc7c4SAlexander Graf0:
1414c2cc7c4SAlexander Graf	ldp	x1, x2, [sp],#16
1424c2cc7c4SAlexander Graf	ldp	x3, x4, [sp],#16
1434c2cc7c4SAlexander Graf	ldp	x5, x6, [sp],#16
1444c2cc7c4SAlexander Graf	ldp	x7, x8, [sp],#16
1454c2cc7c4SAlexander Graf	ldp	x9, x10, [sp],#16
1464c2cc7c4SAlexander Graf	ldp	x11, x12, [sp],#16
1474c2cc7c4SAlexander Graf	ldp	x13, x14, [sp],#16
1484c2cc7c4SAlexander Graf	ldp	x15, x16, [sp],#16
1494c2cc7c4SAlexander Graf	ldp	x17, x18, [sp],#16
1504c2cc7c4SAlexander Graf	ldp	x19, x20, [sp],#16
1514c2cc7c4SAlexander Graf	ldp	x21, x22, [sp],#16
1524c2cc7c4SAlexander Graf	ldp	x23, x24, [sp],#16
1534c2cc7c4SAlexander Graf	ldp	x25, x26, [sp],#16
1544c2cc7c4SAlexander Graf	ldp	x27, x28, [sp],#16
1554c2cc7c4SAlexander Graf	ldp	x29, x30, [sp],#16
1564c2cc7c4SAlexander Graf	eret
157