Leaked source code of windows server 2003
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.

217 lines
4.0 KiB

  1. /*++
  2. Copyright (c) 1997-1998 Microsoft Corporation
  3. Module Name:
  4. ntapm.h
  5. Abstract:
  6. Author:
  7. Environment:
  8. kernel mode only
  9. Notes:
  10. Revision History:
  11. --*/
  12. #include <ntapmsdk.h>
  13. #define APM_INSTANCE_IDS L"0000"
  14. #define APM_INSTANCE_IDS_LENGTH 5
  15. #define NTAPM_PDO_NAME_APM_BATTERY L"\\Device\\NtApm_ApmBattery"
  16. #define NTAPM_ID_APM_BATTERY L"NTAPM\\APMBATT\0\0"
  17. #define NTAPM_POOL_TAG (ULONG) ' MPA'
  18. #undef ExAllocatePool
  19. #define ExAllocatePool(type, size) \
  20. ExAllocatePoolWithTag (type, size, NTAPM_POOL_TAG);
  21. extern PDRIVER_OBJECT NtApmDriverObject;
  22. //
  23. // A common header for the device extensions of the PDOs and FDO
  24. //
  25. typedef struct _COMMON_DEVICE_DATA
  26. {
  27. PDEVICE_OBJECT Self;
  28. // A backpointer to the device object for which this is the extension
  29. CHAR Reserved[3];
  30. BOOLEAN IsFDO;
  31. // A boolean to distringuish between PDO and FDO.
  32. } COMMON_DEVICE_DATA, *PCOMMON_DEVICE_DATA;
  33. //
  34. // The device extension for the PDOs.
  35. // That is the game ports of which this bus driver enumerates.
  36. // (IE there is a PDO for the 201 game port).
  37. //
  38. typedef struct _PDO_DEVICE_DATA
  39. {
  40. COMMON_DEVICE_DATA;
  41. PDEVICE_OBJECT ParentFdo;
  42. // A back pointer to the bus
  43. PWCHAR HardwareIDs;
  44. // An array of (zero terminated wide character strings).
  45. // The array itself also null terminated
  46. ULONG UniqueID;
  47. // Globally unique id in the system
  48. } PDO_DEVICE_DATA, *PPDO_DEVICE_DATA;
  49. //
  50. // The device extension of the bus itself. From whence the PDO's are born.
  51. //
  52. typedef struct _FDO_DEVICE_DATA
  53. {
  54. COMMON_DEVICE_DATA;
  55. PDEVICE_OBJECT UnderlyingPDO;
  56. PDEVICE_OBJECT TopOfStack;
  57. // the underlying bus PDO and the actual device object to which our
  58. // FDO is attached
  59. } FDO_DEVICE_DATA, *PFDO_DEVICE_DATA;
  60. NTSTATUS
  61. ApmAddHelper();
  62. NTSTATUS
  63. NtApm_AddDevice(
  64. IN PDRIVER_OBJECT DriverObject,
  65. IN PDEVICE_OBJECT BusPhysicalDeviceObject
  66. );
  67. NTSTATUS
  68. NtApm_PnP (
  69. IN PDEVICE_OBJECT DeviceObject,
  70. IN PIRP Irp
  71. );
  72. NTSTATUS
  73. NtApm_FDO_PnP (
  74. IN PDEVICE_OBJECT DeviceObject,
  75. IN PIRP Irp,
  76. IN PIO_STACK_LOCATION IrpStack,
  77. IN PFDO_DEVICE_DATA DeviceData
  78. );
  79. NTSTATUS
  80. NtApm_PDO_PnP (
  81. IN PDEVICE_OBJECT DeviceObject,
  82. IN PIRP Irp,
  83. IN PIO_STACK_LOCATION IrpStack,
  84. IN PPDO_DEVICE_DATA DeviceData
  85. );
  86. NTSTATUS
  87. NtApm_StartFdo (
  88. IN PFDO_DEVICE_DATA FdoData,
  89. IN PCM_PARTIAL_RESOURCE_LIST PartialResourceList,
  90. IN PCM_PARTIAL_RESOURCE_LIST PartialResourceListTranslated
  91. );
  92. NTSTATUS
  93. NtApm_Power (
  94. IN PDEVICE_OBJECT DeviceObject,
  95. IN PIRP Irp
  96. );
  97. NTSTATUS
  98. NtApm_FDO_Power (
  99. PFDO_DEVICE_DATA Data,
  100. PIRP Irp
  101. );
  102. NTSTATUS
  103. NtApm_PDO_Power (
  104. PPDO_DEVICE_DATA PdoData,
  105. PIRP Irp
  106. );
  107. NTSTATUS
  108. NtApm_CreatePdo (
  109. PFDO_DEVICE_DATA FdoData,
  110. PWCHAR PdoName,
  111. PDEVICE_OBJECT * PDO
  112. );
  113. VOID
  114. NtApm_InitializePdo(
  115. PDEVICE_OBJECT Pdo,
  116. PFDO_DEVICE_DATA FdoData,
  117. PWCHAR Id
  118. );
  119. VOID
  120. ApmInProgress();
  121. ULONG
  122. DoApmReportBatteryStatus();
  123. //
  124. // APM extractor values
  125. //
  126. //
  127. // APM_GET_POWER_STATUS
  128. //
  129. //
  130. // EBX
  131. // BH = Ac Line Status
  132. //
  133. #define APM_LINEMASK 0xff00
  134. #define APM_LINEMASK_SHIFT 8
  135. #define APM_GET_LINE_OFFLINE 0
  136. #define APM_GET_LINE_ONLINE 1
  137. #define APM_GET_LINE_BACKUP 2
  138. #define APM_GET_LINE_UNKNOWN 0xff
  139. //
  140. // ECX
  141. // CL = Percentage remaining
  142. // CH = flags
  143. //
  144. #define APM_PERCENT_MASK 0xff
  145. #define APM_BATT_HIGH 0x0100
  146. #define APM_BATT_LOW 0x0200
  147. #define APM_BATT_CRITICAL 0x0400
  148. #define APM_BATT_CHARGING 0x0800
  149. #define APM_NO_BATT 0x1000
  150. #define APM_NO_SYS_BATT 0x8000