PowerPC emulation

In an effort to bring kernel 2.6 to D-Link DSM G600 device I have been playing with PowerPC emulators in an effort to boot Linux on them (with grand plan of writing support for DSM G600 device if at all possible).

As a start, I tried to boot DSM G600 Linux kernel with qemu. That didn't work quite well... So, I got detoured into trying to make PearPC to boot anything. Darwin kind-of worked until half of installation, but nothing else did. Shame, I really like PearPC debugging capabilities.

So I went back to qemu. And tried, and patched it, and tried again. Didn't help.

However, I had fortune to stumble upon dynamips which is Cisco 7200 (and other Cisco MIPS and PowerPC routers) which was written much more cleanly, and it was able to boot my unmodified DSM G600 kernel after just a few tweaks to load kernel ELF image at beginning of memory as opposed to address which is embedded in ELF file:

setup_arch: enter
setup_arch: bootmem
Bridge init failed
arch: exit
Memory BAT mapping: BAT2=16Mb, BAT3=0Mb, residual: 0Mb
Total memory is 16777216.
Total memory = 16MB; using 64kB for hash table (at c01f0000)
Linux version 2.4.21-pre4 (dpavlin@brr) (gcc version 2.95.4 20010319 (prerelease)) #523 Wed Sep 5 13:07:36 CDT 2007
Host bridge init failed
Motorola SPS Sandpoint Test Platform
Port by MontaVista Software, Inc. (source@mvista.com)
On node 0 totalpages: 4096
zone(0): 4096 pages.
zone(1): 0 pages.
zone(2): 0 pages.
Kernel command line: root=/dev/sda3 console=ttyS0,9600
No OpenPIC found !
Calibrating delay loop...

It doesn't go much further than this, but than again, this is also great progress :-)

I also evaluated GXemul which is another multi-CPU emulator (supporting among PowerPC among other CPUs), but it doesn't have MMU implementation for PowerPC, so it wasn't able to map memory around which is needed for Linux boot (it seems). It's again shame, because it does have great debugging...

Anders Gavare answered my e-mail about MMU and I stand corrected:

GXemul has MMU (TLB) emulation for PowerPC. Unix-like OSes (such as NetBSD) require it.

However, different powerpc processors may use different kinds of tlbs, so it is possible that the specific PowerPC processor you want to emulate is not implemented in GXemul.

Now, I would really like to have support for qemu. However, qemu code is all but clean and simple, so this doesn't seem like possible goal, at least for me. But, if I continue to develop emulator based on dynamips or gxemul, I will have to write all hardware support myself.

More information about current status can be found in this forum post.