AnotherOS

Documentation

ACPI

Batteries, the lid, the power button, screen brightness — and why running firmware code is unavoidable.

Firmware describes a PC in ACPI tables, and most of what matters in them is not data but code: methods the operating system is expected to run.

A laptop's battery charge is whatever its battery method returns. A 12" MacBook's keyboard is switched onto its SPI bus by a firmware method. A hot-plugged PCI card is announced by a firmware event handler. Reading the tables is easy; running them needs an interpreter.

AnotherOS uses ACPICA, the same interpreter Linux runs. It is vendored unchanged, and everything AnotherOS-specific sits beside it rather than inside it, so it can be updated wholesale.

What happens at boot

In the same order Linux uses: the tables are handed to the interpreter, the platform is switched into ACPI mode, the OS-identity answers are set, the firmware's namespace is loaded, events and the ACPI interrupt are enabled, initialisation methods run, the firmware is told how this kernel routes interrupts, and every general-purpose event that has a handler is enabled.

The boot log ends the sequence with one line naming what was found — how many methods, devices, regions and processors are in the namespace, which interrupt the ACPI events arrive on, and whether the Darwin identity is in force.

It also cross-checks the sleep states against an older, independent byte scanner, and prints whether the two agree. A disagreement is a finding about one of them, and is reported rather than resolved silently.

What the firmware is told

Exactly what Linux tells it. Every Windows version answers true, Linux answers false, and the feature groups Linux adds answer true.

On Apple hardware — decided the way Linux decides it, from the system vendor — the Windows answers are withdrawn and Darwin answers true instead. That matters concretely: Apple firmware only publishes the 12" MacBook's SPI keyboard settings on the Darwin branch, so without this the keyboard does not exist.

Boot options

Option Effect
noacpiec The interpreter runs, but its Embedded Controller driver does not.
noacpica The recovery switch. The interpreter does not start; everything that existed before it runs exactly as before.
acpi=off Linux's spelling: no interpreter, and ACPI suspend and power-off are off too. The processor table for SMP is still read.
acpi_osi= Linux's identity override, with Linux's syntax.
acpi_mask_gpe=N Never enable event N — the escape hatch for an event storm.

Batteries, the adapter and the lid

The Embedded Controller is where a laptop keeps this information, and the firmware's own code reads it out. The EC also reports its own events. Both work through the interpreter.

Control-method batteries — a laptop whose battery is described only by firmware methods rather than by a hardware interface — appear under /sys/class/power_supply exactly as Linux presents them.

The AC adapter and the lid come from ACPI wherever there is no Apple SMC to ask instead.

Screen brightness

Laptops whose firmware describes brightness control for the built-in display get an ACPI backlight under /sys/class/backlight, chosen and set up the way Linux does it — including Linux's list of machines whose firmware method is known to be broken.

On Intel graphics the firmware only passes the request on to the graphics driver, so the kernel answers it and sets the panel itself.

The power button

A short press shuts the machine down in order. The kernel reports the key like any keyboard's power key and asks init for a power-off — the same request the poweroff command makes — so every program is told to exit, the disks are synced, and only then does the machine switch itself off.

Both kinds of button firmware uses are handled: the chipset's fixed button, and a button described as an ACPI device.

The sleep button reports itself but does not suspend yet.

If init cannot handle the request — booting straight to a shell, for example — the press is reported and nothing is shut down, rather than the machine dying mid-write. A four-second hold still forces it off in hardware, as always.

What is not done yet

Suspend and power-off entry still go through the older code path. The interpreter cross-checks their values but does not yet perform the transition.