Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux...
[linux-drm-fsl-dcu.git] / arch / avr32 / boot / u-boot / head.S
1 /*
2  * Startup code for use with the u-boot bootloader.
3  *
4  * Copyright (C) 2004-2006 Atmel Corporation
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  */
10 #include <asm/setup.h>
11 #include <asm/thread_info.h>
12 #include <asm/sysreg.h>
13
14         /*
15          * The kernel is loaded where we want it to be and all caches
16          * have just been flushed. We get two parameters from u-boot:
17          *
18          * r12 contains a magic number (ATAG_MAGIC)
19          * r11 points to a tag table providing information about
20          *     the system.
21          */
22         .section .init.text,"ax"
23         .global _start
24 _start:
25         /* Initialize .bss */
26         lddpc   r2, bss_start_addr
27         lddpc   r3, end_addr
28         mov     r0, 0
29         mov     r1, 0
30 1:      st.d    r2++, r0
31         cp      r2, r3
32         brlo    1b
33
34         /* Initialize status register */
35         lddpc   r0, init_sr
36         mtsr    SYSREG_SR, r0
37
38         /* Set initial stack pointer */
39         lddpc   sp, stack_addr
40         sub     sp, -THREAD_SIZE
41
42 #ifdef CONFIG_FRAME_POINTER
43         /* Mark last stack frame */
44         mov     lr, 0
45         mov     r7, 0
46 #endif
47
48         /* Check if the boot loader actually provided a tag table */
49         lddpc   r0, magic_number
50         cp.w    r12, r0
51         brne    no_tag_table
52
53         /*
54          * Save the tag table address for later use. This must be done
55          * _after_ .bss has been initialized...
56          */
57         lddpc   r0, tag_table_addr
58         st.w    r0[0], r11
59
60         /* Jump to loader-independent setup code */
61         rjmp    kernel_entry
62
63         .align  2
64 magic_number:
65         .long   ATAG_MAGIC
66 tag_table_addr:
67         .long   bootloader_tags
68 bss_start_addr:
69         .long   __bss_start
70 end_addr:
71         .long   _end
72 init_sr:
73         .long   0x007f0000      /* Supervisor mode, everything masked */
74 stack_addr:
75         .long   init_thread_union
76 panic_addr:
77         .long   panic
78
79 no_tag_table:
80         sub     r12, pc, (. - 2f)
81         /* branch to panic() which can be far away with that construct */
82         lddpc   pc, panic_addr
83 2:      .asciz  "Boot loader didn't provide correct magic number\n"