Sandrine Bailleux | 3cd87d7 | 2018-10-09 11:12:55 +0200 | [diff] [blame^] | 1 | /* |
| 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 | */ |
| 27 | func 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 |
| 32 | endfunc 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 | */ |
| 41 | func platform_get_stack |
| 42 | mov r9, lr |
| 43 | get_mp_stack platform_normal_stacks, PLATFORM_STACK_SIZE |
| 44 | bx r9 |
| 45 | endfunc 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 | */ |
| 54 | func platform_set_stack |
| 55 | mov r9, lr |
| 56 | get_mp_stack platform_normal_stacks, PLATFORM_STACK_SIZE |
| 57 | mov sp, r0 |
| 58 | bx r9 |
| 59 | endfunc 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 | */ |
| 68 | declare_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 | */ |
| 79 | declare_stack pcpu_dv_mem_stack, tftf_coherent_stacks, \ |
| 80 | PCPU_DV_MEM_STACK_SIZE, PLATFORM_CORE_COUNT |