Darwin 0.3 & 1.0 on Qemu

Darwin 0.3 PowerPC

Interestingly enough a lot of the same weirdness of missing bits I saw on the x86, is also on the PowerPC.

There is no nice installer, the CD image actually boots MacOS 8.6 which currently won’t run on Qemu.  However Darwin 1.0 uses MacOS 9, which will.  There is not install program for Darwin, rather you need a secondary disk, that is partitioned so the volume manager will pick it up, and then you restore a backup onto the target disk.  Naturally the restore program from 0.3 won’t work, but the 1.0 will under the G4 Cube MacOS 9 CD-ROM install.

Also I couldn’t figure out the boot parameters so I used Steve Troughton Smith’s BootX loader https://github.com/steventroughtonsmith/BootX to get the OS booted.

qemu-system-ppc.exe -L pc-bios -drive file=..\darwin03.qcow2,index=0,format=qcow2,media=disk -drive file=BootX_custom.dmg,index=2,format=raw,media=disk -prom-env “boot-device=ide1:2,\BootX” -prom-env “boot-args=-v rd=hd0 debug=0xffe kdp=2” -prom-env “boot-file=ide0:8,\mach_kernel” -M g3beige

It’s a little convoluted but it does work.

I put together a binary package for Qemu on sourceforge here: Darwin03-PowerPC_qemu-2.11_04_22_2018.7z

Currently there is no networking, I’m guessing I need drivers from OS X 1.x but Ive had really bad luck with the mouse to try to open a terminal window to see if the new sungem NIC is functional at all.

Mac OS X Server 1.0 installs on Qemu

OS X Server 1.2 on qemu single user mode

That’s right, the ADB is usable enough now to type and move the mouse, meaning that OS X Server can now be installed within Qemu!

It’s incredibly slow, and the mouse is incredibly jumpy, but it’s actually running!

Basically, like A/UX, you boot up into MacOS to partition the drive.

qemu-system-ppc-screamer.exe -L pc-bios -m 256 -M mac99 -prom-env “boot-args=-v” -prom-env “auto-boot?=true” -prom-env “vga-ndrv?=true” -hda 2GB.vmdk -cdrom “Mac OS X Server 1.2, MOSX_Booter.iso” -sdl -device usb-mouse -device adb-keyboard -boot d

OS X Server 1.2 MacOS 9 Create OS X Server partition

And then kick off the installer:

OS X Server 1.2 MacOS 9 Start Install

Which really isn’t much to do, other than tagging the partition, and prepping the machine to reboot.

It’s OK

Qemu doesn’t emulate the NVRAM, so it’ll complete with this ‘non fatal’ ‘fatal error’

After that, boot into the OS X Server kernel, and continue the install:

qemu-system-ppc.exe -L pc-bios -prom-env “boot-args=-v rd=sd0″ -drive file=2GB.vmdk,index=1,format=vmdk,media=disk -M g3beige -cpu g3 -drive file=”Mac OS X Server 1.2, MOSX_Booter.iso”,index=0,format=raw,media=cdrom -prom-env “boot-device=cd:9,\\:tbxi” -m 256 -net none

OS X Server 1.2 installing text mode

It will then format the disk, and copy over the base operating system.  After that it’s time to shutdown, and reboot the VM.  I couldn’t figure out a pure hard disk boot, but again using the CD-ROM, you can just tell it to pull the root from the hard disk.

qemu-system-ppc.exe -L pc-bios -prom-env “boot-args=-v rd=hd0″ -drive file=2GB.vmdk,index=1,format=vmdk,media=disk -M g3beige -cpu g3 -drive file=”Mac OS X Server 1.2, MOSX_Booter.iso”,index=0,format=raw,media=cdrom -prom-env “boot-device=cd:9,\\:tbxi” -m 256 -net none

OS X Server 1.2 installing

And after this, it’ll want to reboot again.  Launch it up and now we get the initial setup

Setup Assistant

And with that out of the way, we can logon!

And after a while, it’ll load up the desktop

OS X Server 1.2 Desktop

As mentioned above, the mouse is incredibly jittery.  Doing anything graphical is very difficult. But here we are, running OS X/Rhapsody for the PowerPC!

That’s all!

