Search code examples
operating-systeminterruptcpu-architectureboot

Hardware interrupt when Power Button pressed?


When we first press the power-on button, on the laptop, does a hardware interrupt occur?

I have read at multiple places that: "Once the system receives a "Power Good" signal from the power supply, the CPU will seek instructions from the BIOS about initializing the system" But even before the BIOS instructions getting loaded into the CPU, we have the Bootstrap instructions loaded into the Program counter. So for the memory address to be loaded onto the program counter, there has to be a hardware interrupt at the very start?


Solution

  • When we first press the power-on button, on the laptop, does a hardware interrupt occur?

    No.

    The CPU has to do various things ("built in self-test", determine if it's the "boot CPU" or not, etc), then the firmware has to configure various things (interrupt controller, etc), then something (firmware) has to create a table of interrupt vectors. All of that has to happen before any interrupt is possible.

    So for the memory address to be loaded onto the program counter, there has to be a hardware interrupt at the very start?

    For the main "boot CPU"; after its power-on sequence (self test, etc) the CPU ends up in a well defined default state that was built into the CPU by the manufacturer; which includes a default/initial value for each register (including the instruction pointer). This also means that something (firmware) must exist at the address that was built into the CPU by its manufacturer.

    For other CPUs ("application processors"); after their power-on sequence they just wait until software wakes them up somehow. For 80x86, waking an AP up is done by software sending a sequence of interrupts from another CPU; where (for modern 80x86 CPUs only - Pentium and newer) part of the address to put into the instruction pointer is included in the message sent to the CPU as part of a "startup interrupt" (SIPI); and the rest of the instruction pointer (and all other registers) is still "well defined default state that was built into the CPU by the manufacturer".