4 ms·
How do you actually load / run this code without an OS? I'm guessing its the same way something like grub gets run?
by SulfurHexaFluri 6y ago
How do you actually load / run this code without an OS? I'm guessing its the same way something like grub gets run?
- deleted 6y ago[deleted]
- moonchild 6y agoI don't know how it works on apple hardware—though I heard they used a UEFI variant with HFS+ at one point—but in general, on PCs, there are two ways to get bootcode to run. The first is legacy BIOS: the BIOS will load the first 512 bytes of the boot sector, called the Master Boot Record (MBR) into memory location 0x7C00; they are then responsible for bootstrapping the rest of the system. Usually by doing the bare minimum to load a second-stage bootloader off the disc, and letting the second-stage bootloader do the rest of the work, since 512 bytes (actually only ~440) is really not very much. The second is UEFI. The firmware will load a PE-formatted executable from a .efi-suffixed file on a FAT32 partition which has the EFI System Partition (ESP) flag set. Since this PE file can be any size, a second-stage bootloader is not generally necessary (but may be interesting for aesthetic reasons e.g. if you don't like PE).
- alexjm 6y agoThe process for Apple hardware to find and start EFI is described in the "Booting from an Apple File System Partition" section on page 22 of this document. Basically, the EFI image is read from a special block on disk. https://developer.apple.com/support/downloads/Apple-File-System-Reference.pdf https://developer.apple.com/support/downloads/Apple-File-Sys... The boot process for HFS+ is more involved, because you have to actually read the HFS+ file system to locate the EFI image, since it's stored in a regular file. I'm not sure what happens after jumping into the EFI code. (Disclaimer: I worked on the linked document.)
- CameronNemo 6y agoOn Rockchip boards, there is a bootrom that looks for data at a specific offset on a few storage devices, then calls the first one it finds. From there open source / flashable firmware initializes RAM, scales up CPU frequencies, and starts looking for a kernel or whatever. TL;DR likely read only firmware, possibly more low level than a BIOS, UEFI, or Coreboot implementation would be. Edit: then again, they could be shipping a full EFI implementation like they do on their x86 offerings.
- garaetjjte 6y agoIt's linked into Mach-O binary that is loaded by iBoot bootloader. It is explained in detail there: https://www.youtube.com/watch?v=d5s9fYfvzmY&t=12260 https://www.youtube.com/watch?v=d5s9fYfvzmY&t=12260