#ifndef _BATCLASS_H
#define _BATCLASS_H

/* Battery class driver interfaces */

DEFINE_GUID(GUID_DEVICE_BATTERY,0x72631e54L,0x78A4,0x11d0,0xbc,0xf7,0x00,0xaa,0x00,0xb7,0xb3,0x2a);

#define IOCTL_BATTERY_QUERY_TAG  CTL_CODE(FILE_DEVICE_BATTERY,0x10,METHOD_BUFFERED,FILE_READ_ACCESS)
#define IOCTL_BATTERY_QUERY_INFORMATION  CTL_CODE(FILE_DEVICE_BATTERY,0x11,METHOD_BUFFERED,FILE_READ_ACCESS)
#define IOCTL_BATTERY_SET_INFORMATION  CTL_CODE(FILE_DEVICE_BATTERY,0x12,METHOD_BUFFERED,FILE_WRITE_ACCESS)
#define IOCTL_BATTERY_QUERY_STATUS  CTL_CODE(FILE_DEVICE_BATTERY,0x13,METHOD_BUFFERED,FILE_READ_ACCESS)

#define BATTERY_TAG_INVALID  0

#define BATTERY_SYSTEM_BATTERY  0x80000000
#define BATTERY_CAPACITY_RELATIVE  0x40000000
#define BATTERY_IS_SHORT_TERM  0x20000000
#define BATTERY_SET_CHARGE_SUPPORTED  0x00000001
#define BATTERY_SET_DISCHARGE_SUPPORTED  0x00000002
#define BATTERY_SET_RESUME_SUPPORTED  0x00000004
#define BATTERY_UNKNOWN_CAPACITY  0xFFFFFFFF

#define BATTERY_UNKNOWN_TIME 0xFFFFFFFF

#define MAX_BATTERY_STRING_SIZE 128

#define BATTERY_POWER_ON_LINE  0x00000001
#define BATTERY_DISCHARGING  0x00000002
#define BATTERY_CHARGING  0x00000004
#define BATTERY_CRITICAL  0x00000008

#define BATTERY_UNKNOWN_VOLTAGE  0xFFFFFFFF
#define BATTERY_UNKNOWN_RATE  0x80000000

typedef enum {
    BatteryInformation,
    BatteryGranularityInformation,
    BatteryTemperature,
    BatteryEstimatedTime,
    BatteryDeviceName,
    BatteryManufactureDate,
    BatteryManufactureName,
    BatteryUniqueID,
    BatterySerialNumber
} BATTERY_QUERY_INFORMATION_LEVEL;

typedef struct _BATTERY_QUERY_INFORMATION {
    ULONG BatteryTag;
    BATTERY_QUERY_INFORMATION_LEVEL InformationLevel;
    LONG AtRate;
} BATTERY_QUERY_INFORMATION, *PBATTERY_QUERY_INFORMATION;

typedef struct _BATTERY_INFORMATION {
    ULONG Capabilities;
    UCHAR Technology;
    UCHAR Reserved[3];
    UCHAR Chemistry[4];
    ULONG DesignedCapacity;
    ULONG FullChargedCapacity;
    ULONG DefaultAlert1;
    ULONG DefaultAlert2;
    ULONG CriticalBias;
    ULONG CycleCount;
} BATTERY_INFORMATION, *PBATTERY_INFORMATION;

#ifndef _NTPOAPI_H
typedef struct {
    ULONG Granularity;
    ULONG Capacity;
} BATTERY_REPORTING_SCALE, *PBATTERY_REPORTING_SCALE;
#endif

typedef struct _BATTERY_MANUFACTURE_DATE {
    UCHAR Day;
    UCHAR Month;
    USHORT Year;
} BATTERY_MANUFACTURE_DATE, *PBATTERY_MANUFACTURE_DATE;

typedef enum {
    BatteryCriticalBias,
    BatteryCharge,
    BatteryDischarge
} BATTERY_SET_INFORMATION_LEVEL;

typedef struct _BATTERY_SET_INFORMATION {
    ULONG BatteryTag;
    BATTERY_SET_INFORMATION_LEVEL InformationLevel;
    UCHAR Buffer[1];
} BATTERY_SET_INFORMATION, *PBATTERY_SET_INFORMATION;

typedef struct _BATTERY_WAIT_STATUS {
    ULONG BatteryTag;
    ULONG Timeout;
    ULONG PowerState;
    ULONG LowCapacity;
    ULONG HighCapacity;
} BATTERY_WAIT_STATUS, *PBATTERY_WAIT_STATUS;

typedef struct _BATTERY_STATUS {
    ULONG PowerState;
    ULONG Capacity;
    ULONG Voltage;
    LONG Rate;
} BATTERY_STATUS, *PBATTERY_STATUS;

#ifndef _WINDOWS_H
#define BATTERY_CLASS_MAJOR_VERSION  0x0001
#define BATTERY_CLASS_MINOR_VERSION  0x0000

#if !defined(BATTERYCLASS)
#define BATTERYCLASSAPI DECLSPEC_IMPORT
#else
#define BATTERYCLASSAPI
#endif

typedef struct {
    ULONG PowerState;
    ULONG LowCapacity;
    ULONG HighCapacity;
} BATTERY_NOTIFY, *PBATTERY_NOTIFY;

typedef struct {
    USHORT MajorVersion;
    USHORT MinorVersion;
    PVOID Context;
    BCLASS_QUERY_TAG QueryTag;
    BCLASS_QUERY_INFORMATION QueryInformation;
    BCLASS_SET_INFORMATION SetInformation;
    BCLASS_QUERY_STATUS QueryStatus;
    BCLASS_SET_STATUS_NOTIFY SetStatusNotify;
    BCLASS_DISABLE_STATUS_NOTIFY DisableStatusNotify;
    PDEVICE_OBJECT Pdo;
    PUNICODE_STRING DeviceName;
} BATTERY_MINIPORT_INFO, *PBATTERY_MINIPORT_INFO;

typedef NTSTATUS (*BCLASS_QUERY_TAG)(PVOID,PULONG);
typedef NTSTATUS (*BCLASS_QUERY_INFORMATION)(PVOID,ULONG,BATTERY_QUERY_INFORMATION_LEVEL,LONG,PVOID,ULONG,PULONG);
typedef NTSTATUS (*BCLASS_QUERY_STATUS)(PVOID,ULONG,PBATTERY_STATUS);
typedef NTSTATUS (*BCLASS_SET_STATUS_NOTIFY)(PVOID,ULONG,PBATTERY_NOTIFY);
typedef NTSTATUS (*BCLASS_SET_INFORMATION)(PVOID,ULONG,BATTERY_SET_INFORMATION_LEVEL,PVOID);
typedef NTSTATUS (*BCLASS_DISABLE_STATUS_NOTIFY)(PVOID);

NTSTATUS BATTERYCLASSAPI BatteryClassInitializeDevice(PBATTERY_MINIPORT_INFO,PVOID*);
NTSTATUS BATTERYCLASSAPI BatteryClassUnload(PVOID);
NTSTATUS BATTERYCLASSAPI BatteryClassIoctl(PVOID,PIRP);
NTSTATUS BATTERYCLASSAPI BatteryClassStatusNotify(PVOID);
#endif /* _WINDOWS_H */

#endif /* _BATCLASS_H */
