4f735fd28c34250a39daa44ee605387e5b515e1f
[processor-sdk/open-amp.git] / obsolete / system / generic / machine / zynq7 / linux-firmware / boot_wrapper.S
1 @*
2 @* Copyright (c) 2014, Mentor Graphics Corporation
3 @* All rights reserved.
4 @*
5 @* Redistribution and use in source and binary forms, with or without
6 @* modification, are permitted provided that the following conditions are met:
7 @*
8 @* 1. Redistributions of source code must retain the above copyright notice,
9 @* this list of conditions and the following disclaimer.
10 @* 2. Redistributions in binary form must reproduce the above copyright notice,
11 @* this list of conditions and the following disclaimer in the documentation
12 @* and/or other materials provided with the distribution.
13 @* 3. Neither the name of Mentor Graphics Corporation nor the names of its
14 @* contributors may be used to endorse or promote products derived from this
15 @* software without specific prior written permission.
16 @*
17 @* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 @* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 @* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 @* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 @* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 @* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 @* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 @* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 @* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 @* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 @* POSSIBILITY OF SUCH DAMAGE.
31 .extern boot_linux
32 .extern _bss_end
33 .extern linux_kernel_start
34 .extern dtb_start
36 @ include FIT format linux image
37 .section fit_image, "a"
38 .incbin "libs/system/zc702evk/linux/image.ub";
40 .section bootwrapper, "ax"
42 .code 32
44 BOOTSTRAP_BSS_End:
45 .long _bss_end
47 .global bootwrapper_start
48 bootwrapper_start:
50 MOV r0, #0xdF
52 @ Switch to SVC mode with IRQs and FIQs OFF
53 MSR CPSR_cxsf, r0
55 @ Disable MMU and caches
57 MRC p15,#0,r0,c1,c0,#0
58 BIC r0,r0,#0x00001000 @ Clear I bit to disable instruction cache
59 BIC r0,r0,#0x00000005 @ Clear C and M bits (-C-M)
61 @ Disable alignment checking
62 BIC r0,r0,#0x00000002 @ Clear alignement checking bit
64 MCR p15,#0,r0,c1,c0,#0
66 MRC p15,#0,r0,c1,c0,#2
67 MOV r1,#0xF0
68 LSL r1,r1,#16
69 ORR r0,r0,r1
70 MCR p15,#0,r0,c1,c0,#2
73 MOV r0,#0x40000000
74 FMXR FPEXC,r0
77 @ Setup stack pointer for function calls
78 LDR r0, BOOTSTRAP_BSS_End
80 ADD r0,r0,#64512
82 @ align stack pointer
83 BIC r0,r0,#0x07
84 MOV sp,r0
86 @ branch to C linux boot function
87 B boot_linux
89 .code 32
90 .global start_linux_with_dtb
91 .type start_linux_with_dtb, %function
92 start_linux_with_dtb:
94 @ Set registers as per Linux boot requirements
95 @ For details see:
96 @ https://www.kernel.org/doc/Documentation/arm/Booting
98 MOV r0, #0 @ Set r0 =0
100 LDR r1, =3343 @ Set r1 = machine type (Xilinx)
102 LDR r4, =dtb_start
104 LDR r2, [r4] @ Point r2 to DTB
106 MOV r3, #0
108 LDR r4, =linux_kernel_start
110 LDR lr, [r4]
112 MOV pc, lr @ Jump to start of Linux kernel binary