ReactOS 0.4.15-dev-8138-g1e75ea8
cmexec.c File Reference
#include "cmbatt.h"
#include <acpiioct.h>
#include <debug.h>
Include dependency graph for cmexec.c:

Go to the source code of this file.

Functions

NTSTATUS NTAPI GetDwordElement (IN PACPI_METHOD_ARGUMENT Argument, OUT PULONG Value)
 
NTSTATUS NTAPI GetStringElement (IN PACPI_METHOD_ARGUMENT Argument, OUT PCHAR Value)
 
NTSTATUS NTAPI CmBattSendDownStreamIrp (IN PDEVICE_OBJECT DeviceObject, IN ULONG IoControlCode, IN PVOID InputBuffer, IN ULONG InputBufferLength, IN PACPI_EVAL_OUTPUT_BUFFER OutputBuffer, IN ULONG OutputBufferLength)
 
NTSTATUS NTAPI CmBattGetPsrData (IN PDEVICE_OBJECT DeviceObject, OUT PULONG PsrData)
 
NTSTATUS NTAPI CmBattGetStaData (IN PDEVICE_OBJECT DeviceObject, OUT PULONG StaData)
 
NTSTATUS NTAPI CmBattGetUniqueId (IN PDEVICE_OBJECT DeviceObject, OUT PULONG UniqueId)
 
NTSTATUS NTAPI CmBattSetTripPpoint (IN PCMBATT_DEVICE_EXTENSION DeviceExtension, IN ULONG AlarmValue)
 
NTSTATUS NTAPI CmBattGetBifData (PCMBATT_DEVICE_EXTENSION DeviceExtension, PACPI_BIF_DATA BifData)
 
NTSTATUS NTAPI CmBattGetBstData (PCMBATT_DEVICE_EXTENSION DeviceExtension, PACPI_BST_DATA BstData)
 

Function Documentation

◆ CmBattGetBifData()

NTSTATUS NTAPI CmBattGetBifData ( PCMBATT_DEVICE_EXTENSION  DeviceExtension,
PACPI_BIF_DATA  BifData 
)

Definition at line 325 of file cmexec.c.

327{
330}
#define UNIMPLEMENTED
Definition: debug.h:118
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239

Referenced by CmBattIoctl().

◆ CmBattGetBstData()

NTSTATUS NTAPI CmBattGetBstData ( PCMBATT_DEVICE_EXTENSION  DeviceExtension,
PACPI_BST_DATA  BstData 
)

Definition at line 334 of file cmexec.c.

336{
339}

Referenced by CmBattGetBatteryStatus(), CmBattIoctl(), and CmBattSetStatusNotify().

◆ CmBattGetPsrData()

NTSTATUS NTAPI CmBattGetPsrData ( IN PDEVICE_OBJECT  DeviceObject,
OUT PULONG  PsrData 
)

Definition at line 156 of file cmexec.c.

158{
162 PAGED_CODE();
163 if (CmBattDebug & 0x40)
164 DbgPrint("CmBattGetPsrData: Entered with Pdo %x Tid %x\n",
166
167 /* Initialize to zero */
168 ASSERT(PsrData != NULL);
169 *PsrData = 0;
170
171 /* Request the _PSR method */
172 *(PULONG)InputBuffer.MethodName = 'RSP_';
174
175 /* Send it to ACPI */
179 sizeof(InputBuffer),
181 sizeof(OutputBuffer));
182 if (NT_SUCCESS(Status))
183 {
184 /* Read the result */
185 Status = GetDwordElement(OutputBuffer.Argument, PsrData);
186 if (CmBattDebug & 0x440)
187 DbgPrint("CmBattGetPsrData: _PSR method returned %x \n", *PsrData);
188 }
189 else if (CmBattDebug & 0x44C)
190 {
191 /* Failure */
192 DbgPrint("CmBattGetPsrData: Failed _PSR method - Status (0x%x)\n", Status);
193 }
194
195 /* Return status */
196 return Status;
197}
#define PAGED_CODE()
#define ACPI_EVAL_INPUT_BUFFER_SIGNATURE
Definition: acpiioct.h:7
#define IOCTL_ACPI_EVAL_METHOD
Definition: acpiioct.h:178
LONG NTSTATUS
Definition: precomp.h:26
ULONG CmBattDebug
Definition: cmbatt.c:17
NTSTATUS NTAPI CmBattSendDownStreamIrp(IN PDEVICE_OBJECT DeviceObject, IN ULONG IoControlCode, IN PVOID InputBuffer, IN ULONG InputBufferLength, IN PACPI_EVAL_OUTPUT_BUFFER OutputBuffer, IN ULONG OutputBufferLength)
Definition: cmexec.c:85
NTSTATUS NTAPI GetDwordElement(IN PACPI_METHOD_ARGUMENT Argument, OUT PULONG Value)
Definition: cmexec.c:20
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:25
#define DbgPrint
Definition: hal.h:12
#define KeGetCurrentThread
Definition: hal.h:55
#define ASSERT(a)
Definition: mode.c:44
uint32_t * PULONG
Definition: typedefs.h:59
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
Definition: wdfiotarget.h:863
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR InputBuffer
Definition: wdfiotarget.h:953

