FS#8961 - Anti-Aliased Fonts.
[kugel-rb.git] / firmware / decompressor / decompressor.c
blob11888ef27239528cadf67e943ba730b559755fd3
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2005 by Jens Arnold
12 * Self-extracting firmware loader to work around the 200KB size limit
13 * for archos player and recorder v1
14 * Decompresses a built-in UCL-compressed image (method 2e) and executes it.
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * as published by the Free Software Foundation; either version 2
19 * of the License, or (at your option) any later version.
21 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
22 * KIND, either express or implied.
24 ****************************************************************************/
26 #include "uclimage.h"
28 #define ICODE_ATTR __attribute__ ((section (".icode")))
30 /* Symbols defined in the linker script */
31 extern char iramcopy[], iramstart[], iramend[];
32 extern char stackend[];
33 extern char loadaddress[], dramend[];
35 /* Prototypes */
36 extern void start(void);
38 void main(void) ICODE_ATTR;
39 int ucl_nrv2e_decompress_8(const unsigned char *src, unsigned char *dst,
40 unsigned long *dst_len) ICODE_ATTR;
42 /* Vector table */
43 void (*vbr[]) (void) __attribute__ ((section (".vectors"))) =
45 start, (void *)stackend,
46 start, (void *)stackend,
47 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,
48 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,
51 /** All subsequent functions are executed from IRAM **/
53 #define ALIGNED_IMG_SIZE ((sizeof(image) + 3) & ~3)
54 /* This will never return */
55 void main(void)
57 unsigned long dst_len; /* dummy */
58 unsigned long *src = (unsigned long *)image;
59 unsigned long *dst = (unsigned long *)(dramend - ALIGNED_IMG_SIZE);
62 *dst++ = *src++;
63 while (dst < (unsigned long *)dramend);
65 ucl_nrv2e_decompress_8(dramend - ALIGNED_IMG_SIZE, loadaddress, &dst_len);
67 asm(
68 "mov.l @%0+,r0 \n"
69 "jmp @r0 \n"
70 "mov.l @%0+,r15 \n"
71 : : "r"(loadaddress) : "r0"