Re: [edk2] About EBC calling convention

Subject: Re: [edk2] About EBC calling convention

From: "Kinney, Michael D" <>

To: "" <>

Date: 2010-03-30 23:53:26


Local function is in the same PE/COFF image.  I can imagine EBC compiler/linker implementations that could choose to use CALL within the same OBJ, and CALLEX for all function calls into other OBJs or other PE/COFF images, but you will get better performance if CALL is used for all calls to functions within the same PE/COFF image.

No.  32|64 does not depend on the CPU the image is running on.  Instead, the EBC compiler can perform 32-bit operations on 32-bit operands or 64-bit operations on 64-bit operands.  32-bit CPUs do support both 32-bit and 64-bit operands.

The 4 thunk styles are required because the EBC compiler/linker can not know if a call to/from another PE/COFF image is from native code or EBC code.  The compiler/linker only has visibility to the sources for the current PE/COFF image.

Best regards,


-----Original Message-----
From: []
Sent: Tuesday, March 30, 2010 2:14 PM
To: Kinney, Michael D
Subject: Re: [edk2] About EBC calling convention

Hello Kinney

> Mitnick,
> Local function means a function within the same PE/COFF image.

As you say, the Local function is in the same PE(excutable) or just in
the same COFF(obj)??

> A call to an EFI Boot Services, EFI Runtime Service, or a Protocol
> services produced by a different driver would not be a local function.
> Section 20.9.3 of the UEFI 2.3 Specification described how
> parameters are passed on the stack.
> 20.9.3 Parameter Passing
> Parameters are pushed on the VM stack per the CDECL calling
> convention.   Per this convention, the last argument in the
> parameter list is pushed on   the stack first, and the first
> argument in the parameter list is pushed on the stack last.
> All parameters are stored or accessed as natural size (using
> naturally sized instruction) except 64-bit integers, which are
> pushed as 64-bit values. 32-bit integers are pushed as natural size
> (since they should be passed as 64-bit parameter values on 64-bit
> machines).

I have read the uefi specification and survey the source code of EBC VM.
I am wondering what does instruction like
CMPI[32|64]{w|d}[eq|lte|gte|ulte|ugte] {@}R1 {Index16}, Immed16|Immed32
Dose the number 32|64 depend on processor?? or it just a mechanism to save
memory(choosing which form is depend on the compiler)??

I also have some problem about the thunking,
in the specification there is a sentence in chapter 20.10.2 EBC
Execution Interfacing Requirements of uefi 2.3 specification:
To maintain backward compatibility with existing native code,
and minimize the overhead for non-EBC drivers calling EBC protocols,
all four transitions must be seamless from the application perspective.
does it means that thunking is decided in linking time? because
compiler cannot
identify difference in the source code?



Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
edk2-devel mailing list