Linux for Macintosh 68K Port

“I don't care if space aliens ate my mouse” or a case study in both the technical and human issues in porting the Linux OS to a new M68K target platform.

Several barriers to a Linux for Macintosh 68K port exist. The first is that Apple does not want other operating systems on its machines. While almost all of the workings of a PC can be learned from books, almost nothing is written about the Apple Macintosh. Sometimes Macintosh specifications and technical notes fill in the blanks; at other times, it is necessary to apply a great deal of guesswork and experimentation to figure out the hardware.

The second barrier is a human one. Most Macintosh machines were not sold to the technical market, and average Macintosh users aren't terribly interested in a “real operating system” for their computers. Nevertheless, a sizable technically oriented Macintosh user community does exist, with a lot of Macintosh hardware to go with it (probably more than any other non-Intel Linux platform). A further reason has been provided by Apple, whose quaint advice for owners of 68K machines now appears to be “buy a new computer”.

The third barrier to a Linux port is less obvious and is hidden by a lack of documentation. Certain folks have speculated that embarrassment is the main reason for Apple Computer releasing so little documentation. In general, Macintosh platforms have positively Stone Age design features. For example, the interrupt controllers on a Macintosh II are a pair of 6522 VIA chips, intended for use with the 8-bit 6502 processor. Bad hardware design makes for poor performance, unless carefully handled. The complete lack of DMA (direct memory access) is even less helpful. Apple seems to think no DMA is a feature on most machines and actually have a technical note stating “I used to be a teenage DMA junkie”, which seems to be a justification of their rather comical hardware design.

Getting Started

To get a port started, the first item needed is hardware. I had most of this (a 5MB MacII, cast off from the office as too slow for practical use). Initially, I felt safe helping to work out the directions for the Linux port, as this system lacked an MMU (memory management unit) and was therefore unable to run any proposed Linux port.

Rob Pelkey started on some very basic Linux work for the Macintosh, but needed a boot loader to load the Linux OS and kick it off. On #linux on the LinuxNet IRC network, Jes Sorensen (the keeper of Linux68K), I and several others got into a few discussions about the port and what would be required. After a lot of digging, we managed to gather some basic information on the Macintosh68K, then filled in further areas by investigating the excellent detective work the OpenBSD/Macintosh team had done in getting BSD limping along on Macintosh machines. Further information came to light from the Linux on OSF Mach port sponsored by Apple. We discovered that Apple continued to use the same 8-bit microcontrollers, or emulations of them, and had not redesigned the systems materially for the new processor.

Everything seemed perfectly fine. I had a Macintosh box to laugh at (and we used it occasionally to fail to duplicate problems Macintosh users had with CymruNet), we could kick ideas around and I had no MMU in my Macintosh, so I couldn't possibly help write any code.

By this point, Rob's effort had stalled badly, as he lacked the time to write the boot loader needed to run Linux and was working on passing courses and other sundry items. No worry—either someone would eventually take over the project, or he would finish his courses. Then Frank Neuman sent me an MMU for the MacII and someone else donated a pair of Ethernet cards—whoops, no more excuses.

Learning MacOS

Having fitted the MMU to the Macintosh without blowing it up, I tried to get MacOS to run with virtual memory. This is supposed to be simple—click on the memory tool and select 32-bit, virtual memory on. But no, my memory control didn't have a 32-bit option, let alone a virtual memory one. I stared a bit, then checked on a more modern Mac downstairs to be sure I had the right screen. The other Macintosh which was running the same MacOS version had the required option; mine didn't.

This was my first experience with the horrors of the Mac. While UNIX says “I'm sorry you can't do that”, MacOS has exactly two error messages. It either goes “eep?” or the setup box is simply not there until 12 other unidentified items have been installed and three apparently unrelated dialog boxes have been completed. Mine was an error of the latter category.

Apple shipped the MacII with the ability to upgrade to include an MMU chip; therefore, they sensibly shipped it with a system ROM incapable of running with the MMU enabled. Brilliant—just don't design anything mission-critical, please. Fortunately, Apple had concealed on their web site a small tool which patches the ROM entry points so that it can run in 32-bit mode.

Okay, so all I had to do was download the tool, install it and be done—not so simple. To get the program, I needed the Ethernet to work. I ended up using kermit to transfer 700KB of Ethernet installer onto the Macintosh. After four hours of fighting with the completely alien Macintosh archiver tools, I had the machine talking AppleTalk shares to a Linux box using Netatalk, as well as insight into why Macintosh people meeting a PC for the first time look as if they'd just discovered alien life forms.

An hour later, I had figured out how to unpack Macbin files and the Macintosh was in 32-bit mode and admitted the MMU was present and functional.