On 12/07/2010 06:46 PM, Kevin O'Connor wrote:
In Syslinux I have this formalized so that the sequence:
pushl $func32 callw _pm_call
This is similar to what SeaBIOS used to do - it had: "pushl $func32; jmp transition32" and "pushl $func16; jmp transition16".
The problem with this is that I can't use "popl" to get the destination address in transition16 because a popl in 16bit mode only looks at %sp and not %esp. So, if %esp==0x90000 and I do "pushl $func16; transition16", then when transition16 does a "retl" (or "popl") then it ends up pulling the address at 0x0000 instead of 0x90000.
Right, the code needs to compute the 32-bit flat version and look at it. You don't want to use popl at all. In my code I just use the stored reference on the stack as the target address of the call once we're well within the 32-bit code, at the very end it is dropped by a simple "ret 4".
Anyway, sounds like there might be a fuller version and I'm only seeing part of it.
-hpa