The Salesforce card on the bench, next to the Mesa FPGA card it replaces

Salesforce: Turning a Freescale Dev Board into a Macintosh

For years I had an eBay alert set for a twenty-year-old Freescale development board. Two months ago it finally hit. This is how I turned that board, built around a chip meant for Ethernet routers, into a Macintosh.

PowerPC didn’t die when Apple switched to Intel in 2006. Motorola spun off its chip business as Freescale, Freescale put PowerPC cores into Systems on a Chip, and a decade after NXP bought Freescale, those chips are still in production. They’re in automotive tech as engine, brake, and chassis controllers. They’re in networking gear, and in aerospace hardware nobody wants to redesign. They aren’t new designs, but NXP is going to keep selling them for the foreseeable future.

I’ve always thought it was theoretically possible to build a new Mac out of one of these. The MPC83xx chips have a PowerPC 603e core, the same family as the CPUs in pre-iMac Power Macs, and a careful read of the datasheet shows nothing that would stop Mac OS from running. The late-90s Mac architecture is surprisingly hackable; people have gotten Mac OS 9 running on a Nintendo Wii. All I needed was the hardware, and the patience to wait for it to show up on eBay.

It works. Here’s the first boot on a real monitor:

The MPC8313E-RDB dev board with the Salesforce card plugged in, driving a monitor showing the Mac OS 9 startup screen

How A Macintosh Works

This is a New World ROM Macintosh, the architecture Apple used in everything from the first iMac to the last G4. A Titanium PowerBook works something like the graph below. The ‘system controller’ is kinda equivalent to a PC’s northbridge, and the ‘Mac I/O controller’ is somewhat equivalent to a PC’s southbridge. In the interest of simplicity over accuracy, for the rest of this page I’m going to call them ‘northbridges’ and ‘southbridges’.

Apple's system controllers had code names: Bandit, then the UniNorth family that started in 1999.

The mac-io family began with Grand Central, then O'Hare, Heathrow/Gatwick, Paddington, and KeyLargo.

Around 2001 the two were combined into single chips, Pangea and Intrepid, for the iBooks and iMacs. The G5s split them back apart: U3 and U4 with K2 and Shasta.

flowchart TB
    CPU["PowerPC 750 / 7400"] --> UN["System Controller"]

    UN --> RAM["RAM"]
    UN --> GPU["Graphics"]
    UN --> PCI["PCI"]

    PCI --> KL["Mac I/O Controller"]

    KL --> OP["OpenPIC"]
    KL --> DMA["DBDMA"]
    KL --> PMU["VIA / PMU"]

    OP --> IRQ["Interrupts"]
    DMA --> DEV["ATA / Audio<br/>SCC, etc."]
    PMU --> POWER["Power, RTC<br/>Buttons, Sleep"]

The PowerPC CPU connects to the northbridge, which handles RAM, PCI, and the graphics bus. On the PCI bus sits the southbridge, responsible for interrupts, DMA, storage, serial, audio, timing, and power management.

The Freescale chip already does the CPU and northbridge part: it has its own memory controller and its own PCI host. What it’s missing is everything Apple-specific. So this project is a Mac I/O controller: all the functions of those custom Apple ASICs, rebuilt in an FPGA on a PCI card. I’m calling it Salesforce. Apple named its I/O chips after transit centers, and Salesforce is technically a transit center, so the joke works.

How A Mac Actually Boots

The interesting thing about a New World Mac is how little of Mac OS lives on the motherboard. Before the 1998 iMac, every Mac had a Toolbox ROM, which by the PCI Power Mac era was four megabytes of Apple code on the logic board. The iMac and everything after it ship with a small boot ROM that holds little more than Open Firmware. The actual Mac OS ROM is a file. It’s called Mac OS ROM, it lives in the System Folder, and it’s loaded off the disk like anything else.

How a New World Mac boots: Open Firmware in the boot ROM loads the Mac OS ROM file; its boot script checks for MacRISC; the Trampoline asks Open Firmware about 2,100 questions and hands off to the NanoKernel, which runs the 68k emulator and native PowerPC code that together make up Mac OS

