     { DefaultLowLatencyWake SYSTEM_POWER_STATE } ;
 TYPEDEF: SYSTEM_POWER_CAPABILITIES* PSYSTEM_POWER_CAPABILITIES
 
+ENUM: POWER_ACTION
+  PowerActionNone
+  PowerActionReserved
+  PowerActionSleep
+  PowerActionHibernate
+  PowerActionShutdown
+  PowerActionShutdownReset
+  PowerActionShutdownOff
+  PowerActionWarmEject
+  PowerActionDisplayOff ;
+TYPEDEF: POWER_ACTION* PPOWER_ACTION
+
+STRUCT: POWER_ACTION_POLICY
+    { Action POWER_ACTION }
+    { Flags DWORD }
+    { EventCode DWORD } ;
+TYPEDEF: POWER_ACTION_POLICY* PPOWER_ACTION_POLICY
+
+CONSTANT: DISCHARGE_POLICY_CRITICAL 0
+CONSTANT: DISCHARGE_POLICY_LOW 1
+CONSTANT: NUM_DISCHARGE_POLICIES 4
+
+STRUCT: SYSTEM_POWER_LEVEL
+    { Enable BOOLEAN }
+    { Spare BYTE[3] }
+    { BatteryLevel DWORD }
+    { PowerPolicy POWER_ACTION_POLICY }
+    { MinSystemState SYSTEM_POWER_STATE } ;
+TYPEDEF: SYSTEM_POWER_LEVEL* PSYSTEM_POWER_LEVEL
+
+STRUCT: SYSTEM_POWER_POLICY
+    { Revision DWORD }
+    { PowerButton POWER_ACTION_POLICY }
+    { SleepButton POWER_ACTION_POLICY }
+    { LidClose POWER_ACTION_POLICY }
+    { LidOpenWake SYSTEM_POWER_STATE }
+    { Reserved DWORD }
+    { Idle POWER_ACTION_POLICY }
+    { IdleTimeout DWORD }
+    { IdleSensitivity BYTE }
+    { DynamicThrottle BYTE }
+    { Spare2 BYTE[2] }
+    { MinSleep SYSTEM_POWER_STATE }
+    { MaxSleep SYSTEM_POWER_STATE }
+    { ReducedLatencySleep SYSTEM_POWER_STATE }
+    { WinLogonFlags DWORD }
+    { Spare3 DWORD }
+    { DozeS4Timeout DWORD }
+    { BroadcastCapacityResolution DWORD }
+    { DischargePolicy SYSTEM_POWER_LEVEL[NUM_DISCHARGE_POLICIES] }
+    { VideoTimeout DWORD }
+    { VideoDimDisplay BOOLEAN }
+    { VideoReserved DWORD[3] }
+    { SpindownTimeout DWORD }
+    { OptimizeForPower BOOLEAN }
+    { FanThrottleTolerance BYTE }
+    { ForcedThrottle BYTE }
+    { MinThrottle BYTE }
+    { OverThrottled POWER_ACTION_POLICY } ;
+TYPEDEF: SYSTEM_POWER_POLICY* PSYSTEM_POWER_POLICY
+
+
 STRUCT: SYSTEM_BATTERY_STATE
     { AcOnLine BOOLEAN }
     { BatteryPresent BOOLEAN }

    HPOWERNOTIFY RegistrationHandle
)

: get-processor-power-information ( -- structs )
    ProcessorInformation
    f 0
    cpus <PROCESSOR_POWER_INFORMATION-array>
    PROCESSOR_POWER_INFORMATION heap-size cpus *
    [
        CallNtPowerInformation win32-error=0/f
    ] keepd ;

: get-power-capabilities ( -- struct )
    SYSTEM_POWER_CAPABILITIES <struct>
    [ GetPwrCapabilities win32-error=0/f ] keep ;

! Copyright (C) 2021 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.c-types alien.data alien.syntax classes.struct kernel math
specialized-arrays system-info windows.errors windows.types
windows.user32 ;
IN: windows.powrprof
