blob: fe167cc9b8f081cf13582583ac78ceb06800b2b9 [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 /* -----------------------------------------------------
20 * void platform_set_coherent_stack (unsigned long mpidr)
21 *
22 * For a given CPU, this function sets the stack pointer
23 * to a stack allocated in device memory. This stack can
24 * be used by C code which enables/disables the SCTLR.M
25 * SCTLR.C bit e.g. while powering down a cpu
26 * -----------------------------------------------------
27 */
28func platform_set_coherent_stack
29 mov x9, x30 // lr
30 get_mp_stack pcpu_dv_mem_stack, PCPU_DV_MEM_STACK_SIZE
31 mov sp, x0
32 ret x9
33endfunc platform_set_coherent_stack
34
35 /* -----------------------------------------------------
36 * unsigned long platform_get_stack (unsigned long mpidr)
37 *
38 * For a given CPU, this function returns the stack
39 * pointer for a stack allocated in device memory.
40 * -----------------------------------------------------
41 */
42func platform_get_stack
43 mov x10, x30 // lr
44 get_mp_stack platform_normal_stacks, PLATFORM_STACK_SIZE
45 ret x10
46endfunc platform_get_stack
47
48 /* -----------------------------------------------------
49 * void platform_set_stack (unsigned long mpidr)
50 *
51 * For a given CPU, this function sets the stack pointer
52 * to a stack allocated in normal memory.
53 * -----------------------------------------------------
54 */
55func platform_set_stack
56 mov x9, x30 // lr
57 bl platform_get_stack
58 mov sp, x0
59 ret x9
60endfunc platform_set_stack
61
62 /* -----------------------------------------------------
63 * Per-cpu stacks in normal memory.
64 * Used for C code during runtime execution (when coherent
65 * stacks are not required).
66 * Each cpu gets a stack of PLATFORM_STACK_SIZE bytes.
67 * -----------------------------------------------------
68 */
69declare_stack platform_normal_stacks, tftf_normal_stacks, \
70 PLATFORM_STACK_SIZE, PLATFORM_CORE_COUNT
71
72 /* -----------------------------------------------------
73 * Per-cpu stacks in device memory.
74 * Used for C code just before power down or right after
75 * power up when the MMU or caches need to be turned on
76 * or off.
77 * Each cpu gets a stack of PCPU_DV_MEM_STACK_SIZE bytes.
78 * -----------------------------------------------------
79 */
80declare_stack pcpu_dv_mem_stack, tftf_coherent_stacks, \
81 PCPU_DV_MEM_STACK_SIZE, PLATFORM_CORE_COUNT