forked from len0rd/rockbox
Plugins: modify IRAM copying code
Move to plugin_crt0.c, plugins don't need PLUGIN_IRAM_* macros anymore IRAM is no longered zeroed before copying (as it is at the same address than BSS) -> Fix FS#11581 Use cpucache_invalidate() (and not cpucache_flush), needed for self-modifying code on cached IRAM git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27948 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
a1997c13c1
commit
da16248e47
15 changed files with 39 additions and 110 deletions
|
|
@ -63,10 +63,35 @@ enum plugin_status plugin__start(const void *param)
|
|||
int exit_ret;
|
||||
enum plugin_status ret;
|
||||
|
||||
/* zero out the bss section */
|
||||
#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
|
||||
|
||||
/* IRAM must be copied before clearing the BSS ! */
|
||||
#ifdef PLUGIN_USE_IRAM
|
||||
extern char iramcopy[], iramstart[], iramend[], iedata[], iend[];
|
||||
size_t iram_size = iramend - iramstart;
|
||||
size_t ibss_size = iend - iedata;
|
||||
if (iram_size > 0 || ibss_size > 0)
|
||||
{
|
||||
/* We need to stop audio playback in order to use codec IRAM */
|
||||
rb->audio_stop();
|
||||
rb->memcpy(iramstart, iramcopy, iram_size);
|
||||
rb->memset(iedata, 0, ibss_size);
|
||||
#ifdef HAVE_CPUCACHE_INVALIDATE
|
||||
/* make the icache (if it exists) up to date with the new code */
|
||||
rb->cpucache_invalidate();
|
||||
#endif /* HAVE_CPUCACHE_INVALIDATE */
|
||||
|
||||
/* barrier to prevent reordering iram copy and BSS clearing,
|
||||
* because the BSS segment alias the IRAM copy.
|
||||
*/
|
||||
asm volatile ("" ::: "memory");
|
||||
}
|
||||
#endif /* PLUGIN_USE_IRAM */
|
||||
|
||||
/* zero out the bss section */
|
||||
rb->memset(plugin_bss_start, 0, plugin_end_addr - plugin_bss_start);
|
||||
#endif
|
||||
|
||||
/* we come back here if exit() was called or the plugin returned normally */
|
||||
exit_ret = setjmp(__exit_env);
|
||||
if (exit_ret == 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue