ReactOS 0.4.16-dev-570-g1868985
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.

Classes

struct  ACPI_PACKAGE_FIELD
 

Typedefs

typedef struct ACPI_PACKAGE_FIELDPACPI_PACKAGE_FIELD
 

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)
 
static NTSTATUS CmBattCallAcpiPackage (_In_ LPCSTR FunctionName, _In_ PCMBATT_DEVICE_EXTENSION DeviceExtension, _In_ ULONG PackageName, _In_ ULONG OutputBufferSize, _In_ PACPI_PACKAGE_FIELD PackageFields, _In_ ULONG PackageFieldCount)
 
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 CmBattGetBixData (_In_ PCMBATT_DEVICE_EXTENSION DeviceExtension, _Out_ PACPI_BIX_DATA BixData)
 Retrieves the eXtended static battery information from the ACPI _BIX method.
 
NTSTATUS NTAPI CmBattGetBstData (PCMBATT_DEVICE_EXTENSION DeviceExtension, PACPI_BST_DATA BstData)
 

Typedef Documentation

◆ PACPI_PACKAGE_FIELD

Function Documentation

◆ CmBattCallAcpiPackage()

static NTSTATUS CmBattCallAcpiPackage ( _In_ LPCSTR  FunctionName,
_In_ PCMBATT_DEVICE_EXTENSION  DeviceExtension,
_In_ ULONG  PackageName,
_In_ ULONG  OutputBufferSize,
_In_ PACPI_PACKAGE_FIELD  PackageFields,
_In_ ULONG  PackageFieldCount 
)
static

Definition at line 163 of file cmexec.c.

170{
174 PACPI_METHOD_ARGUMENT Argument;
175 ULONG i;
176 PAGED_CODE();
177
179 OutputBufferSize,
180 'MtaB');
181 if (!OutputBuffer)
182 {
184 DbgPrint("%s: Failed to allocate Buffer\n", FunctionName);
186 }
187
188 /* Initialize to zero */
189 RtlZeroMemory(OutputBuffer, OutputBufferSize);
190
191 /* Request the ACPI method */
192 *(PULONG)InputBuffer.MethodName = PackageName;
194
195 /* Send it to ACPI */
196 Status = CmBattSendDownStreamIrp(DeviceExtension->AttachedDevice,
199 sizeof(InputBuffer),
201 OutputBufferSize);
202 if (!NT_SUCCESS(Status))
203 {
205 DbgPrint("%s: Failed 0x%08x method on device %x - Status (0x%x)\n",
206 FunctionName, PackageName, DeviceExtension->DeviceId, Status);
208 return Status;
209 }
210
211 /* Check if we got the right number of elements */
212 if (OutputBuffer->Count != PackageFieldCount)
213 {
215 DbgPrint("%s: 0x%08x method returned %d elements (requires %d)\n",
216 FunctionName, PackageName, OutputBuffer->Count, PackageFieldCount);
219 }
220
221 Argument = OutputBuffer->Argument;
222 for (i = 0; i < PackageFieldCount && NT_SUCCESS(Status); i++)
223 {
224 if (PackageFields[i].IsString)
225 Status = GetStringElement(Argument, PackageFields[i].Data);
226 else
227 Status = GetDwordElement(Argument, PackageFields[i].Data);
228 if (!NT_SUCCESS(Status))
229 {
231 DbgPrint("%s: Failed to get %s\n", FunctionName, PackageFields[i].Name);
232 break;
233 }
234 Argument = ACPI_METHOD_NEXT_ARGUMENT(Argument);
235 }
236
238 return Status;
239}
#define PAGED_CODE()
ACPI_METHOD_ARGUMENT UNALIGNED * PACPI_METHOD_ARGUMENT
Definition: acpiioct.h:71
#define ACPI_METHOD_NEXT_ARGUMENT(Argument)
Definition: acpiioct.h:150
#define ACPI_EVAL_INPUT_BUFFER_SIGNATURE
Definition: acpiioct.h:7
#define IOCTL_ACPI_EVAL_METHOD
Definition: acpiioct.h:178
ACPI_EVAL_OUTPUT_BUFFER UNALIGNED * PACPI_EVAL_OUTPUT_BUFFER
Definition: acpiioct.h:90
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char * FunctionName
Definition: acpixf.h:1279
LONG NTSTATUS
Definition: precomp.h:26
ULONG CmBattDebug
Definition: cmbatt.c:17
#define CMBATT_ACPI_WARNING
Definition: cmbatt.h:38
#define CMBATT_ACPI_ASSERT
Definition: cmbatt.h:43
#define CMBATT_GENERIC_WARNING
Definition: cmbatt.h:37
#define CMBATT_ACPI_ENTRY_EXIT
Definition: cmbatt.h:41
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:92
NTSTATUS NTAPI GetDwordElement(IN PACPI_METHOD_ARGUMENT Argument, OUT PULONG Value)
Definition: cmexec.c:27
NTSTATUS NTAPI GetStringElement(IN PACPI_METHOD_ARGUMENT Argument, OUT PCHAR Value)
Definition: cmexec.c:54
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
Status
Definition: gdiplustypes.h:25
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define DbgPrint
Definition: hal.h:12
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define STATUS_ACPI_INVALID_DATA
Definition: ntstatus.h:1306
uint32_t * PULONG
Definition: typedefs.h:59
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_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

