1 #include <variant/core.h>
3 #include <asm/asmmacro.h>
4 #include <asm/cacheasm.h>
6 * RB-Data: RedBoot data/bss
10 * The Linux-Kernel image including the loader must be loaded
11 * to a position so that the kernel and the boot parameters
12 * can fit in the space before the load address.
13 * ______________________________________________________
14 * |_RB-Data_|_P_|__________|_L_|___Linux-Kernel___|______|
17 * ______________________________________________________
18 * |___Linux-Kernel___|_P_|_L_|___________________________|
20 * The loader copies the parameter to the position that will
21 * be the end of the kernel and itself to the end of the
25 /* Make sure we have enough space for the 'uncompressor' */
27 #define STACK_SIZE 32768
28 #define HEAP_SIZE (131072*4)
31 # a3: Size of parameter list
36 /* this must be the first byte of the loader! */
38 entry sp, 32 # we do not intend to return
44 .begin literal_prefix .text
46 /* put literals in here! */
51 /* 'reset' window registers */
67 /* copy the loader to its address
68 * Note: The loader itself is a very small piece, so we assume we
69 * don't partially overlap. We also assume (even more important)
70 * that the kernel image is out of the way. Usually, when the
71 * load address of this image is not at an arbitrary address,
72 * but aligned to some 10K's we shouldn't overlap.
75 /* Note: The assembler cannot relax "addi a0, a0, ..." to an
76 l32r, so we load to a4 first. */
78 # addi a4, a0, __start - __start_a0
89 # a0: address where this code has been loaded
90 # a4: compiled address of __start
91 # a5: compiled end address
110 /* We have to flush and invalidate the caches here before we jump. */
112 #if XCHAL_DCACHE_IS_WRITEBACK
114 ___flush_dcache_all a5 a6
118 ___invalidate_icache_all a5 a6
127 /* RedBoot is now at the end of the memory, so we don't have
128 * to copy the parameter list. Keep the code around; in case
129 * we need it again. */
132 # a2: start address of parameter list
133 # a3: length of parameter list
136 /* copy the parameter list out of the way */
138 movi a6, _param_start
148 /* clear BSS section */
158 movi a1, _stack + STACK_SIZE
161 /* Uncompress the kernel */
167 movi a3, __image_load
172 # a8(a4) Load address of the image
174 movi a6, _image_start
184 # a7 maximum size of destination
197 # a6 destination start
198 # a7 maximum size of destination
201 # a10 destination end
217 /* jump to the kernel */
219 #if XCHAL_DCACHE_IS_WRITEBACK
221 ___flush_dcache_all a5 a6
225 ___invalidate_icache_all a5 a6
230 movi a3, boot_initrd_start
231 movi a4, boot_initrd_end
237 # a2 Boot parameter list
238 # a3 initrd_start (virtual load address)
239 # a4 initrd_end (virtual load address)
241 movi a0, _image_start
251 .long _heap + HEAP_SIZE
253 .comm _stack, STACK_SIZE
254 .comm _heap, HEAP_SIZE