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.

434 lines
11 KiB

  1. /*******************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORP., 1993-1994
  4. *
  5. * TITLE: VPOWERD.H
  6. *
  7. * VERSION: 1.0
  8. *
  9. * DATE: 01 Oct 1993
  10. *
  11. * AUTHOR: TCS
  12. *
  13. * Definitions for the Virtual Power Management Device.
  14. *
  15. ********************************************************************************
  16. *
  17. * CHANGE LOG:
  18. *
  19. * DATE REV DESCRIPTION
  20. * ----------- --- -------------------------------------------------------------
  21. * 01 Oct 1993 TCS Original implementation.
  22. *
  23. *******************************************************************************/
  24. #ifndef _INC_VPOWERD
  25. #define _INC_VPOWERD
  26. #ifndef Not_VxD
  27. //
  28. // Virtual Power Management Device service table.
  29. //
  30. /*XLATOFF*/
  31. #define VPOWERD_Service Declare_Service
  32. /*XLATON*/
  33. /*MACROS*/
  34. Begin_Service_Table(VPOWERD, VxD)
  35. VPOWERD_Service (_VPOWERD_Get_Version, VxD_PAGEABLE_CODE)
  36. VPOWERD_Service (_VPOWERD_Get_APM_BIOS_Version, VxD_PAGEABLE_CODE)
  37. VPOWERD_Service (_VPOWERD_Get_Power_Management_Level, VxD_PAGEABLE_CODE)
  38. VPOWERD_Service (_VPOWERD_Set_Power_Management_Level, VxD_PAGEABLE_CODE)
  39. VPOWERD_Service (_VPOWERD_Set_Device_Power_State, VxD_PAGEABLE_CODE)
  40. VPOWERD_Service (_VPOWERD_Set_System_Power_State, VxD_LOCKED_CODE)
  41. VPOWERD_Service (_VPOWERD_Restore_Power_On_Defaults, VxD_PAGEABLE_CODE)
  42. VPOWERD_Service (_VPOWERD_Get_Power_Status, VxD_PAGEABLE_CODE)
  43. VPOWERD_Service (_VPOWERD_Get_Power_State, VxD_PAGEABLE_CODE)
  44. VPOWERD_Service (_VPOWERD_OEM_APM_Function, VxD_PAGEABLE_CODE)
  45. VPOWERD_Service (_VPOWERD_Register_Power_Handler, VxD_PAGEABLE_CODE)
  46. VPOWERD_Service (_VPOWERD_Deregister_Power_Handler, VxD_PAGEABLE_CODE)
  47. VPOWERD_Service (_VPOWERD_W32_Get_System_Power_Status, VxD_PAGEABLE_CODE)
  48. VPOWERD_Service (_VPOWERD_W32_Set_System_Power_State, VxD_PAGEABLE_CODE)
  49. End_Service_Table(VPOWERD, VxD)
  50. /*ENDMACROS*/
  51. #endif
  52. /*XLATOFF*/
  53. #ifdef IS_32
  54. #define POWERFAR
  55. #else
  56. #define POWERFAR _far
  57. #endif
  58. /*XLATON*/
  59. //
  60. // Standard return type from VPOWERD services and handlers.
  61. //
  62. // Error codes 0x00000001 through 0x000000FF are reserved for APM firmware
  63. // errors.
  64. //
  65. // Error codes above 0x80000000 are reserved for definition by VPOWERD.
  66. //
  67. typedef DWORD POWERRET;
  68. #define PR_SUCCESS 0x00000000
  69. #define PR_PM_DISABLED 0x00000001
  70. #define PR_RM_CONNECT_EXISTS 0x00000002
  71. #define PR_INTERFACE_NOT_CONNECTED 0x00000003
  72. #define PR_16BIT_PM_CONNECT_EXISTS 0x00000005
  73. #define PR_16BIT_PM_UNSUPPORTED 0x00000006
  74. #define PR_32BIT_PM_CONNECT_EXISTS 0x00000007
  75. #define PR_32BIT_PM_UNSUPPORTED 0x00000008
  76. #define PR_UNRECOGNIZED_DEVICE_ID 0x00000009
  77. #define PR_PARAMETER_OUT_OF_RANGE 0x0000000A
  78. #define PR_INTERFACE_NOT_ENGAGED 0x0000000B
  79. #define PR_CANNOT_ENTER_STATE 0x00000060
  80. #define PR_NO_PM_EVENTS_PENDING 0x00000080
  81. #define PR_APM_NOT_PRESENT 0x00000086
  82. #define PR_UNDEFINED_FUNCTION 0x000000FF
  83. #define PR_DEFAULT 0x80000000
  84. #define PR_FAILURE 0x80000001
  85. #define PR_REQUEST_VETOED 0x80000002
  86. #define PR_INVALID_POINTER 0x80000003
  87. #define PR_INVALID_FLAG 0x80000004
  88. #define PR_INVALID_PMLEVEL 0x80000005
  89. #define PR_INVALID_DEVICE_ID 0x80000006
  90. #define PR_INVALID_POWER_STATE 0x80000007
  91. #define PR_INVALID_REQUEST_TYPE 0x80000008
  92. #define PR_OUT_OF_MEMORY 0x80000009
  93. #define PR_DUPLICATE_POWER_HANDLER 0x8000000A
  94. #define PR_POWER_HANDLER_NOT_FOUND 0x8000000B
  95. #define PR_INVALID_FUNCTION 0x8000000C
  96. //
  97. // Power device ID type and standard IDs as defined by the APM 1.1
  98. // specification.
  99. //
  100. typedef DWORD POWER_DEVICE_ID;
  101. #define PDI_APM_BIOS 0x0000
  102. #define PDI_MANAGED_BY_APM_BIOS 0x0001
  103. #define PDI_MANAGED_BY_APM_BIOS_OLD 0xFFFF
  104. //
  105. // Power state type and standard power states as defined by the APM 1.1
  106. // specification.
  107. //
  108. typedef DWORD POWER_STATE;
  109. typedef POWER_STATE POWERFAR* LPPOWER_STATE;
  110. #define PSTATE_APM_ENABLED 0x0000
  111. #define PSTATE_STANDBY 0x0001
  112. #define PSTATE_SUSPEND 0x0002
  113. #define PSTATE_OFF 0x0003
  114. //
  115. // Valid power management levels.
  116. //
  117. #define PMLEVEL_ADVANCED 0
  118. #define PMLEVEL_STANDARD 1
  119. #define PMLEVEL_OFF 2
  120. #define PMLEVEL_MAXIMUM PMLEVEL_OFF
  121. //
  122. // Valid request types.
  123. //
  124. #define REQTYPE_USER_INITIATED 0x00000000
  125. #define REQTYPE_TIMER_INITIATED 0x00000001
  126. #define REQTYPE_FORCED_REQUEST 0x00000002
  127. #define REQTYPE_BIOS_CRITICAL_SUSPEND 0x00000003
  128. #define REQTYPE_FROM_BIOS_FLAG 0x80000000 // ;Internal
  129. //
  130. // Power status structures returned by _VPOWERD_Get_Power_Status and
  131. // _VPOWERD_W32_Get_Power_Status.
  132. //
  133. #ifndef NOPOWERSTATUSDEFINES
  134. #define AC_LINE_OFFLINE 0x00
  135. #define AC_LINE_ONLINE 0x01
  136. #define AC_LINE_BACKUP_POWER 0x02
  137. #define AC_LINE_UNKNOWN 0xFF
  138. #define BATTERY_STATUS_HIGH 0x00
  139. #define BATTERY_STATUS_LOW 0x01
  140. #define BATTERY_STATUS_CRITICAL 0x02
  141. #define BATTERY_STATUS_CHARGING 0x03
  142. #define BATTERY_STATUS_UNKNOWN 0xFF
  143. #define BATTERY_FLAG_HIGH 0x01
  144. #define BATTERY_FLAG_LOW 0x02
  145. #define BATTERY_FLAG_CRITICAL 0x04
  146. #define BATTERY_FLAG_CHARGING 0x08
  147. #define BATTERY_FLAG_NO_BATTERY 0x80
  148. #define BATTERY_FLAG_UNKNOWN 0xFF
  149. #define BATTERY_PERCENTAGE_UNKNOWN 0xFF
  150. #define BATTERY_LIFE_MINUTES_MASK 0x8000
  151. #define BATTERY_LIFE_UNKNOWN 0xFFFF
  152. #define BATTERY_LIFE_W32_UNKNOWN 0xFFFFFFFF
  153. #endif // NOPOWERSTATUSDEFINES
  154. typedef struct _POWER_STATUS {
  155. BYTE PS_AC_Line_Status;
  156. BYTE PS_Battery_Status;
  157. BYTE PS_Battery_Flag;
  158. BYTE PS_Battery_Life_Percentage;
  159. WORD PS_Battery_Life_Time;
  160. } POWER_STATUS;
  161. typedef POWER_STATUS POWERFAR* LPPOWER_STATUS;
  162. typedef struct _WIN32_SYSTEM_POWER_STATUS {
  163. BYTE W32PS_AC_Line_Status;
  164. BYTE W32PS_Battery_Flag;
  165. BYTE W32PS_Battery_Life_Percent;
  166. BYTE W32PS_Reserved1;
  167. DWORD W32PS_Battery_Life_Time;
  168. DWORD W32PS_Battery_Full_Life_Time;
  169. } WIN32_SYSTEM_POWER_STATUS;
  170. typedef WIN32_SYSTEM_POWER_STATUS POWERFAR* LPWIN32_SYSTEM_POWER_STATUS;
  171. //
  172. // OEM APM Register Structure used by _VPOWERD_OEM_APM_Function.
  173. //
  174. struct _OEM_APM_BYTE_REGS {
  175. WORD OEMAPM_Reserved1[6];
  176. BYTE OEMAPM_BL;
  177. BYTE OEMAPM_BH;
  178. WORD OEMAPM_Reserved2;
  179. BYTE OEMAPM_DL;
  180. BYTE OEMAPM_DH;
  181. WORD OEMAPM_Reserved3;
  182. BYTE OEMAPM_CL;
  183. BYTE OEMAPM_CH;
  184. WORD OEMAPM_Reserved4;
  185. BYTE OEMAPM_AL;
  186. BYTE OEMAPM_AH;
  187. WORD OEMAPM_Reserved5;
  188. BYTE OEMAPM_Flags;
  189. BYTE OEMAPM_Reserved6[3];
  190. };
  191. struct _OEM_APM_WORD_REGS {
  192. WORD OEMAPM_DI;
  193. WORD OEMAPM_Reserved7;
  194. WORD OEMAPM_SI;
  195. WORD OEMAPM_Reserved8;
  196. WORD OEMAPM_BP;
  197. WORD OEMAPM_Reserved9;
  198. WORD OEMAPM_BX;
  199. WORD OEMAPM_Reserved10;
  200. WORD OEMAPM_DX;
  201. WORD OEMAPM_Reserved11;
  202. WORD OEMAPM_CX;
  203. WORD OEMAPM_Reserved12;
  204. WORD OEMAPM_AX;
  205. WORD OEMAPM_Reserved13[3];
  206. };
  207. struct _OEM_APM_DWORD_REGS {
  208. DWORD OEMAPM_EDI;
  209. DWORD OEMAPM_ESI;
  210. DWORD OEMAPM_EBP;
  211. DWORD OEMAPM_EBX;
  212. DWORD OEMAPM_EDX;
  213. DWORD OEMAPM_ECX;
  214. DWORD OEMAPM_EAX;
  215. DWORD OEMAPM_Reserved14;
  216. };
  217. typedef union _OEM_APM_REGS {
  218. struct _OEM_APM_BYTE_REGS ByteRegs;
  219. struct _OEM_APM_WORD_REGS WordRegs;
  220. struct _OEM_APM_DWORD_REGS DwordRegs;
  221. } OEM_APM_REGS;
  222. typedef OEM_APM_REGS POWERFAR* LPOEM_APM_REGS;
  223. //
  224. // Possible power function codes that are sent to POWER_HANDLER callbacks.
  225. //
  226. typedef DWORD POWERFUNC;
  227. #define PF_SUSPEND_PHASE1 0x00000000
  228. #define PF_SUSPEND_PHASE2 0x00000001
  229. #define PF_SUSPEND_INTS_OFF 0x00000002
  230. #define PF_RESUME_INTS_OFF 0x00000003
  231. #define PF_RESUME_PHASE2 0x00000004
  232. #define PF_RESUME_PHASE1 0x00000005
  233. #define PF_BATTERY_LOW 0x00000006
  234. #define PF_POWER_STATUS_CHANGE 0x00000007
  235. #define PF_UPDATE_TIME 0x00000008
  236. #define PF_APMOEMEVENT_FIRST 0x00000200
  237. #define PF_APMOEMEVENT_LAST 0x000002FF
  238. //
  239. //
  240. //
  241. #define PFG_UI_ALLOWED 0x00000001
  242. #define PFG_CANNOT_FAIL 0x00000002
  243. #define PFG_REQUEST_VETOED 0x00000004
  244. #define PFG_REVERSE 0x00000008
  245. #define PFG_STANDBY 0x00000010
  246. #define PFG_CRITICAL 0x00000020
  247. //
  248. // Standard POWER_HANDLER priority levels.
  249. //
  250. #define PHPL_PBT_BROADCAST 0x40000000
  251. #define PHPL_UNKNOWN 0x80000000
  252. #define PHPL_CONFIGMG 0xC0000000
  253. #define PHPL_TIMER 0xE0000000
  254. //
  255. //
  256. //
  257. typedef POWERRET (*POWER_HANDLER)(POWERFUNC, DWORD);
  258. //
  259. // VPOWERD BroadcastSystemMessage API parameter blocks.
  260. //
  261. typedef struct _VPOWERD_BSMAPI_HEADER {
  262. DWORD VBAPIH_Packet_Size;
  263. WORD VBAPIH_Function;
  264. DWORD VBAPIH_Return_Code;
  265. } VPOWERD_BSMAPI_HEADER;
  266. #define VBAPIF_W32_SET_SYSTEM_STATE 0x000D
  267. typedef struct _VPOWERD_BSMAPI_W32_SET_SYSTEM_STATE {
  268. struct _VPOWERD_BSMAPI_HEADER VBWSSS_VBAPIH;
  269. DWORD VBWSSS_Force_Flag;
  270. } VPOWERD_BSMAPI_W32_SET_SYSTEM_STATE;
  271. //
  272. // Virtual Power Management Device service prototypes.
  273. //
  274. /*XLATOFF*/
  275. BOOL
  276. POWERFAR CDECL
  277. VPOWERD_Get_Entry_Point(
  278. VOID
  279. );
  280. DWORD
  281. POWERFAR CDECL
  282. _VPOWERD_Get_Version(
  283. VOID
  284. );
  285. DWORD
  286. POWERFAR CDECL
  287. _VPOWERD_Get_APM_BIOS_Version(
  288. VOID
  289. );
  290. DWORD
  291. POWERFAR CDECL
  292. _VPOWERD_Get_Power_Management_Level(
  293. VOID
  294. );
  295. POWERRET
  296. POWERFAR CDECL
  297. _VPOWERD_Set_Power_Management_Level(
  298. DWORD Power_Management_Level
  299. );
  300. POWERRET
  301. POWERFAR CDECL
  302. _VPOWERD_Set_Device_Power_State(
  303. POWER_DEVICE_ID Power_Device_ID,
  304. POWER_STATE Power_State
  305. );
  306. POWERRET
  307. POWERFAR CDECL
  308. _VPOWERD_Set_System_Power_State(
  309. POWER_STATE Power_State,
  310. DWORD Request_Type
  311. );
  312. POWERRET
  313. POWERFAR CDECL
  314. _VPOWERD_Restore_Power_On_Defaults(
  315. VOID
  316. );
  317. POWERRET
  318. POWERFAR CDECL
  319. _VPOWERD_Get_Power_Status(
  320. POWER_DEVICE_ID Power_Device_ID,
  321. LPPOWER_STATUS lpPower_Status
  322. );
  323. POWERRET
  324. POWERFAR CDECL
  325. _VPOWERD_Get_Power_State(
  326. POWER_DEVICE_ID Power_Device_ID,
  327. LPPOWER_STATE lpPower_State
  328. );
  329. POWERRET
  330. POWERFAR CDECL
  331. _VPOWERD_OEM_APM_Function(
  332. LPOEM_APM_REGS lpOEM_APM_Regs
  333. );
  334. POWERRET
  335. POWERFAR CDECL
  336. _VPOWERD_Register_Power_Handler(
  337. POWER_HANDLER Power_Handler,
  338. DWORD Priority
  339. );
  340. POWERRET
  341. POWERFAR CDECL
  342. _VPOWERD_Deregister_Power_Handler(
  343. POWER_HANDLER Power_Handler
  344. );
  345. BOOL
  346. POWERFAR CDECL
  347. _VPOWERD_W32_Get_System_Power_Status(
  348. LPWIN32_SYSTEM_POWER_STATUS lpWin32_System_Power_Status
  349. );
  350. DWORD
  351. POWERFAR CDECL
  352. _VPOWERD_W32_Set_System_Power_State(
  353. BOOL Suspend_Flag,
  354. BOOL Force_Flag
  355. );
  356. /*XLATON*/
  357. #endif // _INC_VPOWERD