[openfirmware] r1634 - cpu/x86/pc/olpc/via

svn at openfirmware.info svn at openfirmware.info
Fri Dec 18 17:34:29 CET 2009


Author: wmb
Date: 2009-12-18 17:34:29 +0100 (Fri, 18 Dec 2009)
New Revision: 1634

Modified:
   cpu/x86/pc/olpc/via/cstate.fth
Log:
OLPC trac 9917 - OFW powers off the machine after 10 seconds with the lid closed.


Modified: cpu/x86/pc/olpc/via/cstate.fth
===================================================================
--- cpu/x86/pc/olpc/via/cstate.fth	2009-12-18 16:26:09 UTC (rev 1633)
+++ cpu/x86/pc/olpc/via/cstate.fth	2009-12-18 16:34:29 UTC (rev 1634)
@@ -28,9 +28,31 @@
    then
 ;
 
+: lid-down?  ( -- flag )  h# 48 acpi-l@ h# 80 and 0=  ;
+false value lid-already-down?
+0 value lid-down-time
+d# 10000 constant lid-shutdown-ms
+
+: ?lid-shutdown  ( -- )
+   lid-down?  if
+      lid-already-down?  if
+         acpi-timer@ lid-down-time -  d# 3580 /  ( ms )
+         lid-shutdown-ms >=  if
+            ." Powering off after 10 seconds of lid down" cr
+            power-off
+         then
+      else
+         acpi-timer@ to lid-down-time
+         true to lid-already-down?
+      then
+   else
+      false to lid-already-down?
+   then
+;
+
 defer do-idle  ' noop to do-idle
 
-: safe-idle  ( -- )  can-idle?  if  do-idle  then  ;
+: safe-idle  ( -- )  can-idle?  if  do-idle  then  ?lid-shutdown  ;
 ' safe-idle to stdin-idle
 
 alias c1-idle halt




More information about the openfirmware mailing list