1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * linux/arch/unicore32/boot/compressed/head.S
5 * Code specific to PKUnity SoC and UniCore ISA
7 * Copyright (C) 2001-2010 GUAN Xue-tao
9 #include <linux/linkage.h>
10 #include <mach/memory.h>
14 #define nop8 nop; nop; nop; nop; nop; nop; nop; nop
16 .section ".start", #alloc, #execinstr
21 /* Initialize ASR, PRIV mode and INTR off */
26 ldm (r1, r2, r3, r5, r6, r7, r8), [r0]+
28 sub.a r0, r0, r1 @ calculate the delta offset
31 * if delta is zero, we are running at the address
37 * We're running at a different address. We need to fix
38 * up various pointers:
39 * r5 - zImage base address (_start)
48 * we need to fix up pointers into the BSS region.
58 * Relocate all entries in the GOT table.
59 * This fixes up the C references.
63 1001: ldw r1, [r7+], #0
76 1002: stw.w r0, [r2]+, #4
84 movc p0.c5, r0, #28 @ cache invalidate all
86 movc p0.c6, r0, #6 @ tlb invalidate all
89 mov r0, #0x1c @ en icache and wb dcache
94 * Set up some pointers, for starting decompressing.
97 mov r1, sp @ malloc space above stack
98 add r2, sp, #0x10000 @ 64k max
101 * Check to see if we will overwrite ourselves.
102 * r4 = final kernel address
103 * r5 = start of this image
104 * r6 = size of decompressed image
105 * r2 = end of malloc space (and therefore this image)
108 * r4 + image length <= r5 -> OK
110 ldw r4, =KERNEL_IMAGE_START
118 * If overwrite, just print error message
123 * We're not in danger of overwriting ourselves.
124 * Do this the simple way.
131 * r2: free_mem_ptr_end_p
134 b.l decompress_kernel @ C functions
137 * Clean and flush the cache to maintain consistency.
140 movc p0.c5, r0, #14 @ flush dcache
142 movc p0.c5, r0, #20 @ icache invalidate all
146 * Turn off the Cache and MMU.
148 mov r0, #0 @ disable i/d cache and MMU
152 mov r0, #0 @ must be zero
153 ldw r4, =KERNEL_IMAGE_START
154 mov pc, r4 @ call kernel
160 .word __bss_start @ r2
163 .word _image_size @ r6
164 .word _got_start @ r7
166 .word decompress_stack_end @ sp
170 #ifdef CONFIG_DEBUG_OCD
171 2001: ldb.w r1, [r0]+, #1
193 str_error: .asciz "\nError: Kernel address OVERWRITE\n"
199 .section ".stack", "aw", %nobits
200 decompress_stack: .space 4096
201 decompress_stack_end: