blob: 7e459ac8366f7672847e35638761aa72b0a10808 [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
Anthony Zhou700ebe52015-10-31 06:03:41 +080063
64 ldr x2, [x1]
65 ldr x3, [x1, #0x08]
66 ldr x4, [x1, #0x10]
67 ldr x5, [x1, #0x18]
68 ldr x6, [x1, #0x20]
69 ldr x7, [x1, #0x28]
70 ldr x10, [x1, #0x30]
71 ldr x11, [x1, #0x38]
72
73 stp x2, x3, [x8]
74 stp x4, x5, [x8, #16]
75 stp x6, x7, [x8, #32]
76 stp x10, x11, [x8, #48]
Varun Wadekarc1d2a282016-11-08 15:46:48 -080077
78 ret
79endfunc trusty_context_switch_helper
80
81 .global trusty_init_context_stack
82func trusty_init_context_stack
83 push x8, xzr, x1
84 push xzr, xzr, x1
85 push xzr, xzr, x1
86 push xzr, xzr, x1
87 push xzr, xzr, x1
88 push xzr, xzr, x1
89 adr x9, el3_exit
90 push xzr, x9, x1
91 str x1, [x0]
92 ret
93endfunc trusty_init_context_stack