Shutdown: Difference between revisions

1,037 bytes added ,  29 days ago
m
Bot: Replace deprecated source tag with syntaxhighlight
[unchecked revision][unchecked revision]
m (Bot: Replace deprecated source tag with syntaxhighlight)
 
(9 intermediate revisions by 4 users not shown)
Line 5:
 
* Perform an installation check.
* Check if the APM version is '''at least''' 1.1
* Disconnect any existing APM interface.
* Connect the Real Mode interface.
* Tell the APM that your driver supports version 1.1
* Enable power management for all devices.
* Set the power state for all devices to "Off" (03h).
 
If the APM version is 1.0 (or the APM isn't told that your code supports version 1.1, so it will run as 1.0 for legacy purposes) it isn't possible to set the power state for all devices (maybe it's possible to shut each device down individually)
 
== ACPI ==
Line 17 ⟶ 21:
The ACPI shutdown is technically a really simple thing all that is needed is a <code>outw(PM1a_CNT, SLP_TYPa | SLP_EN );</code> and the computer is powered off. The problem lies in the gathering of these values especialy since the <code>SLP_TYPa</code> is in the <code>\_S5</code> object which is in the <code>DSDT</code> and therefore AML encoded.
</blockquote>
 
'''Warning:''' the code above shouldn't be used in production. There are many things the author skips, like calling the _PTS method. A real AML interpreter is required for that, like for example, ACPICA.
 
On many hardware calling _PTS is required and failing to call it will cause shutdown to fail, or cause hw to freeze in some half-shutdown phase. This phenomenon mostly occurs on laptops, but also occurs on desktops.
 
== Emulator-specific methods ==
Line 24 ⟶ 32:
In Bochs, and older versions of QEMU(than 2.0), you can do the following:
 
<sourcesyntaxhighlight lang="c">
outw (0xB004, 0x2000);
</syntaxhighlight>
</source>
 
In newer versions of QEMU, you can do shutdown with:
 
<syntaxhighlight lang="c">
outw(0x604, 0x2000);
</syntaxhighlight>
 
In Virtualbox, you can do shutdown with:
 
<syntaxhighlight lang="c">
outw(0x4004, 0x3400);
</syntaxhighlight>
 
In newerCloud versions of QEMUHypervisor, you can do shutdown with:
 
<sourcesyntaxhighlight lang="c">
outw(0x6040x600,0x2000 0x34);
</syntaxhighlight>
</source>
 
== See Also ==