Go to file
Nigel Croxon 6caab22f23 From: Laszlo Ersek <lersek@redhat.com>
Date: Mon, 2 Jun 2014 23:26:48 +0200
Subject: [PATCH] always observe EFIAPI calling convention when calling
 STO.SetAttribute

We have to consider the following cases wrt. the PRINT_STATE.Output and
PRINT_STATE.SetAttr EFIAPI function pointers, especially when building for
x86_64 with gcc:

(1) The compiler is new enough, and EFIAPI actually ensures the Microsoft
    calling convention. In this case everything happens to work fine even
    if we forget uefi_call_wrapper(), because the wrapper would expand to
    a normal C function call anyway.

(2) Otherwise (ie. gcc is old), EFIAPI expands to nothing, and we must
    take into account the called function's origin:

  (2a) If the callee that is declared EFIAPI is *defined* inside gnu-efi,
       then EFIAPI means nothing for the callee too, so caller and callee
       only understand each other if the caller intentionally omits
       uefi_call_wrapper().

  (2b) If the callee that is declared EFIAPI is defined by the platform
       UEFI implementation, then the caller *must* use
       uefi_call_wrapper().

The PRINT_STATE.Output EFIAPI function pointer is dereferenced correctly:
the PFLUSH() distinguishes cases (2a) from (2b) by using IsLocalPrint().

However use of the PRINT_STATE.SetAttr EFIAPI function pointer is not
always correct:

- The PSETATTR() helper function always relies on the wrapper (case (2b)).
  This is correct, because PRINT_STATE.SetAttr always points to a
  platform-provided function.

- The DbgPrint() function contains two incorrect calls: they mistakenly
  assume case (2a) (or case (1)), even though the pointer always points to
  a platform function, implying (2b). (The error is masked in case (1).)
  Fix them.

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Nigel Croxon <nigel.croxon@hp.com>
2014-06-19 10:39:23 -04:00
gnu-efi-3.0 From: Laszlo Ersek <lersek@redhat.com> 2014-06-19 10:39:23 -04:00