PDA

View Full Version : Panther on MacBook Air



iMic
7th February 2014, 09:04 PM
Alright, so it's not quite OS X Panther on Intel. This is about as close as it comes though.


In the middle of last year, the Qemu Project finally gained a complete enough OpenBIOS implementation to boot Mac OS X in their PowerPC emulator. Considering PearPC hasn't been updated in quite some time and doesn't compile with JITC support under OS X, rendering it horribly slow, this improvement in Qemu is perhaps the first real attempt at making OS X run, well, on OS X.

But it has a couple of issues. For starters, the colours are horribly distorted. This appears to be an issue with the frame buffer and hopefully it will be fixed in a later version.

http://i.imgur.com/RxStcHT.png

Secondly, Qemu's emulation of New World Macs isn't complete. When starting Qemu, you can choose to run it g3beige mode to emulate an Old World Mac based on the Gossamer architecture, or mac99 mode, which emulates a New World Mac. Emulating an Old World system will allow OS X Jaguar to boot, while the incomplete New World emulation can boot OS X Tiger.



Update (3-3-14): I have tried Tiger with the incomplete New World emulation as well and found that it doesn't seem to work, so your results may vary. If New World emulation fails, it's likely the fixes below to run Panther will allow you to install Tiger as well.


What doesn't work is OS X Panther. Attempting to boot OS X Panther with Old World emulation results in the installer failing hardware checks, and attempting to boot it with New World emulation results in the system locking up during the boot process.

Other than the above, it works. Because I'm impatient and don't want to wait for these fixes, I decided to see if I could work around them.



Building Qemu PPC

