blob: e5bfcf37e54f48a7b88a510f1e3ca8afa86b75a1 [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001/*
Dan Handleye83b0ca2014-01-14 18:17:09 +00002 * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved.
Achin Gupta4f6ad662013-10-25 09:08:21 +01003 *
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#ifndef __RUNTIME_SVC_H__
32#define __RUNTIME_SVC_H__
33#include <psci.h>
Achin Gupta4a826dd2013-11-25 14:00:56 +000034#include <bl_common.h>
Achin Gupta4f6ad662013-10-25 09:08:21 +010035
36/*******************************************************************************
37 * Bit definitions inside the function id as per the SMC calling convention
38 ******************************************************************************/
39#define FUNCID_TYPE_SHIFT 31
40#define FUNCID_CC_SHIFT 30
41#define FUNCID_OWNER_SHIFT 24
42#define FUNCID_NUM_SHIFT 0
43
44#define FUNCID_TYPE_MASK 0x1
45#define FUNCID_CC_MASK 0x1
46#define FUNCID_OWNER_MASK 0x3f
47#define FUNCID_NUM_MASK 0xffff
48
49#define GET_SMC_CC(id) ((id >> FUNCID_CC_SHIFT) & \
50 FUNCID_CC_MASK)
51
52#define SMC_64 1
53#define SMC_32 0
54#define SMC_UNK 0xffffffff
55
56/*******************************************************************************
57 * Constants to indicate type of exception to the common exception handler.
58 ******************************************************************************/
59#define SYNC_EXCEPTION_SP_EL0 0x0
60#define IRQ_SP_EL0 0x1
61#define FIQ_SP_EL0 0x2
62#define SERROR_SP_EL0 0x3
63#define SYNC_EXCEPTION_SP_ELX 0x4
64#define IRQ_SP_ELX 0x5
65#define FIQ_SP_ELX 0x6
66#define SERROR_SP_ELX 0x7
67#define SYNC_EXCEPTION_AARCH64 0x8
68#define IRQ_AARCH64 0x9
69#define FIQ_AARCH64 0xa
70#define SERROR_AARCH64 0xb
71#define SYNC_EXCEPTION_AARCH32 0xc
72#define IRQ_AARCH32 0xd
73#define FIQ_AARCH32 0xe
74#define SERROR_AARCH32 0xf
75
Achin Gupta4a826dd2013-11-25 14:00:56 +000076/*******************************************************************************
77 * Constants that allow assembler code to access members of the 'gp_regs'
78 * structure at their correct offsets.
79 ******************************************************************************/
80#define SIZEOF_GPREGS 0x110
81#define GPREGS_X0_OFF 0x0
82#define GPREGS_X1_OFF 0x8
83#define GPREGS_X2_OFF 0x10
84#define GPREGS_X3_OFF 0x18
85#define GPREGS_X4_OFF 0x20
86#define GPREGS_X5_OFF 0x28
87#define GPREGS_X6_OFF 0x30
88#define GPREGS_X7_OFF 0x38
89#define GPREGS_X8_OFF 0x40
90#define GPREGS_X9_OFF 0x48
91#define GPREGS_X10_OFF 0x50
92#define GPREGS_X11_OFF 0x58
93#define GPREGS_X12_OFF 0x60
94#define GPREGS_X13_OFF 0x68
95#define GPREGS_X14_OFF 0x70
96#define GPREGS_X15_OFF 0x78
97#define GPREGS_X16_OFF 0x80
98#define GPREGS_X17_OFF 0x88
99#define GPREGS_X18_OFF 0x90
100#define GPREGS_X19_OFF 0x98
101#define GPREGS_X20_OFF 0xA0
102#define GPREGS_X21_OFF 0xA8
103#define GPREGS_X22_OFF 0xB0
104#define GPREGS_X23_OFF 0xB8
105#define GPREGS_X24_OFF 0xC0
106#define GPREGS_X25_OFF 0xC8
107#define GPREGS_X26_OFF 0xD0
108#define GPREGS_X27_OFF 0xD8
109#define GPREGS_X28_OFF 0xE0
110#define GPREGS_SP_EL0_OFF 0xE8
111#define GPREGS_SPSR_OFF 0xF0
112#define GPREGS_FP_OFF 0x100
113#define GPREGS_LR_OFF 0x108
114
Achin Gupta4f6ad662013-10-25 09:08:21 +0100115#ifndef __ASSEMBLY__
116
117typedef struct {
Sandrine Bailleuxbdb774d2013-12-17 13:47:14 +0000118 uint64_t x0;
119 uint64_t x1;
120 uint64_t x2;
121 uint64_t x3;
122 uint64_t x4;
123 uint64_t x5;
124 uint64_t x6;
125 uint64_t x7;
126 uint64_t x8;
127 uint64_t x9;
128 uint64_t x10;
129 uint64_t x11;
130 uint64_t x12;
131 uint64_t x13;
132 uint64_t x14;
133 uint64_t x15;
134 uint64_t x16;
135 uint64_t x17;
136 uint64_t x18;
137 uint64_t x19;
138 uint64_t x20;
139 uint64_t x21;
140 uint64_t x22;
141 uint64_t x23;
142 uint64_t x24;
143 uint64_t x25;
144 uint64_t x26;
145 uint64_t x27;
146 uint64_t x28;
147 uint64_t sp_el0;
148 uint32_t spsr;
Achin Gupta4a826dd2013-11-25 14:00:56 +0000149 /*
150 * Alignment constraint which allows save & restore of fp & lr on the
151 * stack during exception handling
152 */
Sandrine Bailleuxbdb774d2013-12-17 13:47:14 +0000153 uint64_t fp __attribute__((__aligned__(16)));
154 uint64_t lr;
Achin Gupta4a826dd2013-11-25 14:00:56 +0000155} __attribute__((__aligned__(16))) gp_regs;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100156
Achin Gupta4a826dd2013-11-25 14:00:56 +0000157/*******************************************************************************
158 * Compile time assertions to ensure that:
159 * 1) the assembler code's view of the size of the 'gp_regs' data structure is
160 * the same as the actual size of this data structure.
161 * 2) the assembler code's view of the offset of the frame pointer member of
162 * the 'gp_regs' structure is the same as the actual offset of this member.
163 ******************************************************************************/
164CASSERT((sizeof(gp_regs) == SIZEOF_GPREGS), assert_sizeof_gpregs_mismatch);
165CASSERT(GPREGS_FP_OFF == __builtin_offsetof(gp_regs, fp), \
166 assert_gpregs_fp_offset_mismatch);
Achin Gupta4f6ad662013-10-25 09:08:21 +0100167
168/*******************************************************************************
169 * Function & variable prototypes
170 ******************************************************************************/
171extern void runtime_svc_init(unsigned long mpidr);
172
173#endif /*__ASSEMBLY__*/
Achin Gupta4f6ad662013-10-25 09:08:21 +0100174#endif /* __RUNTIME_SVC_H__ */