What firmware/hardware mechanism enables force-shutdown?

Is the universal force-shutdown mechanism built in at a hardware or firmware level?

Both the motherboard (hardware) and the BIOS (firmware) are involved in the process.

The actual switching of the power (on and off) is done by circuits on the motherboard. The circuits are triggered to change state by a momentary short circuit of two points in the circuit. That is done by the front panel push button. A short-term connection of that button is enough. The motherboard circuit also has a second and third function it can do.

The BIOS usually is set so that, if the circuit is already on the ON state and the momentary contact is kept closed for at least 4 seconds, one of two actions will be carried out. Either the system will shut down right away (like turning off a switch), or the motherboard will enter the "sleep" state and wait to be re-awakened. Which of these two options is done is something you set in the BIOS Setup screens.**

This is the reason that the motherboard is never entirely "Off" in most operating situations. Even when it is "Off", there is a small portion of it devoted to checking for inputs from a few sources (like the front push button, some USB devices and maybe a modem) so that it can respond by turning power on to the entire system. The way to really shut down all power is either to pull out the power cord, or to use the physical switch mounted on the back of the PSU to switch it off.

Source How (does the) power button work?


The modern switches don't contain any magic. In fact, they are less complicated and expensive than real physical on/off switches.

These switches are just inputs to a micro-controller. The micro controller can tell when you push the button, and the rest is policy encoded in the firmware to decide what to do about it. The power is usually switched with transistors. This means the button itself doesn't have to handle high voltage or high current, so there are a lot more options to make it and for it to be small. It could be a membrane switch, for example, which you'd never use to switch wall power.

This does mean that a little bit of the device is usually on, at least enough to power the micro-controller. However, modern micro-controllers can take such tiny amounts of power when doing nothing but waiting for a switch signal that this power is irrelevant in most cases.

In some cases, the button actually causes the micro to get powered up when pressed, which then turns on some transistors or a relay or something to keep the power on. When you press the button to turn the device off, the micro shuts down everything, including itself.

Source How do these modern power buttons on devices work answer by Olin Lathrop


Is the universal (I assume) force-shutdown mechanism built in at a hardware or firmware level?

Without looking for references, there is a pretty simple logic here: they must work on the hardware level because they work with no CPU in the socket.

Sure, the PC won't do all that much then, but you can still technically power it on; if your mainboard has the capability to give you messages (by beeps or a small 2-digit code) you will probably get the "bad CPU / no CPU" code. You also will be able to power it off with a long-press, which is the important part here.

Also, keep in mind that in all cases where the system is in a deeply non-sane state (i.e., in single-user mode / linux kernel panic / BSOD etc.) and for all intents and purposes at a dead end, the power button still works (at least the long-press).

Note that "hardware level" is a pretty broad term already; i.e., there could easily be anything from a few transistors up to a small dedicated µC with a few bits of NVRAM around (which would keep the values configured by the BIOS, for example on the behaviour of the short-press), which most people would still call "hardware".