Stefan Reinauer | 8af0d03 | 2012-12-14 13:05:21 -0800 | [diff] [blame] | 1 | /* |
| 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 Werner | 64b9ca9 | 2013-12-12 20:24:48 -0800 | [diff] [blame] | 30 | #include <arch/asm.h> |
Stefan Reinauer | 8af0d03 | 2012-12-14 13:05:21 -0800 | [diff] [blame] | 31 | |
| 32 | /* |
| 33 | * Our entry point |
| 34 | */ |
Julius Werner | 64b9ca9 | 2013-12-12 20:24:48 -0800 | [diff] [blame] | 35 | ENTRY(_entry) |
Stefan Reinauer | 8af0d03 | 2012-12-14 13:05:21 -0800 | [diff] [blame] | 36 | |
Vadim Bendebury | b7f82e9 | 2014-05-27 16:16:50 -0700 | [diff] [blame] | 37 | /* 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. */ |
| 47 | loop: |
| 48 | cmp r2, r3 |
| 49 | str r12, [r2], #4 |
| 50 | blt loop |
| 51 | no_bss: |
Gabe Black | c09cf0b | 2014-02-08 06:30:49 -0800 | [diff] [blame] | 52 | /* Save off the location of the coreboot tables */ |
| 53 | ldr r1, 1f |
| 54 | str r0, [r1] |
| 55 | |
Gabe Black | a0e2797 | 2013-02-26 19:08:28 -0800 | [diff] [blame] | 56 | /* Setup new stack */ |
Gabe Black | c09cf0b | 2014-02-08 06:30:49 -0800 | [diff] [blame] | 57 | ldr sp, 2f |
Gabe Black | a0e2797 | 2013-02-26 19:08:28 -0800 | [diff] [blame] | 58 | |
Julius Werner | 64b9ca9 | 2013-12-12 20:24:48 -0800 | [diff] [blame] | 59 | /* TODO: Save old stack pointer and link register */ |
Stefan Reinauer | 8af0d03 | 2012-12-14 13:05:21 -0800 | [diff] [blame] | 60 | |
| 61 | /* Let's rock. */ |
Julius Werner | 64b9ca9 | 2013-12-12 20:24:48 -0800 | [diff] [blame] | 62 | bl start_main |
Stefan Reinauer | 8af0d03 | 2012-12-14 13:05:21 -0800 | [diff] [blame] | 63 | |
Julius Werner | 64b9ca9 | 2013-12-12 20:24:48 -0800 | [diff] [blame] | 64 | /* %r0 has the return value - pass it on unmolested */ |
| 65 | |
| 66 | /* TODO: restore old stack pointer and link register */ |
Stefan Reinauer | 8af0d03 | 2012-12-14 13:05:21 -0800 | [diff] [blame] | 67 | |
| 68 | /* Return to the original context. */ |
Julius Werner | 64b9ca9 | 2013-12-12 20:24:48 -0800 | [diff] [blame] | 69 | bx lr |
| 70 | ENDPROC(_entry) |
Julius Werner | 7c6e489 | 2014-01-24 16:23:08 -0800 | [diff] [blame] | 71 | |
| 72 | .align 4 |
Vadim Bendebury | b7f82e9 | 2014-05-27 16:16:50 -0700 | [diff] [blame] | 73 | bss_boundaries: |
| 74 | .word _edata |
| 75 | .word _end |
Julius Werner | 7c6e489 | 2014-01-24 16:23:08 -0800 | [diff] [blame] | 76 | 1: |
Gabe Black | c09cf0b | 2014-02-08 06:30:49 -0800 | [diff] [blame] | 77 | .word cb_header_ptr |
| 78 | 2: |
Julius Werner | 7c6e489 | 2014-01-24 16:23:08 -0800 | [diff] [blame] | 79 | .word _stack |