[GEM Development] Weird idea...

Owen Rudge owen at owenrudge.net
Wed Feb 22 21:57:42 PST 2006


> Such ideas have been posted to the list a number of times over the past 
> few years... sadly, nobody has been able to come up with any code as of 
> yet. Considering you'd have to emulate the Motorola 68K processor, it's 
> not too easy a task (a number of 68K emulators do exist, though), but it 
> wouldn't be impossible. Apple emulates the 68K processor in their PowerPC 
> Mac OS and has applications run seemingly natively under that, and they've 
> done it again for PowerPC OS X apps in Intel OS X. I'm sure more 
> discussion was had on the technicalities of this in the past, but I can't 
> remember the specifics. If someone's up to the task, anyway, feel free to 
> try. ;-)

Ah, indeed, there was a thread entitled "Re: Atari GEM emulation [Was: 
Fashion]" back in March 2001 which dealt with the subject. I'd link to it in 
an archive, but none seem to exist any more, and the old HTML archive I 
generated from my personal archives disappeared on Noah Silva's server some 
time ago. :-( But, a snippet from Ben:

---
> OK. So we have a program running in the emulator, and if it executes one
> of those traps, we catch it, translate it and pass it to FreeGEM. Any
> results are passed back.
Yep, that ought to cover most eventualities.  We may also want to stick an
exception on whatever the 68k uses for IN/OUT to ports, or MOVs to anything
outside 'userspace', so we can pop up a 'This program may not function
normally as it accesses the Atari hardware directly' alert.

> Presumably this means that the program has to
> watch for a certain sequence of opcodes in the MC68K code and trigger a
> routine when the traps are called to gather the parameters and whatever
> they point to... does this make sense?
Anybody heard of the plex86 project?  It's similar to bochs, except it
doesn't virtualise the x86 hardware entirely - it uses the stuff inside the
processor to do nearly everything, just trapping on anything that's
different between VMs AIUI.  Anyway, one thing that plex86 does to run code
is to set up the page registers so running code that hasn't been checked for
problems already causes a page fault.  This page fault then pushes the
processor into the innards of plex so it can work out what to do.

We could possibly make use of that - if the MC68k supports exceptions in
such a way, we simply replace the GEM TRAP with something that causes an
exception, triggering a return to the GEM emulator.  Otherwise, we would
have to look for the trap calls, and whenever the 'processor' executes this
code, call GEM and hopefully not damage anything.

---

Hope this helps!

-- 
Owen Rudge
http://www.owenrudge.net/ 



More information about the gem-dev mailing list