Liam Proven (liam_on_linux) wrote,
Liam Proven
liam_on_linux

Apple's long processor journey

There have been multiple generations of Macs. Apple has not really divided them up.

1. Original 680x0 Macs with 24-bit ROMs (ending with the SE/30, Mac II, IIx & IIcx)
2. 32-bit-clean-ROM 680x0 Macs (starting with the Mac IIci)
3. NuBus-based PowerMacs (6100, 7100, 8100)
4. OldWorld-ROM PCI-based PowerMacs (all the Beige PowerMacs including the Beige G3 & black PowerBooks) ← note, many but not all of these can run Mac OS X
5. NewWorld-ROM PCI-based PowerMacs (iMac, iBook & later)
6. OS-X-only PowerMacs (starting with the Mirrored Drive Doors 1GHz G4 with Firewire 800)
7. 32-bit Intel Macs (iMac, Mac mini and MacBook Core Solo and Core Duo models)
8. 64-bit Intel Macs with 32-bit EFI (Core 2 Duo models from 2006)
9. 64-bit Intel Macs with 64-bit EFI (anything from 2008 onwards)

Classic MacOS was written for 68000 processors. Later it got some extensions for 68020 and 68030.

When the PowerMacs came out, Apple wrote a tiny, very fast emulator that translated 680x0 instructions on the fly into PowerPC instructions. However, unlike modern retrocomputer emulators, this one allowed apps to call PowerPC code, and the OS was adapted to run on the emulator. It was not like running an Amiga emulator on a PC or something, when the OS in the emulator doesn't "know" it's in an emulator. MacOS did and was tailored for it.

They ran Classic MacOS on this emulator, and profiled it.

They identified which parts were the most performance-critical and were running slowly through the emulator, and where they could, they rewrote the slowest of them in PowerPC code.

Bear in mind, this was something of an emergency, transitional project. Apple did not intend to rewrite the whole OS in PowerPC code. Why? Because:
1. It did not have the manpower or money
2. Classic MacOS was already rather old-fashioned and Apple intended to replace it
3. If it did, 68000 apps (i.e. all of them) wouldn't work any more

So it only did the most performance-critical sections. Most of MacOS remained 68K code and always did for the rest of MacOS' life.

However, all the projects to replace MacOS failed. Copland failed, Pink failed, Taligent failed, IBM Workplace OS failed.

So Apple was stuck with Classic MacOS. So, about the MacOS 7.5 timeframe, Apple got serious about Classic.
A lot of MacOS 7.6 was rewritten from assembly code and Pascal into C. This made it easier to rewrite chunks for PowerPC. However it also made 7.6 larger and slower. This upset a lot of users, but it meant new facilities: e.g. the previously-optional "MultiFinder" was now always on, & there was a new network stack, OpenTransport.

This is also the time that Apple licensed MacOS to other vendors.

Soon afterwards, Apple realised it could not build a new replacement OS itself, and would have to buy one. It considered former Apple exec Jean Louis Gassée's Be for BeOS, and Apple co-founder Steve Jobs' NeXT Computer for the Unix-based NeXTstep.

It bought NeXTstep and got Jobs back into the bargain. He regained control, fired Gil Amelio and killed off the licensing program. He also killed Copland, the experimental multitasking MacOS replacement, and got his coders to salvage as much as they could from it and bolt it onto Classic, calling the result MacOS 8.

MacOS 8 got a multithreaded Finder, desktop "drawers", new gaming and web APIs and more. This also killed the licensing programme, which only applied to MacOS 7.

MacOS 8.1 got a new filesystem, HFS+. This still works today and was the default up to High Sierra.

8.1 is the last release for 680x0 Macs and needs a 68040, although a few 68030 Macs work via Born Again.

The "monolithic" / "nanokernel" distinction applies to CPU protection rings.

These days this principally applies to OSes written entirely in compiled code, usually C code, where some core OS code runs in Ring 0, with no restrictions on its behaviour, and some in Ring 3 where it cannot directly access the hardware. IBM OS/2 2 and later uniquely used Ring 1. I've blogged about this before.

OS/2 2 using Ring 1 is why VirtualBox exists.

Decades ago, more complex OSes like Multics had many more rings and used all of them.

If a Unix-like OS is rewritten and split up sop that a minimal part of the OS runs in Ring 0 and manages the rest of the OS as little separate parts that run in Ring 3, that's called a "microkernel". Ignore the marketing, Mac OS X isn't one and neither is Windows NT. There are only 2 mass-market microkernel OSes and they are both obscure: QNX, now owned by Blackberry, and Minix 3, embedded in the control/management circuitry embedded into every modern Intel x86-64 CPU.

Classic MacOS is not a C-based OS, nor is it an Intel x86 OS. It does not have a distinction between kernel space and user space. It does not use CPU rings, at all. Everything is in Ring 0, all the time. Kernel, drivers, apps, INITs, CDEVs, screensavers, the lot.

MacOS 8.5 went PowerPC-only, and in the process of dropping support for 680x0 Macs, Apple made some provision for future improved PowerMacs.

The 68K emulator got a big upgrade to the emulator, now renamed a "nanokernel". It is not an OS in its own right: it boots and runs another OS on top of it.

It is not a HAL: this is native code, deep within an OS kernel, that allows the same OS to run with little modification on widely-different underlying hardware, with different memory maps, I/O spaces, APICs etc., without adapting the kernel to all the different platforms. MacOS 8.5+ only runs on Macs and the hardware could be adapted to the OS and the OS to the hardware. No need for a HAL.

It is not a hypervisor. A hypervisor partitions a machine up into multiple virtual machines -- it allows 1 PC to emulate multiple separate PCs and each virtual emulated PC runs a separate OS. Classic MacOS can't do that and only runs 1 OS at a time.

The MacOS nanokernel is a very small bit of code that boots first and then executes most of the rest of the code, and manages calls from apps from a 68K OS back to code written for the underlying PowerPC CPU.

It'sd a shame that this bit of code is secret and little-known, but some details have been leaked over the years.

Tags: classic, macos, microkernel, nanokernel, os x
Subscribe

Recent Posts from This Journal

  • Well now, that's interesting

    Edit an entry, use the "switch to new editor" option and it duplicates it. Thanks, LJ, that is not what I wanted at all. 🙄

  • Why was there no 32-bit 6502 or 64-bit 68000?

    [Repurposed from Stack Exchange, here ] The premise in the question is incorrect. There were such chips. The question also fails to allow…

  • Unix is Unix is Unix

    In lieu of anything new right now -- I accidentally sent my last post to the wrong Livejournal. In the unlikely event that anyone is reading this…

  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 10 comments