[Scummvm-devel] Question regarding DC plugins

Andre Heider a.heider at gmail.com
Thu Aug 20 19:12:10 CEST 2009


On Thu, Aug 20, 2009 at 4:49 PM, yotam barnoy<yotambarnoy at gmail.com> wrote:
> While I'm at it, could the Wii developers tell me why they didn't manage to
> use this approach with the Wii? I'm guessing that it has to do with the
> PowerPC's instruction vs. data memory protection and not having kernel level
> access, but I'd be interested to know for sure so that if this method is not
> doable for the PSP I won't waste too much time on it.

There is no memory protection on the PPC side for the Wii, so using
the DC plugin approach for the Wii is possible without technical
difficulties. You can just write code to memory and jump there.
Its not that urgent because a ScummVM binary with all game engines
does works fine, we didn't yet hit the memory limit on any game. The
exception is the Gamecube port, which uses the same code as the Wii
port, and COMI runs out of memory there. I once tried various
implementation to realise plugins, but didn't finish it. I guess we do
hit the limit sooner or later, because the number of game engines grow
from release to release, and the size of the executable does matter.
Plugins provide a nice way to solve that problem. I'd rather implement
that than providing multiple binaries with a different game engines
compiled in.

It's possible to code a generic ELF plugin, which is reusable for
multiple ports. It just has to support the CPU architecture for the
port you want to use it for: You allocate memory for the plugin and
load the ELF sections in there, but you have to relocate it.
Relocating code fixes up things like jump instructions, which is
necessary because the code location in memory is unknown at the time
you compile the plugin.
There are multiple relocation types for every CPU architecture. The DC
has a SH CPU, and I think Marcus just needed to implement one
relocation type. But as is, its not reusable, because of the different
CPU type.

Then, there's an option to compile code as PIC (position independent
code), but the plugin still needs to jump back to common function in
the main code - hence relocation in mandatory.

To port it for Wii/GC, one would have to implement the PPC relocation
types, and the reason I didn't finish is because there are so many:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/include/elf/ppc.h?rev=1.25&content-type=text/x-cvsweb-markup&cvsroot=src
I'm not sure how many of those are really required.

You should talk to Joost before working on plugin support for the PSP.
I think he once mentioned some platform specific feature that could be
used for plugins, and a full fledged plugin loader might not be
necessary. But it's possible I mix things up and that's just not true
;)

Regards,
Andre




More information about the Scummvm-devel mailing list