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> 335f0cdb05SDan Handley#include <platform_def.h> 342bf28e62SAndrew Thoelke 352bf28e62SAndrew Thoelke 362bf28e62SAndrew Thoelke .local platform_normal_stacks 372bf28e62SAndrew Thoelke .weak platform_set_stack 382bf28e62SAndrew Thoelke .weak platform_get_stack 392bf28e62SAndrew Thoelke 402bf28e62SAndrew Thoelke 412bf28e62SAndrew Thoelke /* ----------------------------------------------------- 422bf28e62SAndrew Thoelke * unsigned long platform_get_stack (unsigned long mpidr) 432bf28e62SAndrew Thoelke * 442bf28e62SAndrew Thoelke * For a given CPU, this function returns the stack 452bf28e62SAndrew Thoelke * pointer for a stack allocated in device memory. 462bf28e62SAndrew Thoelke * ----------------------------------------------------- 472bf28e62SAndrew Thoelke */ 482bf28e62SAndrew Thoelkefunc platform_get_stack 492bf28e62SAndrew Thoelke mov x10, x30 // lr 502bf28e62SAndrew Thoelke get_mp_stack platform_normal_stacks, PLATFORM_STACK_SIZE 512bf28e62SAndrew Thoelke ret x10 52*8b779620SKévin Petitendfunc platform_get_stack 532bf28e62SAndrew Thoelke 542bf28e62SAndrew Thoelke /* ----------------------------------------------------- 552bf28e62SAndrew Thoelke * void platform_set_stack (unsigned long mpidr) 562bf28e62SAndrew Thoelke * 572bf28e62SAndrew Thoelke * For a given CPU, this function sets the stack pointer 582bf28e62SAndrew Thoelke * to a stack allocated in normal memory. 592bf28e62SAndrew Thoelke * ----------------------------------------------------- 602bf28e62SAndrew Thoelke */ 612bf28e62SAndrew Thoelkefunc platform_set_stack 622bf28e62SAndrew Thoelke mov x9, x30 // lr 632bf28e62SAndrew Thoelke bl platform_get_stack 642bf28e62SAndrew Thoelke mov sp, x0 652bf28e62SAndrew Thoelke ret x9 66*8b779620SKévin Petitendfunc platform_set_stack 672bf28e62SAndrew Thoelke 682bf28e62SAndrew Thoelke /* ----------------------------------------------------- 69539a7b38SAchin Gupta * Per-cpu stacks in normal memory. Each cpu gets a 70539a7b38SAchin Gupta * stack of PLATFORM_STACK_SIZE bytes. 712bf28e62SAndrew Thoelke * ----------------------------------------------------- 722bf28e62SAndrew Thoelke */ 732bf28e62SAndrew Thoelkedeclare_stack platform_normal_stacks, tzfw_normal_stacks, \ 742bf28e62SAndrew Thoelke PLATFORM_STACK_SIZE, PLATFORM_CORE_COUNT 75