1 /* SPDX-License-Identifier: GPL-2.0 */
2 #include <variant/core.h>
4 #include <asm/asmmacro.h>
5 #include <asm/cacheasm.h>
7 * RB-Data: RedBoot data/bss
11 * The Linux-Kernel image including the loader must be loaded
12 * to a position so that the kernel and the boot parameters
13 * can fit in the space before the load address.
14 * ______________________________________________________
15 * |_RB-Data_|_P_|__________|_L_|___Linux-Kernel___|______|
18 * ______________________________________________________
19 * |___Linux-Kernel___|_P_|_L_|___________________________|
21 * The loader copies the parameter to the position that will
22 * be the end of the kernel and itself to the end of the
26 /* Make sure we have enough space for the 'uncompressor' */
28 #define STACK_SIZE 32768
29 #define HEAP_SIZE (131072*4)
32 # a3: Size of parameter list
37 /* this must be the first byte of the loader! */
39 entry sp, 32 # we do not intend to return
46 .begin literal_prefix .text
48 /* put literals in here! */
53 /* 'reset' window registers */
69 /* copy the loader to its address
70 * Note: The loader itself is a very small piece, so we assume we
71 * don't partially overlap. We also assume (even more important)
72 * that the kernel image is out of the way. Usually, when the
73 * load address of this image is not at an arbitrary address,
74 * but aligned to some 10K's we shouldn't overlap.
77 /* Note: The assembler cannot relax "addi a0, a0, ..." to an
78 l32r, so we load to a4 first. */
80 # addi a4, a0, __start - __start_a0
91 # a0: address where this code has been loaded
92 # a4: compiled address of __start
93 # a5: compiled end address
112 /* We have to flush and invalidate the caches here before we jump. */
114 #if XCHAL_DCACHE_IS_WRITEBACK
116 ___flush_dcache_all a5 a6
120 ___invalidate_icache_all a5 a6
129 /* RedBoot is now at the end of the memory, so we don't have
130 * to copy the parameter list. Keep the code around; in case
131 * we need it again. */
134 # a2: start address of parameter list
135 # a3: length of parameter list
138 /* copy the parameter list out of the way */
140 movi a6, _param_start
150 /* clear BSS section */
160 movi a1, _stack + STACK_SIZE
163 /* Uncompress the kernel */
169 movi a3, __image_load
174 # a8(a4) Load address of the image
176 movi a6, _image_start
186 # a7 maximum size of destination
199 # a6 destination start
200 # a7 maximum size of destination
203 # a10 destination end
219 /* jump to the kernel */
221 #if XCHAL_DCACHE_IS_WRITEBACK
223 ___flush_dcache_all a5 a6
227 ___invalidate_icache_all a5 a6
231 # a2 Boot parameter list
233 movi a0, _image_start
243 .long _heap + HEAP_SIZE
245 .comm _stack, STACK_SIZE
246 .comm _heap, HEAP_SIZE