Because the mouse is VERY jumpy at the moment, Im going to make some pre-configured disk images available because running the disk tool under OS 9 is a major pain.  The first image has only been partitioned, while the second has completed the ‘text mode setup’, aka a minimal install.

And that’s it for now!

One of those days.

/*
* Abosolutely brilliant. Assume that sizeof(long) == 4. The author of this
* code should give classes on how to write non-portable code. Other bitches:
*
* (1) assuming that all architectures are big endian
* (2) storing/accessing shorts on unaligned boundaries
* (3) assuming all machines align things to 4 byte boundaries
*
* Define a 2-byte word type and a 4-byte word type.
*/

source – internal.h

sigh.  Anyone have a PDO/Enterprise Objects disc? for some reason I think I need pdo.h

Darwin 0.3 booted multiuser!

Multiuser!

I know it doesn’t look exciting, but really it is!

Darwin03_qemu090_01_5_2017.7z

NetInfo is completely broken, but I just disabled it, I don’t think anyone cares.  It is missing some kernel system call, and copying the one from Rhapsody results in missing calls in the /System library.  So instead of spending more time on it, I just had the startup comment it out.

The headers and spiraling dependencies of things is out of control, so it really needs to be re-built.  But there is enough there for it to boot up, you can telnet into it, and compile simple programs.

As far as I’m aware none of the early Darwin’s ever were released as binary for x86, so I guess that is a nice thing.

The EIDE driver is still busted, I spent a day trying to debug it to come to the conclusion that, yes it does lose interrupts.  While stacking OO drivers to add features sure looks nice, it makes fundamental issues, either in the Driver itself, or the object framework (let’s face it, nothing is defect free) hard for an outsider to find.  From the outside I used to think it was either the DMA or the multisector transfers screwing it up, but with source in hand, disabling both did nothing.

4.4 BSD (darwin) (ttyp0)

login: root
[darwin:~] root# hostinfo
Mach kernel version:
Kernel Release 5.5:
Sun Apr 30 10:53:53 SGT 2017; root(rcbuilder):kernel-7/BUILD/RELEASE_I386
Copyright (c) 1988-1995,1997-1999 Apple Computer, Inc. All Rights Reserved.

Kernel configured for a single processor only.
1 processor is physically available.
Processor type: pentium (Intel Pentium)
Processor active: 0
Primary memory available: 64.00 megabytes.
Default processor set: 40 tasks, 71 threads, 1 processors
Load average: 0.99, Mach factor: 0.00
[darwin:~] root#

For people who like this kind of stuff.  In my limited testing, I found some configure scripts don’t like the idea of a Darwin with a major number of zero.  And seeing that this would fall into place during OS X Server 1.0.2, which makes it Rhapsody 5.5.  I don’t think either of the 1.2 or 1.2v3 Rhapsody 5.6 versions were ever released to the public in source, but maybe someone has a copy somewhere.

And, of course here is a gratuitous dmesg.

Kernel Release 5.5:
Sun Apr 30 10:53:53 SGT 2017; root(rcbuilder):kernel-7/BUILD/RELEASE_I386
Copyright (c) 1988-1995,1997-1999 Apple Computer, Inc. All Rights Reserved.

physical memory = 64.00 megabytes.
using 227 buffers containing 1.27 megabytes of memory
available memory = 59.19 megabytes. vm_page_free_count = 1d99
minimum quantum is 10 ms
Copyright (c) 1982, 1986, 1989, 1991, 1993
The Regents of the University of California. All rights reserved.

