Darwin
From Xbox-Linux
As of 25 Aug 2005, we have a Darwin/x86 port for the Xbox.
| Table of contents |
[edit]
FAQ
[edit]
What is Darwin?
- Darwin is the base of Mac OS X, comprising the kernel "xnu", the system libraries and the UNIX tools.
[edit]
Can I run Mac OS X on the Xbox?
- No. Darwin does not include the Mac OS X GUI, and the future x86 version of Mac OS X will only run on Apple branded hardware. Besides that, at least the current builds of Mac OS X for x86 need SSE2 and SSE3 support of the CPU - the Xbox CPU has neither. And of course, OS X wouldn't run with only 64 MB of RAM, and very slowly with only 128 MB.
[edit]
Why should I run Darwin instead of Linux?
- You should not. The Xbox version of Linux is far more advanced at the moment than the Xbox version of Darwin. If you are interested in Apple's modified-microkernel BSD-UNIX, have a look at it, though.
[edit]
Pictures and Videos
[edit]
Pictures
Darwin booting in non-verbose mode.
Darwin crashing in non-verbose mode.
[edit]
Video
This video shows Darwin booting on an Xbox:
- High Quality H.264 (5 MB, needs QuickTime 7 or recent MPlayer/VLC): Mirror 1 (http://www.xbox-linux.org/down/darwin/xbox-darwin-h264.mp4)
- Mid-Quality MPEG-4 (5 MB, needs QuickTime 6 or recent MPlayer/VLC): Mirror 1 (http://www.xbox-linux.org/down/darwin/xbox-darwin.mp4) | Mirror 2 (http://franz.smartxx.com/darwin/xbox-darwin.mp4)
- Low-Quality MPEG (10 MB, plays everywhere!): Mirror 1 (http://franz.smartxx.com/darwin/xbox-darwin_vcd.mpg)
Music: "Magic Disk 04/90" by Thomas Detert (http://www.xample-music.com/) (on the Commodore C64). Thanks to Franz & smartxx.com for the mirror.
[edit]
Kernel Messages
dmesg output (http://www.xbox-linux.org/down/darwin/darwin-dmesg.txt)
[edit]
How to run Darwin
The patches and binaries currently support Darwin 8.0.1 only (this is the base of Mac OS X 10.4.0).
- You need a 128 MB Xbox for this for now!
- Use a PC with at least a Pentium 4 or Athlon 64 CPU (because of SSE2) to install Darwin/x86 8.0.1 on a fresh hard disk (should be at least 2 GB).
- Replace /System/Library/Extensions/IOPCIFamily.kext with the patched version.
- Set up a DHCP and TFTP server to send "bootkernel.elf" to the Xbox's MAC.
- Run Cromwell and choose "Etherboot".
"bootkernel.elf" already includes the patched Darwin kernel, so there is no need to replace "/mach_kernel".
[edit]
Downloads
[edit]
Binaries
- bootkernel.elf.zip (http://www.xbox-linux.org/down/darwin/bootkernel.elf.zip)
- IOPCIFamily.kext.zip (http://www.xbox-linux.org/down/darwin/IOPCIFamily.kext.zip)
[edit]
Patches
- xbox-darwin-patches-0.zip (http://www.xbox-linux.org/down/darwin/xbox-darwin-patches-0.zip)
[edit]
Technical Description of the Port
Here are some notes about what has been done to make Darwin boot on the Xbox.
[edit]
Bootloader
- The Darwin bootloader has three stages: boot0 (MBR), boot1 (bootsector) and boot2. boot2 is the real bootloader, it can decide HFS+ and load and run the kernel and its extensions.
- boot2 requires a BIOS. Instead of rewriting all functions that call the BIOS, a BIOS emulator for certain functions has been implemented instead; this code may be used unmodified for other bootloader ports:
Int 10/AH=00h - VIDEO - SET VIDEO MODE Int 10/AH=01h - VIDEO - SET TEXT-MODE CURSOR SHAPE Int 10/AH=02h - VIDEO - SET CURSOR POSITION Int 10/AH=03h - VIDEO - GET CURSOR POSITION AND SIZE Int 10/AH=06h - VIDEO - SCROLL UP WINDOW Int 10/AH=0Eh - VIDEO - TELETYPE OUTPUT Int 10/AX=4F00h - VESA SuperVGA BIOS (VBE) - GET SuperVGA INFORMATION Int 10/AX=4F01h - VESA SuperVGA BIOS - GET SuperVGA MODE INFORMATION Int 10/AX=4F02h - VESA SuperVGA BIOS - SET SuperVGA VIDEO MODE Int 13/AH=00h - DISK - RESET DISK SYSTEM Int 13/AH=02h - DISK - READ SECTOR(S) INTO MEMORY Int 13/AH=08h - DISK - GET DRIVE PARAMETERS Int 13/AH=41h/BX=55AAh - IBM/MS INT 13 Extensions - INSTALLATION CHECK Int 13/AH=42h - IBM/MS INT 13 Extensions - EXTENDED READ Int 13/AH=48h - IBM/MS INT 13 Extensions - GET DRIVE PARAMETERS Int 13/AX=4B01h - Bootable CD-ROM - GET STATUS Int 15/AX=E820h - Newer BIOSes - GET SYSTEM MEMORY MAP Int 16/AH=00h - KEYBOARD - GET KEYSTROKE Int 16/AH=01h - KEYBOARD - CHECK FOR KEYSTROKE Int 16/AH=02h - KEYBOARD - GET SHIFT FLAGS Int 1A/AH=00h - TIME - GET SYSTEM TIME Int 1A/AX=B101h - PCI BIOS v2.0c+ - INSTALLATION CHECK
- enableA20() in boot2 will hang if there is no keyboard controller. This should be detected! Disabled the function for now.
- bug in the boot2 bootloader: if we are not on EBIOS, the variable phys_nbps never gets set, so Biosread() panics - should be fixed in boot2 some time (but not important for the Xbox)
[edit]
Kernel
- the bootloader defaults to setting up 1024x768x32, which is unavailable on the Xbox, so it would leave the 80x25 text mode set up. "Graphics Mode"="640x480x32" on the kernel command line makes it set up 640x480.
- if APIC is not enabled, xnu panics. Enabled the APIC in bootloader.
- ACPI does not seem to work (missing init in bootloader?), X86PC does. Added "X86PC" to the bootloader.
- x86_lowmem_free() crashes. not investigated, just disabled it in osfmk/i386/AT386/model_dep.c
- PCI enumeration causes Xbox to crash. Implemented blacklist in IOPCIFamily-32/IOPCIBridge.cpp. From now on, booting requires "-f" to ignore the kext cache.
- USB panics ("UIMInitialize error(0)"), because the Xbox boot selector left the USB controller in a bad state. Added USB reset/initialization code to bootloader.
- lots of warnings ("IOPCI2PCIBridge: "bad bridge bus numbering, no room to fix , bailing out!") slow down everything significantly. Initialized PCI to PCI bridge properly by cloning the nForce contents.
- "still waiting for root device" - the bootloader does not seem to pass the boot disk information correctly. Fixed by adding "rd=disk0s1" to the kernel parameters.
- Darwin 8.0.1 is compiled with SSE2, which is unavailable on the Xbox. Many of the executables run from /etc/rc will crash. Single user mode ("-s") at least gets us a prompt. "uname" and "ls" work. :-)
[edit]
Notes
- The build scripts and the startup code have been extended to support being run by Etherboot.
- boot2 loaders the kernel from hard disk through the BIOS, or from network, if the card has its own ROM. This is not the case on the Xbox. Instead of swapping the hard disk every time the kernel was modified, the bootloader has been extended to support running a kernel that is attached to the bootloader and can be transferred to the Xbox through Etherboot.
- The following kernel command line has to be used on the Xbox:
mach_kernel -s -f \"Graphics Mode\"=\"640x480x32\" platform=X86PC rd=disk0s1
- This is hardcoded into boot2 for now, but you could also edit the boot configuration file on hard disk.
- The BIOS emulation code codes not support a keyboard and the time functions seem not to work correctly. Once the bootloader shows the menu, you are stuck.
- Scrolling is BIOS disabled, because it would be *slow*. Reason unknown; in Darwin, it's fast...
- bios.c is licensed under the APSL, or, at your option, under the GPL.
- Thanks to Gé van Geldorp for his ReactOS port, which helped me a lot, to Franz Lehner for Xbox support and some crazy ideas, to Michael Engel for his help with Darwin, and to Wolfgang Zehtner for lending the USB/IDE converter.
- Thanks to Apple for open sourcing their base OS.
- Thanks a lot to the creators of SmartXX for such a fine development tool!

