blob: 4f4f526f9320ef348317f9f543456a8db08da3ac [file] [log] [blame]
David Feng85fd5f12013-12-14 11:47:35 +08001/*
2 * (C) Copyright 2013
3 * David Feng <fenghua@phytium.com.cn>
4 *
5 * SPDX-License-Identifier: GPL-2.0+
6 */
7
8#include <asm-offsets.h>
9#include <config.h>
David Feng85fd5f12013-12-14 11:47:35 +080010#include <asm/ptrace.h>
11#include <asm/macro.h>
12#include <linux/linkage.h>
13
14/*
15 * Enter Exception.
16 * This will save the processor state that is ELR/X0~X30
17 * to the stack frame.
18 */
19.macro exception_entry
20 stp x29, x30, [sp, #-16]!
21 stp x27, x28, [sp, #-16]!
22 stp x25, x26, [sp, #-16]!
23 stp x23, x24, [sp, #-16]!
24 stp x21, x22, [sp, #-16]!
25 stp x19, x20, [sp, #-16]!
26 stp x17, x18, [sp, #-16]!
27 stp x15, x16, [sp, #-16]!
28 stp x13, x14, [sp, #-16]!
29 stp x11, x12, [sp, #-16]!
30 stp x9, x10, [sp, #-16]!
31 stp x7, x8, [sp, #-16]!
32 stp x5, x6, [sp, #-16]!
33 stp x3, x4, [sp, #-16]!
34 stp x1, x2, [sp, #-16]!
35
36 /* Could be running at EL3/EL2/EL1 */
37 switch_el x11, 3f, 2f, 1f
383: mrs x1, esr_el3
39 mrs x2, elr_el3
40 b 0f
412: mrs x1, esr_el2
42 mrs x2, elr_el2
43 b 0f
441: mrs x1, esr_el1
45 mrs x2, elr_el1
460:
47 stp x2, x0, [sp, #-16]!
48 mov x0, sp
49.endm
50
51/*
52 * Exception vectors.
53 */
54 .align 11
55 .globl vectors
56vectors:
57 .align 7
58 b _do_bad_sync /* Current EL Synchronous Thread */
59
60 .align 7
61 b _do_bad_irq /* Current EL IRQ Thread */
62
63 .align 7
64 b _do_bad_fiq /* Current EL FIQ Thread */
65
66 .align 7
67 b _do_bad_error /* Current EL Error Thread */
68
69 .align 7
70 b _do_sync /* Current EL Synchronous Handler */
71
72 .align 7
73 b _do_irq /* Current EL IRQ Handler */
74
75 .align 7
76 b _do_fiq /* Current EL FIQ Handler */
77
78 .align 7
79 b _do_error /* Current EL Error Handler */
80
81
82_do_bad_sync:
83 exception_entry
84 bl do_bad_sync
Alexander Graf99adbd92016-03-04 01:10:05 +010085 b exception_exit
David Feng85fd5f12013-12-14 11:47:35 +080086
87_do_bad_irq:
88 exception_entry
89 bl do_bad_irq
Alexander Graf99adbd92016-03-04 01:10:05 +010090 b exception_exit
David Feng85fd5f12013-12-14 11:47:35 +080091
92_do_bad_fiq:
93 exception_entry
94 bl do_bad_fiq
Alexander Graf99adbd92016-03-04 01:10:05 +010095 b exception_exit
David Feng85fd5f12013-12-14 11:47:35 +080096
97_do_bad_error:
98 exception_entry
99 bl do_bad_error
Alexander Graf99adbd92016-03-04 01:10:05 +0100100 b exception_exit
David Feng85fd5f12013-12-14 11:47:35 +0800101
102_do_sync:
103 exception_entry
104 bl do_sync
Alexander Graf99adbd92016-03-04 01:10:05 +0100105 b exception_exit
David Feng85fd5f12013-12-14 11:47:35 +0800106
107_do_irq:
108 exception_entry
109 bl do_irq
Alexander Graf99adbd92016-03-04 01:10:05 +0100110 b exception_exit
David Feng85fd5f12013-12-14 11:47:35 +0800111
112_do_fiq:
113 exception_entry
114 bl do_fiq
Alexander Graf99adbd92016-03-04 01:10:05 +0100115 b exception_exit
David Feng85fd5f12013-12-14 11:47:35 +0800116
117_do_error:
118 exception_entry
119 bl do_error
Alexander Graf99adbd92016-03-04 01:10:05 +0100120 b exception_exit
121
122exception_exit:
123 ldp x2, x0, [sp],#16
124 switch_el x11, 3f, 2f, 1f
1253: msr elr_el3, x2
126 b 0f
1272: msr elr_el2, x2
128 b 0f
1291: msr elr_el1, x2
1300:
131 ldp x1, x2, [sp],#16
132 ldp x3, x4, [sp],#16
133 ldp x5, x6, [sp],#16
134 ldp x7, x8, [sp],#16
135 ldp x9, x10, [sp],#16
136 ldp x11, x12, [sp],#16
137 ldp x13, x14, [sp],#16
138 ldp x15, x16, [sp],#16
139 ldp x17, x18, [sp],#16
140 ldp x19, x20, [sp],#16
141 ldp x21, x22, [sp],#16
142 ldp x23, x24, [sp],#16
143 ldp x25, x26, [sp],#16
144 ldp x27, x28, [sp],#16
145 ldp x29, x30, [sp],#16
146 eret