blob: 407ed47881fc49dee9d46e0f4fc01eb7d19c70aa [file] [log] [blame]
Achin Gupta7c88f3f2014-02-18 18:09:12 +00001/*
Paul Beesley1fbc97b2019-01-11 18:26:51 +00002 * Copyright (c) 2013-2019, ARM Limited and Contributors. All rights reserved.
Achin Gupta7c88f3f2014-02-18 18:09:12 +00003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Achin Gupta7c88f3f2014-02-18 18:09:12 +00005 */
6
Dan Handleyed6ff952014-05-14 17:44:19 +01007#include <platform_def.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00008
9#include <arch_helpers.h>
10#include <bl32/tsp/tsp.h>
11#include <common/bl_common.h>
12#include <common/debug.h>
13#include <lib/spinlock.h>
14#include <plat/common/platform.h>
Dan Handley4fd2f5c2014-08-04 11:41:20 +010015#include <platform_tsp.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000016
Dan Handleye2c27f52014-08-01 17:58:27 +010017#include "tsp_private.h"
Achin Gupta7c88f3f2014-02-18 18:09:12 +000018
Vikram Kanigirid8c9d262014-05-16 18:48:12 +010019
20/*******************************************************************************
Achin Gupta7c88f3f2014-02-18 18:09:12 +000021 * Lock to control access to the console
22 ******************************************************************************/
23spinlock_t console_lock;
24
25/*******************************************************************************
26 * Per cpu data structure to populate parameters for an SMC in C code and use
27 * a pointer to this structure in assembler code to populate x0-x7
28 ******************************************************************************/
Dan Handleye2712bc2014-04-10 15:37:22 +010029static tsp_args_t tsp_smc_args[PLATFORM_CORE_COUNT];
Achin Gupta7c88f3f2014-02-18 18:09:12 +000030
31/*******************************************************************************
32 * Per cpu data structure to keep track of TSP activity
33 ******************************************************************************/
Achin Gupta76717892014-05-09 11:42:56 +010034work_statistics_t tsp_stats[PLATFORM_CORE_COUNT];
Achin Gupta7c88f3f2014-02-18 18:09:12 +000035
36/*******************************************************************************
Sandrine Bailleuxbdba5e52016-06-16 14:24:26 +010037 * The TSP memory footprint starts at address BL32_BASE and ends with the
38 * linker symbol __BL32_END__. Use these addresses to compute the TSP image
39 * size.
Vikram Kanigirid8c9d262014-05-16 18:48:12 +010040 ******************************************************************************/
Antonio Nino Diazde97ff32019-01-25 13:28:38 +000041#define BL32_TOTAL_LIMIT BL32_END
Sandrine Bailleuxbdba5e52016-06-16 14:24:26 +010042#define BL32_TOTAL_SIZE (BL32_TOTAL_LIMIT - (unsigned long) BL32_BASE)
Vikram Kanigirid8c9d262014-05-16 18:48:12 +010043
Dan Handleye2712bc2014-04-10 15:37:22 +010044static tsp_args_t *set_smc_args(uint64_t arg0,
Achin Gupta7c88f3f2014-02-18 18:09:12 +000045 uint64_t arg1,
46 uint64_t arg2,
47 uint64_t arg3,
48 uint64_t arg4,
49 uint64_t arg5,
50 uint64_t arg6,
51 uint64_t arg7)
52{
Achin Gupta7c88f3f2014-02-18 18:09:12 +000053 uint32_t linear_id;
Dan Handleye2712bc2014-04-10 15:37:22 +010054 tsp_args_t *pcpu_smc_args;
Achin Gupta7c88f3f2014-02-18 18:09:12 +000055
56 /*
57 * Return to Secure Monitor by raising an SMC. The results of the
58 * service are passed as an arguments to the SMC
59 */
Soby Mathewda43b662015-07-08 21:45:46 +010060 linear_id = plat_my_core_pos();
Achin Gupta7c88f3f2014-02-18 18:09:12 +000061 pcpu_smc_args = &tsp_smc_args[linear_id];
62 write_sp_arg(pcpu_smc_args, TSP_ARG0, arg0);
63 write_sp_arg(pcpu_smc_args, TSP_ARG1, arg1);
64 write_sp_arg(pcpu_smc_args, TSP_ARG2, arg2);
65 write_sp_arg(pcpu_smc_args, TSP_ARG3, arg3);
66 write_sp_arg(pcpu_smc_args, TSP_ARG4, arg4);
67 write_sp_arg(pcpu_smc_args, TSP_ARG5, arg5);
68 write_sp_arg(pcpu_smc_args, TSP_ARG6, arg6);
69 write_sp_arg(pcpu_smc_args, TSP_ARG7, arg7);
70
71 return pcpu_smc_args;
72}
73
74/*******************************************************************************
75 * TSP main entry point where it gets the opportunity to initialize its secure
76 * state/applications. Once the state is initialized, it must return to the
Andrew Thoelke891c4ca2014-05-20 21:43:27 +010077 * SPD with a pointer to the 'tsp_vector_table' jump table.
Achin Gupta7c88f3f2014-02-18 18:09:12 +000078 ******************************************************************************/
79uint64_t tsp_main(void)
80{
Dan Handley91b624e2014-07-29 17:14:00 +010081 NOTICE("TSP: %s\n", version_string);
82 NOTICE("TSP: %s\n", build_message);
Sandrine Bailleuxbdba5e52016-06-16 14:24:26 +010083 INFO("TSP: Total memory base : 0x%lx\n", (unsigned long) BL32_BASE);
84 INFO("TSP: Total memory size : 0x%lx bytes\n", BL32_TOTAL_SIZE);
Dan Handley91b624e2014-07-29 17:14:00 +010085
Soby Mathewda43b662015-07-08 21:45:46 +010086 uint32_t linear_id = plat_my_core_pos();
Achin Gupta7c88f3f2014-02-18 18:09:12 +000087
Achin Gupta7c88f3f2014-02-18 18:09:12 +000088 /* Initialize the platform */
Dan Handley4fd2f5c2014-08-04 11:41:20 +010089 tsp_platform_setup();
Achin Gupta7c88f3f2014-02-18 18:09:12 +000090
91 /* Initialize secure/applications state here */
Achin Guptabbc33f22014-05-09 13:33:42 +010092 tsp_generic_timer_start();
Achin Gupta7c88f3f2014-02-18 18:09:12 +000093
94 /* Update this cpu's statistics */
95 tsp_stats[linear_id].smc_count++;
96 tsp_stats[linear_id].eret_count++;
97 tsp_stats[linear_id].cpu_on_count++;
98
Dan Handley91b624e2014-07-29 17:14:00 +010099#if LOG_LEVEL >= LOG_LEVEL_INFO
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000100 spin_lock(&console_lock);
Soby Mathewda43b662015-07-08 21:45:46 +0100101 INFO("TSP: cpu 0x%lx: %d smcs, %d erets %d cpu on requests\n",
102 read_mpidr(),
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000103 tsp_stats[linear_id].smc_count,
104 tsp_stats[linear_id].eret_count,
105 tsp_stats[linear_id].cpu_on_count);
106 spin_unlock(&console_lock);
Dan Handley91b624e2014-07-29 17:14:00 +0100107#endif
Andrew Thoelke891c4ca2014-05-20 21:43:27 +0100108 return (uint64_t) &tsp_vector_table;
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000109}
110
111/*******************************************************************************
112 * This function performs any remaining book keeping in the test secure payload
113 * after this cpu's architectural state has been setup in response to an earlier
114 * psci cpu_on request.
115 ******************************************************************************/
Dan Handleye2712bc2014-04-10 15:37:22 +0100116tsp_args_t *tsp_cpu_on_main(void)
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000117{
Soby Mathewda43b662015-07-08 21:45:46 +0100118 uint32_t linear_id = plat_my_core_pos();
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000119
Achin Guptabbc33f22014-05-09 13:33:42 +0100120 /* Initialize secure/applications state here */
121 tsp_generic_timer_start();
122
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000123 /* Update this cpu's statistics */
124 tsp_stats[linear_id].smc_count++;
125 tsp_stats[linear_id].eret_count++;
126 tsp_stats[linear_id].cpu_on_count++;
127
Dan Handley91b624e2014-07-29 17:14:00 +0100128#if LOG_LEVEL >= LOG_LEVEL_INFO
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000129 spin_lock(&console_lock);
Soby Mathewda43b662015-07-08 21:45:46 +0100130 INFO("TSP: cpu 0x%lx turned on\n", read_mpidr());
131 INFO("TSP: cpu 0x%lx: %d smcs, %d erets %d cpu on requests\n",
132 read_mpidr(),
Dan Handley91b624e2014-07-29 17:14:00 +0100133 tsp_stats[linear_id].smc_count,
134 tsp_stats[linear_id].eret_count,
135 tsp_stats[linear_id].cpu_on_count);
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000136 spin_unlock(&console_lock);
Dan Handley91b624e2014-07-29 17:14:00 +0100137#endif
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000138 /* Indicate to the SPD that we have completed turned ourselves on */
139 return set_smc_args(TSP_ON_DONE, 0, 0, 0, 0, 0, 0, 0);
140}
141
142/*******************************************************************************
143 * This function performs any remaining book keeping in the test secure payload
144 * before this cpu is turned off in response to a psci cpu_off request.
145 ******************************************************************************/
Dan Handleye2712bc2014-04-10 15:37:22 +0100146tsp_args_t *tsp_cpu_off_main(uint64_t arg0,
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000147 uint64_t arg1,
148 uint64_t arg2,
149 uint64_t arg3,
150 uint64_t arg4,
151 uint64_t arg5,
152 uint64_t arg6,
153 uint64_t arg7)
154{
Soby Mathewda43b662015-07-08 21:45:46 +0100155 uint32_t linear_id = plat_my_core_pos();
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000156
Achin Guptabbc33f22014-05-09 13:33:42 +0100157 /*
158 * This cpu is being turned off, so disable the timer to prevent the
159 * secure timer interrupt from interfering with power down. A pending
160 * interrupt will be lost but we do not care as we are turning off.
161 */
162 tsp_generic_timer_stop();
163
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000164 /* Update this cpu's statistics */
165 tsp_stats[linear_id].smc_count++;
166 tsp_stats[linear_id].eret_count++;
167 tsp_stats[linear_id].cpu_off_count++;
168
Dan Handley91b624e2014-07-29 17:14:00 +0100169#if LOG_LEVEL >= LOG_LEVEL_INFO
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000170 spin_lock(&console_lock);
Soby Mathewda43b662015-07-08 21:45:46 +0100171 INFO("TSP: cpu 0x%lx off request\n", read_mpidr());
172 INFO("TSP: cpu 0x%lx: %d smcs, %d erets %d cpu off requests\n",
173 read_mpidr(),
Dan Handley91b624e2014-07-29 17:14:00 +0100174 tsp_stats[linear_id].smc_count,
175 tsp_stats[linear_id].eret_count,
176 tsp_stats[linear_id].cpu_off_count);
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000177 spin_unlock(&console_lock);
Dan Handley91b624e2014-07-29 17:14:00 +0100178#endif
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000179
Achin Gupta607084e2014-02-09 18:24:19 +0000180 /* Indicate to the SPD that we have completed this request */
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000181 return set_smc_args(TSP_OFF_DONE, 0, 0, 0, 0, 0, 0, 0);
182}
183
184/*******************************************************************************
185 * This function performs any book keeping in the test secure payload before
186 * this cpu's architectural state is saved in response to an earlier psci
187 * cpu_suspend request.
188 ******************************************************************************/
Soby Mathewf5121572014-09-30 11:19:51 +0100189tsp_args_t *tsp_cpu_suspend_main(uint64_t arg0,
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000190 uint64_t arg1,
191 uint64_t arg2,
192 uint64_t arg3,
193 uint64_t arg4,
194 uint64_t arg5,
195 uint64_t arg6,
196 uint64_t arg7)
197{
Soby Mathewda43b662015-07-08 21:45:46 +0100198 uint32_t linear_id = plat_my_core_pos();
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000199
Achin Guptabbc33f22014-05-09 13:33:42 +0100200 /*
201 * Save the time context and disable it to prevent the secure timer
202 * interrupt from interfering with wakeup from the suspend state.
203 */
204 tsp_generic_timer_save();
205 tsp_generic_timer_stop();
206
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000207 /* Update this cpu's statistics */
208 tsp_stats[linear_id].smc_count++;
209 tsp_stats[linear_id].eret_count++;
210 tsp_stats[linear_id].cpu_suspend_count++;
211
Dan Handley91b624e2014-07-29 17:14:00 +0100212#if LOG_LEVEL >= LOG_LEVEL_INFO
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000213 spin_lock(&console_lock);
Sandrine Bailleux8723adf2015-02-05 15:42:31 +0000214 INFO("TSP: cpu 0x%lx: %d smcs, %d erets %d cpu suspend requests\n",
Soby Mathewda43b662015-07-08 21:45:46 +0100215 read_mpidr(),
Dan Handley91b624e2014-07-29 17:14:00 +0100216 tsp_stats[linear_id].smc_count,
217 tsp_stats[linear_id].eret_count,
218 tsp_stats[linear_id].cpu_suspend_count);
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000219 spin_unlock(&console_lock);
Dan Handley91b624e2014-07-29 17:14:00 +0100220#endif
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000221
Achin Gupta607084e2014-02-09 18:24:19 +0000222 /* Indicate to the SPD that we have completed this request */
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000223 return set_smc_args(TSP_SUSPEND_DONE, 0, 0, 0, 0, 0, 0, 0);
224}
225
226/*******************************************************************************
227 * This function performs any book keeping in the test secure payload after this
228 * cpu's architectural state has been restored after wakeup from an earlier psci
229 * cpu_suspend request.
230 ******************************************************************************/
Achin Gupta9a0ff9b2015-09-07 20:43:27 +0100231tsp_args_t *tsp_cpu_resume_main(uint64_t max_off_pwrlvl,
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000232 uint64_t arg1,
233 uint64_t arg2,
234 uint64_t arg3,
235 uint64_t arg4,
236 uint64_t arg5,
237 uint64_t arg6,
238 uint64_t arg7)
239{
Soby Mathewda43b662015-07-08 21:45:46 +0100240 uint32_t linear_id = plat_my_core_pos();
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000241
Achin Guptabbc33f22014-05-09 13:33:42 +0100242 /* Restore the generic timer context */
243 tsp_generic_timer_restore();
244
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000245 /* Update this cpu's statistics */
246 tsp_stats[linear_id].smc_count++;
247 tsp_stats[linear_id].eret_count++;
248 tsp_stats[linear_id].cpu_resume_count++;
249
Dan Handley91b624e2014-07-29 17:14:00 +0100250#if LOG_LEVEL >= LOG_LEVEL_INFO
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000251 spin_lock(&console_lock);
Masahiro Yamadae93a0f42018-02-02 15:09:36 +0900252 INFO("TSP: cpu 0x%lx resumed. maximum off power level %lld\n",
Achin Gupta9a0ff9b2015-09-07 20:43:27 +0100253 read_mpidr(), max_off_pwrlvl);
Sandrine Bailleux8723adf2015-02-05 15:42:31 +0000254 INFO("TSP: cpu 0x%lx: %d smcs, %d erets %d cpu suspend requests\n",
Soby Mathewda43b662015-07-08 21:45:46 +0100255 read_mpidr(),
Dan Handley91b624e2014-07-29 17:14:00 +0100256 tsp_stats[linear_id].smc_count,
257 tsp_stats[linear_id].eret_count,
258 tsp_stats[linear_id].cpu_suspend_count);
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000259 spin_unlock(&console_lock);
Dan Handley91b624e2014-07-29 17:14:00 +0100260#endif
Achin Gupta607084e2014-02-09 18:24:19 +0000261 /* Indicate to the SPD that we have completed this request */
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000262 return set_smc_args(TSP_RESUME_DONE, 0, 0, 0, 0, 0, 0, 0);
263}
264
265/*******************************************************************************
Juan Castillo4dc4a472014-08-12 11:17:06 +0100266 * This function performs any remaining bookkeeping in the test secure payload
267 * before the system is switched off (in response to a psci SYSTEM_OFF request)
268 ******************************************************************************/
269tsp_args_t *tsp_system_off_main(uint64_t arg0,
270 uint64_t arg1,
271 uint64_t arg2,
272 uint64_t arg3,
273 uint64_t arg4,
274 uint64_t arg5,
275 uint64_t arg6,
276 uint64_t arg7)
277{
Soby Mathewda43b662015-07-08 21:45:46 +0100278 uint32_t linear_id = plat_my_core_pos();
Juan Castillo4dc4a472014-08-12 11:17:06 +0100279
280 /* Update this cpu's statistics */
281 tsp_stats[linear_id].smc_count++;
282 tsp_stats[linear_id].eret_count++;
283
284#if LOG_LEVEL >= LOG_LEVEL_INFO
285 spin_lock(&console_lock);
Soby Mathewda43b662015-07-08 21:45:46 +0100286 INFO("TSP: cpu 0x%lx SYSTEM_OFF request\n", read_mpidr());
287 INFO("TSP: cpu 0x%lx: %d smcs, %d erets requests\n", read_mpidr(),
Juan Castillo4dc4a472014-08-12 11:17:06 +0100288 tsp_stats[linear_id].smc_count,
289 tsp_stats[linear_id].eret_count);
290 spin_unlock(&console_lock);
291#endif
292
293 /* Indicate to the SPD that we have completed this request */
294 return set_smc_args(TSP_SYSTEM_OFF_DONE, 0, 0, 0, 0, 0, 0, 0);
295}
296
297/*******************************************************************************
298 * This function performs any remaining bookkeeping in the test secure payload
299 * before the system is reset (in response to a psci SYSTEM_RESET request)
300 ******************************************************************************/
301tsp_args_t *tsp_system_reset_main(uint64_t arg0,
302 uint64_t arg1,
303 uint64_t arg2,
304 uint64_t arg3,
305 uint64_t arg4,
306 uint64_t arg5,
307 uint64_t arg6,
308 uint64_t arg7)
309{
Soby Mathewda43b662015-07-08 21:45:46 +0100310 uint32_t linear_id = plat_my_core_pos();
Juan Castillo4dc4a472014-08-12 11:17:06 +0100311
312 /* Update this cpu's statistics */
313 tsp_stats[linear_id].smc_count++;
314 tsp_stats[linear_id].eret_count++;
315
316#if LOG_LEVEL >= LOG_LEVEL_INFO
317 spin_lock(&console_lock);
Soby Mathewda43b662015-07-08 21:45:46 +0100318 INFO("TSP: cpu 0x%lx SYSTEM_RESET request\n", read_mpidr());
319 INFO("TSP: cpu 0x%lx: %d smcs, %d erets requests\n", read_mpidr(),
Juan Castillo4dc4a472014-08-12 11:17:06 +0100320 tsp_stats[linear_id].smc_count,
321 tsp_stats[linear_id].eret_count);
322 spin_unlock(&console_lock);
323#endif
324
325 /* Indicate to the SPD that we have completed this request */
326 return set_smc_args(TSP_SYSTEM_RESET_DONE, 0, 0, 0, 0, 0, 0, 0);
327}
328
329/*******************************************************************************
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000330 * TSP fast smc handler. The secure monitor jumps to this function by
331 * doing the ERET after populating X0-X7 registers. The arguments are received
332 * in the function arguments in order. Once the service is rendered, this
Soby Mathew9f71f702014-05-09 20:49:17 +0100333 * function returns to Secure Monitor by raising SMC.
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000334 ******************************************************************************/
Soby Mathew9f71f702014-05-09 20:49:17 +0100335tsp_args_t *tsp_smc_handler(uint64_t func,
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000336 uint64_t arg1,
337 uint64_t arg2,
338 uint64_t arg3,
339 uint64_t arg4,
340 uint64_t arg5,
341 uint64_t arg6,
342 uint64_t arg7)
343{
Achin Gupta916a2c12014-02-09 23:11:46 +0000344 uint64_t results[2];
345 uint64_t service_args[2];
Soby Mathewda43b662015-07-08 21:45:46 +0100346 uint32_t linear_id = plat_my_core_pos();
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000347
Achin Gupta916a2c12014-02-09 23:11:46 +0000348 /* Update this cpu's statistics */
349 tsp_stats[linear_id].smc_count++;
350 tsp_stats[linear_id].eret_count++;
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000351
Masahiro Yamadae93a0f42018-02-02 15:09:36 +0900352 INFO("TSP: cpu 0x%lx received %s smc 0x%llx\n", read_mpidr(),
David Cunado28f69ab2017-04-05 11:34:03 +0100353 ((func >> 31) & 1) == 1 ? "fast" : "yielding",
Dan Handley91b624e2014-07-29 17:14:00 +0100354 func);
Soby Mathewda43b662015-07-08 21:45:46 +0100355 INFO("TSP: cpu 0x%lx: %d smcs, %d erets\n", read_mpidr(),
Dan Handley91b624e2014-07-29 17:14:00 +0100356 tsp_stats[linear_id].smc_count,
357 tsp_stats[linear_id].eret_count);
Achin Gupta916a2c12014-02-09 23:11:46 +0000358
359 /* Render secure services and obtain results here */
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000360 results[0] = arg1;
361 results[1] = arg2;
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000362
363 /*
364 * Request a service back from dispatcher/secure monitor. This call
Paul Beesley1fbc97b2019-01-11 18:26:51 +0000365 * return and thereafter resume execution
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000366 */
367 tsp_get_magic(service_args);
368
369 /* Determine the function to perform based on the function ID */
Soby Mathew9f71f702014-05-09 20:49:17 +0100370 switch (TSP_BARE_FID(func)) {
371 case TSP_ADD:
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000372 results[0] += service_args[0];
373 results[1] += service_args[1];
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000374 break;
Soby Mathew9f71f702014-05-09 20:49:17 +0100375 case TSP_SUB:
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000376 results[0] -= service_args[0];
377 results[1] -= service_args[1];
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000378 break;
Soby Mathew9f71f702014-05-09 20:49:17 +0100379 case TSP_MUL:
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000380 results[0] *= service_args[0];
381 results[1] *= service_args[1];
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000382 break;
Soby Mathew9f71f702014-05-09 20:49:17 +0100383 case TSP_DIV:
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000384 results[0] /= service_args[0] ? service_args[0] : 1;
385 results[1] /= service_args[1] ? service_args[1] : 1;
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000386 break;
387 default:
388 break;
389 }
390
Soby Mathew9f71f702014-05-09 20:49:17 +0100391 return set_smc_args(func, 0,
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000392 results[0],
393 results[1],
Soby Mathew9f71f702014-05-09 20:49:17 +0100394 0, 0, 0, 0);
Achin Gupta7c88f3f2014-02-18 18:09:12 +0000395}
396
Douglas Raillardf2129652016-11-24 15:43:19 +0000397/*******************************************************************************
Paul Beesley1fbc97b2019-01-11 18:26:51 +0000398 * TSP smc abort handler. This function is called when aborting a preempted
David Cunado28f69ab2017-04-05 11:34:03 +0100399 * yielding SMC request. It should cleanup all resources owned by the SMC
Douglas Raillardf2129652016-11-24 15:43:19 +0000400 * handler such as locks or dynamically allocated memory so following SMC
401 * request are executed in a clean environment.
402 ******************************************************************************/
403tsp_args_t *tsp_abort_smc_handler(uint64_t func,
404 uint64_t arg1,
405 uint64_t arg2,
406 uint64_t arg3,
407 uint64_t arg4,
408 uint64_t arg5,
409 uint64_t arg6,
410 uint64_t arg7)
411{
412 return set_smc_args(TSP_ABORT_DONE, 0, 0, 0, 0, 0, 0, 0);
413}