From OSDev Wiki
Jump to: navigation, search

In order to shutdown the computer, you need to use some sort of power management. Either APM or ACPI.



This is the basic sequence of APM commands that must be given in order to shut down a computer. For details on exactly how to implement these steps, see the APM article.

  • Perform an installation check.
  • Disconnect any existing APM interface.
  • Connect the Real Mode interface.
  • Enable power management for all devices.
  • Set the power state for all devices to "Off" (03h).


ACPI Shutdown code with good explanation in C

A summary of ACPI shutdown from the above forum post:

The ACPI shutdown is technically a really simple thing all that is needed is a outw(PM1a_CNT, SLP_TYPa | SLP_EN ); and the computer is powered off. The problem lies in the gathering of these values especialy since the SLP_TYPa is in the \_S5 object which is in the DSDT and therefore AML encoded.

Emulator-specific methods

In some cases (such as testing), you may want a poweroff method, but not need it to work on real hardware.

In Bochs, and older versions of QEMU, you can do the following:

for (const char *s = "Shutdown"; *s; ++s) {
  outb(0x8900, *s);

In newer versions of QEMU, you can pass -device isa-debug-exit,iobase=0xf4,iosize=0x04 on the command-line, and do:

outb(0xf4, 0x00);

See Also


Personal tools