Furquan Shaikh | e5d014c | 2014-07-07 11:45:15 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright 2014 Google Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
Furquan Shaikh | e5d014c | 2014-07-07 11:45:15 -0700 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | /* Macro to initialize stack, perform seeding if required and finally call the |
| 17 | * function provided |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 18 | * @stack_top : First address above the stack |
| 19 | * @stack_bottom : Lowest address on the stack |
| 20 | * @seed : Stack seeding required (1=yes/otherwise=no) |
| 21 | * @func : Function to call after initializing stack |
Furquan Shaikh | e5d014c | 2014-07-07 11:45:15 -0700 | [diff] [blame] | 22 | */ |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 23 | .macro stack_init stack_top, stack_bottom, seed, func |
Furquan Shaikh | e5d014c | 2014-07-07 11:45:15 -0700 | [diff] [blame] | 24 | /* Check if stack seeding is required */ |
| 25 | mov r0, #\seed |
| 26 | cmp r0, #1 |
| 27 | bne call_func |
| 28 | /* Stack seeding */ |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 29 | ldr r0, =\stack_bottom |
| 30 | ldr r1, =\stack_top |
Furquan Shaikh | e5d014c | 2014-07-07 11:45:15 -0700 | [diff] [blame] | 31 | ldr r2, =0xdeadbeef |
| 32 | init_stack_loop: |
| 33 | str r2, [r0] |
| 34 | add r0, #4 |
| 35 | cmp r0, r1 |
| 36 | bne init_stack_loop |
| 37 | |
| 38 | call_func: |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 39 | ldr sp, =\stack_top /* Set up stack pointer */ |
Furquan Shaikh | e5d014c | 2014-07-07 11:45:15 -0700 | [diff] [blame] | 40 | bl \func |
| 41 | .endm |