Skip to contentSkip to conversation

PPC emulation, how?

Qemu-devel Francisco Jos� Ca�izares Santofimia 5 participants 12 messages Apr 13, 2004 – Apr 21, 2004 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

Hi all.

Jocelyn said was trying to merge the sources into CVS. Today appears to be PPC emulation in CVS :), so, i've got a question about that.

The functions are the same as you specified in:

http://mail.gnu.org/archive/html/qemu-devel/2004-04/msg00092.html

That it's, we can run some linux distributions, but,

waht ROM to use? Get it from a Mac (tried only oldworld macs, such as SheepShaver, although Jocelyn said not want to support it), or, get the Openfirmware (�how?).

If not, what rom/type of rom we need, or it's a free rom (suchs as Bochs BIOS).

Many Thanks in advance :)

______________________________________________________
Get Paid... With Your Free Email at
http://www.zwallet.com/index.html?user=telefrancisco

#1 lore raw
Quoted 3 lines · Francisco José Cañizares Santofimia

Hi all.

Jocelyn said was trying to merge the sources into CVS. Today appears to be PPC emulation in CVS :), so, i've got a question about that.

Yes, thanks to Fabrice who did the merge.

Quoted 7 lines

The functions are the same as you specified in:

http://mail.gnu.org/archive/html/qemu-devel/2004-04/msg00092.html

That it's, we can run some linux distributions, but,

waht ROM to use? Get it from a Mac (tried only oldworld macs, such as SheepShaver, although Jocelyn said not want to support it), or, get the Openfirmware (¿how?).

For now, I don't use a ROM.
I only support booting Linux PREP kernels, using -kernel option.

For help, I put some infos, kernel and boot image here:
http://jocelyn.mayer.free.fr/qemu-ppc/index.htm

I'm far to emulate a real Mac, even far to emulate a real PREP:
we even don't have any kind of PCI support, which seems mandatory for most PPC platforms...

I don't have a real boot-loader, just a few hacks that build a minimal environment to run Linux PREP kernel without firmware support, no RTAS, even no residual infos.
All those stuff will come later...

For now, I still have (many ?) bugs to fix in MMU and exception handling to have a solid core emulation, then I will focus more on hardware & firmware. My goal is to follow current MOL approach and use OpenBIOS so qemu won't need any non-free binaries to run.

Signature · 2 lines
Jocelyn Mayer <[email protected]>
Never organized
#2 lore raw
Quoted 3 lines

For help, I put some infos, kernel and boot image here:
http://jocelyn.mayer.free.fr/qemu-ppc/index.htm

You say there:
To run qemu PPC emulation, I use the following command line:

Quoted 1 line

qemu -S -kernel <my_kernel> -fda <my_floppy> -hda <my_disk> -cdrom <my_cdrom>

Is the -S a special new option or should this be -s

I tried your kernel image and debian install disk.
It does boot but I can't get networking to work
I can set the eth0 of the emulated client to 172.20.0.2 but am unable to ping the host (which is setup at 172.20.0.1 by /etc/qemu-ifup.sh) or the other way around. Is networking not working at all yet or am I missing something

Also I use -nographic else the emulator crashes (stops)

Greetings,
Martin (nldudok1)

#3 lore raw

Hi, sorry for the delay...

Quoted 9 lines · Martin
Quoted 2 lines

For help, I put some infos, kernel and boot image here:
http://jocelyn.mayer.free.fr/qemu-ppc/index.htm

You say there:
To run qemu PPC emulation, I use the following command line:

Quoted 1 line

qemu -S -kernel <my_kernel> -fda <my_floppy> -hda <my_disk> -cdrom

<my_cdrom>

Is the -S a special new option or should this be -s

It's really '-S' . I added this option to tell to qemu not to launch the emulated code. This way, you have some time to grab the serial port output and be able to edit the kernel's command line at startup (PREP kernel allow this...). You just have to type 'c' in qemu monitor then the kernel waits one second with the current command line displayed, then boots if no chars were received.

Quoted 7 lines

I tried your kernel image and debian install disk.
It does boot but I can't get networking to work
I can set the eth0 of the emulated client to 172.20.0.2 but am unable to ping the host (which is setup at 172.20.0.1 by /etc/qemu-ifup.sh) or the other way around.
Is networking not working at all yet or am I missing something

It may not work: I didn't really test the network, just made sure that the NE2000 was seen by the kernel. PPC system emulation is still very experimental...

Quoted 1 line

Also I use -nographic else the emulator crashes (stops)

I never used this option, and it doesn't crash for me. Could you try to launch it under gdb and send me a trace ?

Regards.

