summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
authorRafaël Carré <rafael.carre@gmail.com>2010-08-30 20:47:53 +0000
committerRafaël Carré <rafael.carre@gmail.com>2010-08-30 20:47:53 +0000
commitda16248e47901c826a90291d2bb2a7aae78b209a (patch)
treefcc2a1944dd1b543e21346b46f50252ffc27fb7c /apps/plugins
parenta1997c13c168beeb41bf2f5b814115cdd5cb574c (diff)
downloadrockbox-da16248e47901c826a90291d2bb2a7aae78b209a.zip
rockbox-da16248e47901c826a90291d2bb2a7aae78b209a.tar.gz
rockbox-da16248e47901c826a90291d2bb2a7aae78b209a.tar.bz2
rockbox-da16248e47901c826a90291d2bb2a7aae78b209a.tar.xz
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')
-rw-r--r--apps/plugins/beatbox/beatbox.c4
-rw-r--r--apps/plugins/doom/rockdoom.c5
-rw-r--r--apps/plugins/midi/midiplay.c4
-rw-r--r--apps/plugins/mp3_encoder.c4
-rw-r--r--apps/plugins/mpegplayer/mpegplayer.c5
-rw-r--r--apps/plugins/pacbox/pacbox.c5
-rw-r--r--apps/plugins/pdbox/pdbox.c4
-rw-r--r--apps/plugins/pitch_detector.c6
-rw-r--r--apps/plugins/plugin_crt0.c27
-rw-r--r--apps/plugins/rockboy/rockboy.c5
-rw-r--r--apps/plugins/test_fps.c3
-rw-r--r--apps/plugins/test_sampr.c4
-rw-r--r--apps/plugins/zxbox/zxbox.c6
13 files changed, 27 insertions, 55 deletions
diff --git a/apps/plugins/beatbox/beatbox.c b/apps/plugins/beatbox/beatbox.c
index 9cb7dd4..34c7257 100644
--- a/apps/plugins/beatbox/beatbox.c
+++ b/apps/plugins/beatbox/beatbox.c
@@ -27,8 +27,6 @@
#include "midi/midifile.h"
-PLUGIN_IRAM_DECLARE
-
/* variable button definitions */
#if CONFIG_KEYPAD == RECORDER_PAD
#define BTN_QUIT BUTTON_OFF
@@ -249,8 +247,6 @@ enum plugin_status plugin_start(const void* parameter)
{
int retval = 0;
- PLUGIN_IRAM_INIT(rb)
-
rb->lcd_setfont(0);
#if defined(HAVE_ADJUSTABLE_CPU_FREQ)
diff --git a/apps/plugins/doom/rockdoom.c b/apps/plugins/doom/rockdoom.c
index 324cb24..4267a61 100644
--- a/apps/plugins/doom/rockdoom.c
+++ b/apps/plugins/doom/rockdoom.c
@@ -41,9 +41,6 @@
#include "st_stuff.h"
#include "lib/helper.h"
-
-PLUGIN_IRAM_DECLARE
-
extern boolean timingdemo, singledemo, demoplayback, fastdemo; // killough
int filearray[9];
@@ -663,8 +660,6 @@ enum plugin_status plugin_start(const void* parameter)
/* Disable all talking before initializing IRAM */
rb->talk_disable(true);
- PLUGIN_IRAM_INIT(rb)
-
(void)parameter;
doomexit=0;
diff --git a/apps/plugins/midi/midiplay.c b/apps/plugins/midi/midiplay.c
index 442a747..5a3c461 100644
--- a/apps/plugins/midi/midiplay.c
+++ b/apps/plugins/midi/midiplay.c
@@ -26,8 +26,6 @@
#include "midifile.h"
-PLUGIN_IRAM_DECLARE
-
/* variable button definitions */
#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
#define BTN_QUIT BUTTON_OFF
@@ -451,8 +449,6 @@ enum plugin_status plugin_start(const void* parameter)
{
int retval;
- PLUGIN_IRAM_INIT(rb)
-
if (parameter == NULL)
{
rb->splash(HZ*2, " Play .MID file ");
diff --git a/apps/plugins/mp3_encoder.c b/apps/plugins/mp3_encoder.c
index d265008..392fc36 100644
--- a/apps/plugins/mp3_encoder.c
+++ b/apps/plugins/mp3_encoder.c
@@ -15,8 +15,6 @@
#include "plugin.h"
-PLUGIN_IRAM_DECLARE
-
#define SAMP_PER_FRAME 1152
#define SAMPL2 576
#define SBLIMIT 32
@@ -2504,8 +2502,6 @@ enum plugin_status plugin_start(const void* parameter)
if (parameter == NULL)
return PLUGIN_ERROR;
- PLUGIN_IRAM_INIT(rb)
-
enc_buffer = rb->plugin_get_audio_buffer(&enc_buffer_size);
#ifdef CPU_COLDFIRE
diff --git a/apps/plugins/mpegplayer/mpegplayer.c b/apps/plugins/mpegplayer/mpegplayer.c
index 8142c6f..5b333c3 100644
--- a/apps/plugins/mpegplayer/mpegplayer.c
+++ b/apps/plugins/mpegplayer/mpegplayer.c
@@ -109,8 +109,6 @@
#include "stream_mgr.h"
-PLUGIN_IRAM_DECLARE
-
/* button definitions */
#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
#define MPEG_MENU BUTTON_MODE
@@ -1761,9 +1759,6 @@ enum plugin_status plugin_start(const void* parameter)
/* Disable all talking before initializing IRAM */
rb->talk_disable(true);
- /* Initialize IRAM - stops audio and voice as well */
- PLUGIN_IRAM_INIT(rb)
-
#ifdef HAVE_LCD_COLOR
rb->lcd_set_backdrop(NULL);
rb->lcd_set_foreground(LCD_WHITE);
diff --git a/apps/plugins/pacbox/pacbox.c b/apps/plugins/pacbox/pacbox.c
index e942841..5165ff3 100644
--- a/apps/plugins/pacbox/pacbox.c
+++ b/apps/plugins/pacbox/pacbox.c
@@ -32,9 +32,6 @@
#include "lib/configfile.h"
#include "lib/playback_control.h"
-
-PLUGIN_IRAM_DECLARE
-
struct pacman_settings {
int difficulty;
int numlives;
@@ -493,8 +490,6 @@ enum plugin_status plugin_start(const void* parameter)
{
(void)parameter;
- PLUGIN_IRAM_INIT(rb)
-
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
rb->cpu_boost(true);
#endif
diff --git a/apps/plugins/pdbox/pdbox.c b/apps/plugins/pdbox/pdbox.c
index 7f4a7ac..3ba6f4e 100644
--- a/apps/plugins/pdbox/pdbox.c
+++ b/apps/plugins/pdbox/pdbox.c
@@ -29,8 +29,6 @@
/* Welcome to the PDBox plugin */
-PLUGIN_IRAM_DECLARE
-
/* Name of the file to open. */
char* filename;
@@ -159,8 +157,6 @@ void core_thread(void)
/* Plug-in entry point */
enum plugin_status plugin_start(const void* parameter)
{
- PLUGIN_IRAM_INIT(rb)
-
/* Memory pool variables. */
size_t mem_size;
void* mem_pool;
diff --git a/apps/plugins/pitch_detector.c b/apps/plugins/pitch_detector.c
index 22e8f75..2b80f5c 100644
--- a/apps/plugins/pitch_detector.c
+++ b/apps/plugins/pitch_detector.c
@@ -69,8 +69,6 @@
#include "pluginbitmaps/pitch_notes.h"
-PLUGIN_IRAM_DECLARE
-
/* Some fixed point calculation stuff */
typedef int32_t fixed_data;
struct _fixed
@@ -1056,12 +1054,10 @@ static void init_everything(void)
/* Disable all talking before initializing IRAM */
rb->talk_disable(true);
- PLUGIN_IRAM_INIT(rb);
-
load_settings();
rb->storage_sleep();
- /* Stop all playback (if no IRAM, otherwise IRAM_INIT would have) */
+ /* Stop all playback */
rb->plugin_get_audio_buffer(NULL);
/* --------- Init the audio recording ----------------- */
diff --git a/apps/plugins/plugin_crt0.c b/apps/plugins/plugin_crt0.c
index e34124c..1db9d6a 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)
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)
diff --git a/apps/plugins/rockboy/rockboy.c b/apps/plugins/rockboy/rockboy.c
index 7fc9199..e7d56b5 100644
--- a/apps/plugins/rockboy/rockboy.c
+++ b/apps/plugins/rockboy/rockboy.c
@@ -26,9 +26,6 @@
#include "hw.h"
#include "pcm.h"
-
-PLUGIN_IRAM_DECLARE
-
int shut,cleanshut;
char *errormsg;
@@ -380,8 +377,6 @@ static int gnuboy_main(const char *rom)
/* this is the plugin entry point */
enum plugin_status plugin_start(const void* parameter)
{
- PLUGIN_IRAM_INIT(rb)
-
rb->lcd_setfont(0);
rb->lcd_clear_display();
diff --git a/apps/plugins/test_fps.c b/apps/plugins/test_fps.c
index f57f45b..c03adc4 100644
--- a/apps/plugins/test_fps.c
+++ b/apps/plugins/test_fps.c
@@ -22,8 +22,6 @@
#include "lib/helper.h"
#include "lib/grey.h"
-PLUGIN_IRAM_DECLARE
-
#if (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) || \
(CONFIG_KEYPAD == IPOD_1G2G_PAD)
#define FPS_QUIT BUTTON_MENU
@@ -344,7 +342,6 @@ enum plugin_status plugin_start(const void* parameter)
#endif
/* standard stuff */
- PLUGIN_IRAM_INIT(rb)
(void)parameter;
log_init();
diff --git a/apps/plugins/test_sampr.c b/apps/plugins/test_sampr.c
index 85525c5..db8301b 100644
--- a/apps/plugins/test_sampr.c
+++ b/apps/plugins/test_sampr.c
@@ -29,8 +29,6 @@
*/
-PLUGIN_IRAM_DECLARE;
-
static int hw_freq IDATA_ATTR = HW_FREQ_DEFAULT;
static unsigned long hw_sampr IDATA_ATTR = HW_SAMPR_DEFAULT;
@@ -298,8 +296,6 @@ enum plugin_status plugin_start(const void *parameter)
/* Disable all talking before initializing IRAM */
rb->talk_disable(true);
- PLUGIN_IRAM_INIT(rb);
-
while (!exit)
{
int result = rb->do_menu(&menu, &selected, NULL, false);
diff --git a/apps/plugins/zxbox/zxbox.c b/apps/plugins/zxbox/zxbox.c
index 459e062..edaa7cf 100644
--- a/apps/plugins/zxbox/zxbox.c
+++ b/apps/plugins/zxbox/zxbox.c
@@ -20,10 +20,6 @@
****************************************************************************/
#include "zxconfig.h"
-
-
-PLUGIN_IRAM_DECLARE
-
#include "spkey_p.h"
spkeyboard kb_mkey;
@@ -61,8 +57,6 @@ long start_time IBSS_ATTR = 0;
enum plugin_status plugin_start(const void* parameter)
{
- PLUGIN_IRAM_INIT(rb)
-
#if LCD_DEPTH > 1
rb->lcd_set_backdrop(NULL);
#endif