Rev 2455 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2455 | Rev 3539 | ||
---|---|---|---|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; Copyright (C) KolibriOS team 2009-2011. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2009-2011. All rights reserved. ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
5 | ;; ;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
7 | 7 | ||
8 | ; 11.09.2009 staper@inbox.ru |
8 | ; 11.09.2009 staper@inbox.ru |
9 | ; see kernel\docs\apm.txt |
9 | ; see kernel\docs\apm.txt |
10 | 10 | ||
11 | use32 |
11 | use32 |
12 | 12 | ||
13 | org 0x0 |
13 | org 0x0 |
14 | 14 | ||
15 | db 'MENUET01' |
15 | db 'MENUET01' |
16 | dd 0x1 |
16 | dd 0x1 |
17 | dd START |
17 | dd START |
18 | dd I_END |
18 | dd I_END |
19 | dd (I_END+100) and not 3 |
19 | dd (I_END+100) and not 3 |
20 | dd (I_END+100) and not 3 |
20 | dd (I_END+100) and not 3 |
21 | dd 0x0,0x0 |
21 | dd 0x0,0x0 |
22 | 22 | ||
23 | include 'macros.inc' |
23 | include 'macros.inc' |
24 | 24 | ||
25 | START: |
25 | START: |
26 | mcall 40,0x7 |
26 | mcall 40,0x7 |
27 | 27 | ||
28 | mcall 49,0x0001,0x0001,0x5308 ;CX = FFFFh APM v1.0 |
28 | mcall 49,0x0001,0x0001,0x5308 ;CX = FFFFh APM v1.0 |
29 | ; mcall 49,0x0001,0x0001,0x530d |
29 | ; mcall 49,0x0001,0x0001,0x530d |
30 | ; mcall 49,0x0001,0x0001,0x530f |
30 | ; mcall 49,0x0001,0x0001,0x530f |
31 | 31 | ||
32 | ; mcall 49,0x0000,,0x5310 ;bl - number of batteries |
32 | ; mcall 49,0x0000,,0x5310 ;bl - number of batteries |
33 | redraw: |
33 | redraw: |
34 | mcall 49,0x0000,,0x530c |
34 | mcall 49,0x0000,,0x530c |
35 | dec cl |
35 | dec cl |
36 | jz still |
36 | jz still |
37 | mcall 49,0x0001,0x0001,0x5308 |
37 | mcall 49,0x0001,0x0001,0x5308 |
38 | mcall 49,0x01ff,,0x530c |
38 | mcall 49,0x01ff,,0x530c |
39 | test cl, cl |
39 | test cl, cl |
40 | jz @f |
40 | jz @f |
41 | mcall 49,0x0000,0x0001,0x530d |
41 | mcall 49,0x0000,0x0001,0x530d |
42 | mcall 49,0x0000,0x0000,0x5307 |
42 | mcall 49,0x0000,0x0000,0x5307 |
43 | mcall 49,0x0000,0x0001,0x5308 |
43 | mcall 49,0x0000,0x0001,0x5308 |
44 | @@: |
44 | @@: |
45 | mcall 12,1 |
45 | mcall 12,1 |
46 | mcall 0,100*65536+235,100*65536+90,0x34ffffff,0x000000,title |
46 | mcall 0,100*65536+235,100*65536+90,0x34ffffff,0x000000,title |
47 | mcall 49,0x0000,,0x5300 |
47 | mcall 49,0x0000,,0x5300 |
48 | jnc @f |
48 | jnc @f |
49 | mcall 4,10*65536+3,0x80000000,text.4 |
49 | mcall 4,10*65536+3,0x80000000,text.4 |
50 | bts [flags], 1 |
50 | bts [flags], 1 |
51 | jmp .end |
51 | jmp .end |
52 | @@: |
52 | @@: |
53 | cmp al, 0 |
53 | cmp al, 0 |
54 | jne @f |
54 | jne @f |
55 | mov edx, text.1 |
55 | mov edx, text.1 |
56 | jmp .0 |
56 | jmp .0 |
57 | @@: |
57 | @@: |
58 | cmp al, 1 |
58 | cmp al, 1 |
59 | jne @f |
59 | jne @f |
60 | mov edx, text.2 |
60 | mov edx, text.2 |
61 | jmp .0 |
61 | jmp .0 |
62 | @@: |
62 | @@: |
63 | mov edx, text.3 |
63 | mov edx, text.3 |
64 | .0: |
64 | .0: |
65 | push edx |
65 | push edx |
66 | mcall 4,169*65536+3,0x80dddddd,text.0 |
66 | mcall 4,169*65536+3,0x80dddddd,text.0 |
67 | pop edx |
67 | pop edx |
68 | add ebx, 47*65536 |
68 | add ebx, 47*65536 |
69 | mcall |
69 | mcall |
70 | mcall 49,0x0001,,0x530a |
70 | mcall 49,0x0001,,0x530a |
71 | jc .error |
71 | jc .error |
72 | push si dx cx bx ;time of battery life, b. flag, b. status, AC line status |
72 | push si dx cx bx ;time of battery life, b. flag, b. status, AC line status |
73 | 73 | ||
74 | ;AC line status |
74 | ;AC line status |
75 | cmp bh, 0 |
75 | cmp bh, 0 |
76 | jne @f |
76 | jne @f |
77 | mov edx, text.01 |
77 | mov edx, text.01 |
78 | jmp .1 |
78 | jmp .1 |
79 | @@: |
79 | @@: |
80 | cmp bh, 1 |
80 | cmp bh, 1 |
81 | jne @f |
81 | jne @f |
82 | mov edx, text.02 |
82 | mov edx, text.02 |
83 | jmp .1 |
83 | jmp .1 |
84 | @@: |
84 | @@: |
85 | cmp bh, 2 |
85 | cmp bh, 2 |
86 | jne @f |
86 | jne @f |
87 | mov edx, text.03 |
87 | mov edx, text.03 |
88 | jmp .1 |
88 | jmp .1 |
89 | @@: |
89 | @@: |
90 | mov edx, text.04 |
90 | mov edx, text.04 |
91 | .1: |
91 | .1: |
92 | push edx |
92 | push edx |
93 | mcall 4,10*65536+10,0x80000000,text.00 |
93 | mcall 4,10*65536+10,0x80000000,text.00 |
94 | pop edx |
94 | pop edx |
95 | mcall ,100*65536+10,;0x80000000 |
95 | mcall ,100*65536+10,;0x80000000 |
96 | 96 | ||
97 | ;battery status |
97 | ;battery status |
98 | pop bx |
98 | pop bx |
99 | cmp bl, 0 |
99 | cmp bl, 0 |
100 | jne @f |
100 | jne @f |
101 | mov edx, text.11 |
101 | mov edx, text.11 |
102 | jmp .2 |
102 | jmp .2 |
103 | @@: |
103 | @@: |
104 | cmp bl, 1 |
104 | cmp bl, 1 |
105 | jne @f |
105 | jne @f |
106 | mov edx, text.12 |
106 | mov edx, text.12 |
107 | jmp .2 |
107 | jmp .2 |
108 | @@: |
108 | @@: |
109 | cmp bl, 2 |
109 | cmp bl, 2 |
110 | jne @f |
110 | jne @f |
111 | mov edx, text.13 |
111 | mov edx, text.13 |
112 | jmp .2 |
112 | jmp .2 |
113 | @@: |
113 | @@: |
114 | cmp bl, 3 |
114 | cmp bl, 3 |
115 | jne @f |
115 | jne @f |
116 | mov edx, text.14 |
116 | mov edx, text.14 |
117 | jmp .2 |
117 | jmp .2 |
118 | @@: |
118 | @@: |
119 | mov edx, text.04 |
119 | mov edx, text.04 |
120 | .2: |
120 | .2: |
121 | push edx |
121 | push edx |
122 | mcall 4,10*65536+20,0x80000000,text.10 |
122 | mcall 4,10*65536+20,0x80000000,text.10 |
123 | pop edx |
123 | pop edx |
124 | mcall ,100*65536+20, |
124 | mcall ,100*65536+20, |
125 | 125 | ||
126 | ;battery life, percentage and minutes/seconds |
126 | ;battery life, percentage and minutes/seconds |
127 | mcall ,10*65536+30,,text.20 |
127 | mcall ,10*65536+30,,text.20 |
128 | pop cx |
128 | pop cx |
129 | cmp cl, 0xff |
129 | cmp cl, 0xff |
130 | jne @f |
130 | jne @f |
131 | mcall ,100*65536+30,0x80000000,text.04 |
131 | mcall ,100*65536+30,0x80000000,text.04 |
132 | pop eax |
132 | pop eax |
133 | jmp .end |
133 | jmp .end |
134 | @@: |
134 | @@: |
135 | shl ecx, 24 |
135 | shl ecx, 24 |
136 | shr ecx, 24 |
136 | shr ecx, 24 |
137 | mcall 47,0x80030000,,100*65536+30,0x347636 |
137 | mcall 47,0x80030000,,100*65536+30,0x347636 |
138 | .3: |
138 | .3: |
139 | mcall 4,115*65536+30,0x80000000,text.15 |
139 | mcall 4,115*65536+30,0x80000000,text.15 |
140 | mov dx, [esp] |
140 | mov dx, [esp] |
141 | shl edx, 17 |
141 | shl edx, 17 |
142 | shr edx, 17 |
142 | shr edx, 17 |
143 | mov ecx, edx |
143 | mov ecx, edx |
144 | mcall 47,0x80030000,,140*65536+30 |
144 | mcall 47,0x80030000,,140*65536+30 |
145 | pop cx |
145 | pop cx |
146 | mov edx, text.21 |
146 | mov edx, text.21 |
147 | bt cx, 15 |
147 | bt cx, 15 |
148 | jc @f |
148 | jc @f |
149 | mov edx, text.22 |
149 | mov edx, text.22 |
150 | @@: |
150 | @@: |
151 | mcall 4,160*65536+30,0x80000000 |
151 | mcall 4,160*65536+30,0x80000000 |
152 | pop si |
152 | pop si |
153 | .error: |
153 | .error: |
154 | .end: |
154 | .end: |
155 | ;buttons |
155 | ;buttons |
156 | mcall 8,148*65536+16,45*65536+15,3,0x00677ab0 |
156 | mcall 8,148*65536+16,45*65536+15,3,0x00677ab0 |
157 | mcall ,166*65536+16,,4, |
157 | mcall ,166*65536+16,,4, |
158 | mcall ,184*65536+16,,5, |
158 | mcall ,184*65536+16,,5, |
159 | mcall ,202*65536+16,,6, |
159 | mcall ,202*65536+16,,6, |
160 | bt [flags], 1 |
160 | bt [flags], 1 |
161 | jc @f |
161 | jc @f |
162 | mcall ,65*65536+45,,2, |
162 | mcall ,65*65536+45,,2, |
163 | @@: |
163 | @@: |
164 | mcall 4,10*65536+50,0x80564242,text.30 |
164 | mcall 4,10*65536+50,0x80564242,text.30 |
165 | mcall 12,2 |
165 | mcall 12,2 |
166 | 166 | ||
167 | still: |
167 | still: |
168 | ; mcall 10 |
168 | ; mcall 10 |
169 | mcall 23,12000 |
169 | mcall 23,12000 |
170 | test eax, eax |
170 | test eax, eax |
171 | jz redraw |
171 | jz redraw |
172 | 172 | ||
173 | dec al |
173 | dec al |
174 | jz redraw |
174 | jz redraw |
175 | dec al |
175 | dec al |
176 | jz key |
176 | jz key |
177 | dec al |
177 | dec al |
178 | jz button |
178 | jz button |
179 | jmp still |
179 | jmp still |
180 | 180 | ||
181 | 181 | ||
182 | 182 | ||
183 | 183 | ||
184 | key: |
184 | key: |
185 | mcall 2 |
185 | mcall 2 |
186 | jmp still |
186 | jmp still |
187 | 187 | ||
188 | button: |
188 | button: |
189 | mcall 17 |
189 | mcall 17 |
190 | cmp ah, 1 |
190 | cmp ah, 1 |
191 | jne @f |
191 | jne @f |
192 | mcall -1 |
192 | mcall -1 |
193 | 193 | ||
194 | @@: |
194 | @@: |
195 | cmp ah, 2 |
195 | cmp ah, 2 |
196 | jne @f |
196 | jne @f |
197 | mcall 5,50 |
197 | mcall 5,50 |
198 | mcall 49,0x0001,0x0001,0x5307 |
198 | mcall 49,0x0001,0x0001,0x5307 |
199 | jmp redraw |
199 | jmp redraw |
200 | 200 | ||
201 | @@: |
201 | @@: |
202 | cmp ah, 4 |
202 | cmp ah, 4 |
203 | jg @f |
203 | jg @f |
204 | mov edx, 0x01f7 ;primary chan. |
204 | mov edx, 0x01f7 ;primary chan. |
205 | call reserv_ports |
205 | call reserv_ports |
206 | jc redraw |
206 | jc redraw |
207 | sub bh, 3 |
207 | sub bh, 3 |
208 | .1: |
208 | .1: |
209 | call set_drive |
209 | call set_drive |
210 | btc [flags], 2 |
210 | btc [flags], 2 |
211 | jnc .2 |
211 | jnc .2 |
212 | call device_reset |
212 | call device_reset |
213 | jmp .3 |
213 | jmp .3 |
214 | .2: |
214 | .2: |
215 | call standby_hdd |
215 | call standby_hdd |
216 | .3: |
216 | .3: |
217 | call free_ports |
217 | call free_ports |
218 | jmp redraw |
218 | jmp redraw |
219 | 219 | ||
220 | @@: |
220 | @@: |
221 | cmp ah, 6 |
221 | cmp ah, 6 |
222 | jg redraw |
222 | jg redraw |
223 | mov edx, 0x0177 ;secondary chan. |
223 | mov edx, 0x0177 ;secondary chan. |
224 | call reserv_ports |
224 | call reserv_ports |
225 | jc redraw |
225 | jc redraw |
226 | sub bh, 5 |
226 | sub bh, 5 |
227 | jmp .1 |
227 | jmp .1 |
228 | 228 | ||
229 | set_drive: |
229 | set_drive: |
230 | dec dx |
230 | dec dx |
231 | in al, dx |
231 | in al, dx |
232 | test bh, bh |
232 | test bh, bh |
233 | jnz @f |
233 | jnz @f |
234 | btr ax, 4 |
234 | btr ax, 4 |
235 | .1: |
235 | .1: |
236 | out dx, al |
236 | out dx, al |
237 | inc dx |
237 | inc dx |
238 | ret |
238 | ret |
239 | @@: |
239 | @@: |
240 | bts ax, 4 |
240 | bts ax, 4 |
241 | jmp .1 |
241 | jmp .1 |
242 | 242 | ||
243 | 243 | ||
244 | standby_hdd: |
244 | standby_hdd: |
245 | ; 94h E0h nondata standby immediate |
245 | ; 94h E0h nondata standby immediate |
246 | ; 95h E1h nondata idle immediate |
246 | ; 95h E1h nondata idle immediate |
247 | ; 96h E2h nondata standby |
247 | ; 96h E2h nondata standby |
248 | ; 97h E3h nondata idle |
248 | ; 97h E3h nondata idle |
249 | ; 98h E5h nondata check power mode |
249 | ; 98h E5h nondata check power mode |
250 | ; 99h E6h nondata set sleep mode |
250 | ; 99h E6h nondata set sleep mode |
251 | xor ecx, ecx |
251 | xor ecx, ecx |
252 | @@: |
252 | @@: |
253 | in al, dx |
253 | in al, dx |
254 | dec cx |
254 | dec cx |
255 | jz @f |
255 | jz @f |
256 | bt ax, 6 |
256 | bt ax, 6 |
257 | jnc @b |
257 | jnc @b |
258 | mov al, 0x96 |
258 | mov al, 0x96 |
259 | out dx, al |
259 | out dx, al |
260 | mov al, 0xe2 |
260 | mov al, 0xe2 |
261 | out dx, al |
261 | out dx, al |
262 | @@: |
262 | @@: |
263 | ret |
263 | ret |
264 | 264 | ||
265 | reserv_ports: |
265 | reserv_ports: |
266 | mov ecx, edx |
266 | mov ecx, edx |
267 | dec ecx |
267 | dec ecx |
268 | push ax |
268 | push ax |
269 | mcall 46,0 |
269 | mcall 46,0 |
270 | test al, al |
270 | test al, al |
271 | jnz @f |
271 | jnz @f |
272 | pop bx |
272 | pop bx |
273 | clc |
273 | clc |
274 | ret |
274 | ret |
275 | @@: |
275 | @@: |
276 | pop bx |
276 | pop bx |
277 | stc |
277 | stc |
278 | ret |
278 | ret |
279 | 279 | ||
280 | device_reset: |
280 | device_reset: |
281 | xor ecx, ecx |
281 | xor ecx, ecx |
282 | @@: |
282 | @@: |
283 | in al, dx |
283 | in al, dx |
284 | dec cx |
284 | dec cx |
285 | jz @f |
285 | jz @f |
286 | bt ax, 6 |
286 | bt ax, 6 |
287 | jnc @b |
287 | jnc @b |
288 | mov al, 0x10 |
288 | mov al, 0x10 |
289 | out dx, al |
289 | out dx, al |
290 | @@: |
290 | @@: |
291 | ret |
291 | ret |
292 | 292 | ||
293 | free_ports: |
293 | free_ports: |
294 | mov ecx, edx |
294 | mov ecx, edx |
295 | dec ecx |
295 | dec ecx |
296 | mcall 46,1 |
296 | mcall 46,1 |
297 | ret |
297 | ret |
298 | 298 | ||
299 | 299 | ||
300 | ; |
300 | ; ДАННЫЕ ПРОГРАММЫ |
301 | title db '',0 |
301 | title db '',0 |
302 | flags dw 0 |
302 | flags dw 0 |
303 | 303 | ||
304 | text: |
304 | text: |
305 | .0: |
305 | .0: |
306 | db 'APM v.1.',0 |
306 | db 'APM v.1.',0 |
307 | .1: |
307 | .1: |
308 | db '0',0 |
308 | db '0',0 |
309 | .2: |
309 | .2: |
310 | db '1',0 |
310 | db '1',0 |
311 | .3: |
311 | .3: |
312 | db '2',0 |
312 | db '2',0 |
313 | .4: |
313 | .4: |
314 | db 'APM not supported',0 |
314 | db 'APM not supported',0 |
315 | 315 | ||
316 | .00: |
316 | .00: |
317 | db 'power status:',0 |
317 | db 'power status:',0 |
318 | .01: |
318 | .01: |
319 | db 'off-line',0 |
319 | db 'off-line',0 |
320 | .02: |
320 | .02: |
321 | db 'on-line',0 |
321 | db 'on-line',0 |
322 | .03: |
322 | .03: |
323 | db 'on backup power',0 |
323 | db 'on backup power',0 |
324 | .04: |
324 | .04: |
325 | db 'unknown',0 |
325 | db 'unknown',0 |
326 | 326 | ||
327 | .10: |
327 | .10: |
328 | db 'battery flag:',0 |
328 | db 'battery flag:',0 |
329 | .11: |
329 | .11: |
330 | db 'high',0 |
330 | db 'high',0 |
331 | .12: |
331 | .12: |
332 | db 'low',0 |
332 | db 'low',0 |
333 | .13: |
333 | .13: |
334 | db 'critical',0 |
334 | db 'critical',0 |
335 | .14: |
335 | .14: |
336 | db 'charging',0 |
336 | db 'charging',0 |
337 | .15: |
337 | .15: |
338 | db ' % ,',0 |
338 | db ' % ,',0 |
339 | 339 | ||
340 | .20: |
340 | .20: |
341 | db 'battery life:',0 |
341 | db 'battery life:',0 |
342 | .21: |
342 | .21: |
343 | db 'min',0 |
343 | db 'min',0 |
344 | .22: |
344 | .22: |
345 | db 'sec',0 |
345 | db 'sec',0 |
346 | 346 | ||
347 | .30: |
347 | .30: |
348 | db 'STAND-BY: SYSTEM HDD: 0 1 2 3',0 |
348 | db 'STAND-BY: SYSTEM HDD: 0 1 2 3',0 |
349 | 349 | ||
350 | I_END: |
350 | I_END: |