summaryrefslogtreecommitdiff
path: root/firmware/decompressor/decompressor.c
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2005-11-28 23:40:57 +0000
committerJens Arnold <amiconn@rockbox.org>2005-11-28 23:40:57 +0000
commit104b81ea9a1a9c7b67e9e060fef4d0a97a547b7b (patch)
tree5234c4b9fe280b128bac7bc5ccbbeb7e7ac90915 /firmware/decompressor/decompressor.c
parentd371141493a6863890e3867e5fef4f9c1b9d3add (diff)
downloadrockbox-104b81ea9a1a9c7b67e9e060fef4d0a97a547b7b.tar.gz
rockbox-104b81ea9a1a9c7b67e9e060fef4d0a97a547b7b.zip
Fixed self-extracting loader: (1) Proper startup code, ensuring the stack pointer is set to the desired location. (2) Code cleanup.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8103 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/decompressor/decompressor.c')
-rw-r--r--firmware/decompressor/decompressor.c33
1 files changed, 10 insertions, 23 deletions
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}