# Running a kernel through an emulator.

## Darexius

I'm curious to know if it's possible to run an x86 kernel on another architecture through qemu much like you would if you installed Windows on a non-x86 arch?

The project revolves around running an x86 base on a PPC-based PS3. If you can run Wine via an emulated x86 system, you could maximize the amount of memory you have, and with the RSX being unlocked via new kernel modules, you could "in theory" run a rather solid system on the PS3.

----------

## szczerb

From what I remember emulating a different arch is seriously slow.

----------

## NeddySeagoon

Darexius,

There is gentoo for the PS3, why bother with inter arch emulation which is seriously slow?

WINE is not an emulator. It gives windows programs full control of the CPU as if they were really running in windows.

When these windows programs make API calls, WINE mimics Windows behavior so the program gets the response it expects.

Hence WINE provides native or sometimes faster execution.

WINE is still only 32 bit, so can only usefully address 4Gb of RAM. You would not get the benefit of the PS3 64 bit CPU.

----------

## boerKrelis

AFAIK you can't run x86 win32 apps on a 32 bits ppc-compiled Wine, provided there is a non-experimental ppc Wine. x86 is little-endian. PPC is big-endian.

I've booted x86 win2k on a 1.13 Ghz G4 with qemu. Barely usable, but YMMV.

----------

## Darexius

The reason why I would need to emulate the arch is to take advantage of Wine. Like the previous post stated, you can't use wine on the PPC. It only translates system calls, not emulates them. While Gentoo has a PS3 build, it won't help trying to run x86 apps. It's painfully slow, but YMMV. Instead of emulating Windows, if I just emulated a linux subsystem it would use less memory and should execute somewhat faster than it's doze counterpart. That'll allow for more memory to be used for x86 apps, albeit they'll process slowly.

----------

## eccerr0r

Still don't understand what's the point of this project (what specifically are you trying to do?)... It is possible to totally emulate a cpu (and peripherals) with another, with or without dynamic translation, but it would be slow either way.  But once you emulate the CPU, if you can run a native kernel in that environment, you can also run native wine and apps that normally run under x86/wine should work fine under ps3 emulated x86/wine..

But it will not be any faster than simply running windows in the emulator.  Memory will not be your bottleneck, translation will be.  Other than for a cute demonstration of running some windows program on your ps3 (maybe this is specifically your intent?), you're better off running on real hardware...

----------

## Darexius

 *eccerr0r wrote:*   

> Still don't understand what's the point of this project (what specifically are you trying to do?)... It is possible to totally emulate a cpu (and peripherals) with another, with or without dynamic translation, but it would be slow either way.  But once you emulate the CPU, if you can run a native kernel in that environment, you can also run native wine and apps that normally run under x86/wine should work fine under ps3 emulated x86/wine..
> 
> But it will not be any faster than simply running windows in the emulator.  Memory will not be your bottleneck, translation will be.  Other than for a cute demonstration of running some windows program on your ps3 (maybe this is specifically your intent?), you're better off running on real hardware...

 

Well that's entirely it. If I can run an x86 system, albeit Windows or Linux (wouldn't Windows have more overhead to worry about, though?), you can run x86 apps on your PS3 or any PPC system. This project started when I was discussing a port to a specific game, FFXI, to the PS3, and since the PS3 is nolonger backwards compatible, the only other viable solution to playing FFXI on the PS3 is running it through emulation. The intent isn't to get blazing graphics or anything, it's just to make it playable.

----------

## NeddySeagoon

Darexius,

Look at what PearPC does. Its a PPC emulator for x86 CPUs. The idea is to run Apple PPC code on Intel based hardware.

I relaise you want to go the other way but it will give some indication of what is involved.

They use two approaches, instruction by instruction emulation, which is very slow. Each instruction is emulated every time its encontered. The other approach they use is to emulate once and store the native code, so that next time the instruction sequence is encountered, the emulation is already complete. From memory, this produces speeds approaching 1/40 of native.

Also look at mame. Mame emulates lots of processors on x86 (again, the wrong way for you) but you may learn something useful.

Emulating the CPU is usually the easy bit. Emulating the I/O is much harder.

----------

