This question is motivated by curiosity, and because I've been unable to find a clear answer on my own.
I have read this answer explaining how the kernel shuts down the system. Overall, it seems clear to me. Reviewing the code for reboot.c in LXR, the kernel_power_off function in reboot.c piqued my curiosity. Unfortunately, LXR seems to stumble when locating the machine-dependent code for machine_power_off, and it's not clear to me what this function does, or how it does it.
QUESTION: Is the function definition for machine_power_off typically based on some binary blob (proprietary firmware perhaps?) unique to a specific class of machines - or a manufacturer - or is it typically written in Assembler or even C?
Now fast-forward from the April 2014 to July 2021 - the present. The April 2014 answer made sense to me, but there have been many changes since this answer was prepared: Numerous revisions to the kernel, and systemd has become a default part of many/most Linux distros.
It's my understanding that halt/shutdown is now handled by the systemd login manager(?!): systemd-logind.service. Reviewing man logind.conf and man systemd-logind.service reveals the HandlePowerKey=, HandleLidSwitchExternalPower= options, and the associated poweroff action - these option names suggest similarities with reboot.c, but things are clearly different. Looking further upstream at implementation suggested the D-Bus interface of systemd-logind plays a significant role in system shutdown now. At this point, I'm struggling to "connect the dots" between reboot.c and systemd-logind.service.
In the meantime, my distro seemingly has retained the reboot.c code. Assuming that the code is being maintained only because it's still used on my systemd-based OS leads me to my other question:
QUESTION: Do systemd-based options for powering off a system ultimately end by executing reboot.c? If not, what is the role of reboot.c?