Open Firmware is a Forth interpreter that runs first. It tests the hardware, builds a device tree (a description of every chip on the board, what it’s called, and where its registers live), and then reads the boot script at the top of the Mac OS ROM file. That script checks that the machine says it’s a MacRISC machine, loads the Trampoline and the ROM image, and starts the boot.

The Trampoline is the bridge between Open Firmware and Mac OS. It’s an ordinary Open Firmware client program, and it does its job by asking Open Firmware questions: how much memory there is, where it can put things, what’s in the device tree. It asks a lot of questions. Booting 9.2.2 takes about 2,100 of them. It hands Mac OS a copy of the device tree, which becomes the Name Registry, lays out memory, tells Open Firmware to get out of the way, and jumps into the NanoKernel.

The NanoKernel is a tiny microkernel that owns the PowerPC itself, and it’s been in every Power Mac since 1994. It handles every exception and interrupt, manages the MMU and page tables, and runs the 68k emulator. From there it’s a normal Mac boot: drivers inside the ROM file are matched to device-tree nodes by name, then the System file, every extension, and the Finder.

That chain is why this project is possible at all. Mac OS mostly doesn’t care what’s on the motherboard; it cares what the device tree says is on the motherboard, and whether the drivers it finds can talk to it. Mostly. There are a few places where it reaches out and touches real hardware, and those are where all the fun bugs live.

The Dev Board

The board that finally showed up on eBay is a Freescale MPC8313E-RDB: an MPC8313 PowerQUICC II Pro with an e300 core, 128 MB of DDR2, Ethernet, and, critically, a PCI slot. $120. Plus $70 in shipping.

eBay listing for a Freescale MPC8313E-RDB development board with development kit, sold for $119.96

The e300 is a 603e with extra stuff bolted on, so in theory all of this just works. In practice, there were questions to answer before designing any hardware: Will Apple’s PowerPC code run on the e300? Will the NanoKernel run on it? Does virtual memory work? Do interrupts work the way the NanoKernel wants?

The dev board has no Apple Open Firmware and no Apple chips, so I needed a reference for what a Mac is supposed to look like. That’s QEMU. Its ‘mac99’ machine is a G4 Power Mac with a UniNorth and a KeyLargo, running OpenBIOS, and Mac OS 9.2.2 boots on it. I ran it under a debugger and logged every question the Trampoline asked Open Firmware and every answer it got, all 2,118 of them, plus the whole device tree.

That log is a spec. I wrote a minimal Open Firmware for the dev board that answers exactly those questions and serves that device tree. The Trampoline doesn’t know the difference. It loads the real Mac OS ROM file, hands off to Apple’s NanoKernel, and Mac OS starts running natively on the e300. With no Apple hardware on the board yet, a small firmware stand-in plays the part of the missing chips, modeled on QEMU’s source.

Every question got a yes. And then it went further: the bare dev board boots Mac OS 9.2.2 to the Finder.

Mac OS 9.2.2 Finder desktop, with the Setup Assistant open, read back from the memory of the MPC8313E-RDB

That’s Apple’s NanoKernel, the New World ROM, the 68k emulator, Apple’s own ATA driver, the System file, every extension, and the Finder, all running natively on the MPC8313E. Nothing in Mac OS was patched. There was no monitor attached; I read that screen out of the board’s memory over a serial port.

My favorite bug from that stage: the Trampoline calibrates the CPU’s timer by watching the VIA’s timer count down. On the dev board, the ‘VIA’ at that point was a blank piece of RAM that never counted. The calibration gave up and decided the timer ran at 1.06 GHz. The real figure is 41.67 MHz. Every timer in Mac OS ran 25 times slow, and it took a week of ‘why is the clock always 9:38’ to find it.

Getting to the Finder produced a list of exactly what Mac OS needs from a southbridge: the VIA and PMU, the OpenPIC, a serial port, a handful of feature-control and GPIO registers, a timer, a framebuffer, ATA with DBDMA, and a USB controller. That’s the spec for Salesforce.

An FPGA On The PCI Bus

Software stand-ins don’t answer the hardware questions. Can the Freescale chip’s PCI host enumerate an FPGA? Can an FPGA interrupt the PowerPC? Can it convincingly be a Mac I/O controller?

