ReactOS 0.4.16-dev-555-g690643f
cmbatt.h
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/cmbatt.h
5 * PURPOSE: Main Header File
6 * PROGRAMMERS: ReactOS Portable Systems Group
7 */
8
9#ifndef _CMBATT_PCH_
10#define _CMBATT_PCH_
11
12#include <wdm.h>
13#include <batclass.h>
14#include <wmilib.h>
15#include <wdmguid.h>
16
17#define IOCTL_BATTERY_QUERY_UNIQUE_ID \
18 CTL_CODE(FILE_DEVICE_BATTERY, 0x101, METHOD_BUFFERED, FILE_READ_ACCESS) // 0x294404
19
20#define IOCTL_BATTERY_QUERY_STA \
21 CTL_CODE(FILE_DEVICE_BATTERY, 0x102, METHOD_BUFFERED, FILE_READ_ACCESS) // 0x294408
22
23#define IOCTL_BATTERY_QUERY_PSR \
24 CTL_CODE(FILE_DEVICE_BATTERY, 0x103, METHOD_BUFFERED, FILE_READ_ACCESS) // 0x29440C
25
26#define IOCTL_BATTERY_SET_TRIP_POINT \
27 CTL_CODE(FILE_DEVICE_BATTERY, 0x104, METHOD_BUFFERED, FILE_READ_ACCESS) // 0x294410
28
29#define IOCTL_BATTERY_QUERY_BIF_BIX \
30 CTL_CODE(FILE_DEVICE_BATTERY, 0x105, METHOD_BUFFERED, FILE_READ_ACCESS) // 0x294414
31
32#define IOCTL_BATTERY_QUERY_BST \
33 CTL_CODE(FILE_DEVICE_BATTERY, 0x106, METHOD_BUFFERED, FILE_READ_ACCESS) // 0x294418
34
35#define CMBATT_GENERIC_STATUS 0x01
36#define CMBATT_GENERIC_INFO 0x02
37#define CMBATT_GENERIC_WARNING 0x04
38#define CMBATT_ACPI_WARNING 0x08
39#define CMBATT_POWER_INFO 0x10
40#define CMBATT_PNP_INFO 0x20
41#define CMBATT_ACPI_ENTRY_EXIT 0x40
42#define CMBATT_PNP_ENTRY_EXIT 0x200
43#define CMBATT_ACPI_ASSERT 0x400
44
45//
46// Constant used to determine if the battery was discharging
47// for over 15 seconds since last time the AC adapter got unplugged.
48//
49#define CMBATT_DISCHARGE_TIME 150000000
50
51//
52// Bogus constant used to determine if the remaining battery capacity
53// overflows which is returned by the hardware.
54//
55#define CMBATT_CAPACITY_BOGUS 0x100000
56
58{
62
63#define ACPI_BUS_CHECK 0x00
64#define ACPI_DEVICE_CHECK 0x01
65
66#define ACPI_STA_PRESENT 0x01
67#define ACPI_STA_ENABLED 0x02
68#define ACPI_STA_SHOW_UI 0x04
69#define ACPI_STA_FUNCTIONAL 0x08
70#define ACPI_STA_BATTERY_PRESENT 0x10
71
72#define ACPI_BATT_NOTIFY_STATUS 0x80
73#define ACPI_BATT_NOTIFY_INFO 0x81
74
75#define ACPI_BATT_STAT_DISCHARG 0x0001
76#define ACPI_BATT_STAT_CHARGING 0x0002
77#define ACPI_BATT_STAT_CRITICAL 0x0004
78
79#define CM_MAX_VALUE 0x7FFFFFFF
80#define CM_UNKNOWN_VALUE 0xFFFFFFFF
81
82#define CONVERT_MAH_TO_MWH(mA, Volts) (((mA) * (Volts) + 500) / 1000)
83
84#define CONVERT_BATT_INFO(Capacity, DesignVoltage) \
85 (((Capacity) != BATTERY_UNKNOWN_CAPACITY) \
86 ? CONVERT_MAH_TO_MWH((Capacity), (DesignVoltage)) \
87 : BATTERY_UNKNOWN_CAPACITY)
88
89typedef struct _ACPI_BST_DATA
90{
96
97#define ACPI_BATT_POWER_UNIT_WATTS 0x0
98#define ACPI_BATT_POWER_UNIT_AMPS 0x1
99
100#define ASCIIZ_MAX_LENGTH 256
101
102typedef struct _ACPI_BIF_DATA
103{
118
119typedef struct _ACPI_BIX_DATA
120{
143
145{
150
151#define CMBATT_BATT_STATIC_INFO_TAG 'nItS'
152
153#define CMBATT_AR_NOTIFY 0x01
154#define CMBATT_AR_INSERT 0x02
155#define CMBATT_AR_REMOVE 0x04
156
158{
197
199NTAPI
202 PIRP Irp
203);
204
206NTAPI
209 PIRP Irp
210);
211
213NTAPI
217);
218
220NTAPI
223 PIRP Irp
224);
225
227NTAPI
229 PCMBATT_DEVICE_EXTENSION DeviceExtension,
230 PACPI_BST_DATA BstData
231);
232
234NTAPI
237 PULONG PsrData
238);
239
241NTAPI
244 PULONG StaData
245);
246
248NTAPI
250 PCMBATT_DEVICE_EXTENSION DeviceExtension,
251 PACPI_BIF_DATA BifData
252);
253
255NTAPI
257 _In_ PCMBATT_DEVICE_EXTENSION DeviceExtension,
258 _Out_ PACPI_BIX_DATA BixData
259);
260
262NTAPI
264 PCMBATT_DEVICE_EXTENSION DeviceExtension,
265 ULONG AlarmValue
266);
267
268VOID
269NTAPI
271 IN PCMBATT_DEVICE_EXTENSION DeviceExtension,
272 IN ULONG NotifyValue
273);
274
276NTAPI
278 PCMBATT_DEVICE_EXTENSION DeviceExtension
279);
280
282NTAPI
284 PCMBATT_DEVICE_EXTENSION DeviceExtension
285);
286
288NTAPI
291 PULONG UniqueId
292);
293
295NTAPI
298 IN ULONG Tag,
304);
305
307NTAPI
309 IN PCMBATT_DEVICE_EXTENSION DeviceExtension,
310 IN ULONG Tag,
312);
313
315NTAPI
317 IN PCMBATT_DEVICE_EXTENSION DeviceExtension,
320);
321
323NTAPI
325 IN PCMBATT_DEVICE_EXTENSION DeviceExtension
326);
327
329NTAPI
331 IN PCMBATT_DEVICE_EXTENSION DeviceExtension,
333);
334
336extern ULONG CmBattDebug;
337
338#endif /* _CMBATT_PCH_ */
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
_In_ ULONG _In_ BATTERY_QUERY_INFORMATION_LEVEL _In_ LONG _In_ ULONG _Out_ PULONG ReturnedLength
Definition: batclass.h:188
_In_ ULONG _In_ PBATTERY_NOTIFY BatteryNotify
Definition: batclass.h:216
_Out_ PULONG BatteryTag
Definition: batclass.h:173
_In_ ULONG _Out_ PBATTERY_STATUS BatteryStatus
Definition: batclass.h:199
_In_ ULONG _In_ BATTERY_QUERY_INFORMATION_LEVEL _In_ LONG AtRate
Definition: batclass.h:185
enum _BATTERY_QUERY_INFORMATION_LEVEL BATTERY_QUERY_INFORMATION_LEVEL
Definition: bufpool.h:45
NTSTATUS NTAPI CmBattSetTripPpoint(PCMBATT_DEVICE_EXTENSION DeviceExtension, ULONG AlarmValue)
PDEVICE_OBJECT AcAdapterPdo
Definition: cmbatt.c:23
struct _ACPI_BST_DATA * PACPI_BST_DATA
NTSTATUS NTAPI CmBattGetStaData(PDEVICE_OBJECT DeviceObject, PULONG StaData)
NTSTATUS NTAPI CmBattGetPsrData(PDEVICE_OBJECT DeviceObject, PULONG PsrData)
struct _ACPI_BATT_STATIC_INFO * PACPI_BATT_STATIC_INFO
struct _ACPI_BATT_STATIC_INFO ACPI_BATT_STATIC_INFO
struct _ACPI_BIF_DATA ACPI_BIF_DATA
NTSTATUS NTAPI CmBattGetUniqueId(PDEVICE_OBJECT DeviceObject, PULONG UniqueId)
NTSTATUS NTAPI CmBattPowerDispatch(PDEVICE_OBJECT DeviceObject, PIRP Irp)
ULONG CmBattDebug
Definition: cmbatt.c:17
struct _ACPI_BIF_DATA * PACPI_BIF_DATA
NTSTATUS NTAPI CmBattGetBifData(PCMBATT_DEVICE_EXTENSION DeviceExtension, PACPI_BIF_DATA BifData)
Definition: cmexec.c:412
NTSTATUS NTAPI CmBattGetBstData(PCMBATT_DEVICE_EXTENSION DeviceExtension, PACPI_BST_DATA BstData)
Definition: cmexec.c:514
struct _CMBATT_DEVICE_EXTENSION * PCMBATT_DEVICE_EXTENSION
NTSTATUS NTAPI CmBattDisableStatusNotify(IN PCMBATT_DEVICE_EXTENSION DeviceExtension)
Definition: cmbatt.c:884
NTSTATUS NTAPI CmBattQueryStatus(IN PCMBATT_DEVICE_EXTENSION DeviceExtension, IN ULONG Tag, IN PBATTERY_STATUS BatteryStatus)
Definition: cmbatt.c:1573
NTSTATUS NTAPI CmBattPnpDispatch(PDEVICE_OBJECT DeviceObject, PIRP Irp)
NTSTATUS NTAPI CmBattQueryInformation(IN PCMBATT_DEVICE_EXTENSION FdoExtension, IN ULONG Tag, IN BATTERY_QUERY_INFORMATION_LEVEL InfoLevel, IN OPTIONAL LONG AtRate, IN PVOID Buffer, IN ULONG BufferLength, OUT PULONG ReturnedLength)
Definition: cmbatt.c:1317
struct _ACPI_BST_DATA ACPI_BST_DATA
NTSTATUS NTAPI CmBattGetBixData(_In_ PCMBATT_DEVICE_EXTENSION DeviceExtension, _Out_ PACPI_BIX_DATA BixData)
Retrieves the eXtended static battery information from the ACPI _BIX method.
Definition: cmexec.c:468
VOID NTAPI CmBattNotifyHandler(IN PCMBATT_DEVICE_EXTENSION DeviceExtension, IN ULONG NotifyValue)
Definition: cmbatt.c:142
struct _ACPI_BIX_DATA ACPI_BIX_DATA
NTSTATUS NTAPI CmBattAddDevice(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT DeviceObject)
#define ASCIIZ_MAX_LENGTH
Definition: cmbatt.h:100
NTSTATUS NTAPI CmBattSystemControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
NTSTATUS NTAPI CmBattWmiRegistration(PCMBATT_DEVICE_EXTENSION DeviceExtension)
NTSTATUS NTAPI CmBattQueryTag(IN PCMBATT_DEVICE_EXTENSION DeviceExtension, OUT PULONG Tag)
Definition: cmbatt.c:826
NTSTATUS NTAPI CmBattWmiDeRegistration(PCMBATT_DEVICE_EXTENSION DeviceExtension)
struct _ACPI_BIX_DATA * PACPI_BIX_DATA
NTSTATUS NTAPI CmBattSetStatusNotify(IN PCMBATT_DEVICE_EXTENSION DeviceExtension, IN ULONG BatteryTag, IN PBATTERY_NOTIFY BatteryNotify)
Definition: cmbatt.c:925
struct _CMBATT_DEVICE_EXTENSION CMBATT_DEVICE_EXTENSION
enum _CMBATT_EXTENSION_TYPE CMBATT_EXTENSION_TYPE
_CMBATT_EXTENSION_TYPE
Definition: cmbatt.h:58
@ CmBattAcAdapter
Definition: cmbatt.h:59
@ CmBattBattery
Definition: cmbatt.h:60
_In_ PIRP Irp
Definition: csq.h:116
@ FdoExtension
Definition: precomp.h:48
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
long LONG
Definition: pedump.c:60
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
ACPI_BIX_DATA BixData
Definition: cmbatt.h:147
BOOLEAN ExtendedData
Definition: cmbatt.h:148
ACPI_BIF_DATA BifData
Definition: cmbatt.h:146
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
ULONG BatteryCapacityGranularity2
Definition: cmbatt.h:136
CHAR BatteryType[ASCIIZ_MAX_LENGTH]
Definition: cmbatt.h:139
ULONG MinAverageInterval
Definition: cmbatt.h:134
ULONG PowerUnit
Definition: cmbatt.h:122
ULONG BatteryTechnology
Definition: cmbatt.h:125
CHAR ModelNumber[ASCIIZ_MAX_LENGTH]
Definition: cmbatt.h:137
ULONG DesignCapacityLow
Definition: cmbatt.h:128
ULONG DesignVoltage
Definition: cmbatt.h:126
ULONG MaxSampleTime
Definition: cmbatt.h:131
CHAR SerialNumber[ASCIIZ_MAX_LENGTH]
Definition: cmbatt.h:138
ULONG LastFullCapacity
Definition: cmbatt.h:124
ULONG BatteryCapacityGranularity1
Definition: cmbatt.h:135
ULONG Revision
Definition: cmbatt.h:121
ULONG DesignCapacity
Definition: cmbatt.h:123
ULONG MinSampleTime
Definition: cmbatt.h:132
ULONG MaxAverageInterval
Definition: cmbatt.h:133
ULONG SwapCapability
Definition: cmbatt.h:141
ULONG DesignCapacityWarning
Definition: cmbatt.h:127
ULONG Accuracy
Definition: cmbatt.h:130
ULONG CycleCount
Definition: cmbatt.h:129
CHAR OemInfo[ASCIIZ_MAX_LENGTH]
Definition: cmbatt.h:140
ULONG PresentRate
Definition: cmbatt.h:92
ULONG RemainingCapacity
Definition: cmbatt.h:93
ULONG PresentVoltage
Definition: cmbatt.h:94
ULONG State
Definition: cmbatt.h:91
PUNICODE_STRING DeviceName
Definition: cmbatt.h:172
POWER_STATE PowerState
Definition: cmbatt.h:167
CMBATT_EXTENSION_TYPE FdoType
Definition: cmbatt.h:159
ACPI_BATT_STATIC_INFO BattInfo
Definition: cmbatt.h:183
ULONGLONG InterruptTime
Definition: cmbatt.h:195
PDEVICE_OBJECT PdoDeviceObject
Definition: cmbatt.h:162
WMILIB_CONTEXT WmiLibInfo
Definition: cmbatt.h:168
PDEVICE_OBJECT FdoDeviceObject
Definition: cmbatt.h:161
ACPI_BST_DATA BstData
Definition: cmbatt.h:182
PDEVICE_OBJECT DeviceObject
Definition: cmbatt.h:160
BOOLEAN DelayNotification
Definition: cmbatt.h:174
PDEVICE_OBJECT AttachedDevice
Definition: cmbatt.h:163
IO_REMOVE_LOCK RemoveLock
Definition: cmbatt.h:170
FAST_MUTEX FastMutex
Definition: cmbatt.h:164
ULONG BatteryCapacityGranularity1
Definition: cmbatt.h:190
ULONG BatteryCapacityGranularity2
Definition: cmbatt.h:191
BATTERY_INFORMATION BatteryInformation
Definition: cmbatt.h:189
ACPI_INTERFACE_STANDARD AcpiInterface
Definition: cmbatt.h:173
uint32_t * PULONG
Definition: typedefs.h:59
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
uint64_t ULONGLONG
Definition: typedefs.h:67
#define OUT
Definition: typedefs.h:40
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4065
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3771
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
FAST_MUTEX
Definition: extypes.h:17
char CHAR
Definition: xmlstorage.h:175