Andrew Thoelke | 65668f9 | 2014-03-20 10:48:23 +0000 | [diff] [blame] | 1 | /* |
Antonio Nino Diaz | 7c65c1e | 2017-04-20 09:58:28 +0100 | [diff] [blame] | 2 | * Copyright (c) 2014-2017, ARM Limited and Contributors. All rights reserved. |
Andrew Thoelke | 65668f9 | 2014-03-20 10:48:23 +0000 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Andrew Thoelke | 65668f9 | 2014-03-20 10:48:23 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <arch.h> |
Andrew Thoelke | 65668f9 | 2014-03-20 10:48:23 +0000 | [diff] [blame] | 8 | #include <asm_macros.S> |
Soby Mathew | 49473e4 | 2015-06-10 13:49:59 +0100 | [diff] [blame] | 9 | #include <assert_macros.S> |
Dan Handley | ed6ff95 | 2014-05-14 17:44:19 +0100 | [diff] [blame] | 10 | #include <platform_def.h> |
Andrew Thoelke | 65668f9 | 2014-03-20 10:48:23 +0000 | [diff] [blame] | 11 | |
Andrew Thoelke | 65668f9 | 2014-03-20 10:48:23 +0000 | [diff] [blame] | 12 | .local platform_normal_stacks |
Soby Mathew | b0082d2 | 2015-04-09 13:40:55 +0100 | [diff] [blame] | 13 | .weak plat_get_my_stack |
| 14 | .weak plat_set_my_stack |
Soby Mathew | 70716d6 | 2015-07-13 16:26:11 +0100 | [diff] [blame] | 15 | .globl platform_get_stack |
| 16 | .globl platform_set_stack |
Soby Mathew | 49473e4 | 2015-06-10 13:49:59 +0100 | [diff] [blame] | 17 | |
Soby Mathew | 70716d6 | 2015-07-13 16:26:11 +0100 | [diff] [blame] | 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 | |
Andrew Thoelke | 65668f9 | 2014-03-20 10:48:23 +0000 | [diff] [blame] | 29 | /* ----------------------------------------------------- |
Soby Mathew | a0fedc4 | 2016-06-16 14:52:04 +0100 | [diff] [blame] | 30 | * uintptr_t plat_get_my_stack () |
Soby Mathew | b0082d2 | 2015-04-09 13:40:55 +0100 | [diff] [blame] | 31 | * |
| 32 | * For the current CPU, this function returns the stack |
| 33 | * pointer for a stack allocated in device memory. |
| 34 | * ----------------------------------------------------- |
| 35 | */ |
| 36 | func plat_get_my_stack |
| 37 | mov x10, x30 // lr |
| 38 | get_my_mp_stack platform_normal_stacks, PLATFORM_STACK_SIZE |
| 39 | ret x10 |
| 40 | endfunc plat_get_my_stack |
| 41 | |
| 42 | /* ----------------------------------------------------- |
| 43 | * void plat_set_my_stack () |
| 44 | * |
| 45 | * For the current CPU, this function sets the stack |
| 46 | * pointer to a stack allocated in normal memory. |
| 47 | * ----------------------------------------------------- |
| 48 | */ |
| 49 | func plat_set_my_stack |
| 50 | mov x9, x30 // lr |
| 51 | bl plat_get_my_stack |
| 52 | mov sp, x0 |
| 53 | ret x9 |
| 54 | endfunc plat_set_my_stack |
| 55 | |
| 56 | /* ----------------------------------------------------- |
Achin Gupta | 9c60d80 | 2014-06-26 11:12:37 +0100 | [diff] [blame] | 57 | * Per-cpu stacks in normal memory. Each cpu gets a |
| 58 | * stack of PLATFORM_STACK_SIZE bytes. |
Andrew Thoelke | 65668f9 | 2014-03-20 10:48:23 +0000 | [diff] [blame] | 59 | * ----------------------------------------------------- |
| 60 | */ |
| 61 | declare_stack platform_normal_stacks, tzfw_normal_stacks, \ |
Soby Mathew | bfdbecf | 2016-06-09 17:16:35 +0100 | [diff] [blame] | 62 | PLATFORM_STACK_SIZE, PLATFORM_CORE_COUNT, \ |
| 63 | CACHE_WRITEBACK_GRANULE |