* 24-Apr-2005 Oleg I. Vdovikin
* reordered functions using lds script, removed forward decl
*
+ * 24-Mar-2007 Gabor Juhos
+ * pass original values of the a0,a1,a2,a3 registers to the kernel
+ *
*/
#include "LzmaDecode.h"
unsigned int offset;
unsigned char *data;
+typedef void (*kernel_entry)(unsigned long reg_a0, unsigned long reg_a1,
+ unsigned long reg_a2, unsigned long reg_a3);
+
/* flash access should be aligned, so wrapper is used */
/* read byte from the flash, all accesses are 32-bit aligned */
static int read_byte(void *object, unsigned char **buffer, UInt32 *bufferSize)
}
/* should be the first function */
-void entry(unsigned long icache_size, unsigned long icache_lsize,
+void entry(unsigned long reg_a0, unsigned long reg_a1,
+ unsigned long reg_a2, unsigned long reg_a3,
+ unsigned long icache_size, unsigned long icache_lsize,
unsigned long dcache_size, unsigned long dcache_lsize)
{
unsigned int i; /* temp value */
/* Jump to load address */
uart_write_str("ok\r\n");
- ((void (*)(void)) LOADADDR)();
+ ((kernel_entry) LOADADDR)(reg_a0, reg_a1, reg_a2, reg_a3);
}
uart_write_str("failed\r\n");
while (1 );
+/* Copyright 2007 Gabor Juhos */
+/* keep original values of the a0,a1,a2,a3 registers */
+/* cache manipulation adapted from Broadcom code */
/* Copyright 2005 Oleg I. Vdovikin (oleg@cs.msu.su) */
/* cache manipulation adapted from Broadcom code */
/* idea taken from original bunzip2 decompressor code */
.set noreorder
/* Copy decompressor code to the right place */
- li t2, BZ_TEXT_START
- add a0, t2, 0
- la a1, code_start
- la a2, code_stop
+ li t0, BZ_TEXT_START
+
+ la t1, code_start
+ la t2, code_stop
$L1:
- lw t0, 0(a1)
- sw t0, 0(a0)
- add a1, 4
- add a0, 4
- blt a1, a2, $L1
- nop
-
+ lw t3, 0(t1)
+ sw t3, 0(t0)
+ add t1, 4
+ blt t1, t2, $L1
+ add t0, 4
+
/* At this point we need to invalidate dcache and */
/* icache before jumping to new code */
addu t0,s3
noic:
- move a0,s3 /* icache line size */
- move a1,s4 /* icache size */
- move a2,s1 /* dcache line size */
- jal t2
- move a3,s2 /* dcache size */
+ li t0, BZ_TEXT_START
+
+ addiu sp, -32 /* reserve stack for parameters */
+#if 0
+ sw a0, 0(sp)
+ sw a1, 4(sp)
+ sw a2, 8(sp)
+ sw a3, 12(sp)
+#endif
+ sw s3, 16(sp) /* icache line size */
+ sw s4, 20(sp) /* icache size */
+ sw s1, 24(sp) /* dcache line size */
+ jr t0
+ sw s2, 28(sp) /* dcache size */
.set reorder
END(startup)