Author: sir_richard
Date: Mon Mar 22 03:11:16 2010
New Revision: 46336
URL:
http://svn.reactos.org/svn/reactos?rev=46336&view=rev
Log:
[CMBATT]: Implement CmBattSystemControl to parse WMI requests.
Modified:
trunk/reactos/drivers/bus/acpi/cmbatt/cmbatt.rbuild
trunk/reactos/drivers/bus/acpi/cmbatt/cmbpnp.c
trunk/reactos/drivers/bus/acpi/cmbatt/cmbwmi.c
Modified: trunk/reactos/drivers/bus/acpi/cmbatt/cmbatt.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/acpi/cmbatt/cm…
==============================================================================
--- trunk/reactos/drivers/bus/acpi/cmbatt/cmbatt.rbuild [iso-8859-1] (original)
+++ trunk/reactos/drivers/bus/acpi/cmbatt/cmbatt.rbuild [iso-8859-1] Mon Mar 22 03:11:16
2010
@@ -4,6 +4,7 @@
<library>ntoskrnl</library>
<library>hal</library>
<library>battc</library>
+ <library>wmilib</library>
<include base="cmbatt">.</include>
<file>cmbatt.c</file>
<file>cmexec.c</file>
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 03:11:16 2010
@@ -312,6 +312,7 @@
if (CmBattDebug & 0x220)
DbgPrint("CmBattAddBattery: pdo %x\n", DeviceObject);
+ /* Create the FDO */
Status = CmBattCreateFdo(DriverObject,
DeviceObject,
sizeof(CMBATT_DEVICE_EXTENSION),
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 03:11:16 2010
@@ -18,6 +18,37 @@
};
/* FUNCTIONS ******************************************************************/
+
+PCHAR
+NTAPI
+WMIMinorFunctionString(IN UCHAR MinorFunction)
+{
+ switch (MinorFunction)
+ {
+ case IRP_MN_CHANGE_SINGLE_INSTANCE:
+ return "IRP_MN_CHANGE_SINGLE_INSTANCE";
+ case IRP_MN_CHANGE_SINGLE_ITEM:
+ return "IRP_MN_CHANGE_SINGLE_ITEM";
+ case IRP_MN_DISABLE_COLLECTION:
+ return "IRP_MN_DISABLE_COLLECTION";
+ case IRP_MN_DISABLE_EVENTS:
+ return "IRP_MN_DISABLE_EVENTS";
+ case IRP_MN_ENABLE_COLLECTION:
+ return "IRP_MN_ENABLE_COLLECTION";
+ case IRP_MN_ENABLE_EVENTS:
+ return "IRP_MN_ENABLE_EVENTS";
+ case IRP_MN_EXECUTE_METHOD:
+ return "IRP_MN_EXECUTE_METHOD";
+ case IRP_MN_QUERY_ALL_DATA:
+ return "IRP_MN_QUERY_ALL_DATA";
+ case IRP_MN_QUERY_SINGLE_INSTANCE:
+ return "IRP_MN_QUERY_SINGLE_INSTANCE";
+ case IRP_MN_REGINFO:
+ return "IRP_MN_REGINFO";
+ default:
+ return "IRP_MN_?????";
+ }
+}
NTSTATUS
NTAPI
@@ -111,11 +142,80 @@
NTSTATUS
NTAPI
-CmBattSystemControl(PDEVICE_OBJECT DeviceObject,
- PIRP Irp)
-{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+CmBattSystemControl(IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp)
+{
+ NTSTATUS Status;
+ PCMBATT_DEVICE_EXTENSION DeviceExtension;
+ PWMILIB_CONTEXT WmiLibContext;
+ SYSCTL_IRP_DISPOSITION Disposition = IrpForward;
+ PAGED_CODE();
+ if (CmBattDebug & 2)
+ DbgPrint("CmBatt: SystemControl: %s\n",
+
WMIMinorFunctionString(IoGetCurrentIrpStackLocation(Irp)->MinorFunction));
+
+ /* Acquire the remove lock */
+ DeviceExtension = DeviceObject->DeviceExtension;
+ Status = IoAcquireRemoveLock(&DeviceExtension->RemoveLock, 0);
+ if (!NT_SUCCESS(Status))
+ {
+ /* It's too late, fail */
+ Irp->IoStatus.Status = STATUS_DEVICE_REMOVED;
+ IofCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_DEVICE_REMOVED;
+ }
+
+ /* What kind of device is this? */
+ WmiLibContext = &DeviceExtension->WmiLibInfo;
+ if (DeviceExtension->FdoType == CmBattBattery)
+ {
+ /* For batteries, let the class driver handle it */
+ Status = BatteryClassSystemControl(DeviceExtension->ClassData,
+ WmiLibContext,
+ DeviceObject,
+ Irp,
+ &Disposition);
+ }
+ else
+ {
+ /* Otherwise, call the wmi library directly */
+ Status = WmiSystemControl(WmiLibContext,
+ DeviceObject,
+ Irp,
+ &Disposition);
+ }
+
+ /* Check what happened */
+ switch (Disposition)
+ {
+ case IrpNotCompleted:
+
+ /* Complete it here */
+ if (CmBattDebug & 2) DbgPrint("CmBatt: SystemControl: Irp Not
Completed.\n");
+ IofCompleteRequest(Irp, IO_NO_INCREMENT);
+ break;
+
+ case IrpForward:
+
+ /* Forward it to ACPI */
+ if (CmBattDebug & 2) DbgPrint("CmBatt: SystemControl: Irp
Forward.\n");
+ IoSkipCurrentIrpStackLocation(Irp);
+ Status = IoCallDriver(DeviceExtension->AttachedDevice, Irp);
+ break;
+
+ case IrpProcessed:
+
+ /* Nothing to do */
+ if (CmBattDebug & 2) DbgPrint("CmBatt: SystemControl: Irp
Processed.\n");
+ break;
+
+ default:
+ ASSERT(FALSE);
+ }
+
+ /* Release the lock and return */
+ IoReleaseRemoveLock(&DeviceExtension->RemoveLock, 0);
+ return Status;
}
/* EOF */