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.

582 lines
15 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. // APM 1.2 services
  50. VPOWERD_Service (_VPOWERD_Get_Capabilities, VxD_PAGEABLE_CODE)
  51. VPOWERD_Service (_VPOWERD_Enable_Resume_On_Ring, VxD_PAGEABLE_CODE)
  52. VPOWERD_Service (_VPOWERD_Disable_Resume_On_Ring, VxD_PAGEABLE_CODE)
  53. VPOWERD_Service (_VPOWERD_Set_Resume_Timer, VxD_PAGEABLE_CODE)
  54. VPOWERD_Service (_VPOWERD_Get_Resume_Timer, VxD_PAGEABLE_CODE)
  55. VPOWERD_Service (_VPOWERD_Disable_Resume_Timer, VxD_PAGEABLE_CODE)
  56. VPOWERD_Service (_VPOWERD_Enable_Timer_Based_Requests, VxD_PAGEABLE_CODE)
  57. VPOWERD_Service (_VPOWERD_Disable_Timer_Based_Requests, VxD_PAGEABLE_CODE)
  58. VPOWERD_Service (_VPOWERD_W32_Get_Power_Status, VxD_PAGEABLE_CODE)
  59. VPOWERD_Service (_VPOWERD_Get_Timer_Based_Requests_Status, VxD_PAGEABLE_CODE)
  60. VPOWERD_Service (_VPOWERD_Get_Ring_Resume_Status, VxD_PAGEABLE_CODE)
  61. End_Service_Table(VPOWERD, VxD)
  62. /*ENDMACROS*/
  63. #endif
  64. /*XLATOFF*/
  65. #ifdef IS_32
  66. #define POWERFAR
  67. #else
  68. #define POWERFAR _far
  69. #endif
  70. /*XLATON*/
  71. //
  72. // Standard return type from VPOWERD services and handlers.
  73. //
  74. // Error codes 0x00000001 through 0x000000FF are reserved for APM firmware
  75. // errors.
  76. //
  77. // Error codes above 0x80000000 are reserved for definition by VPOWERD
  78. //
  79. typedef DWORD POWERRET;
  80. #define PR_SUCCESS 0x00000000
  81. #define PR_PM_DISABLED 0x00000001
  82. #define PR_RM_CONNECT_EXISTS 0x00000002
  83. #define PR_INTERFACE_NOT_CONNECTED 0x00000003
  84. #define PR_16BIT_PM_CONNECT_EXISTS 0x00000005
  85. #define PR_16BIT_PM_UNSUPPORTED 0x00000006
  86. #define PR_32BIT_PM_CONNECT_EXISTS 0x00000007
  87. #define PR_32BIT_PM_UNSUPPORTED 0x00000008
  88. #define PR_UNRECOGNIZED_DEVICE_ID 0x00000009
  89. #define PR_PARAMETER_OUT_OF_RANGE 0x0000000A
  90. #define PR_INTERFACE_NOT_ENGAGED 0x0000000B
  91. // APM 1.2 error codes
  92. #define PR_FUNC_NOT_SUPPORTED 0x0000000C
  93. #define PR_RESUME_TIMER_DISABLED 0x0000000D
  94. // end
  95. #define PR_CANNOT_ENTER_STATE 0x00000060
  96. #define PR_NO_PM_EVENTS_PENDING 0x00000080
  97. #define PR_APM_NOT_PRESENT 0x00000086
  98. #define PR_UNDEFINED_FUNCTION 0x000000FF
  99. #define PR_DEFAULT 0x80000000
  100. #define PR_FAILURE 0x80000001
  101. #define PR_REQUEST_VETOED 0x80000002
  102. #define PR_INVALID_POINTER 0x80000003
  103. #define PR_INVALID_FLAG 0x80000004
  104. #define PR_INVALID_PMLEVEL 0x80000005
  105. #define PR_INVALID_DEVICE_ID 0x80000006
  106. #define PR_INVALID_POWER_STATE 0x80000007
  107. #define PR_INVALID_REQUEST_TYPE 0x80000008
  108. #define PR_OUT_OF_MEMORY 0x80000009
  109. #define PR_DUPLICATE_POWER_HANDLER 0x8000000A
  110. #define PR_POWER_HANDLER_NOT_FOUND 0x8000000B
  111. #define PR_INVALID_FUNCTION 0x8000000C
  112. //
  113. // Power device ID type and standard IDs as defined by the APM 1.1
  114. // specification.
  115. //
  116. typedef DWORD POWER_DEVICE_ID;
  117. #define PDI_APM_BIOS 0x0000
  118. #define PDI_MANAGED_BY_APM_BIOS 0x0001
  119. #define PDI_MANAGED_BY_APM_BIOS_OLD 0xFFFF
  120. // APM 1.2
  121. #define PDI_SPECIFIC_BATTERY 0x8000 // OR in the 1 based battery unit number
  122. // end
  123. //
  124. // Power state type and standard power states as defined by the APM 1.1
  125. // specification.
  126. //
  127. typedef DWORD POWER_STATE;
  128. typedef POWER_STATE POWERFAR* LPPOWER_STATE;
  129. #define PSTATE_APM_ENABLED 0x0000
  130. #define PSTATE_STANDBY 0x0001
  131. #define PSTATE_SUSPEND 0x0002
  132. #define PSTATE_OFF 0x0003
  133. // APM 1.2
  134. #define PSTATE_HIBERNATE 0x0006
  135. // end
  136. //
  137. // Valid power management levels.
  138. //
  139. #define PMLEVEL_ADVANCED 0
  140. #define PMLEVEL_STANDARD 1
  141. #define PMLEVEL_OFF 2
  142. #define PMLEVEL_MAXIMUM PMLEVEL_OFF
  143. //
  144. // Valid request types.
  145. //
  146. #define REQTYPE_USER_INITIATED 0x00000000
  147. #define REQTYPE_TIMER_INITIATED 0x00000001
  148. #define REQTYPE_FORCED_REQUEST 0x00000002
  149. #define REQTYPE_BIOS_CRITICAL_SUSPEND 0x00000003
  150. #define REQTYPE_FROM_BIOS_FLAG 0x80000000 // ;Internal
  151. // valid values for Status returned by Get_Timer_Based_Requests_Status and Get_Ring_Resume_Status
  152. #define CAPABILITY_ENABLED 0x00000001
  153. #define CAPABILITY_DISABLED 0x00000000
  154. //
  155. // Power status structures returned by _VPOWERD_Get_Power_Status and
  156. // _VPOWERD_W32_Get_Power_Status.
  157. //
  158. #ifndef NOPOWERSTATUSDEFINES
  159. #define AC_LINE_OFFLINE 0x00
  160. #define AC_LINE_ONLINE 0x01
  161. #define AC_LINE_BACKUP_POWER 0x02
  162. #define AC_LINE_UNKNOWN 0xFF
  163. #define BATTERY_STATUS_HIGH 0x00
  164. #define BATTERY_STATUS_LOW 0x01
  165. #define BATTERY_STATUS_CRITICAL 0x02
  166. #define BATTERY_STATUS_CHARGING 0x03
  167. #define BATTERY_STATUS_UNKNOWN 0xFF
  168. #define BATTERY_FLAG_HIGH 0x01
  169. #define BATTERY_FLAG_LOW 0x02
  170. #define BATTERY_FLAG_CRITICAL 0x04
  171. #define BATTERY_FLAG_CHARGING 0x08
  172. // APM 1.2
  173. #define BATTERY_NOT_PRESENT 0x10
  174. // end
  175. #define BATTERY_FLAG_NO_BATTERY 0x80
  176. #define BATTERY_FLAG_UNKNOWN 0xFF
  177. #define BATTERY_PERCENTAGE_UNKNOWN 0xFF
  178. #define BATTERY_LIFE_MINUTES_MASK 0x8000
  179. #define BATTERY_LIFE_UNKNOWN 0xFFFF
  180. #define BATTERY_LIFE_W32_UNKNOWN 0xFFFFFFFF
  181. #endif // NOPOWERSTATUSDEFINES
  182. typedef struct _POWER_STATUS {
  183. BYTE PS_AC_Line_Status;
  184. BYTE PS_Battery_Status;
  185. BYTE PS_Battery_Flag;
  186. BYTE PS_Battery_Life_Percentage;
  187. WORD PS_Battery_Life_Time;
  188. } POWER_STATUS;
  189. typedef POWER_STATUS POWERFAR* LPPOWER_STATUS;
  190. typedef struct _POWERTIME { // st
  191. WORD Year;
  192. WORD Month;
  193. WORD DayOfWeek;
  194. WORD Day;
  195. WORD Hour;
  196. WORD Minute;
  197. WORD Second;
  198. WORD Milliseconds;
  199. } POWERTIME;
  200. typedef POWERTIME POWERFAR* LPPOWERTIME;
  201. typedef struct APM_CAPABILITIES_S {
  202. WORD Capabilities;
  203. BYTE BatteryCount;
  204. BYTE Reserved;
  205. }APM_CAPABILITIES, *PAPM_CAPABILITIES;
  206. /*
  207. Capability flags
  208. Bit 0 = 1 System can enter global standby state. Indicates BIOS will post standby and standby-resume events.
  209. Bit 1 = 1 System can enter global suspend state. Indicates BIOS will post suspend and suspend-resume events.
  210. Bit 2 = 1 Resume timer will wake up from standby.
  211. Bit 3 = 1 Resume timer will wake up from suspend.
  212. Bit 4 = 1 Resume on ring indicator (internal COM or modem) will wake up from standby.
  213. Bit 5 = 1 Resume on ring indicator (internal COM or modem) will wake up from suspend.
  214. Bit 6 = 1 PCMCIA Ring indicator will wake up from standby.
  215. Bit 7 = 1 PCMCIA Ring indicator will wake up from suspend.
  216. Other bits Reserved (must be set to 0)
  217. */
  218. #define GLOBAL_STANDBY_SUPPORTED_BIT 0
  219. #define GLOBAL_STANDBY_SUPPORTED (1 << GLOBAL_STANDBY_SUPPORTED_BIT)
  220. #define GLOBAL_SUSPEND_SUPPORTED_BIT 1
  221. #define GLOBAL_SUSPEND_SUPPORTED (1 << GLOBAL_SUSPEND_SUPPORTED_BIT)
  222. #define WAKE_ON_TIMER_STANDBY_BIT 2
  223. #define WAKE_ON_TIMER_STANDBY (1 << WAKE_ON_TIMER_STANDBY_BIT)
  224. #define WAKE_ON_TIMER_SUSPEND_BIT 3
  225. #define WAKE_ON_TIMER_SUSPEND (1 << WAKE_ON_TIMER_SUSPEND_BIT)
  226. #define RING_RESUME_INTERNAL_STANDBY_BIT 4
  227. #define RING_RESUME_INTERNAL_STANDBY (1 << RING_RESUME_INTERNAL_STANDBY_BIT)
  228. #define RING_RESUME_INTERNAL_SUSPEND_BIT 5
  229. #define RING_RESUME_INTERNAL_SUSPEND (1 << RING_RESUME_INTERNAL_SUSPEND_BIT)
  230. #define RING_RESUME_PCMCIA_STANDBY_BIT 6
  231. #define RING_RESUME_PCMCIA_STANDBY (1 << RING_RESUME_PCMCIA_STANDBY_BIT)
  232. #define RING_RESUME_PCMCIA_SUSPEND_BIT 7
  233. #define RING_RESUME_PCMCIA_SUSPEND (1 << RING_RESUME_PCMCIA_SUSPEND_BIT)
  234. typedef struct _WIN32_SYSTEM_POWER_STATUS {
  235. BYTE W32PS_AC_Line_Status;
  236. BYTE W32PS_Battery_Flag;
  237. BYTE W32PS_Battery_Life_Percent;
  238. BYTE W32PS_Reserved1;
  239. DWORD W32PS_Battery_Life_Time;
  240. DWORD W32PS_Battery_Full_Life_Time;
  241. } WIN32_SYSTEM_POWER_STATUS;
  242. typedef WIN32_SYSTEM_POWER_STATUS POWERFAR* LPWIN32_SYSTEM_POWER_STATUS;
  243. //
  244. // OEM APM Register Structure used by _VPOWERD_OEM_APM_Function.
  245. //
  246. struct _OEM_APM_BYTE_REGS {
  247. WORD OEMAPM_Reserved1[6];
  248. BYTE OEMAPM_BL;
  249. BYTE OEMAPM_BH;
  250. WORD OEMAPM_Reserved2;
  251. BYTE OEMAPM_DL;
  252. BYTE OEMAPM_DH;
  253. WORD OEMAPM_Reserved3;
  254. BYTE OEMAPM_CL;
  255. BYTE OEMAPM_CH;
  256. WORD OEMAPM_Reserved4;
  257. BYTE OEMAPM_AL;
  258. BYTE OEMAPM_AH;
  259. WORD OEMAPM_Reserved5;
  260. BYTE OEMAPM_Flags;
  261. BYTE OEMAPM_Reserved6[3];
  262. };
  263. struct _OEM_APM_WORD_REGS {
  264. WORD OEMAPM_DI;
  265. WORD OEMAPM_Reserved7;
  266. WORD OEMAPM_SI;
  267. WORD OEMAPM_Reserved8;
  268. WORD OEMAPM_BP;
  269. WORD OEMAPM_Reserved9;
  270. WORD OEMAPM_BX;
  271. WORD OEMAPM_Reserved10;
  272. WORD OEMAPM_DX;
  273. WORD OEMAPM_Reserved11;
  274. WORD OEMAPM_CX;
  275. WORD OEMAPM_Reserved12;
  276. WORD OEMAPM_AX;
  277. WORD OEMAPM_Reserved13[3];
  278. };
  279. struct _OEM_APM_DWORD_REGS {
  280. DWORD OEMAPM_EDI;
  281. DWORD OEMAPM_ESI;
  282. DWORD OEMAPM_EBP;
  283. DWORD OEMAPM_EBX;
  284. DWORD OEMAPM_EDX;
  285. DWORD OEMAPM_ECX;
  286. DWORD OEMAPM_EAX;
  287. DWORD OEMAPM_Reserved14;
  288. };
  289. typedef union _OEM_APM_REGS {
  290. struct _OEM_APM_BYTE_REGS ByteRegs;
  291. struct _OEM_APM_WORD_REGS WordRegs;
  292. struct _OEM_APM_DWORD_REGS DwordRegs;
  293. } OEM_APM_REGS;
  294. typedef OEM_APM_REGS POWERFAR* LPOEM_APM_REGS;
  295. //
  296. // Possible power function codes that are sent to POWER_HANDLER callbacks.
  297. //
  298. typedef DWORD POWERFUNC;
  299. #define PF_SUSPEND_PHASE1 0x00000000
  300. #define PF_SUSPEND_PHASE2 0x00000001
  301. #define PF_SUSPEND_INTS_OFF 0x00000002
  302. #define PF_RESUME_INTS_OFF 0x00000003
  303. #define PF_RESUME_PHASE2 0x00000004
  304. #define PF_RESUME_PHASE1 0x00000005
  305. #define PF_BATTERY_LOW 0x00000006
  306. #define PF_POWER_STATUS_CHANGE 0x00000007
  307. #define PF_UPDATE_TIME 0x00000008
  308. #define PF_CAPABILITIES_CHANGE 0x00000009
  309. #define PF_APMOEMEVENT_FIRST 0x00000200
  310. #define PF_APMOEMEVENT_LAST 0x000002FF
  311. //
  312. //
  313. //
  314. #define PFG_UI_ALLOWED 0x00000001
  315. #define PFG_CANNOT_FAIL 0x00000002
  316. #define PFG_REQUEST_VETOED 0x00000004
  317. #define PFG_REVERSE 0x00000008
  318. #define PFG_STANDBY 0x00000010
  319. #define PFG_CRITICAL 0x00000020
  320. #ifdef SUPPORT_HIBERNATE
  321. #define PFG_HIBERNATE 0x00000040 // NEW for APM 1.2
  322. #endif
  323. #define PFG_KEPT_POWER 0x00000080
  324. //
  325. // Standard POWER_HANDLER priority levels.
  326. //
  327. #define PHPL_PBT_BROADCAST 0x40000000
  328. #define PHPL_UNKNOWN 0x80000000
  329. #define PHPL_CONFIGMG 0xC0000000
  330. #define PHPL_TIMER 0xE0000000
  331. //
  332. //
  333. //
  334. typedef POWERRET (*POWER_HANDLER)(POWERFUNC, DWORD);
  335. //
  336. // VPOWERD BroadcastSystemMessage API parameter blocks.
  337. //
  338. typedef struct _VPOWERD_BSMAPI_HEADER {
  339. DWORD VBAPIH_Packet_Size;
  340. WORD VBAPIH_Function;
  341. DWORD VBAPIH_Return_Code;
  342. } VPOWERD_BSMAPI_HEADER;
  343. #define VBAPIF_W32_SET_SYSTEM_STATE 0x000D
  344. typedef struct _VPOWERD_BSMAPI_W32_SET_SYSTEM_STATE {
  345. struct _VPOWERD_BSMAPI_HEADER VBWSSS_VBAPIH;
  346. DWORD VBWSSS_Force_Flag;
  347. } VPOWERD_BSMAPI_W32_SET_SYSTEM_STATE;
  348. //
  349. // Virtual Power Management Device service prototypes.
  350. //
  351. /*XLATOFF*/
  352. BOOL
  353. POWERFAR CDECL
  354. VPOWERD_Get_Entry_Point(
  355. VOID
  356. );
  357. DWORD
  358. POWERFAR CDECL
  359. _VPOWERD_Get_Version(
  360. VOID
  361. );
  362. DWORD
  363. POWERFAR CDECL
  364. _VPOWERD_Get_APM_BIOS_Version(
  365. VOID
  366. );
  367. DWORD
  368. POWERFAR CDECL
  369. _VPOWERD_Get_Power_Management_Level(
  370. VOID
  371. );
  372. POWERRET
  373. POWERFAR CDECL
  374. _VPOWERD_Set_Power_Management_Level(
  375. DWORD Power_Management_Level
  376. );
  377. POWERRET
  378. POWERFAR CDECL
  379. _VPOWERD_Set_Device_Power_State(
  380. POWER_DEVICE_ID Power_Device_ID,
  381. POWER_STATE Power_State
  382. );
  383. POWERRET
  384. POWERFAR CDECL
  385. _VPOWERD_Set_System_Power_State(
  386. POWER_STATE Power_State,
  387. DWORD Request_Type
  388. );
  389. POWERRET
  390. POWERFAR CDECL
  391. _VPOWERD_Restore_Power_On_Defaults(
  392. VOID
  393. );
  394. POWERRET
  395. POWERFAR CDECL
  396. _VPOWERD_Get_Power_Status(
  397. POWER_DEVICE_ID Power_Device_ID,
  398. LPPOWER_STATUS lpPower_Status
  399. );
  400. POWERRET
  401. POWERFAR CDECL
  402. _VPOWERD_Get_Power_State(
  403. POWER_DEVICE_ID Power_Device_ID,
  404. LPPOWER_STATE lpPower_State
  405. );
  406. POWERRET
  407. POWERFAR CDECL
  408. _VPOWERD_OEM_APM_Function(
  409. LPOEM_APM_REGS lpOEM_APM_Regs
  410. );
  411. POWERRET
  412. POWERFAR CDECL
  413. _VPOWERD_Register_Power_Handler(
  414. POWER_HANDLER Power_Handler,
  415. DWORD Priority
  416. );
  417. POWERRET
  418. POWERFAR CDECL
  419. _VPOWERD_Deregister_Power_Handler(
  420. POWER_HANDLER Power_Handler
  421. );
  422. BOOL
  423. POWERFAR CDECL
  424. _VPOWERD_W32_Get_System_Power_Status(
  425. LPWIN32_SYSTEM_POWER_STATUS lpWin32_System_Power_Status
  426. );
  427. DWORD
  428. POWERFAR CDECL
  429. _VPOWERD_W32_Set_System_Power_State(
  430. BOOL Suspend_Flag,
  431. BOOL Force_Flag
  432. );
  433. POWERRET
  434. POWERFAR CDECL
  435. _VPOWERD_Get_Capabilities(
  436. PAPM_CAPABILITIES pAPMCaps
  437. );
  438. POWERRET
  439. POWERFAR CDECL
  440. _VPOWERD_Enable_Resume_On_Ring(
  441. VOID
  442. );
  443. POWERRET
  444. POWERFAR CDECL
  445. _VPOWERD_Disable_Resume_On_Ring(
  446. VOID
  447. );
  448. POWERRET
  449. POWERFAR CDECL
  450. _VPOWERD_Set_Resume_Timer(
  451. LPPOWERTIME pPowerTime
  452. );
  453. POWERRET
  454. POWERFAR CDECL
  455. _VPOWERD_Get_Resume_Timer(
  456. LPPOWERTIME pPowerTime
  457. );
  458. POWERRET
  459. POWERFAR CDECL
  460. _VPOWERD_Disable_Resume_Timer(
  461. VOID
  462. );
  463. POWERRET
  464. POWERFAR CDECL
  465. _VPOWERD_Enable_Timer_Based_Requests(
  466. VOID
  467. );
  468. POWERRET
  469. POWERFAR CDECL
  470. _VPOWERD_Disable_Timer_Based_Requests(
  471. VOID
  472. );
  473. POWERRET
  474. POWERFAR CDECL
  475. _VPOWERD_W32_Get_Power_Status(
  476. POWER_DEVICE_ID Power_Device_ID,
  477. LPWIN32_SYSTEM_POWER_STATUS lpWin32_System_Power_Status
  478. );
  479. /*XLATON*/
  480. #endif // _INC_VPOWERD