1 #ifndef _LINUX_APM_H
2 #define _LINUX_APM_H
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 typedef unsigned short apm_event_t;
22
23 #ifdef __KERNEL__
24
25 #include <linux/tasks.h>
26 #include <linux/sched.h>
27
28 #define APM_CS _TSS(NR_TASKS)
29 #define APM_CS_16 (APM_CS + 8)
30 #define APM_DS (APM_CS_16 + 8)
31
32 struct apm_bios_info {
33 unsigned short version;
34 unsigned short cseg;
35 unsigned long offset;
36 unsigned short cseg_16;
37 unsigned short dseg;
38 unsigned short flags;
39 unsigned short cseg_len;
40 unsigned short dseg_len;
41 };
42
43
44 #define APM_16_BIT_SUPPORT 0x0001
45 #define APM_32_BIT_SUPPORT 0x0002
46 #define APM_IDLE_SLOWS_CLOCK 0x0004
47 #define APM_BIOS_DISABLED 0x0008
48 #define APM_BIOS_DISENGAGED 0x0010
49
50
51
52
53 #define APM_MAX_EVENTS 20
54
55
56
57
58 struct apm_bios_struct {
59 int magic;
60 struct apm_bios_struct * next;
61 int suser;
62 int suspends_pending;
63 int standbys_pending;
64 int event_head;
65 int event_tail;
66 apm_event_t events[APM_MAX_EVENTS];
67 };
68
69
70
71
72 #define APM_BIOS_MAGIC 0x4101
73
74
75
76
77 extern struct apm_bios_info apm_bios_info;
78
79 extern void apm_bios_init(void);
80
81 extern int apm_register_callback(int (*callback)(apm_event_t));
82 extern void apm_unregister_callback(int (*callback)(apm_event_t));
83
84 extern int apm_display_blank(void);
85 extern int apm_display_unblank(void);
86
87 #endif
88
89
90
91
92 #define APM_STATE_READY 0x0000
93 #define APM_STATE_STANDBY 0x0001
94 #define APM_STATE_SUSPEND 0x0002
95 #define APM_STATE_OFF 0x0003
96 #define APM_STATE_BUSY 0x0004
97 #define APM_STATE_REJECT 0x0005
98
99
100
101
102 #define APM_SYS_STANDBY 0x0001
103 #define APM_SYS_SUSPEND 0x0002
104 #define APM_NORMAL_RESUME 0x0003
105 #define APM_CRITICAL_RESUME 0x0004
106 #define APM_LOW_BATTERY 0x0005
107 #define APM_POWER_STATUS_CHANGE 0x0006
108 #define APM_UPDATE_TIME 0x0007
109 #define APM_CRITICAL_SUSPEND 0x0008
110 #define APM_USER_STANDBY 0x0009
111 #define APM_USER_SUSPEND 0x000a
112 #define APM_STANDBY_RESUME 0x000b
113
114
115
116
117 #define APM_SUCCESS 0x00
118 #define APM_DISABLED 0x01
119 #define APM_CONNECTED 0x02
120 #define APM_NOT_CONNECTED 0x03
121 #define APM_16_CONNECTED 0x05
122 #define APM_16_UNSUPPORTED 0x06
123 #define APM_32_CONNECTED 0x07
124 #define APM_32_UNSUPPORTED 0x08
125 #define APM_BAD_DEVICE 0x09
126 #define APM_BAD_PARAM 0x0a
127 #define APM_NOT_ENGAGED 0x0b
128 #define APM_BAD_STATE 0x60
129 #define APM_NO_EVENTS 0x80
130 #define APM_NOT_PRESENT 0x86
131
132
133 #include <linux/ioctl.h>
134
135 #define APM_IOC_STANDBY _IO('A', 1)
136 #define APM_IOC_SUSPEND _IO('A', 2)
137
138 #endif