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
45 .begin literal_prefix .text
47 /* put literals in here! */
52 /* 'reset' window registers */
68 /* copy the loader to its address
69 * Note: The loader itself is a very small piece, so we assume we
70 * don't partially overlap. We also assume (even more important)
71 * that the kernel image is out of the way. Usually, when the
72 * load address of this image is not at an arbitrary address,
73 * but aligned to some 10K's we shouldn't overlap.
76 /* Note: The assembler cannot relax "addi a0, a0, ..." to an
77 l32r, so we load to a4 first. */
79 # addi a4, a0, __start - __start_a0
90 # a0: address where this code has been loaded
91 # a4: compiled address of __start
92 # a5: compiled end address
111 /* We have to flush and invalidate the caches here before we jump. */
113 #if XCHAL_DCACHE_IS_WRITEBACK
115 ___flush_dcache_all a5 a6
119 ___invalidate_icache_all a5 a6
128 /* RedBoot is now at the end of the memory, so we don't have
129 * to copy the parameter list. Keep the code around; in case
130 * we need it again. */
133 # a2: start address of parameter list
134 # a3: length of parameter list
137 /* copy the parameter list out of the way */
139 movi a6, _param_start
149 /* clear BSS section */
159 movi a1, _stack + STACK_SIZE
162 /* Uncompress the kernel */
168 movi a3, __image_load
173 # a8(a4) Load address of the image
175 movi a6, _image_start
185 # a7 maximum size of destination
198 # a6 destination start
199 # a7 maximum size of destination
202 # a10 destination end
218 /* jump to the kernel */
220 #if XCHAL_DCACHE_IS_WRITEBACK
222 ___flush_dcache_all a5 a6
226 ___invalidate_icache_all a5 a6
230 # a2 Boot parameter list
232 movi a0, _image_start
242 .long _heap + HEAP_SIZE
244 .comm _stack, STACK_SIZE
245 .comm _heap, HEAP_SIZE