◆ CmBattGetStaData()

NTSTATUS NTAPI CmBattGetStaData ( IN PDEVICE_OBJECT  DeviceObject,
OUT PULONG  StaData 
)

Definition at line 201 of file cmexec.c.

203{
207 PAGED_CODE();
208 if (CmBattDebug & 0x40)
209 DbgPrint("CmBattGetStaData: Entered with Pdo %x Tid %x\n",
211
212 /* Initialize to zero */
213 ASSERT(StaData != NULL);
214 *StaData = 0;
215
216 /* Request the _PSR method */
217 *(PULONG)InputBuffer.MethodName = 'ATS_';
219
220 /* Send it to ACPI */
224 sizeof(InputBuffer),
226 sizeof(OutputBuffer));
227 if (NT_SUCCESS(Status))
228 {
229 /* Read the result */
230 Status = GetDwordElement(OutputBuffer.Argument, StaData);
231 if (CmBattDebug & 0x440)
232 DbgPrint("CmBattGetStaData: _STA method returned %x \n", *StaData);
233 }
234 else if (CmBattDebug & 0x44C)
235 {
236 /* Failure */
237 DbgPrint("CmBattGetStaData: Failed _STA method - Status (0x%x)\n", Status);
239 }
240
241 /* Return status */
242 return Status;
243}
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136

◆ CmBattGetUniqueId()

NTSTATUS NTAPI CmBattGetUniqueId ( IN PDEVICE_OBJECT  DeviceObject,
OUT PULONG  UniqueId 
)

Definition at line 247 of file cmexec.c.

249{
253 PAGED_CODE();
254 if (CmBattDebug & 0x40)
255 DbgPrint("CmBattGetUniqueId: Entered with Pdo %x Tid %x\n",
257
258 /* Initialize to zero */
259 ASSERT(UniqueId != NULL);
260 *UniqueId = 0;
261
262 /* Request the _PSR method */
263 *(PULONG)InputBuffer.MethodName = 'DIU_';
265
266 /* Send it to ACPI */
270 sizeof(InputBuffer),
272 sizeof(OutputBuffer));
273 if (NT_SUCCESS(Status))
274 {
275 /* Read the result */
276 Status = GetDwordElement(OutputBuffer.Argument, UniqueId);
277 if (CmBattDebug & 0x440)
278 DbgPrint("CmBattGetUniqueId: _UID method returned %x \n", *UniqueId);
279 }
280 else if (CmBattDebug & 0x44C)
281 {
282 /* Failure */
283 DbgPrint("CmBattGetUniqueId: Failed _UID method - Status (0x%x)\n", Status);
285 }
286
287 /* Return status */
288 return Status;
289}

◆ CmBattSendDownStreamIrp()

NTSTATUS NTAPI CmBattSendDownStreamIrp ( IN PDEVICE_OBJECT  DeviceObject,
IN ULONG  IoControlCode,
IN PVOID  InputBuffer,
IN ULONG  InputBufferLength,
IN PACPI_EVAL_OUTPUT_BUFFER  OutputBuffer,
IN ULONG  OutputBufferLength 
)

Definition at line 85 of file cmexec.c.

