Author: sir_richard
Date: Mon Mar 22 02:47:40 2010
New Revision: 46333
URL:
http://svn.reactos.org/svn/reactos?rev=46333&view=rev
Log:
[CMBATT]: Implement CmBattGetAcpiInterfaces and CmBattIoCompletion to get the ACPI
interface.
[CMBATT]: Implement CmBattWmiRegistration and CmBattWmiDeRegistration to initialize the
WMILIB and register with the I/O WMI routines.
[DDK]: Add missing IoWMIRegistrationControl flags.
Modified:
trunk/reactos/drivers/bus/acpi/cmbatt/cmbatt.h
trunk/reactos/drivers/bus/acpi/cmbatt/cmbpnp.c
trunk/reactos/drivers/bus/acpi/cmbatt/cmbwmi.c
trunk/reactos/include/ddk/wdm.h
Modified: trunk/reactos/drivers/bus/acpi/cmbatt/cmbatt.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/acpi/cmbatt/cm…
==============================================================================
--- trunk/reactos/drivers/bus/acpi/cmbatt/cmbatt.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/bus/acpi/cmbatt/cmbatt.h [iso-8859-1] Mon Mar 22 02:47:40 2010
@@ -11,6 +11,7 @@
#include <batclass.h>
#include <acpiioct.h>
#include <wmilib.h>
+#include <wdmguid.h>
#include <debug.h>
#define CMBATT_GENERIC_STATUS 0x01
Modified: trunk/reactos/drivers/bus/acpi/cmbatt/cmbpnp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/acpi/cmbatt/cm…
==============================================================================
--- trunk/reactos/drivers/bus/acpi/cmbatt/cmbpnp.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/bus/acpi/cmbatt/cmbpnp.c [iso-8859-1] Mon Mar 22 02:47:40 2010
@@ -14,21 +14,85 @@
NTSTATUS
NTAPI
-CmBattIoCompletion(PDEVICE_OBJECT DeviceObject,
- PIRP Irp,
- PKEVENT Event)
-{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
-}
-
-NTSTATUS
-NTAPI
-CmBattGetAcpiInterfaces(PDEVICE_OBJECT DeviceObject,
- PACPI_INTERFACE_STANDARD AcpiInterface)
-{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+CmBattIoCompletion(IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp,
+ IN PKEVENT Event)
+{
+ if (CmBattDebug & 2) DbgPrint("CmBattIoCompletion: Event (%x)\n",
Event);
+
+ /* Set the completion event */
+ KeSetEvent(Event, IO_NO_INCREMENT, FALSE);
+ return STATUS_MORE_PROCESSING_REQUIRED;
+}
+
+NTSTATUS
+NTAPI
+CmBattGetAcpiInterfaces(IN PDEVICE_OBJECT DeviceObject,
+ IN OUT PACPI_INTERFACE_STANDARD AcpiInterface)
+{
+ PIRP Irp;
+ NTSTATUS Status;
+ PIO_STACK_LOCATION IoStackLocation;
+ KEVENT Event;
+
+ /* Allocate the IRP */
+ Irp = IoAllocateIrp(DeviceObject->StackSize, 0);
+ if (!Irp)
+ {
+ /* Fail */
+ if (CmBattDebug & 0xC)
+ DbgPrint("CmBattGetAcpiInterfaces: Failed to allocate Irp\n");
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ /* Set default error code */
+ Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
+
+ /* Build the query */
+ IoStackLocation = IoGetNextIrpStackLocation(Irp);
+ IoStackLocation->MinorFunction = IRP_MN_QUERY_INTERFACE;
+ IoStackLocation->Parameters.QueryInterface.InterfaceType =
&GUID_ACPI_INTERFACE_STANDARD;
+ IoStackLocation->Parameters.QueryInterface.Size =
sizeof(ACPI_INTERFACE_STANDARD);
+ IoStackLocation->Parameters.QueryInterface.Version = 1;
+ IoStackLocation->Parameters.QueryInterface.Interface = (PINTERFACE)AcpiInterface;
+ IoStackLocation->Parameters.QueryInterface.InterfaceSpecificData = NULL;
+
+ /* Set default ACPI interface data */
+ AcpiInterface->Size = sizeof(ACPI_INTERFACE_STANDARD);
+ AcpiInterface->Version = 1;
+
+ /* Initialize our wait event */
+ KeInitializeEvent(&Event, SynchronizationEvent, 0);
+
+ /* Set the completion routine */
+ IoCopyCurrentIrpStackLocationToNext(Irp);
+ IoSetCompletionRoutine(Irp,
+ (PVOID)CmBattIoCompletion,
+ &Event,
+ TRUE,
+ TRUE,
+ TRUE);
+
+ /* Now call ACPI */
+ Status = IoCallDriver(DeviceObject, Irp);
+ if (Status == STATUS_PENDING)
+ {
+ /* Wait for completion */
+ KeWaitForSingleObject(&Event,
+ Executive,
+ KernelMode,
+ FALSE,
+ NULL);
+ Status = Irp->IoStatus.Status;
+ }
+
+ /* Free the IRP */
+ IoFreeIrp(Irp);
+
+ /* Return status */
+ if (!(NT_SUCCESS(Status)) && (CmBattDebug & 0xC))
+ DbgPrint("CmBattGetAcpiInterfaces: Could not get ACPI driver interfaces,
status = %x\n", Status);
+ return Status;
}
VOID
Modified: trunk/reactos/drivers/bus/acpi/cmbatt/cmbwmi.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/acpi/cmbatt/cm…
==============================================================================
--- trunk/reactos/drivers/bus/acpi/cmbatt/cmbwmi.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/bus/acpi/cmbatt/cmbwmi.c [iso-8859-1] Mon Mar 22 02:47:40 2010
@@ -9,6 +9,13 @@
/* INCLUDES *******************************************************************/
#include "cmbatt.h"
+
+/* GLOBALS ********************************************************************/
+
+WMIGUIDREGINFO CmBattWmiGuidList[1] =
+{
+ {&GUID_POWER_DEVICE_WAKE_ENABLE, 1, 0}
+};
/* FUNCTIONS ******************************************************************/
@@ -69,18 +76,37 @@
NTSTATUS
NTAPI
-CmBattWmiDeRegistration(PCMBATT_DEVICE_EXTENSION DeviceExtension)
+CmBattWmiDeRegistration(IN PCMBATT_DEVICE_EXTENSION DeviceExtension)
{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+ PAGED_CODE();
+
+ /* De-register */
+ return IoWMIRegistrationControl(DeviceExtension->FdoDeviceObject,
+ WMIREG_ACTION_DEREGISTER);
}
NTSTATUS
NTAPI
-CmBattWmiRegistration(PCMBATT_DEVICE_EXTENSION DeviceExtension)
+CmBattWmiRegistration(IN PCMBATT_DEVICE_EXTENSION DeviceExtension)
{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+ PAGED_CODE();
+
+ /* GUID information */
+ DeviceExtension->WmiLibInfo.GuidCount = sizeof(CmBattWmiGuidList) /
+ sizeof(WMIGUIDREGINFO);
+ DeviceExtension->WmiLibInfo.GuidList = CmBattWmiGuidList;
+
+ /* Callbacks */
+ DeviceExtension->WmiLibInfo.QueryWmiRegInfo = CmBattQueryWmiRegInfo;
+ DeviceExtension->WmiLibInfo.QueryWmiDataBlock = CmBattQueryWmiDataBlock;
+ DeviceExtension->WmiLibInfo.SetWmiDataBlock = CmBattSetWmiDataBlock;
+ DeviceExtension->WmiLibInfo.SetWmiDataItem = CmBattSetWmiDataItem;
+ DeviceExtension->WmiLibInfo.ExecuteWmiMethod = NULL;
+ DeviceExtension->WmiLibInfo.WmiFunctionControl = NULL;
+
+ /* Register */
+ return IoWMIRegistrationControl(DeviceExtension->FdoDeviceObject,
+ WMIREG_ACTION_REGISTER);
}
NTSTATUS
Modified: trunk/reactos/include/ddk/wdm.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ddk/wdm.h?rev=4633…
==============================================================================
--- trunk/reactos/include/ddk/wdm.h [iso-8859-1] (original)
+++ trunk/reactos/include/ddk/wdm.h [iso-8859-1] Mon Mar 22 02:47:40 2010
@@ -3158,6 +3158,12 @@
(DDKAPI *WMI_NOTIFICATION_CALLBACK)(
PVOID Wnode,
PVOID Context);
+
+#define WMIREG_ACTION_REGISTER 1
+#define WMIREG_ACTION_DEREGISTER 2
+#define WMIREG_ACTION_REREGISTER 3
+#define WMIREG_ACTION_UPDATE_GUIDS 4
+#define WMIREG_ACTION_BLOCK_IRPS 5
#define EVENT_INCREMENT 1
#define IO_NO_INCREMENT 0