apm_bios.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. #ifndef _LINUX_APM_H
  3. #define _LINUX_APM_H
  4. /*
  5. * Include file for the interface to an APM BIOS
  6. * Copyright 1994-2001 Stephen Rothwell (sfr@canb.auug.org.au)
  7. */
  8. #include <linux/types.h>
  9. typedef unsigned short apm_event_t;
  10. typedef unsigned short apm_eventinfo_t;
  11. struct apm_bios_info {
  12. __u16 version;
  13. __u16 cseg;
  14. __u32 offset;
  15. __u16 cseg_16;
  16. __u16 dseg;
  17. __u16 flags;
  18. __u16 cseg_len;
  19. __u16 cseg_16_len;
  20. __u16 dseg_len;
  21. };
  22. #ifdef __KERNEL__
  23. #define APM_CS (GDT_ENTRY_APMBIOS_BASE * 8)
  24. #define APM_CS_16 (APM_CS + 8)
  25. #define APM_DS (APM_CS_16 + 8)
  26. /* Results of APM Installation Check */
  27. #define APM_16_BIT_SUPPORT 0x0001
  28. #define APM_32_BIT_SUPPORT 0x0002
  29. #define APM_IDLE_SLOWS_CLOCK 0x0004
  30. #define APM_BIOS_DISABLED 0x0008
  31. #define APM_BIOS_DISENGAGED 0x0010
  32. /*
  33. * Data for APM that is persistent across module unload/load
  34. */
  35. struct apm_info {
  36. struct apm_bios_info bios;
  37. unsigned short connection_version;
  38. int get_power_status_broken;
  39. int get_power_status_swabinminutes;
  40. int allow_ints;
  41. int forbid_idle;
  42. int realmode_power_off;
  43. int disabled;
  44. };
  45. /*
  46. * The APM function codes
  47. */
  48. #define APM_FUNC_INST_CHECK 0x5300
  49. #define APM_FUNC_REAL_CONN 0x5301
  50. #define APM_FUNC_16BIT_CONN 0x5302
  51. #define APM_FUNC_32BIT_CONN 0x5303
  52. #define APM_FUNC_DISCONN 0x5304
  53. #define APM_FUNC_IDLE 0x5305
  54. #define APM_FUNC_BUSY 0x5306
  55. #define APM_FUNC_SET_STATE 0x5307
  56. #define APM_FUNC_ENABLE_PM 0x5308
  57. #define APM_FUNC_RESTORE_BIOS 0x5309
  58. #define APM_FUNC_GET_STATUS 0x530a
  59. #define APM_FUNC_GET_EVENT 0x530b
  60. #define APM_FUNC_GET_STATE 0x530c
  61. #define APM_FUNC_ENABLE_DEV_PM 0x530d
  62. #define APM_FUNC_VERSION 0x530e
  63. #define APM_FUNC_ENGAGE_PM 0x530f
  64. #define APM_FUNC_GET_CAP 0x5310
  65. #define APM_FUNC_RESUME_TIMER 0x5311
  66. #define APM_FUNC_RESUME_ON_RING 0x5312
  67. #define APM_FUNC_TIMER 0x5313
  68. /*
  69. * Function code for APM_FUNC_RESUME_TIMER
  70. */
  71. #define APM_FUNC_DISABLE_TIMER 0
  72. #define APM_FUNC_GET_TIMER 1
  73. #define APM_FUNC_SET_TIMER 2
  74. /*
  75. * Function code for APM_FUNC_RESUME_ON_RING
  76. */
  77. #define APM_FUNC_DISABLE_RING 0
  78. #define APM_FUNC_ENABLE_RING 1
  79. #define APM_FUNC_GET_RING 2
  80. /*
  81. * Function code for APM_FUNC_TIMER_STATUS
  82. */
  83. #define APM_FUNC_TIMER_DISABLE 0
  84. #define APM_FUNC_TIMER_ENABLE 1
  85. #define APM_FUNC_TIMER_GET 2
  86. /*
  87. * in arch/i386/kernel/setup.c
  88. */
  89. extern struct apm_info apm_info;
  90. #endif /* __KERNEL__ */
  91. /*
  92. * Power states
  93. */
  94. #define APM_STATE_READY 0x0000
  95. #define APM_STATE_STANDBY 0x0001
  96. #define APM_STATE_SUSPEND 0x0002
  97. #define APM_STATE_OFF 0x0003
  98. #define APM_STATE_BUSY 0x0004
  99. #define APM_STATE_REJECT 0x0005
  100. #define APM_STATE_OEM_SYS 0x0020
  101. #define APM_STATE_OEM_DEV 0x0040
  102. #define APM_STATE_DISABLE 0x0000
  103. #define APM_STATE_ENABLE 0x0001
  104. #define APM_STATE_DISENGAGE 0x0000
  105. #define APM_STATE_ENGAGE 0x0001
  106. /*
  107. * Events (results of Get PM Event)
  108. */
  109. #define APM_SYS_STANDBY 0x0001
  110. #define APM_SYS_SUSPEND 0x0002
  111. #define APM_NORMAL_RESUME 0x0003
  112. #define APM_CRITICAL_RESUME 0x0004
  113. #define APM_LOW_BATTERY 0x0005
  114. #define APM_POWER_STATUS_CHANGE 0x0006
  115. #define APM_UPDATE_TIME 0x0007
  116. #define APM_CRITICAL_SUSPEND 0x0008
  117. #define APM_USER_STANDBY 0x0009
  118. #define APM_USER_SUSPEND 0x000a
  119. #define APM_STANDBY_RESUME 0x000b
  120. #define APM_CAPABILITY_CHANGE 0x000c
  121. /*
  122. * Error codes
  123. */
  124. #define APM_SUCCESS 0x00
  125. #define APM_DISABLED 0x01
  126. #define APM_CONNECTED 0x02
  127. #define APM_NOT_CONNECTED 0x03
  128. #define APM_16_CONNECTED 0x05
  129. #define APM_16_UNSUPPORTED 0x06
  130. #define APM_32_CONNECTED 0x07
  131. #define APM_32_UNSUPPORTED 0x08
  132. #define APM_BAD_DEVICE 0x09
  133. #define APM_BAD_PARAM 0x0a
  134. #define APM_NOT_ENGAGED 0x0b
  135. #define APM_BAD_FUNCTION 0x0c
  136. #define APM_RESUME_DISABLED 0x0d
  137. #define APM_NO_ERROR 0x53
  138. #define APM_BAD_STATE 0x60
  139. #define APM_NO_EVENTS 0x80
  140. #define APM_NOT_PRESENT 0x86
  141. /*
  142. * APM Device IDs
  143. */
  144. #define APM_DEVICE_BIOS 0x0000
  145. #define APM_DEVICE_ALL 0x0001
  146. #define APM_DEVICE_DISPLAY 0x0100
  147. #define APM_DEVICE_STORAGE 0x0200
  148. #define APM_DEVICE_PARALLEL 0x0300
  149. #define APM_DEVICE_SERIAL 0x0400
  150. #define APM_DEVICE_NETWORK 0x0500
  151. #define APM_DEVICE_PCMCIA 0x0600
  152. #define APM_DEVICE_BATTERY 0x8000
  153. #define APM_DEVICE_OEM 0xe000
  154. #define APM_DEVICE_OLD_ALL 0xffff
  155. #define APM_DEVICE_CLASS 0x00ff
  156. #define APM_DEVICE_MASK 0xff00
  157. #ifdef __KERNEL__
  158. /*
  159. * This is the "All Devices" ID communicated to the BIOS
  160. */
  161. #define APM_DEVICE_BALL ((apm_info.connection_version > 0x0100) ? \
  162. APM_DEVICE_ALL : APM_DEVICE_OLD_ALL)
  163. #endif
  164. /*
  165. * Battery status
  166. */
  167. #define APM_MAX_BATTERIES 2
  168. /*
  169. * APM defined capability bit flags
  170. */
  171. #define APM_CAP_GLOBAL_STANDBY 0x0001
  172. #define APM_CAP_GLOBAL_SUSPEND 0x0002
  173. #define APM_CAP_RESUME_STANDBY_TIMER 0x0004 /* Timer resume from standby */
  174. #define APM_CAP_RESUME_SUSPEND_TIMER 0x0008 /* Timer resume from suspend */
  175. #define APM_CAP_RESUME_STANDBY_RING 0x0010 /* Resume on Ring fr standby */
  176. #define APM_CAP_RESUME_SUSPEND_RING 0x0020 /* Resume on Ring fr suspend */
  177. #define APM_CAP_RESUME_STANDBY_PCMCIA 0x0040 /* Resume on PCMCIA Ring */
  178. #define APM_CAP_RESUME_SUSPEND_PCMCIA 0x0080 /* Resume on PCMCIA Ring */
  179. /*
  180. * ioctl operations
  181. */
  182. #include <linux/ioctl.h>
  183. #define APM_IOC_STANDBY _IO('A', 1)
  184. #define APM_IOC_SUSPEND _IO('A', 2)
  185. #endif /* LINUX_APM_H */