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 #define MIMIC_A_VMLINUZ
14 .section .text.init,#alloc,#execinstr
15 .type _start,#function
18 /* Some bootloaders like it this way, for others it won't harm */
19 #ifdef MIMIC_A_VMLINUZ
35 * It might be the case that we're not run at the position where we
36 * have been linked to. If this is the case we copy ourselves to the
37 * position we're linked to.
39 adr r4, run /* Running version */
40 ldr r5, .LCrun /* supposed to be version */
41 cmp r4, r5 /* If equal ... */
42 beq run /* ... go to run */
44 /* Figure how to move */
46 subs r8, r5, r4 /* r8 is the distance between the blocks */
49 /* Copy before, copy forwards */
50 /* First, copy our copy loop to the very beginning to avoid code
52 mov r2, r5 /* r2: run address */
72 /* Copy behind, copy backwards */
74 sub r8, r7, r8 /* r8 points to the end of source image */
75 3: ldr r6, [r8, #-4]! /* Take bytes */
76 str r6, [r7, #-4]! /* Put bytes */
83 .LCstart_bin: .word _start
84 .LCend_bin: .word _module_data_end
88 sub r1, r1, #1 /* r1 == 0xfff */
89 mrc p15, 0, r0, c0, c0, 0 /* Main ID */
93 /* Check for processors that understand CPU ID */
102 bne do_bootstrap /* None matched, normal startup */
105 mrc p15, 0, r0, c0, c0, 5 /* CPU ID */
106 and r0, r0, #0xf /* CPU id */
107 cmp r0, #0 /* CPU0 continues with bootstrap */
110 /* CPU1+ wait for bootup */
113 mrc p15, 0, r0, c1, c0, 0
114 orr r0, r0, #(1 << 12)
115 mcr p15, 0, r0, c1, c0, 0
122 #ifdef PLATFORM_TYPE_rv
123 // enable GIC CPU interface + prio mask for IRQs
125 // get board ID and retrieve MPCore-base from table
129 adr r6, .Lmpcore_base_table
151 .word 0xe320f003 /* wfi */
158 .word 0x1190f500 /* Board ID */
159 .word 0x1e000000 /* MPCore base */
161 /* Default value (with #0) must come last! */
167 1: .word 0xe320f003 /* wfi */
172 ldr r3, .LCcrt0_tramppage /* Load address of tramppage var */
173 str sp, [r3] /* Store SP in variable */
179 .LCcrt0_tramppage: .word crt0_tramppage
180 .LCstack: .word crt0_stack_high
184 .global crt0_tramppage
188 .global crt0_stack_low
192 .global crt0_stack_high