Referenced by CmBattGetBifData(), CmBattGetBixData(), and CmBattGetBstData().

◆ CmBattGetBifData()

NTSTATUS NTAPI CmBattGetBifData ( PCMBATT_DEVICE_EXTENSION  DeviceExtension,
PACPI_BIF_DATA  BifData 
)

Definition at line 412 of file cmexec.c.

414{
415 ACPI_PACKAGE_FIELD BifFields[] = {
416 { "PowerUnit", FALSE, &BifData->PowerUnit },
417 { "DesignCapacity", FALSE, &BifData->DesignCapacity },
418 { "LastFullCapacity", FALSE, &BifData->LastFullCapacity },
419 { "BatteryTechnology", FALSE, &BifData->BatteryTechnology },
420 { "DesignVoltage", FALSE, &BifData->DesignVoltage },
421 { "DesignCapacityWarning", FALSE, &BifData->DesignCapacityWarning },
422 { "DesignCapacityLow", FALSE, &BifData->DesignCapacityLow },
423 { "BatteryCapacityGranularity1", FALSE, &BifData->BatteryCapacityGranularity1 },
424 { "BatteryCapacityGranularity2", FALSE, &BifData->BatteryCapacityGranularity2 },
425 { "ModelNumber", TRUE, &BifData->ModelNumber },
426 { "SerialNumber", TRUE, &BifData->SerialNumber },
427 { "BatteryType", TRUE, &BifData->BatteryType },
428 { "OemInfo", TRUE, &BifData->OemInfo },
429 };
430 PAGED_CODE();
431
433 DbgPrint("CmBattGetBifData: Buffer (0x%x) Device %x Tid %x\n",
434 BifData, DeviceExtension->DeviceId, KeGetCurrentThread());
435
436 /* Request the _BIF method */
437 /* Note that _BIF method is deprecated since ACPI 4.0, and replaced by _BIX method.
438 * However, VirtualBox 7.0 only support _BIF method.
439 */
440 return CmBattCallAcpiPackage("CmBattGetBifData",
441 DeviceExtension,
442 'FIB_',
443 512,
444 BifFields,
445 RTL_NUMBER_OF(BifFields));
446}
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
static NTSTATUS CmBattCallAcpiPackage(_In_ LPCSTR FunctionName, _In_ PCMBATT_DEVICE_EXTENSION DeviceExtension, _In_ ULONG PackageName, _In_ ULONG OutputBufferSize, _In_ PACPI_PACKAGE_FIELD PackageFields, _In_ ULONG PackageFieldCount)
Definition: cmexec.c:163
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define KeGetCurrentThread
Definition: hal.h:55
ULONG DesignCapacityLow
Definition: cmbatt.h:110
ULONG DesignVoltage
Definition: cmbatt.h:108
ULONG LastFullCapacity
Definition: cmbatt.h:106
ULONG DesignCapacity
Definition: cmbatt.h:105
CHAR SerialNumber[ASCIIZ_MAX_LENGTH]
Definition: cmbatt.h:114
ULONG BatteryTechnology
Definition: cmbatt.h:107
CHAR BatteryType[ASCIIZ_MAX_LENGTH]
Definition: cmbatt.h:115
ULONG BatteryCapacityGranularity1
Definition: cmbatt.h:111
CHAR OemInfo[ASCIIZ_MAX_LENGTH]
Definition: cmbatt.h:116
ULONG DesignCapacityWarning
Definition: cmbatt.h:109
ULONG BatteryCapacityGranularity2
Definition: cmbatt.h:112
CHAR ModelNumber[ASCIIZ_MAX_LENGTH]
Definition: cmbatt.h:113
ULONG PowerUnit
Definition: cmbatt.h:104

