Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Nov 2025 21:51:37 -0700
From:      Warner Losh <imp@bsdimp.com>
To:        FreeBSD Current <freebsd-current@freebsd.org>
Subject:   Fwd: git: 396b32e801d6 - main - stand: Add back missing EFIAPI define
Message-ID:  <CANCZdfrSHWJ%2BBdPCE4OTfKDJdjUk8rTDMKsRPnutxyFYh7qq8Q@mail.gmail.com>
In-Reply-To: <202511180445.5AI4jnYK085911@gitrepo.freebsd.org>
References:  <202511180445.5AI4jnYK085911@gitrepo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
Normally I don't forward things like this to -current (It's current after
all), but I broke at least the amd64 efi boot loader yesterday and this is
the fix for it. My apologies for anybody that got stuck.

Warner

---------- Forwarded message ---------
From: Warner Losh <imp@freebsd.org>
Date: Mon, Nov 17, 2025 at 9:45 PM
Subject: git: 396b32e801d6 - main - stand: Add back missing EFIAPI define
To: <src-committers@freebsd.org>, <dev-commits-src-all@freebsd.org>, <
dev-commits-src-main@freebsd.org>


The branch main has been updated by imp:

URL:
https://cgit.FreeBSD.org/src/commit/?id=396b32e801d615954750162a616b4e9174b39916

commit 396b32e801d615954750162a616b4e9174b39916
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2025-11-18 04:44:07 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2025-11-18 04:45:59 +0000

    stand: Add back missing EFIAPI define

    EFIAPI has to be defined correctly for amd64, or things won't boot
    because it uses a different API than we normally use. Normally, this
    only affects amd64, since all the other archs are basically nothing.
    Tested on: amd64, aarch64 and armv7 (the frist two by markj and I with
    differnet test setups).

    Fixes:                  43b8edb32051
    Sponsored by:           Netflix
    Reviewed by:            markj
    Differential Revision:  https://reviews.freebsd.org/D53799
---
 sys/sys/efi-edk2.h | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/sys/sys/efi-edk2.h b/sys/sys/efi-edk2.h
index 513c56549803..b27b26bd613c 100644
--- a/sys/sys/efi-edk2.h
+++ b/sys/sys/efi-edk2.h
@@ -41,7 +41,20 @@ typedef void VOID;

 /* We can't actually call this stuff, so snip out API syntactic sugar */
 #define INTERFACE_DECL(x) struct x
+#ifdef _STANDALONE
+#if defined(__amd64__)
+#define EFIAPI    __attribute__((ms_abi))
+#endif
+#ifndef EFIAPI                  // Forces EFI calling conventions
reguardless of compiler options
+    #ifdef _MSC_EXTENSIONS
+        #define EFIAPI __cdecl  // Force C calling convention for
Microsoft C compiler
+    #else
+        #define EFIAPI          // Substitute expresion to force C calling
convention
+    #endif
+#endif
+#else
 #define EFIAPI
+#endif
 #define IN
 #define OUT
 #define CONST const
@@ -64,11 +77,13 @@ typedef void VOID;
 #define PACKED

 /*
- * Since we're not compiling for the UEFI boot time (which use ms abi
- * conventions), tell EDK2 to define VA_START correctly. For the boot
- * loader, this likely needs to be different.
+ * For userland and the kernel, we're not compiling for the UEFI boot time
+ * (which use ms abi conventions on amd64), tell EDK2 to define VA_START
+ * correctly. For the boot loader, we can't do that, so don't.
  */
+#ifndef _STANDALONE
 #define NO_MSABI_VA_FUNCS 1
