mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 10:37:38 -04:00
Made the overlay loader code part of the plugin library.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8813 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
df25cd5376
commit
eeec278d21
5 changed files with 152 additions and 72 deletions
|
@ -17,8 +17,8 @@ ifdef APPEXTRA
|
|||
INCLUDES += $(patsubst %,-I$(APPSDIR)/%,$(subst :, ,$(APPEXTRA)))
|
||||
endif
|
||||
|
||||
CFLAGS = $(GCCOPTS) \
|
||||
$(INCLUDES) $(TARGET) $(EXTRA_DEFINES) -DMEM=${MEMORYSIZE} -DPLUGIN
|
||||
CFLAGS = $(GCCOPTS) $(INCLUDES) $(TARGET) $(EXTRA_DEFINES) \
|
||||
-DTARGET_ID=$(TARGET_ID) -DMEM=${MEMORYSIZE} -DPLUGIN
|
||||
|
||||
# Sectioned compilation for target
|
||||
ifndef SIMVER
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
configfile.c
|
||||
highscore.c
|
||||
#if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH < 4) && !defined(SIMULATOR) && \
|
||||
(CONFIG_LCD != LCD_IPOD2BPP)
|
||||
gray_core.c
|
||||
|
@ -7,8 +6,9 @@ gray_draw.c
|
|||
gray_parm.c
|
||||
gray_scroll.c
|
||||
#endif
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
xlcd.c
|
||||
highscore.c
|
||||
#ifndef SIMULATOR
|
||||
overlay.c
|
||||
#endif
|
||||
#ifdef HAVE_LCD_CHARCELLS
|
||||
playergfx.c
|
||||
|
@ -16,3 +16,6 @@ playergfx.c
|
|||
#ifdef RB_PROFILE
|
||||
profile_plugin.c
|
||||
#endif
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
xlcd.c
|
||||
#endif
|
||||
|
|
106
apps/plugins/lib/overlay.c
Executable file
106
apps/plugins/lib/overlay.c
Executable file
|
@ -0,0 +1,106 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Overlay loader
|
||||
*
|
||||
* Copyright (C) 2006 Jens Arnold
|
||||
*
|
||||
* All files in this archive are subject to the GNU General Public License.
|
||||
* See the file COPYING in the source tree root for full license agreement.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef SIMULATOR
|
||||
#include "plugin.h"
|
||||
|
||||
/* load and run a plugin linked as an overlay.
|
||||
|
||||
arguments:
|
||||
rb = pointer to plugin api, also passed on to the overlay
|
||||
parameter = plugin parameter, passed on to the overlay
|
||||
filename = overlay file name, absolute path as usual
|
||||
name = overlay display name
|
||||
|
||||
result:
|
||||
return value from the overlay
|
||||
|
||||
As long as a large plugin to be overlayed doesn't use the audiobuffer
|
||||
itself, no adjustments in the plugin source code are necessary to make
|
||||
it work as an overlay, it only needs an adapted linker script.
|
||||
|
||||
If the overlayed plugin *does* use the audiobuffer itself, it needs
|
||||
to make sure not to overwrite itself.
|
||||
|
||||
The linker script for the overlay should use a base address towards the
|
||||
end of the audiobuffer, just low enough to make the overlay fit. */
|
||||
|
||||
enum plugin_status run_overlay(struct plugin_api* rb, void* parameter,
|
||||
unsigned char *filename, unsigned char *name)
|
||||
{
|
||||
int fd, readsize;
|
||||
int audiobuf_size;
|
||||
unsigned char *audiobuf;
|
||||
static struct plugin_header header;
|
||||
|
||||
fd = rb->open(filename, O_RDONLY);
|
||||
if (fd < 0)
|
||||
{
|
||||
rb->splash(2*HZ, true, "Can't open %s", filename);
|
||||
return PLUGIN_ERROR;
|
||||
}
|
||||
readsize = rb->read(fd, &header, sizeof(header));
|
||||
rb->close(fd);
|
||||
/* Close for now. Less code than doing it in all error checks.
|
||||
* Would need to seek back anyway. */
|
||||
|
||||
if (readsize != sizeof(header))
|
||||
{
|
||||
rb->splash(2*HZ, true, "Reading %s overlay failed.", name);
|
||||
return PLUGIN_ERROR;
|
||||
}
|
||||
if (header.magic != PLUGIN_MAGIC || header.target_id != TARGET_ID)
|
||||
{
|
||||
rb->splash(2*HZ, true, "%s overlay: Incompatible model.", name);
|
||||
return PLUGIN_ERROR;
|
||||
}
|
||||
if (header.api_version != PLUGIN_API_VERSION)
|
||||
{
|
||||
rb->splash(2*HZ, true, "%s overlay: Incompatible version.", name);
|
||||
return PLUGIN_ERROR;
|
||||
}
|
||||
|
||||
audiobuf = rb->plugin_get_audio_buffer(&audiobuf_size);
|
||||
if (header.load_addr < audiobuf ||
|
||||
header.end_addr > audiobuf + audiobuf_size)
|
||||
{
|
||||
rb->splash(2*HZ, true, "%s overlay doesn't fit into memory.", name);
|
||||
return PLUGIN_ERROR;
|
||||
}
|
||||
rb->memset(header.load_addr, 0, header.end_addr - header.load_addr);
|
||||
|
||||
fd = rb->open(filename, O_RDONLY);
|
||||
if (fd < 0)
|
||||
{
|
||||
rb->splash(2*HZ, true, "Can't open %s", filename);
|
||||
return PLUGIN_ERROR;
|
||||
}
|
||||
readsize = rb->read(fd, header.load_addr, header.end_addr - header.load_addr);
|
||||
rb->close(fd);
|
||||
|
||||
if (readsize < 0)
|
||||
{
|
||||
rb->splash(2*HZ, true, "Reading %s overlay failed.", name);
|
||||
return PLUGIN_ERROR;
|
||||
}
|
||||
return header.entry_point(rb, parameter);
|
||||
}
|
||||
#endif
|
34
apps/plugins/lib/overlay.h
Executable file
34
apps/plugins/lib/overlay.h
Executable file
|
@ -0,0 +1,34 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Overlay loader
|
||||
*
|
||||
* Copyright (C) 2006 Jens Arnold
|
||||
*
|
||||
* All files in this archive are subject to the GNU General Public License.
|
||||
* See the file COPYING in the source tree root for full license agreement.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __OVERLAY_H__
|
||||
#define __OVERLAY_H__
|
||||
|
||||
#ifndef SIMULATOR
|
||||
#include "plugin.h"
|
||||
|
||||
/* load and run a plugin linked as an overlay. */
|
||||
enum plugin_status run_overlay(struct plugin_api* api, void* parameter,
|
||||
unsigned char *filename, unsigned char *name);
|
||||
|
||||
#endif /* !SIMULATOR */
|
||||
#endif /* __OVERLAY_H__ */
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
*
|
||||
* Copyright (C) 2005 Jens Arnold
|
||||
*
|
||||
* Overlay loader for rockboy on Archos
|
||||
* Overlay loader stub plugin for rockboy on Archos
|
||||
*
|
||||
* All files in this archive are subject to the GNU General Public License.
|
||||
* See the file COPYING in the source tree root for full license agreement.
|
||||
|
@ -22,76 +22,13 @@
|
|||
|
||||
#if MEM <= 8 && !defined(SIMULATOR)
|
||||
|
||||
#include "overlay.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
#define OVL_NAME "/.rockbox/viewers/rockboy.ovl"
|
||||
#define OVL_DISPLAYNAME "RockBoy"
|
||||
|
||||
struct plugin_api* rb;
|
||||
unsigned char *audiobuf;
|
||||
int audiobuf_size;
|
||||
|
||||
/* this is the plugin entry point */
|
||||
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
||||
{
|
||||
int fd, readsize;
|
||||
struct plugin_header header;
|
||||
|
||||
rb = api;
|
||||
|
||||
fd = rb->open(OVL_NAME, O_RDONLY);
|
||||
if (fd < 0)
|
||||
{
|
||||
rb->splash(2*HZ, true, "Can't open " OVL_NAME);
|
||||
return PLUGIN_ERROR;
|
||||
}
|
||||
readsize = rb->read(fd, &header, sizeof(header));
|
||||
rb->close(fd);
|
||||
/* Close for now. Less code than doing it in all error checks.
|
||||
* Would need to seek back anyway. */
|
||||
|
||||
if (readsize != sizeof(header))
|
||||
{
|
||||
rb->splash(2*HZ, true, "Reading" OVL_DISPLAYNAME " overlay failed.");
|
||||
return PLUGIN_ERROR;
|
||||
}
|
||||
if (header.magic != PLUGIN_MAGIC || header.target_id != TARGET_ID)
|
||||
{
|
||||
rb->splash(2*HZ, true, OVL_DISPLAYNAME
|
||||
" overlay: Incompatible model.");
|
||||
return PLUGIN_ERROR;
|
||||
}
|
||||
if (header.api_version != PLUGIN_API_VERSION)
|
||||
{
|
||||
rb->splash(2*HZ, true, OVL_DISPLAYNAME
|
||||
" overlay: Incompatible version.");
|
||||
return PLUGIN_ERROR;
|
||||
}
|
||||
|
||||
audiobuf = rb->plugin_get_audio_buffer(&audiobuf_size);
|
||||
if (header.load_addr < audiobuf ||
|
||||
header.end_addr > audiobuf + audiobuf_size)
|
||||
{
|
||||
rb->splash(2*HZ, true, OVL_DISPLAYNAME
|
||||
" overlay doesn't fit into memory.");
|
||||
return PLUGIN_ERROR;
|
||||
}
|
||||
rb->memset(header.load_addr, 0, header.end_addr - header.load_addr);
|
||||
|
||||
fd = rb->open(OVL_NAME, O_RDONLY);
|
||||
if (fd < 0)
|
||||
{
|
||||
rb->splash(2*HZ, true, "Can't open " OVL_NAME);
|
||||
return PLUGIN_ERROR;
|
||||
}
|
||||
readsize = rb->read(fd, header.load_addr, header.end_addr - header.load_addr);
|
||||
rb->close(fd);
|
||||
|
||||
if (readsize < 0)
|
||||
{
|
||||
rb->splash(2*HZ, true, "Reading" OVL_DISPLAYNAME " overlay failed.");
|
||||
return PLUGIN_ERROR;
|
||||
}
|
||||
return header.entry_point(api, parameter);
|
||||
return run_overlay(api, parameter, "/.rockbox/viewers/rockboy.ovl", "RockBoy");
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue