Intel Extensible Firmware Interface Network Router User Manual


  Open as PDF
of 1084
 
EFI Byte Code Virtual Machine
Version 1.10 12/01/02 19-71
19.12.5 Native to EBC Arguments Calling Convention
The calling convention for arguments passed to EBC functions follows the standard CDECL calling
convention. The arguments must be pushed as their native size. After the function arguments have
been pushed on the stack, execution is passed to the called EBC function. The overhead of
thunking the function parameters depends on the standard parameter passing convention for the
host processor. The implementation of this functionality is left to the interpreter.
19.12.6 EBC to Native Arguments Calling Convention
When EBC makes function calls via function pointers, the EBC C compiler cannot determine
whether the calls are to native code or EBC. It therefore assumes that the calls are to native code,
and emits the appropriate EBC CALLEX
instructions. To be compatible with calls to native code,
the calling convention of EBC calling native code must follow the parameter passing convention of
the native processor. The EBC C compiler generates EBC instructions that push all arguments on
the stack. The interpreter is then responsible for performing the necessary thunking. The exact
implementation of this functionality is left to the interpreter.
19.12.7 EBC to EBC Arguments Calling Convention
If the EBC C compiler is able to determine that a function call is to a local function, it can emit a
standard EBC CALL
instruction. In this case, the function arguments are passed as described in the
other sections of this specification.
19.12.8 Function Returns
When EBC calls an external function, the thunking process includes setting up the host processor
stack or registers such that when the called function returns, execution is passed back to the EBC at
the instruction following the call. The implementation is left to the interpreter, but it must follow
the standard function return process of the host processor. Typically this will require the interpreter
to push the return address on the stack or move it to a processor register prior to calling the
external function.
19.12.9 Function Return Values
EBC function return values of 8 bytes or less are returned in VM general-purpose register R7.
Returning values larger than 8 bytes on the stack is not supported. Instead, the caller or callee must
allocate memory for the return value, and the caller can pass a pointer to the callee, or the callee can
return a pointer to the value in the standard return register R7.
If an EBC function returns to native code, then the interpreter thunking process is responsible for
transferring the contents of R7 to an appropriate location such that the caller has access to the value
using standard native code. Typically the value will be transferred to a processor register.
Conversely, if a native function returns to an EBC function, the interpreter is responsible for
transferring the return value from the native return memory or register location into VM
register R7.