beautypg.com

12 ebc tools, 1 ebc c compiler, 2 c coding convention – Intel Extensible Firmware Interface User Manual

Page 844: 3 ebc interface assembly instructions, 4 stack maintenance and argument passing

background image

Extensible Firmware Interface Specification

19-70

12/01/02

Version 1.10

19.12 EBC Tools

19.12.1 EBC C Compiler

This section describes the responsibilities of the EBC C compiler. To fully specify these
responsibilities requires that the thunking mechanisms between EBC and native code be described.

19.12.2 C Coding Convention

The EBC C compiler supports only the C programming language. There is no support for C++,
inline assembly, floating point types/operations, or C calling conventions other than CDECL.

Pointer type in C is supported only as 64-bit pointer. The code should be 64-bit pointer ready (not
assign pointers to integers and vice versa).

The compiler does not support user-defined sections through pragmas.

Global variables containing pointers that are initialized will be put in the uninitialized VarBss
section and the compiler will generate code to initialize these variables during load time. The code
will be placed in an init text section. This compiler-generated code will be executed before the
actual image entry point is executed.

19.12.3 EBC Interface Assembly Instructions

The EBC instruction set includes two forms of a

CALL

instruction that can be used to invoke

external protocols. Their assembly language formats are:

CALLEX Immed64

CALLEX32 {@}R

1

{Immed32}

Both forms can be used to invoke external protocols at an absolute address specified by the
immediate data and/or register operand. The second form also supports jumping to code at a
relative address. When one of these instructions is executed, the interpreter is responsible for
thunking arguments and then jumping to the destination address. When the called function returns,
code begins execution at the EBC instruction following the CALL instruction. The process by
which this happens is called thunking. Later sections describe this operation in detail.

19.12.4 Stack Maintenance and Argument Passing

There are several EBC assembly instructions that directly manipulate the stack contents and stack
pointer. These instructions operate on the EBC stack, not the interpreter stack. The instructions
include the EBC

PUSH

,

POP

,

PUSHn

, and

POPn

, and all forms of the

MOV

instructions.

These instructions must adjust the EBC stack pointer in the same manner as equivalent
instructions of the native instruction set. With this implementation, parameters pushed on the
stack by an EBC driver can be accessed normally for stack-based native code. If native code
expects parameters in registers, then the interpreter thunking process must transfer the arguments
from EBC stack to the appropriate processor registers. The process would need to be reversed
when native code calls EBC.