blob: fd0a01e297d0eefcdde606edf01c5609c8a66b55 [file] [log] [blame]
Andrew Thoelke65668f92014-03-20 10:48:23 +00001/*
Antonio Nino Diaz7c65c1e2017-04-20 09:58:28 +01002 * Copyright (c) 2014-2017, ARM Limited and Contributors. All rights reserved.
Andrew Thoelke65668f92014-03-20 10:48:23 +00003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Andrew Thoelke65668f92014-03-20 10:48:23 +00005 */
6
7#include <arch.h>
Andrew Thoelke65668f92014-03-20 10:48:23 +00008#include <asm_macros.S>
Soby Mathew49473e42015-06-10 13:49:59 +01009#include <assert_macros.S>
Dan Handleyed6ff952014-05-14 17:44:19 +010010#include <platform_def.h>
Andrew Thoelke65668f92014-03-20 10:48:23 +000011
Andrew Thoelke65668f92014-03-20 10:48:23 +000012 .local platform_normal_stacks
Soby Mathewb0082d22015-04-09 13:40:55 +010013 .weak plat_get_my_stack
14 .weak plat_set_my_stack
Soby Mathew70716d62015-07-13 16:26:11 +010015 .globl platform_get_stack
16 .globl platform_set_stack
Soby Mathew49473e42015-06-10 13:49:59 +010017
Soby Mathew70716d62015-07-13 16:26:11 +010018 /* ---------------------------------------------------------------------
19 * When the compatility layer is disabled, the new platform APIs
20 * viz plat_get_my_stack() and plat_set_my_stack() are
21 * supported by the platform and the previous APIs platform_get_stack()
22 * and platform_set_stack() are defined in terms of new APIs making use
23 * of the fact that they are only ever invoked for the current CPU.
24 * This is to enable components of Trusted Firmware like SPDs using the
25 * old platform APIs to continue to work.
26 * --------------------------------------------------------------------
27 */
28
29 /* -------------------------------------------------------
30 * unsigned long platform_get_stack (unsigned long mpidr)
31 *
32 * For the current CPU, this function returns the stack
33 * pointer for a stack allocated in device memory. The
34 * 'mpidr' should correspond to that of the current CPU.
35 * This function is deprecated and plat_get_my_stack()
36 * should be used instead.
37 * -------------------------------------------------------
38 */
39func_deprecated platform_get_stack
Antonio Nino Diaz7c65c1e2017-04-20 09:58:28 +010040#if ENABLE_ASSERTIONS
Soby Mathew70716d62015-07-13 16:26:11 +010041 mrs x1, mpidr_el1
42 cmp x0, x1
43 ASM_ASSERT(eq)
44#endif
45 b plat_get_my_stack
46endfunc_deprecated platform_get_stack
47
48 /* -----------------------------------------------------
49 * void platform_set_stack (unsigned long mpidr)
50 *
51 * For the current CPU, this function sets the stack pointer
52 * to a stack allocated in normal memory. The
53 * 'mpidr' should correspond to that of the current CPU.
54 * This function is deprecated and plat_get_my_stack()
55 * should be used instead.
56 * -----------------------------------------------------
57 */
58func_deprecated platform_set_stack
Antonio Nino Diaz7c65c1e2017-04-20 09:58:28 +010059#if ENABLE_ASSERTIONS
Soby Mathew70716d62015-07-13 16:26:11 +010060 mrs x1, mpidr_el1
61 cmp x0, x1
62 ASM_ASSERT(eq)
63#endif
64 b plat_set_my_stack
65endfunc_deprecated platform_set_stack
Soby Mathew981487a2015-07-13 14:10:57 +010066
Andrew Thoelke65668f92014-03-20 10:48:23 +000067 /* -----------------------------------------------------
Soby Mathewa0fedc42016-06-16 14:52:04 +010068 * uintptr_t plat_get_my_stack ()
Soby Mathewb0082d22015-04-09 13:40:55 +010069 *
70 * For the current CPU, this function returns the stack
71 * pointer for a stack allocated in device memory.
72 * -----------------------------------------------------
73 */
74func plat_get_my_stack
75 mov x10, x30 // lr
76 get_my_mp_stack platform_normal_stacks, PLATFORM_STACK_SIZE
77 ret x10
78endfunc plat_get_my_stack
79
80 /* -----------------------------------------------------
81 * void plat_set_my_stack ()
82 *
83 * For the current CPU, this function sets the stack
84 * pointer to a stack allocated in normal memory.
85 * -----------------------------------------------------
86 */
87func plat_set_my_stack
88 mov x9, x30 // lr
89 bl plat_get_my_stack
90 mov sp, x0
91 ret x9
92endfunc plat_set_my_stack
93
94 /* -----------------------------------------------------
Achin Gupta9c60d802014-06-26 11:12:37 +010095 * Per-cpu stacks in normal memory. Each cpu gets a
96 * stack of PLATFORM_STACK_SIZE bytes.
Andrew Thoelke65668f92014-03-20 10:48:23 +000097 * -----------------------------------------------------
98 */
99declare_stack platform_normal_stacks, tzfw_normal_stacks, \
Soby Mathewbfdbecf2016-06-09 17:16:35 +0100100 PLATFORM_STACK_SIZE, PLATFORM_CORE_COUNT, \
101 CACHE_WRITEBACK_GRANULE