diff --git a/apps/codecs.c b/apps/codecs.c index da4b1f8bff..16338c263c 100644 --- a/apps/codecs.c +++ b/apps/codecs.c @@ -16,6 +16,8 @@ * KIND, either express or implied. * ****************************************************************************/ +#include "config.h" + #include #include #include @@ -52,7 +54,7 @@ #ifdef SIMULATOR #if CONFIG_HWCODEC == MASNONE -static unsigned char codecbuf[CODEC_BUFFER_SIZE]; +static unsigned char codecbuf[CODEC_SIZE]; #endif void *sim_codec_load(char *plugin, int *fd); void sim_codec_close(int fd); @@ -251,9 +253,9 @@ int codec_load_ram(char* codecptr, size_t size, void* ptr2, size_t bufwrap) if ((char *)&codecbuf[0] != codecptr) { /* zero out codec buffer to ensure a properly zeroed bss area */ - memset(codecbuf, 0, CODEC_BUFFER_SIZE); + memset(codecbuf, 0, CODEC_SIZE); - size = MIN(size, CODEC_BUFFER_SIZE); + size = MIN(size, CODEC_SIZE); copy_n = MIN(size, bufwrap); memcpy(codecbuf, codecptr, copy_n); size -= copy_n; @@ -283,7 +285,7 @@ int codec_load_file(const char *plugin) return fd; } - rc = read(fd, &codecbuf[0], CODEC_BUFFER_SIZE); + rc = read(fd, &codecbuf[0], CODEC_SIZE); close(fd); if (rc <= 0) { logf("Codec read error"); diff --git a/apps/codecs.h b/apps/codecs.h index c50af3030e..1a03139be8 100644 --- a/apps/codecs.h +++ b/apps/codecs.h @@ -72,10 +72,6 @@ #endif -/* This size must match the one set in ../plugins/plugin.lds and - ../../firmware/app.lds */ -#define CODEC_BUFFER_SIZE 0x40000 - #ifdef SIMULATOR #define PREFIX(_x_) sim_ ## _x_ #else diff --git a/apps/plugin.h b/apps/plugin.h index 6d2b6e5bf0..d2253b42c6 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -80,13 +80,6 @@ #endif -/* These three sizes must match the ones set in plugins/plugin.lds */ -#if MEM >= 32 -#define PLUGIN_BUFFER_SIZE 0xC0000 -#else -#define PLUGIN_BUFFER_SIZE 0x8000 -#endif - #ifdef SIMULATOR #define PREFIX(_x_) sim_ ## _x_ #else diff --git a/apps/plugins/Makefile b/apps/plugins/Makefile index fbae027ca3..a59e33f5c6 100644 --- a/apps/plugins/Makefile +++ b/apps/plugins/Makefile @@ -51,7 +51,7 @@ endif all: $(BUILDDIR)/libplugin.a $(ROCKS) $(SUBDIRS) $(DEPFILE) ifndef SIMVER -$(OBJDIR)/%.elf: $(OBJDIR)/%.o $(LINKFILE) $(LINKCODEC) $(BUILDDIR)/libplugin.a +$(OBJDIR)/%.elf: $(OBJDIR)/%.o $(LINKFILE) $(BUILDDIR)/libplugin.a $(SILENT)(file=`basename $@`; \ echo "LD $$file"; \ $(CC) $(GCCOPTS) -O -nostdlib -o $@ $< -L$(BUILDDIR) $(CODECLIBS) -lplugin -lgcc -T$(LINKFILE) -Wl,-Map,$(OBJDIR)/$*.map) diff --git a/apps/plugins/plugin.lds b/apps/plugins/plugin.lds index f1b4d300d7..3e624d6a0b 100644 --- a/apps/plugins/plugin.lds +++ b/apps/plugins/plugin.lds @@ -22,19 +22,9 @@ OUTPUT_FORMAT(elf32-sh) #define DRAMORIG 0x09000000 + STUBOFFSET #endif +#define PLUGIN_LENGTH PLUGIN_BUFFER_SIZE + #ifdef CODEC -#define CODEC_SIZE 0x40000 -#else -#define CODEC_SIZE 0 -#endif - -#if MEMORYSIZE >= 32 -#define PLUGIN_LENGTH 0xC0000 -#else -#define PLUGIN_LENGTH 0x8000 -#endif - -#if CODEC_SIZE > 0 #define THIS_LENGTH CODEC_SIZE #else #define THIS_LENGTH PLUGIN_LENGTH diff --git a/apps/plugins/rockboy/archos.lds b/apps/plugins/rockboy/archos.lds index 23d03c6297..9412c4365a 100755 --- a/apps/plugins/rockboy/archos.lds +++ b/apps/plugins/rockboy/archos.lds @@ -6,7 +6,7 @@ OUTPUT_FORMAT(elf32-sh) #define DRAMORIG 0x09000000 -#define PLUGIN_LENGTH 0x8000 +#define PLUGIN_LENGTH PLUGIN_BUFFER_SIZE #define OVERLAY_LENGTH 0x68000 #define OVERLAY_ORIGIN (DRAMORIG + (MEMORYSIZE * 0x100000) - PLUGIN_LENGTH - OVERLAY_LENGTH) diff --git a/firmware/app.lds b/firmware/app.lds index 91f03955cc..ee666d8cb3 100644 --- a/firmware/app.lds +++ b/firmware/app.lds @@ -101,17 +101,9 @@ _pluginbuf = 0; #else -#if MEMORYSIZE >= 32 -#define PLUGINSIZE 0xC0000 -#else -#define PLUGINSIZE 0x8000 -#endif +#define PLUGINSIZE PLUGIN_BUFFER_SIZE +#define CODECSIZE CODEC_SIZE -#if CONFIG_HWCODEC == MASNONE -#define CODECSIZE 0x40000 -#else -#define CODECSIZE 0 -#endif #ifdef DEBUG #define STUBOFFSET 0x10000 diff --git a/firmware/export/config-fmrecorder.h b/firmware/export/config-fmrecorder.h index a3f2597d5d..d566ffd7eb 100644 --- a/firmware/export/config-fmrecorder.h +++ b/firmware/export/config-fmrecorder.h @@ -17,6 +17,9 @@ /* Define this if you have a software controlled poweroff */ #define HAVE_SW_POWEROFF +/* The number of bytes reserved for loadable plugins */ +#define PLUGIN_BUFFER_SIZE 0x8000 + #ifndef SIMULATOR /* Define this if you have a MAS3587F */ diff --git a/firmware/export/config-gmini120.h b/firmware/export/config-gmini120.h index 93b8727b63..fa7e98eb45 100644 --- a/firmware/export/config-gmini120.h +++ b/firmware/export/config-gmini120.h @@ -19,6 +19,13 @@ /* Define this if you have a software controlled poweroff */ #define HAVE_SW_POWEROFF +/* The number of bytes reserved for loadable codecs. Although in this case + the codec won't be loadable... */ +#define CODEC_SIZE 0x40000 + +/* The number of bytes reserved for loadable plugins */ +#define PLUGIN_BUFFER_SIZE 0xC0000 + #ifndef SIMULATOR /* Define this if you have a TCC730 (CalmRISC16) */ diff --git a/firmware/export/config-gminisp.h b/firmware/export/config-gminisp.h index 6a1105f30a..2bf97d5ef5 100644 --- a/firmware/export/config-gminisp.h +++ b/firmware/export/config-gminisp.h @@ -13,6 +13,13 @@ /* Define this if you have a software controlled poweroff */ #define HAVE_SW_POWEROFF +/* The number of bytes reserved for loadable codecs. Although in this case + the codec won't be loadable... */ +#define CODEC_SIZE 0x40000 + +/* The number of bytes reserved for loadable plugins */ +#define PLUGIN_BUFFER_SIZE 0xC0000 + #ifndef SIMULATOR /* Define this if you have a TCC730 (CalmRISC16) */ diff --git a/firmware/export/config-h100.h b/firmware/export/config-h100.h index 552eea1166..5c161ae7a0 100644 --- a/firmware/export/config-h100.h +++ b/firmware/export/config-h100.h @@ -27,6 +27,12 @@ /* Define this if you have a software controlled poweroff */ #define HAVE_SW_POWEROFF +/* The number of bytes reserved for loadable codecs */ +#define CODEC_SIZE 0x40000 + +/* The number of bytes reserved for loadable plugins */ +#define PLUGIN_BUFFER_SIZE 0xC0000 + #ifndef SIMULATOR /* Define this if you have a Motorola SCF5249 */ diff --git a/firmware/export/config-h300.h b/firmware/export/config-h300.h index 015f31ad8a..f6e1e69e31 100644 --- a/firmware/export/config-h300.h +++ b/firmware/export/config-h300.h @@ -25,6 +25,12 @@ /* Define this if you have a software controlled poweroff */ #define HAVE_SW_POWEROFF +/* The number of bytes reserved for loadable codecs */ +#define CODEC_SIZE 0x40000 + +/* The number of bytes reserved for loadable plugins */ +#define PLUGIN_BUFFER_SIZE 0xC0000 + #ifndef SIMULATOR /* Define this if you have a Motorola SCF5249 */ diff --git a/firmware/export/config-ondiofm.h b/firmware/export/config-ondiofm.h index 9436b86f1e..48f1d86128 100644 --- a/firmware/export/config-ondiofm.h +++ b/firmware/export/config-ondiofm.h @@ -14,6 +14,9 @@ /* Define this if you have a software controlled poweroff */ #define HAVE_SW_POWEROFF +/* The number of bytes reserved for loadable plugins */ +#define PLUGIN_BUFFER_SIZE 0x8000 + #ifndef SIMULATOR /* Define this if you have a SH7034 */ diff --git a/firmware/export/config-ondiosp.h b/firmware/export/config-ondiosp.h index fd79d19cb7..3030c2830e 100644 --- a/firmware/export/config-ondiosp.h +++ b/firmware/export/config-ondiosp.h @@ -11,6 +11,9 @@ /* Define this if you have a software controlled poweroff */ #define HAVE_SW_POWEROFF +/* The number of bytes reserved for loadable plugins */ +#define PLUGIN_BUFFER_SIZE 0x8000 + #ifndef SIMULATOR /* Define this if you have a SH7034 */ diff --git a/firmware/export/config-player.h b/firmware/export/config-player.h index eee9e97530..464561d90d 100644 --- a/firmware/export/config-player.h +++ b/firmware/export/config-player.h @@ -8,6 +8,9 @@ /* define this if you have the Player's keyboard */ #define CONFIG_KEYPAD PLAYER_PAD +/* The number of bytes reserved for loadable plugins */ +#define PLUGIN_BUFFER_SIZE 0x8000 + #ifndef SIMULATOR /* Define this if you have a SH7034 */ diff --git a/firmware/export/config-recorder.h b/firmware/export/config-recorder.h index 61c76d480d..4cc378f180 100644 --- a/firmware/export/config-recorder.h +++ b/firmware/export/config-recorder.h @@ -14,6 +14,9 @@ /* define this if you have a real-time clock */ #define HAVE_RTC 1 +/* The number of bytes reserved for loadable plugins */ +#define PLUGIN_BUFFER_SIZE 0x8000 + #ifndef SIMULATOR /* Define this if you have a MAS3587F */ diff --git a/firmware/export/config-recorderv2.h b/firmware/export/config-recorderv2.h index c75f0e6f12..a9c8afcdd3 100644 --- a/firmware/export/config-recorderv2.h +++ b/firmware/export/config-recorderv2.h @@ -17,6 +17,9 @@ /* Define this if you have a software controlled poweroff */ #define HAVE_SW_POWEROFF +/* The number of bytes reserved for loadable plugins */ +#define PLUGIN_BUFFER_SIZE 0x8000 + #ifndef SIMULATOR /* Define this if you have a SH7034 */ diff --git a/firmware/export/config.h b/firmware/export/config.h index e0d901b587..61c9899762 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h @@ -108,4 +108,8 @@ /* no known platform */ #endif +#ifndef CODEC_SIZE +#define CODEC_SIZE 0 +#endif + #endif