1 // APM BIOS support for the Bochs BIOS
2 // Copyright (C) 2004 Fabrice Bellard
4 // Debugging extensions, 16-bit interface and extended power options
5 // Copyright (C) 2005 Struan Bartlett
7 // This library is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU Lesser General Public
9 // License as published by the Free Software Foundation; either
10 // version 2 of the License, or (at your option) any later version.
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // Lesser General Public License for more details.
17 // You should have received a copy of the GNU Lesser General Public
18 // License along with this library; if not, write to the Free Software
19 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #define APMSYM(s) apmreal_ ## s
23 #elif defined(APM_PROT16)
24 #define APMSYM(s) apm16_ ## s
25 #elif defined(APM_PROT32)
26 #define APMSYM(s) apm32_ ## s
28 #error unsupported APM mode
48 APMSYM(07_poweroff_str):
51 APMSYM(07_suspend_str):
54 APMSYM(07_standby_str):
66 ; print the hex number in eax
118 mov eax, #0x3d584145 // 'EAX='
122 mov eax, #0x3d584245 // 'EBX='
125 mov eax, #0x3d584345 // 'ECX='
128 mov eax, #0x3d584445 // 'EDX='
131 mov eax, #0x3d495345 // 'ESI='
134 mov eax, #0x3d494445 // 'EDI='
145 #if defined(APM_PROT32)
148 #if defined(APM_PROT16)
153 #if defined(APM_REAL)
158 call APMSYM(put_regs)
161 #if defined(APM_REAL)
163 ; APM installation check
168 mov ah, #1 // APM major version
169 mov al, #2 // APM minor version
174 // bit 0 : 16 bit interface supported
175 // bit 1 : 32 bit interface supported
180 ; APM real mode interface connect
187 ; APM 16 bit protected mode interface connect
192 mov bx, #_apm16_entry
194 mov ax, #0xf000 // 16 bit code segment base
195 mov si, #0xfff0 // 16 bit code segment size
196 mov cx, #0xf000 // data segment address
197 mov di, #0xfff0 // data segment length
201 ; APM 32 bit protected mode interface connect
205 mov ax, #0xf000 // 32 bit code segment base
206 mov ebx, #_apm32_entry
207 mov cx, #0xf000 // 16 bit code segment base
208 // 32 bit code segment size (low 16 bits)
209 // 16 bit code segment size (high 16 bits)
211 mov dx, #0xf000 // data segment address
212 mov di, #0xfff0 // data segment length
217 ; APM interface disconnect
233 ; APM Set Power State
242 je APMSYM(07_poweroff)
245 je APMSYM(07_suspend)
248 je APMSYM(07_standby)
253 // send power off event to emulator
256 mov ax, #APMSYM(07_poweroff_str)
266 mov ax, #APMSYM(07_suspend_str)
274 mov ax, #APMSYM(07_standby_str)
280 ; APM Enable / Disable
292 mov bh, #0x01 // on line
293 // mov bh, #0x02 // battery
294 mov bl, #0xff // unknown battery status
295 // mov bl, #0x03 // charging
296 mov ch, #0x80 // no system battery
297 // mov ch, #0x8 // charging
298 mov cl, #0xff // unknown remaining time
300 mov dx, #0xffff // unknown remaining time
301 mov si, #0 // zero battery
302 // mov si, #1 // one battery
310 mov ah, #0x80 // no event pending
325 ; APM Engage / Disengage
333 ; APM Get Capabilities
336 jne APMSYM(unimplemented)
347 #if defined(APM_REAL)
352 APMSYM(unimplemented):
356 #if defined(APM_REAL)