Page 1 of 1

apm bios pmode

Posted: Mon Sep 21, 2009 8:56 am
by lama
Hi,

Can someone please show me how to perform call to apm bios? I'm really stucked here. I have checked for APM PMODE 32BIT support, have setup interface connection and have updated my GDT. Then, I tried to far-call the APM entry point with ax=530a (get power status) and bx=1. What i got was GPF and in bochsout was:
BOCHS-DEBUGGER wrote: LOCK prefix unallowed (op1=0x53, attr=0x0, mod=0x0, nnn=0)
LOCK prefix unallowed (op1=0x53, attr=0x0, mod=0x0, nnn=0)
write_virtual_checks(): write beyond limit, r/w
....maybe the values whitch i caught from 5303 int15 is wrong:
BOCHS-DEBUGGER wrote: pm 32bit cs base : 0xf000 (returned in ax)
apm 16bit cs base : 0xf000 (returned in cx)
apm entrypoint : 0xaf0d (returned in ebx)
apm ds base : 0xf000 (returned in dx)
apm 32/16 cs lenght : 0xfff0 (both) (returned in esi)
apm ds lenght : 0xfff0 (returned in di),
Can someone show me how to do this right? It means a lot for me to get this thing working,

Re: apm bios pmode

Posted: Mon Sep 21, 2009 12:02 pm
by Combuster
LOCK prefix unallowed (op1=0x53, attr=0x0, mod=0x0, nnn=0)
Tip of the day: do not try to execute data. Instead jump to the location the bios instructed you to and not somewhere else :wink:

Re: apm bios pmode

Posted: Tue Sep 22, 2009 5:23 am
by lama
i dont get it :D if edx is the entry point and ds is set to apm cs - call [ds:edx] - is this a wrong way how to perform call ?show me what you mean please :)

Re: apm bios pmode

Posted: Tue Sep 22, 2009 5:24 am
by Combuster
lama wrote:call [ds:edx] - is this a wrong way how to perform call?
I'm 99% sure that it does *not* do what you think :wink: (look it up in the intel manuals)

Re: apm bios pmode

Posted: Tue Sep 22, 2009 5:28 am
by lama
wow that was quick :D well, it will perform a far call , cs is updated to value in ds, right?

Re: apm bios pmode

Posted: Tue Sep 22, 2009 6:38 am
by Brendan
Hi,
lama wrote:wow that was quick :D well, it will perform a far call , cs is updated to value in ds, right?
Wrong.

For "call [ds:edx]" the CPU loads EIP from address "ds:edx". What you're trying to do is "call far ds:edx" (e.g. load CS from DS and load EIP from EDX), but the CPU doesn't support that.

What you'd need to do is something like:

Code: Select all

    mov [foo],edx
    mov [foo+4],ds
   call far [foo]
Also note that "call far [foo]" is different to "call [foo]", and they're both entirely different to "call foo".


Cheers,

Brendan

Re: apm bios pmode

Posted: Tue Sep 22, 2009 7:06 am
by lama
thanks a lot for the explanation :) i know what does [] stands for,but 'call ds:edx' has nasm rejected..so i thought that call [ds:edx] is the same in this case, but cleary it was a complete nonsense , thanks again :D now i got different gpf - incorrect cs... so i probably have some junk in gdt .. :(