1*2bf28e62SAndrew Thoelke/* 2*2bf28e62SAndrew Thoelke * Copyright (c) 2014, ARM Limited and Contributors. All rights reserved. 3*2bf28e62SAndrew Thoelke * 4*2bf28e62SAndrew Thoelke * Redistribution and use in source and binary forms, with or without 5*2bf28e62SAndrew Thoelke * modification, are permitted provided that the following conditions are met: 6*2bf28e62SAndrew Thoelke * 7*2bf28e62SAndrew Thoelke * Redistributions of source code must retain the above copyright notice, this 8*2bf28e62SAndrew Thoelke * list of conditions and the following disclaimer. 9*2bf28e62SAndrew Thoelke * 10*2bf28e62SAndrew Thoelke * Redistributions in binary form must reproduce the above copyright notice, 11*2bf28e62SAndrew Thoelke * this list of conditions and the following disclaimer in the documentation 12*2bf28e62SAndrew Thoelke * and/or other materials provided with the distribution. 13*2bf28e62SAndrew Thoelke * 14*2bf28e62SAndrew Thoelke * Neither the name of ARM nor the names of its contributors may be used 15*2bf28e62SAndrew Thoelke * to endorse or promote products derived from this software without specific 16*2bf28e62SAndrew Thoelke * prior written permission. 17*2bf28e62SAndrew Thoelke * 18*2bf28e62SAndrew Thoelke * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19*2bf28e62SAndrew Thoelke * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20*2bf28e62SAndrew Thoelke * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21*2bf28e62SAndrew Thoelke * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 22*2bf28e62SAndrew Thoelke * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23*2bf28e62SAndrew Thoelke * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24*2bf28e62SAndrew Thoelke * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25*2bf28e62SAndrew Thoelke * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26*2bf28e62SAndrew Thoelke * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27*2bf28e62SAndrew Thoelke * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28*2bf28e62SAndrew Thoelke * POSSIBILITY OF SUCH DAMAGE. 29*2bf28e62SAndrew Thoelke */ 30*2bf28e62SAndrew Thoelke 31*2bf28e62SAndrew Thoelke#include <arch.h> 32*2bf28e62SAndrew Thoelke#include <platform.h> 33*2bf28e62SAndrew Thoelke#include <asm_macros.S> 34*2bf28e62SAndrew Thoelke 35*2bf28e62SAndrew Thoelke 36*2bf28e62SAndrew Thoelke .local pcpu_dv_mem_stack 37*2bf28e62SAndrew Thoelke .local platform_normal_stacks 38*2bf28e62SAndrew Thoelke .globl platform_set_stack 39*2bf28e62SAndrew Thoelke .globl platform_get_stack 40*2bf28e62SAndrew Thoelke .globl platform_set_coherent_stack 41*2bf28e62SAndrew Thoelke 42*2bf28e62SAndrew Thoelke 43*2bf28e62SAndrew Thoelke /* ----------------------------------------------------- 44*2bf28e62SAndrew Thoelke * void platform_set_coherent_stack (unsigned long) 45*2bf28e62SAndrew Thoelke * 46*2bf28e62SAndrew Thoelke * For cold-boot BL images, only the primary CPU needs a 47*2bf28e62SAndrew Thoelke * stack. This function sets the stack pointer to a stack 48*2bf28e62SAndrew Thoelke * allocated in device memory. 49*2bf28e62SAndrew Thoelke * ----------------------------------------------------- 50*2bf28e62SAndrew Thoelke */ 51*2bf28e62SAndrew Thoelkefunc platform_set_coherent_stack 52*2bf28e62SAndrew Thoelke get_up_stack pcpu_dv_mem_stack, PCPU_DV_MEM_STACK_SIZE 53*2bf28e62SAndrew Thoelke mov sp, x0 54*2bf28e62SAndrew Thoelke ret 55*2bf28e62SAndrew Thoelke 56*2bf28e62SAndrew Thoelke 57*2bf28e62SAndrew Thoelke /* ----------------------------------------------------- 58*2bf28e62SAndrew Thoelke * unsigned long platform_get_stack (unsigned long) 59*2bf28e62SAndrew Thoelke * 60*2bf28e62SAndrew Thoelke * For cold-boot BL images, only the primary CPU needs a 61*2bf28e62SAndrew Thoelke * stack. This function returns the stack pointer for a 62*2bf28e62SAndrew Thoelke * stack allocated in device memory. 63*2bf28e62SAndrew Thoelke * ----------------------------------------------------- 64*2bf28e62SAndrew Thoelke */ 65*2bf28e62SAndrew Thoelkefunc platform_get_stack 66*2bf28e62SAndrew Thoelke get_up_stack platform_normal_stacks, PLATFORM_STACK_SIZE 67*2bf28e62SAndrew Thoelke ret 68*2bf28e62SAndrew Thoelke 69*2bf28e62SAndrew Thoelke /* ----------------------------------------------------- 70*2bf28e62SAndrew Thoelke * void platform_set_stack (unsigned long) 71*2bf28e62SAndrew Thoelke * 72*2bf28e62SAndrew Thoelke * For cold-boot BL images, only the primary CPU needs a 73*2bf28e62SAndrew Thoelke * stack. This function sets the stack pointer to a stack 74*2bf28e62SAndrew Thoelke * allocated in normal memory. 75*2bf28e62SAndrew Thoelke * ----------------------------------------------------- 76*2bf28e62SAndrew Thoelke */ 77*2bf28e62SAndrew Thoelkefunc platform_set_stack 78*2bf28e62SAndrew Thoelke get_up_stack platform_normal_stacks, PLATFORM_STACK_SIZE 79*2bf28e62SAndrew Thoelke mov sp, x0 80*2bf28e62SAndrew Thoelke ret 81*2bf28e62SAndrew Thoelke 82*2bf28e62SAndrew Thoelke /* ----------------------------------------------------- 83*2bf28e62SAndrew Thoelke * Single cpu stack in normal memory. 84*2bf28e62SAndrew Thoelke * Used for C code during boot, PLATFORM_STACK_SIZE bytes 85*2bf28e62SAndrew Thoelke * are allocated 86*2bf28e62SAndrew Thoelke * ----------------------------------------------------- 87*2bf28e62SAndrew Thoelke */ 88*2bf28e62SAndrew Thoelkedeclare_stack platform_normal_stacks, tzfw_normal_stacks, \ 89*2bf28e62SAndrew Thoelke PLATFORM_STACK_SIZE, 1 90*2bf28e62SAndrew Thoelke 91*2bf28e62SAndrew Thoelke /* ----------------------------------------------------- 92*2bf28e62SAndrew Thoelke * Single cpu stack in device/coherent memory. 93*2bf28e62SAndrew Thoelke * PCPU_DV_MEM_STACK_SIZE bytes are allocated. 94*2bf28e62SAndrew Thoelke * ----------------------------------------------------- 95*2bf28e62SAndrew Thoelke */ 96*2bf28e62SAndrew Thoelkedeclare_stack pcpu_dv_mem_stack, tzfw_coherent_mem, \ 97*2bf28e62SAndrew Thoelke PCPU_DV_MEM_STACK_SIZE, 1 98