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 /* Disable caches as we're moving code around */
45 mcr p15, 0, r3, c7, c5, 0 /* ICIALLU */
46 mrc p15, 0, r0, c1, c0
49 mcr p15, 0, r0, c1, c0
51 /* Figure how to move */
53 subs r8, r5, r4 /* r8 is the distance between the blocks */
56 /* Copy before, copy forwards */
57 /* First, copy our copy loop to the very beginning to avoid code
59 mov r9, r5 /* r9: run address */
79 /* Copy behind, copy backwards */
81 sub r8, r7, r8 /* r8 points to the end of source image */
82 3: ldr r6, [r8, #-4]! /* Take bytes */
83 str r6, [r7, #-4]! /* Put bytes */
90 .LCstart_bin: .word _start
91 .LCend_bin: .word _module_data_end
95 sub r3, r3, #1 /* r3 == 0xfff */
96 mrc p15, 0, r0, c0, c0, 0 /* Main ID */
100 /* Check for processors that understand CPU ID */
109 bne do_bootstrap /* None matched, normal startup */
112 mrc p15, 0, r0, c0, c0, 5 /* CPU ID */
113 and r0, r0, #0xf /* CPU id */
114 cmp r0, #0 /* CPU0 continues with bootstrap */
117 /* CPU1+ wait for bootup */
120 mrc p15, 0, r0, c1, c0, 0
121 orr r0, r0, #(1 << 12)
122 mcr p15, 0, r0, c1, c0, 0
129 #if defined(PLATFORM_TYPE_rv) || defined(PLATFORM_TYPE_rv_pbx) || defined(PLATFORM_TYPE_rv_vexpress)
130 // enable GIC CPU interface + prio mask for IRQs
132 // get board ID and retrieve MPCore-base from table
136 adr r6, .Lmpcore_base_table
158 .inst 0xe320f003 /* wfi */
165 .word 0x1190f500 /* Board ID */
166 .word 0x1e000000 /* MPCore base */
168 /* Default value (with #0) must come last! */
174 1: .word 0xe320f003 /* wfi */
179 ldr r3, .LCcrt0_tramppage /* Load address of tramppage var */
180 str sp, [r3] /* Store SP in variable */
183 mov r0, r2 /* ATAG pointer */
187 .LCcrt0_tramppage: .word crt0_tramppage
188 .LCstack: .word crt0_stack_high
192 .global crt0_tramppage
196 .global crt0_stack_low
200 .global crt0_stack_high