ReactOS 0.4.15-dev-8131-g4988de4
cmbwmi.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS ACPI-Compliant Control Method Battery
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: boot/drivers/bus/acpi/cmbatt/cmbwmi.c
5 * PURPOSE: WMI Interface
6 * PROGRAMMERS: ReactOS Portable Systems Group
7 */
8
9/* INCLUDES *******************************************************************/
10
11#include "cmbatt.h"
12
13#include <debug.h>
14
15/* GLOBALS ********************************************************************/
16
18{
19 {&GUID_POWER_DEVICE_WAKE_ENABLE, 1, 0}
20};
21
22/* FUNCTIONS ******************************************************************/
23
27{
28 switch (MinorFunction)
29 {
31 return "IRP_MN_CHANGE_SINGLE_INSTANCE";
33 return "IRP_MN_CHANGE_SINGLE_ITEM";
35 return "IRP_MN_DISABLE_COLLECTION";
37 return "IRP_MN_DISABLE_EVENTS";
39 return "IRP_MN_ENABLE_COLLECTION";
41 return "IRP_MN_ENABLE_EVENTS";
43 return "IRP_MN_EXECUTE_METHOD";
45 return "IRP_MN_QUERY_ALL_DATA";
47 return "IRP_MN_QUERY_SINGLE_INSTANCE";
48 case IRP_MN_REGINFO:
49 return "IRP_MN_REGINFO";
50 default:
51 return "IRP_MN_?????";
52 }
53}
54
63{
66}
67
71 PIRP Irp,
75 PULONG InstanceLengthArray,
78{
81}
82
86 PIRP Irp,
91{
94}
95
99 PIRP Irp,
105{
108}
109
111NTAPI
113{
114 PAGED_CODE();
115
116 /* De-register */
117 return IoWMIRegistrationControl(DeviceExtension->FdoDeviceObject,
119}
120
122NTAPI
124{
125 PAGED_CODE();
126
127 /* GUID information */
128 DeviceExtension->WmiLibInfo.GuidCount = sizeof(CmBattWmiGuidList) /
129 sizeof(WMIGUIDREGINFO);
130 DeviceExtension->WmiLibInfo.GuidList = CmBattWmiGuidList;
131
132 /* Callbacks */
133 DeviceExtension->WmiLibInfo.QueryWmiRegInfo = CmBattQueryWmiRegInfo;
134 DeviceExtension->WmiLibInfo.QueryWmiDataBlock = CmBattQueryWmiDataBlock;
135 DeviceExtension->WmiLibInfo.SetWmiDataBlock = CmBattSetWmiDataBlock;
136 DeviceExtension->WmiLibInfo.SetWmiDataItem = CmBattSetWmiDataItem;
137 DeviceExtension->WmiLibInfo.ExecuteWmiMethod = NULL;
138 DeviceExtension->WmiLibInfo.WmiFunctionControl = NULL;
139
140 /* Register */
141 return IoWMIRegistrationControl(DeviceExtension->FdoDeviceObject,
143}
144
146NTAPI
148 IN PIRP Irp)
149{
151 PCMBATT_DEVICE_EXTENSION DeviceExtension;
154 PAGED_CODE();
155 if (CmBattDebug & 2)
156 DbgPrint("CmBatt: SystemControl: %s\n",
158
159 /* Acquire the remove lock */
160 DeviceExtension = DeviceObject->DeviceExtension;
161 Status = IoAcquireRemoveLock(&DeviceExtension->RemoveLock, 0);
162 if (!NT_SUCCESS(Status))
163 {
164 /* It's too late, fail */
165 Irp->IoStatus.Status = STATUS_DEVICE_REMOVED;
168 }
169
170 /* What kind of device is this? */
171 WmiLibContext = &DeviceExtension->WmiLibInfo;
172 if (DeviceExtension->FdoType == CmBattBattery)
173 {
174 /* For batteries, let the class driver handle it */
175 Status = BatteryClassSystemControl(DeviceExtension->ClassData,
178 Irp,
179 &Disposition);
180 }
181 else
182 {
183 /* Otherwise, call the wmi library directly */
186 Irp,
187 &Disposition);
188 }
189
190 /* Check what happened */
191 switch (Disposition)
192 {
193 case IrpNotCompleted:
194
195 /* Complete it here */
196 if (CmBattDebug & 2) DbgPrint("CmBatt: SystemControl: Irp Not Completed.\n");
198 break;
199
200 case IrpForward:
201
202 /* Forward it to ACPI */
203 if (CmBattDebug & 2) DbgPrint("CmBatt: SystemControl: Irp Forward.\n");
205 Status = IoCallDriver(DeviceExtension->AttachedDevice, Irp);
206 break;
207
208 case IrpProcessed:
209
210 /* Nothing to do */
211 if (CmBattDebug & 2) DbgPrint("CmBatt: SystemControl: Irp Processed.\n");
212 break;
213
214 default:
215 ASSERT(FALSE);
216 }
217
218 /* Release the lock and return */
219 IoReleaseRemoveLock(&DeviceExtension->RemoveLock, 0);
220 return Status;
221}
222
223/* EOF */
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
#define PAGED_CODE()
LONG NTSTATUS
Definition: precomp.h:26
_In_ PVOID WmiLibContext
Definition: batclass.h:377
BCLASSAPI NTSTATUS NTAPI BatteryClassSystemControl(PVOID ClassData, PVOID WmiLibContext, PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID Disposition)
Definition: battc.c:49
#define UNIMPLEMENTED
Definition: debug.h:118
Definition: bufpool.h:45
_In_ LPGUID _In_ ULONG InstanceIndex
Definition: classpnp.h:1251
_Out_ ULONG * RegFlags
Definition: classpnp.h:403
_In_ PIRP _In_ ULONG GuidIndex
Definition: classpnp.h:419
_In_ PIRP _In_ ULONG _In_ ULONG BufferAvail
Definition: classpnp.h:420
ULONG CmBattDebug
Definition: cmbatt.c:17
@ CmBattBattery
Definition: cmbatt.h:48
PCHAR NTAPI WMIMinorFunctionString(IN UCHAR MinorFunction)
Definition: cmbwmi.c:26
NTSTATUS NTAPI CmBattWmiRegistration(IN PCMBATT_DEVICE_EXTENSION DeviceExtension)
Definition: cmbwmi.c:123
WMIGUIDREGINFO CmBattWmiGuidList[1]
Definition: cmbwmi.c:17
NTSTATUS NTAPI CmBattQueryWmiDataBlock(PDEVICE_OBJECT DeviceObject, PIRP Irp, ULONG GuidIndex, ULONG InstanceIndex, ULONG InstanceCount, PULONG InstanceLengthArray, ULONG BufferAvail, PUCHAR Buffer)
Definition: cmbwmi.c:70
NTSTATUS NTAPI CmBattSetWmiDataItem(PDEVICE_OBJECT DeviceObject, PIRP Irp, ULONG GuidIndex, ULONG InstanceIndex, ULONG DataItemId, ULONG BufferSize, PUCHAR Buffer)
Definition: cmbwmi.c:98
NTSTATUS NTAPI CmBattSetWmiDataBlock(PDEVICE_OBJECT DeviceObject, PIRP Irp, ULONG GuidIndex, ULONG InstanceIndex, ULONG BufferSize, PUCHAR Buffer)
Definition: cmbwmi.c:85
NTSTATUS NTAPI CmBattWmiDeRegistration(IN PCMBATT_DEVICE_EXTENSION DeviceExtension)
Definition: cmbwmi.c:112
NTSTATUS NTAPI CmBattSystemControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: cmbwmi.c:147
NTSTATUS NTAPI CmBattQueryWmiRegInfo(PDEVICE_OBJECT DeviceObject, PULONG RegFlags, PUNICODE_STRING InstanceName, PUNICODE_STRING *RegistryPath, PUNICODE_STRING MofResourceName, PDEVICE_OBJECT *Pdo)
Definition: cmbwmi.c:57
_In_ PIRP Irp
Definition: csq.h:116
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_Must_inspect_result_ _Inout_ PFLT_VOLUME _In_opt_ PCUNICODE_STRING InstanceName
Definition: fltkernel.h:1163
Status
Definition: gdiplustypes.h:25
#define DbgPrint
Definition: hal.h:12
#define ASSERT(a)
Definition: mode.c:44
_In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Reserved_ ULONG _In_opt_ PUNICODE_STRING _In_ ULONG _Out_opt_ PULONG Disposition
Definition: cmfuncs.h:56
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define IoCompleteRequest
Definition: irp.c:1240
#define IoCallDriver
Definition: irp.c:1225
NTSTATUS NTAPI IoWMIRegistrationControl(IN PDEVICE_OBJECT DeviceObject, IN ULONG Action)
Definition: wmi.c:68
#define STATUS_DEVICE_REMOVED
Definition: ntstatus.h:809
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
CMBATT_EXTENSION_TYPE FdoType
Definition: cmbatt.h:104
WMILIB_CONTEXT WmiLibInfo
Definition: cmbatt.h:113
PDEVICE_OBJECT AttachedDevice
Definition: cmbatt.h:108
IO_REMOVE_LOCK RemoveLock
Definition: cmbatt.h:115
uint32_t * PULONG
Definition: typedefs.h:59
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
char * PCHAR
Definition: typedefs.h:51
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING MofResourceName
Definition: wdfdevice.h:2464
_In_ UCHAR _In_ UCHAR MinorFunction
Definition: wdfdevice.h:1699
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
WDF_EXTERN_C_START typedef _Must_inspect_result_ _In_ WDFDRIVER _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ PDEVICE_OBJECT _In_opt_ PDEVICE_OBJECT _In_opt_ PDEVICE_OBJECT Pdo
Definition: wdfminiport.h:72
_In_ ULONG DataItemId
Definition: wdfwmi.h:123
NTSTATUS NTAPI WmiSystemControl(IN PWMILIB_CONTEXT WmiLibInfo, IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, OUT PSYSCTL_IRP_DISPOSITION IrpDisposition)
Definition: wmilib.c:48
@ IrpForward
Definition: wmilib.h:16
@ IrpNotCompleted
Definition: wmilib.h:14
@ IrpProcessed
Definition: wmilib.h:13
enum _SYSCTL_IRP_DISPOSITION SYSCTL_IRP_DISPOSITION
_In_ ULONG InstanceCount
Definition: iofuncs.h:1323
#define IoAcquireRemoveLock(RemoveLock, Tag)
#define IoReleaseRemoveLock(_RemoveLock, _Tag)
Definition: iofuncs.h:2764
#define IRP_MN_EXECUTE_METHOD
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define IRP_MN_DISABLE_COLLECTION
#define IRP_MN_CHANGE_SINGLE_ITEM
#define WMIREG_ACTION_REGISTER
#define IRP_MN_QUERY_ALL_DATA
#define WMIREG_ACTION_DEREGISTER
#define IRP_MN_DISABLE_EVENTS
#define IRP_MN_ENABLE_EVENTS
#define IRP_MN_ENABLE_COLLECTION
#define IRP_MN_REGINFO
#define IRP_MN_CHANGE_SINGLE_INSTANCE
#define IRP_MN_QUERY_SINGLE_INSTANCE
unsigned char UCHAR
Definition: xmlstorage.h:181