blob: e1516efcc2112e08d667c55ea37e14b20fe92b62 [file] [log] [blame]
Angel Ponsa2ee7612020-04-04 18:51:15 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Patrick Georgi40a3e322015-06-22 19:41:29 +02002
3/* Macro to initialize stack, perform seeding if required and finally call the
4 * function provided
5 * @stack_top : First address above the stack
6 * @stack_bottom : Lowest address on the stack
7 * @seed : Stack seeding required (1=yes/otherwise=no)
8 * @func : Function to call after initializing stack
9 */
10.macro stack_init stack_top, stack_bottom, seed, func
Elyes HAOUAS88607a42018-10-05 10:36:45 +020011 /* Check if stack seeding is required */
Patrick Georgi40a3e322015-06-22 19:41:29 +020012 mov r0, #\seed
13 cmp r0, #1
14 bne call_func
15 /* Stack seeding */
16 ldr r0, =\stack_bottom
17 ldr r1, =\stack_top
18 ldr r2, =0xdeadbeef
19init_stack_loop:
20 str r2, [r0]
21 add r0, #4
22 cmp r0, r1
23 bne init_stack_loop
24
25call_func:
26 ldr sp, =\stack_top /* Set up stack pointer */
27 bl \func
28.endm