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_offinkernel/reboot.cand 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_dumphandler. The last thingkernel_power_offdoes before invoking the platform-specific power-off code is to executekmsg_dump(KMSG_DUMP_POWEROFF);. (Just ignore anykmsg_dumpcalls other than that one.)