summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/Makefile2
-rw-r--r--apps/plugin.c135
-rw-r--r--apps/plugin.h113
-rw-r--r--apps/plugins/Makefile2
-rw-r--r--apps/plugins/alpine_cdc.c6
-rw-r--r--apps/plugins/battery_test.c3
-rw-r--r--apps/plugins/bounce.c3
-rw-r--r--apps/plugins/calculator.c3
-rw-r--r--apps/plugins/calendar.c5
-rw-r--r--apps/plugins/chessclock.c4
-rw-r--r--apps/plugins/chip8.c6
-rw-r--r--apps/plugins/clock.c3
-rw-r--r--apps/plugins/credits.c3
-rw-r--r--apps/plugins/cube.c3
-rw-r--r--apps/plugins/databox/Makefile2
-rw-r--r--apps/plugins/databox/databox.c7
-rw-r--r--apps/plugins/demystify.c11
-rw-r--r--apps/plugins/dict.c3
-rw-r--r--apps/plugins/euroconverter.c7
-rw-r--r--apps/plugins/favorites.c7
-rw-r--r--apps/plugins/fire.c9
-rw-r--r--apps/plugins/firmware_flash.c9
-rw-r--r--apps/plugins/flipit.c3
-rw-r--r--apps/plugins/grayscale.c7
-rw-r--r--apps/plugins/helloworld.c9
-rw-r--r--apps/plugins/iriverify.c2
-rw-r--r--apps/plugins/jackpot.c7
-rw-r--r--apps/plugins/jewels.c5
-rw-r--r--apps/plugins/jpeg.c7
-rw-r--r--apps/plugins/logo.c3
-rw-r--r--apps/plugins/mandelbrot.c3
-rw-r--r--apps/plugins/metronome.c3
-rw-r--r--apps/plugins/midi2wav.c5
-rw-r--r--apps/plugins/minesweeper.c5
-rw-r--r--apps/plugins/mosaique.c3
-rw-r--r--apps/plugins/mp3_encoder.c4
-rw-r--r--apps/plugins/nim.c8
-rw-r--r--apps/plugins/oscillograph.c3
-rw-r--r--apps/plugins/oscilloscope.c3
-rw-r--r--apps/plugins/plasma.c9
-rw-r--r--apps/plugins/plugin.lds13
-rw-r--r--apps/plugins/pong.c6
-rw-r--r--apps/plugins/rockblox.c6
-rw-r--r--apps/plugins/rockbox_flash.c6
-rw-r--r--apps/plugins/rockboy.c6
-rw-r--r--apps/plugins/rockboy/Makefile2
-rw-r--r--apps/plugins/rockboy/rockboy.c9
-rw-r--r--apps/plugins/search.c4
-rw-r--r--apps/plugins/searchengine/Makefile2
-rw-r--r--apps/plugins/searchengine/searchengine.c9
-rw-r--r--apps/plugins/sliding_puzzle.c3
-rw-r--r--apps/plugins/snake.c3
-rw-r--r--apps/plugins/snake2.c3
-rw-r--r--apps/plugins/snow.c3
-rw-r--r--apps/plugins/sokoban.c3
-rw-r--r--apps/plugins/solitaire.c3
-rw-r--r--apps/plugins/sort.c3
-rw-r--r--apps/plugins/splitedit.c2
-rw-r--r--apps/plugins/star.c3
-rw-r--r--apps/plugins/starfield.c9
-rw-r--r--apps/plugins/stats.c3
-rw-r--r--apps/plugins/stopwatch.c3
-rw-r--r--apps/plugins/sudoku.c5
-rw-r--r--apps/plugins/vbrfix.c4
-rw-r--r--apps/plugins/video.c7
-rw-r--r--apps/plugins/viewer.c5
-rw-r--r--apps/plugins/vu_meter.c3
-rw-r--r--apps/plugins/wav2wv.c4
-rw-r--r--apps/plugins/wormlet.c3
-rwxr-xr-xtools/configure6
70 files changed, 268 insertions, 308 deletions
diff --git a/apps/Makefile b/apps/Makefile
index 278e1c7..c6e5d2d 100644
--- a/apps/Makefile
+++ b/apps/Makefile
@@ -34,7 +34,7 @@ ifdef APPEXTRA
INCLUDES += $(patsubst %,-I%,$(subst :, ,$(APPEXTRA)))
endif
-CFLAGS = $(GCCOPTS) $(INCLUDES) $(TARGET) $(DEFINES) \
+CFLAGS = $(GCCOPTS) $(INCLUDES) $(TARGET) $(DEFINES) -DTARGET_ID=$(TARGET_ID) \
-DAPPSVERSION=\"$(VERSION)\" $(EXTRA_DEFINES) -DMEM=${MEMORYSIZE}
OBJS := $(OBJDIR)/lang.o $(SRC:%.c=$(OBJDIR)/%.o)
diff --git a/apps/plugin.c b/apps/plugin.c
index 9a20827..0997b0a 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -78,13 +78,8 @@ static bool plugin_loaded = false;
static int plugin_size = 0;
static void (*pfn_tsr_exit)(void) = NULL; /* TSR exit callback */
-static int plugin_test(int api_version, int model, int memsize);
-
static const struct plugin_api rockbox_api = {
- PLUGIN_API_VERSION,
- plugin_test,
-
/* lcd */
lcd_set_contrast,
lcd_clear_display,
@@ -135,6 +130,7 @@ static const struct plugin_api rockbox_api = {
checkbox,
font_get,
font_getstringsize,
+ font_get_width,
#endif
backlight_on,
backlight_off,
@@ -243,9 +239,18 @@ static const struct plugin_api rockbox_api = {
strcat,
memcmp,
strcasestr,
+ /* unicode stuff */
+ utf8decode,
+ iso_decode,
+ utf16LEdecode,
+ utf16BEdecode,
+ utf8encode,
+ utf8length,
/* sound */
sound_set,
+ sound_min,
+ sound_max,
#ifndef SIMULATOR
mp3_play_data,
mp3_play_pause,
@@ -307,6 +312,21 @@ static const struct plugin_api rockbox_api = {
&rundb_fd,
&rundb_initialized,
+ /* menu */
+ menu_init,
+ menu_exit,
+ menu_show,
+ menu_run,
+ menu_cursor,
+ menu_description,
+ menu_delete,
+ menu_count,
+ menu_moveup,
+ menu_movedown,
+ menu_draw,
+ menu_insert,
+ menu_set_cursor,
+
/* misc */
srand,
rand,
@@ -337,39 +357,13 @@ static const struct plugin_api rockbox_api = {
#endif
#ifdef HAVE_LCD_BITMAP
read_bmp_file,
+ screen_dump_set_hook,
#endif
show_logo,
/* new stuff at the end, sort into place next time
the API gets incompatible */
- menu_init,
- menu_exit,
- menu_show,
- menu_run,
- menu_cursor,
- menu_description,
- menu_delete,
- menu_count,
- menu_moveup,
- menu_movedown,
- menu_draw,
- menu_insert,
- menu_set_cursor,
-
-#ifdef HAVE_LCD_BITMAP
- screen_dump_set_hook,
- font_get_width,
-#endif
- utf8decode,
- iso_decode,
- utf16LEdecode,
- utf16BEdecode,
- utf8encode,
- utf8length,
-
- sound_min,
- sound_max,
};
int plugin_load(const char* plugin, void* parameter)
@@ -377,7 +371,8 @@ int plugin_load(const char* plugin, void* parameter)
enum plugin_status (*plugin_start)(struct plugin_api* api, void* param);
int rc;
#ifndef SIMULATOR
- char buf[64];
+ struct plugin_header header;
+ ssize_t readsize;
#endif
int fd;
@@ -408,28 +403,50 @@ int plugin_load(const char* plugin, void* parameter)
#else
fd = open(plugin, O_RDONLY);
if (fd < 0) {
- snprintf(buf, sizeof buf, str(LANG_PLUGIN_CANT_OPEN), plugin);
- gui_syncsplash(HZ*2, true, buf);
+ gui_syncsplash(HZ*2, true, str(LANG_PLUGIN_CANT_OPEN), plugin);
return fd;
}
-
+
+ readsize = read(fd, &header, sizeof(header));
+ close(fd);
+ /* Close for now. Less code than doing it in all error checks.
+ * Would need to seek back anyway. */
+
+ if (readsize != sizeof(header)) {
+ gui_syncsplash(HZ*2, true, str(LANG_READ_FAILED), plugin);
+ return -1;
+ }
+ if (header.magic != PLUGIN_MAGIC
+ || header.target_id != TARGET_ID
+ || header.load_addr != pluginbuf
+ || header.end_addr > pluginbuf + PLUGIN_BUFFER_SIZE) {
+ gui_syncsplash(HZ*2, true, str(LANG_PLUGIN_WRONG_MODEL));
+ return -1;
+ }
+ if (header.api_version > PLUGIN_API_VERSION
+ || header.api_version < PLUGIN_MIN_API_VERSION) {
+ gui_syncsplash(HZ*2, true, str(LANG_PLUGIN_WRONG_VERSION));
+ return -1;
+ }
+
/* zero out plugin buffer to ensure a properly zeroed bss area */
- memset(pluginbuf, 0, PLUGIN_BUFFER_SIZE);
+ memset(pluginbuf, 0, header.end_addr - pluginbuf);
- plugin_start = (void*)&pluginbuf;
- plugin_size = read(fd, plugin_start, PLUGIN_BUFFER_SIZE);
+ fd = open(plugin, O_RDONLY);
+ if (fd < 0) {
+ gui_syncsplash(HZ*2, true, str(LANG_PLUGIN_CANT_OPEN), plugin);
+ return fd;
+ }
+ readsize = read(fd, pluginbuf, PLUGIN_BUFFER_SIZE);
close(fd);
- if (plugin_size < 0) {
+
+ if (readsize < 0) {
/* read error */
- snprintf(buf, sizeof buf, str(LANG_READ_FAILED), plugin);
- gui_syncsplash(HZ*2, true, buf);
- return -1;
- }
- if (plugin_size == 0) {
- /* loaded a 0-byte plugin, implying it's not for this model */
- gui_syncsplash(HZ*2, true, str(LANG_PLUGIN_WRONG_MODEL));
+ gui_syncsplash(HZ*2, true, str(LANG_READ_FAILED), plugin);
return -1;
}
+ plugin_start = header.entry_point;
+ plugin_size = header.end_addr - header.load_addr;
#endif
plugin_loaded = true;
@@ -458,14 +475,6 @@ int plugin_load(const char* plugin, void* parameter)
case PLUGIN_USB_CONNECTED:
return PLUGIN_USB_CONNECTED;
- case PLUGIN_WRONG_API_VERSION:
- gui_syncsplash(HZ*2, true, str(LANG_PLUGIN_WRONG_VERSION));
- break;
-
- case PLUGIN_WRONG_MODEL:
- gui_syncsplash(HZ*2, true, str(LANG_PLUGIN_WRONG_MODEL));
- break;
-
default:
gui_syncsplash(HZ*2, true, str(LANG_PLUGIN_ERROR));
break;
@@ -521,19 +530,3 @@ void plugin_tsr(void (*exit_callback)(void))
{
pfn_tsr_exit = exit_callback; /* remember the callback for later */
}
-
-
-static int plugin_test(int api_version, int model, int memsize)
-{
- if (api_version < PLUGIN_MIN_API_VERSION ||
- api_version > PLUGIN_API_VERSION)
- return PLUGIN_WRONG_API_VERSION;
-
- if (model != MODEL)
- return PLUGIN_WRONG_MODEL;
-
- if (memsize != MEM)
- return PLUGIN_WRONG_MODEL;
-
- return PLUGIN_OK;
-}
diff --git a/apps/plugin.h b/apps/plugin.h
index f935809..bf8f34a 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -90,44 +90,23 @@
#define PREFIX(_x_) _x_
#endif
+#define PLUGIN_MAGIC 0x526F634B /* RocK */
+
/* increase this every time the api struct changes */
-#define PLUGIN_API_VERSION 54
+#define PLUGIN_API_VERSION 1
/* update this to latest version if a change to the api struct breaks
backwards compatibility (and please take the opportunity to sort in any
new function which are "waiting" at the end of the function table) */
-#define PLUGIN_MIN_API_VERSION 51
+#define PLUGIN_MIN_API_VERSION 1
/* plugin return codes */
enum plugin_status {
PLUGIN_OK = 0,
PLUGIN_USB_CONNECTED,
-
- PLUGIN_WRONG_API_VERSION = -1,
- PLUGIN_WRONG_MODEL = -2,
- PLUGIN_ERROR = -3,
+ PLUGIN_ERROR = -1,
};
-/* different (incompatible) plugin models */
-enum model {
- PLAYER,
- RECORDER
-};
-
-#ifdef HAVE_LCD_CHARCELLS
-#define MODEL PLAYER
-#else
-#define MODEL RECORDER
-#endif
-
-/* compatibility test macro */
-#define TEST_PLUGIN_API(_api_) \
-do { \
- int _rc_ = _api_->plugin_test(PLUGIN_API_VERSION, MODEL, MEM); \
- if (_rc_<0) \
- return _rc_; \
-} while(0)
-
/* NOTE: To support backwards compatibility, only add new functions at
the end of the structure. Every time you add a new function,
remember to increase PLUGIN_API_VERSION. If you make changes to the
@@ -135,10 +114,6 @@ do { \
version
*/
struct plugin_api {
- /* these two fields must always be first, to ensure
- TEST_PLUGIN_API will always work */
- int version;
- int (*plugin_test)(int api_version, int model, int memsize);
/* lcd */
void (*lcd_set_contrast)(int x);
@@ -198,6 +173,7 @@ struct plugin_api {
struct font* (*font_get)(int font);
int (*font_getstringsize)(const unsigned char *str, int *w, int *h,
int fontnumber);
+ int (*font_get_width)(struct font* pf, unsigned short char_code);
#endif
void (*backlight_on)(void);
void (*backlight_off)(void);
@@ -314,9 +290,18 @@ struct plugin_api {
char *(*strcat)(char *s1, const char *s2);
int (*memcmp)(const void *s1, const void *s2, size_t n);
char *(*strcasestr) (const char* phaystack, const char* pneedle);
+ /* unicode stuff */
+ const unsigned char* (*utf8decode)(const unsigned char *utf8, unsigned short *ucs);
+ unsigned char* (*iso_decode)(const unsigned char *iso, unsigned char *utf8, int cp, int count);
+ unsigned char* (*utf16LEdecode)(const unsigned char *utf16, unsigned char *utf8, unsigned int count);
+ unsigned char* (*utf16BEdecode)(const unsigned char *utf16, unsigned char *utf8, unsigned int count);
+ unsigned char* (*utf8encode)(unsigned long ucs, unsigned char *utf8);
+ unsigned long (*utf8length)(const unsigned char *utf8);
/* sound */
void (*sound_set)(int setting, int value);
+ int (*sound_min)(int setting);
+ int (*sound_max)(int setting);
#ifndef SIMULATOR
void (*mp3_play_data)(const unsigned char* start, int size, void (*get_more)(unsigned char** start, int* size));
void (*mp3_play_pause)(bool play);
@@ -378,6 +363,23 @@ struct plugin_api {
int *rundb_fd;
int *rundb_initialized;
+ /* menu */
+ int (*menu_init)(const struct menu_item* mitems, int count,
+ int (*callback)(int, int),
+ const char *button1, const char *button2, const char *button3);
+ void (*menu_exit)(int menu);
+ int (*menu_show)(int m);
+ bool (*menu_run)(int menu);
+ int (*menu_cursor)(int menu);
+ char* (*menu_description)(int menu, int position);
+ void (*menu_delete)(int menu, int position);
+ int (*menu_count)(int menu);
+ bool (*menu_moveup)(int menu);
+ bool (*menu_movedown)(int menu);
+ void (*menu_draw)(int menu);
+ void (*menu_insert)(int menu, int position, char *desc, bool (*function) (void));
+ void (*menu_set_cursor)(int menu, int position);
+
/* misc */
void (*srand)(unsigned int seed);
int (*rand)(void);
@@ -416,42 +418,37 @@ struct plugin_api {
#ifdef HAVE_LCD_BITMAP
int (*read_bmp_file)(char* filename, int *get_width, int *get_height,
char *bitmap, int maxsize);
+ void (*screen_dump_set_hook)(void (*hook)(int fh));
#endif
int (*show_logo)(void);
/* new stuff at the end, sort into place next time
the API gets incompatible */
- int (*menu_init)(const struct menu_item* mitems, int count,
- int (*callback)(int, int),
- const char *button1, const char *button2, const char *button3);
- void (*menu_exit)(int menu);
- int (*menu_show)(int m);
- bool (*menu_run)(int menu);
- int (*menu_cursor)(int menu);
- char* (*menu_description)(int menu, int position);
- void (*menu_delete)(int menu, int position);
- int (*menu_count)(int menu);
- bool (*menu_moveup)(int menu);
- bool (*menu_movedown)(int menu);
- void (*menu_draw)(int menu);
- void (*menu_insert)(int menu, int position, char *desc, bool (*function) (void));
- void (*menu_set_cursor)(int menu, int position);
+};
-#ifdef HAVE_LCD_BITMAP
- void (*screen_dump_set_hook)(void (*hook)(int fh));
- int (*font_get_width)(struct font* pf, unsigned short char_code);
-#endif
- const unsigned char* (*utf8decode)(const unsigned char *utf8, unsigned short *ucs);
- unsigned char* (*iso_decode)(const unsigned char *iso, unsigned char *utf8, int cp, int count);
- unsigned char* (*utf16LEdecode)(const unsigned char *utf16, unsigned char *utf8, unsigned int count);
- unsigned char* (*utf16BEdecode)(const unsigned char *utf16, unsigned char *utf8, unsigned int count);
- unsigned char* (*utf8encode)(unsigned long ucs, unsigned char *utf8);
- unsigned long (*utf8length)(const unsigned char *utf8);
-
- int (*sound_min)(int setting);
- int (*sound_max)(int setting);
+#ifndef SIMULATOR
+/* plugin header */
+struct plugin_header {
+ unsigned long magic;
+ unsigned short target_id;
+ unsigned short api_version;
+ unsigned char *load_addr;
+ unsigned char *end_addr;
+ enum plugin_status(*entry_point)(struct plugin_api*, void*);
};
+#ifdef PLUGIN
+extern unsigned char plugin_start_addr[];
+extern unsigned char plugin_end_addr[];
+#define PLUGIN_HEADER \
+ const struct plugin_header __header \
+ __attribute__ ((section (".header")))= { \
+ PLUGIN_MAGIC, TARGET_ID, PLUGIN_API_VERSION, \
+ plugin_start_addr, plugin_end_addr, plugin_start };
+#endif
+#else /* SIMULATOR */
+#define PLUGIN_HEADER
+#endif
int plugin_load(const char* plugin, void* parameter);
void* plugin_get_buffer(int *buffer_size);
diff --git a/apps/plugins/Makefile b/apps/plugins/Makefile
index 45fa7a4..2ed1a10 100644
--- a/apps/plugins/Makefile
+++ b/apps/plugins/Makefile
@@ -10,7 +10,7 @@
INCLUDES = -I$(FIRMDIR)/include -I$(FIRMDIR)/export -I$(FIRMDIR)/common \
-I$(FIRMDIR)/drivers -I$(APPSDIR) -Ilib -I$(BUILDDIR)
CFLAGS = $(GCCOPTS) $(INCLUDES) $(TARGET) $(EXTRA_DEFINES) \
- -DMEM=${MEMORYSIZE} -DPLUGIN
+ -DTARGET_ID=$(TARGET_ID) -DMEM=${MEMORYSIZE} -DPLUGIN
ifdef APPEXTRA
INCLUDES += $(patsubst %,-I$(APPSDIR)/%,$(subst :, ,$(APPEXTRA)))
diff --git a/apps/plugins/alpine_cdc.c b/apps/plugins/alpine_cdc.c
index 874f722..91cfb0e 100644
--- a/apps/plugins/alpine_cdc.c
+++ b/apps/plugins/alpine_cdc.c
@@ -34,6 +34,8 @@
/* Only build for (correct) target */
#if !defined(SIMULATOR) && CONFIG_CPU==SH7034 && !defined(HAVE_MMC)
+PLUGIN_HEADER
+
#ifdef HAVE_LCD_CHARCELLS /* player model */
#define LINES 2
#define COLUMNS 11
@@ -1192,10 +1194,6 @@ int main(void* parameter)
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
- /* this macro should be called as the first thing you do in the plugin.
- it test that the api version and model the plugin was compiled for
- matches the machine it is running on */
- TEST_PLUGIN_API(api);
rb = api; /* copy to global api pointer */
/* now go ahead and have fun! */
diff --git a/apps/plugins/battery_test.c b/apps/plugins/battery_test.c
index ac47b00..c076ad7 100644
--- a/apps/plugins/battery_test.c
+++ b/apps/plugins/battery_test.c
@@ -29,6 +29,8 @@
to watch.
*/
+PLUGIN_HEADER
+
/* variable button definitions */
#if CONFIG_KEYPAD == RECORDER_PAD
#define BATTERY_TEST_QUIT BUTTON_OFF
@@ -136,7 +138,6 @@ enum plugin_status loop(void)
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
- TEST_PLUGIN_API(api);
(void)parameter;
rb = api;
diff --git a/apps/plugins/bounce.c b/apps/plugins/bounce.c
index 2a2d520..7b59841 100644
--- a/apps/plugins/bounce.c
+++ b/apps/plugins/bounce.c
@@ -21,6 +21,8 @@
#ifdef HAVE_LCD_BITMAP
+PLUGIN_HEADER
+
#define SS_TITLE "Bouncer"
#define SS_TITLE_FONT 2
@@ -443,7 +445,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
char *off = "[Off] to stop";
int len;
- TEST_PLUGIN_API(api);
(void)(parameter);
rb = api;
diff --git a/apps/plugins/calculator.c b/apps/plugins/calculator.c
index 51b9cfa..ba18cc1 100644
--- a/apps/plugins/calculator.c
+++ b/apps/plugins/calculator.c
@@ -76,6 +76,8 @@ F3: equal to "="
#ifdef HAVE_LCD_BITMAP
#include "math.h"
+PLUGIN_HEADER
+
#define REC_HEIGHT 10 /* blank height = 9 */
#define REC_WIDTH 22 /* blank width = 21 */
@@ -1324,7 +1326,6 @@ Main();
----------------------------------------------------------------------- */
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
- TEST_PLUGIN_API(api);
(void)parameter;
rb = api;
diff --git a/apps/plugins/calendar.c b/apps/plugins/calendar.c
index 5cb04b5..464d810 100644
--- a/apps/plugins/calendar.c
+++ b/apps/plugins/calendar.c
@@ -23,6 +23,8 @@
#include <timefuncs.h>
+PLUGIN_HEADER
+
static struct plugin_api* rb;
static bool leap_year;
@@ -664,9 +666,8 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
bool exit = false;
int button;
- TEST_PLUGIN_API(api);
(void)(parameter);
-
+
rb = api;
calendar_init(&today, &shown);
diff --git a/apps/plugins/chessclock.c b/apps/plugins/chessclock.c
index 18ba680..73f53c9 100644
--- a/apps/plugins/chessclock.c
+++ b/apps/plugins/chessclock.c
@@ -18,6 +18,8 @@
****************************************************************************/
#include "plugin.h"
+PLUGIN_HEADER
+
/* variable button definitions */
#if CONFIG_KEYPAD == RECORDER_PAD
#define CHC_QUIT BUTTON_OFF
@@ -136,8 +138,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
bool done;
int nr;
- TEST_PLUGIN_API(api);
-
(void)parameter;
rb=api;
diff --git a/apps/plugins/chip8.c b/apps/plugins/chip8.c
index 56ce12a..50e32ed 100644
--- a/apps/plugins/chip8.c
+++ b/apps/plugins/chip8.c
@@ -22,6 +22,8 @@
/* Only build for (correct) target */
#ifdef HAVE_LCD_BITMAP
+PLUGIN_HEADER
+
static struct plugin_api* rb; /* here is a global api struct pointer */
#define EXTERN static
@@ -1276,10 +1278,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
char* filename;
- /* this macro should be called as the first thing you do in the plugin.
- it test that the api version and model the plugin was compiled for
- matches the machine it is running on */
- TEST_PLUGIN_API(api);
rb = api; /* copy to global api pointer */
if (parameter == NULL)
diff --git a/apps/plugins/clock.c b/apps/plugins/clock.c
index 9c940dc..167a64e 100644
--- a/apps/plugins/clock.c
+++ b/apps/plugins/clock.c
@@ -80,6 +80,8 @@ Original release, featuring analog / digital modes and a few options.
#if defined(HAVE_LCD_BITMAP) && defined(CONFIG_RTC)
+PLUGIN_HEADER
+
#define CLOCK_VERSION "2.60"
#define MODE_ANALOG 1
@@ -2875,7 +2877,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
struct tm* current_time;
- TEST_PLUGIN_API(api);
(void)parameter;
rb = api;
diff --git a/apps/plugins/credits.c b/apps/plugins/credits.c
index 1b1aadb..5fdc215 100644
--- a/apps/plugins/credits.c
+++ b/apps/plugins/credits.c
@@ -18,6 +18,8 @@
****************************************************************************/
#include "plugin.h"
+PLUGIN_HEADER
+
void roll_credits(void);
const char* const credits[] = {
#include "credits.raw" /* generated list of names from docs/CREDITS */
@@ -30,7 +32,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
int j = 0;
int btn;
- TEST_PLUGIN_API(api);
(void)parameter;
rb = api;
diff --git a/apps/plugins/cube.c b/apps/plugins/cube.c
index e71d8b6..a70e332 100644
--- a/apps/plugins/cube.c
+++ b/apps/plugins/cube.c
@@ -22,6 +22,8 @@
#include "playergfx.h"
#include "xlcd.h"
+PLUGIN_HEADER
+
/* Loops that the values are displayed */
#define DISP_TIME 30
@@ -446,7 +448,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
bool redraw = true;
bool exit = false;
- TEST_PLUGIN_API(api);
(void)(parameter);
rb = api;
diff --git a/apps/plugins/databox/Makefile b/apps/plugins/databox/Makefile
index 78387fd..6a44333 100644
--- a/apps/plugins/databox/Makefile
+++ b/apps/plugins/databox/Makefile
@@ -10,7 +10,7 @@
INCLUDES = -I$(APPSDIR) -I.. -I. -I$(FIRMDIR)/include -I$(FIRMDIR)/export \
-I$(FIRMDIR)/common -I$(FIRMDIR)/drivers -I$(OUTDIR) -I$(BUILDDIR)
CFLAGS = $(GCCOPTS) -O3 $(INCLUDES) $(TARGET) $(EXTRA_DEFINES) \
- -DMEM=${MEMORYSIZE} -DPLUGIN
+ -DTARGET_ID=$(TARGET_ID) -DMEM=${MEMORYSIZE} -DPLUGIN
ifdef APPEXTRA
INCLUDES += $(patsubst %,-I$(APPSDIR)/%,$(subst :, ,$(APPEXTRA)))
diff --git a/apps/plugins/databox/databox.c b/apps/plugins/databox/databox.c
index ebed139..2cc78a0 100644
--- a/apps/plugins/databox/databox.c
+++ b/apps/plugins/databox/databox.c
@@ -18,6 +18,8 @@
****************************************************************************/
#include "databox.h"
+PLUGIN_HEADER
+
/* variable button definitions */
#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
(CONFIG_KEYPAD == IRIVER_H300_PAD)
@@ -233,11 +235,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
int button,done=0,abort=0;
char filename[100],buf[100];
- /* this macro should be called as the first thing you do in the plugin.
- it test that the api version and model the plugin was compiled for
- matches the machine it is running on */
- TEST_PLUGIN_API(api);
-
/* if you don't use the parameter, you can do like
this to avoid the compiler warning about it */
(void)parameter;
diff --git a/apps/plugins/demystify.c b/apps/plugins/demystify.c
index 8cb3315..f4e54be 100644
--- a/apps/plugins/demystify.c
+++ b/apps/plugins/demystify.c
@@ -23,6 +23,8 @@
#ifdef HAVE_LCD_BITMAP
+PLUGIN_HEADER
+
/* Key assignement */
#if (CONFIG_KEYPAD == IPOD_4G_PAD)
#define DEMYSTIFY_QUIT BUTTON_MENU
@@ -337,19 +339,12 @@ int plugin_main(void)
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
int ret;
- /*
- * this macro should be called as the first thing you do in the plugin.
- * it test that the api version and model the plugin was compiled for
- * matches the machine it is running on
- */
-
- TEST_PLUGIN_API(api);
rb = api; /* copy to global api pointer */
(void)parameter;
if (rb->global_settings->backlight_timeout > 0)
rb->backlight_set_timeout(1);/* keep the light on */
-
+
ret = plugin_main();
return ret;
diff --git a/apps/plugins/dict.c b/apps/plugins/dict.c
index c432b56..7209240 100644
--- a/apps/plugins/dict.c
+++ b/apps/plugins/dict.c
@@ -19,6 +19,8 @@
#include "plugin.h"
+PLUGIN_HEADER
+
/* as in hello world :) */
static struct plugin_api* rb;
/* screen info */
@@ -127,7 +129,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
int lines, len, outputted, next;
/* plugin stuff */
- TEST_PLUGIN_API(api);
(void)parameter;
rb = api;
diff --git a/apps/plugins/euroconverter.c b/apps/plugins/euroconverter.c
index 3fb1e0e..3cf36af 100644
--- a/apps/plugins/euroconverter.c
+++ b/apps/plugins/euroconverter.c
@@ -43,6 +43,8 @@ To do:
- The Irish currency needs 6 digits after the . to have sufficient precision on big number
*/
+PLUGIN_HEADER
+
/* Name and path of the config file*/
static const char cfg_filename[] = "euroconverter.cfg";
#define CFGFILE_VERSION 0 /* Current config file version */
@@ -405,11 +407,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
longlong_t e,h,old_e,old_h;
int button;
- /* this macro should be called as the first thing you do in the plugin.
- it test that the api version and model the plugin was compiled for
- matches the machine it is running on */
- TEST_PLUGIN_API(api);
-
/* if you don't use the parameter, you can do like
this to avoid the compiler warning about it */
(void)parameter;
diff --git a/apps/plugins/favorites.c b/apps/plugins/favorites.c
index 68eab43..d45f785 100644
--- a/apps/plugins/favorites.c
+++ b/apps/plugins/favorites.c
@@ -1,6 +1,8 @@
#include "plugin.h"
#define FAVORITES_FILE "/favorites.m3u"
+PLUGIN_HEADER
+
static struct plugin_api* rb;
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
@@ -9,11 +11,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
char track_path[MAX_PATH+1];
int fd, result, len;
- /* this macro should be called as the first thing you do in the plugin.
- it test that the api version and model the plugin was compiled for
- matches the machine it is running on */
- TEST_PLUGIN_API(api);
-
rb = api;
/* If we were passed a parameter, use that as the file name,
diff --git a/apps/plugins/fire.c b/apps/plugins/fire.c
index bf01e9b..727644f 100644
--- a/apps/plugins/fire.c
+++ b/apps/plugins/fire.c
@@ -25,6 +25,8 @@
#ifdef HAVE_LCD_BITMAP /* and also not for the Player */
#include "gray.h"
+PLUGIN_HEADER
+
/******************************* Globals ***********************************/
static struct plugin_api* rb; /* global api struct pointer */
@@ -278,13 +280,6 @@ int main(void)
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
int ret;
- /*
- * this macro should be called as the first thing you do in the plugin.
- * it test that the api version and model the plugin was compiled for
- * matches the machine it is running on
- */
-
- TEST_PLUGIN_API(api);
rb = api; // copy to global api pointer
(void)parameter;
diff --git a/apps/plugins/firmware_flash.c b/apps/plugins/firmware_flash.c
index 697884f..fa77a33 100644
--- a/apps/plugins/firmware_flash.c
+++ b/apps/plugins/firmware_flash.c
@@ -79,6 +79,8 @@
#ifdef PLATFORM_ID
+PLUGIN_HEADER
+
#if CONFIG_KEYPAD == ONDIO_PAD /* limited keypad */
#define KEY1 BUTTON_LEFT
#define KEY2 BUTTON_UP
@@ -1048,7 +1050,7 @@ void DoUserDialog(char* filename)
rb->snprintf(buf, sizeof(buf), "Verify failed! %d errors", rc);
rb->lcd_puts_scroll(0, 0, buf);
}
-
+
rb->lcd_puts_scroll(0, 1, "Press any key to exit.");
WaitForButton();
}
@@ -1062,11 +1064,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
int oldmode;
- /* this macro should be called as the first thing you do in the plugin.
- it test that the api version and model the plugin was compiled for
- matches the machine it is running on */
- TEST_PLUGIN_API(api);
-
rb = api; /* copy to global api pointer */
/* now go ahead and have fun! */
diff --git a/apps/plugins/flipit.c b/apps/plugins/flipit.c
index f921a2e..f1fba87 100644
--- a/apps/plugins/flipit.c
+++ b/apps/plugins/flipit.c
@@ -19,6 +19,8 @@
#include "plugin.h"
#ifdef HAVE_LCD_BITMAP
+PLUGIN_HEADER
+
/* variable button definitions */
#if CONFIG_KEYPAD == RECORDER_PAD
#define FLIPIT_UP BUTTON_UP
@@ -294,7 +296,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
int w, h, i;
- TEST_PLUGIN_API(api);
(void)parameter;
rb = api;
diff --git a/apps/plugins/grayscale.c b/apps/plugins/grayscale.c
index 192dcc1..9e921ae 100644
--- a/apps/plugins/grayscale.c
+++ b/apps/plugins/grayscale.c
@@ -25,6 +25,8 @@
#if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH < 4)
#include "gray.h"
+PLUGIN_HEADER
+
/* variable button definitions */
#if CONFIG_KEYPAD == RECORDER_PAD
#define GRAYSCALE_SHIFT BUTTON_ON
@@ -302,11 +304,6 @@ int main(void)
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
- /* this macro should be called as the first thing you do in the plugin.
- it test that the api version and model the plugin was compiled for
- matches the machine it is running on */
- TEST_PLUGIN_API(api);
-
rb = api; // copy to global api pointer
(void)parameter;
diff --git a/apps/plugins/helloworld.c b/apps/plugins/helloworld.c
index d0fecba..e4220e4 100644
--- a/apps/plugins/helloworld.c
+++ b/apps/plugins/helloworld.c
@@ -20,6 +20,10 @@
/* welcome to the example rockbox plugin */
+/* This macros must always be included. Should be placed at the top by
+ convention, although the actual position doesn't matter */
+PLUGIN_HEADER
+
/* here is a global api struct pointer. while not strictly necessary,
it's nice not to have to pass the api pointer in all function calls
in the plugin */
@@ -28,11 +32,6 @@ static struct plugin_api* rb;
/* this is the plugin entry point */
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
- /* this macro should be called as the first thing you do in the plugin.
- it test that the api version and model the plugin was compiled for
- matches the machine it is running on */
- TEST_PLUGIN_API(api);
-
/* if you don't use the parameter, you can do like
this to avoid the compiler warning about it */
(void)parameter;
diff --git a/apps/plugins/iriverify.c b/apps/plugins/iriverify.c
index 7b5c218..a0f8d50 100644
--- a/apps/plugins/iriverify.c
+++ b/apps/plugins/iriverify.c
@@ -23,6 +23,7 @@
****************************************************************************/
#include "plugin.h"
+PLUGIN_HEADER
static struct plugin_api* rb;
@@ -133,7 +134,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
char *buf;
int rc;
- TEST_PLUGIN_API(api);
filename = (char *)parameter;
diff --git a/apps/plugins/jackpot.c b/apps/plugins/jackpot.c
index d35e35a..a2ebb81 100644
--- a/apps/plugins/jackpot.c
+++ b/apps/plugins/jackpot.c
@@ -29,6 +29,8 @@ History:
#ifdef HAVE_LCD_CHARCELLS
+PLUGIN_HEADER
+
/* Jackpot game for the player */
static unsigned char pattern[]={
@@ -89,11 +91,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
bool exit=false;
bool go;
- /* this macro should be called as the first thing you do in the plugin.
- it test that the api version and model the plugin was compiled for
- matches the machine it is running on */
- TEST_PLUGIN_API(api);
-
/* if you don't use the parameter, you can do like
this to avoid the compiler warning about it */
(void)parameter;
diff --git a/apps/plugins/jewels.c b/apps/plugins/jewels.c
index af5a374..a4ce1ae 100644
--- a/apps/plugins/jewels.c
+++ b/apps/plugins/jewels.c
@@ -20,11 +20,11 @@
****************************************************************************/
#include "plugin.h"
-#include "button.h"
-#include "lcd.h"
#ifdef HAVE_LCD_BITMAP
+PLUGIN_HEADER
+
/* save files */
#define SCORE_FILE PLUGIN_DIR "/bejeweled.score"
#define SAVE_FILE PLUGIN_DIR "/bejeweled.save"
@@ -2466,7 +2466,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) {
char str[19];
/* plugin init */
- TEST_PLUGIN_API(api);
(void)parameter;
rb = api;
/* end of plugin init */
diff --git a/apps/plugins/jpeg.c b/apps/plugins/jpeg.c
index fee24d1..468f745 100644
--- a/apps/plugins/jpeg.c
+++ b/apps/plugins/jpeg.c
@@ -29,6 +29,8 @@
#if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH < 4)
#include "gray.h"
+PLUGIN_HEADER
+
/* variable button definitions */
#if CONFIG_KEYPAD == RECORDER_PAD
#define JPEG_ZOOM_IN BUTTON_PLAY
@@ -1959,11 +1961,6 @@ int main(char* filename)
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
- /* this macro should be called as the first thing you do in the plugin.
- it test that the api version and model the plugin was compiled for
- matches the machine it is running on */
- TEST_PLUGIN_API(api);
-
rb = api; /* copy to global api pointer */
return main((char*)parameter);
diff --git a/apps/plugins/logo.c b/apps/plugins/logo.c
index 9472de9..0167859 100644
--- a/apps/plugins/logo.c
+++ b/apps/plugins/logo.c
@@ -19,6 +19,8 @@
#include "plugin.h"
#include "playergfx.h"
+PLUGIN_HEADER
+
#ifdef HAVE_LCD_BITMAP
#define DISPLAY_WIDTH LCD_WIDTH
#define DISPLAY_HEIGHT LCD_HEIGHT
@@ -226,7 +228,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) {
int old_cpos = -1;
#endif
- TEST_PLUGIN_API(api);
(void)parameter;
#ifdef HAVE_LCD_CHARCELLS
diff --git a/apps/plugins/mandelbrot.c b/apps/plugins/mandelbrot.c
index 1f80ff3..1d2b48c 100644
--- a/apps/plugins/mandelbrot.c
+++ b/apps/plugins/mandelbrot.c
@@ -24,6 +24,8 @@
#if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH < 4)
#include "gray.h"
+PLUGIN_HEADER
+
/* variable button definitions */
#if CONFIG_KEYPAD == RECORDER_PAD
#define MANDELBROT_QUIT BUTTON_OFF
@@ -371,7 +373,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
int grayscales;
int redraw = REDRAW_FULL;
- TEST_PLUGIN_API(api);
rb = api;
(void)parameter;
diff --git a/apps/plugins/metronome.c b/apps/plugins/metronome.c
index 1b2d28a..2f897d7 100644
--- a/apps/plugins/metronome.c
+++ b/apps/plugins/metronome.c
@@ -20,6 +20,8 @@
#if !defined(SIMULATOR)
+PLUGIN_HEADER
+
/* variable button definitions */
#if CONFIG_KEYPAD == RECORDER_PAD
#define METRONOME_QUIT BUTTON_OFF
@@ -907,7 +909,6 @@ void tap(void)
enum plugin_status plugin_start(struct plugin_api* api, void* parameter){
int button;
- TEST_PLUGIN_API(api);
(void)parameter;
rb = api;
diff --git a/apps/plugins/midi2wav.c b/apps/plugins/midi2wav.c
index e0f9e83..d0d4661 100644
--- a/apps/plugins/midi2wav.c
+++ b/apps/plugins/midi2wav.c
@@ -41,6 +41,8 @@
//#include "../codecs/lib/xxx2wav.h"
+PLUGIN_HEADER
+
int numberOfSamples IDATA_ATTR;
long bpm;
@@ -67,9 +69,6 @@ struct plugin_api * rb;
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
- TEST_PLUGIN_API(api);
- rb = api;
- TEST_PLUGIN_API(api);
(void)parameter;
rb = api;
diff --git a/apps/plugins/minesweeper.c b/apps/plugins/minesweeper.c
index 624c807..5baaea6 100644
--- a/apps/plugins/minesweeper.c
+++ b/apps/plugins/minesweeper.c
@@ -28,11 +28,11 @@ use F3 to see how many mines are left (supposing all your flags are correct)
*****************************************************************************/
#include "plugin.h"
-#include "button.h"
-#include "lcd.h"
#ifdef HAVE_LCD_BITMAP
+PLUGIN_HEADER
+
//what the minesweeper() function can return
#define MINESWEEPER_USB 3
#define MINESWEEPER_QUIT 2
@@ -521,7 +521,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
bool exit = false;
/* plugin init */
- TEST_PLUGIN_API(api);
(void)parameter;
rb = api;
/* end of plugin init */
diff --git a/apps/plugins/mosaique.c b/apps/plugins/mosaique.c
index 7a18bc2..bccc436 100644
--- a/apps/plugins/mosaique.c
+++ b/apps/plugins/mosaique.c
@@ -19,6 +19,8 @@
#include "plugin.h"
#include "playergfx.h"
+PLUGIN_HEADER
+
#ifdef HAVE_LCD_BITMAP
#define LARGE ((LCD_WIDTH - 2) / 2)
#define HAUT ((LCD_HEIGHT - 2) / 2)
@@ -72,7 +74,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
int sx = 3;
int sy = 3;
struct plugin_api* rb = api;
- TEST_PLUGIN_API(api);
(void)parameter;
#ifdef HAVE_LCD_CHARCELLS
diff --git a/apps/plugins/mp3_encoder.c b/apps/plugins/mp3_encoder.c
index 0171bc4..bd1a304 100644
--- a/apps/plugins/mp3_encoder.c
+++ b/apps/plugins/mp3_encoder.c
@@ -38,6 +38,8 @@ enum e_byte_order { order_unknown, order_bigEndian, order_littleEndian };
#define memcpy rb->memcpy
#define memset rb->memset
+PLUGIN_HEADER
+
static struct plugin_api* rb;
extern char iramcopy[];
extern char iramstart[];
@@ -1892,8 +1894,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
char *bitratename[] = { "64","80","96","112","128","160","192","224","256","320" };
int brate[] = { 64,80,96,112,128,160,192,224,256,320 };
- TEST_PLUGIN_API(api);
-
(void)parameter;
rb = api;
diff --git a/apps/plugins/nim.c b/apps/plugins/nim.c
index 27f1210..d937af1 100644
--- a/apps/plugins/nim.c
+++ b/apps/plugins/nim.c
@@ -20,7 +20,7 @@
#ifdef HAVE_LCD_CHARCELLS
-/* NIM game for the player
+/* NIM game for the player
Rules of nim game
-----------------
@@ -46,6 +46,7 @@ V1.2 : 2003-07-30
take a match. Later you are obliged to take at least one.)
*/
+PLUGIN_HEADER
/*Pattern for the game*/
static unsigned char smile[]={0x00, 0x11, 0x04, 0x04, 0x00, 0x11, 0x0E}; /* :-) */
@@ -140,11 +141,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
bool ok;
bool go;
- /* this macro should be called as the first thing you do in the plugin.
- it test that the api version and model the plugin was compiled for
- matches the machine it is running on */
- TEST_PLUGIN_API(api);
-
/* if you don't use the parameter, you can do like
this to avoid the compiler warning about it */
(void)parameter;
diff --git a/apps/plugins/oscillograph.c b/apps/plugins/oscillograph.c
index 069ef44..13858a1 100644
--- a/apps/plugins/oscillograph.c
+++ b/apps/plugins/oscillograph.c
@@ -22,6 +22,8 @@
#ifndef SIMULATOR /* don't want this code in the simulator */
#if CONFIG_CODEC != SWCODEC /* only for MAS-targets */
+PLUGIN_HEADER
+
/* The different drawing modes */
#define DRAW_MODE_FILLED 0
#define DRAW_MODE_OUTLINE 1
@@ -93,7 +95,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
bool exit = false;
- TEST_PLUGIN_API(api);
(void)parameter;
rb = api;
diff --git a/apps/plugins/oscilloscope.c b/apps/plugins/oscilloscope.c
index 916e550..b69d15d 100644
--- a/apps/plugins/oscilloscope.c
+++ b/apps/plugins/oscilloscope.c
@@ -25,6 +25,8 @@
#ifdef HAVE_LCD_BITMAP /* and also not for the Player */
#if CONFIG_CODEC != SWCODEC /* only for MAS-targets */
+PLUGIN_HEADER
+
/* The different drawing modes */
#define DRAW_MODE_FILLED 0
#define DRAW_MODE_OUTLINE 1
@@ -201,7 +203,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
bool exit = false;
bool paused = false;
- TEST_PLUGIN_API(api);
(void)parameter;
rb = api;
diff --git a/apps/plugins/plasma.c b/apps/plugins/plasma.c
index 2623bdc..46cf4c7 100644
--- a/apps/plugins/plasma.c
+++ b/apps/plugins/plasma.c
@@ -28,6 +28,8 @@
#ifdef HAVE_LCD_BITMAP /* and also not for the Player */
#include "gray.h"
+PLUGIN_HEADER
+
/******************************* Globals ***********************************/
static struct plugin_api* rb; /* global api struct pointer */
@@ -241,13 +243,6 @@ int main(void)
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
int ret;
- /*
- * this macro should be called as the first thing you do in the plugin.
- * it test that the api version and model the plugin was compiled for
- * matches the machine it is running on
- */
-
- TEST_PLUGIN_API(api);
rb = api; // copy to global api pointer
(void)parameter;
diff --git a/apps/plugins/plugin.lds b/apps/plugins/plugin.lds
index c8ac88f..0626623 100644
--- a/apps/plugins/plugin.lds
+++ b/apps/plugins/plugin.lds
@@ -64,7 +64,13 @@ MEMORY
SECTIONS
{
- .text :
+ .header : {
+ _plugin_start_addr = .;
+ plugin_start_addr = .;
+ KEEP(*(.header))
+ } > PLUGIN_RAM
+
+ .text :
{
KEEP(*(.entry))
*(.text*)
@@ -80,7 +86,7 @@ SECTIONS
. = ALIGN(0x4);
} > PLUGIN_RAM
- .data :
+ .data :
{
*(.data*)
#if defined(ARCH_IRIVER) || defined(ARCH_IPOD) || (CONFIG_CPU==PNX0101)
@@ -118,6 +124,9 @@ SECTIONS
{
*(.bss*)
*(COMMON)
+ . = ALIGN(0x4);
+ _plugin_end_addr = .;
+ plugin_end_addr = .;
} > PLUGIN_RAM
/* Special trick to avoid a linker error when no other sections are
diff --git a/apps/plugins/pong.c b/apps/plugins/pong.c
index 41507c5..4e9d99b 100644
--- a/apps/plugins/pong.c
+++ b/apps/plugins/pong.c
@@ -20,6 +20,8 @@
#ifdef HAVE_LCD_BITMAP
+PLUGIN_HEADER
+
#define PAD_HEIGHT LCD_HEIGHT / 6 /* Recorder: 10 iRiver: 21 */
#define PAD_WIDTH LCD_WIDTH / 50 /* Recorder: 2 iRiver: 2 */
@@ -336,9 +338,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
/* if you don't use the parameter, you can do like
this to avoid the compiler warning about it */
(void)parameter;
-
- TEST_PLUGIN_API(api);
-
+
rb = api; /* use the "standard" rb pointer */
/* Clear screen */
diff --git a/apps/plugins/rockblox.c b/apps/plugins/rockblox.c
index 786e590..f30a21a 100644
--- a/apps/plugins/rockblox.c
+++ b/apps/plugins/rockblox.c
@@ -22,6 +22,8 @@
#ifdef HAVE_LCD_BITMAP
+PLUGIN_HEADER
+
#if (CONFIG_KEYPAD == IPOD_4G_PAD)
#define ROCKBLOX_OFF BUTTON_MENU
#define ROCKBLOX_UP BUTTON_SCROLL_BACK
@@ -420,11 +422,9 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
int ret;
- TEST_PLUGIN_API(api);
-
(void)parameter;
rb = api;
-
+
/* Lets use the default font */
rb->lcd_setfont(FONT_SYSFIXED);
diff --git a/apps/plugins/rockbox_flash.c b/apps/plugins/rockbox_flash.c
index 4c55262..0b71340 100644
--- a/apps/plugins/rockbox_flash.c
+++ b/apps/plugins/rockbox_flash.c
@@ -23,6 +23,8 @@
#if !defined(SIMULATOR) && (CONFIG_CPU == SH7034) /* Only for SH targets */
+PLUGIN_HEADER
+
/* define DUMMY if you only want to "play" with the UI, does no harm */
/* #define DUMMY */
@@ -1010,10 +1012,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
int oldmode;
- /* this macro should be called as the first thing you do in the plugin.
- it test that the api version and model the plugin was compiled for
- matches the machine it is running on */
- TEST_PLUGIN_API(api);
rb = api; /* copy to global api pointer */
if (parameter == NULL)
diff --git a/apps/plugins/rockboy.c b/apps/plugins/rockboy.c
index 783e096..d350457 100644
--- a/apps/plugins/rockboy.c
+++ b/apps/plugins/rockboy.c
@@ -22,6 +22,8 @@
#if MEM <= 8 && !defined(SIMULATOR)
+PLUGIN_HEADER
+
#define OVL_NAME "/.rockbox/viewers/rockboy.ovl"
#define OVL_DISPLAYNAME "RockBoy"
@@ -40,10 +42,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
enum plugin_status(*entry_point)(struct plugin_api*, void*);
} header;
- /* this macro should be called as the first thing you do in the plugin.
- it test that the api version and model the plugin was compiled for
- matches the machine it is running on */
- TEST_PLUGIN_API(api);
rb = api;
fh = rb->open(OVL_NAME, O_RDONLY);
diff --git a/apps/plugins/rockboy/Makefile b/apps/plugins/rockboy/Makefile
index 3657e8d..f0dbc55 100644
--- a/apps/plugins/rockboy/Makefile
+++ b/apps/plugins/rockboy/Makefile
@@ -10,7 +10,7 @@
INCLUDES = -I$(APPSDIR) -I.. -I. -I$(FIRMDIR)/include -I$(FIRMDIR)/export \
-I$(FIRMDIR)/common -I$(FIRMDIR)/drivers -I$(OUTDIR) -I$(BUILDDIR)
CFLAGS = $(GCCOPTS) -O3 $(INCLUDES) $(TARGET) $(EXTRA_DEFINES) \
- -DMEM=${MEMORYSIZE} -DPLUGIN
+ -DTARGET_ID=$(TARGET_ID) -DMEM=${MEMORYSIZE} -DPLUGIN
ifdef APPEXTRA
INCLUDES += $(patsubst %,-I$(APPSDIR)/%,$(subst :, ,$(APPEXTRA)))
diff --git a/apps/plugins/rockboy/rockboy.c b/apps/plugins/rockboy/rockboy.c
index fc004e7..a21e9e4 100644
--- a/apps/plugins/rockboy/rockboy.c
+++ b/apps/plugins/rockboy/rockboy.c
@@ -36,6 +36,8 @@ const struct {
0x524f564c, /* ROVL */
ovl_start_addr, ovl_end_addr, plugin_start
};
+#else
+PLUGIN_HEADER
#endif
#ifdef USE_IRAM
@@ -93,17 +95,12 @@ void setmallocpos(void *pointer)
/* this is the plugin entry point */
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
- /* this macro should be called as the first thing you do in the plugin.
- it test that the api version and model the plugin was compiled for
- matches the machine it is running on */
- TEST_PLUGIN_API(api);
-
/* if you are using a global api pointer, don't forget to copy it!
otherwise you will get lovely "I04: IllInstr" errors... :-) */
rb = api;
rb->lcd_setfont(0);
-
+
if (!parameter) {
rb->splash(HZ*3, true, "Play gameboy ROM file! (.gb/.gbc)");
return PLUGIN_OK;
diff --git a/apps/plugins/search.c b/apps/plugins/search.c
index 450b05c..fb9d239 100644
--- a/apps/plugins/search.c
+++ b/apps/plugins/search.c
@@ -20,6 +20,8 @@
#include "plugin.h"
#include "ctype.h"
+PLUGIN_HEADER
+
static struct plugin_api* rb;
#define BUFFER_SIZE 16384
@@ -150,8 +152,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
char *filename = parameter;
char *p;
- TEST_PLUGIN_API(api);
-
rb = api;
DEBUGF("%s - %s\n", parameter, &filename[rb->strlen(filename)-4]);
diff --git a/apps/plugins/searchengine/Makefile b/apps/plugins/searchengine/Makefile
index efa7d95..baa0020 100644
--- a/apps/plugins/searchengine/Makefile
+++ b/apps/plugins/searchengine/Makefile
@@ -10,7 +10,7 @@
INCLUDES = -I$(APPSDIR) -I.. -I. -I$(FIRMDIR)/include -I$(FIRMDIR)/export \
-I$(FIRMDIR)/common -I$(FIRMDIR)/drivers -I$(OUTDIR) -I$(BUILDDIR)
CFLAGS = $(GCCOPTS) -O3 $(INCLUDES) $(TARGET) $(EXTRA_DEFINES) \
- -DMEM=${MEMORYSIZE} -DPLUGIN
+ -DTARGET_ID=$(TARGET_ID) -DMEM=${MEMORYSIZE} -DPLUGIN
ifdef APPEXTRA
INCLUDES += $(patsubst %,-I$(APPSDIR)/%,$(subst :, ,$(APPEXTRA)))
diff --git a/apps/plugins/searchengine/searchengine.c b/apps/plugins/searchengine/searchengine.c
index 8953ba7..b585c25 100644
--- a/apps/plugins/searchengine/searchengine.c
+++ b/apps/plugins/searchengine/searchengine.c
@@ -21,6 +21,8 @@
#include "token.h"
#include "dbinterface.h"
+PLUGIN_HEADER
+
void *audio_bufferbase;
void *audio_bufferpointer;
unsigned int audio_buffer_free;
@@ -58,15 +60,10 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
unsigned char *result,buf[500];
int parsefd,hits;
- /* this macro should be called as the first thing you do in the plugin.
- it test that the api version and model the plugin was compiled for
- matches the machine it is running on */
- TEST_PLUGIN_API(api);
-
/* if you are using a global api pointer, don't forget to copy it!
otherwise you will get lovely "I04: IllInstr" errors... :-) */
rb = api;
-
+
audio_bufferbase=audio_bufferpointer=0;
audio_buffer_free=0;
diff --git a/apps/plugins/sliding_puzzle.c b/apps/plugins/sliding_puzzle.c
index a153467..060ab18 100644
--- a/apps/plugins/sliding_puzzle.c
+++ b/apps/plugins/sliding_puzzle.c
@@ -19,6 +19,8 @@
#include "plugin.h"
#ifdef HAVE_LCD_BITMAP
+PLUGIN_HEADER
+
/* variable button definitions */
#if CONFIG_KEYPAD == RECORDER_PAD
#define PUZZLE_QUIT BUTTON_OFF
@@ -333,7 +335,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
int i, w, h;
- TEST_PLUGIN_API(api);
(void)parameter;
rb = api;
diff --git a/apps/plugins/snake.c b/apps/plugins/snake.c
index bf5d8f9..dc78f17 100644
--- a/apps/plugins/snake.c
+++ b/apps/plugins/snake.c
@@ -33,6 +33,8 @@ dir is the current direction of the snake - 0=up, 1=right, 2=down, 3=left;
#include "plugin.h"
#ifdef HAVE_LCD_BITMAP
+PLUGIN_HEADER
+
/* variable button definitions */
#if CONFIG_KEYPAD == RECORDER_PAD
#define SNAKE_QUIT BUTTON_OFF
@@ -344,7 +346,6 @@ void game_init(void) {
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
- TEST_PLUGIN_API(api);
(void)(parameter);
rb = api;
diff --git a/apps/plugins/snake2.c b/apps/plugins/snake2.c
index ea526b3..4008209 100644
--- a/apps/plugins/snake2.c
+++ b/apps/plugins/snake2.c
@@ -30,6 +30,8 @@ Head and Tail are stored
#include "plugin.h"
#ifdef HAVE_LCD_BITMAP
+PLUGIN_HEADER
+
#define WIDTH 28
#define HEIGHT 16
@@ -1425,7 +1427,6 @@ void game_init(void)
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
- TEST_PLUGIN_API(api);
(void)(parameter);
rb = api;
diff --git a/apps/plugins/snow.c b/apps/plugins/snow.c
index 7fd0c8a..a1405a1 100644
--- a/apps/plugins/snow.c
+++ b/apps/plugins/snow.c
@@ -19,6 +19,8 @@
#include "plugin.h"
#include "playergfx.h"
+PLUGIN_HEADER
+
#ifdef HAVE_LCD_BITMAP
#define NUM_PARTICLES (LCD_WIDTH * LCD_HEIGHT / 72)
#define SNOW_HEIGHT LCD_HEIGHT
@@ -161,7 +163,6 @@ static void snow_init(void)
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
int button;
- TEST_PLUGIN_API(api);
(void)(parameter);
rb = api;
diff --git a/apps/plugins/sokoban.c b/apps/plugins/sokoban.c
index 5159973..994a117 100644
--- a/apps/plugins/sokoban.c
+++ b/apps/plugins/sokoban.c
@@ -22,6 +22,8 @@
#ifdef HAVE_LCD_BITMAP
+PLUGIN_HEADER
+
#define SOKOBAN_TITLE "Sokoban"
#define SOKOBAN_TITLE_FONT 2
@@ -896,7 +898,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
int w, h;
int len;
- TEST_PLUGIN_API(api);
(void)(parameter);
rb = api;
diff --git a/apps/plugins/solitaire.c b/apps/plugins/solitaire.c
index 81bd820..9a60635 100644
--- a/apps/plugins/solitaire.c
+++ b/apps/plugins/solitaire.c
@@ -39,6 +39,8 @@ use F3 to put card on top of the remains' stack on one of the 4 final stacks
#ifdef HAVE_LCD_BITMAP
+PLUGIN_HEADER
+
/* here is a global api struct pointer. while not strictly necessary,
it's nice not to have to pass the api pointer in all function calls
in the plugin */
@@ -1541,7 +1543,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
int result;
/* plugin init */
- TEST_PLUGIN_API(api);
(void)parameter;
rb = api;
/* end of plugin init */
diff --git a/apps/plugins/sort.c b/apps/plugins/sort.c
index cf91dbb..7ba510e 100644
--- a/apps/plugins/sort.c
+++ b/apps/plugins/sort.c
@@ -55,6 +55,8 @@
* TODO: Implement a merge sort for files larger than the buffer
****************************************************************************/
+PLUGIN_HEADER
+
static struct plugin_api* rb;
int buf_size;
@@ -178,7 +180,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
char *buf;
int rc;
- TEST_PLUGIN_API(api);
filename = (char *)parameter;
diff --git a/apps/plugins/splitedit.c b/apps/plugins/splitedit.c
index 35562f9..d0fd4e1 100644
--- a/apps/plugins/splitedit.c
+++ b/apps/plugins/splitedit.c
@@ -22,6 +22,8 @@
#ifndef SIMULATOR
#ifdef HAVE_LCD_BITMAP
+PLUGIN_HEADER
+
/* variable button definitions */
#if CONFIG_KEYPAD == RECORDER_PAD
#define SPLITEDIT_QUIT BUTTON_OFF
diff --git a/apps/plugins/star.c b/apps/plugins/star.c
index c6a2853..03dac34 100644
--- a/apps/plugins/star.c
+++ b/apps/plugins/star.c
@@ -19,6 +19,8 @@
#include "plugin.h"
#ifdef HAVE_LCD_BITMAP
+PLUGIN_HEADER
+
/* file which contains the levels */
#define STAR_LEVELS_FILE "/.rockbox/star/levels.txt"
@@ -877,7 +879,6 @@ static int star_menu(void)
*/
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
- TEST_PLUGIN_API(api);
(void)parameter;
rb = api;
diff --git a/apps/plugins/starfield.c b/apps/plugins/starfield.c
index 407e79f..750c59f 100644
--- a/apps/plugins/starfield.c
+++ b/apps/plugins/starfield.c
@@ -19,6 +19,8 @@
#ifdef HAVE_LCD_BITMAP /* and also not for the Player */
+PLUGIN_HEADER
+
/******************************* Globals ***********************************/
static struct plugin_api* rb; /* global api struct pointer */
@@ -251,13 +253,6 @@ int plugin_main(void)
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
int ret;
- /*
- * this macro should be called as the first thing you do in the plugin.
- * it test that the api version and model the plugin was compiled for
- * matches the machine it is running on
- */
-
- TEST_PLUGIN_API(api);
rb = api; // copy to global api pointer
(void)parameter;
diff --git a/apps/plugins/stats.c b/apps/plugins/stats.c
index e1b8b6f..b54adb5 100644
--- a/apps/plugins/stats.c
+++ b/apps/plugins/stats.c
@@ -18,6 +18,8 @@
****************************************************************************/
#include "plugin.h"
+PLUGIN_HEADER
+
static struct plugin_api* rb;
static int files, dirs;
static int lasttick;
@@ -100,7 +102,6 @@ void traversedir(char* location, char* name)
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
int button;
- TEST_PLUGIN_API(api);
(void)parameter;
diff --git a/apps/plugins/stopwatch.c b/apps/plugins/stopwatch.c
index 4a1382e..3742a9a 100644
--- a/apps/plugins/stopwatch.c
+++ b/apps/plugins/stopwatch.c
@@ -19,6 +19,8 @@
#include "plugin.h"
+PLUGIN_HEADER
+
#ifdef HAVE_LCD_BITMAP
#define LAP_LINES 6
#define TIMER_Y 1
@@ -121,7 +123,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
int done = false;
bool update_lap = true;
- TEST_PLUGIN_API(api);
(void)parameter;
rb = api;
diff --git a/apps/plugins/sudoku.c b/apps/plugins/sudoku.c
index 453a444..94ff96d 100644
--- a/apps/plugins/sudoku.c
+++ b/apps/plugins/sudoku.c
@@ -57,11 +57,11 @@ Example ".ss" file, and one with a saved state:
*/
#include "plugin.h"
-#include "button.h"
-#include "lcd.h"
#ifdef HAVE_LCD_BITMAP
+PLUGIN_HEADER
+
#define STATE_FILE PLUGIN_DIR "/sudoku.state"
#define GAMES_FILE PLUGIN_DIR "/sudoku.levels"
@@ -2429,7 +2429,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
struct sudoku_state_t state;
/* plugin init */
- TEST_PLUGIN_API(api);
rb = api;
/* end of plugin init */
diff --git a/apps/plugins/vbrfix.c b/apps/plugins/vbrfix.c
index ca6b9ca..d05419f 100644
--- a/apps/plugins/vbrfix.c
+++ b/apps/plugins/vbrfix.c
@@ -18,6 +18,8 @@
****************************************************************************/
#include "plugin.h"
+PLUGIN_HEADER
+
static struct plugin_api* rb;
static char *audiobuf;
@@ -265,8 +267,6 @@ static bool vbr_fix(char *selected_file)
enum plugin_status plugin_start(struct plugin_api* api, void *parameter)
{
- TEST_PLUGIN_API(api);
-
rb = api;
if (!parameter)
diff --git a/apps/plugins/video.c b/apps/plugins/video.c
index 91d47a5..6ed7036 100644
--- a/apps/plugins/video.c
+++ b/apps/plugins/video.c
@@ -32,6 +32,8 @@
#ifndef SIMULATOR // not for simulator by now
#ifdef HAVE_LCD_BITMAP // and definitely not for the Player, haha
+PLUGIN_HEADER
+
/* variable button definitions */
#if CONFIG_KEYPAD == RECORDER_PAD
#define VIDEO_STOP_SEEK BUTTON_PLAY
@@ -984,11 +986,6 @@ int main(char* filename)
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
- /* this macro should be called as the first thing you do in the plugin.
- it test that the api version and model the plugin was compiled for
- matches the machine it is running on */
- TEST_PLUGIN_API(api);
-
rb = api; // copy to global api pointer
if (parameter == NULL)
diff --git a/apps/plugins/viewer.c b/apps/plugins/viewer.c
index 823072e..b98605a 100644
--- a/apps/plugins/viewer.c
+++ b/apps/plugins/viewer.c
@@ -20,9 +20,7 @@
#include "plugin.h"
#include <ctype.h>
-#if PLUGIN_API_VERSION < 3
-#error Scrollbar function requires PLUGIN_API_VERSION 3 at least
-#endif
+PLUGIN_HEADER
#define SETTINGS_FILE "/.rockbox/viewers/viewer.dat"
@@ -1022,7 +1020,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* file)
int i;
int ok;
- TEST_PLUGIN_API(api);
rb = api;
if (!file)
diff --git a/apps/plugins/vu_meter.c b/apps/plugins/vu_meter.c
index 6a55a1a..b486c3c 100644
--- a/apps/plugins/vu_meter.c
+++ b/apps/plugins/vu_meter.c
@@ -19,6 +19,8 @@
#if defined(HAVE_LCD_BITMAP) && (CONFIG_CODEC != SWCODEC)
+PLUGIN_HEADER
+
/* variable button definitions */
#if CONFIG_KEYPAD == RECORDER_PAD
#define VUMETER_QUIT BUTTON_OFF
@@ -427,7 +429,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) {
int button;
int lastbutton = BUTTON_NONE;
- TEST_PLUGIN_API(api);
(void) parameter;
rb = api;
diff --git a/apps/plugins/wav2wv.c b/apps/plugins/wav2wv.c
index 1f47eff..20a4589 100644
--- a/apps/plugins/wav2wv.c
+++ b/apps/plugins/wav2wv.c
@@ -20,6 +20,8 @@
#include <codecs/libwavpack/wavpack.h>
+PLUGIN_HEADER
+
#define SAMPLES_PER_BLOCK 22050
static struct plugin_api* rb;
@@ -287,8 +289,6 @@ static int wav2wv (char *filename)
enum plugin_status plugin_start(struct plugin_api* api, void *parameter)
{
- TEST_PLUGIN_API(api);
-
rb = api;
if (!parameter)
diff --git a/apps/plugins/wormlet.c b/apps/plugins/wormlet.c
index e0e33b6..6016cda 100644
--- a/apps/plugins/wormlet.c
+++ b/apps/plugins/wormlet.c
@@ -20,6 +20,8 @@
#if defined(HAVE_LCD_BITMAP) && (CONFIG_KEYPAD == RECORDER_PAD)
+PLUGIN_HEADER
+
/* size of the field the worm lives in */
#define FIELD_RECT_X 1
#define FIELD_RECT_Y 1
@@ -1891,7 +1893,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
bool worm_dead = false;
int button;
- TEST_PLUGIN_API(api);
(void)(parameter);
rb = api;
diff --git a/tools/configure b/tools/configure
index f8fea6e..2cd855e 100755
--- a/tools/configure
+++ b/tools/configure
@@ -427,7 +427,7 @@ appsdir='\$(ROOTDIR)/apps'
echo "15 - iPod Video"
echo "16 - iriver iFP-790"
- getit=`input`;
+ target_id=`input`;
# Set of tools built for all target platforms:
toolset="rdf2binary convbdf"
@@ -437,7 +437,7 @@ appsdir='\$(ROOTDIR)/apps'
iriverbitmaptools="$toolset scramble descramble mkboot bmp2rb codepages"
ipodbitmaptools="$toolset scramble ipod_fw bmp2rb codepages"
- case $getit in
+ case $target_id in
1)
archos="player"
@@ -881,6 +881,7 @@ sed > Makefile \
-e "s,@ROOTDIR@,${rootdir},g" \
-e "s,@DEBUG@,${debug},g" \
-e "s,@MEMORY@,${memory},g" \
+ -e "s,@TARGET_ID@,${target_id},g" \
-e "s,@TARGET@,${target},g" \
-e "s,@ARCHOS@,${archos},g" \
-e "s,@LANGUAGE@,${language},g" \
@@ -927,6 +928,7 @@ export DEBUG=@DEBUG@
export ARCHOS=@ARCHOS@
export ARCHOSROM=@ARCHOSROM@
export FLASHFILE=@FLASHFILE@
+export TARGET_ID=@TARGET_ID@
export TARGET=@TARGET@
export OBJDIR=@PWD@
export BUILDDIR=@PWD@