blob: b1f1a9417448bacf9f02776704bd3aa6493a3d02 [file] [log] [blame]
Furquan Shaikh2af76f42014-04-28 16:39:40 -07001/*
2 * This file is part of the libpayload project.
3 *
4 * Copyright 2014 Google Inc.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <arch/asm.h>
31
32 .text
33
34 .align 11
35 .global exception_table
36exception_table:
37 .align 7
38 bl exception_prologue
39 bl exception_sync_el0
40 .align 7
41 bl exception_prologue
42 bl exception_irq_el0
43 .align 7
44 bl exception_prologue
45 bl exception_fiq_el0
46 .align 7
47 bl exception_prologue
48 bl exception_serror_el0
49 .align 7
50 bl exception_prologue
51 bl exception_sync
52 .align 7
53 bl exception_prologue
54 bl exception_irq
55 .align 7
56 bl exception_prologue
57 bl exception_fiq
58 .align 7
59 bl exception_prologue
60 bl exception_serror
61
62/*
63 * Save state (register file + ELR) to stack
64 * and set arguments x0 and x1 for exception call
65 */
66ENTRY(exception_prologue)
67 stp x29, x30, [sp, #-16]!
68 stp x27, x28, [sp, #-16]!
69 stp x25, x26, [sp, #-16]!
70 stp x23, x24, [sp, #-16]!
71 stp x21, x22, [sp, #-16]!
72 stp x19, x20, [sp, #-16]!
73 stp x17, x18, [sp, #-16]!
74 stp x15, x16, [sp, #-16]!
75 stp x13, x14, [sp, #-16]!
76 stp x11, x12, [sp, #-16]!
77 stp x9, x10, [sp, #-16]!
78 stp x7, x8, [sp, #-16]!
79 stp x5, x6, [sp, #-16]!
80 stp x3, x4, [sp, #-16]!
81 stp x1, x2, [sp, #-16]!
82
83 /* FIXME: Don't assume always running in EL2 */
84 mrs x1, elr_el2
85 stp x1, x0, [sp, #-16]!
86
87 mrs x1, esr_el2
88 mov x0, sp
89
90 ret
91ENDPROC(exception_prologue)
92
93 .global exception_stack_end
94exception_stack_end:
95 .quad 0
96
97exception_handler:
98 .word 0
99
100 .global set_vbar
101set_vbar:
102 msr vbar_el2, x0
103 ret