[syslinux] Calling between real mode and protected mode on the core32 branch
H. Peter Anvin
hpa at zytor.com
Sun May 31 11:41:18 PDT 2009
H. Peter Anvin wrote:
>
> *** Calls from protected mode (32-bit) to real mode (16-bit):
>
> This is done via the core_intcall(), core_farcall() and core_cfarcall()
> functions, which are the direct versions of the analogous instructions
> in the com32 world. They are defined in <core.h>:
>
> void __cdecl core_intcall(uint8_t, const com32sys_t *, com32sys_t *);
> void __cdecl core_farcall(uint32_t, const com32sys_t *, com32sys_t *);
> int __cdecl core_cfarcall(uint32_t, const void *, uint32_t);
>
I forgot to cover core_cfarcall(): it's used to call real-mode functions
that mimic the 16-bit C compiler calling convention. In that case, the
first argument is (CS << 16)+IP, the second argument is a copy of the
stack frame parameters (it's a structure with the parameters in order
from left to right), and the third one is the size of the stack frame
structure.
The return value is passed in from EAX; depending on what the called
function is it may be necessary to cast it to (int16_t) or (uint16_t) if
it is to be used at all.
In the com32 world, this is provided by a wrapper function called
__cfarcall(); the only difference there is that CS and IP are two
separate arguments.
-hpa
--
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.
More information about the Syslinux
mailing list