Tuesday, January 05, 2010

RISC OS Compatibility Revisited

Today, I managed to get a Public Domain RISC OS program that uses the shared C library to run.

The application is unmodsqz from !SqzUnSqz (www.martinkd.freeuk.com/unsqueeze.html), which unsqueezes relocatable modules.

Unfortunately, it was a rather circular problem, because the shared C library is squeezed and thus not directly supported by the compatibility library (which can be thought of as being a bit like WINE, but for RISC OS). The solution I used was to unsqueeze the CLib module on an existing RO computer, a better one is probably to use the Graham Shaw's open source (GPL) library from RiscPkg.

Anyway, the biggest problem was with the library accessing zero page (the bottom 4k of RAM), because it appears that it can't be mmap'd into memory on x86 Linux. The solution I've used is just to catch SEGV events and interpret the x86 instruction accessing the memory. That was a lot easier than I thought (especially as I only had to deal with x86 instructions generated by the ARM emulator code), and gave me some experience of recovering from signals. A similar approach could be fairly easily used for non-word-aligned memory accesses and reduce the code generated by the emulator and, no doubt, speed up emulated code significantly.

I've tried to get a few of the applications from the ROOL site to run, but without success; a lot more SWIs need to be implemented. One thing I noticed was that Edit uses UpCall 6 (no UpCalls are supported at the moment, the SWI just pretends to work), and that could be something like ROLF's Detatch mechanism - needs looking into.