91{
92 PIRP Irp;
96 PAGED_CODE();
97
98 /* Initialize our wait event */
100
101 /* Allocate the IRP */
108 0,
109 &Event,
111 if (!Irp)
112 {
113 /* No IRP, fail */
114 if (CmBattDebug & 0x4C)
115 DbgPrint("CmBattSendDownStreamIrp: Failed to allocate Irp\n");
117 }
118
119 /* Call ACPI */
120 if (CmBattDebug & 0x40)
121 DbgPrint("CmBattSendDownStreamIrp: Irp %x [Tid] %x\n",
124 if (Status == STATUS_PENDING)
125 {
126 /* Wait for completion */
128 Executive,
130 FALSE,
131 NULL);
132 Status = Irp->IoStatus.Status;
133 }
134
135 /* Check if caller wanted output */
136 if (OutputBuffer)
137 {
138 /* Make sure it's valid ACPI output buffer */
140 !(OutputBuffer->Count))
141 {
142 /* It isn't, so set failure code */
144 }
145 }
146
147 /* Return status */
148 if (CmBattDebug & 0x40)
149 DbgPrint("CmBattSendDownStreamIrp: Irp %x completed %x! [Tid] %x\n",
151 return Status;
152}
#define ACPI_EVAL_OUTPUT_BUFFER_SIGNATURE
Definition: acpiioct.h:11
_In_ PIRP Irp
Definition: csq.h:116
#define FALSE
Definition: types.h:117
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define KernelMode
Definition: asm.h:34
@ SynchronizationEvent
PIRP NTAPI IoBuildDeviceIoControlRequest(IN ULONG IoControlCode, IN PDEVICE_OBJECT DeviceObject, IN PVOID InputBuffer, IN ULONG InputBufferLength, IN PVOID OutputBuffer, IN ULONG OutputBufferLength, IN BOOLEAN InternalDeviceIoControl, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:881
#define IoCallDriver
Definition: irp.c:1225
#define STATUS_PENDING
Definition: ntstatus.h:82
#define STATUS_ACPI_INVALID_DATA
Definition: ntstatus.h:1306
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
Definition: wdfio.h:325
_In_ WDFREQUEST _In_ size_t OutputBufferLength
Definition: wdfio.h:320
_In_ WDFREQUEST _In_ size_t _In_ size_t InputBufferLength
Definition: wdfio.h:322
@ Executive
Definition: ketypes.h:415

Referenced by CmBattGetPsrData(), CmBattGetStaData(), CmBattGetUniqueId(), and CmBattSetTripPpoint().

◆ CmBattSetTripPpoint()

NTSTATUS NTAPI CmBattSetTripPpoint ( IN PCMBATT_DEVICE_EXTENSION  DeviceExtension,
IN ULONG  AlarmValue 
)

Definition at line 293 of file cmexec.c.

295{
298 PAGED_CODE();
299 if (CmBattDebug & 0x440)
300 DbgPrint("CmBattSetTripPpoint: _BTP Alarm Value %x Device %x Tid %x\n",
301 AlarmValue, DeviceExtension->DeviceId, KeGetCurrentThread);
302
303 /* Request the _BTP method */
304 *(PULONG)InputBuffer.MethodName = 'PTB_';
306 InputBuffer.IntegerArgument = AlarmValue;
307
308 /* Send it to ACPI */
309 Status = CmBattSendDownStreamIrp(DeviceExtension->AttachedDevice,
312 sizeof(InputBuffer),
313 NULL,
314 0);
315 if (!(NT_SUCCESS(Status)) && (CmBattDebug & 0x440))
316 DbgPrint("CmBattSetTripPpoint: Failed _BTP method on device %x - Status (0x%x)\n",
317 DeviceExtension->DeviceId, Status);
318
319 /* Return status */
320 return Status;
321}
#define ACPI_EVAL_INPUT_BUFFER_SIMPLE_INTEGER_SIGNATURE
Definition: acpiioct.h:8

◆ GetDwordElement()

NTSTATUS NTAPI GetDwordElement ( IN PACPI_METHOD_ARGUMENT  Argument,
OUT PULONG  Value 
)

Definition at line 20 of file cmexec.c.

22{
24
25 /* Must have an integer */
26 if (Argument->Type != ACPI_METHOD_ARGUMENT_INTEGER)
27 {
28 /* Not an integer, fail */
30 if (CmBattDebug & 0x4C)
31 DbgPrint("GetDwordElement: Object contained wrong data type - %d\n",
32 Argument->Type);
33 }
34 else
35 {
36 /* Read the integer value */
37 *Value = Argument->Argument;
39 }
40
41 /* Return status */
42 return Status;
43}
#define ACPI_METHOD_ARGUMENT_INTEGER
Definition: acpiioct.h:21
#define STATUS_SUCCESS
Definition: shellext.h:65
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

Referenced by CmBattGetPsrData(), CmBattGetStaData(), and CmBattGetUniqueId().

◆ GetStringElement()

NTSTATUS NTAPI GetStringElement ( IN PACPI_METHOD_ARGUMENT  Argument,
OUT PCHAR  Value 
)

Definition at line 47 of file cmexec.c.

49{
51
52 /* Must have a string of buffer */
53 if ((Argument->Type == ACPI_METHOD_ARGUMENT_STRING) ||
54 (Argument->Type == ACPI_METHOD_ARGUMENT_BUFFER))
55 {
56 /* String must be less than 256 characters */
57 if (Argument->DataLength < 256)
58 {
59 /* Copy the buffer */
60 RtlCopyMemory(Value, Argument->Data, Argument->DataLength);
62 }
63 else
64 {
65 /* The buffer is too small (the string is too large) */
67 if (CmBattDebug & 0x4C)
68 DbgPrint("GetStringElement: return buffer not big enough - %d\n", Argument->DataLength);
69 }
70 }
71 else
72 {
73 /* Not valid string data */
75 if (CmBattDebug & 0x4C)
76 DbgPrint("GetStringElement: Object contained wrong data type - %d\n", Argument->Type);
77 }
78
79 /* Return the status */
80 return Status;
81}
#define ACPI_METHOD_ARGUMENT_STRING
Definition: acpiioct.h:22
#define ACPI_METHOD_ARGUMENT_BUFFER
Definition: acpiioct.h:23
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263