blob: 69dda05955929830ad973df10908bcd8a30ad8c2 [file] [log] [blame]
Achin Gupta7c88f3f2014-02-18 18:09:12 +00001/*
2 * Copyright (c) 2013-2014, 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#ifndef __TSP_H__
32#define __TSP_H__
33
34#include <bl_common.h>
35#include <platform.h>
36
37/*
38 * SMC function IDs that TSP uses to signal various forms of completions
39 * to the secure payload dispatcher.
40 */
41#define TSP_ENTRY_DONE 0xf2000000
42#define TSP_ON_DONE 0xf2000001
43#define TSP_OFF_DONE 0xf2000002
44#define TSP_SUSPEND_DONE 0xf2000003
45#define TSP_RESUME_DONE 0xf2000004
46#define TSP_WORK_DONE 0xf2000005
47
48/* SMC function ID that TSP uses to request service from secure montior */
49#define TSP_GET_ARGS 0xf2001000
50
51/* Function IDs for various TSP services */
52#define TSP_FID_ADD 0xf2002000
53#define TSP_FID_SUB 0xf2002001
54#define TSP_FID_MUL 0xf2002002
55#define TSP_FID_DIV 0xf2002003
56
57/* Definitions to help the assembler access the SMC/ERET args structure */
58#define TSP_ARGS_SIZE 0x40
59#define TSP_ARG0 0x0
60#define TSP_ARG1 0x8
61#define TSP_ARG2 0x10
62#define TSP_ARG3 0x18
63#define TSP_ARG4 0x20
64#define TSP_ARG5 0x28
65#define TSP_ARG6 0x30
66#define TSP_ARG7 0x38
67#define TSP_ARGS_END 0x40
68
69#ifndef __ASSEMBLY__
70#include <stdint.h>
71
72typedef void (*tsp_generic_fptr)(uint64_t arg0,
73 uint64_t arg1,
74 uint64_t arg2,
75 uint64_t arg3,
76 uint64_t arg4,
77 uint64_t arg5,
78 uint64_t arg6,
79 uint64_t arg7);
80
81typedef struct {
82 tsp_generic_fptr fast_smc_entry;
83 tsp_generic_fptr cpu_on_entry;
84 tsp_generic_fptr cpu_off_entry;
85 tsp_generic_fptr cpu_resume_entry;
86 tsp_generic_fptr cpu_suspend_entry;
87} entry_info;
88
89typedef struct {
90 uint32_t smc_count; /* Number of returns on this cpu */
91 uint32_t eret_count; /* Number of entries on this cpu */
92 uint32_t cpu_on_count; /* Number of cpu on requests */
93 uint32_t cpu_off_count; /* Number of cpu off requests */
94 uint32_t cpu_suspend_count; /* Number of cpu suspend requests */
95 uint32_t cpu_resume_count; /* Number of cpu resume requests */
96} __aligned(CACHE_WRITEBACK_GRANULE) work_statistics;
97
98typedef struct {
99 uint64_t _regs[TSP_ARGS_END >> 3];
100} __aligned(CACHE_WRITEBACK_GRANULE) tsp_args;
101
102/* Macros to access members of the above structure using their offsets */
103#define read_sp_arg(args, offset) ((args)->_regs[offset >> 3])
104#define write_sp_arg(args, offset, val)(((args)->_regs[offset >> 3]) \
105 = val)
106
107/*
108 * Ensure that the assembler's view of the size of the tsp_args is the
109 * same as the compilers
110 */
111CASSERT(TSP_ARGS_SIZE == sizeof(tsp_args), assert_sp_args_size_mismatch);
112
113extern void tsp_get_magic(uint64_t args[4]);
114
115extern void tsp_fast_smc_entry(uint64_t arg0,
116 uint64_t arg1,
117 uint64_t arg2,
118 uint64_t arg3,
119 uint64_t arg4,
120 uint64_t arg5,
121 uint64_t arg6,
122 uint64_t arg7);
123extern void tsp_cpu_resume_entry(uint64_t arg0,
124 uint64_t arg1,
125 uint64_t arg2,
126 uint64_t arg3,
127 uint64_t arg4,
128 uint64_t arg5,
129 uint64_t arg6,
130 uint64_t arg7);
131extern tsp_args *tsp_cpu_resume_main(uint64_t arg0,
132 uint64_t arg1,
133 uint64_t arg2,
134 uint64_t arg3,
135 uint64_t arg4,
136 uint64_t arg5,
137 uint64_t arg6,
138 uint64_t arg7);
139extern void tsp_cpu_suspend_entry(uint64_t arg0,
140 uint64_t arg1,
141 uint64_t arg2,
142 uint64_t arg3,
143 uint64_t arg4,
144 uint64_t arg5,
145 uint64_t arg6,
146 uint64_t arg7);
147extern tsp_args *tsp_cpu_suspend_main(uint64_t arg0,
148 uint64_t arg1,
149 uint64_t arg2,
150 uint64_t arg3,
151 uint64_t arg4,
152 uint64_t arg5,
153 uint64_t arg6,
154 uint64_t arg7);
155extern void tsp_cpu_on_entry(uint64_t arg0,
156 uint64_t arg1,
157 uint64_t arg2,
158 uint64_t arg3,
159 uint64_t arg4,
160 uint64_t arg5,
161 uint64_t arg6,
162 uint64_t arg7);
163extern tsp_args *tsp_cpu_on_main(void);
164extern void tsp_cpu_off_entry(uint64_t arg0,
165 uint64_t arg1,
166 uint64_t arg2,
167 uint64_t arg3,
168 uint64_t arg4,
169 uint64_t arg5,
170 uint64_t arg6,
171 uint64_t arg7);
172extern tsp_args *tsp_cpu_off_main(uint64_t arg0,
173 uint64_t arg1,
174 uint64_t arg2,
175 uint64_t arg3,
176 uint64_t arg4,
177 uint64_t arg5,
178 uint64_t arg6,
179 uint64_t arg7);
180#endif /* __ASSEMBLY__ */
181
182#endif /* __BL2_H__ */