2
* linux/arch/unicore32/boot/compressed/head.S
4
* Code specific to PKUnity SoC and UniCore ISA
6
* Copyright (C) 2001-2010 GUAN Xue-tao
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License version 2 as
10
* published by the Free Software Foundation.
12
#include <linux/linkage.h>
13
#include <mach/memory.h>
17
#define nop8 nop; nop; nop; nop; nop; nop; nop; nop
19
.section ".start", #alloc, #execinstr
24
/* Initialize ASR, PRIV mode and INTR off */
29
ldm (r1, r2, r3, r5, r6, r7, r8), [r0]+
31
sub.a r0, r0, r1 @ calculate the delta offset
34
* if delta is zero, we are running at the address
40
* We're running at a different address. We need to fix
41
* up various pointers:
42
* r5 - zImage base address (_start)
51
* we need to fix up pointers into the BSS region.
61
* Relocate all entries in the GOT table.
62
* This fixes up the C references.
66
1001: ldw r1, [r7+], #0
79
1002: stw.w r0, [r2]+, #4
87
movc p0.c5, r0, #28 @ cache invalidate all
89
movc p0.c6, r0, #6 @ tlb invalidate all
92
mov r0, #0x1c @ en icache and wb dcache
97
* Set up some pointers, for starting decompressing.
100
mov r1, sp @ malloc space above stack
101
add r2, sp, #0x10000 @ 64k max
104
* Check to see if we will overwrite ourselves.
105
* r4 = final kernel address
106
* r5 = start of this image
107
* r6 = size of decompressed image
108
* r2 = end of malloc space (and therefore this image)
111
* r4 + image length <= r5 -> OK
113
ldw r4, =KERNEL_IMAGE_START
121
* If overwrite, just print error message
126
* We're not in danger of overwriting ourselves.
127
* Do this the simple way.
134
* r2: free_mem_ptr_end_p
137
b.l decompress_kernel @ C functions
140
* Clean and flush the cache to maintain consistency.
143
movc p0.c5, r0, #14 @ flush dcache
145
movc p0.c5, r0, #20 @ icache invalidate all
149
* Turn off the Cache and MMU.
151
mov r0, #0 @ disable i/d cache and MMU
155
mov r0, #0 @ must be zero
156
ldw r4, =KERNEL_IMAGE_START
157
mov pc, r4 @ call kernel
163
.word __bss_start @ r2
166
.word _image_size @ r6
167
.word _got_start @ r7
169
.word decompress_stack_end @ sp
173
#ifdef CONFIG_DEBUG_OCD
174
2001: ldb.w r1, [r0]+, #1
196
str_error: .asciz "\nError: Kernel address OVERWRITE\n"
202
.section ".stack", "aw", %nobits
203
decompress_stack: .space 4096
204
decompress_stack_end: