2 * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
3 * Frank Mehnert <fm3@os.inf.tu-dresden.de>
4 * economic rights: Technische Universität Dresden (Germany)
6 * This file is part of TUD:OS and distributed under the terms of the
7 * GNU General Public License 2.
8 * Please see the COPYING-GPL-2 file for details.
12 .section .text.init,#alloc,#execinstr
13 .type _start,#function
17 * It might be the case that we're not run at the position where we
18 * have been linked to. If this is the case we copy ourselves to the
19 * position we're linked to.
21 adr r4, run /* Running version */
22 ldr r5, .LCrun /* supposed to be version */
23 cmp r4, r5 /* If equal ... */
24 beq run /* ... go to run */
26 /* Figure how to move */
28 subs r8, r5, r4 /* r8 is the distance between the blocks */
31 /* Copy before, copy forwards */
32 /* First, copy our copy loop to the very beginning to avoid code
34 mov r2, r5 /* r2: run address */
54 /* Copy behind, copy backwards */
56 sub r8, r7, r8 /* r8 points to the end of source image */
57 3: ldr r6, [r8, #-4]! /* Take bytes */
58 str r6, [r7, #-4]! /* Put bytes */
65 .LCstart_bin: .word _start
66 .LCend_bin: .word _module_data_end
70 sub r1, r1, #1 /* r1 == 0xfff */
71 mrc p15, 0, r0, c0, c0, 0 /* Main ID */
75 /* Check for processors that understand CPU ID */
84 bne do_bootstrap /* None matched, normal startup */
87 mrc p15, 0, r0, c0, c0, 5 /* CPU ID */
88 and r0, r0, #0xf /* CPU id */
89 cmp r0, #0 /* CPU0 continues with bootstrap */
92 /* CPU1+ wait for bootup */
95 mrc p15, 0, r0, c1, c0, 0
96 orr r0, r0, #(1 << 12)
97 mcr p15, 0, r0, c1, c0, 0
104 // enable GIC CPU interface + prio mask for IRQs
117 .word 0xe320f003 /* wfi */
123 ldr r3, .LCcrt0_tramppage /* Load address of tramppage var */
124 str sp, [r3] /* Store SP in variable */
130 .LCcrt0_tramppage: .word crt0_tramppage
131 .LCstack: .word crt0_stack_high
135 .global crt0_tramppage
139 .global crt0_stack_low
143 .global crt0_stack_high