1/**
2 * \file
3 * \brief Bootstrap the bootloader.
4 */
5
6/*
7 * Copyright (c) 2007, 2008, 2009, 2010, ETH Zurich.
8 * All rights reserved.
9 *
10 * This file is distributed under the terms in the attached LICENSE file.
11 * If you do not find this file, copies can be found by writing to:
12 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
13 */
14
15/*
16 * This is the entry point called from the gem5 bootloader. It loads and relocates the
17 * kernel image, and sets some global parameters passed along to the kernel
18 * On entry:
19 *
20 * r0 contains zero
21 * r1 contains board id
22 * r2 atags ptr
23 * r3 kernel start address
24 * r4 GIC address
25 * r5 flag register address
26 */
27    .syntax unified
28	.text
29//	.arm    //interferes with thumb code
30	.globl	molly_start, molly_to_kernel_transition
31	//.extern cd, kernel_entry
32
33        // ........................................
34        //
35        // Entry point.  Initialize a stack and branch to the
36        // C entry point in molly_init.c
37molly_start:
38	ldr		r6, =molly_kernel_stack
39	add	    r6, r6, #2048//done in two steps to make sure it is thumb-compatible
40	add     r6, r6, #2048
41	mov     sp, r6
42	b		molly_init
43
44        // Never reached
45halt:
46	b	halt
47
48        // ........................................
49        //
50        // Transfer control to the proper kernel once it has
51        // been loaded and relocated.  The caller supplies the
52        // r0 value through which the kernel expects
53        // the core_data info.
54molly_to_kernel_transition:
55#ifdef __thumb2__
56//in thumb, the lsb of the starting address must be 1
57        mov     r6, #1
58        orr     r0, r0, r6
59#endif
60        mov     lr, r0
61        mov     r0, r1
62        bx		lr
63
64        // ........................................
65        //
66        // Stack for use by the C molly kernel.
67
68        .data
69molly_kernel_stack:
70        .skip   4096
71
72