From 37183be69ce68e3f9ecaf12ce668d7e21229d8f0 Mon Sep 17 00:00:00 2001 From: Mustapha Senhaji Date: Fri, 20 Feb 2009 23:14:09 +0000 Subject: [PATCH] FS#9901 by Joshua Simmons for the Goban plugin: Goban overlay for the Archos targets. This is a first try to enable this plugin for low memory targets like our old archoses :) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20069 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/SOURCES | 5 +++ apps/plugins/SUBDIRS | 3 -- apps/plugins/goban/archos.lds | 43 ++++++++++++++++++++++++ apps/plugins/goban/goban.c | 56 +++++++++++++++++++------------- apps/plugins/goban/goban.make | 40 +++++++++++++++++++---- apps/plugins/goban/sgf_storage.c | 13 ++++++-- manual/plugins/main.tex | 2 -- 7 files changed, 126 insertions(+), 36 deletions(-) create mode 100644 apps/plugins/goban/archos.lds diff --git a/apps/plugins/SOURCES b/apps/plugins/SOURCES index 6257a222bd..7854ef3e1d 100644 --- a/apps/plugins/SOURCES +++ b/apps/plugins/SOURCES @@ -107,6 +107,11 @@ rockboy.c zxbox.c #endif +/* overlay loader for Goban */ +#if (PLUGIN_BUFFER_SIZE < 0x10000) && !defined(SIMULATOR) +goban.c +#endif + /* not support recorder models for now */ #if (LCD_WIDTH > 112) && (LCD_HEIGHT > 64) fireworks.c diff --git a/apps/plugins/SUBDIRS b/apps/plugins/SUBDIRS index f07bf861b4..af5e1d0c0e 100644 --- a/apps/plugins/SUBDIRS +++ b/apps/plugins/SUBDIRS @@ -20,10 +20,7 @@ chessbox jpeg sudoku reversi -/* Plugin is about 40k, rounding up to 65k to be safe. */ -#if (defined(PLUGIN_BUFFER_SIZE) && PLUGIN_BUFFER_SIZE >= 0x10000) goban -#endif #ifndef OLYMPUS_MROBE_500 zxbox #endif diff --git a/apps/plugins/goban/archos.lds b/apps/plugins/goban/archos.lds new file mode 100644 index 0000000000..c17346ff0b --- /dev/null +++ b/apps/plugins/goban/archos.lds @@ -0,0 +1,43 @@ +#include "config.h" + +/* linker script for goban as an overlay */ + +OUTPUT_FORMAT(elf32-sh) + +#define DRAMORIG 0x09000000 +#define PLUGIN_LENGTH PLUGIN_BUFFER_SIZE + +#define OVERLAY_LENGTH 0x10000 +#define OVERLAY_ORIGIN (DRAMORIG + (MEMORYSIZE * 0x100000) - PLUGIN_LENGTH - OVERLAY_LENGTH) + +MEMORY +{ + OVERLAY_RAM : ORIGIN = OVERLAY_ORIGIN, LENGTH = OVERLAY_LENGTH +} + +SECTIONS +{ + .header : { + _plugin_start_addr = .; + KEEP(*(.header)) + } > OVERLAY_RAM + + .text : { + *(.text*) + } > OVERLAY_RAM + + .rodata : { + *(.rodata*) + } > OVERLAY_RAM + + .data : { + *(.data*) + } > OVERLAY_RAM + + .bss : { + *(.bss*) + *(COMMON) + . = ALIGN(0x4); + _plugin_end_addr = .; + } > OVERLAY_RAM +} diff --git a/apps/plugins/goban/goban.c b/apps/plugins/goban/goban.c index 04b74b7f59..20cccd7e03 100644 --- a/apps/plugins/goban/goban.c +++ b/apps/plugins/goban/goban.c @@ -1,25 +1,37 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2007-2009 Joshua Simmons - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "plugin.h" +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2007-2009 Joshua Simmons + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "plugin.h" + +#if PLUGIN_BUFFER_SIZE < 0x10000 && !defined(SIMULATOR) + +#include "lib/overlay.h" + +PLUGIN_HEADER + +enum plugin_status plugin_start(const void* parameter) +{ + return run_overlay(parameter, PLUGIN_GAMES_DIR "/goban.ovl", "Goban"); +} +#endif + #include "lib/playback_control.h" #include "lib/configfile.h" diff --git a/apps/plugins/goban/goban.make b/apps/plugins/goban/goban.make index f3f96ff5c6..b8866fbc4f 100644 --- a/apps/plugins/goban/goban.make +++ b/apps/plugins/goban/goban.make @@ -8,15 +8,41 @@ # -GOBANSRCDIR := $(APPSDIR)/plugins/goban -GOBANBUILDDIR := $(BUILDDIR)/apps/plugins/goban +GOBAN_SRCDIR := $(APPSDIR)/plugins/goban +GOBAN_BUILDDIR := $(BUILDDIR)/apps/plugins/goban -ROCKS += $(GOBANBUILDDIR)/goban.rock - - -GOBAN_SRC := $(call preprocess, $(GOBANSRCDIR)/SOURCES) +GOBAN_SRC := $(call preprocess, $(GOBAN_SRCDIR)/SOURCES) GOBAN_OBJ := $(call c2obj, $(GOBAN_SRC)) OTHER_SRC += $(GOBAN_SRC) -$(GOBANBUILDDIR)/goban.rock: $(GOBAN_OBJ) +ifndef SIMVER +ifneq (,$(strip $(foreach tgt,RECORDER ONDIO,$(findstring $(tgt),$(TARGET))))) + ### archos recorder targets + GOBAN_INLDS := $(GOBAN_SRCDIR)/archos.lds + ROCKS += $(GOBAN_BUILDDIR)/goban.ovl +else + ### all other targets + GOBAN_INLDS := $(APPSDIR)/plugins/plugin.lds + ROCKS += $(GOBAN_BUILDDIR)/goban.rock +endif + GOBAN_OVLFLAGS = -T$(GOBAN_OUTLDS) -Wl,--gc-sections -Wl,-Map,$(basename $@).map + GOBAN_OUTLDS = $(GOBAN_BUILDDIR)/goban.lds +else + ### simulator + ROCKS += $(GOBAN_BUILDDIR)/goban.rock + GOBAN_OVLFLAGS = $(SHARED_FLAG) # <-- from Makefile +endif + +$(GOBAN_OUTLDS): $(GOBAN_INLDS) $(GOBAN_OBJ) + $(call PRINTS,PP $(splash (2 * HZ, "Stopping music playback to get more space"); + rb->splash (1 * HZ, "Stopping music playback to get more space"); DEBUGF ("storage_buffer_size < MIN!!: %d\n", (int) total_storage_size); temp_buffer = rb->plugin_get_audio_buffer (&size); @@ -335,7 +335,7 @@ setup_sgf (void) if (total_storage_size < MIN_STORAGE_BUFFER_SIZE) { - rb->splash (5 * HZ, "Low memory. Large files may not load."); + rb->splash (1 * HZ, "Low memory. Large files may not load."); DEBUGF ("storage_buffer_size < MIN!!!!: %d\n", (int) total_storage_size); @@ -387,6 +387,15 @@ setup_storage_buffer (char *temp_buffer, size_t size) unsigned int index = 0; int temp; +#if PLUGIN_BUFFER_SIZE < 0x10000 && !defined(SIMULATOR) + /* loaded as an overlay plugin, protect from overwriting ourselves */ + if (plugin_start_addr >= (unsigned char *) temp_buffer && + plugin_start_addr < (unsigned char *) temp_buffer + size) + { + size = plugin_start_addr - (unsigned char *) temp_buffer; + } +#endif + while (1) { if (index >= sizeof (storage_initialized) / diff --git a/manual/plugins/main.tex b/manual/plugins/main.tex index 54b051fab7..04ded681a3 100644 --- a/manual/plugins/main.tex +++ b/manual/plugins/main.tex @@ -35,9 +35,7 @@ text files% {\input{plugins/flipit.tex}} -\nopt{recorder,recorderv2fm,ondio}{ \opt{lcd_bitmap}{\input{plugins/goban.tex}} -} \opt{lcd_non-mono}{\nopt{h10_5gb,ipodmini,c200}{ \input{plugins/invadrox.tex}}}