Login  •  Register


The time is now: Sun Dec 11, 2016 1:45 pm

Emaculation wiki  •  Delete all board cookies



Post new topic  Reply to topic Page 1 of 1 [ 5 posts ]
Print view Previous topic  |  Next topic
Author Message
PostPosted: Sun Oct 23, 2016 5:09 pm 
Offline
Space Cadet

Joined: Sun Sep 11, 2016 6:35 am
Posts: 2
Hello my fellow Mac OS enthusiasts,

For several months now, Nanopico and I, both of the MacOS9Lives forum, have been picking apart the Power Mac ROM. As we go, we have been writing build and "unbuild" code for NewWorld ROM images (aka "Mac OS ROM" files, Toolbox images and tbxis). The part of the ROM that we have explored to the greatest depth is the PowerPC Nanokernel -- specifically version 02.28, which seems to be the final one. This (very sanitised!) workflow best demonstrates our toolchain, which I have dubbed the "Toolbox toolbox".

Code:
$ git clone https://github.com/elliotnunn/cdg5.git && cd cdg5

$ ls
boot-script              kernel-stock     prcl-pefs      test-template.img
datafork-pefs            Makefile         README.md      trampoline.elf
kernel-disasm-script.py  PowerROM-nokern  rsrc-template

$ make kernel-redisassemble
Disasm:  05k 10k 15k 20k 25k 30k 35k 40k 45k 50k 55k 60k 65k 70k 75k 80k ...80736b

(Edit your newly-generated kernel-disasm.s, an annotated assembly code document. Maybe clobber something to see when and how the machine crashes, or change a constant to observe its effect on the PowerMacInfo application.)

$ make test
(output from kernel assembly, PowerROM construction, parcel compression,
Mac OS ROM packaging, HFS image modification and QEMU)

(QEMU will start from the included minimal OS 9 image, patched with your kernel. The Nanokernel log will come up during boot and will be redrawn intermittently. PowerMacInfo is the only startup app.)

(Now edit your kernel-disasm-script.py, the script that produced the above kernel-disasm.s, to reflect the wisdom that you have gleaned from your experiment.)

$ make kernel-redisassemble
Disasm:  05k 10k 15k 20k 25k 30k 35k 40k 45k 50k 55k 60k 65k 70k 75k 80k ...80736b

(Admire your more beautifully disassembled kernel. And submit a pull request so that I can too!)

The Nanokernel stands right in between the PowerPC and the mostly-68k "blue" task. I am interested in it because it is the first barrier to broadening Mac OS 9's hardware support. Using QEMU's new ability to emulate the Mac OS, I have been able to make rapid iterative improvements to my disassembly script, which describes much of what I know about the kernel.

We'd be pretty chuffed if anyone wants to join in. The best test of your relevant knowledge is probably whether you know C and grok pointers -- but err on the side of having a go. I picked up PowerPC assembly as I went, and so can you.

While we have some moderately exotic build dependencies, I have neatly packaged these up as Docker images. To run the above code you only need to have Make, Docker and an OS 9-capable QEMU. You do not need to download any Docker images yourself, or even know how to use Docker. The makefile takes care of that for you. This build system is brand new, and while I think it should work for everyone, I'd like to know about build failures ASAP.

Happy hacking,

Elliot


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Mon Oct 24, 2016 3:55 am 
Offline
Apple Corer

Joined: Sun Feb 01, 2009 4:55 pm
Posts: 226
I've wanted to this for so long. Huge props to you guys for doing this.

I don't think it will be easy, but I do have some dev docs related to this for a Power Mac G3 B&W model. I can imagine there would be hacks to get around the hardware revisions Apple did. I can imagine the Old World ROMs being a mess, seeing as it's a mix between PPC and 68k code. Oh, and the Mac OS relies on the ROM for the 68k emulator, unless you're Sheepshaver and can supply your own.

And for those who don't know what grok means, here comes Wiktionary to the rescue.


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Tue Oct 25, 2016 9:33 am 
Offline
Space Cadet

Joined: Sun Sep 11, 2016 6:35 am
Posts: 2
Thanks!

Broadly speaking, the top megabyte of the PowerROM contains low-level PowerPC-specific code and data: the Nanokernel, the emulator and some boot-time structures. I understand its layout pretty well. The remaining three megabytes are a mess, although we've made some progress there.

The most amazing thing you could do (plug plug) would be to try out our build system and hit me with some feedback! Any takers?


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Thu Dec 01, 2016 1:37 am 
Offline
Student Driver

Joined: Tue Jun 23, 2015 5:37 am
Posts: 13
Just curious, what hardware are you aiming at having some type of support?


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Thu Dec 08, 2016 1:32 pm 
Offline
Space Cadet

Joined: Sat Oct 24, 2015 12:24 pm
Posts: 2
elliotnunn wrote:
The part of the ROM that we have explored to the greatest depth is the PowerPC Nanokernel

Wow, very impressive work, especially the annotated assembly!

I did a vaguely similar analysis of the very first PowerPC Nanokernel used in the PDM machines (PowerMac 6100/7100/8100). I used the built-in debugger of the MAME/MESS project which is very convenient. Although MESS' emulation of the PowerMac 6100 is still preliminary (its hardware isn't supported fully yet) I was able to trace execution flow from HWInit to the 68k emulator.

elliotnunn wrote:
I am interested in it because it is the first barrier to broadening Mac OS 9's hardware support

Do you need to understand the Nanokernel in order to write a device driver for unsupported hardware?

My Nanokernel research has started in 2004 after purchasing a G5 PowerMac. I already owned a G4 Mac and the Connectix VirtualPC emulation package that refused to run in the G5-driven Mac. Because M$oft that purchased VirtualPC 2003 from Connectix refused to fix it in order to work on G5, I was interested to give a try.

Unfortunately, I wasn't able to understand VirtualPC's internals because these were deeply buried in undocumented Nanokernel calls. The OS 9 version of VirtualPC uses several F-trap calls in order to install low-level hooks for switching the CPU endianness, for example. This requires operating in the PowerPC supervisor mode and could be achieved by using undocumented Nanokernel features only.

This was the first time I noticed this amazing piece of software called "Nanokernel". Today, my research is mainly motivated by the question whether it's possible to replace the Nanokernel with a shim instead of low-level emulation. This could be a great step towards freedom of proprietary software and speed improvements. Such a replacement could be only possible if the Nanokernel function and API could be fully understood. BTW, the Classic environment uses a Darwin-based shim instead of OS 9 Nanokernel.

My goal is therefore to contribute to the missing Nanokernel documentation.

Best regards
Max


Top
 Profile  
Reply with quote Post a reply  
Display posts from previous:  Sort by  
Post new topic  Reply to topic Page 1 of 1 [ 5 posts ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
 

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group