Gabe Black | f2f817e | 2013-10-01 05:20:17 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Early initialization code for ARM architecture. |
| 3 | * |
| 4 | * This file is based off of the OMAP3530/ARM Cortex start.S file from Das |
| 5 | * U-Boot, which itself got the file from armboot. |
| 6 | * |
| 7 | * Copyright (c) 2004 Texas Instruments <r-woodruff2@ti.com> |
| 8 | * Copyright (c) 2001 Marius Gröger <mag@sysgo.de> |
| 9 | * Copyright (c) 2002 Alex Züpke <azu@sysgo.de> |
| 10 | * Copyright (c) 2002 Gary Jennejohn <garyj@denx.de> |
| 11 | * Copyright (c) 2003 Richard Woodruff <r-woodruff2@ti.com> |
| 12 | * Copyright (c) 2003 Kshitij <kshitij@ti.com> |
| 13 | * Copyright (c) 2006-2008 Syed Mohammed Khasim <x0khasim@ti.com> |
| 14 | * Copyright (c) 2013 The Chromium OS Authors |
| 15 | * |
| 16 | * This program is free software; you can redistribute it and/or |
| 17 | * modify it under the terms of the GNU General Public License as |
| 18 | * published by the Free Software Foundation; version 2 of |
| 19 | * the License. |
| 20 | * |
| 21 | * This program is distributed in the hope that it will be useful, |
| 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 24 | * GNU General Public License for more details. |
Gabe Black | f2f817e | 2013-10-01 05:20:17 -0700 | [diff] [blame] | 25 | */ |
| 26 | |
Julius Werner | 64b9ca9 | 2013-12-12 20:24:48 -0800 | [diff] [blame] | 27 | #include <arch/asm.h> |
| 28 | |
Julius Werner | 64b9ca9 | 2013-12-12 20:24:48 -0800 | [diff] [blame] | 29 | ENTRY(_start) |
Gabe Black | f2f817e | 2013-10-01 05:20:17 -0700 | [diff] [blame] | 30 | /* |
Elyes HAOUAS | 777ea89 | 2016-07-29 07:40:41 +0200 | [diff] [blame] | 31 | * Set the CPU to System mode with IRQ and FIQ disabled. Prefetch/Data |
Gabe Black | f2f817e | 2013-10-01 05:20:17 -0700 | [diff] [blame] | 32 | * aborts may happen early and crash before the abort handlers are |
| 33 | * installed, but at least the problem will show up near the code that |
| 34 | * causes it. |
| 35 | */ |
| 36 | msr cpsr_cxf, #0xdf |
| 37 | |
| 38 | /* |
| 39 | * Initialize the stack to a known value. This is used to check for |
| 40 | * stack overflow later in the boot process. |
| 41 | */ |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 42 | ldr r0, =_stack |
| 43 | ldr r1, =_estack |
Gabe Black | f2f817e | 2013-10-01 05:20:17 -0700 | [diff] [blame] | 44 | ldr r2, =0xdeadbeef |
| 45 | init_stack_loop: |
| 46 | str r2, [r0] |
| 47 | add r0, #4 |
| 48 | cmp r0, r1 |
| 49 | bne init_stack_loop |
| 50 | |
David Hendricks | a4a44a7 | 2013-10-03 14:02:45 -0700 | [diff] [blame] | 51 | /* Set stackpointer in internal RAM to call bootblock main() */ |
Gabe Black | f2f817e | 2013-10-01 05:20:17 -0700 | [diff] [blame] | 52 | call_bootblock: |
Julius Werner | ec5e5e0 | 2014-08-20 15:29:56 -0700 | [diff] [blame] | 53 | ldr sp, =_estack /* Set up stack pointer */ |
Gabe Black | f2f817e | 2013-10-01 05:20:17 -0700 | [diff] [blame] | 54 | ldr r0,=0x00000000 |
| 55 | /* |
| 56 | * The current design of cpu_info places the |
| 57 | * struct at the top of the stack. The number of |
| 58 | * words pushed must be at least as large as that |
| 59 | * struct. |
| 60 | */ |
| 61 | push {r0-r2} |
| 62 | bic sp, sp, #7 /* 8-byte alignment for ABI compliance */ |
| 63 | /* |
| 64 | * Use "bl" instead of "b" even though we do not intend to return. |
| 65 | * "bl" gets compiled to "blx" if we're transitioning from ARM to |
| 66 | * Thumb. However, "b" will not and GCC may attempt to create a |
| 67 | * wrapper which is currently broken. |
| 68 | */ |
| 69 | bl main |
Julius Werner | 64b9ca9 | 2013-12-12 20:24:48 -0800 | [diff] [blame] | 70 | ENDPROC(_start) |