aboutsummaryrefslogtreecommitdiff
path: root/backends/plugins/psp
diff options
context:
space:
mode:
authorTony Puccinelli2010-08-07 05:01:43 +0000
committerTony Puccinelli2010-08-07 05:01:43 +0000
commit0712d418708540c2c6dbba4c4912eb94302c9125 (patch)
treecb2bc61acdc2b0707fc40bc42c626757b3def7cf /backends/plugins/psp
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
Diffstat (limited to 'backends/plugins/psp')
-rw-r--r--backends/plugins/psp/psp-provider.cpp80
-rw-r--r--backends/plugins/psp/psp-provider.h8
2 files changed, 26 insertions, 62 deletions
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__)