[NTOSKRNL]
authorCameron Gutman <aicommander@gmail.com>
Fri, 20 Aug 2010 02:27:05 +0000 (02:27 +0000)
committerCameron Gutman <aicommander@gmail.com>
Fri, 20 Aug 2010 02:27:05 +0000 (02:27 +0000)
- Shutdown the system if we receive a SYS_BUTTON_POWER event
- Register for GUID_DEVICE_LID arrival events so we can receive lid events

svn path=/trunk/; revision=48572

reactos/ntoskrnl/include/internal/po.h
reactos/ntoskrnl/po/events.c
reactos/ntoskrnl/po/power.c

index 01ddf3b..ef4ee1a 100644 (file)
@@ -6,6 +6,7 @@
 * PROGRAMMERS:     Alex Ionescu (alex.ionescu@reactos.org)
 */
 
 * PROGRAMMERS:     Alex Ionescu (alex.ionescu@reactos.org)
 */
 
+#include "initguid.h"
 #include <poclass.h>
 
 //
 #include <poclass.h>
 
 //
index 8417f27..efbcc10 100644 (file)
@@ -79,6 +79,15 @@ PopGetSysButtonCompletion(
                if (SysButton & SYS_BUTTON_LID) DbgPrint(" LID");
                if (SysButton == 0) DbgPrint(" WAKE");
                DbgPrint(" )\n");
                if (SysButton & SYS_BUTTON_LID) DbgPrint(" LID");
                if (SysButton == 0) DbgPrint(" WAKE");
                DbgPrint(" )\n");
+        
+        if (SysButton & SYS_BUTTON_POWER)
+        {
+            /* FIXME: Read registry for the action we should perform here */
+            DPRINT1("Initiating shutdown after power button event\n");
+            
+            ZwShutdownSystem(ShutdownNoReboot);
+        }
+            
        }
 
        /* Allocate a new workitem to send the next IOCTL_GET_SYS_BUTTON_EVENT */
        }
 
        /* Allocate a new workitem to send the next IOCTL_GET_SYS_BUTTON_EVENT */
index e8d37b8..d745d76 100644 (file)
@@ -136,7 +136,7 @@ PoInitSystem(IN ULONG BootPhase)
     /* Check if this is phase 1 init */
     if (BootPhase == 1)
     {
     /* Check if this is phase 1 init */
     if (BootPhase == 1)
     {
-        /* Registry power button notification */
+        /* Register power button notification */
         IoRegisterPlugPlayNotification(EventCategoryDeviceInterfaceChange,
                                        PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES,
                                        (PVOID)&GUID_DEVICE_SYS_BUTTON,
         IoRegisterPlugPlayNotification(EventCategoryDeviceInterfaceChange,
                                        PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES,
                                        (PVOID)&GUID_DEVICE_SYS_BUTTON,
@@ -145,6 +145,16 @@ PoInitSystem(IN ULONG BootPhase)
                                        PopAddRemoveSysCapsCallback,
                                        NULL,
                                        &NotificationEntry);
                                        PopAddRemoveSysCapsCallback,
                                        NULL,
                                        &NotificationEntry);
+        
+        /* Register lid notification */
+        IoRegisterPlugPlayNotification(EventCategoryDeviceInterfaceChange,
+                                       PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES,
+                                       (PVOID)&GUID_DEVICE_LID,
+                                       IopRootDeviceNode->
+                                       PhysicalDeviceObject->DriverObject,
+                                       PopAddRemoveSysCapsCallback,
+                                       NULL,
+                                       &NotificationEntry);
         return TRUE;
     }
 
         return TRUE;
     }