+#endif

 /*
  * Finally, we need to define the processor we are in EDK2 terms.

[-- Attachment #2 --]
<div dir="ltr">Normally I don&#39;t forward things like this to -current (It&#39;s current after all), but I broke at least the amd64 efi boot loader yesterday and this is the fix for it. My apologies for anybody that got stuck.<div><br></div><div><div>Warner</div><div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">---------- Forwarded message ---------<br>From: <strong class="gmail_sendername" dir="auto">Warner Losh</strong> <span dir="auto">&lt;<a href="mailto:imp@freebsd.org">imp@freebsd.org</a>&gt;</span><br>Date: Mon, Nov 17, 2025 at 9:45 PM<br>Subject: git: 396b32e801d6 - main - stand: Add back missing EFIAPI  define<br>To:  &lt;<a href="mailto:src-committers@freebsd.org">src-committers@freebsd.org</a>&gt;,  &lt;<a href="mailto:dev-commits-src-all@freebsd.org">dev-commits-src-all@freebsd.org</a>&gt;,  &lt;<a href="mailto:dev-commits-src-main@freebsd.org">dev-commits-src-main@freebsd.org</a>&gt;<br></div><br><br>The branch main has been updated by imp:<br>
<br>
URL: <a href="https://cgit.FreeBSD.org/src/commit/?id=396b32e801d615954750162a616b4e9174b39916" rel="noreferrer" target="_blank">https://cgit.FreeBSD.org/src/commit/?id=396b32e801d615954750162a616b4e9174b39916</a><br>;
<br>
commit 396b32e801d615954750162a616b4e9174b39916<br>
Author:     Warner Losh &lt;imp@FreeBSD.org&gt;<br>
AuthorDate: 2025-11-18 04:44:07 +0000<br>
Commit:     Warner Losh &lt;imp@FreeBSD.org&gt;<br>
CommitDate: 2025-11-18 04:45:59 +0000<br>
<br>
    stand: Add back missing EFIAPI define<br>
<br>
    EFIAPI has to be defined correctly for amd64, or things won&#39;t boot<br>
    because it uses a different API than we normally use. Normally, this<br>
    only affects amd64, since all the other archs are basically nothing.<br>
    Tested on: amd64, aarch64 and armv7 (the frist two by markj and I with<br>
    differnet test setups).<br>
<br>
    Fixes:                  43b8edb32051<br>
    Sponsored by:           Netflix<br>
    Reviewed by:            markj<br>
    Differential Revision:  <a href="https://reviews.freebsd.org/D53799" rel="noreferrer" target="_blank">https://reviews.freebsd.org/D53799</a><br>;
---<br>
 sys/sys/efi-edk2.h | 21 ++++++++++++++++++---<br>
 1 file changed, 18 insertions(+), 3 deletions(-)<br>
<br>
diff --git a/sys/sys/efi-edk2.h b/sys/sys/efi-edk2.h<br>
index 513c56549803..b27b26bd613c 100644<br>
--- a/sys/sys/efi-edk2.h<br>
+++ b/sys/sys/efi-edk2.h<br>
@@ -41,7 +41,20 @@ typedef void VOID;<br>
<br>
 /* We can&#39;t actually call this stuff, so snip out API syntactic sugar */<br>
 #define INTERFACE_DECL(x) struct x<br>
+#ifdef _STANDALONE<br>
+#if defined(__amd64__)<br>
+#define EFIAPI    __attribute__((ms_abi))<br>
+#endif<br>
+#ifndef EFIAPI                  // Forces EFI calling conventions reguardless of compiler options<br>
+    #ifdef _MSC_EXTENSIONS<br>
+        #define EFIAPI __cdecl  // Force C calling convention for Microsoft C compiler<br>
+    #else<br>
+        #define EFIAPI          // Substitute expresion to force C calling convention<br>
+    #endif<br>
+#endif<br>
+#else<br>
 #define EFIAPI<br>
+#endif<br>
 #define IN<br>
 #define OUT<br>
 #define CONST const<br>
@@ -64,11 +77,13 @@ typedef void VOID;<br>
 #define PACKED<br>
<br>
 /*<br>
- * Since we&#39;re not compiling for the UEFI boot time (which use ms abi<br>
- * conventions), tell EDK2 to define VA_START correctly. For the boot<br>
- * loader, this likely needs to be different.<br>
+ * For userland and the kernel, we&#39;re not compiling for the UEFI boot time<br>
+ * (which use ms abi conventions on amd64), tell EDK2 to define VA_START<br>
+ * correctly. For the boot loader, we can&#39;t do that, so don&#39;t.<br>
  */<br>
+#ifndef _STANDALONE<br>
 #define NO_MSABI_VA_FUNCS 1<br>
+#endif<br>
<br>
 /*<br>
  * Finally, we need to define the processor we are in EDK2 terms.<br>
<br>
</div></div></div></div>

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CANCZdfrSHWJ%2BBdPCE4OTfKDJdjUk8rTDMKsRPnutxyFYh7qq8Q>