blob: 9bbb044adf37625dc1116852bd2c100ef6614eb8 [file] [log] [blame]
Varun Wadekarc1d2a282016-11-08 15:46:48 -08001/*
2 * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * Redistributions of source code must retain the above copyright notice, this
8 * list of conditions and the following disclaimer.
9 *
10 * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 *
14 * Neither the name of ARM nor the names of its contributors may be used
15 * to endorse or promote products derived from this software without specific
16 * prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#include <asm_macros.S>
32
33.macro push ra, rb, sp=sp
34 stp \ra, \rb, [\sp,#-16]!
35.endm
36
37.macro pop ra, rb, sp=sp
38 ldp \ra, \rb, [\sp], #16
39.endm
40
41 .global trusty_context_switch_helper
42func trusty_context_switch_helper
43 push x8, xzr
44 push x19, x20
45 push x21, x22
46 push x23, x24
47 push x25, x26
48 push x27, x28
49 push x29, x30
50
51 mov x9, sp
52 ldr x10, [x0]
53 mov sp, x10
54 str x9, [x0]
55
56 pop x29, x30
57 pop x27, x28
58 pop x25, x26
59 pop x23, x24
60 pop x21, x22
61 pop x19, x20
62 pop x8, xzr
63 stp x1, x2, [x8]
64 stp x3, x4, [x8, #16]
65
66 ret
67endfunc trusty_context_switch_helper
68
69 .global trusty_init_context_stack
70func trusty_init_context_stack
71 push x8, xzr, x1
72 push xzr, xzr, x1
73 push xzr, xzr, x1
74 push xzr, xzr, x1
75 push xzr, xzr, x1
76 push xzr, xzr, x1
77 adr x9, el3_exit
78 push xzr, x9, x1
79 str x1, [x0]
80 ret
81endfunc trusty_init_context_stack