aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Puccinelli2010-08-07 05:01:43 +0000
committerTony Puccinelli2010-08-07 05:01:43 +0000
commit0712d418708540c2c6dbba4c4912eb94302c9125 (patch)
treecb2bc61acdc2b0707fc40bc42c626757b3def7cf
parent6982aed8a43be6a33802be95c9fde557885b7a5b (diff)
downloadscummvm-rg350-0712d418708540c2c6dbba4c4912eb94302c9125.tar.gz
scummvm-rg350-0712d418708540c2c6dbba4c4912eb94302c9125.tar.bz2
scummvm-rg350-0712d418708540c2c6dbba4c4912eb94302c9125.zip
modified psp to use mips-loader.cpp (and added things to backends/module.mk)
svn-id: r51826
-rw-r--r--backends/module.mk4
-rw-r--r--backends/platform/ds/arm9/makefile6
-rw-r--r--backends/platform/ps2/Makefile.ps26
-rw-r--r--backends/platform/psp/Makefile2
-rw-r--r--backends/plugins/arm-loader.cpp4
-rw-r--r--backends/plugins/elf-loader.h7
-rw-r--r--backends/plugins/mips-loader.cpp4
-rw-r--r--backends/plugins/psp/psp-provider.cpp80
-rw-r--r--backends/plugins/psp/psp-provider.h8
-rw-r--r--backends/plugins/shorts-segment-manager.cpp4
10 files changed, 42 insertions, 83 deletions
diff --git a/backends/module.mk b/backends/module.mk
index d164cd3782..0a1cadd366 100644
--- a/backends/module.mk
+++ b/backends/module.mk
@@ -30,6 +30,10 @@ MODULE_OBJS := \
midi/timidity.o \
midi/dmedia.o \
midi/windows.o \
+ plugins/elf-loader.o \
+ plugins/mips-loader.o \
+ plugins/shorts-segment-manager.o \
+ plugins/arm-loader.o \
plugins/elf-provider.o \
plugins/dc/dc-provider.o \
plugins/ds/ds-provider.o \
diff --git a/backends/platform/ds/arm9/makefile b/backends/platform/ds/arm9/makefile
index 86b7bd3628..c43c28c223 100644
--- a/backends/platform/ds/arm9/makefile
+++ b/backends/platform/ds/arm9/makefile
@@ -238,7 +238,7 @@ CXXFLAGS= $(CFLAGS) -Wno-non-virtual-dtor -Wno-unknown-pragmas -Wno-reorder \
ASFLAGS = -mcpu=arm9tdmi -mthumb-interwork
-DEFINES += -D__DS__ -DNDS -DARM9 -DNONSTANDARD_PORT -DDISABLE_FANCY_THEMES -DVECTOR_RENDERER_FORMAT=1555 -DDISABLE_DOSBOX_OPL -DDISABLE_DEFAULT_SAVEFILEMANAGER -DELF_LOADER_TARGET -DARM#-DNEW_PLUGIN_DESIGN_FIRST_REFINEMENT
+DEFINES += -D__DS__ -DNDS -DARM9 -DNONSTANDARD_PORT -DDISABLE_FANCY_THEMES -DVECTOR_RENDERER_FORMAT=1555 -DDISABLE_DOSBOX_OPL -DDISABLE_DEFAULT_SAVEFILEMANAGER -DELF_LOADER_TARGET -DARM -DARM_TARGET#-DNEW_PLUGIN_DESIGN_FIRST_REFINEMENT
ifdef USE_MAD
DEFINES += -DUSE_MAD
endif
@@ -291,9 +291,7 @@ PORT_OBJS := $(portdir)/source/blitters_arm.o $(portdir)/source/cdaudio.o $(port
$(portdir)/source/osystem_ds.o $(portdir)/source/ramsave.o\
$(portdir)/source/touchkeyboard.o $(portdir)/source/zipreader.o\
$(portdir)/source/dsoptions.o $(portdir)/source/keys.o $(portdir)/source/wordcompletion.o\
- $(portdir)/source/interrupt.o\
- $(srcdir)/backends/plugins/elf-loader.o\
- $(srcdir)/backends/plugins/arm-loader.o
+ $(portdir)/source/interrupt.o
ifdef USE_PROFILER
PORT_OBJS += $(portdir)/source/profiler/cyg-profile.o
diff --git a/backends/platform/ps2/Makefile.ps2 b/backends/platform/ps2/Makefile.ps2
index 8c59ee8c17..717bc94379 100644
--- a/backends/platform/ps2/Makefile.ps2
+++ b/backends/platform/ps2/Makefile.ps2
@@ -77,7 +77,8 @@ DEPDIR = .deps
TARGET = elf/scummvm.elf
-DEFINES += -DUSE_VORBIS -DUSE_TREMOR -DUSE_MAD -DUSE_ZLIB -DFORCE_RTL -DDISABLE_SAVEGAME_SORTING -D_EE -D__PLAYSTATION2__ -DELF_LOADER_TARGET -G2 -O2 -Wall -Wno-multichar -fno-rtti -fno-exceptions -DNO_ADAPTOR#-DNEW_PLUGIN_DESIGN_FIRST_REFINEMENT
+DEFINES += -DUSE_VORBIS -DUSE_TREMOR -DUSE_MAD -DUSE_ZLIB -DFORCE_RTL -DDISABLE_SAVEGAME_SORTING -D_EE -D__PLAYSTATION2__ -G2 -O2 -Wall -Wno-multichar -fno-rtti -fno-exceptions -DNO_ADAPTOR
+DEFINES += -DELF_LOADER_TARGET -DMIPS_TARGET#-DNEW_PLUGIN_DESIGN_FIRST_REFINEMENT
INCLUDES = $(addprefix -I$(PS2_EXTRA),$(PS2_EXTRA_INCS))
INCLUDES += -I $(PS2SDK)/ee/include -I $(PS2SDK)/common/include -I ./common -I . -I $(srcdir) -I $(srcdir)/engines
@@ -111,9 +112,6 @@ OBJS := $(srcdir)/backends/platform/ps2/DmaPipe.o \
$(srcdir)/backends/platform/ps2/systemps2.o \
$(srcdir)/backends/platform/ps2/ps2mutex.o \
$(srcdir)/backends/platform/ps2/ps2time.o \
- $(srcdir)/backends/plugins/elf-loader.o \
- $(srcdir)/backends/plugins/mips-loader.o \
- $(srcdir)/backends/plugins/shorts-segment-manager.o \
$(srcdir)/backends/platform/ps2/ps2debug.o
include $(srcdir)/Makefile.common
diff --git a/backends/platform/psp/Makefile b/backends/platform/psp/Makefile
index 010f6e635a..754bc775f0 100644
--- a/backends/platform/psp/Makefile
+++ b/backends/platform/psp/Makefile
@@ -68,7 +68,7 @@ endif
# Variables for common Scummvm makefile
CXX = psp-g++
CXXFLAGS = -O3 -Wall -Wno-multichar -fno-exceptions -fno-rtti
-DEFINES = -D__PSP__ -DNONSTANDARD_PORT -DDISABLE_TEXT_CONSOLE -DDISABLE_COMMAND_LINE -DUSE_ZLIB -DDISABLE_DOSBOX_OPL -DUSE_RGB_COLOR -DELF_LOADER_TARGET
+DEFINES = -D__PSP__ -DNONSTANDARD_PORT -DDISABLE_TEXT_CONSOLE -DDISABLE_COMMAND_LINE -DUSE_ZLIB -DDISABLE_DOSBOX_OPL -DUSE_RGB_COLOR -DELF_LOADER_TARGET -DMIPS_TARGET
LDFLAGS :=
INCDIR := $(srcdir) . $(srcdir)/engines/ $(PSPSDK)/include
diff --git a/backends/plugins/arm-loader.cpp b/backends/plugins/arm-loader.cpp
index cb19af78b6..7e8269220b 100644
--- a/backends/plugins/arm-loader.cpp
+++ b/backends/plugins/arm-loader.cpp
@@ -23,7 +23,7 @@
*
*/
-#if defined(DYNAMIC_MODULES)
+#if defined(DYNAMIC_MODULES) && defined(ARM_TARGET)
#include "backends/fs/ds/ds-fs.h"
#include "elf-loader.h"
@@ -166,4 +166,4 @@ bool ARMDLObject::relocateRels(Common::SeekableReadStream* DLFile, Elf32_Ehdr *e
return true;
}
-#endif /* defined(DYNAMIC_MODULES) */
+#endif /* defined(DYNAMIC_MODULES) && defined(ARM_TARGET) */
diff --git a/backends/plugins/elf-loader.h b/backends/plugins/elf-loader.h
index 423a97bc42..7abe012003 100644
--- a/backends/plugins/elf-loader.h
+++ b/backends/plugins/elf-loader.h
@@ -30,15 +30,10 @@
#include "common/stream.h"
#include "backends/plugins/dynamic-plugin.h"
-#if defined(__PLAYSTATION2__) || defined(__PSP__)
-#define MIPS_TARGET
+#if defined(MIPS_TARGET)
#include "shorts-segment-manager.h"
#endif
-#if defined(__DS__)
-#define ARM_TARGET
-#endif
-
class DLObject {
protected:
void *_segment, *_symtab;
diff --git a/backends/plugins/mips-loader.cpp b/backends/plugins/mips-loader.cpp
index 708456d475..f537729197 100644
--- a/backends/plugins/mips-loader.cpp
+++ b/backends/plugins/mips-loader.cpp
@@ -23,7 +23,7 @@
*
*/
-#if defined(DYNAMIC_MODULES)
+#if defined(DYNAMIC_MODULES) && defined(MIPS_TARGET)
#include "mips-loader.h"
@@ -259,4 +259,4 @@ bool MIPSDLObject::relocateRels(Common::SeekableReadStream* DLFile, Elf32_Ehdr *
return true;
}
-#endif /* defined(DYNAMIC_MODULES) */
+#endif /* defined(DYNAMIC_MODULES) && defined(MIPS_TARGET) */
diff --git a/backends/plugins/psp/psp-provider.cpp b/backends/plugins/psp/psp-provider.cpp
index f394916538..f542373b87 100644
--- a/backends/plugins/psp/psp-provider.cpp
+++ b/backends/plugins/psp/psp-provider.cpp
@@ -25,84 +25,52 @@
#if defined(DYNAMIC_MODULES) && defined(__PSP__)
+#include "backends/plugins/mips-loader.h"
+#include "backends/plugins/elf-provider.h"
#include "backends/plugins/psp/psp-provider.h"
-#include "backends/plugins/dynamic-plugin.h"
-#include "common/fs.h"
-#include "backends/platform/psp/psploader.h"
-
-
-class PSPPlugin : public DynamicPlugin {
-protected:
- void *_dlHandle;
- Common::String _filename;
-
- virtual VoidFunc findSymbol(const char *symbol) {
- void *func = dlsym(_dlHandle, symbol);
- if (!func)
- warning("Failed loading symbol '%s' from plugin '%s' (%s)", symbol, _filename.c_str(), dlerror());
-
- // FIXME HACK: This is a HACK to circumvent a clash between the ISO C++
- // standard and POSIX: ISO C++ disallows casting between function pointers
- // and data pointers, but dlsym always returns a void pointer. For details,
- // see e.g. <http://www.trilithium.com/johan/2004/12/problem-with-dlsym/>.
- assert(sizeof(VoidFunc) == sizeof(func));
- VoidFunc tmp;
- memcpy(&tmp, &func, sizeof(VoidFunc));
- return tmp;
- }
+class PSPPlugin : public ELFPlugin {
public:
- PSPPlugin(const Common::String &filename)
- : _dlHandle(0), _filename(filename) {}
+ PSPPlugin(const Common::String &filename) {
+ _dlHandle = 0;
+ _filename = filename;
+ }
~PSPPlugin() {
- if (_dlHandle) unloadPlugin();
+ if (_dlHandle)
+ unloadPlugin();
}
- bool loadPlugin() {
+ bool loadPlugin();
+};
+
+bool PSPPlugin::loadPlugin() {
assert(!_dlHandle);
- _dlHandle = dlopen(_filename.c_str(), RTLD_LAZY);
+ DLObject *obj = new MIPSDLObject();
+ if (obj->open(_filename.c_str())) {
+ _dlHandle = obj;
+ } else {
+ delete obj;
+ _dlHandle = NULL;
+ }
if (!_dlHandle) {
- warning("Failed loading plugin '%s' (%s)", _filename.c_str(), dlerror());
+ warning("Failed loading plugin '%s'", _filename.c_str());
return false;
}
bool ret = DynamicPlugin::loadPlugin();
- if (ret)
- dlforgetsyms(_dlHandle);
+ if (ret && _dlHandle) {
+ _dlHandle->discard_symtab();
+ }
return ret;
- }
-
- void unloadPlugin() {
- DynamicPlugin::unloadPlugin();
- if (_dlHandle) {
- if (dlclose(_dlHandle) != 0)
- warning("Failed unloading plugin '%s' (%s)", _filename.c_str(), dlerror());
- _dlHandle = 0;
- }
- }
};
-
Plugin* PSPPluginProvider::createPlugin(const Common::FSNode &node) const {
return new PSPPlugin(node.getPath());
}
-bool PSPPluginProvider::isPluginFilename(const Common::FSNode &node) const {
- // Check the plugin suffix
- Common::String filename = node.getName();
- fprintf(stderr, "Testing name %s", filename.c_str());
- if (!filename.hasSuffix(".PLG") && !filename.hasSuffix(".plg")) {
- fprintf(stderr," fail.\n");
- return false;
- }
-
- fprintf(stderr," success!\n");
- return true;
-}
-
#endif // defined(DYNAMIC_MODULES) && defined(__PSP__)
diff --git a/backends/plugins/psp/psp-provider.h b/backends/plugins/psp/psp-provider.h
index d6c44c5a85..c4debc7997 100644
--- a/backends/plugins/psp/psp-provider.h
+++ b/backends/plugins/psp/psp-provider.h
@@ -26,16 +26,12 @@
#ifndef BACKENDS_PLUGINS_PSP_PSP_PROVIDER_H
#define BACKENDS_PLUGINS_PSP_PSP_PROVIDER_H
-#include "base/plugins.h"
+#include "backends/plugins/elf-provider.h"
#if defined(DYNAMIC_MODULES) && defined(__PSP__)
-class PSPPluginProvider : public FilePluginProvider {
-protected:
+class PSPPluginProvider : public ELFPluginProvider {
Plugin* createPlugin(const Common::FSNode &node) const;
-
- bool isPluginFilename(const Common::FSNode &node) const;
-
};
#endif // defined(DYNAMIC_MODULES) && defined(__PSP__)
diff --git a/backends/plugins/shorts-segment-manager.cpp b/backends/plugins/shorts-segment-manager.cpp
index 25962c504d..2376759919 100644
--- a/backends/plugins/shorts-segment-manager.cpp
+++ b/backends/plugins/shorts-segment-manager.cpp
@@ -23,7 +23,7 @@
*
*/
-#if defined(DYNAMIC_MODULES) //TODO: && defined (MIPS target)
+#if defined(DYNAMIC_MODULES) && defined(MIPS_TARGET)
#include "shorts-segment-manager.h"
@@ -86,4 +86,4 @@ void ShortSegmentManager::deleteSegment(ShortSegmentManager::Segment *seg) {
delete seg;
}
-#endif /* DYNAMIC_MODULES */
+#endif /* DYNAMIC_MODULES && MIPS_TARGET */