xref: /rk3399_ARM-atf/plat/common/aarch64/platform_mp_stack.S (revision 90e0c983734ca4d2ee7523a1c85d7d5449a756df)
1/*
2 * Copyright (c) 2014-2017, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
8#include <asm_macros.S>
9#include <assert_macros.S>
10#include <platform_def.h>
11
12	.local	platform_normal_stacks
13	.weak	plat_get_my_stack
14	.weak	plat_set_my_stack
15	.globl	platform_get_stack
16	.globl	platform_set_stack
17
18	/* ---------------------------------------------------------------------
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
40#if ENABLE_ASSERTIONS
41	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
59#if ENABLE_ASSERTIONS
60	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
66
67	/* -----------------------------------------------------
68	 * uintptr_t plat_get_my_stack ()
69	 *
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	/* -----------------------------------------------------
95	 * Per-cpu stacks in normal memory. Each cpu gets a
96	 * stack of PLATFORM_STACK_SIZE bytes.
97	 * -----------------------------------------------------
98	 */
99declare_stack platform_normal_stacks, tzfw_normal_stacks, \
100		PLATFORM_STACK_SIZE, PLATFORM_CORE_COUNT, \
101		CACHE_WRITEBACK_GRANULE
102