blob: 4ac7a1aaf131fb37de2e0ea40ecfce133c1b4938 [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
Achin Gupta7c88f3f2014-02-18 18:09:12 +000034#include <platform.h>
Dan Handleyf3c8f322014-04-17 17:29:58 +010035#include <cassert.h>
Achin Gupta7c88f3f2014-02-18 18:09:12 +000036
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
Jeenu Viswambharandf1ddb52014-02-28 11:23:35 +000057/*
58 * Total number of function IDs implemented for services offered to NS clients.
59 * The function IDs are defined above
60 */
61#define TSP_NUM_FID 0x4
62
63/* TSP implementation version numbers */
64#define TSP_VERSION_MAJOR 0x0 /* Major version */
65#define TSP_VERSION_MINOR 0x1 /* Minor version */
66
67/*
68 * Standard Trusted OS Function IDs that fall under Trusted OS call range
69 * according to SMC calling convention
70 */
71#define TOS_CALL_COUNT 0xbf00ff00 /* Number of calls implemented */
72#define TOS_UID 0xbf00ff01 /* Implementation UID */
73/* 0xbf00ff02 is reserved */
74#define TOS_CALL_VERSION 0xbf00ff03 /* Trusted OS Call Version */
75
Achin Gupta7c88f3f2014-02-18 18:09:12 +000076/* Definitions to help the assembler access the SMC/ERET args structure */
77#define TSP_ARGS_SIZE 0x40
78#define TSP_ARG0 0x0
79#define TSP_ARG1 0x8
80#define TSP_ARG2 0x10
81#define TSP_ARG3 0x18
82#define TSP_ARG4 0x20
83#define TSP_ARG5 0x28
84#define TSP_ARG6 0x30
85#define TSP_ARG7 0x38
86#define TSP_ARGS_END 0x40
87
88#ifndef __ASSEMBLY__
89#include <stdint.h>
90
Dan Handleye2712bc2014-04-10 15:37:22 +010091typedef void (*tsp_generic_fptr_t)(uint64_t arg0,
Achin Gupta7c88f3f2014-02-18 18:09:12 +000092 uint64_t arg1,
93 uint64_t arg2,
94 uint64_t arg3,
95 uint64_t arg4,
96 uint64_t arg5,
97 uint64_t arg6,
98 uint64_t arg7);
99
Dan Handleye2712bc2014-04-10 15:37:22 +0100100typedef struct entry_info {
101 tsp_generic_fptr_t fast_smc_entry;
102 tsp_generic_fptr_t cpu_on_entry;
103 tsp_generic_fptr_t cpu_off_entry;
104 tsp_generic_fptr_t cpu_resume_entry;
105 tsp_generic_fptr_t cpu_suspend_entry;
106} entry_info_t;
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000107
Dan Handleye2712bc2014-04-10 15:37:22 +0100108typedef struct work_statistics {
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000109 uint32_t smc_count; /* Number of returns on this cpu */
110 uint32_t eret_count; /* Number of entries on this cpu */
111 uint32_t cpu_on_count; /* Number of cpu on requests */
112 uint32_t cpu_off_count; /* Number of cpu off requests */
113 uint32_t cpu_suspend_count; /* Number of cpu suspend requests */
114 uint32_t cpu_resume_count; /* Number of cpu resume requests */
Dan Handleye2712bc2014-04-10 15:37:22 +0100115} __aligned(CACHE_WRITEBACK_GRANULE) work_statistics_t;
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000116
Dan Handleye2712bc2014-04-10 15:37:22 +0100117typedef struct tsp_args {
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000118 uint64_t _regs[TSP_ARGS_END >> 3];
Dan Handleye2712bc2014-04-10 15:37:22 +0100119} __aligned(CACHE_WRITEBACK_GRANULE) tsp_args_t;
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000120
121/* Macros to access members of the above structure using their offsets */
122#define read_sp_arg(args, offset) ((args)->_regs[offset >> 3])
123#define write_sp_arg(args, offset, val)(((args)->_regs[offset >> 3]) \
124 = val)
125
126/*
127 * Ensure that the assembler's view of the size of the tsp_args is the
128 * same as the compilers
129 */
Dan Handleye2712bc2014-04-10 15:37:22 +0100130CASSERT(TSP_ARGS_SIZE == sizeof(tsp_args_t), assert_sp_args_size_mismatch);
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000131
132extern void tsp_get_magic(uint64_t args[4]);
133
134extern void tsp_fast_smc_entry(uint64_t arg0,
135 uint64_t arg1,
136 uint64_t arg2,
137 uint64_t arg3,
138 uint64_t arg4,
139 uint64_t arg5,
140 uint64_t arg6,
141 uint64_t arg7);
142extern void tsp_cpu_resume_entry(uint64_t arg0,
143 uint64_t arg1,
144 uint64_t arg2,
145 uint64_t arg3,
146 uint64_t arg4,
147 uint64_t arg5,
148 uint64_t arg6,
149 uint64_t arg7);
Dan Handleye2712bc2014-04-10 15:37:22 +0100150extern tsp_args_t *tsp_cpu_resume_main(uint64_t arg0,
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000151 uint64_t arg1,
152 uint64_t arg2,
153 uint64_t arg3,
154 uint64_t arg4,
155 uint64_t arg5,
156 uint64_t arg6,
157 uint64_t arg7);
158extern void tsp_cpu_suspend_entry(uint64_t arg0,
159 uint64_t arg1,
160 uint64_t arg2,
161 uint64_t arg3,
162 uint64_t arg4,
163 uint64_t arg5,
164 uint64_t arg6,
165 uint64_t arg7);
Dan Handleye2712bc2014-04-10 15:37:22 +0100166extern tsp_args_t *tsp_cpu_suspend_main(uint64_t arg0,
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000167 uint64_t arg1,
168 uint64_t arg2,
169 uint64_t arg3,
170 uint64_t arg4,
171 uint64_t arg5,
172 uint64_t arg6,
173 uint64_t arg7);
174extern void tsp_cpu_on_entry(uint64_t arg0,
175 uint64_t arg1,
176 uint64_t arg2,
177 uint64_t arg3,
178 uint64_t arg4,
179 uint64_t arg5,
180 uint64_t arg6,
181 uint64_t arg7);
Dan Handleye2712bc2014-04-10 15:37:22 +0100182extern tsp_args_t *tsp_cpu_on_main(void);
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000183extern void tsp_cpu_off_entry(uint64_t arg0,
184 uint64_t arg1,
185 uint64_t arg2,
186 uint64_t arg3,
187 uint64_t arg4,
188 uint64_t arg5,
189 uint64_t arg6,
190 uint64_t arg7);
Dan Handleye2712bc2014-04-10 15:37:22 +0100191extern tsp_args_t *tsp_cpu_off_main(uint64_t arg0,
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000192 uint64_t arg1,
193 uint64_t arg2,
194 uint64_t arg3,
195 uint64_t arg4,
196 uint64_t arg5,
197 uint64_t arg6,
198 uint64_t arg7);
199#endif /* __ASSEMBLY__ */
200
201#endif /* __BL2_H__ */