User:Fekhesk

From OSDev.wiki
Jump to navigation Jump to search

Apple PowerPC Development Information

Preface

As has been said before, there is not really any such thing as "the PowerPC architecture". This article will primarily focus on Apple G3-G4 PowerMacs and PowerBooks, so keep in mind that many things this article discusses may not be applicable on other platforms.

Mainly, there are many differences between "New World" PowerMacs, "Old World" PowerMacs, CHRP PowerMacs, and even more for the other platforms that make use of PowerPC CPUs (e.g. consoles, new Amiga hardware, etc.).

References to "PowerPC" and "the PowerPC architecture" should be assumed to be in reference to New World PowerMacs.

Overview

A good place to start with osdev on PowerPC is by writing an OpenFirmware client, that is, a program that can be run under OpenFirmware. These programs are simply ELF binaries that receive a function pointer in the arguments to their entry function, which can be used to access "services" from the OpenFirmware runtime. This system is somewhat analogous to how UEFI works, and like with UEFI, your next steps should probably be to get information about the system, stop using OpenFirmware, and then take over control of the system.

After this, you'll probably want to take control of memory management (which up until now has been under the control of OpenFirmware), set up exception handling, and start working on device drivers.

Your best references will likely be the books published by IBM on the PowerPC instruction set architecture (IBM, The PowerPC Architecture: A specification for a new family of RISC processors), which will provide you with most of the information required for general PowerPC stuff such as paging, exceptions, instructions, etc.; the book published by apple on CHRP Macintosh computers (Apple Computer, Inc., Macintosh Technology in the Common Hardware Reference Platform), which while not as applicable to New World computers, still will provide you with information on hardware such as ADB, Mac-IO, VIA, etc.; and the standards documents for the IEEE 1275 (OpenFirmware) standards, which will provide the most information on calling OpenFirmware services, and help with things that will definitely be useful such as printing to the OpenFirmware terminal, and accessing the initial framebuffer.

Getting Started

As stated above, if you want to start out by writing an OpenFirmware client, then you should get a simple "hello world" program booting on your system. This will require making a program that gets the "stdout" property from the device tree node "/chosen", and calling the method on it to write text to the terminal. Most if not all of the information required to write this code is available on the Open Firmware documentation website, although some files may need to be converted from PostScript if you do not have a PostScript reader.

After building an OpenFirmware-compatible ELF file, you will want to place this on an HFSPLUS partition on a drive formated using an APM "MAC" partition table. This can then be booted from OpenFirmware using something along the lines of:

load usb0/disk@1:,\filepath

go

Notable Information

While working on PowerPC, it is always best to test on real hardware.

Notably, some things that QEMU allows with MMU initialization, will result in a "decrementor exception" error on real hardware (not actually related to the CPU decrementor, rather seemingly a generic error printed by the system in certain cases).