Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

199 lines
4.7 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. apmbattp.h
  5. Abstract:
  6. Control Method Battery Miniport Driver
  7. Author:
  8. Ron Mosgrove (Intel)
  9. Environment:
  10. Kernel mode
  11. Revision History:
  12. --*/
  13. #ifndef FAR
  14. #define FAR
  15. #endif
  16. #include <wdm.h>
  17. #include <poclass.h>
  18. //#include "acpiioct.h"
  19. //
  20. // Debug
  21. //
  22. #define DEBUG 1
  23. #if DEBUG
  24. extern ULONG ApmBattDebug;
  25. #define ApmBattPrint(l,m) if(l & ApmBattDebug) DbgPrint m
  26. #else
  27. #define ApmBattPrint(l,m)
  28. #endif
  29. #define APMBATT_LOW 0x00000001
  30. #define APMBATT_NOTE 0x00000002
  31. #define APMBATT_WARN 0x00000004
  32. #define APMBATT_ERROR_ONLY 0x00000008
  33. #define APMBATT_ERROR (APMBATT_ERROR_ONLY | APMBATT_WARN)
  34. #define APMBATT_POWER 0x00000010
  35. #define APMBATT_PNP 0x00000020
  36. #define APMBATT_CM_EXE 0x00000040
  37. #define APMBATT_DATA 0x00000100
  38. #define APMBATT_TRACE 0x00000200
  39. #define APMBATT_BIOS 0x00000400 // Show message to verify BIOS/HW functionality
  40. #define APMBATT_MINI 0x00000800 // Show message to verify miniport retun data
  41. #define MAX_DEVICE_NAME_LENGTH 128
  42. //
  43. // These definitions are for the Technology field of the BATTERY_INFORMATION structure.
  44. // They probably ought to be in the poclass.h file, but they've been here
  45. // a whole release and nothing bad has happened, so leave them here.
  46. //
  47. // BATTERY_INFORMATION.Technology flags
  48. //
  49. #define BATTERY_PRIMARY_NOT_RECHARGABLE 0x00
  50. #define BATTERY_SECONDARY_CHARGABLE 0x01
  51. //
  52. // Use the IoSkipCurrentIrpStackLocation routine because the we
  53. // don't need to change arguments, or a completion routine
  54. //
  55. #define ApmBattCallLowerDriver(Status, DeviceObject, Irp) { \
  56. IoSkipCurrentIrpStackLocation(Irp); \
  57. Status = IoCallDriver(DeviceObject,Irp); \
  58. }
  59. #define GetTid() PsGetCurrentThread()
  60. //
  61. // Pagable device extension for control battery
  62. //
  63. typedef struct _CM_BATT {
  64. ULONG Type; // This must be the first entry
  65. // as it is shared with the AC_ACAPTER
  66. PDEVICE_OBJECT DeviceObject; // Battery device object
  67. PDEVICE_OBJECT Fdo; // Functional Device Object
  68. PDEVICE_OBJECT Pdo; // Physical Device Object
  69. PDEVICE_OBJECT LowerDeviceObject; // Detected at AddDevice time
  70. PVOID Class; // Battery Class handle
  71. BOOLEAN IsStarted; // if non zero, the device is started
  72. BOOLEAN IsCacheValid; // Is cached battery info currently valid?
  73. //
  74. // Selector
  75. //
  76. PVOID Selector; // Selector for battery
  77. //
  78. // Battery
  79. //
  80. ULONG TagCount; // Tag for next battery
  81. PUNICODE_STRING DeviceName;
  82. USHORT DeviceNumber;
  83. } CM_BATT, *PCM_BATT;
  84. //
  85. // Misc globals
  86. //
  87. extern PVOID ApmGlobalClass;
  88. extern ULONG DeviceCount;
  89. extern ULONG TagValue;
  90. extern ULONG (*NtApmGetBatteryLevel)();
  91. //
  92. // Prototypes
  93. //
  94. NTSTATUS
  95. ApmBattPnpDispatch(
  96. IN PDEVICE_OBJECT DeviceObject,
  97. IN PIRP Irp
  98. );
  99. NTSTATUS
  100. ApmBattPowerDispatch(
  101. IN PDEVICE_OBJECT DeviceObject,
  102. IN PIRP Irp
  103. );
  104. NTSTATUS
  105. ApmBattForwardRequest(
  106. IN PDEVICE_OBJECT DeviceObject,
  107. IN PIRP Irp
  108. );
  109. NTSTATUS
  110. ApmBattAddDevice(
  111. IN PDRIVER_OBJECT DriverObject,
  112. IN PDEVICE_OBJECT Pdo
  113. );
  114. NTSTATUS
  115. ApmBattQueryTag (
  116. IN PVOID Context,
  117. OUT PULONG BatteryTag
  118. );
  119. NTSTATUS
  120. ApmBattSetStatusNotify (
  121. IN PVOID Context,
  122. IN ULONG BatteryTag,
  123. IN PBATTERY_NOTIFY BatteryNotify
  124. );
  125. NTSTATUS
  126. ApmBattDisableStatusNotify (
  127. IN PVOID Context
  128. );
  129. NTSTATUS
  130. ApmBattQueryStatus (
  131. IN PVOID Context,
  132. IN ULONG BatteryTag,
  133. OUT PBATTERY_STATUS BatteryStatus
  134. );
  135. NTSTATUS
  136. ApmBattIoCompletion(
  137. IN PDEVICE_OBJECT DeviceObject,
  138. IN PIRP Irp,
  139. IN PKEVENT pdoIoCompletedEvent
  140. );
  141. NTSTATUS
  142. ApmBattQueryInformation (
  143. IN PVOID Context,
  144. IN ULONG BatteryTag,
  145. IN BATTERY_QUERY_INFORMATION_LEVEL Level,
  146. IN ULONG AtRate OPTIONAL,
  147. OUT PVOID Buffer,
  148. IN ULONG BufferLength,
  149. OUT PULONG ReturnedLength
  150. );
  151. VOID
  152. ApmBattPowerNotifyHandler(
  153. VOID
  154. );