blob: 788e328322df49eea007c47a8b2ff97af53040ef [file] [log] [blame]
Stefan Reinauer8af0d032012-12-14 13:05:21 -08001/*
2 * This file is part of the libpayload project.
3 *
4 * Copyright (C) 2008 Advanced Micro Devices, Inc.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
Julius Werner64b9ca92013-12-12 20:24:48 -080030#include <arch/asm.h>
Stefan Reinauer8af0d032012-12-14 13:05:21 -080031
32/*
33 * Our entry point
34 */
Julius Werner64b9ca92013-12-12 20:24:48 -080035ENTRY(_entry)
Stefan Reinauer8af0d032012-12-14 13:05:21 -080036
Vadim Bendeburyb7f82e92014-05-27 16:16:50 -070037 /* TODO: disable interrupts */
38
39 /* Clear BSS */
40 mov r12, #0
41 ldr r2, bss_boundaries
42 ldr r3, bss_boundaries + 4
43 cmp r2, r3
44 beq no_bss
45
46 sub r3, #4 /* Account for late condition check. */
47loop:
48 cmp r2, r3
49 str r12, [r2], #4
50 blt loop
51no_bss:
Gabe Blackc09cf0b2014-02-08 06:30:49 -080052 /* Save off the location of the coreboot tables */
53 ldr r1, 1f
54 str r0, [r1]
55
Gabe Blacka0e27972013-02-26 19:08:28 -080056 /* Setup new stack */
Gabe Blackc09cf0b2014-02-08 06:30:49 -080057 ldr sp, 2f
Gabe Blacka0e27972013-02-26 19:08:28 -080058
Julius Werner64b9ca92013-12-12 20:24:48 -080059 /* TODO: Save old stack pointer and link register */
Stefan Reinauer8af0d032012-12-14 13:05:21 -080060
61 /* Let's rock. */
Julius Werner64b9ca92013-12-12 20:24:48 -080062 bl start_main
Stefan Reinauer8af0d032012-12-14 13:05:21 -080063
Julius Werner64b9ca92013-12-12 20:24:48 -080064 /* %r0 has the return value - pass it on unmolested */
65
66 /* TODO: restore old stack pointer and link register */
Stefan Reinauer8af0d032012-12-14 13:05:21 -080067
68 /* Return to the original context. */
Julius Werner64b9ca92013-12-12 20:24:48 -080069 bx lr
70ENDPROC(_entry)
Julius Werner7c6e4892014-01-24 16:23:08 -080071
72.align 4
Vadim Bendeburyb7f82e92014-05-27 16:16:50 -070073bss_boundaries:
74 .word _edata
75 .word _end
Julius Werner7c6e4892014-01-24 16:23:08 -0800761:
Gabe Blackc09cf0b2014-02-08 06:30:49 -080077.word cb_header_ptr
782:
Julius Werner7c6e4892014-01-24 16:23:08 -080079.word _stack