ref: 57d107f5b1773342db98f17923e5ceb43b14366e
parent: 921529e5bbebed85d5f3972b3d7f3850d42d3330
author: mia soweli <inbox@tachibana-labs.org>
date: Sat May 20 17:56:51 EDT 2023
aux/acpi: attempt to call _PTS and _TTS before shutdown The ACPI specification requires us to call _PTS (prepare to sleep) and _TTS (transition to state) before we write to PM1a_CNT_BLK and PM1b_CNT_BLK.
--- a/sys/src/cmd/aux/acpi.c
+++ b/sys/src/cmd/aux/acpi.c
@@ -256,6 +256,7 @@
poweroff(void)
{
int n;
+ void *tts, *pts;
if(facp == 0){
werrstr("no FACP");
@@ -263,6 +264,16 @@
}
wirecpu0();
+
+ /* The ACPI spec requires we call _TTS and _PTS to prepare
+ * the system to go to _S5 state. If they fail, too bad,
+ * try to go to _S5 state anyway. */
+ pts = amlval(amlwalk(amlroot, "_PTS"));
+ tts = amlval(amlwalk(amlroot, "_TTS"));
+ if(pts)
+ amleval(pts, "i", 5, nil);
+ if(tts)
+ amleval(tts, "i", 5, nil);
/* disable GPEs */
for(n = 0; GPE0_BLK > 0 && n < GPE0_BLK_LEN/2; n += 2){