PCI Ver=2.10 BusCount=1 Features=[ BIOS16 CM1 ]
Found PCI 2.0 device: ID=0x12378086 at Dev=0 Func=0 Bus=0
Found PCI 2.0 device: ID=0x70008086 at Dev=1 Func=0 Bus=0
Found PCI 2.0 device: ID=0x70108086 at Dev=1 Func=1 Bus=0
Found PCI 2.0 device: ID=0x00a81013 at Dev=2 Func=0 Bus=0
Found PCI 2.0 device: ID=0x802910ec at Dev=3 Func=0 Bus=0
PCI bus support enabled
PnP: Plug and Play support enabled
ISA/EISA bus support enabled
ISA bus
DriverKit version 500
hc0: device detected at port 0x1f0 irq 14
hc0: Checking for ATA drive 0… Detected
hc0: Checking for ATA drive 1…
hc0: Checking for ATAPI drive 1…
hc0: Resetting drives…
Registering: hc0
hd0: QEMU HARDDISK 0.9.0
hd0: 4063 cylinders, 16 heads, 63 spt (disk geometry)
hd0: using multisector (16) transfers.
Registering: hd0
hd0: Device Block Size: 512 bytes
hd0: Device Capacity: 1999 MB
hd0: Disk Label: Disk
hc1: device detected at port 0x170 irq 15
hc1: Checking for ATA drive 0…
hc1: Checking for ATAPI drive 0… Detected
hc1: Checking for ATA drive 1…
hc1: Checking for ATAPI drive 1…
hc1: Resetting drives…
hc1: Drive 0: ATAPI CD-ROM (FAST DRQ, REMOVABLE, CMD PKT LEN=12)
hc1: LBA supported.
hc1: buffer type 3, 512 sectors.
Registering: hc1
IDEDisk: disk 0 is ATAPI
Registering: sc0
sd0: QEMU QEMU CD-ROM 0.9.
Registering: sd0 at Target 0 LUN 0 at sc0
sd0: Disk Not Ready
Registering: fc0
Registering: PS2Controller
Registering: PCKeyboard0
PCI bus support enabled
Registering: PCI0
Registering: EISA0
Registering: event0
Registering: kmDevice0
rootdev 300, howto 40000
BusMouse mouseInit: no resolution in config table. Default is 400
Bus mouse running
Registering: BusMouse
Display0: Cirrus Logic GD5434 detected (2097152 Bytes)
Display0: PCI Dev: 2 Func: 0 Bus: 0
Display: Mode selected: 800 x 600 @ 60 Hz (RGB:256/8)
Registering: Display0
NE2000 Generic Driver v0.9.1b
by Gabor Sebestyen

Vendor: RealTek RTL-8029
BASE: 0xc100; IRQ: 11
Registering: en0
en0: Ethernet address 52:54:00:12:34:56
Device inited…

Updated Darwin 0.3

Darwin03_29_4_2017.7z

It still boots single user mode, one of the source projects has a nice rm -rf $DSTROOT so it nuked what little progress I made during the week.

But I have the compiler running and lots more.  It has issues with netinfo which is really the only thing blocking it from multiuser boot.  Some syscall not found, and I need to dig into the kernel to see if it even exists…

I’ll re-build all the libs and headers.  Oddly enough the disk image I can build libraries and programs can’t build driverkit or the kernel…

Darwin 0.3 single user mode test drive

So I asked around for some old Darwin CD’s and I got lucky!

Darwin 0.3 Front

Volume 1, Summer of 1999!  Although the back doesn’t really give it justice:

Darwin 0.3 back

As you can guess, when they talk about binary and installers, it’s for the PowerMa computers of the era, and not x86.

So once more again, I was able to rebuild a kernel, and build some of the OS.  There isn’t really anything to see, it’s not even slightly usable.  However at the boot loader type in

-s

hit enter, and it’ll boot up in single user mode.

Darwin 0.3 single user mode

Darwin03_qemu090_24_4_2017.7z

There is no games, nothing fun to do, I didn’t even build a compiler.  It’s just enough to show that it’ll boot up.  If you manually conifgure the loop back you can ping yourself, launch inetd you can even try to telnet in, but control break is .. broken, and there is no NetInfo running so no passwords.

Of course for anyone finding this site today there are more newer, and capable images on my sourceforge page:

aapl-darwin/files/qemu-images/

Darwin 0.1 + Rhapsody DR 2 booted!


Following up from yesterday, here we go!

Rhapsody 1.0 booting

So I finally got it running, after some inspiration from NCommander over at nextcomputers.org forums, that the Darwin 0.1 kernel is infact build able, I went ahead and took a stab at it.  While he was trying to start from OPENSTEP, I tried it from something as close as I could to the target, which was Rhapsody DR2.

Back in the days of the NeXT / Apple merger, there was hope that OPENTSTEP could become the next great OS for the Apple Macintosh.  It had been a while since NeXT had the OS running so things had rotten somewhat, as time had passed on.  However the first and most viable platform would of course be the x86.  Back in 1993 while feeling increased pressure in the hardware space, NeXT was forced to start porting away from their black m68k based hardware, and this was an opportunity to get their software running on different platforms.  And sadly in 1993, the NRW aka NeXT RISC Workstation that was in development with dual m88000 processors was killed along with all hardware projects.  In the end it didn’t matter as much as the only processor from the early 90’s that has a vibrant future is the i386.

