xref: /rk3399_ARM-atf/plat/common/aarch64/platform_mp_stack.S (revision 12d0d00d1e4714fc59c4abbe1d8a2a3ae8a84f56)
12bf28e62SAndrew Thoelke/*
22bf28e62SAndrew Thoelke * Copyright (c) 2014, ARM Limited and Contributors. All rights reserved.
32bf28e62SAndrew Thoelke *
42bf28e62SAndrew Thoelke * Redistribution and use in source and binary forms, with or without
52bf28e62SAndrew Thoelke * modification, are permitted provided that the following conditions are met:
62bf28e62SAndrew Thoelke *
72bf28e62SAndrew Thoelke * Redistributions of source code must retain the above copyright notice, this
82bf28e62SAndrew Thoelke * list of conditions and the following disclaimer.
92bf28e62SAndrew Thoelke *
102bf28e62SAndrew Thoelke * Redistributions in binary form must reproduce the above copyright notice,
112bf28e62SAndrew Thoelke * this list of conditions and the following disclaimer in the documentation
122bf28e62SAndrew Thoelke * and/or other materials provided with the distribution.
132bf28e62SAndrew Thoelke *
142bf28e62SAndrew Thoelke * Neither the name of ARM nor the names of its contributors may be used
152bf28e62SAndrew Thoelke * to endorse or promote products derived from this software without specific
162bf28e62SAndrew Thoelke * prior written permission.
172bf28e62SAndrew Thoelke *
182bf28e62SAndrew Thoelke * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
192bf28e62SAndrew Thoelke * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
202bf28e62SAndrew Thoelke * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
212bf28e62SAndrew Thoelke * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
222bf28e62SAndrew Thoelke * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
232bf28e62SAndrew Thoelke * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
242bf28e62SAndrew Thoelke * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
252bf28e62SAndrew Thoelke * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
262bf28e62SAndrew Thoelke * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
272bf28e62SAndrew Thoelke * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
282bf28e62SAndrew Thoelke * POSSIBILITY OF SUCH DAMAGE.
292bf28e62SAndrew Thoelke */
302bf28e62SAndrew Thoelke
312bf28e62SAndrew Thoelke#include <arch.h>
322bf28e62SAndrew Thoelke#include <asm_macros.S>
335f0cdb05SDan Handley#include <platform_def.h>
342bf28e62SAndrew Thoelke
352bf28e62SAndrew Thoelke
362bf28e62SAndrew Thoelke	.local	platform_normal_stacks
372bf28e62SAndrew Thoelke	.weak	platform_set_stack
382bf28e62SAndrew Thoelke	.weak	platform_get_stack
39*12d0d00dSSoby Mathew	.weak	plat_get_my_stack
40*12d0d00dSSoby Mathew	.weak	plat_set_my_stack
412bf28e62SAndrew Thoelke
422bf28e62SAndrew Thoelke	/* -----------------------------------------------------
432bf28e62SAndrew Thoelke	 * unsigned long platform_get_stack (unsigned long mpidr)
442bf28e62SAndrew Thoelke	 *
452bf28e62SAndrew Thoelke	 * For a given CPU, this function returns the stack
462bf28e62SAndrew Thoelke	 * pointer for a stack allocated in device memory.
472bf28e62SAndrew Thoelke	 * -----------------------------------------------------
482bf28e62SAndrew Thoelke	 */
492bf28e62SAndrew Thoelkefunc platform_get_stack
502bf28e62SAndrew Thoelke	mov x10, x30 // lr
512bf28e62SAndrew Thoelke	get_mp_stack platform_normal_stacks, PLATFORM_STACK_SIZE
522bf28e62SAndrew Thoelke	ret x10
538b779620SKévin Petitendfunc platform_get_stack
542bf28e62SAndrew Thoelke
552bf28e62SAndrew Thoelke	/* -----------------------------------------------------
562bf28e62SAndrew Thoelke	 * void platform_set_stack (unsigned long mpidr)
572bf28e62SAndrew Thoelke	 *
582bf28e62SAndrew Thoelke	 * For a given CPU, this function sets the stack pointer
592bf28e62SAndrew Thoelke	 * to a stack allocated in normal memory.
602bf28e62SAndrew Thoelke	 * -----------------------------------------------------
612bf28e62SAndrew Thoelke	 */
622bf28e62SAndrew Thoelkefunc platform_set_stack
632bf28e62SAndrew Thoelke	mov x9, x30 // lr
642bf28e62SAndrew Thoelke	bl  platform_get_stack
652bf28e62SAndrew Thoelke	mov sp, x0
662bf28e62SAndrew Thoelke	ret x9
678b779620SKévin Petitendfunc platform_set_stack
682bf28e62SAndrew Thoelke
692bf28e62SAndrew Thoelke	/* -----------------------------------------------------
70*12d0d00dSSoby Mathew	 * unsigned long plat_get_my_stack ()
71*12d0d00dSSoby Mathew	 *
72*12d0d00dSSoby Mathew	 * For the current CPU, this function returns the stack
73*12d0d00dSSoby Mathew	 * pointer for a stack allocated in device memory.
74*12d0d00dSSoby Mathew	 * -----------------------------------------------------
75*12d0d00dSSoby Mathew	 */
76*12d0d00dSSoby Mathewfunc plat_get_my_stack
77*12d0d00dSSoby Mathew	mov	x10, x30 // lr
78*12d0d00dSSoby Mathew	get_my_mp_stack platform_normal_stacks, PLATFORM_STACK_SIZE
79*12d0d00dSSoby Mathew	ret	x10
80*12d0d00dSSoby Mathewendfunc plat_get_my_stack
81*12d0d00dSSoby Mathew
82*12d0d00dSSoby Mathew	/* -----------------------------------------------------
83*12d0d00dSSoby Mathew	 * void plat_set_my_stack ()
84*12d0d00dSSoby Mathew	 *
85*12d0d00dSSoby Mathew	 * For the current CPU, this function sets the stack
86*12d0d00dSSoby Mathew	 * pointer to a stack allocated in normal memory.
87*12d0d00dSSoby Mathew	 * -----------------------------------------------------
88*12d0d00dSSoby Mathew	 */
89*12d0d00dSSoby Mathewfunc plat_set_my_stack
90*12d0d00dSSoby Mathew	mov	x9, x30 // lr
91*12d0d00dSSoby Mathew	bl 	plat_get_my_stack
92*12d0d00dSSoby Mathew	mov	sp, x0
93*12d0d00dSSoby Mathew	ret	x9
94*12d0d00dSSoby Mathewendfunc plat_set_my_stack
95*12d0d00dSSoby Mathew
96*12d0d00dSSoby Mathew	/* -----------------------------------------------------
97539a7b38SAchin Gupta	 * Per-cpu stacks in normal memory. Each cpu gets a
98539a7b38SAchin Gupta	 * stack of PLATFORM_STACK_SIZE bytes.
992bf28e62SAndrew Thoelke	 * -----------------------------------------------------
1002bf28e62SAndrew Thoelke	 */
1012bf28e62SAndrew Thoelkedeclare_stack platform_normal_stacks, tzfw_normal_stacks, \
1022bf28e62SAndrew Thoelke		PLATFORM_STACK_SIZE, PLATFORM_CORE_COUNT
103