To find out, I bought an FPGA PCI card meant for controlling CNC machines. Fuck it, an FPGA can control a CNC, or it can be the southbridge in a Macintosh.

eBay listing for a Mesa 5I25 Superport card, a PCI card with a Spartan-6 FPGA, sold for $100

It enumerated, it interrupted, and the device-tree approach held up. That was enough to know this whole project wouldn’t fall flat on its ass, and all of it was learned from about $300 of twenty-year-old electronics off eBay.

Building Salesforce

The Mesa card is an FPGA and a pile of 50-pin headers. That’s enough to prove an FPGA can be a Mac I/O controller, but a Mac I/O controller with nothing attached isn’t a Macintosh. There’s nowhere to plug in a monitor. So I built the real thing.

A render of the Salesforce card, an FPGA on a PCI card, with USB, VGA, audio, an ESP32, and SATA

Ethernet isn’t on the card at all. The Freescale chip has it built in, so I wrote a Mac OS driver for it.

The best part is the boot. The dev board is completely stock: nothing on it is reflashed, and its original bootloader is still there. When it powers on, the card takes over from the stock bootloader, loads Open Firmware, and starts Mac OS. Plug the card into any one of these boards, connect a monitor, keyboard, and a SATA drive, turn it on, and you get a happy Mac.

Bringing It Up

Real hardware is where the device tree stops being enough. A couple of my favorites:

AirPort was slow. Not broken, just slow: tens of kilobytes per second. The ESP32 wasn’t losing anything over the air, and the Mac wasn’t dropping anything either. Frames were vanishing on the SPI link between the FPGA and the ESP. After every transfer, the ESP needs a moment to arm itself for the next one, and the FPGA was starting the next transfer about a tenth of a microsecond too early, into a chip that wasn’t listening yet. Making the FPGA wait for the ESP to say it’s ready took AirPort from a crawl to about half a megabyte per second.

Disk writes were ten times slower than reads. Reads ran at 24 MB/s; writes crawled along at 2.3. The bridge between the Mac’s ATA controller and the SATA drive was sending every 512-byte sector of a write as its own separate command, then waiting for the drive to answer before sending the next one. Mac OS writes in 64 KB chunks, so the drive’s per-command overhead was getting paid a hundred times over. Batching sectors into one command took raw writes from 3 MB/s to 25.

It’s A Mac

It boots Mac OS 9.1 off its install CD, and 9.2.2 off a SATA drive. Holding Shift turns extensions off. Command-Option-P-R zaps the PRAM, and you get the second chime. Settings survive a restart. Ethernet pulls 1.7 MB/s over FTP, AirPort does about half a megabyte a second, and Netscape downloads things. Apple System Profiler knows what it is:

Mac OS 9.2.2 running on the Salesforce card: Graphing Calculator drawing a 3D surface, About This Computer, and Apple System Profiler reporting a model name of SOSUMI Salesforce at 333 MHz with 80 MB of memory

And of course, it plays StarCraft:

StarCraft running on the Salesforce card at 640x480: a Zerg hatchery, drones mining minerals

The CPU in the Freescale chip is a 333 MHz e300 with no L2 cache, so it’s not fast. For raw processor work, MacBench puts it well under half a 300 MHz G3. The graphics and disk numbers are a different story: the FPGA’s framebuffer and SATA keep it right around the G3.

MacBench 5.0 results against a Power Macintosh G3/300 baseline: Processor 407, Disk 698, Graphics 1148

That disk score is from before the write fix. It’s 972 now.

What Comes Next

Salesforce isn’t a product. It needs a specific twenty-year-old Freescale dev board with a 3.3 V PCI slot, and you’d have to find one on eBay the same way I did. What it is is proof: you can build a New World Mac out of a Freescale SoC and an FPGA, running Apple’s own ROM, NanoKernel, and drivers, unmodified.

And once that’s true, a lot of things become possible. There’s nothing stopping a custom motherboard built around this same chip-and-FPGA stack: a Mini-ITX board with SATA, IDE, SCSI, USB, real Mac serial ports, maybe even an AAUI port, if you can find the connector. The Freescale reference designs are all public.

I have a project in mind, which is why the full source for Salesforce isn’t out yet. When it’s done, it’ll all be in the open, and you’re all going to want one.