]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Thunk16.S
EdkCompatabilityPkg: Fix build issues with X64 clang
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / Thunk16 / X64 / Thunk16.S
index 26709e61b06006d0e33b89014b293dfa94809cba..7328ab764d99b53cde18bde4d2f8b4d1991fc407 100644 (file)
@@ -1,7 +1,7 @@
 #*****************************************************************************\r
 #*\r
-#*   Copyright (c) 2008, Intel Corporation                                                         \r
-#*   All rights reserved. This program and the accompanying materials                          \r
+#*   Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>\r
+#*   This program and the accompanying materials                          \r
 #*   are licensed and made available under the terms and conditions of the BSD License         \r
 #*   which accompanies this distribution.  The full text of the license may be found at        \r
 #*   http://opensource.org/licenses/bsd-license.php                                            \r
@@ -20,7 +20,7 @@
 #*****************************************************************************\r
 #include <EfiBind.h>\r
 \r
-\r
+#ifndef __APPLE__\r
 \r
     .data\r
 \r
@@ -106,6 +106,9 @@ ASM_PFX(Thunk16):
       pushq  $0xe                       #push    sizeof (IA32_REGS) / 4\r
       pop    %rcx\r
       rep movsl %ds:(%rsi),%es:(%rdi)\r
+      #; copy eflags to stack frame\r
+      mov    -16(%rsi), %rax\r
+      mov    %rax, -80(%rsi)\r
       pop    %rbx                       #rbx <- 16-bit stack offset\r
       lea    Label,%eax                 #42 <_Thunk16+0x42>\r
       stos   %eax,%es:(%rdi)\r
@@ -166,7 +169,7 @@ Label:
       retq   \r
 \r
 \r
-    .align 0x10\r
+    .p2align 4\r
 \r
 _Code16Addr:\r
 ASM_PFX(RealMode):\r
@@ -183,27 +186,30 @@ ASM_PFX(RealMode):
    .byte   0x07                        #pop es\r
     popq   %fs\r
     popq   %gs\r
-    add    $0x8,%esp                   #skip RFLAGS\r
-   .byte   0x67                        #test [esp + 0eh], 1\r
+    sub    64, %esp\r
+    .byte  0x66, 0x9d                  #popfd\r
+    add    $0x4,%esp                   #skip high part of RFLAGS\r
+   .byte   0x67                        #; test    (_STK16 ptr [esp + STACK_PARAM_SIZE + sizeof(IA32_REGS)]).ThunkFlags, 1\r
    .byte   0xf7    \r
    .byte   0x44\r
    .byte   0x24\r
-   .byte   0x0e\r
+   .byte   0x4e\r
    .byte   0x01\r
    .byte   0x00\r
     jz      1f\r
-    pushfq                             #pushf, actually\r
+    pushfq                             #pushf, actually, when it's INT#\r
 1:\r
    .byte   0x0e                        #push cs\r
    .byte   0x68                        #push /iw\r
    .word   FarCallRet - _Code16Addr\r
     jz     2f\r
    .byte   0x66\r
-    ljmp   *6(%esp)\r
+    ljmp   *70(%esp)\r
 2:    \r
    .byte   0x66\r
-    ljmp   *4(%esp)\r
+    ljmp   *68(%esp)\r
 FarCallRet: \r
+    add    64, %esp\r
    .byte   0x66\r
     push   $0x00                       #push a dword of zero\r
    .byte   0x66\r
@@ -234,3 +240,5 @@ FarCallRet:
 _16Idtr:\r
    .word 0x3ff                          #FWORD   (1 SHL 10) - 1\r
    .byte 0x00\r
+\r
+#endif\r