Signature · 2 lines
Jocelyn Mayer <[email protected]>
Never organized
#4 lore raw
Quoted 10 lines · Jocelyn Mayer

Hi, sorry for the delay...

Quoted 7 lines

I tried your kernel image and debian install disk.
It does boot but I can't get networking to work
I can set the eth0 of the emulated client to 172.20.0.2 but am unable to ping the host (which is setup at 172.20.0.1 by /etc/qemu-ifup.sh) or the other way around.
Is networking not working at all yet or am I missing something

Quoted 3 lines

It may not work: I didn't really test the network, just made sure that the NE2000 was seen by the kernel. PPC system emulation is still very experimental...

Here's a little patch in NE2000 emulation that makes network available for PPC:
I can now ping my host machine, but failed to mount nfs exports...

Index: hw/ne2000.c
===================================================================
RCS file: /cvsroot/qemu/qemu/hw/ne2000.c,v
retrieving revision 1.5

ne2000.c +9 -0
diff -u -d -w -B -b -d -p -r1.5 ne2000.c
@@ -368,8 +368,13 @@ static void ne2000_asic_ioport_write(voi
     p = s->mem + s->rsar;
     if (s->dcfg & 0x01) {
         /* 16 bit access */
+#ifdef TARGET_WORDS_BIGENDIAN
+        p[1] = val;
+        p[0] = val >> 8;
+#else
         p[0] = val;
         p[1] = val >> 8;
+#endif
         s->rsar += 2;
         s->rcnt -= 2;
     } else {
@@ -397,7 +402,11 @@ static uint32_t ne2000_asic_ioport_read(
     p = s->mem + s->rsar;
     if (s->dcfg & 0x01) {
         /* 16 bit access */
+#ifdef TARGET_WORDS_BIGENDIAN
+        ret = p[1] | (p[0] << 8);
+#else
         ret = p[0] | (p[1] << 8);
+#endif
         s->rsar += 2;
         s->rcnt -= 2;
     } else {
Signature · 2 lines
J. Mayer <[email protected]>
Never organized
#5 lore raw
In reply to Jocelyn Mayer
Quoted 10 lines

It's really '-S' . I added this option to tell to qemu not to launch the emulated code. This way, you have some time to grab the serial port output and be able to edit the kernel's command line at startup (PREP kernel allow this...). You just have to type 'c' in qemu monitor then the kernel waits one second with the current command line displayed, then boots if no chars were received.

I didn't need this to edit the kernel commandline. If you just start typing rightaway when the kernelcommandline appears you can edit it. I did have to use a very wide console to get the whole commandline on one line. The kernel spits out the commandline it got later on and that is consistent with what I typed in.

Quoted 6 lines
Quoted 1 line

Also I use -nographic else the emulator crashes (stops)

I never used this option, and it doesn't crash for me. Could you try to launch it under gdb and send me a trace ?

Ye4s, I will try to do this tuesday or wednesday.

Quoted 3 lines

Here's a little patch in NE2000 emulation that makes network available for PPC:
I can now ping my host machine, but failed to mount nfs exports...

Thanks, I will try this too tuesday or wednesday.
I have two goals for networking right now. The first is to mount a nfs host from within the emulated prep machine. Then I can mount the root filesystem from my real prep machine and chroot or even a root nfs boot (dangerous, I know). This way I can find out very fast which command work and which have problems without having to make huge diskimages first. The second is telnet, ssh and/or x11 using the network.
Serial console and network card are the only two really needed hardware components needed for an (emulated) linux machine. The rest you can do over the network ;-)

A little offtopic maybe. Do you know how I can findout fast which libraries are needed for a certain executable. I tried to make a small diskimage with the basic command from my real prep machine and tried to guess which libraries I needed (but guesses wrong ofcourse). I copied /bin /sbin /etc /lib and a subset of /usr/bin and /usr/lib. /usr/lib is very large and I know I only need some of the libs for the commands I copied in /usr/bin but not which ones.

Greetings,
Martin DvH

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): 1082363002.29001.41.camel@rapid

#9 lore raw
Quoted 7 lines

Is your host your PREP machine ?
If so, it may be (one more) endianness related bug. I will check on a mac, one of these days...

No, My host is an x86 machine (AMD duron 800) running a linux 2.6 kernel. This also might cause problems related to the 1000 Hz kernel ticks in 2.6 in stead of 100Hz kernel ticks in 2.4. I haven't tried to run my prep machine as a host yet. It is not that fast a machine (200 Mhz 604e)

Quoted 8 lines
Quoted 3 lines

A little offtopic maybe. Do you know how I can findout fast which libraries are needed for a certain executable. I tried to make a small diskimage with the basic command from my real prep machine and tried to guess which libraries I needed (but guesses wrong ofcourse). I copied /bin /sbin /etc /lib and a subset of /usr/bin and /usr/lib. /usr/lib is very large and I know I only need some of the libs for the commands I copied in /usr/bin but not which ones.

Well, it seems that ldd or just /lib/ld.so.1 are the tool you need to use:

Quoted 9 lines
Quoted 3 lines

/lib/ld.so.1 --list /bin/ls

       libpthread.so.0 => /lib/libpthread.so.0 (0x0ff8f000)
       librt.so.1 => /lib/librt.so.1 (0x0ff5d000)
       libc.so.6 => /lib/libc.so.6 (0x0fe03000)
       /lib/ld.so.1 => /lib/ld.so.1 (0x08000000)

Thanks, this is what I needed,

Martin

#10 lore raw
Quoted 7 lines · Martin
Quoted 4 lines

Is your host your PREP machine ?
If so, it may be (one more) endianness related bug. I will check on a mac, one of these days...

No, My host is an x86 machine (AMD duron 800) running a linux 2.6 kernel. This also might cause problems related to the 1000 Hz kernel ticks in 2.6 in stead of 100Hz kernel ticks in 2.4.

I don't think it's directly related to this point, as I've been using Linux 2.6 for several monthes on an Athlon XP.
Maybe the gdb trace will say more...

Quoted 2 lines

I haven't tried to run my prep machine as a host yet. It is not that fast a machine (200 Mhz 604e)

Well, I'd better test on a faster Mac, so :-)

Signature · 2 lines
J. Mayer <[email protected]>
Never organized
#11 lore raw
Quoted 4 lines · J. Mayer
Quoted 2 lines

I haven't tried to run my prep machine as a host yet. It is not that fast a machine (200 Mhz 604e)

Well, I'd better test on a faster Mac, so :-)

Hi! I'm running qemu (i386 emulation only, haven't tried ppc yet) on an iBook2 500 MHz. Not the fastest machine under the Sun, but I'd gladly help with any testing that you may need.

Cheers,

Carlos <[email protected]>

#12 lore raw

IWith the ne2000 patch I can ping from host to qemu and from qemu to host.
nfsmount doesn't work yet.
I also tried a few tests with wget.
It fails on some and succeeds on other tests. The good thing is that you can stop wget with ctrl-C (mount and ping from the debianinstalldisk just stop reacting if they fail in qemu)

I think there are more endianess problems because wget fails on all files which are odd sized. I made a few testfiles (less than 1 kb) and put them on my httpserver of the host. a text file of 907 bytes fails 906 bytes succeeds 905 bytes fails.
Fails in this case means the download doesn't even start.

If I try to download the default apache homepage index.html then the download starts but it stoppes at 87 % and says -stalled- I think this file needs more packets (it is 4410 bytes)

I am still not sure how to use the -S option and/or the gdb debugger with qemu.

greetings,
Martin

#13 lore raw
Quoted 6 lines · Martin

IWith the ne2000 patch I can ping from host to qemu and from qemu to host. nfsmount doesn't work yet.
I also tried a few tests with wget.
It fails on some and succeeds on other tests. The good thing is that you can stop wget with ctrl-C (mount and ping from the debianinstalldisk just stop reacting if they fail in qemu)

Just try to use ping -c <count>
so you'll get the shell back...

Quoted 6 lines

I think there are more endianess problems because wget fails on all files which are odd sized.
I made a few testfiles (less than 1 kb) and put them on my httpserver of the host.
a text file of 907 bytes fails 906 bytes succeeds 905 bytes fails. Fails in this case means the download doesn't even start.

I didn't test wget, because it's used to crash when I try to launch it...
I'm not sure those are endian problems. It may be timer problem or worse (MMU...).
I have a new implementation of time-base/decrementer which makes Linux guest timings to be connected to reality.
This also boosts the emulation by a factor of 2 or 3. I'm reworking exception management, which is not well implemented and may be buggy. This will also improve speed and (I hope) solve some emulation problems.

Quoted 2 lines

I am still not sure how to use the -S option and/or the gdb debugger with qemu.

'-S' option is really simple: it just stops qemu just before starting the emulation. You then have to enter the 'c' command in qemu monitor to let it run.
You now have a PPC register dump in the monitor, too with 'info registers'
The use of gdb is not easy when you emulate the whole system. I only use it to solve kernel problems. For userland problems,
the best way may be to launch gdb in the guest system :-)

Signature · 2 lines
J. Mayer <[email protected]>
Never organized