Search code examples
macosassemblybootloaderuefi

How to write a custom bootloader for mac systems?


I wrote a little bootloader in assembly and it uses BIOS interrupts and it works great on my pc. My question is, is there any possibility to make it work on Mac / Apple systems. I know that Apple doesn't use BIOS in that sense and that they are locking lot of things down. However it is possible to use a live ubuntu stick on mac, so might it be possible to run an assembly program from startup on a mac? If yes, do you know any starting points or references of what has been done before?

Thanks a lot!


Solution

  • My question is, is there any possibility to make it work on Mac / Apple systems.

    There's always a possibility. For example, it's possible that someone might port a system emulator (e.g. Bochs, Qemu) to UEFI (so that it looks like a UEFI application) that's capable of emulating a completely different computer that does have BIOS.

    In practice, you'll need to write at a new boot loader for UEFI.

    Note that you should also assume that UEFI is the first step in a "legacy baggage removal" scheme (and assume that Intel's "no BIOS after 2020, not even just a compatibility module" statement was made because Intel are planning to rip "legacy baggage" out of chipsets, etc; which would prevent firmware written by other people from continuing to support BIOS). For one simple example (that already exists); Apple machines don't have a PS/2 keyboard controller chip and don't have "legacy PS/2 emulation for USB devices" support, and attempting to access the PS/2 keyboard controller chip can cause the computer to lock up.

    Mostly; there are a whole pile of assumptions (e.g. about the memory map, and the existence of things like A20 gate, PIC chips, PIT chip, PS/2 keyboard controller, "BIOS compatible" video card ROM, VGA hardware registers, etc) that are either not true for UEFI or not future-proof for UEFI. For this reason you should also audit the OS that the boot loader boots, to identify and eradicate all of the (potentially false) "legacy assumptions" (otherwise, even if you've got a perfectly good boot loader designed for UEFI, the OS will probably fail soon after boot).