From e13e318c3748a0db8e2a81447fb8e234a6c2581b Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Thu, 30 Oct 2008 00:17:45 +0000 Subject: 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 --- flash/bootloader/Makefile | 9 ++++-- flash/bootloader/bootloader.c | 69 +---------------------------------------- flash/bootloader/bootloader.h | 1 + flash/bootloader/bootloader.lds | 2 +- flash/bootloader/no_rom.lds | 2 +- 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 SRC := $(wildcard *.c) -OBJS := $(SRC:%.c=$(OBJDIR)/%.o) +OBJS := $(SRC:%.c=$(OBJDIR)/%.o) $(OBJDIR)/sh_nrv2e_d8.o ifdef NO_ROM LINKFILE = $(OBJDIR)/no_rom.lds @@ -64,9 +64,12 @@ ifndef NO_ROM $(TOOLSDIR)/scramble $(OBJDIR)/$(TARGET).bin $(OBJDIR)/$(TARGET).ajz endif -$(OBJDIR)/$(TARGET).elf : $(OBJS) - $(CC) -Os -nostdlib -o $(OBJDIR)/$(TARGET).elf -L$(OBJDIR) -T$(LINKFILE) -Wl,-Map,$(OBJDIR)/$(TARGET).map +$(OBJDIR)/$(TARGET).elf : $(OBJS) + $(CC) -Os -nostdlib -o $@ $(OBJS) -T$(LINKFILE) -Wl,-Map,$(OBJDIR)/$(TARGET).map +# cross-reference, saves code duplication +$(OBJDIR)/sh_nrv2e_d8.o : ../../firmware/decompressor/sh_nrv2e_d8.S + $(CC) $(CFLAGS) -c $< -o $@ clean: -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 @@ // prototypes static void PlatformInit(void); -static int ucl_nrv2e_decompress_8(const UINT8 *src, UINT8 *dst, UINT32* dst_len); static void DecompressStart(tImage* pImage); #ifdef USE_ADC static int ReadADC(int channel); @@ -41,7 +40,7 @@ static void SetLed(BOOL bOn); static void UartInit(void); static UINT8 UartRead(void); static void UartWrite(UINT8 byte); -static void MiniMon(void); +static void MiniMon(void); #ifdef NO_ROM @@ -188,72 +187,6 @@ static void PlatformInit(void) } -/* Thinned out version of the UCL 2e decompression sourcecode - * Original (C) Markus F.X.J Oberhumer under GNU GPL license */ -#define GETBIT(bb, src, ilen) \ - (((bb = bb & 0x7f ? bb*2 : ((unsigned)src[ilen++]*2+1)) >> 8) & 1) - -static int ucl_nrv2e_decompress_8( - const UINT8 *src, UINT8 *dst, UINT32* dst_len) -{ - UINT32 bb = 0; - unsigned ilen = 0, olen = 0, last_m_off = 1; - - for (;;) - { - unsigned m_off, m_len; - - while (GETBIT(bb,src,ilen)) - { - dst[olen++] = src[ilen++]; - } - m_off = 1; - for (;;) - { - m_off = m_off*2 + GETBIT(bb,src,ilen); - if (GETBIT(bb,src,ilen)) break; - m_off = (m_off-1)*2 + GETBIT(bb,src,ilen); - } - if (m_off == 2) - { - m_off = last_m_off; - m_len = GETBIT(bb,src,ilen); - } - else - { - m_off = (m_off-3)*256 + src[ilen++]; - if (m_off == 0xffffffff) - break; - m_len = (m_off ^ 0xffffffff) & 1; - m_off >>= 1; - last_m_off = ++m_off; - } - if (m_len) - m_len = 1 + GETBIT(bb,src,ilen); - else if (GETBIT(bb,src,ilen)) - m_len = 3 + GETBIT(bb,src,ilen); - else - { - m_len++; - do { - m_len = m_len*2 + GETBIT(bb,src,ilen); - } while (!GETBIT(bb,src,ilen)); - m_len += 3; - } - m_len += (m_off > 0x500); - { - const UINT8 *m_pos; - m_pos = dst + olen - m_off; - dst[olen++] = *m_pos++; - do dst[olen++] = *m_pos++; while (--m_len > 0); - } - } - *dst_len = olen; - - return ilen; -} - - /* move the image into place and start it */ static void DecompressStart(tImage* pImage) { 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 #define FW_VERSION *(unsigned short*)(FLASH_BASE + 0xFE) // firmware version // prototypes +int ucl_nrv2e_decompress_8(const UINT8 *src, UINT8 *dst, UINT32* dst_len); void _main(void) __attribute__ ((section (".startup"))); int main(void); 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 @@ OUTPUT_FORMAT(elf32-sh) -INPUT(bootloader.o) MEMORY { @@ -19,6 +18,7 @@ SECTIONS .text : { *(.text) + *(.icode) . = ALIGN(0x4); } > IRAM 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 @@ where the flash ROM is mirrored to address zero */ OUTPUT_FORMAT(elf32-sh) -INPUT(bootloader.o) MEMORY { @@ -29,6 +28,7 @@ SECTIONS { _begin_text = .; *(.text) + *(.icode) . = ALIGN(0x4); _end_text = .; } > IRAM -- cgit v1.2.3