summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2005-06-22 02:47:54 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2005-06-22 02:47:54 +0000
commitecf2f747edae9ffc3eb0057958da41915cbfac19 (patch)
tree7aa2c608a86033351ca6eaaa3f1c00488ee59cfe /apps
parent2f2b9eab4b44f35f4aa82cd9c61255debcfa2f03 (diff)
Daniel's fix that loads codecs in their own memory space
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6794 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/playback.c4
-rw-r--r--apps/plugin.c43
-rw-r--r--apps/plugin.h8
-rw-r--r--apps/plugins/Makefile20
-rw-r--r--apps/plugins/plugin.lds17
5 files changed, 56 insertions, 36 deletions
diff --git a/apps/playback.c b/apps/playback.c
index b2a31bf87f..f384a23a08 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -119,10 +119,10 @@ static const char codec_thread_name[] = "codec";
static volatile bool filling;
/* Ring buffer where tracks and codecs are loaded. */
-char *codecbuf;
+static char *codecbuf;
/* Total size of the ring buffer. */
-int codecbuflen;
+static int codecbuflen;
/* Bytes available in the buffer. */
static volatile int codecbufused;
diff --git a/apps/plugin.c b/apps/plugin.c
index 726a518508..a1a0b0629c 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -61,22 +61,21 @@
#include "lcd-remote.h"
#endif
-#if MEM >= 32
-#define PLUGIN_BUFFER_SIZE 0xC0000
-#else
-#define PLUGIN_BUFFER_SIZE 0x8000
-#endif
-
#ifdef SIMULATOR
static unsigned char pluginbuf[PLUGIN_BUFFER_SIZE];
+#if CONFIG_HWCODEC == MASNONE
+static unsigned char codecbuf[CODEC_BUFFER_SIZE];
+#endif
void *sim_plugin_load(char *plugin, int *fd);
void sim_plugin_close(int fd);
#else
#define sim_plugin_close(x)
extern unsigned char pluginbuf[];
+extern unsigned char codecbuf[];
#include "bitswap.h"
#endif
+/* for actual plugins only, not for codecs */
static bool plugin_loaded = false;
static int plugin_size = 0;
#ifndef SIMULATOR
@@ -334,38 +333,29 @@ static const struct plugin_api rockbox_api = {
};
#if CONFIG_HWCODEC == MASNONE
-int codec_load_ram(char* pluginptr, size_t size, void *parameter, void* ptr2,
+int codec_load_ram(char* codecptr, size_t size, void *parameter, void* ptr2,
size_t bufwrap)
{
enum plugin_status (*plugin_start)(struct plugin_api* api, void* param);
int copy_n;
int status;
- plugin_size = size;
- if ((int)&pluginbuf != (int)pluginptr) {
- /* zero out plugin buffer to ensure a properly zeroed bss area */
- memset(pluginbuf, 0, PLUGIN_BUFFER_SIZE);
+ if ((char *)&codecbuf[0] != codecptr) {
+ /* zero out codec buffer to ensure a properly zeroed bss area */
+ memset(codecbuf, 0, CODEC_BUFFER_SIZE);
- size = MIN(size, PLUGIN_BUFFER_SIZE);
+ size = MIN(size, CODEC_BUFFER_SIZE);
copy_n = MIN(size, bufwrap);
- memcpy(pluginbuf, pluginptr, copy_n);
-
+ memcpy(codecbuf, codecptr, copy_n);
size -= copy_n;
if (size > 0) {
- memcpy(&pluginbuf[copy_n], ptr2, size);
+ memcpy(&codecbuf[copy_n], ptr2, size);
}
}
-
- plugin_start = (void*)&pluginbuf;
-
- if (plugin_size <= 0) {
- return -1;
- }
-
- plugin_loaded = true;
+ plugin_start = (void*)&codecbuf;
+
invalidate_icache();
status = plugin_start((struct plugin_api*) &rockbox_api, parameter);
- plugin_loaded = false;
return status;
}
@@ -384,15 +374,14 @@ int codec_load_file(const char *plugin, void *parameter)
return fd;
}
- rc = read(fd, &pluginbuf[0], PLUGIN_BUFFER_SIZE);
+ rc = read(fd, &codecbuf[0], CODEC_BUFFER_SIZE);
close(fd);
if (rc <= 0) {
logf("Codec read error");
return PLUGIN_ERROR;
}
- plugin_size = rc;
- return codec_load_ram(pluginbuf, plugin_size, parameter, NULL, 0);
+ return codec_load_ram(codecbuf, (size_t)rc, parameter, NULL, 0);
}
#endif
diff --git a/apps/plugin.h b/apps/plugin.h
index dbfdca516e..94967c7673 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -80,6 +80,14 @@
#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
+#define CODEC_BUFFER_SIZE 0x3C000
+
#ifdef SIMULATOR
#define PREFIX(_x_) sim_ ## _x_
#else
diff --git a/apps/plugins/Makefile b/apps/plugins/Makefile
index fa0e8b8f74..44e055d2a4 100644
--- a/apps/plugins/Makefile
+++ b/apps/plugins/Makefile
@@ -22,6 +22,7 @@ endif
LDS := plugin.lds
LINKFILE := $(OBJDIR)/pluginlink.lds
+LINKCODEC := $(OBJDIR)/codeclink.lds
DEPFILE = $(OBJDIR)/dep-plugins
# This sets up 'SRC' based on the files mentioned in SOURCES
@@ -51,9 +52,16 @@ endif
all: $(BUILDDIR)/libplugin.a $(ROCKS) $(SUBDIRS) $(DEPFILE)
ifndef SIMVER
-$(OBJDIR)/%.elf: $(OBJDIR)/%.o $(LINKFILE) $(BUILDDIR)/libplugin.a
- @echo "LD "`basename $@`
- @$(CC) $(GCCOPTS) -O -nostdlib -o $@ $< -L$(BUILDDIR) $(CODECLIBS) -lplugin -lgcc -T$(LINKFILE) -Wl,-Map,$(OBJDIR)/$*.map
+$(OBJDIR)/%.elf: $(OBJDIR)/%.o $(LINKFILE) $(LINKCODEC) $(BUILDDIR)/libplugin.a
+ $(SILENT)(file=`basename $@`; \
+ echo "LD $$file"; \
+ match=`grep $$file CODECS`; \
+ if test -z "$$match"; then \
+ LINKWITH=$(LINKFILE); \
+ else \
+ LINKWITH=$(LINKCODEC); \
+ fi; \
+ $(CC) $(GCCOPTS) -O -nostdlib -o $@ $< -L$(BUILDDIR) $(CODECLIBS) -lplugin -lgcc -T$$LINKWITH -Wl,-Map,$(OBJDIR)/$*.map)
$(OBJDIR)/%.rock : $(OBJDIR)/%.elf
@echo "OBJCOPY "`basename $@`
@@ -104,12 +112,14 @@ $(BUILDDIR)/libplugin.a:
@mkdir -p $(OBJDIR)/lib
@$(MAKE) -C lib OBJDIR=$(OBJDIR)/lib
-# MEM should be passed on to this makefile with the chosen memory size given
-# in number of MB
$(LINKFILE): $(LDS)
@echo "build $@"
@cat $< | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P - >$@
+$(LINKCODEC): $(LDS)
+ @echo "build $@"
+ @cat $< | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) -DCODEC $(INCLUDES) $(TARGET) $(DEFINES) -E -P - >$@
+
$(SUBDIRS):
@echo "MAKE in $@"
@mkdir -p $(OBJDIR)/$@
diff --git a/apps/plugins/plugin.lds b/apps/plugins/plugin.lds
index 3b9ac8a2da..619bb0e7e8 100644
--- a/apps/plugins/plugin.lds
+++ b/apps/plugins/plugin.lds
@@ -22,17 +22,30 @@ OUTPUT_FORMAT(elf32-sh)
#define DRAMORIG 0x09000000 + STUBOFFSET
#endif
+#ifdef CODEC
+#define CODEC_SIZE 0x3C000
+#else
+#define CODEC_SIZE 0
+#endif
+
#if MEMORYSIZE >= 32
#define PLUGIN_LENGTH 0xC0000
#else
#define PLUGIN_LENGTH 0x8000
#endif
-#define DRAMSIZE (MEMORYSIZE * 0x100000) - PLUGIN_LENGTH
+
+#if CODEC_SIZE > 0
+#define THIS_LENGTH CODEC_SIZE
+#else
+#define THIS_LENGTH PLUGIN_LENGTH
+#endif
+
+#define DRAMSIZE (MEMORYSIZE * 0x100000) - PLUGIN_LENGTH - CODEC_SIZE
#define PLUGIN_ORIGIN (DRAMORIG + (DRAMSIZE))
MEMORY
{
- PLUGIN_RAM : ORIGIN = PLUGIN_ORIGIN, LENGTH = PLUGIN_LENGTH
+ PLUGIN_RAM : ORIGIN = PLUGIN_ORIGIN, LENGTH = THIS_LENGTH
#ifdef IRIVER_H100
PLUGIN_IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE
#endif