2 * Copyright (C) 2009 Thomas Chou <thomas@wytron.com.tw>
4 * Based on arch/nios2/kernel/head.S
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
13 * This code can be loaded anywhere, eg FLASH ROM as reset vector,
14 * as long as output does not overlap it.
17 #include <linux/linkage.h>
18 #include <asm/cache.h>
23 wrctl status, r0 /* disable interrupt */
24 /* invalidate all instruction cache */
25 movia r1, NIOS2_ICACHE_SIZE
26 movui r2, NIOS2_ICACHE_LINE_SIZE
30 /* invalidate all data cache */
31 movia r1, NIOS2_DCACHE_SIZE
32 movui r2, NIOS2_DCACHE_LINE_SIZE
37 nextpc r1 /* Find out where we are */
40 beq r1, r2, finish_move /* We are running in correct address,
42 /* move code, r1: src, r2: dest, r3: last dest */
43 addi r1, r1, (_start - chkadr) /* Source */
44 movia r2, _start /* Destination */
45 movia r3, __bss_start /* End of copy */
46 1: ldw r8, 0(r1) /* load a word from [r1] */
47 stw r8, 0(r2) /* stort a word to dest [r2] */
48 addi r1, r1, 4 /* inc the src addr */
49 addi r2, r2, 4 /* inc the dest addr */
51 /* flush the data cache after moving */
52 movia r1, NIOS2_DCACHE_SIZE
53 movui r2, NIOS2_DCACHE_LINE_SIZE
58 jmp r1 /* jmp to linked address */
61 /* zero out the .bss segment (uninitialized common data) */
62 movia r2, __bss_start /* presume nothing is between */
63 movia r1, _end /* the .bss and _end. */
68 * set up the stack pointer, some where higher than _end.
69 * The stack space must be greater than 32K for decompress.
73 /* save args passed from u-boot, maybe */
79 /* decompress the kernel */
80 call decompress_kernel
81 /* pass saved args to kernel */
87 /* flush all data cache after decompressing */
88 movia r1, NIOS2_DCACHE_SIZE
89 movui r2, NIOS2_DCACHE_LINE_SIZE
93 /* flush all instruction cache */
94 movia r1, NIOS2_ICACHE_SIZE
95 movui r2, NIOS2_ICACHE_LINE_SIZE
100 /* jump to start real kernel */
101 movia r1, (CONFIG_NIOS2_MEM_BASE | CONFIG_NIOS2_KERNEL_REGION_BASE)
105 fake_headers_as_bzImage: