summaryrefslogtreecommitdiff
path: root/lib/rbcodec/codecs/codec_crt0.c
diff options
context:
space:
mode:
authorSean Bartell <wingedtachikoma@gmail.com>2011-06-25 21:32:25 -0400
committerNils Wallménius <nils@rockbox.org>2012-04-25 22:13:20 +0200
commitf40bfc9267b13b54e6379dfe7539447662879d24 (patch)
tree9b20069d5e62809ff434061ad730096836f916f2 /lib/rbcodec/codecs/codec_crt0.c
parenta0009907de7a0107d49040d8a180f140e2eff299 (diff)
downloadrockbox-f40bfc9267b13b54e6379dfe7539447662879d24.tar.gz
rockbox-f40bfc9267b13b54e6379dfe7539447662879d24.zip
Add codecs to librbcodec.
Change-Id: Id7f4717d51ed02d67cb9f9cb3c0ada4a81843f97 Reviewed-on: http://gerrit.rockbox.org/137 Reviewed-by: Nils Wallménius <nils@rockbox.org> Tested-by: Nils Wallménius <nils@rockbox.org>
Diffstat (limited to 'lib/rbcodec/codecs/codec_crt0.c')
-rw-r--r--lib/rbcodec/codecs/codec_crt0.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/lib/rbcodec/codecs/codec_crt0.c b/lib/rbcodec/codecs/codec_crt0.c
new file mode 100644
index 0000000000..e3c3321e54
--- /dev/null
+++ b/lib/rbcodec/codecs/codec_crt0.c
@@ -0,0 +1,74 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 Tomasz Malesinski
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "config.h"
23#include "codecs.h"
24
25struct codec_api *ci DATA_ATTR;
26
27extern unsigned char plugin_bss_start[];
28extern unsigned char plugin_end_addr[];
29
30/* stub, the entry point is called via its reference in __header to
31 * avoid warning with certain compilers */
32int _start(void) {return 0;}
33
34enum codec_status codec_start(enum codec_entry_call_reason reason)
35{
36#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
37 if (reason == CODEC_LOAD)
38 {
39#ifdef USE_IRAM
40 extern char iramcopy[], iramstart[], iramend[], iedata[], iend[];
41 size_t iram_size = iramend - iramstart;
42 size_t ibss_size = iend - iedata;
43 if (iram_size > 0 || ibss_size > 0)
44 {
45 ci->memcpy(iramstart, iramcopy, iram_size);
46 ci->memset(iedata, 0, ibss_size);
47 /* make the icache (if it exists) up to date with the new code */
48 ci->commit_discard_idcache();
49 /* barrier to prevent reordering iram copy and BSS clearing,
50 * because the BSS segment alias the IRAM copy.
51 */
52 asm volatile ("" ::: "memory");
53 }
54#endif /* PLUGIN_USE_IRAM */
55 ci->memset(plugin_bss_start, 0, plugin_end_addr - plugin_bss_start);
56 /* Some parts of bss may be used via a no-cache alias (at least
57 * portalplayer has this). If we don't clear the cache, those aliases
58 * may read garbage */
59 ci->commit_dcache();
60 }
61#endif /* CONFIG_PLATFORM */
62
63 /* Note: If for any reason codec_main would not be called with CODEC_LOAD
64 * because the above code failed then it must not be ever be called with
65 * any other value and some strategy to avoid doing so must be conceived */
66 return codec_main(reason);
67}
68
69#if defined(CPU_ARM) && (CONFIG_PLATFORM & PLATFORM_NATIVE)
70void __attribute__((naked)) __div0(void)
71{
72 asm volatile("bx %0" : : "r"(ci->__div0));
73}
74#endif