apm_bios.h
上传用户:szlgq88
上传日期:2009-04-28
资源大小:48287k
文件大小:6k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

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