byuu's homepage

Apple Mac OS X 10.5.2


I've never been a fan of Apple. A company with less customer friendly practices than Microsoft, that charges unbelievable premiums for underpowered hardware, that does things its own way -- customers' opinions be damned, and yet somehow manages to gain the fervent adoration of countless individuals.

Combine this with my past experiences with OS X 10.3, and I'd have been more happy to never see a Mac again. Unfortunately, part of being a software developer is catering to the widest audience possible. This means using operating systems we don't care for, simply for the sake of porting software.

Hardware

OS X is a special case. It's the only x86-based operating system I'm aware of that will not allow you to install it on ordinary IBM-compatible PC hardware. Instead, Apple expects you to purchase their hardware to run the OS. At the time of this writing, the cheapest model available is the Mac Mini, retailing for $599. Ouch. And what does this get you?

• 1.83GHz Core 2 Duo
• 1GB DDR2-667 RAM
• Intel GMA 950 graphics
• Intel HD audio
• 80GB SATA HDD
• DVD-ROM / CD-RW drive

Keep in mind that the base Mac Mini does not come with a monitor, keyboard or mouse. Let's see what a comparable system would cost if built from scratch ...

• 1.80GHz Pentium E2160 (rebranded Core 2 Duo Conroe) -> $60
• 1GB Kingston ValueRAM DDR2-667-> $25
• Gigabyte GA-945GCM-S2C -> $55
• Western Digital 80GB SATA HDD -> $40
• Samsung DVD-RW / CD-RW drive -> $30
• Generic case w/PSU -> $25
Grand total: $275

... not even half the cost. Given the custom system will have a significantly larger case, but for an extra $50 you could instead buy the stylish Antec Minuet. And on the plus side, it's possible to upgrade all components of the custom system.

The situation was even worse for me. I had most of the above parts lying around from older system parts. The custom system above, with the Minuet case, cost me less than $200 to put together. Throw in a retail copy of OS X 10.5.2 Leopard for $110, and things were looking very affordable.

Quite frankly, there was no way in hell I was paying an extra ~$300 for an Apple logo on my case.

So I decided to give it a go ... worst case, I'd have a very stylish Xubuntu box.


The assembled system.

Software installation

Installation was a breeze, resultint in a fully working system with only a single flaw: restart did not work.

There did exist a patched kernel which fixed restart, but it was too heavily modified for my taste. I was otherwise able to run the official, unmodified kernel; yet this kernel was patched to run on AMD and SSE2 hardware.

Working off a restart patch from the 10.4.4 kernel, and examining disassemblies of the 10.5.2 kernel, I was able to patch the new kernel myself with the code below:

;restart patch for Mac OS X 10.5.2 (vanilla mach_kernel 9.2.2)
;author: byuu
;license: public domain
;date: 2008-04-28
;assemble with "yasm -f bin restart.asm -o restart.bin"

bits 32

%define base 0x09d80e
%define relative(n) n - (base + $ - zero)

zero:
  push ebp
  mov  ebp,esp
  sub  esp,24

  mov  eax,[ebp+8]
  test eax,eax
  je  .shutdown

.restart
  mov  dword[esp],0x4621f4
  call relative(0x0232f8)
; mov  dword[esp],1
  xor  eax,eax
  inc  eax
  mov  [esp],eax
  call relative(0x32066a)
; jmp .hang
  mov  al,0xfe
  out  0x64,al
  hlt

.shutdown
  mov  dword[esp],0x462204
  call relative(0x0232f8)
; mov  dword[esp],0
  xor  eax,eax
  mov  [esp],eax
  call relative(0x32066a)

.hang
  jmp .hang

;original:
;offset  hex
;09d80e  55 89 e5 83 ec 18 8b 45 08 85 c0 74 1a c7 04 24
;09d81e  f4 21 46 00 e8 d1 5a f8 ff c7 04 24 01 00 00 00
;09d82e  e8 37 2e 28 00 eb 18 c7 04 24 04 22 46 00 e8 b7
;09d83e  5a f8 ff c7 04 24 00 00 00 00 e8 1d 2e 28 00 eb
;09d84e  fe

;modified:
;offset  hex
;09d80e  55 89 e5 83 ec 18 8b 45 08 85 c0 74 1c c7 04 24
;09d81e  f4 21 46 00 e8 d1 5a f8 ff 31 c0 40 89 04 24 e8
;09d82e  38 2e 28 00 b0 fe e6 64 f4 c7 04 24 04 22 46 00
;09d83e  e8 b5 5a f8 ff 31 c0 89 04 24 e8 1d 2e 28 00 eb
;09d84e  fe

Save the patched kernel to /byuukernel, update /Library/Preferences/SystemConfiguration/com.apple.Boot.plist to point to it, and restart shut down. Problem solved, both restart and shutdown now work properly. Even sleep seems to work great. I guess this makes me a kernel hacker now, too. Great, I'll be sure to add that one to the old resume.


The completed system, running OS X 10.5.2 (desktop screenshot).

Ignore the pillowcase. It makes it easy to turn the monitor without scratching the nice Minuet case. Oh, and the 19" LCD monitor was $99. A TN panel, but I hear the ~$600 20" Apple Cinema panels are TN now, too.

Performance of the system is great. I can easily run even older PowerPC-only applications. Very impressive, that should make working with the PPC port of libco much easier in the future.

Overall impressions

Compared to older versions of OS X, I'm very much impressed with Leopard. The GUI inconsistencies have mostly been eliminated (goodbye, brushed metal), more configuration options have been added (though still far too few), and I must admit that the dock on the right-hand side of the screen is very attractive.

I still resent how different OS X has to be from every other operating system, but when you accept them as differences and not flaws, the system really isn't bad at all. It's really just a different way of doing things. To be quite honest, I could see myself using this OS day to day. It's at least an order of magnitude more usable than Windows Vista.

I'm happy that this system build was a success. I don't intend to immediately begin porting my applications to OS X, but it's now a possibility, at least.

It's really too bad Apple is so spiteful toward their potential customers. The biggest problem I see with OS X is the lack of software available, and what is available is almost entirely composed of shareware. How many developers would go as far as I have just to port software to their OS?