aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/module.mk10
-rw-r--r--backends/plugins/ds/ds-provider.cpp75
-rw-r--r--backends/plugins/ds/ds-provider.h22
-rw-r--r--backends/plugins/elf/arm-loader.h5
-rw-r--r--backends/plugins/elf/elf-loader.cpp49
-rw-r--r--backends/plugins/elf/elf-loader.h11
-rw-r--r--backends/plugins/elf/elf-provider.h2
-rw-r--r--backends/plugins/elf/mips-loader.cpp4
-rw-r--r--backends/plugins/elf/mips-loader.h6
-rw-r--r--backends/plugins/elf/ppc-loader.h5
-rw-r--r--backends/plugins/ps2/ps2-provider.cpp72
-rw-r--r--backends/plugins/ps2/ps2-provider.h21
-rw-r--r--backends/plugins/psp/psp-provider.cpp75
-rw-r--r--backends/plugins/psp/psp-provider.h19
-rw-r--r--backends/plugins/wii/wii-provider.cpp75
-rw-r--r--backends/plugins/wii/wii-provider.h18
16 files changed, 363 insertions, 106 deletions
diff --git a/backends/module.mk b/backends/module.mk
index eea7ec98d2..e0bdd26cf7 100644
--- a/backends/module.mk
+++ b/backends/module.mk
@@ -50,7 +50,8 @@ endif
ifeq ($(BACKEND),ds)
MODULE_OBJS += \
fs/ds/ds-fs-factory.o \
- fs/ds/ds-fs.o
+ fs/ds/ds-fs.o \
+ plugins/ds/ds-provider.o
endif
ifeq ($(BACKEND),n64)
@@ -61,20 +62,23 @@ endif
ifeq ($(BACKEND),ps2)
MODULE_OBJS += \
- fs/ps2/ps2-fs-factory.o
+ fs/ps2/ps2-fs-factory.o \
+ plugins/ps2/ps2-provider.o
endif
ifeq ($(BACKEND),psp)
MODULE_OBJS += \
fs/psp/psp-fs-factory.o \
fs/psp/psp-stream.o \
+ plugins/psp/psp-provider.o \
saves/psp/psp-saves.o \
timer/psp/timer.o
endif
ifeq ($(BACKEND),wii)
MODULE_OBJS += \
- fs/wii/wii-fs-factory.o
+ fs/wii/wii-fs-factory.o \
+ plugins/wii/wii-provider.o
endif
# Include common rules
diff --git a/backends/plugins/ds/ds-provider.cpp b/backends/plugins/ds/ds-provider.cpp
new file mode 100644
index 0000000000..c188b6c9df
--- /dev/null
+++ b/backends/plugins/ds/ds-provider.cpp
@@ -0,0 +1,75 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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 program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#if defined(DYNAMIC_MODULES) && defined(__DS__)
+
+#include <malloc.h>
+#include <nds.h>
+
+#include "backends/plugins/ds/ds-provider.h"
+#include "backends/plugins/elf/arm-loader.h"
+
+class DSDLObject : public ARMDLObject {
+public:
+ DSDLObject() :
+ ARMDLObject() {
+ }
+
+ virtual ~DSDLObject() {
+ unload();
+ }
+
+protected:
+ virtual void *allocSegment(size_t boundary, size_t size) const {
+ return memalign(boundary, size);
+ }
+
+ virtual void freeSegment(void *segment) const {
+ free(segment);
+ }
+
+ virtual void flushDataCache(void *ptr, uint32 len) const {
+ DC_FlushRange(ptr, len);
+ IC_InvalidateRange(ptr, len);
+ }
+};
+
+class DSPlugin : public ELFPlugin {
+public:
+ DSPlugin(const Common::String &filename) :
+ ELFPlugin(filename) {
+ }
+
+ virtual DLObject *makeDLObject() {
+ return new DSDLObject();
+ }
+};
+
+Plugin *DSPluginProvider::createPlugin(const Common::FSNode &node) const {
+ return new DSPlugin(node.getPath());
+}
+
+#endif // defined(DYNAMIC_MODULES) && defined(__DS__)
+
diff --git a/backends/plugins/ds/ds-provider.h b/backends/plugins/ds/ds-provider.h
index c856937172..b7f7aaa746 100644
--- a/backends/plugins/ds/ds-provider.h
+++ b/backends/plugins/ds/ds-provider.h
@@ -18,28 +18,24 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
+ * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/gsoc2010-plugins/backends/plugins/ds/ds-provider.h $
+ * $Id: ds-provider.h 52112 2010-08-16 08:41:04Z toneman1138 $
*
*/
#if defined(DYNAMIC_MODULES) && defined(__DS__)
+#ifndef BACKENDS_PLUGINS_DS_PROVIDER_H
+#define BACKENDS_PLUGINS_DS_PROVIDER_H
+
#include "backends/plugins/elf/elf-provider.h"
-#include "backends/plugins/elf/arm-loader.h"
class DSPluginProvider : public ELFPluginProvider {
- class DSPlugin : public ELFPlugin {
- public:
- DSPlugin(const Common::String &filename) : ELFPlugin(filename) {}
-
- DLObject *makeDLObject() { return new ARMDLObject(); }
- };
-
public:
- Plugin* createPlugin(const Common::FSNode &node) const {
- return new DSPlugin(node.getPath());
- }
+ Plugin *createPlugin(const Common::FSNode &node) const;
};
+#endif // BACKENDS_PLUGINS_DS_PROVIDER_H
+
#endif // defined(DYNAMIC_MODULES) && defined(__DS__)
+
diff --git a/backends/plugins/elf/arm-loader.h b/backends/plugins/elf/arm-loader.h
index 52a3be5447..c4df671060 100644
--- a/backends/plugins/elf/arm-loader.h
+++ b/backends/plugins/elf/arm-loader.h
@@ -25,6 +25,9 @@
#if defined(DYNAMIC_MODULES) && defined(ARM_TARGET)
+#ifndef BACKENDS_PLUGINS_ARM_LOADER_H
+#define BACKENDS_PLUGINS_ARM_LOADER_H
+
#include "backends/plugins/elf/elf-loader.h"
class ARMDLObject : public DLObject {
@@ -36,4 +39,6 @@ public:
ARMDLObject() : DLObject() {}
};
+#endif /* BACKENDS_PLUGINS_ARM_LOADER_H */
+
#endif /* defined(DYNAMIC_MODULES) && defined(ARM_TARGET) */
diff --git a/backends/plugins/elf/elf-loader.cpp b/backends/plugins/elf/elf-loader.cpp
index 5ce8af6295..e11f9fcce6 100644
--- a/backends/plugins/elf/elf-loader.cpp
+++ b/backends/plugins/elf/elf-loader.cpp
@@ -25,53 +25,12 @@
#if defined(DYNAMIC_MODULES) && defined(ELF_LOADER_TARGET)
-#include <string.h>
-#include <stdarg.h>
-
-#ifdef __PSP__
-#include <psputils.h>
-#include <psputilsforkernel.h>
-#endif
-
-#ifdef __DS__
-#include <nds.h>
-#endif
-
-#ifdef __WII__
-#include <malloc.h>
-#include <ogc/cache.h>
-#endif
-
#include "backends/plugins/elf/elf-loader.h"
#include "common/debug.h"
#include "common/file.h"
#include "common/fs.h"
-/**
- * Flushes the data cache (Platform Specific).
- */
-static void flushDataCache(void *ptr, uint32 len) {
-#ifdef __DS__
- DC_FlushRange(ptr, len);
- IC_InvalidateRange(ptr, len);
-#endif
-#ifdef __PLAYSTATION2__
- (void) ptr;
- (void) len;
- FlushCache(0);
- FlushCache(2);
-#endif
-#ifdef __PSP__
- sceKernelDcacheWritebackRange(ptr, len);
- sceKernelIcacheInvalidateRange(ptr, len);
-#endif
-#ifdef __WII__
- DCFlushRange(ptr, len);
- ICInvalidateRange(ptr, len);
-#endif
-}
-
DLObject::DLObject() :
_segment(0),
_symtab(0),
@@ -86,7 +45,6 @@ DLObject::DLObject() :
}
DLObject::~DLObject() {
- unload();
}
// Expel the symbol table from memory
@@ -101,8 +59,11 @@ void DLObject::discard_symtab() {
// Unload all objects from memory
void DLObject::unload() {
discard_symtab();
- free(_segment);
+ freeSegment(_segment);
_segment = 0;
+ _segmentSize = 0;
+ _segmentOffset = 0;
+ _segmentVMA = 0;
}
bool DLObject::readElfHeader(Common::SeekableReadStream* DLFile, Elf32_Ehdr *ehdr) {
@@ -193,7 +154,7 @@ bool DLObject::loadSegment(Common::SeekableReadStream* DLFile, Elf32_Phdr *phdr)
int extra = phdr->p_vaddr % phdr->p_align; // Get extra length TODO: check logic here
debug(2, "elfloader: Extra mem is %x", extra);
- if (!(_segment = (char *)memalign(phdr->p_align, phdr->p_memsz + extra))) {
+ if (!(_segment = (char *) allocSegment(phdr->p_align, phdr->p_memsz + extra))) {
warning("elfloader: Out of memory.");
return false;
}
diff --git a/backends/plugins/elf/elf-loader.h b/backends/plugins/elf/elf-loader.h
index 6413c46cea..7c1d0830f3 100644
--- a/backends/plugins/elf/elf-loader.h
+++ b/backends/plugins/elf/elf-loader.h
@@ -25,8 +25,8 @@
#if defined(DYNAMIC_MODULES) && defined(ELF_LOADER_TARGET)
-#ifndef ELF_LOADER_H
-#define ELF_LOADER_H
+#ifndef BACKENDS_PLUGINS_ELF_LOADER_H
+#define BACKENDS_PLUGINS_ELF_LOADER_H
#include <stddef.h>
@@ -65,9 +65,14 @@ protected:
bool loadStringTable(Common::SeekableReadStream* DLFile, Elf32_Shdr *shdr);
virtual void relocateSymbols(ptrdiff_t offset);
+ // architecture specific
virtual bool relocate(Common::SeekableReadStream* DLFile, unsigned long offset, unsigned long size, void *relSegment) = 0;
virtual bool relocateRels(Common::SeekableReadStream* DLFile, Elf32_Ehdr *ehdr, Elf32_Shdr *shdr) = 0;
+ // platform specific
+ virtual void *allocSegment(size_t boundary, size_t size) const = 0;
+ virtual void freeSegment(void *segment) const = 0;
+ virtual void flushDataCache(void *ptr, uint32 len) const = 0;
public:
DLObject();
virtual ~DLObject();
@@ -78,6 +83,6 @@ public:
void discard_symtab();
};
-#endif /* ELF_LOADER_H */
+#endif /* BACKENDS_PLUGINS_ELF_LOADER_H */
#endif /* defined(DYNAMIC_MODULES) && defined(ELF_LOADER_TARGET) */
diff --git a/backends/plugins/elf/elf-provider.h b/backends/plugins/elf/elf-provider.h
index f06621f5b7..447e71ea18 100644
--- a/backends/plugins/elf/elf-provider.h
+++ b/backends/plugins/elf/elf-provider.h
@@ -52,7 +52,7 @@ public:
ELFPlugin(const Common::String &filename)
: _dlHandle(0), _filename(filename) {}
- ~ELFPlugin() {
+ virtual ~ELFPlugin() {
if (_dlHandle)
unloadPlugin();
}
diff --git a/backends/plugins/elf/mips-loader.cpp b/backends/plugins/elf/mips-loader.cpp
index 642ea0427a..027ff34698 100644
--- a/backends/plugins/elf/mips-loader.cpp
+++ b/backends/plugins/elf/mips-loader.cpp
@@ -321,10 +321,6 @@ bool MIPSDLObject::loadSegment(Common::SeekableReadStream* DLFile, Elf32_Phdr *p
// Unload all objects from memory
void MIPSDLObject::unload() {
- discard_symtab();
- free(_segment);
- _segment = 0;
-
if (_shortsSegment) {
ShortsMan.deleteSegment(_shortsSegment);
_shortsSegment = 0;
diff --git a/backends/plugins/elf/mips-loader.h b/backends/plugins/elf/mips-loader.h
index a3210b5b12..28b8c7f636 100644
--- a/backends/plugins/elf/mips-loader.h
+++ b/backends/plugins/elf/mips-loader.h
@@ -26,6 +26,9 @@
#if defined(DYNAMIC_MODULES) && defined(MIPS_TARGET)
+#ifndef BACKENDS_PLUGINS_MIPS_LOADER_H
+#define BACKENDS_PLUGINS_MIPS_LOADER_H
+
#include "backends/plugins/elf/elf-loader.h"
#include "backends/plugins/elf/shorts-segment-manager.h"
@@ -47,4 +50,7 @@ public:
}
};
+#endif /* BACKENDS_PLUGINS_MIPS_LOADER_H */
+
#endif /* defined(DYNAMIC_MODULES) && defined(MIPS_TARGET) */
+
diff --git a/backends/plugins/elf/ppc-loader.h b/backends/plugins/elf/ppc-loader.h
index 13043924bb..574ba104e6 100644
--- a/backends/plugins/elf/ppc-loader.h
+++ b/backends/plugins/elf/ppc-loader.h
@@ -25,6 +25,9 @@
#if defined(DYNAMIC_MODULES) && defined(PPC_TARGET)
+#ifndef BACKENDS_PLUGINS_PPC_LOADER_H
+#define BACKENDS_PLUGINS_PPC_LOADER_H
+
#include "backends/plugins/elf/elf-loader.h"
class PPCDLObject : public DLObject {
@@ -36,5 +39,7 @@ public:
PPCDLObject() : DLObject() {}
};
+#endif /* BACKENDS_PLUGINS_PPC_LOADER_H */
+
#endif /* defined(DYNAMIC_MODULES) && defined(PPC_TARGET) */
diff --git a/backends/plugins/ps2/ps2-provider.cpp b/backends/plugins/ps2/ps2-provider.cpp
new file mode 100644
index 0000000000..71e715ae50
--- /dev/null
+++ b/backends/plugins/ps2/ps2-provider.cpp
@@ -0,0 +1,72 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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 program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#if defined(DYNAMIC_MODULES) && defined(__PLAYSTATION2__)
+
+#include "backends/plugins/ps2/ps2-provider.h"
+#include "backends/plugins/elf/mips-loader.h"
+
+class PS2DLObject : public MIPSDLObject {
+public:
+ PS2DLObject() :
+ MIPSDLObject() {
+ }
+
+ virtual ~PS2DLObject() {
+ unload();
+ }
+
+protected:
+ virtual void *allocSegment(size_t boundary, size_t size) const {
+ return memalign(boundary, size);
+ }
+
+ virtual void freeSegment(void *segment) const {
+ free(segment);
+ }
+
+ virtual void flushDataCache(void *, uint32) const {
+ FlushCache(0);
+ FlushCache(2);
+ }
+};
+
+class PS2Plugin : public ELFPlugin {
+public:
+ PS2Plugin(const Common::String &filename) :
+ ELFPlugin(filename) {
+ }
+
+ virtual DLObject *makeDLObject() {
+ return new PS2DLObject();
+ }
+};
+
+Plugin *PS2PluginProvider::createPlugin(const Common::FSNode &node) const {
+ return new PS2Plugin(node.getPath());
+}
+
+#endif // defined(DYNAMIC_MODULES) && defined(__PLAYSTATION2__)
+
diff --git a/backends/plugins/ps2/ps2-provider.h b/backends/plugins/ps2/ps2-provider.h
index 00ddb4647e..8c5e8af65a 100644
--- a/backends/plugins/ps2/ps2-provider.h
+++ b/backends/plugins/ps2/ps2-provider.h
@@ -18,29 +18,24 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
+ * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/gsoc2010-plugins/backends/plugins/ds/ds-provider.h $
+ * $Id: ds-provider.h 52112 2010-08-16 08:41:04Z toneman1138 $
*
*/
#if defined(DYNAMIC_MODULES) && defined(__PLAYSTATION2__)
+#ifndef BACKENDS_PLUGINS_PS2_PROVIDER_H
+#define BACKENDS_PLUGINS_PS2_PROVIDER_H
+
#include "backends/plugins/elf/elf-provider.h"
-#include "backends/plugins/elf/mips-loader.h"
class PS2PluginProvider : public ELFPluginProvider {
- class PS2Plugin : public ELFPlugin {
- public:
- PS2Plugin(const Common::String &filename) : ELFPlugin(filename) {}
-
- DLObject *makeDLObject() { return new MIPSDLObject(); }
- };
-
public:
- Plugin* createPlugin(const Common::FSNode &node) const {
- return new PS2Plugin(node.getPath());
- }
+ Plugin *createPlugin(const Common::FSNode &node) const;
};
+#endif // BACKENDS_PLUGINS_PS2_PROVIDER_H
+
#endif // defined(DYNAMIC_MODULES) && defined(__PLAYSTATION2__)
diff --git a/backends/plugins/psp/psp-provider.cpp b/backends/plugins/psp/psp-provider.cpp
new file mode 100644
index 0000000000..5bf9b0cc20
--- /dev/null
+++ b/backends/plugins/psp/psp-provider.cpp
@@ -0,0 +1,75 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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 program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#if defined(DYNAMIC_MODULES) && defined(__PSP__)
+
+#include <psputils.h>
+#include <psputilsforkernel.h>
+
+#include "backends/plugins/psp/psp-provider.h"
+#include "backends/plugins/elf/mips-loader.h"
+
+class PSPDLObject : public MIPSDLObject {
+public:
+ PSPDLObject() :
+ MIPSDLObject() {
+ }
+
+ virtual ~PSPDLObject() {
+ unload();
+ }
+
+protected:
+ virtual void *allocSegment(size_t boundary, size_t size) const {
+ return memalign(boundary, size);
+ }
+
+ virtual void freeSegment(void *segment) const {
+ free(segment);
+ }
+
+ virtual void flushDataCache(void *ptr, uint32 len) const {
+ sceKernelDcacheWritebackRange(ptr, len);
+ sceKernelIcacheInvalidateRange(ptr, len);
+ }
+};
+
+class PSPPlugin : public ELFPlugin {
+public:
+ PSPPlugin(const Common::String &filename) :
+ ELFPlugin(filename) {
+ }
+
+ virtual DLObject *makeDLObject() {
+ return new PSPDLObject();
+ }
+};
+
+Plugin *PSPPluginProvider::createPlugin(const Common::FSNode &node) const {
+ return new PSPPlugin(node.getPath());
+}
+
+#endif // defined(DYNAMIC_MODULES) && defined(__PSP__)
+
diff --git a/backends/plugins/psp/psp-provider.h b/backends/plugins/psp/psp-provider.h
index 18623e448c..39e0d32caa 100644
--- a/backends/plugins/psp/psp-provider.h
+++ b/backends/plugins/psp/psp-provider.h
@@ -18,8 +18,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
+ * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/gsoc2010-plugins/backends/plugins/ds/ds-provider.h $
+ * $Id: ds-provider.h 52112 2010-08-16 08:41:04Z toneman1138 $
*
*/
@@ -29,22 +29,13 @@
#define BACKENDS_PLUGINS_PSP_PSP_PROVIDER_H
#include "backends/plugins/elf/elf-provider.h"
-#include "backends/plugins/elf/mips-loader.h"
class PSPPluginProvider : public ELFPluginProvider {
- class PSPPlugin : public ELFPlugin {
- public:
- PSPPlugin(const Common::String &filename) : ELFPlugin(filename) {}
-
- DLObject *makeDLObject() { return new MIPSDLObject(); }
- };
-
public:
- Plugin* createPlugin(const Common::FSNode &node) const {
- return new PSPPlugin(node.getPath());
- }
+ Plugin *createPlugin(const Common::FSNode &node) const;
};
-#endif /* BACKENDS_PLUGINS_PSP_PSP_PROVIDER_H */
+#endif // BACKENDS_PLUGINS_PSP_PROVIDER_H
#endif // defined(DYNAMIC_MODULES) && defined(__PSP__)
+
diff --git a/backends/plugins/wii/wii-provider.cpp b/backends/plugins/wii/wii-provider.cpp
new file mode 100644
index 0000000000..25f54f02de
--- /dev/null
+++ b/backends/plugins/wii/wii-provider.cpp
@@ -0,0 +1,75 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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 program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#if defined(DYNAMIC_MODULES) && defined(__WII__)
+
+#include <malloc.h>
+#include <ogc/cache.h>
+
+#include "backends/plugins/wii/wii-provider.h"
+#include "backends/plugins/elf/ppc-loader.h"
+
+class WiiDLObject : public PPCDLObject {
+public:
+ WiiDLObject() :
+ PPCDLObject() {
+ }
+
+ virtual ~WiiDLObject() {
+ unload();
+ }
+
+protected:
+ virtual void *allocSegment(size_t boundary, size_t size) const {
+ return memalign(boundary, size);
+ }
+
+ virtual void freeSegment(void *segment) const {
+ free(segment);
+ }
+
+ virtual void flushDataCache(void *ptr, uint32 len) const {
+ DCFlushRange(ptr, len);
+ ICInvalidateRange(ptr, len);
+ }
+};
+
+class WiiPlugin : public ELFPlugin {
+public:
+ WiiPlugin(const Common::String &filename) :
+ ELFPlugin(filename) {
+ }
+
+ virtual DLObject *makeDLObject() {
+ return new WiiDLObject();
+ }
+};
+
+Plugin *WiiPluginProvider::createPlugin(const Common::FSNode &node) const {
+ return new WiiPlugin(node.getPath());
+}
+
+#endif // defined(DYNAMIC_MODULES) && defined(__WII__)
+
diff --git a/backends/plugins/wii/wii-provider.h b/backends/plugins/wii/wii-provider.h
index deb143b02a..a29f1da931 100644
--- a/backends/plugins/wii/wii-provider.h
+++ b/backends/plugins/wii/wii-provider.h
@@ -25,21 +25,17 @@
#if defined(DYNAMIC_MODULES) && defined(__WII__)
+#ifndef BACKENDS_PLUGINS_WII_PROVIDER_H
+#define BACKENDS_PLUGINS_WII_PROVIDER_H
+
#include "backends/plugins/elf/elf-provider.h"
-#include "backends/plugins/elf/ppc-loader.h"
class WiiPluginProvider : public ELFPluginProvider {
- class WiiPlugin : public ELFPlugin {
- public:
- WiiPlugin(const Common::String &filename) : ELFPlugin(filename) {}
-
- DLObject *makeDLObject() { return new PPCDLObject(); }
- };
-
public:
- Plugin* createPlugin(const Common::FSNode &node) const {
- return new WiiPlugin(node.getPath());
- }
+ Plugin *createPlugin(const Common::FSNode &node) const;
};
+#endif // BACKENDS_PLUGINS_WII_PROVIDER_H
+
#endif // defined(DYNAMIC_MODULES) && defined(__WII__)
+