So back again to this transitional time before OS X 10, there were developer versions of this OS seeded out that required you to have an intel machine as OPENSTEP was being ported to the PowerPC machines that Apple was selling.

So on May 14, 1998, the last public version for the Intel processor was released, DR2.

However two interesting things happened along the way to what would become OS X Server 1.0 .  The first is that Apple gave up on the ‘yellow box‘ portable API, and to satisfy the GPL requirement to release changes to source code, Apple would go one further and release the source code to many of the internal system utilities, along with the kernel in what was known as Darwin.

This was a big deal for many of us, as the cost of getting the source code to any UNIX was incredibly prohibitive, and OS’s like Linux, NetBSD/OpenBSD/FreeBSD were picking up steam, OPENSTEP being awaken from it’s cryonic hibernation but with the promise of being free and open software was pretty great!  Back in the day it sure looked promising!

Obviously things didn’t work out as everyone had hoped as Apple either straight up ignored anyone on the outside, or they hired people who showed promise, made them sign NDA’s and were basically never heard from again.

So the recently recovered source code to Darwin 0.1 corresponds with the release of the PowerPC only OS X Server 1.0.  However as we all found out, Darwin will still built and maintained on Intel, as it was a very secretive plan B, in case something went wrong with the PowerPC platform.  Being portable had saved NeXT before, and now it would save Apple.

So with this little background, and a lot of stumbling around in the dark, I came up with some steps, that have permitted me to build the Darwin 0.1 kernel under DR2.

However it was not perfect, and the biggest glaring issue was due to the software that was recovered, the layer known as driverkit, (driverkit-139.1-1.tar.gz) turns out to be from another, later release of Darwin, the 0.2 release, which the only thing surviving is the driver kit.  It doesn’t build cleanly, and In order to get it to build I had to break the mach PCI bus.  This means that yes, PCI devices will not load at runtime, only at boottime by sald.

After a lot of fighting I was able to produce a system that could boot into both single user and multiuser mode, although it was unable to load drivers so there was no networking, and no UI.

In a fit of boredrom, I built a bunch of the command line tools for Darwin, and a few libraries, and then went to see why the driverkit had a problem finding the reason why KernBus was undefined, or even with some attempts at helping all the methods were unknown, I stumbled onto the fact that during compilation it will generate new headers, and in those headers are the correct interface for driverkit to call into the KernBus.  So I was able to quickly rebuild driverkit, then re-link into the kernel and now I could load drivers!  Thrilled with this much, I did something more aggressive, I made a dump of my install ‘target’ and then restored it onto an image of my dev VM.  And much to my amazement it booted up to the graphical login.  I now had PCI working correctly.

Darwin 0.1

This kind of thing is not for casual users, but if you install DR2 into a VM, you ought to be able to then use this ISO image, and follow these instructions, and you will then have a DR2 OS from 1998 with the OS X 1.0 kernel from 1999 running.  The biggest difference I’ve noticed is that the newer kernel can use 512MB of RAM, a nice bump up from 192 which was the prior limit.

Obviously there is a lot more work to be done, it’d be nice to find some source to an IDE or other block controller and modify it to work with the massive disks of today, along with the filesystem code to handle partitions larger than 2GB.

Maybe it will be possible to port in the driverkit to XNU, so we can get things like existing drivers, and SMP, massive filesystems etc..  It’s great to see we are going the right way.

For fans, here is a qemu 0.90 image+exe that can run Darwin 0.3 into single user mode.

EDIT and for people still hitting this, here is a multiuser bootable image.  I’ll keep updating on the source forge page.

Sourcecode to Darwin 0.1 located!

Over on the NeXT Computers forum, the source code has been uploaded and shared to all!

Rob Blessin uploaded the source!

So naturally I mirrored it as soon as I found out, dumped it into CVS, so I can load it up in CVS2WEB, and src2html.

And I setup a quick mirror over on my vpsland site (as always 404 error gives the correct password). It’s source code only, so no binaries.

As an edit, it was source only, but I’ve made binaries, and even Qemu images.