FS#11968 by Peter Lecky - Slovak language update
[maemo-rb.git] / apps / codecs / codec_crt0.c
blobcf14e460ecea3af191d78b9e7609959b7f600460
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2006 Tomasz Malesinski
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #include "config.h"
23 #include "codecs.h"
25 struct codec_api *ci DATA_ATTR;
27 extern unsigned char plugin_bss_start[];
28 extern unsigned char plugin_end_addr[];
30 extern enum codec_status codec_main(void);
32 /* stub, the entry point is called via its reference in __header to
33 * avoid warning with certain compilers */
34 int _start(void) {return 0;}
36 enum codec_status codec_start(void)
38 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
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)
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->cpucache_invalidate();
49 /* barrier to prevent reordering iram copy and BSS clearing,
50 * because the BSS segment alias the IRAM copy.
52 asm volatile ("" ::: "memory");
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->cpucache_invalidate();
60 #endif
62 return codec_main();
65 #if defined(CPU_ARM) && (CONFIG_PLATFORM & PLATFORM_NATIVE)
66 void __attribute__((naked)) __div0(void)
68 asm volatile("bx %0" : : "r"(ci->__div0));
70 #endif