blob: c4ea8958478f103b57380ec2d058e75e77277d1b [file] [log] [blame]
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02001/*
2 * Copyright (c) 2018, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
8#include <asm_macros.S>
9#include <platform_def.h>
10
11
12 .local pcpu_dv_mem_stack
13 .local platform_normal_stacks
14 .weak platform_set_stack
15 .weak platform_get_stack
16 .weak platform_set_coherent_stack
17
18 /* -----------------------------------------------------
19 * void platform_set_coherent_stack (unsigned long mpidr)
20 *
21 * For a given CPU, this function sets the stack pointer
22 * to a stack allocated in device memory. This stack can
23 * be used by C code which enables/disables the SCTLR.M
24 * SCTLR.C bit e.g. while powering down a cpu
25 * -----------------------------------------------------
26 */
27func platform_set_coherent_stack
28 mov r9, lr
29 get_mp_stack pcpu_dv_mem_stack, PCPU_DV_MEM_STACK_SIZE
30 mov sp, r0
31 bx r9
32endfunc platform_set_coherent_stack
33
34 /* -----------------------------------------------------
35 * uintptr_t platform_get_stack (u_register_t mpidr)
36 *
37 * For a given CPU, this function returns the stack
38 * pointer for a stack allocated in normal memory.
39 * -----------------------------------------------------
40 */
41func platform_get_stack
42 mov r9, lr
43 get_mp_stack platform_normal_stacks, PLATFORM_STACK_SIZE
44 bx r9
45endfunc platform_get_stack
46
47 /* -----------------------------------------------------
48 * void platform_set_stack (u_register_t mpidr)
49 *
50 * For a given CPU, this function sets the stack
51 * pointer to a stack allocated in normal memory.
52 * -----------------------------------------------------
53 */
54func platform_set_stack
55 mov r9, lr
56 get_mp_stack platform_normal_stacks, PLATFORM_STACK_SIZE
57 mov sp, r0
58 bx r9
59endfunc platform_set_stack
60
61 /* -----------------------------------------------------
62 * Per-cpu stacks in normal memory.
63 * Used for C code during runtime execution (when coherent
64 * stacks are not required).
65 * Each cpu gets a stack of PLATFORM_STACK_SIZE bytes.
66 * -----------------------------------------------------
67 */
68declare_stack platform_normal_stacks, tftf_normal_stacks, \
69 PLATFORM_STACK_SIZE, PLATFORM_CORE_COUNT
70
71 /* -----------------------------------------------------
72 * Per-cpu stacks in device memory.
73 * Used for C code just before power down or right after
74 * power up when the MMU or caches need to be turned on
75 * or off.
76 * Each cpu gets a stack of PCPU_DV_MEM_STACK_SIZE bytes.
77 * -----------------------------------------------------
78 */
79declare_stack pcpu_dv_mem_stack, tftf_coherent_stacks, \
80 PCPU_DV_MEM_STACK_SIZE, PLATFORM_CORE_COUNT