Referenced by CmBattGetBattStaticInfo(), and CmBattIoctl().

◆ CmBattGetBixData()

NTSTATUS NTAPI CmBattGetBixData ( _In_ PCMBATT_DEVICE_EXTENSION  DeviceExtension,
_Out_ PACPI_BIX_DATA  BixData 
)

Retrieves the eXtended static battery information from the ACPI _BIX method.

Parameters
[in]DeviceExtensionA pointer to a Control Method (CM) battery device extension. It is used to send the ACPI method evaluation operation to the ACPI driver of which it is attached to this CM battery.
[out]BixDataA pointer to a structure that contains the _BIX data fields, returned to caller.
Returns
Returns STATUS_SUCCESS if the operation has succeeded successfully, otherwise a failure NTSTATUS code is returned.

Definition at line 468 of file cmexec.c.

471{
472 ACPI_PACKAGE_FIELD BixFields[] = {
473 { "Revision", FALSE, &BixData->Revision },
474 { "PowerUnit", FALSE, &BixData->PowerUnit },
475 { "DesignCapacity", FALSE, &BixData->DesignCapacity },
476 { "LastFullCapacity", FALSE, &BixData->LastFullCapacity },
477 { "BatteryTechnology", FALSE, &BixData->BatteryTechnology },
478 { "DesignVoltage", FALSE, &BixData->DesignVoltage },
479 { "DesignCapacityWarning", FALSE, &BixData->DesignCapacityWarning },
480 { "DesignCapacityLow", FALSE, &BixData->DesignCapacityLow },
481 { "CycleCount", FALSE, &BixData->CycleCount },
482 { "Accuracy", FALSE, &BixData->Accuracy },
483 { "MaxSampleTime", FALSE, &BixData->MaxSampleTime },
484 { "MinSampleTime", FALSE, &BixData->MinSampleTime },
485 { "MaxAverageInterval", FALSE, &BixData->MaxAverageInterval },
486 { "MinAverageInterval", FALSE, &BixData->MinAverageInterval },
487 { "BatteryCapacityGranularity1", FALSE, &BixData->BatteryCapacityGranularity1 },
488 { "BatteryCapacityGranularity2", FALSE, &BixData->BatteryCapacityGranularity2 },
489 { "ModelNumber", TRUE, &BixData->ModelNumber },
490 { "SerialNumber", TRUE, &BixData->SerialNumber },
491 { "BatteryType", TRUE, &BixData->BatteryType },
492 { "OemInfo", TRUE, &BixData->OemInfo },
493 { "SwapCapability", FALSE, &BixData->SwapCapability },
494 };
495 PAGED_CODE();
496
498 {
499 DbgPrint("CmBattGetBixData: Buffer (0x%x) Device %x Tid %x\n",
500 BixData, DeviceExtension->DeviceId, KeGetCurrentThread());
501 }
502
503 /* Request the ACPI driver to get the _BIX data for us */
504 return CmBattCallAcpiPackage("CmBattGetBifData",
505 DeviceExtension,
506 'XIB_',
507 512,
508 BixFields,
509 RTL_NUMBER_OF(BixFields));
510}

Referenced by CmBattGetBattStaticInfo(), and CmBattIoctl().

◆ CmBattGetBstData()

NTSTATUS NTAPI CmBattGetBstData ( PCMBATT_DEVICE_EXTENSION  DeviceExtension,
PACPI_BST_DATA  BstData 
)

Definition at line 514 of file cmexec.c.

