source: trunk/include/helpers/apmh.h@ 147

Last change on this file since 147 was 111, checked in by umoeller, 24 years ago

misc changes

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 7.9 KB
Line 
1
2/*
3 *@@sourcefile apmh.h:
4 * header file for apmh.c.
5 *
6 * Note: Version numbering in this file relates to XWorkplace version
7 * numbering.
8 *
9 *@@include #include <os2.h>
10 *@@include #include "helpers\apmh.h"
11 */
12
13/* Copyright (C) 1998-2001 Ulrich M”ller.
14 * This file is part of the "XWorkplace helpers" source package.
15 * This is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published
17 * by the Free Software Foundation, in version 2 as it comes in the
18 * "COPYING" file of the XWorkplace main distribution.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 */
24
25#if __cplusplus
26extern "C" {
27#endif
28
29#ifndef APMH_HEADER_INCLUDED
30 #define APMH_HEADER_INCLUDED
31
32 /* ******************************************************************
33 *
34 * APM definitions (from DDK)
35 *
36 ********************************************************************/
37
38 /*---------------------------------------------------------------------------*
39 * Category 12 (Power Management) IOCtl Function Codes *
40 *---------------------------------------------------------------------------*/
41
42 #define APMGIO_Category 12 // Generic IOCtl Category for APM.
43
44 #define APMGIO_SendEvent 0x40 // Function Codes.
45 #define APMGIO_SetEventSem 0x41
46 #define APMGIO_ConfirmEvent 0x42 // 0x42 is UNDOCUMENTED.
47 #define APMGIO_BroadcastEvent 0x43 // 0x43 is UNDOCUMENTED.
48 #define APMGIO_RegDaemonThread 0x44 // 0x44 is UNDOCUMENTED.
49 #define APMGIO_OEMFunction 0x45
50 #define APMGIO_QueryStatus 0x60
51 #define APMGIO_QueryEvent 0x61
52 #define APMGIO_QueryInfo 0x62
53 #define APMGIO_QueryState 0x63
54
55 #pragma pack(1)
56
57 /*---------------------------------------------------------------------------*
58 * Function 0x60, Query Power Status *
59 * Reference MS/Intel APM specification for interpretation of status codes. *
60 *---------------------------------------------------------------------------*/
61
62 typedef struct _APMGIO_QSTATUS_PPKT { // Parameter Packet.
63
64 USHORT ParmLength; // Length, in bytes, of the Parm Packet.
65 USHORT Flags; // Output: Flags.
66 UCHAR ACStatus;
67 // Output: 0x00 if not on AC,
68 // 0x01 if AC,
69 // 0x02 if on backup power,
70 // 0xFF if unknown
71 UCHAR BatteryStatus;
72 // Output: 0x00 if battery high,
73 // 0x01 if battery low,
74 // 0x02 if battery critically low,
75 // 0x03 if battery charging
76 // 0xFF if unknown
77 UCHAR BatteryLife;
78 // Output: Battery power life (as percentage)
79 UCHAR BatteryTimeForm;
80 // Output:
81 // 0x00 if format is seconds,
82 // 0x01 if format is minutes,
83 // 0xFF if unknown
84 USHORT BatteryTime; // Output: Remaining battery time.
85 UCHAR BatteryFlags; // Output: Battery status flags
86
87 } APMGIO_QSTATUS_PPKT, *NPAPMGIO_QSTATUS_PPKT, FAR *PAPMGIO_QSTATUS_PPKT;
88
89 typedef struct _APMGIO_10_QSTATUS_PPKT { // Parameter Packet for
90 // APM 1.0 interface
91 USHORT ParmLength; // Length, in bytes, of the Parm Packet.
92 USHORT Flags; // Output: Flags.
93 UCHAR ACStatus; // Output: AC line power status.
94 UCHAR BatteryStatus; // Output: Battery power status
95 UCHAR BatteryLife; // Output: Battery power status
96
97 } APMGIO_10_QSTATUS_PPKT;
98
99 // Error return codes.
100 #define GIOERR_PowerNoError 0
101 #define GIOERR_PowerBadSubId 1
102 #define GIOERR_PowerBadReserved 2
103 #define GIOERR_PowerBadDevId 3
104 #define GIOERR_PowerBadPwrState 4
105 #define GIOERR_PowerSemAlreadySetup 5
106 #define GIOERR_PowerBadFlags 6
107 #define GIOERR_PowerBadSemHandle 7
108 #define GIOERR_PowerBadLength 8
109 #define GIOERR_PowerDisabled 9
110 #define GIOERR_PowerNoEventQueue 10
111 #define GIOERR_PowerTooManyQueues 11
112 #define GIOERR_PowerBiosError 12
113 #define GIOERR_PowerBadSemaphore 13
114 #define GIOERR_PowerQueueOverflow 14
115 #define GIOERR_PowerStateChangeReject 15
116 #define GIOERR_PowerNotSupported 16
117 #define GIOERR_PowerDisengaged 17
118 #define GIOERR_PowerHighestErrCode 17
119
120 typedef struct _APMGIO_DPKT {
121
122 USHORT ReturnCode;
123
124 } APMGIO_DPKT, *NPAPMGIO_DPKT, FAR *PAPMGIO_DPKT;
125
126 /*
127 * define constants and type for APM function
128 */
129
130 #define POWER_SUBID_ENABLE_APM 0x0003
131 #define POWER_SUBID_SET_POWER_STATE 0x0006
132
133 #define POWER_DEVID_ALL_DEVICES 0x0001
134
135 #define POWER_STATE_OFF 0x0003
136
137 #define BIOSFLAG_APMSUPPORTED 0x0008
138
139 typedef struct
140 {
141 USHORT usSubID;
142 USHORT usReserved;
143 USHORT usData1;
144 USHORT usData2;
145 } SENDPOWEREVENT;
146
147 typedef struct
148 {
149 USHORT usParmLength;
150 USHORT usBIOSFlags;
151 USHORT usBIOSVersion;
152 USHORT usDriverVersion;
153 } GETPOWERINFO;
154
155 #pragma pack()
156
157 /* ******************************************************************
158 *
159 * APM helper APIs
160 *
161 ********************************************************************/
162
163 /*
164 *@@ APM:
165 * APM monitor data returned from apmhOpen.
166 *
167 *@@added V0.9.14 (2001-08-01) [umoeller]
168 */
169
170 typedef struct _APM
171 {
172 HFILE hfAPMSys;
173
174 USHORT usBIOSVersion,
175 usDriverVersion,
176 usLowestAPMVersion;
177
178 BOOL fAlreadyRead;
179 // TRUE after the first call to aphReadStatus
180
181 // the following are valid after a call to
182 // apmhReadStatus
183 ULONG ulBatteryStatus;
184 // copy of APM battery status, that is:
185 // Output: 0x00 if battery high,
186 // 0x01 if battery low,
187 // 0x02 if battery critically low,
188 // 0x03 if battery charging
189 // 0xFF if unknown
190 ULONG ulBatteryLife;
191 // current battery life as percentage (0-100)
192
193 } APM, *PAPM;
194
195 APIRET APIENTRY apmhIOCtl(HFILE hfAPMSys, ULONG ulFunction, PVOID pvParamPck, ULONG cbParamPck);
196 typedef APIRET APIENTRY APMHIOCTL(HFILE hfAPMSys, ULONG ulFunction, PVOID pvParamPck, ULONG cbParamPck);
197 typedef APMHIOCTL *PAPMHIOCTL;
198
199 APIRET APIENTRY apmhOpen(PAPM *ppApm);
200 typedef APIRET APIENTRY APMHOPEN(PAPM *ppApm);
201 typedef APMHOPEN *PAPMHOPEN;
202
203 APIRET APIENTRY apmhReadStatus(PAPM pApm, PBOOL pfChanged);
204 typedef APIRET APIENTRY APMHREADSTATUS(PAPM pApm, PBOOL pfChanged);
205 typedef APMHREADSTATUS *PAPMHREADSTATUS;
206
207 VOID APIENTRY apmhClose(PAPM *ppApm);
208 typedef VOID APIENTRY APMHCLOSE(PAPM *ppApm);
209 typedef APMHCLOSE *PAPMHCLOSE;
210
211 BOOL apmhHasBattery(VOID);
212
213#endif
214
215#if __cplusplus
216}
217#endif
218
Note: See TracBrowser for help on using the repository browser.