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> 33*5f0cdb05SDan Handley#include <platform_def.h> 342bf28e62SAndrew Thoelke 352bf28e62SAndrew Thoelke 362bf28e62SAndrew Thoelke .local pcpu_dv_mem_stack 372bf28e62SAndrew Thoelke .local platform_normal_stacks 382bf28e62SAndrew Thoelke .globl platform_set_stack 392bf28e62SAndrew Thoelke .globl platform_get_stack 402bf28e62SAndrew Thoelke .globl platform_set_coherent_stack 412bf28e62SAndrew Thoelke 422bf28e62SAndrew Thoelke 432bf28e62SAndrew Thoelke /* ----------------------------------------------------- 442bf28e62SAndrew Thoelke * void platform_set_coherent_stack (unsigned long) 452bf28e62SAndrew Thoelke * 462bf28e62SAndrew Thoelke * For cold-boot BL images, only the primary CPU needs a 472bf28e62SAndrew Thoelke * stack. This function sets the stack pointer to a stack 482bf28e62SAndrew Thoelke * allocated in device memory. 492bf28e62SAndrew Thoelke * ----------------------------------------------------- 502bf28e62SAndrew Thoelke */ 512bf28e62SAndrew Thoelkefunc platform_set_coherent_stack 522bf28e62SAndrew Thoelke get_up_stack pcpu_dv_mem_stack, PCPU_DV_MEM_STACK_SIZE 532bf28e62SAndrew Thoelke mov sp, x0 542bf28e62SAndrew Thoelke ret 552bf28e62SAndrew Thoelke 562bf28e62SAndrew Thoelke 572bf28e62SAndrew Thoelke /* ----------------------------------------------------- 582bf28e62SAndrew Thoelke * unsigned long platform_get_stack (unsigned long) 592bf28e62SAndrew Thoelke * 602bf28e62SAndrew Thoelke * For cold-boot BL images, only the primary CPU needs a 612bf28e62SAndrew Thoelke * stack. This function returns the stack pointer for a 622bf28e62SAndrew Thoelke * stack allocated in device memory. 632bf28e62SAndrew Thoelke * ----------------------------------------------------- 642bf28e62SAndrew Thoelke */ 652bf28e62SAndrew Thoelkefunc platform_get_stack 662bf28e62SAndrew Thoelke get_up_stack platform_normal_stacks, PLATFORM_STACK_SIZE 672bf28e62SAndrew Thoelke ret 682bf28e62SAndrew Thoelke 692bf28e62SAndrew Thoelke /* ----------------------------------------------------- 702bf28e62SAndrew Thoelke * void platform_set_stack (unsigned long) 712bf28e62SAndrew Thoelke * 722bf28e62SAndrew Thoelke * For cold-boot BL images, only the primary CPU needs a 732bf28e62SAndrew Thoelke * stack. This function sets the stack pointer to a stack 742bf28e62SAndrew Thoelke * allocated in normal memory. 752bf28e62SAndrew Thoelke * ----------------------------------------------------- 762bf28e62SAndrew Thoelke */ 772bf28e62SAndrew Thoelkefunc platform_set_stack 782bf28e62SAndrew Thoelke get_up_stack platform_normal_stacks, PLATFORM_STACK_SIZE 792bf28e62SAndrew Thoelke mov sp, x0 802bf28e62SAndrew Thoelke ret 812bf28e62SAndrew Thoelke 822bf28e62SAndrew Thoelke /* ----------------------------------------------------- 832bf28e62SAndrew Thoelke * Single cpu stack in normal memory. 842bf28e62SAndrew Thoelke * Used for C code during boot, PLATFORM_STACK_SIZE bytes 852bf28e62SAndrew Thoelke * are allocated 862bf28e62SAndrew Thoelke * ----------------------------------------------------- 872bf28e62SAndrew Thoelke */ 882bf28e62SAndrew Thoelkedeclare_stack platform_normal_stacks, tzfw_normal_stacks, \ 892bf28e62SAndrew Thoelke PLATFORM_STACK_SIZE, 1 902bf28e62SAndrew Thoelke 912bf28e62SAndrew Thoelke /* ----------------------------------------------------- 922bf28e62SAndrew Thoelke * Single cpu stack in device/coherent memory. 932bf28e62SAndrew Thoelke * PCPU_DV_MEM_STACK_SIZE bytes are allocated. 942bf28e62SAndrew Thoelke * ----------------------------------------------------- 952bf28e62SAndrew Thoelke */ 962bf28e62SAndrew Thoelkedeclare_stack pcpu_dv_mem_stack, tzfw_coherent_mem, \ 972bf28e62SAndrew Thoelke PCPU_DV_MEM_STACK_SIZE, 1 98