blob: c0668ea78cdf2a54d5b63e142b0f6df492864237 [file] [log] [blame]
Andrew Thoelke2bf28e62014-03-20 10:48:23 +00001/*
Alexei Fedorov34dd1e92020-05-30 17:33:26 +01002 * Copyright (c) 2014-2020, ARM Limited and Contributors. All rights reserved.
Andrew Thoelke2bf28e62014-03-20 10:48:23 +00003 *
dp-arm82cb2c12017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Andrew Thoelke2bf28e62014-03-20 10:48:23 +00005 */
6
7#include <arch.h>
Andrew Thoelke2bf28e62014-03-20 10:48:23 +00008#include <asm_macros.S>
Soby Mathew32bc85f2015-06-10 13:49:59 +01009#include <assert_macros.S>
Dan Handley5f0cdb02014-05-14 17:44:19 +010010#include <platform_def.h>
Andrew Thoelke2bf28e62014-03-20 10:48:23 +000011
Andrew Thoelke2bf28e62014-03-20 10:48:23 +000012 .local platform_normal_stacks
Soby Mathew12d0d002015-04-09 13:40:55 +010013 .weak plat_get_my_stack
14 .weak plat_set_my_stack
Soby Mathew32bc85f2015-06-10 13:49:59 +010015
Soby Mathew5c8babc2015-07-13 16:26:11 +010016 /* ---------------------------------------------------------------------
David Horstmann5d9101b2020-11-12 15:19:04 +000017 * When the compatibility layer is disabled, the platform APIs
Antonio Nino Diaz73308612019-02-28 13:35:21 +000018 * plat_get_my_stack() and plat_set_my_stack() are supported by the
19 * platform and the previous APIs platform_get_stack() and
20 * platform_set_stack() are defined in terms of new APIs making use of
21 * the fact that they are only ever invoked for the current CPU. This
22 * is to enable components of Trusted Firmware like SPDs using the old
23 * platform APIs to continue to work.
Soby Mathew5c8babc2015-07-13 16:26:11 +010024 * --------------------------------------------------------------------
25 */
26
Andrew Thoelke2bf28e62014-03-20 10:48:23 +000027 /* -----------------------------------------------------
Soby Mathew4c0d0392016-06-16 14:52:04 +010028 * uintptr_t plat_get_my_stack ()
Soby Mathew12d0d002015-04-09 13:40:55 +010029 *
30 * For the current CPU, this function returns the stack
31 * pointer for a stack allocated in device memory.
32 * -----------------------------------------------------
33 */
34func plat_get_my_stack
Alexei Fedorov34dd1e92020-05-30 17:33:26 +010035 mov x10, x30
Soby Mathew12d0d002015-04-09 13:40:55 +010036 get_my_mp_stack platform_normal_stacks, PLATFORM_STACK_SIZE
37 ret x10
38endfunc plat_get_my_stack
39
40 /* -----------------------------------------------------
41 * void plat_set_my_stack ()
42 *
43 * For the current CPU, this function sets the stack
44 * pointer to a stack allocated in normal memory.
45 * -----------------------------------------------------
46 */
47func plat_set_my_stack
Alexei Fedorov34dd1e92020-05-30 17:33:26 +010048 mov x9, x30
Soby Mathew12d0d002015-04-09 13:40:55 +010049 bl plat_get_my_stack
50 mov sp, x0
51 ret x9
52endfunc plat_set_my_stack
53
54 /* -----------------------------------------------------
Alexei Fedorov34dd1e92020-05-30 17:33:26 +010055 * Per-CPU stacks in normal memory. Each CPU gets a
Achin Gupta539a7b32014-06-26 11:12:37 +010056 * stack of PLATFORM_STACK_SIZE bytes.
Andrew Thoelke2bf28e62014-03-20 10:48:23 +000057 * -----------------------------------------------------
58 */
59declare_stack platform_normal_stacks, tzfw_normal_stacks, \
Soby Mathew663db202016-06-09 17:16:35 +010060 PLATFORM_STACK_SIZE, PLATFORM_CORE_COUNT, \
61 CACHE_WRITEBACK_GRANULE