1/* 2 * Copyright (c) 2017-2020, ARM Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6#ifndef ARM_RECLAIM_INIT_LD_S 7#define ARM_RECLAIM_INIT_LD_S 8 9SECTIONS 10{ 11 .init __STACKS_START__ : { 12 . = . + PLATFORM_STACK_SIZE; 13 . = ALIGN(PAGE_SIZE); 14 __INIT_CODE_START__ = .; 15 *(*text.init*); 16 __INIT_CODE_END__ = .; 17 } >RAM 18 19#ifdef BL31_PROGBITS_LIMIT 20 ASSERT(__INIT_CODE_END__ <= BL31_PROGBITS_LIMIT, 21 "BL31 init has exceeded progbits limit.") 22#endif 23 24 ASSERT(__INIT_CODE_END__ <= __STACKS_END__, 25 "Init code ends past the end of the stacks") 26 27} 28 29#undef MIN 30#define ABS ABSOLUTE 31#define COUNT PLATFORM_CORE_COUNT 32#define ALIGN_MASK ~(CACHE_WRITEBACK_GRANULE - 1) 33 34#define PRIMARY_STACK \ 35 __STACKS_START__ = .; \ 36 *(tzfw_normal_stacks) \ 37 OFFSET = ABS(SIZEOF(.init) - (. - __STACKS_START__)); \ 38 /* Offset sign */ \ 39 SIGN = ABS(OFFSET) & (1 << 63); \ 40 /* Offset mask */ \ 41 MASK = ABS(SIGN >> 63) - 1; \ 42 . += ABS(OFFSET) & ABS(MASK); \ 43 . = ALIGN(PAGE_SIZE); \ 44 __STACKS_END__ = .; \ 45 /* Total stack size */ \ 46 SIZE = ABS(. - __STACKS_START__); \ 47 /* Maximum primary CPU stack */ \ 48 STACK = ABS(__STACKS_START__ + SIZE / COUNT) & ALIGN_MASK; \ 49 /* Primary CPU stack */ \ 50 __PRIMARY_STACK__ = MIN(STACK, ABS(__INIT_CODE_START__)); 51 52#if (COUNT > 1) 53#define SECONDARY_STACK \ 54 /* Size of the secondary CPUs' stack */ \ 55 REST = ABS(__STACKS_END__ - __PRIMARY_STACK__); \ 56 /* Secondary per-CPU stack size */ \ 57 __STACK_SIZE__ = ABS(REST / (COUNT - 1)); 58#else 59#define SECONDARY_STACK 60#endif 61 62#define STACK_SECTION \ 63 stacks (NOLOAD) : { \ 64 PRIMARY_STACK \ 65 SECONDARY_STACK \ 66 } 67#endif /* ARM_RECLAIM_INIT_LD_S */ 68