summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2008-10-30 00:17:45 +0000
committerJens Arnold <amiconn@rockbox.org>2008-10-30 00:17:45 +0000
commite13e318c3748a0db8e2a81447fb8e234a6c2581b (patch)
tree554c1a93510cfc26613e76751450ff51d2d11a8b
parentc91d7873c79103f9e6ef00cedbec7ad9410c7666 (diff)
downloadrockbox-e13e318c3748a0db8e2a81447fb8e234a6c2581b.tar.gz
rockbox-e13e318c3748a0db8e2a81447fb8e234a6c2581b.zip
Use the asm optimised UCL decompressor for the flash bootloader as well. Verified working on Player, Recorder v1, Ondio SP and Ondio FM.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18928 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--flash/bootloader/Makefile9
-rw-r--r--flash/bootloader/bootloader.c69
-rw-r--r--flash/bootloader/bootloader.h1
-rw-r--r--flash/bootloader/bootloader.lds2
-rw-r--r--flash/bootloader/no_rom.lds2
5 files changed, 10 insertions, 73 deletions
diff --git a/flash/bootloader/Makefile b/flash/bootloader/Makefile
index e7bd17aae9..edc32113c6 100644
--- a/flash/bootloader/Makefile
+++ b/flash/bootloader/Makefile
@@ -46,7 +46,7 @@ endif
46 46
47SRC := $(wildcard *.c) 47SRC := $(wildcard *.c)
48 48
49OBJS := $(SRC:%.c=$(OBJDIR)/%.o) 49OBJS := $(SRC:%.c=$(OBJDIR)/%.o) $(OBJDIR)/sh_nrv2e_d8.o
50 50
51ifdef NO_ROM 51ifdef NO_ROM
52LINKFILE = $(OBJDIR)/no_rom.lds 52LINKFILE = $(OBJDIR)/no_rom.lds
@@ -64,9 +64,12 @@ ifndef NO_ROM
64 $(TOOLSDIR)/scramble $(OBJDIR)/$(TARGET).bin $(OBJDIR)/$(TARGET).ajz 64 $(TOOLSDIR)/scramble $(OBJDIR)/$(TARGET).bin $(OBJDIR)/$(TARGET).ajz
65endif 65endif
66 66
67$(OBJDIR)/$(TARGET).elf : $(OBJS) 67$(OBJDIR)/$(TARGET).elf : $(OBJS)
68 $(CC) -Os -nostdlib -o $(OBJDIR)/$(TARGET).elf -L$(OBJDIR) -T$(LINKFILE) -Wl,-Map,$(OBJDIR)/$(TARGET).map 68 $(CC) -Os -nostdlib -o $@ $(OBJS) -T$(LINKFILE) -Wl,-Map,$(OBJDIR)/$(TARGET).map
69 69
70# cross-reference, saves code duplication
71$(OBJDIR)/sh_nrv2e_d8.o : ../../firmware/decompressor/sh_nrv2e_d8.S
72 $(CC) $(CFLAGS) -c $< -o $@
70 73
71clean: 74clean:
72 -rm -f \ 75 -rm -f \
diff --git a/flash/bootloader/bootloader.c b/flash/bootloader/bootloader.c
index d1955c2ccd..40c0dc5c54 100644
--- a/flash/bootloader/bootloader.c
+++ b/flash/bootloader/bootloader.c
@@ -29,7 +29,6 @@
29 29
30// prototypes 30// prototypes
31static void PlatformInit(void); 31static void PlatformInit(void);
32static int ucl_nrv2e_decompress_8(const UINT8 *src, UINT8 *dst, UINT32* dst_len);
33static void DecompressStart(tImage* pImage); 32static void DecompressStart(tImage* pImage);
34#ifdef USE_ADC 33#ifdef USE_ADC
35static int ReadADC(int channel); 34static int ReadADC(int channel);
@@ -41,7 +40,7 @@ static void SetLed(BOOL bOn);
41static void UartInit(void); 40static void UartInit(void);
42static UINT8 UartRead(void); 41static UINT8 UartRead(void);
43static void UartWrite(UINT8 byte); 42static void UartWrite(UINT8 byte);
44static void MiniMon(void); 43static void MiniMon(void);
45 44
46 45
47#ifdef NO_ROM 46#ifdef NO_ROM
@@ -188,72 +187,6 @@ static void PlatformInit(void)
188} 187}
189 188
190 189
191/* Thinned out version of the UCL 2e decompression sourcecode
192 * Original (C) Markus F.X.J Oberhumer under GNU GPL license */
193#define GETBIT(bb, src, ilen) \
194 (((bb = bb & 0x7f ? bb*2 : ((unsigned)src[ilen++]*2+1)) >> 8) & 1)
195
196static int ucl_nrv2e_decompress_8(
197 const UINT8 *src, UINT8 *dst, UINT32* dst_len)
198{
199 UINT32 bb = 0;
200 unsigned ilen = 0, olen = 0, last_m_off = 1;
201
202 for (;;)
203 {
204 unsigned m_off, m_len;
205
206 while (GETBIT(bb,src,ilen))
207 {
208 dst[olen++] = src[ilen++];
209 }
210 m_off = 1;
211 for (;;)
212 {
213 m_off = m_off*2 + GETBIT(bb,src,ilen);
214 if (GETBIT(bb,src,ilen)) break;
215 m_off = (m_off-1)*2 + GETBIT(bb,src,ilen);
216 }
217 if (m_off == 2)
218 {
219 m_off = last_m_off;
220 m_len = GETBIT(bb,src,ilen);
221 }
222 else
223 {
224 m_off = (m_off-3)*256 + src[ilen++];
225 if (m_off == 0xffffffff)
226 break;
227 m_len = (m_off ^ 0xffffffff) & 1;
228 m_off >>= 1;
229 last_m_off = ++m_off;
230 }
231 if (m_len)
232 m_len = 1 + GETBIT(bb,src,ilen);
233 else if (GETBIT(bb,src,ilen))
234 m_len = 3 + GETBIT(bb,src,ilen);
235 else
236 {
237 m_len++;
238 do {
239 m_len = m_len*2 + GETBIT(bb,src,ilen);
240 } while (!GETBIT(bb,src,ilen));
241 m_len += 3;
242 }
243 m_len += (m_off > 0x500);
244 {
245 const UINT8 *m_pos;
246 m_pos = dst + olen - m_off;
247 dst[olen++] = *m_pos++;
248 do dst[olen++] = *m_pos++; while (--m_len > 0);
249 }
250 }
251 *dst_len = olen;
252
253 return ilen;
254}
255
256
257/* move the image into place and start it */ 190/* move the image into place and start it */
258static void DecompressStart(tImage* pImage) 191static void DecompressStart(tImage* pImage)
259{ 192{
diff --git a/flash/bootloader/bootloader.h b/flash/bootloader/bootloader.h
index 948311f55d..5811fd0aa4 100644
--- a/flash/bootloader/bootloader.h
+++ b/flash/bootloader/bootloader.h
@@ -77,6 +77,7 @@ typedef struct
77#define FW_VERSION *(unsigned short*)(FLASH_BASE + 0xFE) // firmware version 77#define FW_VERSION *(unsigned short*)(FLASH_BASE + 0xFE) // firmware version
78 78
79// prototypes 79// prototypes
80int ucl_nrv2e_decompress_8(const UINT8 *src, UINT8 *dst, UINT32* dst_len);
80void _main(void) __attribute__ ((section (".startup"))); 81void _main(void) __attribute__ ((section (".startup")));
81int main(void); 82int main(void);
82 83
diff --git a/flash/bootloader/bootloader.lds b/flash/bootloader/bootloader.lds
index 143d83bdc7..ecc1268988 100644
--- a/flash/bootloader/bootloader.lds
+++ b/flash/bootloader/bootloader.lds
@@ -1,5 +1,4 @@
1OUTPUT_FORMAT(elf32-sh) 1OUTPUT_FORMAT(elf32-sh)
2INPUT(bootloader.o)
3 2
4MEMORY 3MEMORY
5{ 4{
@@ -19,6 +18,7 @@ SECTIONS
19 .text : 18 .text :
20 { 19 {
21 *(.text) 20 *(.text)
21 *(.icode)
22 . = ALIGN(0x4); 22 . = ALIGN(0x4);
23 } > IRAM 23 } > IRAM
24 24
diff --git a/flash/bootloader/no_rom.lds b/flash/bootloader/no_rom.lds
index e65e7fdd3c..796fbda4fb 100644
--- a/flash/bootloader/no_rom.lds
+++ b/flash/bootloader/no_rom.lds
@@ -2,7 +2,6 @@
2 where the flash ROM is mirrored to address zero */ 2 where the flash ROM is mirrored to address zero */
3 3
4OUTPUT_FORMAT(elf32-sh) 4OUTPUT_FORMAT(elf32-sh)
5INPUT(bootloader.o)
6 5
7MEMORY 6MEMORY
8{ 7{
@@ -29,6 +28,7 @@ SECTIONS
29 { 28 {
30 _begin_text = .; 29 _begin_text = .;
31 *(.text) 30 *(.text)
31 *(.icode)
32 . = ALIGN(0x4); 32 . = ALIGN(0x4);
33 _end_text = .; 33 _end_text = .;
34 } > IRAM 34 } > IRAM