I am writing some software to shutdown some external hardware wired into my control board. The catch is that I need to wait for the VERY end of the poweroff operation to send the signal (through a gpio output). I am weighing some options right now, but I am curious as to where I can see what the kernel actually does right before poweroff.
Is there a file somewhere that I can look into?
Start at the function kernel_power_off
in kernel/reboot.c
and follow the code. The final power-off operations are very platform specific, so if you want to follow down to the bitter end, you'd need to figure out exactly which bits of arch-specific code you're using.
One simpler possibility for sending your signals is to register a kmsg_dump
handler. The last thing kernel_power_off
does before invoking the platform-specific power-off code is to execute kmsg_dump(KMSG_DUMP_POWEROFF);
. (Just ignore any kmsg_dump
calls other than that one.)