aboutsummaryrefslogtreecommitdiff
path: root/backends/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'backends/plugins')
-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
6 files changed, 33 insertions, 74 deletions
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 */