First thing's first. You'll need Xcode installed from the Mac App Store. Once that's done, you'll want to install Homebrew (http://brew.sh) unless you find sorting dependencies thrilling. Once Homebrew installs, it prompts you to run brew doctor from the command line to configure it. If you're running the version of Xcode from the App Store and haven't yet installed the command line tools, it will likely prompt you to do so now.

You will then need to install some packages - pkg-config, glib, automake and libtool. This is where Homebrew makes this so much easier. All you have to do is type one brew install command to install a package, then wait.


Install pkg-config

brew install pkg-config

Install glib

brew install glib

Install automake

brew install automake

Install libtool

brew install libtool


There's a few dependencies, so it's possible I've missed a few that I forgot I had to install. If I find any more, I'll add them in here.

Now remember I said Qemu had a couple of issues before? This is where we work around one of them. Qemu uses GTK as its frame buffer, and this is where the inverted colours bug lies. So instead of attempting to fix it this time, I simply decided to disable GTK and use SDL instead. To do this, we'll need to install one more package:


Install SDL

brew install sdl


Now we start working on Qemu. Download the latest Qemu source tar.bz2 from Download - QEMU (http://wiki.qemu.org/Download). I'm using v1.7.0 here, although v1.6.2 has a later release date. From what I gather, either is fine. I simply decompressed the archive to a folder on my desktop, nothing fancy here.

Once you have the source in a folder, it's time to make it do something. First, switch to the directory containing the source code.



cd /path/to/qemu/source/


Now we want to configure the source to build the PowerPC emulator. You first need to type ./configure followed by a few arguments. --target-list=ppc-softmmu tells the compiler to build the PowerPC emulator.

To work around the distorted colours issue, we're disabling GTK, so add --disable-gtk as well. Finally, because we're not using GTK, make Qemu use SDL instead with --enable-sdl. You should have the following:



./configure --target-list=ppc-softmmu --disable-gtk --enable-sdl


It can take a few moments for the Configure process to run. When it is done, we're ready to build the emulator. To do this, you can run make install to begin the process. However in order to keep the files that are built contained in a central location, I'm also using the DESTDIR argument to specify the output folder for the built files, like so:



make DESTDIR=$HOME/qemu install


If you experience errors along the lines of autoreconf: failed to run aclocal: No such file or directory, make sure you've installed Automake from Homebrew. Likewise, errors such as error: possibly undefined macro: AC_PROG_LIBTOOL are related to Libtool not being installed.

The DESTDIR=$HOME/qemu argument forces the compiled files to be placed in a folder called qemu in the user's home folder.

Provided the build completed successfully, you should now have several files in that directory, like so:


http://i.imgur.com/6EJQ9V1.png



Running Qemu

For now, we're focusing our attention to the bin folder. Change to this directory from the command line. If you used the same locations as me, it will be something like so:



cd ~/qemu/usr/local/bin/


Now, we should make a blank hard disk image to install OS X to. You can do this with the qemu-img utility that was compiled alongside the qemu-system-ppc application in the bin folder.

It's rather simple. You run qemu-img with the create flag, then -f qcow2 to set the image format to qcow2, then specify the location to create the disk image. I placed it alongside the app in the bin folder with ./machd.img. Finally, you specify the image size in GB. A 5GB image should be enough for a small install, so 5G will do. When you're done, it should look like so:



./qemu-img create -f qcow2 ./machd.img 5G


This is incredibly quick, almost instantaneous. That's normal. You should now have a machd.img folder in the location you specified.


Now it's time to start this machine up!

There are a number of variables to pass to the VM to make it behave in different ways. I'll do my best to explain these.



./qemu-system-ppc


Starts the app.

-L pc-bios/


I haven't looked into this setting actually... but it works with it there.

-m 256


The amount of memory available to the VM in megabytes (MB). Note this is a lower case flag (-m).

-M g3beige or -M mac99


The type of machine to emulate. Use g3beige for Jaguar, or mac99 for Tiger. You can also use g3beige to run Panther - and i'll tell you how I fixed that soon.

-cpu G3 or -cpu G4 or -cpu 970fx


The type of processor to emulate. G3 and G4 both work with g3beige, however 970fx only works with mac99.

-hda /path/to/hard/disk/image.img


The path to the hard disk image you created earlier.

-cdrom /path/to/cd/image.iso


The path to the CD/DVD image you are using to install OS X.

-g 1024x768x32


The resolution and colour depth of the VM window. I can confirm 800x600 and 1024x768 work, but I'd imagine many more combinations do too. I'd recommend leaving the colour depth at 32 however. It may be possible to switch to lower colour depth to speed up the video, but I haven't had success doing so.

-boot c or -boot d


Specifies what Qemu should automatically boot from. I still have to check, but I think -boot c forces a boot from the HDD image, while -boot d forces a boot from the CD/DVD image. You don't have to use this flag, but not specifying it will cause Qemu to boot to an Open Firmware prompt, and you will have to type boot hd:,\\:tbxi or boot cd:,\\:tbxi from there to choose the boot device - just like on a real Mac.

-prom-env ‘boot-args=-v’


Passes Open Firmware commands to the virtual machine. Boot-args=-v tells the machine to boot in Verbose Mode. You can replace the -v with -s (Single User Mode) and -x (Safe Boot) as well. You could in theory replace everything between the single quotes with another command to pass that to the VM if you wished.


There are possibly more commands that will work as seen at QEMU Emulator User Documentation (http://wiki.qemu.org/download/qemu-doc.html), but I'm still messing around to see what works and what doesn't.



The command I use to start Qemu is:



./qemu-system-ppc -L pc-bios/ -m 256 -M g3beige -cpu G3 -cdrom /Users/me/Desktop/Panther1.iso -g 1024x768x32 -hda /Users/me/Desktop/machd.img


Keeping in mind that I chose to have my HD and CD images on the desktop, so my paths may look a little different. I also left off the -boot d argument since I'm comfortable with bashing commands into Open Firmware.

Having run that command and waited a surprisingly short amount of time for it to boot considering it's an emulator, I finally see the product of my efforts.


http://i.imgur.com/856tpOR.png


If you're running OS X Jaguar or OS X Tiger, I'm told this is all you need to do. Go forth and install!


But wait, isn't that Panther I'm running? I promised I'd explain how to make Qemu accept OS X Panther, so if you feel adventurous, read on...



Patching OpenBIOS for Panther (and Tiger!)

When you enable -M g3beige while launching Qemu, it will happily boot from your Panther disc all the way into the installer. However the installer then chokes, telling you that OS X Panther can not be installed.

See, when Panther checks for incompatible machines, it looks for AAPL,PowerMac G3. This was a throwback to the Power Mac G3 Minitower and Desktop, which would run up to OS X Jaguar but were officially dropped with OS X Panther.

Of course, the OpenBIOS implementation used by Qemu for g3beige mode identifies as an AAPL,PowerMac G3. This is why the installer fails. So the trick is to modify OpenBIOS to make it identify as a Power Mac G3 Blue & White - the PowerMac1,1.


Fire up a Hex Editor. I recommend Hex Fiend (http://ridiculousfish.com/hexfiend/).


Navigate to the folder where Qemu is stored, but this time go to share > qemu instead of bin and open openbios-ppc with your hex editor.

http://i.imgur.com/FazEaOt.png


Now you want to select Edit > Find. In the Find field type:


41 41 50 4C 2C 50 6F 77 65 72 4D 61 63 20 47 33

And in Replace type:


50 6F 77 65 72 4D 61 63 31 2C 31 00 00 00 00 00

Then click Replace. The file should then look like this:


http://i.imgur.com/eMFYgT7.png


Once that is done, save the file. Boot up Qemu like you did before and start up from your OS X Panther disc. This time it should pass the machine identifier check and install OS X successfully.

All done!





If you're curious as to what this hex edit does, read on. Otherwise you can skip this next part.


You want to search for the text string "AAPL,PowerMac G3" (without quotes) or hex 41 41 50 4C 2C 50 6F 77 65 72 4D 61 63 20 47 33. The hex may not have spaces, but in Hex Fiend it did. You should find it like so:


http://i.imgur.com/A52UNAL.png


Now change it to text string "PowerMac1,1 " (without quotes) or hex 50 6F 77 65 72 4D 61 63 31 2C 31 00 00 00 00 00.

This is what it should then look like:


http://i.imgur.com/kq3RIHV.png


You may notice there's some extra spaces after "PowerMac1,1". This is intentional. Since "PowerMac1,1" is shorter than "AAPL,PowerMac G3" by 5 characters, we need to pad the missing characters with 5 spaces.

However, you can't simply hit the space bar a few times after typing "PowerMac1,1" since this will then include the spaces as characters in the machine identifier, and OS X won't be able to find the correct drivers for the platform. The reason is that a regular space in hex is 20, and we need the hex value of the spaces to be 00.

In other words, hitting space 5 times will be represented in hex like so:



50 6F 77 65 72 4D 61 63 31 2C 31 20 20 20 20 20


And we need:



50 6F 77 65 72 4D 61 63 31 2C 31 00 00 00 00 00


So while you can hit space 5 times after typing "PowerMac1,1", you'll need to change those "20"s in hex to "00"s.



Hopefully once the mac99 emulation is a little more complete, this modification will no longer be necessary and OS X Panther will boot up using the mac99 emulation as intended. Until then though, this is a suitable fix.



Conclusion

I worked on this late into the morning, and so hopefully I haven't missed anything important. Retracing my own steps while writing this allowed me to successfully compile Qemu again, so I think it's right.


Having installed OS X Panther under Qemu, I can safely say that performance wise, this blows PearPC out of the water. The OS is actually usable enough to play around with, although it still needs further improvements to actually be a practical use system. For example, sound and video acceleration don't work, and while networking does, it does so via a tap method. Some key mappings are also incomplete, so some keys like the Apple / Command key don't map to the guest.

However I was incredibly surprised to see that Qemu doesn't constantly hammer the host CPU, so while the emulation takes a decent amount of processing power to perform heavier tasks (such as installing the OS), its host CPU utilisation falls to as low at 12% on my 1.8GHz i5 MacBook Air when the PowerPC guest is idle. Needless to say, this emulation is very good.

All in all, it's a very promising start.


http://i.imgur.com/tZZhOFF.png


Most of all though, it's just a little fun. Anyone that loves to play around with older operating systems like I do will find this interesting.


Oh, and if anyone would like my pre-compiled version of Qemu with the OpenBIOS modification already applied, I'd be happy to send it over. From what I gather it should run on any x86_64 based Mac, but I don't have another machine to test on at the moment so I can't guarantee it. Still, if anyone would like to have a shot at it, I'll gladly send it over.


Cheers,
~ Michael.


Sources

OS X PowerPC on Qemu | Fun with virtualization (http://virtuallyfun.superglobalmegacorp.com/?p=3189)

QEMU Mac OS X... Success! - Mike Levin (http://mikelev.in/2012/10/qemu-mac-os-x-success/)

Installing Qemu for OSX and running PowerPC OSX 10.2, 10.3 or 10.4 [E-Maculation wiki] (http://www.emaculation.com/doku.php/ppc-osx-on-qemu-for-osx)

Oldmacs
3rd March 2014, 11:16 AM
How on earth did I miss this!!!

Thanks for posting this!! It looks very interesting.. I've wanted a way to run Panther or Tiger on my Macbook for a while :)

iMic
27th April 2014, 07:51 PM
No worries, it was a fun challenge. :) I'm still finding out more information as I find the time to mess around with it as well.

Speaking of which, I updated the article above. I've added information about the dependencies Automake and Libtool, which I overlooked earlier. Thankfully they're easy installs from Homebrew. I also went through and moved all the screenshots to Imgur since the existing host wasn't as reliable.

paronga
2nd May 2014, 01:07 PM
:O!!!!