diff options
author | Rafaël Carré <rafael.carre@gmail.com> | 2010-08-30 20:47:53 +0000 |
---|---|---|
committer | Rafaël Carré <rafael.carre@gmail.com> | 2010-08-30 20:47:53 +0000 |
commit | da16248e47901c826a90291d2bb2a7aae78b209a (patch) | |
tree | fcc2a1944dd1b543e21346b46f50252ffc27fb7c /apps/plugins/plugin_crt0.c | |
parent | a1997c13c168beeb41bf2f5b814115cdd5cb574c (diff) | |
download | rockbox-da16248e47901c826a90291d2bb2a7aae78b209a.tar.gz rockbox-da16248e47901c826a90291d2bb2a7aae78b209a.zip |
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
Diffstat (limited to 'apps/plugins/plugin_crt0.c')
-rw-r--r-- | apps/plugins/plugin_crt0.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/apps/plugins/plugin_crt0.c b/apps/plugins/plugin_crt0.c index e34124c5a2..1db9d6a81a 100644 --- a/apps/plugins/plugin_crt0.c +++ b/apps/plugins/plugin_crt0.c | |||
@@ -63,10 +63,35 @@ enum plugin_status plugin__start(const void *param) | |||
63 | int exit_ret; | 63 | int exit_ret; |
64 | enum plugin_status ret; | 64 | enum plugin_status ret; |
65 | 65 | ||
66 | /* zero out the bss section */ | ||
67 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) | 66 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) |
67 | |||
68 | /* IRAM must be copied before clearing the BSS ! */ | ||
69 | #ifdef PLUGIN_USE_IRAM | ||
70 | extern char iramcopy[], iramstart[], iramend[], iedata[], iend[]; | ||
71 | size_t iram_size = iramend - iramstart; | ||
72 | size_t ibss_size = iend - iedata; | ||
73 | if (iram_size > 0 || ibss_size > 0) | ||
74 | { | ||
75 | /* We need to stop audio playback in order to use codec IRAM */ | ||
76 | rb->audio_stop(); | ||
77 | rb->memcpy(iramstart, iramcopy, iram_size); | ||
78 | rb->memset(iedata, 0, ibss_size); | ||
79 | #ifdef HAVE_CPUCACHE_INVALIDATE | ||
80 | /* make the icache (if it exists) up to date with the new code */ | ||
81 | rb->cpucache_invalidate(); | ||
82 | #endif /* HAVE_CPUCACHE_INVALIDATE */ | ||
83 | |||
84 | /* barrier to prevent reordering iram copy and BSS clearing, | ||
85 | * because the BSS segment alias the IRAM copy. | ||
86 | */ | ||
87 | asm volatile ("" ::: "memory"); | ||
88 | } | ||
89 | #endif /* PLUGIN_USE_IRAM */ | ||
90 | |||
91 | /* zero out the bss section */ | ||
68 | rb->memset(plugin_bss_start, 0, plugin_end_addr - plugin_bss_start); | 92 | rb->memset(plugin_bss_start, 0, plugin_end_addr - plugin_bss_start); |
69 | #endif | 93 | #endif |
94 | |||
70 | /* we come back here if exit() was called or the plugin returned normally */ | 95 | /* we come back here if exit() was called or the plugin returned normally */ |
71 | exit_ret = setjmp(__exit_env); | 96 | exit_ret = setjmp(__exit_env); |
72 | if (exit_ret == 0) | 97 | if (exit_ret == 0) |