News for hackers. Stuff that matters.
Re:Apple M1 Assembly Language Hello World by SulfurHexaFluri on Friday January 15, 2021 @12:04AM (#25787201)
How do you actually load / run this code without an OS? I'm guessing its the same way something like grub gets run?
Re:Apple M1 Assembly Language Hello World by garaetjjte on Friday January 15, 2021 @08:10AM (#25790526)
It'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
Re:Apple M1 Assembly Language Hello World by moonchild on Friday January 15, 2021 @03:19AM (#25788310)
I 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).

Re:Apple M1 Assembly Language Hello World by alexjm on Friday January 15, 2021 @11:28AM (#25792612)
The 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-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.)

Re:Apple M1 Assembly Language Hello World by CameronNemo on Friday January 15, 2021 @04:34AM (#25788799)
On 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.