git: 9front

Download patch

ref: c746948c67d62d01d17f5a22276244c33e71544e
parent: acf68b9ba3e034421729ea0eac0f1dcb6a6867e0
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){
--