blob: 0391ebf1ac363f11efbd20ff89d8de84f283d458 [file] [log] [blame]
Gabe Blackf2f817e2013-10-01 05:20:17 -07001/*
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 Blackf2f817e2013-10-01 05:20:17 -070025 */
26
Julius Werner64b9ca92013-12-12 20:24:48 -080027#include <arch/asm.h>
28
Julius Werner64b9ca92013-12-12 20:24:48 -080029ENTRY(_start)
Gabe Blackf2f817e2013-10-01 05:20:17 -070030 /*
Elyes HAOUAS777ea892016-07-29 07:40:41 +020031 * Set the CPU to System mode with IRQ and FIQ disabled. Prefetch/Data
Gabe Blackf2f817e2013-10-01 05:20:17 -070032 * 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 Wernerec5e5e02014-08-20 15:29:56 -070042 ldr r0, =_stack
43 ldr r1, =_estack
Gabe Blackf2f817e2013-10-01 05:20:17 -070044 ldr r2, =0xdeadbeef
45init_stack_loop:
46 str r2, [r0]
47 add r0, #4
48 cmp r0, r1
49 bne init_stack_loop
50
David Hendricksa4a44a72013-10-03 14:02:45 -070051/* Set stackpointer in internal RAM to call bootblock main() */
Gabe Blackf2f817e2013-10-01 05:20:17 -070052call_bootblock:
Julius Wernerec5e5e02014-08-20 15:29:56 -070053 ldr sp, =_estack /* Set up stack pointer */
Gabe Blackf2f817e2013-10-01 05:20:17 -070054 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 Werner64b9ca92013-12-12 20:24:48 -080070ENDPROC(_start)