• Port Colinux to OSX (Leopard 10.5) for Intel only CPUs


  • Because it's possible
  • Educational purpose
  • I want to run a postfix mailserver in Linux, but I also want to use Windows or OSX and use my favourite mail program.


  • We have a "virtual" qemu/kvm OSX installation running [1]
  • XCode works
  • We found out how to write a Kext that can access the CR0 and CR3 register
Jul 19 20:56:46 Mac kernel[0]: hello world
Jul 19 20:56:46 Mac kernel[0]: cr0: 8001003b
  • A device handler works
emumac:~ monsti$ ls -la /dev/colinux
crw-------  1 root  wheel   18,   0 Jul 21 19:08 /dev/colinux
  • We can now compile the kernel part. However the darwin kernel functions are 99% dummy. But here that's what you can see on the OSX syslog:
colinux: loaded version 0.8.0 (compiled on Aug  5 2008 18:54:38)
colinux: manager load failure: ffe04c01
  • Implemented:
alloc.c - 50% partial (userspace map/unmap unfinished)
conet.c - 100% dummy 
debug.c -100%  dummy as in linux
file.c - 0% dummy
fs.c - 100% dummy as in linux
manager.c - 50% a /dev/colinux is created but there is no implementation of the functions
misc.c - 50% co_os_virt_to_phys() is missing and no idea how to implement
mutex.c - 100% but unsure if this works - maybe we need some init() / refcounter for creating only one "group" 
pagec.c - 0% no idea how to implement
scsi.c - 100% dummy as in linux
time.c - 100% maybe some tuning is required
timer.c - 50%  implement co_os_timer_create - OSX has about 20 Time functions :)
user.c - 0% no idea how to implement
wait.c - 100% needs some tuning

OSX is so funny :) The mutex concept is so full feature blown. Also the Apple documentation is somehow buggy for WAIT/SLEEP in the kernel. The wait queues aren't available from the Kext as this Apple document claims [[2]] (Wait Queues and Wait Primitives). It took some time to find out that the msleep()/wakeup() is what we need.

  • Next step: implement more!

I want to help[]

Usefull Links[]

  • Qemu/KVM [3]
  • Apples opensource darwin sources [4]
  • Sample source for a driver written with the IOKit (using a IOService - so we run in Kernel space). The driver also creates a device in /dev. [5]