mirror of
https://github.com/reactos/reactos.git
synced 2024-07-01 10:20:03 +00:00
Start to support GUID_DEVICE_SYS_BUTTON interface. It is required to handle keyboards with power buttons (wake/sleep/power)
(This commit is done now to be able to debug an APC problem) svn path=/trunk/; revision=24082
This commit is contained in:
parent
fec5904b50
commit
2140d54ca5
|
@ -6,6 +6,8 @@
|
|||
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
|
||||
*/
|
||||
|
||||
#include <poclass.h>
|
||||
|
||||
//
|
||||
// Define this if you want debugging support
|
||||
//
|
||||
|
@ -61,6 +63,13 @@ PopCleanupPowerState(
|
|||
IN PPOWER_STATE PowerState
|
||||
);
|
||||
|
||||
NTSTATUS
|
||||
CALLBACK
|
||||
PopAddRemoveSysCapsCallback(
|
||||
IN PVOID NotificationStructure,
|
||||
IN PVOID Context
|
||||
);
|
||||
|
||||
//
|
||||
// Global data inside the Power Manager
|
||||
//
|
||||
|
|
|
@ -32,15 +32,15 @@
|
|||
<file>abios.c</file>
|
||||
<file>cpu.c</file>
|
||||
<file>ctxswitch.S</file>
|
||||
<file>clock.S</file>
|
||||
<file>clock.S</file>
|
||||
<file>exp.c</file>
|
||||
<!-- <file>irq.c</file> -->
|
||||
<!-- <file>irq.c</file> -->
|
||||
<file>kiinit.c</file>
|
||||
<file>ldt.c</file>
|
||||
<file>thread.c</file>
|
||||
<file>trap.s</file>
|
||||
<file>usercall_asm.S</file>
|
||||
<file>userapc.c</file>
|
||||
<file>userapc.c</file>
|
||||
<file>v86vdm.c</file>
|
||||
<file>v86m_sup.S</file>
|
||||
</directory>
|
||||
|
@ -70,10 +70,10 @@
|
|||
<file>usercall.c</file>
|
||||
<file>wait.c</file>
|
||||
</directory>
|
||||
<directory name="deprecated">
|
||||
<file>irqhand.S</file>
|
||||
<file>irq.c</file>
|
||||
</directory>
|
||||
<directory name="deprecated">
|
||||
<file>irqhand.S</file>
|
||||
<file>irq.c</file>
|
||||
</directory>
|
||||
<directory name="cc">
|
||||
<file>cacheman.c</file>
|
||||
<file>copy.c</file>
|
||||
|
@ -129,7 +129,7 @@
|
|||
<file>callback.c</file>
|
||||
<file>dbgctrl.c</file>
|
||||
<file>error.c</file>
|
||||
<file>efi.c</file>
|
||||
<file>efi.c</file>
|
||||
<file>event.c</file>
|
||||
<file>evtpair.c</file>
|
||||
<file>fmutex.c</file>
|
||||
|
@ -170,7 +170,7 @@
|
|||
<file>inbv.c</file>
|
||||
</directory>
|
||||
<directory name="io">
|
||||
<directory name="iomgr">
|
||||
<directory name="iomgr">
|
||||
<file>adapter.c</file>
|
||||
<file>arcname.c</file>
|
||||
<file>bootlog.c</file>
|
||||
|
@ -182,31 +182,31 @@
|
|||
<file>drvrlist.c</file>
|
||||
<file>error.c</file>
|
||||
<file>event.c</file>
|
||||
<file>file.c</file>
|
||||
<file>iocomp.c</file>
|
||||
<file>iofunc.c</file>
|
||||
<file>iomgr.c</file>
|
||||
<file>iowork.c</file>
|
||||
<file>irp.c</file>
|
||||
<file>irq.c</file>
|
||||
<file>mdl.c</file>
|
||||
<file>rawfs.c</file>
|
||||
<file>remlock.c</file>
|
||||
<file>resource.c</file>
|
||||
<file>util.c</file>
|
||||
<file>symlink.c</file>
|
||||
<file>timer.c</file>
|
||||
<file>volume.c</file>
|
||||
</directory>
|
||||
<directory name="pnpmgr">
|
||||
<file>plugplay.c</file>
|
||||
<file>pnpdma.c</file>
|
||||
<file>pnpmgr.c</file>
|
||||
<file>pnpnotify.c</file>
|
||||
<file>pnpreport.c</file>
|
||||
<file>pnproot.c</file>
|
||||
</directory>
|
||||
</directory>
|
||||
<file>file.c</file>
|
||||
<file>iocomp.c</file>
|
||||
<file>iofunc.c</file>
|
||||
<file>iomgr.c</file>
|
||||
<file>iowork.c</file>
|
||||
<file>irp.c</file>
|
||||
<file>irq.c</file>
|
||||
<file>mdl.c</file>
|
||||
<file>rawfs.c</file>
|
||||
<file>remlock.c</file>
|
||||
<file>resource.c</file>
|
||||
<file>util.c</file>
|
||||
<file>symlink.c</file>
|
||||
<file>timer.c</file>
|
||||
<file>volume.c</file>
|
||||
</directory>
|
||||
<directory name="pnpmgr">
|
||||
<file>plugplay.c</file>
|
||||
<file>pnpdma.c</file>
|
||||
<file>pnpmgr.c</file>
|
||||
<file>pnpnotify.c</file>
|
||||
<file>pnpreport.c</file>
|
||||
<file>pnproot.c</file>
|
||||
</directory>
|
||||
</directory>
|
||||
<directory name="kd">
|
||||
<directory name="wrappers">
|
||||
<file>bochs.c</file>
|
||||
|
@ -289,6 +289,7 @@
|
|||
</directory>
|
||||
<directory name="po">
|
||||
<file>power.c</file>
|
||||
<file>events.c</file>
|
||||
</directory>
|
||||
<directory name="ps">
|
||||
<file>debug.c</file>
|
||||
|
@ -331,13 +332,13 @@
|
|||
</directory>
|
||||
<directory name="vdm">
|
||||
<if property="ARCH" value="i386">
|
||||
<file>vdmmain.c</file>
|
||||
<file>vdmexec.c</file>
|
||||
<file>vdmmain.c</file>
|
||||
<file>vdmexec.c</file>
|
||||
</if>
|
||||
</directory>
|
||||
<directory name="wmi">
|
||||
<file>wmi.c</file>
|
||||
</directory>
|
||||
</directory>
|
||||
<directory name="wmi">
|
||||
<file>wmi.c</file>
|
||||
</directory>
|
||||
<file>ntoskrnl.rc</file>
|
||||
<linkerflag>-nostartfiles</linkerflag>
|
||||
<linkerflag>-nostdlib</linkerflag>
|
||||
|
|
97
reactos/ntoskrnl/po/events.c
Normal file
97
reactos/ntoskrnl/po/events.c
Normal file
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/po/events.c
|
||||
* PURPOSE: Power Manager
|
||||
*
|
||||
* PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.org)
|
||||
*/
|
||||
|
||||
#include <ntoskrnl.h>
|
||||
//#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
NTSTATUS CALLBACK
|
||||
PopAddRemoveSysCapsCallback(
|
||||
IN PVOID NotificationStructure,
|
||||
IN PVOID Context)
|
||||
{
|
||||
PDEVICE_INTERFACE_CHANGE_NOTIFICATION Notification;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
HANDLE DeviceHandle;
|
||||
IO_STATUS_BLOCK IoStatusBlock;
|
||||
BOOLEAN Arrival;
|
||||
ULONG Caps;
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT("PopAddRemoveSysCapsCallback(%p %p)\n",
|
||||
NotificationStructure, Context);
|
||||
|
||||
Notification = (PDEVICE_INTERFACE_CHANGE_NOTIFICATION)NotificationStructure;
|
||||
if (Notification->Version != 1)
|
||||
return STATUS_REVISION_MISMATCH;
|
||||
if (Notification->Size != sizeof(DEVICE_INTERFACE_CHANGE_NOTIFICATION))
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
if (RtlCompareMemory(&Notification->Event, &GUID_DEVICE_INTERFACE_ARRIVAL, sizeof(GUID) == sizeof(GUID)))
|
||||
Arrival = TRUE;
|
||||
else if (RtlCompareMemory(&Notification->Event, &GUID_DEVICE_INTERFACE_REMOVAL, sizeof(GUID) == sizeof(GUID)))
|
||||
Arrival = FALSE;
|
||||
else
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
|
||||
if (Arrival)
|
||||
{
|
||||
DPRINT("Arrival of %wZ\n", Notification->SymbolicLinkName);
|
||||
|
||||
/* Open device */
|
||||
InitializeObjectAttributes(
|
||||
&ObjectAttributes,
|
||||
Notification->SymbolicLinkName,
|
||||
OBJ_KERNEL_HANDLE,
|
||||
NULL,
|
||||
NULL);
|
||||
Status = ZwOpenFile(
|
||||
&DeviceHandle,
|
||||
FILE_READ_DATA,
|
||||
&ObjectAttributes,
|
||||
&IoStatusBlock,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
0);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("ZwOpenFile() failed with status 0x%08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* Send IOCTL_GET_SYS_BUTTON_CAPS to get new caps */
|
||||
Status = ZwDeviceIoControlFile(
|
||||
DeviceHandle,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&IoStatusBlock,
|
||||
IOCTL_GET_SYS_BUTTON_CAPS,
|
||||
NULL,
|
||||
0,
|
||||
&Caps,
|
||||
sizeof(Caps));
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("ZwDeviceIoControlFile(IOCTL_GET_SYS_BUTTON_CAPS) failed with status 0x%08lx\n", Status);
|
||||
ZwClose(DeviceHandle);
|
||||
return Status;
|
||||
}
|
||||
/* FIXME: What do do with this? */
|
||||
DPRINT1("Device capabilities: 0x%lx\n", Caps);
|
||||
|
||||
/* Send IOCTL_GET_SYS_BUTTON_CAPS to get current caps */
|
||||
/* FIXME: Set a IO completion routine on it to be able to send a new one */
|
||||
DPRINT1("Send a IOCTL_GET_SYS_BUTTON_EVENT\n");
|
||||
return ZwClose(DeviceHandle);
|
||||
}
|
||||
else
|
||||
{
|
||||
DPRINT1("Removal of a power capable device not implemented\n");
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
}
|
|
@ -308,6 +308,8 @@ NTAPI
|
|||
PoInit(PROS_LOADER_PARAMETER_BLOCK LoaderBlock,
|
||||
BOOLEAN ForceAcpiDisable)
|
||||
{
|
||||
PVOID NotificationEntry;
|
||||
|
||||
if (ForceAcpiDisable)
|
||||
{
|
||||
/* Set the ACPI State to False if it's been forced that way */
|
||||
|
@ -318,6 +320,15 @@ PoInit(PROS_LOADER_PARAMETER_BLOCK LoaderBlock,
|
|||
/* Otherwise check the LoaderBlock's Flag */
|
||||
PopAcpiPresent = (LoaderBlock->Flags & MB_FLAGS_ACPI_TABLE) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
IoRegisterPlugPlayNotification(
|
||||
EventCategoryDeviceInterfaceChange,
|
||||
0, /* The registry has not been initialized yet */
|
||||
(PVOID)&GUID_DEVICE_SYS_BUTTON,
|
||||
IopRootDeviceNode->PhysicalDeviceObject->DriverObject,
|
||||
PopAddRemoveSysCapsCallback,
|
||||
NULL,
|
||||
&NotificationEntry);
|
||||
}
|
||||
|
||||
VOID
|
||||
|
|
Loading…
Reference in a new issue