Build the PowerPC part of the NewWorld Mac ROM
Go to file
Elliot Nunn a323be3c8b Reverse some VM functions (Daniel)
VeryPopularFunction (now GetPARPageInfo) takes a page number in the PAR
and returns a bunch of info on it. The flags of the PTE are copied into
cr5-cr7 of the condition register so that VMCalls can easily make
decisions off of them. I had already figured out the bit flags of the
PTEs Mac OS 9 uses when I reversed PagingFunc1. The definitions are in
the end of the 'Area Definitions.txt' file I sent you a while ago.

If you see a  ' bltl cr5, VMDoSomethingWithTLB' (now RemovePageFromTLB)
followed by a ' bltl cr5, major_0x09b40' (now RemovePTEFromHTAB), you
know that the function is manipulating pages directly. RemovePageFromTLB
clears a page from the TLB if it follows a VeryPopularFunction call.
RemovePTEFromHTAB takes a page that is resident in the HTAB and removes
its HTAB entry. cr5_lt is bit 20 (mask 0x800), which my notes tell me is
set when the PTE is in the HTAB. Altogether, the sequence translates to
'if the page is in the HTAB, flush it from the TLB and delete its HTAB
entry'. VMExchangePages uses this (twice) to make sure there are no race
conditions when it is swapping the data in the pages.

I still don't have proof, but I am very very strongly convinced that
KDP.FlatPageListPointer is always equal to the PAR's PageMapArrayPtr.

On an unrelated note, KCMapPage seems to always panic when called on an
area where the PageMapArrayPtr is 2d. I have absolutely no idea why this
happens, but it is bad news for MPMapper because the threshold for
2-dimensionality is around 1 MB. I would have to make 512 separate
CreateArea calls to map all the memory without the NK panicking. I will
have to look into this.
2018-02-18 11:17:23 +08:00
BuildResults Initial commit 2018-02-18 01:24:10 +08:00
Internal Start to reverse the legacy VM subsystem 2018-02-18 01:24:21 +08:00
Linker Initial commit 2018-02-18 01:24:10 +08:00
NanoKernel Reverse some VM functions (Daniel) 2018-02-18 11:17:23 +08:00
.gitignore Initial commit 2018-02-18 01:24:10 +08:00
ConfigInfo.s Initial commit 2018-02-18 01:24:10 +08:00
EasyBuild Initial commit 2018-02-18 01:24:10 +08:00
Emulator.x Initial commit 2018-02-18 01:24:10 +08:00
MakeFile Initial commit 2018-02-18 01:24:10 +08:00
PPCExceptionTable.s Initial commit 2018-02-18 01:24:10 +08:00
README.md Initial commit 2018-02-18 01:24:10 +08:00
RomMondo.bin Initial commit 2018-02-18 01:24:10 +08:00
SetFileTypes.sh Initial commit 2018-02-18 01:24:10 +08:00

The PowerPC ROM for NewWorld Macs

This repo is part of the CDG5 project. It builds a 4 MB PowerPC Mac ROM by appending PowerPC code to a 68k Mac ROM (either the included dump, or one that you built yourself). The build result is a byte-perfect copy of the ROM inside the final "Mac OS ROM" release.

Fixing line endings

MPW requires old-style Mac line endings (CR), while Git works better with Unix line endings (LF). Git filters can be used to convert between the two. Files committed to the repo are "cleaned" (LF-ed), and then "smudged" (CR-ed) when they hit the working tree. After cloning, append these snippets to your Git config.

Append this to .git/config:

[filter "maclines"]
	clean = LC_CTYPE=C tr \\\\r \\\\n
	smudge = LC_CTYPE=C tr \\\\n \\\\r

Append this to .git/info/attributes:

* filter=maclines
*.* -filter
*.s filter=maclines
*.a filter=maclines
*.c filter=maclines
*.h filter=maclines

Finally, do a once-off "re-smudge":

rm -rf ../powermac-rom/*
git checkout .

Setting type and creator codes

Some MPW Tools require their input files to have the correct Mac OS file type, but Git does not save Mac OS type and creator codes. This shell script will give enough files a "TEXT" type to keep MPW happy.

sh SetFileTypes.sh

Building

This code is built with the Macintosh Programmer's Workshop (MPW), which runs on the Classic Mac OS. To satisfy the memory requirements of the build process, the MPW Shell should get a memory partition of at least 16 MB. Once you have MPW set up, the build process is not particularly fussy.

Not many computers run the Classic Mac OS any more. Here are a few workarounds:

  • Just find a Mac running Mac OS 7.5-9.2. (Not much fun if it's also your test machine.)
  • Use the Classic environment on a PowerPC Mac running Mac OS X 10.4 or earlier. (A small PowerBook or iBook is perfect.)
  • Use EMPW ("Emulated MPW"), a package of command-line tools, emulators and OS images that lets you run MPW commands straight from your macOS Terminal. This is my preferred solution.

Once MPW is set up, the build command is:

EasyBuild

Using EMPW, that's:

empw -b EasyBuild

The 4 MB image will be at BuildResults/PowerROM.

What's next?

On NewWorld Macs, this image is extracted into RAM from a "Mac OS ROM" file at boot. Use https://github.com/elliotnunn/newworld-rom to build such a file.