516{
517 ACPI_PACKAGE_FIELD BstFields[] = {
518 { "State", FALSE, &BstData->State },
519 { "PresentRate", FALSE, &BstData->PresentRate },
520 { "RemainingCapacity", FALSE, &BstData->RemainingCapacity },
521 { "PresentVoltage", FALSE, &BstData->PresentVoltage },
522 };
523 PAGED_CODE();
524
526 DbgPrint("CmBattGetBstData: Buffer (0x%x) Device %x Tid %x\n",
527 BstData, DeviceExtension->DeviceId, KeGetCurrentThread());
528
529
530 return CmBattCallAcpiPackage("CmBattGetBstData",
531 DeviceExtension,
532 'TSB_',
533 512,
534 BstFields,
535 RTL_NUMBER_OF(BstFields));
536}
ULONG PresentRate
Definition: cmbatt.h:92
ULONG RemainingCapacity
Definition: cmbatt.h:93
ULONG PresentVoltage
Definition: cmbatt.h:94
ULONG State
Definition: cmbatt.h:91

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

◆ CmBattGetPsrData()

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

Definition at line 243 of file cmexec.c.

245{
249 PAGED_CODE();
250 if (CmBattDebug & 0x40)
251 DbgPrint("CmBattGetPsrData: Entered with Pdo %x Tid %x\n",
253
254 /* Initialize to zero */
255 ASSERT(PsrData != NULL);
256 *PsrData = 0;
257
258 /* Request the _PSR method */
259 *(PULONG)InputBuffer.MethodName = 'RSP_';
261
262 /* Send it to ACPI */
266 sizeof(InputBuffer),
268 sizeof(OutputBuffer));
269 if (NT_SUCCESS(Status))
270 {
271 /* Read the result */
272 Status = GetDwordElement(OutputBuffer.Argument, PsrData);
273 if (CmBattDebug & 0x440)
274 DbgPrint("CmBattGetPsrData: _PSR method returned %x \n", *PsrData);
275 }
276 else if (CmBattDebug & 0x44C)
277 {
278 /* Failure */
279 DbgPrint("CmBattGetPsrData: Failed _PSR method - Status (0x%x)\n", Status);
280 }
281
282 /* Return status */
283 return Status;
284}
#define NULL
Definition: types.h:112
#define ASSERT(a)
Definition: mode.c:44
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055

◆ CmBattGetStaData()

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

Definition at line 288 of file cmexec.c.

290{
294 PAGED_CODE();
295 if (CmBattDebug & 0x40)
296 DbgPrint("CmBattGetStaData: Entered with Pdo %x Tid %x\n",
298
299 /* Initialize to zero */
300 ASSERT(StaData != NULL);
301 *StaData = 0;
302
303 /* Request the _STA method */
304 *(PULONG)InputBuffer.MethodName = 'ATS_';
306
307 /* Send it to ACPI */
311 sizeof(InputBuffer),
313 sizeof(OutputBuffer));
314 if (NT_SUCCESS(Status))
315 {
316 /* Read the result */
317 Status = GetDwordElement(OutputBuffer.Argument, StaData);
318 if (CmBattDebug & 0x440)
319 DbgPrint("CmBattGetStaData: _STA method returned %x \n", *StaData);
320 }
321 else if (CmBattDebug & 0x44C)
322 {
323 /* Failure */
324 DbgPrint("CmBattGetStaData: Failed _STA method - Status (0x%x)\n", Status);
326 }
327
328 /* Return status */
329 return Status;
330}
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136

◆ CmBattGetUniqueId()

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

Definition at line 334 of file cmexec.c.

336{
340 PAGED_CODE();
341 if (CmBattDebug & 0x40)
342 DbgPrint("CmBattGetUniqueId: Entered with Pdo %x Tid %x\n",
344
345 /* Initialize to zero */
346 ASSERT(UniqueId != NULL);
347 *UniqueId = 0;
348
349 /* Request the _UID method */
350 *(PULONG)InputBuffer.MethodName = 'DIU_';
352
353 /* Send it to ACPI */
357 sizeof(InputBuffer),
359 sizeof(OutputBuffer));
360 if (NT_SUCCESS(Status))
361 {
362 /* Read the result */
363 Status = GetDwordElement(OutputBuffer.Argument, UniqueId);
364 if (CmBattDebug & 0x440)
365 DbgPrint("CmBattGetUniqueId: _UID method returned %x \n", *UniqueId);
366 }
367 else if (CmBattDebug & 0x44C)
368 {
369 /* Failure */
370 DbgPrint("CmBattGetUniqueId: Failed _UID method - Status (0x%x)\n", Status);
372 }
373
374 /* Return status */
375 return Status;
376}

◆ 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 92 of file cmexec.c.

