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 SerialNumber[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 ACPI_BST_DATA BstData; 128 ACPI_BIF_DATA BifData; 129 ULONG Id; 130 ULONG State; 131 ULONG RemainingCapacity; 132 ULONG PresentVoltage; 133 ULONG Rate; 134 BATTERY_INFORMATION BatteryInformation; 135 ULONG BatteryCapacityGranularity1; 136 ULONG BatteryCapacityGranularity2; 137 BOOLEAN TripPointSet; 138 ULONG TripPointValue; 139 ULONG TripPointOld; 140 ULONGLONG InterruptTime; 141 } CMBATT_DEVICE_EXTENSION, *PCMBATT_DEVICE_EXTENSION; 142 143 NTSTATUS 144 NTAPI 145 CmBattPowerDispatch( 146 PDEVICE_OBJECT DeviceObject, 147 PIRP Irp 148 ); 149 150 NTSTATUS 151 NTAPI 152 CmBattPnpDispatch( 153 PDEVICE_OBJECT DeviceObject, 154 PIRP Irp 155 ); 156 157 NTSTATUS 158 NTAPI 159 CmBattAddDevice( 160 PDRIVER_OBJECT DriverObject, 161 PDEVICE_OBJECT DeviceObject 162 ); 163 164 NTSTATUS 165 NTAPI 166 CmBattSystemControl( 167 PDEVICE_OBJECT DeviceObject, 168 PIRP Irp 169 ); 170 171 NTSTATUS 172 NTAPI 173 CmBattGetBstData( 174 PCMBATT_DEVICE_EXTENSION DeviceExtension, 175 PACPI_BST_DATA BstData 176 ); 177 178 NTSTATUS 179 NTAPI 180 CmBattGetPsrData( 181 PDEVICE_OBJECT DeviceObject, 182 PULONG PsrData 183 ); 184 185 NTSTATUS 186 NTAPI 187 CmBattGetStaData( 188 PDEVICE_OBJECT DeviceObject, 189 PULONG StaData 190 ); 191 192 NTSTATUS 193 NTAPI 194 CmBattGetBifData( 195 PCMBATT_DEVICE_EXTENSION DeviceExtension, 196 PACPI_BIF_DATA BifData 197 ); 198 199 NTSTATUS 200 NTAPI 201 CmBattSetTripPpoint( 202 PCMBATT_DEVICE_EXTENSION DeviceExtension, 203 ULONG AlarmValue 204 ); 205 206 VOID 207 NTAPI 208 CmBattNotifyHandler( 209 IN PCMBATT_DEVICE_EXTENSION DeviceExtension, 210 IN ULONG NotifyValue 211 ); 212 213 NTSTATUS 214 NTAPI 215 CmBattWmiDeRegistration( 216 PCMBATT_DEVICE_EXTENSION DeviceExtension 217 ); 218 219 NTSTATUS 220 NTAPI 221 CmBattWmiRegistration( 222 PCMBATT_DEVICE_EXTENSION DeviceExtension 223 ); 224 225 NTSTATUS 226 NTAPI 227 CmBattGetUniqueId( 228 PDEVICE_OBJECT DeviceObject, 229 PULONG UniqueId 230 ); 231 232 NTSTATUS 233 NTAPI 234 CmBattQueryInformation( 235 IN PCMBATT_DEVICE_EXTENSION FdoExtension, 236 IN ULONG Tag, 237 IN BATTERY_QUERY_INFORMATION_LEVEL InfoLevel, 238 IN OPTIONAL LONG AtRate, 239 IN PVOID Buffer, 240 IN ULONG BufferLength, 241 OUT PULONG ReturnedLength 242 ); 243 244 NTSTATUS 245 NTAPI 246 CmBattQueryStatus( 247 IN PCMBATT_DEVICE_EXTENSION DeviceExtension, 248 IN ULONG Tag, 249 IN PBATTERY_STATUS BatteryStatus 250 ); 251 252 NTSTATUS 253 NTAPI 254 CmBattSetStatusNotify( 255 IN PCMBATT_DEVICE_EXTENSION DeviceExtension, 256 IN ULONG BatteryTag, 257 IN PBATTERY_NOTIFY BatteryNotify 258 ); 259 260 NTSTATUS 261 NTAPI 262 CmBattDisableStatusNotify( 263 IN PCMBATT_DEVICE_EXTENSION DeviceExtension 264 ); 265 266 NTSTATUS 267 NTAPI 268 CmBattQueryTag( 269 IN PCMBATT_DEVICE_EXTENSION DeviceExtension, 270 OUT PULONG Tag 271 ); 272 273 extern PDEVICE_OBJECT AcAdapterPdo; 274 extern ULONG CmBattDebug; 275 276 #endif /* _CMBATT_PCH_ */ 277