xref: /reactos/drivers/bus/acpi/cmbatt/cmbatt.h (revision 321bcc05)
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 \
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 typedef enum _CMBATT_EXTENSION_TYPE
46 {
47     CmBattAcAdapter,
48     CmBattBattery
49 } CMBATT_EXTENSION_TYPE;
50 
51 #define ACPI_BUS_CHECK              0x00
52 #define ACPI_DEVICE_CHECK           0x01
53 
54 #define ACPI_STA_PRESENT            0x01
55 #define ACPI_STA_ENABLED            0x02
56 #define ACPI_STA_SHOW_UI            0x04
57 #define ACPI_STA_FUNCTIONAL         0x08
58 #define ACPI_STA_BATTERY_PRESENT    0x10
59 
60 #define ACPI_BATT_NOTIFY_STATUS     0x80
61 #define ACPI_BATT_NOTIFY_INFO       0x81
62 
63 #define ACPI_BATT_STAT_DISCHARG		0x0001
64 #define ACPI_BATT_STAT_CHARGING		0x0002
65 #define ACPI_BATT_STAT_CRITICAL		0x0004
66 
67 #define CM_MAX_VALUE                0x7FFFFFFF
68 #define CM_UNKNOWN_VALUE            0xFFFFFFFF
69 
70 typedef struct _ACPI_BST_DATA
71 {
72     ULONG State;
73     ULONG PresentRate;
74     ULONG RemainingCapacity;
75     ULONG PresentVoltage;
76 } ACPI_BST_DATA, *PACPI_BST_DATA;
77 
78 #define ACPI_BATT_POWER_UNIT_WATTS  0x0
79 #define ACPI_BATT_POWER_UNIT_AMPS   0x1
80 
81 typedef struct _ACPI_BIF_DATA
82 {
83     ULONG PowerUnit;
84     ULONG DesignCapacity;
85     ULONG LastFullCapacity;
86     ULONG BatteryTechnology;
87     ULONG DesignVoltage;
88     ULONG DesignCapacityWarning;
89     ULONG DesignCapacityLow;
90     ULONG BatteryCapacityGranularity1;
91     ULONG BatteryCapacityGranularity2;
92     CHAR ModelNumber[256];
93     CHAR SerialNubmer[256];
94     CHAR BatteryType[256];
95     CHAR OemInfo[256];
96 } ACPI_BIF_DATA, *PACPI_BIF_DATA;
97 
98 #define CMBATT_AR_NOTIFY            0x01
99 #define CMBATT_AR_INSERT            0x02
100 #define CMBATT_AR_REMOVE            0x04
101 
102 typedef struct _CMBATT_DEVICE_EXTENSION
103 {
104     CMBATT_EXTENSION_TYPE FdoType;
105     PDEVICE_OBJECT DeviceObject;
106     PDEVICE_OBJECT FdoDeviceObject;
107     PDEVICE_OBJECT PdoDeviceObject;
108     PDEVICE_OBJECT AttachedDevice;
109     FAST_MUTEX FastMutex;
110     ULONG HandleCount;
111     PIRP PowerIrp;
112     POWER_STATE PowerState;
113     WMILIB_CONTEXT WmiLibInfo;
114     BOOLEAN WaitWakeEnable;
115     IO_REMOVE_LOCK RemoveLock;
116     ULONG DeviceId;
117     PUNICODE_STRING DeviceName;
118     ACPI_INTERFACE_STANDARD AcpiInterface;
119     BOOLEAN DelayNotification;
120     BOOLEAN ArFlag;
121     PVOID ClassData;
122     BOOLEAN Started;
123     BOOLEAN NotifySent;
124     LONG ArLockValue;
125     ULONG TagData;
126     ULONG Tag;
127     ULONG ModelNumberLength;
128     PCHAR ModelNumber;
129     ULONG SerialNumberLength;
130     PCHAR SerialNumber;
131     ULONG OemInfoLength;
132     PCHAR OemInfo;
133     ACPI_BST_DATA BstData;
134     ACPI_BIF_DATA BifData;
135     ULONG Id;
136     ULONG State;
137     ULONG RemainingCapacity;
138     ULONG PresentVoltage;
139     ULONG Rate;
140     BATTERY_INFORMATION BatteryInformation;
141     ULONG BatteryCapacityGranularity1;
142     ULONG BatteryCapacityGranularity2;
143     BOOLEAN TripPointSet;
144     ULONG TripPointValue;
145     ULONG TripPointOld;
146     ULONGLONG InterruptTime;
147 } CMBATT_DEVICE_EXTENSION, *PCMBATT_DEVICE_EXTENSION;
148 
149 NTSTATUS
150 NTAPI
151 CmBattPowerDispatch(
152     PDEVICE_OBJECT DeviceObject,
153     PIRP Irp
154 );
155 
156 NTSTATUS
157 NTAPI
158 CmBattPnpDispatch(
159     PDEVICE_OBJECT DeviceObject,
160     PIRP Irp
161 );
162 
163 NTSTATUS
164 NTAPI
165 CmBattAddDevice(
166     PDRIVER_OBJECT DriverObject,
167     PDEVICE_OBJECT DeviceObject
168 );
169 
170 NTSTATUS
171 NTAPI
172 CmBattSystemControl(
173     PDEVICE_OBJECT DeviceObject,
174     PIRP Irp
175 );
176 
177 NTSTATUS
178 NTAPI
179 CmBattGetBstData(
180     PCMBATT_DEVICE_EXTENSION DeviceExtension,
181     PACPI_BST_DATA BstData
182 );
183 
184 NTSTATUS
185 NTAPI
186 CmBattGetPsrData(
187     PDEVICE_OBJECT DeviceObject,
188     PULONG PsrData
189 );
190 
191 NTSTATUS
192 NTAPI
193 CmBattGetStaData(
194     PDEVICE_OBJECT DeviceObject,
195     PULONG StaData
196 );
197 
198 NTSTATUS
199 NTAPI
200 CmBattGetBifData(
201     PCMBATT_DEVICE_EXTENSION DeviceExtension,
202     PACPI_BIF_DATA BifData
203 );
204 
205 NTSTATUS
206 NTAPI
207 CmBattSetTripPpoint(
208     PCMBATT_DEVICE_EXTENSION DeviceExtension,
209     ULONG AlarmValue
210 );
211 
212 VOID
213 NTAPI
214 CmBattNotifyHandler(
215     IN PCMBATT_DEVICE_EXTENSION DeviceExtension,
216     IN ULONG NotifyValue
217 );
218 
219 NTSTATUS
220 NTAPI
221 CmBattWmiDeRegistration(
222     PCMBATT_DEVICE_EXTENSION DeviceExtension
223 );
224 
225 NTSTATUS
226 NTAPI
227 CmBattWmiRegistration(
228     PCMBATT_DEVICE_EXTENSION DeviceExtension
229 );
230 
231 NTSTATUS
232 NTAPI
233 CmBattGetUniqueId(
234     PDEVICE_OBJECT DeviceObject,
235     PULONG UniqueId
236 );
237 
238 NTSTATUS
239 NTAPI
240 CmBattQueryInformation(
241     IN PCMBATT_DEVICE_EXTENSION FdoExtension,
242     IN ULONG Tag,
243     IN BATTERY_QUERY_INFORMATION_LEVEL InfoLevel,
244     IN OPTIONAL LONG AtRate,
245     IN PVOID Buffer,
246     IN ULONG BufferLength,
247     OUT PULONG ReturnedLength
248 );
249 
250 NTSTATUS
251 NTAPI
252 CmBattQueryStatus(
253     IN PCMBATT_DEVICE_EXTENSION DeviceExtension,
254     IN ULONG Tag,
255     IN PBATTERY_STATUS BatteryStatus
256 );
257 
258 NTSTATUS
259 NTAPI
260 CmBattSetStatusNotify(
261     IN PCMBATT_DEVICE_EXTENSION DeviceExtension,
262     IN ULONG BatteryTag,
263     IN PBATTERY_NOTIFY BatteryNotify
264 );
265 
266 NTSTATUS
267 NTAPI
268 CmBattDisableStatusNotify(
269     IN PCMBATT_DEVICE_EXTENSION DeviceExtension
270 );
271 
272 NTSTATUS
273 NTAPI
274 CmBattQueryTag(
275     IN PCMBATT_DEVICE_EXTENSION DeviceExtension,
276     OUT PULONG Tag
277 );
278 
279 extern PDEVICE_OBJECT AcAdapterPdo;
280 extern ULONG CmBattDebug;
281 
282 #endif /* _CMBATT_PCH_ */
283