98{
99 PIRP Irp;
103 PAGED_CODE();
104
105 /* Initialize our wait event */
107
108 /* Allocate the IRP */
115 0,
116 &Event,
118 if (!Irp)
119 {
120 /* No IRP, fail */
121 if (CmBattDebug & 0x4C)
122 DbgPrint("CmBattSendDownStreamIrp: Failed to allocate Irp\n");
124 }
125
126 /* Call ACPI */
127 if (CmBattDebug & 0x40)
128 DbgPrint("CmBattSendDownStreamIrp: Irp %x [Tid] %x\n",
131 if (Status == STATUS_PENDING)
132 {
133 /* Wait for completion */
135 Executive,
137 FALSE,
138 NULL);
139 Status = Irp->IoStatus.Status;
140 }
141
142 /* Check if caller wanted output */
143 if (OutputBuffer)
144 {
145 /* Make sure it's valid ACPI output buffer */
147 !(OutputBuffer->Count))
148 {
149 /* It isn't, so set failure code */
151 }
152 }
153
154 /* Return status */
155 if (CmBattDebug & 0x40)
156 DbgPrint("CmBattSendDownStreamIrp: Irp %x completed %x! [Tid] %x\n",
158 return Status;
159}
#define ACPI_EVAL_OUTPUT_BUFFER_SIGNATURE
Definition: acpiioct.h:11
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_PENDING
Definition: d3dkmdt.h:43
#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:38
@ 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
_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 CmBattCallAcpiPackage(), CmBattGetPsrData(), CmBattGetStaData(), CmBattGetUniqueId(), and CmBattSetTripPpoint().

◆ CmBattSetTripPpoint()

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

Definition at line 380 of file cmexec.c.

382{
385 PAGED_CODE();
386 if (CmBattDebug & 0x440)
387 DbgPrint("CmBattSetTripPpoint: _BTP Alarm Value %x Device %x Tid %x\n",
388 AlarmValue, DeviceExtension->DeviceId, KeGetCurrentThread);
389
390 /* Request the _BTP method */
391 *(PULONG)InputBuffer.MethodName = 'PTB_';
393 InputBuffer.IntegerArgument = AlarmValue;
394
395 /* Send it to ACPI */
396 Status = CmBattSendDownStreamIrp(DeviceExtension->AttachedDevice,
399 sizeof(InputBuffer),
400 NULL,
401 0);
402 if (!(NT_SUCCESS(Status)) && (CmBattDebug & 0x440))
403 DbgPrint("CmBattSetTripPpoint: Failed _BTP method on device %x - Status (0x%x)\n",
404 DeviceExtension->DeviceId, Status);
405
406 /* Return status */
407 return Status;
408}
#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 27 of file cmexec.c.

29{
31
32 /* Must have an integer */
33 if (Argument->Type != ACPI_METHOD_ARGUMENT_INTEGER)
34 {
35 /* Not an integer, fail */
37 if (CmBattDebug & 0x4C)
38 DbgPrint("GetDwordElement: Object contained wrong data type - %d\n",
39 Argument->Type);
40 }
41 else
42 {
43 /* Read the integer value */
44 *Value = Argument->Argument;
46 }
47
48 /* Return status */
49 return Status;
50}
#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 CmBattCallAcpiPackage(), CmBattGetPsrData(), CmBattGetStaData(), and CmBattGetUniqueId().

◆ GetStringElement()

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

Definition at line 54 of file cmexec.c.

56{
58
59 /* Must have a string of buffer */
60 if ((Argument->Type == ACPI_METHOD_ARGUMENT_STRING) ||
61 (Argument->Type == ACPI_METHOD_ARGUMENT_BUFFER))
62 {
63 /* String must be less than 256 characters */
64 if (Argument->DataLength < 256)
65 {
66 /* Copy the buffer */
67 RtlCopyMemory(Value, Argument->Data, Argument->DataLength);
69 }
70 else
71 {
72 /* The buffer is too small (the string is too large) */
74 if (CmBattDebug & 0x4C)
75 DbgPrint("GetStringElement: return buffer not big enough - %d\n", Argument->DataLength);
76 }
77 }
78 else
79 {
80 /* Not valid string data */
82 if (CmBattDebug & 0x4C)
83 DbgPrint("GetStringElement: Object contained wrong data type - %d\n", Argument->Type);
84 }
85
86 /* Return the status */
87 return Status;
88}
#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

Referenced by CmBattCallAcpiPackage().