summaryrefslogtreecommitdiff
path: root/firmware/decompressor
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/decompressor')
-rw-r--r--firmware/decompressor/Makefile2
-rw-r--r--firmware/decompressor/decompressor.c33
-rwxr-xr-xfirmware/decompressor/startup.S57
3 files changed, 68 insertions, 24 deletions
diff --git a/firmware/decompressor/Makefile b/firmware/decompressor/Makefile
index 99e91aa35e..29a78523ea 100644
--- a/firmware/decompressor/Makefile
+++ b/firmware/decompressor/Makefile
@@ -21,7 +21,7 @@ MEMORYSIZE = 2
21 21
22LDS := link.lds 22LDS := link.lds
23LINKFILE = $(OBJDIR)/linkage.lds 23LINKFILE = $(OBJDIR)/linkage.lds
24OBJS := $(OBJDIR)/decompressor.o $(OBJDIR)/rockboxucl.o 24OBJS := $(OBJDIR)/decompressor.o $(OBJDIR)/rockboxucl.o $(OBJDIR)/startup.o
25 25
26CFLAGS = -O -W -Wall -m1 -nostdlib -ffreestanding -Wstrict-prototypes -fomit-frame-pointer -fschedule-insns 26CFLAGS = -O -W -Wall -m1 -nostdlib -ffreestanding -Wstrict-prototypes -fomit-frame-pointer -fschedule-insns
27 27
diff --git a/firmware/decompressor/decompressor.c b/firmware/decompressor/decompressor.c
index 1223ff2f05..9cd7d5998e 100644
--- a/firmware/decompressor/decompressor.c
+++ b/firmware/decompressor/decompressor.c
@@ -31,7 +31,8 @@ extern char imgstart[], imgend[];
31extern char loadaddress[], dramend[]; 31extern char loadaddress[], dramend[];
32 32
33/* Prototypes */ 33/* Prototypes */
34void start(void) __attribute__ ((section (".start"))); 34extern void start(void);
35
35void main(void) ICODE_ATTR; 36void main(void) ICODE_ATTR;
36int ucl_nrv2e_decompress_8(const unsigned char *src, unsigned char *dst, 37int ucl_nrv2e_decompress_8(const unsigned char *src, unsigned char *dst,
37 unsigned long *dst_len) ICODE_ATTR; 38 unsigned long *dst_len) ICODE_ATTR;
@@ -45,22 +46,6 @@ void (*vbr[]) (void) __attribute__ ((section (".vectors"))) =
45 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 46 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
46}; 47};
47 48
48/* Inline copy function */
49static inline void longcopy(long *dst, long *dst_end, const long *src)
50 __attribute__ ((always_inline));
51static inline void longcopy(long *dst, long *dst_end, const long *src)
52{
53 while (dst < dst_end)
54 *dst++ = *src++;
55}
56
57/* Entry point */
58void start(void)
59{
60 longcopy((long *)iramstart, (long *)iramend, (long *)iramcopy);
61 main();
62}
63
64/** All subsequent functions are executed from IRAM **/ 49/** All subsequent functions are executed from IRAM **/
65 50
66/* Thinned out version of the UCL 2e decompression sourcecode 51/* Thinned out version of the UCL 2e decompression sourcecode
@@ -133,18 +118,20 @@ void main(void)
133{ 118{
134 unsigned long dst_len; /* dummy */ 119 unsigned long dst_len; /* dummy */
135 unsigned long img_len = (unsigned long)(imgend - imgstart); 120 unsigned long img_len = (unsigned long)(imgend - imgstart);
136 121 unsigned long *src = (unsigned long *)imgstart;
137 longcopy((long *)(dramend - img_len), (long *) dramend, 122 unsigned long *dst = (unsigned long *)(dramend - img_len);
138 (long *) imgstart); 123
139 124 do
125 *dst++ = *src++;
126 while (dst < (unsigned long *)dramend);
127
140 ucl_nrv2e_decompress_8(dramend - img_len + UCL_HEADER, 128 ucl_nrv2e_decompress_8(dramend - img_len + UCL_HEADER,
141 loadaddress, &dst_len); 129 loadaddress, &dst_len);
142 130
143 asm( 131 asm(
144 "mov.l @%0+,r0 \n" 132 "mov.l @%0+,r0 \n"
145 "mov.l @%0+,r15 \n"
146 "jmp @r0 \n" 133 "jmp @r0 \n"
147 "nop \n" 134 "mov.l @%0+,r15 \n"
148 : : "r"(loadaddress) : "r0" 135 : : "r"(loadaddress) : "r0"
149 ); 136 );
150} 137}
diff --git a/firmware/decompressor/startup.S b/firmware/decompressor/startup.S
new file mode 100755
index 0000000000..62efef9cc3
--- /dev/null
+++ b/firmware/decompressor/startup.S
@@ -0,0 +1,57 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2005 by Jens Arnold
11 * based on crt0.S by Linus Nielsen Feltzing
12 *
13 * All files in this archive are subject to the GNU General Public License.
14 * See the file COPYING in the source tree root for full license agreement.
15 *
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
18 *
19 ****************************************************************************/
20 .section .start,"ax",@progbits
21 .global _start
22_start:
23 /* copy the .iram section */
24 mov.l .iramcopy_k,r0
25 mov.l .iram_k,r1
26 mov.l .iramend_k,r2
27 /* Note: We cannot put a PC relative load into the delay slot of a 'bra'
28 instruction (the offset would be wrong), but there is nothing else to
29 do before the loop, so the delay slot would be 'nop'. The cmp / bf
30 sequence is the same length, but more efficient. */
31 cmp/hi r1,r2
32 bf .noiramcopy
33.iramloop:
34 mov.l @r0+,r3
35 mov.l r3,@r1
36 add #4,r1
37 cmp/hi r1,r2
38 bt .iramloop
39.noiramcopy:
40
41 /* call the mainline */
42 mov.l .main_k,r0
43 mov.l .stackend_k,r15
44 jmp @r0
45 nop
46
47 .align 2
48.iramcopy_k:
49 .long _iramcopy
50.iram_k:
51 .long _iramstart
52.iramend_k:
53 .long _iramend
54.stackend_k:
55 .long _stackend
56.main_k:
57 .long _main