noxorc преди 12 години
родител
ревизия
1d931b46c0

+ 57 - 0
gnu-efi-3.0/ChangeLog

@@ -1,3 +1,60 @@
+2013-02-21 Nigel Croxon <nigel.croxon@hp.com>
+	* Change from Peter Jones <pjones@redhat.com>
+	  - Previously we were incorrectly passing 3 functions with
+            the System V ABI to UEFI functions as EFI ABI functions.
+            Mark them as EFIAPI so the compiler will (in our new
+            GNU_EFI_USE_MS_ABI world) use the correct ABI.
+          - These need to be EFIAPI functions because in some cases
+            they call ST->ConOut->OutputString(), which is an EFIAPI
+            function. (Which means that previously in cases that 
+            needed "cdecl", these didn't work right.)
+          - If the compiler version is new enough, and GNU_EFI_USE_MS_ABI
+            is defined, use the function attribute ms_abi on everything
+            defined with "EFIAPI".  Such calls will no longer go through
+            efi_call*, and as such will be properly type-checked.
+          - Honor PREFIX and LIBDIR correctly when passed in during the build.
+          - Add machine type defines for i386, arm/thumb, ia64, ebc, x86_64.
+          - __STDC_VERSION__ never actually gets defined unless there's a
+            --std=... line.  So we were accidentally defining lots of c99
+            types ourself. Since it's 2012, use --std=c11 where appropriate,
+            and if it's defined and we're using gcc, actually include gcc's
+            stdint definitions.
+          - New test application added: route80h. This is a test program
+            for PciIo.  It routes ioport 80h on ICH10 to PCI. This is also
+            useful on a very limited set of hardware to enable use of
+            a port 80h debug card.
+          - New test applcation added: modelist. This lists video modes
+            the GOP driver is showing us.
+	* Change from Finnbarr Murphy
+          - https://sourceforge.net/p/gnu-efi/feature-requests/2/
+            Please add the following status codes to <efierr.h>
+            EFI_INCOMPATIBLE_VERSION 25
+            EFI_SECURITY_VIOLATION 26 
+            EFI_CRC_ERROR 27 
+            EFI_END_OF_MEDIA 28 
+            EFI_END_OF_FILE 31 
+            EFI_INVALID_LANGUAGE 32 
+            EFI_COMPROMISED_DATA 33
+	* Change from SourceForge.net Bug report
+          - https://sourceforge.net/p/gnu-efi/bugs/5/
+            BufferSize is a UINT64 *. The file shipped with GNU EFI is from
+            1998 whereas the latest one is from 2004. I suspect Intel changed
+            the API in order handle 64-bit systems.
+        * Change from Felipe Contreras <felipe.contreras@gmail.com>
+          - The current code seems to screw the stack at certain points.
+            Multiple people have complained that gummiboot hangs right away,
+            which is in part the fault of gummiboot, but happens only
+            because the stack gets screwed. x86_64 EFI already aligns the
+            stack, so there's no need for so much code to find a proper
+            alignment, we always need to shift by 8 anyway.
+        * Change from A. Steinmetz
+          - https://sourceforge.net/p/gnu-efi/patches/1/
+            The patch prepares for elilo to support uefi pxe over ipv6
+            See uefi spec 2.3.1 errata c page 963 as reference.
+            Verfied on an ASUS Sabertooth X79 BIOS Rev. 2104 system which
+            is able to do an IPv6 UEFI PXE boot.
+	* Release 3.0t
+
 2012-09-21 Nigel Croxon <nigel.croxon@hp.com>
 	* Change from Peter Jones <pjones@redhat.com>
 	  - EFI Block I/O protocol versions 2 and 3 provide more information

+ 10 - 3
gnu-efi-3.0/Make.defaults

@@ -38,8 +38,9 @@
 # Where to install the package. GNU-EFI will create and access
 # lib and include under the root
 #
-INSTALLROOT=/usr/local
-LIBDIR=lib
+INSTALLROOT := /
+PREFIX := /usr/local
+LIBDIR := ${PREFIX}/lib
 
 TOPDIR    := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
 
@@ -47,7 +48,14 @@ HOSTARCH   = $(shell uname -m | sed s,i[3456789]86,ia32,)
 ARCH	   := $(shell uname -m | sed s,i[3456789]86,ia32,)
 OS	   = $(shell uname -s)
 INCDIR	   = -I$(SRCDIR) -I$(TOPDIR)/inc -I$(TOPDIR)/inc/$(ARCH) -I$(TOPDIR)/inc/protocol 
+GCCVERSION := $(shell gcc -dumpversion | cut -f1 -d.)
+GCCMINOR := $(shell gcc -dumpversion | cut -f2 -d.)
+GCCNEWENOUGH := $(shell ([ $(GCCVERSION) -gt "4" ] || ([ $(GCCVERSION) -eq "4" ] && [ $(GCCMINOR) -ge "7" ])) && echo 1)
+
 CPPFLAGS   = -DCONFIG_$(ARCH)
+ifeq ($(GCCNEWENOUGH),1)
+CPPFLAGS   += -DGNU_EFI_USE_MS_ABI -maccumulate-outgoing-args --std=c11
+endif
 CFLAGS	   = $(ARCH3264) -O2 -fpic -Wall -fshort-wchar -fno-strict-aliasing -fno-merge-constants
 ASFLAGS    = $(ARCH3264)
 LDFLAGS	   = -nostdlib
@@ -73,7 +81,6 @@ endif
 
 ifeq ($(ARCH), x86_64)
   CFLAGS += -mno-red-zone
-  LIBDIR = lib
   ifeq ($(HOSTARCH), ia32)
     ARCH3264 = -m64
   endif

+ 5 - 0
gnu-efi-3.0/Make.rules

@@ -44,3 +44,8 @@
 %.o: %.c
 	$(CC) $(INCDIR) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
 
+%.S: %.c
+	$(CC) $(INCDIR) $(CFLAGS) $(CPPFLAGS) -S $< -o $@
+
+%.E: %.c
+	$(CC) $(INCDIR) $(CFLAGS) $(CPPFLAGS) -E $< -o $@

+ 1 - 1
gnu-efi-3.0/apps/Makefile

@@ -58,7 +58,7 @@ LDFLAGS		+= -T $(LDSCRIPT) -shared -Bsymbolic -L../lib -L../gnuefi $(CRTOBJS)
 LOADLIBES	= -lefi -lgnuefi $(shell $(CC) $(ARCH3264) -print-libgcc-file-name)
 FORMAT		= efi-app-$(ARCH)
 
-TARGETS = t.efi t2.efi t3.efi t4.efi t5.efi t6.efi printenv.efi t7.efi tcc.efi
+TARGETS = t.efi t2.efi t3.efi t4.efi t5.efi t6.efi printenv.efi t7.efi tcc.efi modelist.efi route80h.efi
 
 all:	$(TARGETS)
 

+ 1 - 1
gnu-efi-3.0/apps/tcc.c

@@ -337,7 +337,7 @@ efi_main (EFI_HANDLE *image, EFI_SYSTEM_TABLE *systab)
 	return EFI_UNSUPPORTED;
 #endif
 
-	asm volatile("out %0,%1" : : "a" ((uint8_t)0x14), "dN" (0x80));
+	__asm__ volatile("out %0,%1" : : "a" ((uint8_t)0x14), "dN" (0x80));
 
 	Print(L"Hello\r\n");
 	rc = test_failure();

+ 8 - 8
gnu-efi-3.0/inc/Makefile

@@ -13,15 +13,15 @@ all:
 clean:
 
 install:
-	mkdir -p $(INSTALLROOT)/include/efi
-	mkdir -p $(INSTALLROOT)/include/efi/protocol
-	mkdir -p $(INSTALLROOT)/include/efi/$(ARCH)
-	$(INSTALL) -m 644 *.h $(INSTALLROOT)/include/efi
-	$(INSTALL) -m 644 protocol/*.h $(INSTALLROOT)/include/efi/protocol
-	$(INSTALL) -m 644 $(ARCH)/*.h $(INSTALLROOT)/include/efi/$(ARCH)
+	mkdir -p $(INSTALLROOT)$(PREFIX)/include/efi
+	mkdir -p $(INSTALLROOT)$(PREFIX)/include/efi/protocol
+	mkdir -p $(INSTALLROOT)$(PREFIX)/include/efi/$(ARCH)
+	$(INSTALL) -m 644 *.h $(INSTALLROOT)$(PREFIX)/include/efi
+	$(INSTALL) -m 644 protocol/*.h $(INSTALLROOT)$(PREFIX)/include/efi/protocol
+	$(INSTALL) -m 644 $(ARCH)/*.h $(INSTALLROOT)$(PREFIX)/include/efi/$(ARCH)
 ifeq ($(ARCH),ia64)
-	mkdir -p $(INSTALLROOT)/include/efi/protocol/ia64
-	$(INSTALL) -m 644 protocol/ia64/*.h $(INSTALLROOT)/include/efi/protocol/ia64
+	mkdir -p $(INSTALLROOT)$(PREFIX)/include/efi/protocol/ia64
+	$(INSTALL) -m 644 protocol/ia64/*.h $(INSTALLROOT)$(PREFIX)/include/efi/protocol/ia64
 endif
 
 include $(SRCDIR)/../Make.rules

+ 7 - 0
gnu-efi-3.0/inc/efierr.h

@@ -50,6 +50,13 @@ Revision History
 #define EFI_ICMP_ERROR                  EFIERR(22)
 #define EFI_TFTP_ERROR                  EFIERR(23)
 #define EFI_PROTOCOL_ERROR              EFIERR(24)
+#define EFI_INCOMPATIBLE_VERSION        EFIERR(25)
+#define EFI_SECURITY_VIOLATION          EFIERR(26)
+#define EFI_CRC_ERROR                   EFIERR(27)
+#define EFI_END_OF_MEDIA                EFIERR(28)
+#define EFI_END_OF_FILE                 EFIERR(31)
+#define EFI_INVALID_LANGUAGE            EFIERR(32)
+#define EFI_COMPROMISED_DATA            EFIERR(33)
 
 #define EFI_WARN_UNKOWN_GLYPH           EFIWARN(1)
 #define EFI_WARN_DELETE_FAILURE         EFIWARN(2)

+ 7 - 6
gnu-efi-3.0/inc/efipxebc.h

@@ -65,15 +65,16 @@ typedef struct {
     UINT8                           DhcpOptions[56];
 } EFI_PXE_BASE_CODE_DHCPV4_PACKET;
 
-// TBD in EFI v1.1
-//typedef struct {
-//    UINT8                           reserved;
-//} EFI_PXE_BASE_CODE_DHCPV6_PACKET;
+typedef struct {
+    UINT32                          MessageType:8;
+    UINT32                          TransactionId:24;
+    UINT8                           DhcpOptions[1024];
+} EFI_PXE_BASE_CODE_DHCPV6_PACKET;
 
 typedef union {
     UINT8                               Raw[1472];
     EFI_PXE_BASE_CODE_DHCPV4_PACKET     Dhcpv4;
-//    EFI_PXE_BASE_CODE_DHCPV6_PACKET     Dhcpv6;
+    EFI_PXE_BASE_CODE_DHCPV6_PACKET     Dhcpv6;
 } EFI_PXE_BASE_CODE_PACKET;
 
 typedef struct {
@@ -297,7 +298,7 @@ EFI_STATUS
     IN EFI_PXE_BASE_CODE_TFTP_OPCODE    Operation,
     IN OUT VOID                         *BufferPtr  OPTIONAL,
     IN BOOLEAN                          Overwrite,
-    IN OUT UINTN                        *BufferSize,
+    IN OUT UINT64                       *BufferSize,
     IN UINTN                            *BlockSize  OPTIONAL,
     IN EFI_IP_ADDRESS                   *ServerIp,
     IN UINT8                            *Filename,

+ 2 - 0
gnu-efi-3.0/inc/ia32/efibind.h

@@ -75,6 +75,8 @@ Revision History
        typedef unsigned char       uint8_t;
        typedef char                int8_t;
     #endif
+#elif defined(__GNUC__)
+    #include <stdint-gcc.h>
 #endif
 
 //

+ 4 - 0
gnu-efi-3.0/inc/ia32/pe.h

@@ -98,8 +98,12 @@ typedef struct _IMAGE_FILE_HEADER {
 #define IMAGE_FILE_MACHINE_R3000             0x162   // MIPS little-endian, 0540 big-endian
 #define IMAGE_FILE_MACHINE_R4000             0x166   // MIPS little-endian
 #define IMAGE_FILE_MACHINE_ALPHA             0x184   // Alpha_AXP
+#define IMAGE_FILE_MACHINE_ARMTHUMB_MIXED    0x1c2   // Arm/Thumb
 #define IMAGE_FILE_MACHINE_POWERPC           0x1F0   // IBM PowerPC Little-Endian
+#define IMAGE_FILE_MACHINE_IA64              0x200   // IA-64
 #define IMAGE_FILE_MACHINE_TAHOE             0x7cc   // Intel EM machine
+#define IMAGE_FILE_MACHINE_EBC               0xebc   // EFI Byte Code
+#define IMAGE_FILE_MACHINE_X64               0x8664  // x86_64
 //
 // Directory format.
 //

+ 2 - 0
gnu-efi-3.0/inc/ia64/efibind.h

@@ -62,6 +62,8 @@ Revision History
         typedef unsigned char       uint8_t;
         typedef char                int8_t;
     #endif
+#elif defined(__GNUC__)
+    #include <stdint-gcc.h>
 #endif
 
 //

+ 4 - 0
gnu-efi-3.0/inc/ia64/pe.h

@@ -113,8 +113,12 @@ typedef struct _IMAGE_FILE_HEADER {
 #define IMAGE_FILE_MACHINE_R3000             0x162   // MIPS little-endian, 0540 big-endian
 #define IMAGE_FILE_MACHINE_R4000             0x166   // MIPS little-endian
 #define IMAGE_FILE_MACHINE_ALPHA             0x184   // Alpha_AXP
+#define IMAGE_FILE_MACHINE_ARMTHUMB_MIXED    0x1c2   // Arm/Thumb
 #define IMAGE_FILE_MACHINE_POWERPC           0x1F0   // IBM PowerPC Little-Endian
+#define IMAGE_FILE_MACHINE_IA64              0x200   // IA-64
 #define IMAGE_FILE_MACHINE_TAHOE             0x7cc   // Intel EM machine
+#define IMAGE_FILE_MACHINE_EBC               0xebc   // EFI Byte Code
+#define IMAGE_FILE_MACHINE_X64               0x8664  // x86_64
 //
 // Directory format.
 //

+ 17 - 0
gnu-efi-3.0/inc/x86_64/efibind.h

@@ -22,6 +22,14 @@ Revision History
 #pragma pack()
 #endif
 
+#if defined(GNU_EFI_USE_MS_ABI)
+    #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7))
+        #define HAVE_USE_MS_ABI 1
+    #else
+        #error Compiler is too old for GNU_EFI_USE_MS_ABI
+    #endif
+#endif
+
 //
 // Basic int types of various widths
 //
@@ -76,6 +84,8 @@ Revision History
        typedef unsigned char       uint8_t;
        typedef char                int8_t;
     #endif
+#elif defined(__GNUC__)
+    #include <stdint-gcc.h>
 #endif
 
 //
@@ -173,6 +183,9 @@ typedef uint64_t   UINTN;
 #ifndef EFIAPI                  // Forces EFI calling conventions reguardless of compiler options 
     #ifdef _MSC_EXTENSIONS
         #define EFIAPI __cdecl  // Force C calling convention for Microsoft C compiler 
+    #elif defined(HAVE_USE_MS_ABI)
+        // Force amd64/ms calling conventions.
+        #define EFIAPI __attribute__((ms_abi))
     #else
         #define EFIAPI          // Substitute expresion to force C calling convention 
     #endif
@@ -274,7 +287,11 @@ typedef uint64_t   UINTN;
 #endif
 
 /* for x86_64, EFI_FUNCTION_WRAPPER must be defined */
+#if defined(HAVE_USE_MS_ABI)
+#define uefi_call_wrapper(func, va_num, ...) func(__VA_ARGS__)
+#else
 UINTN uefi_call_wrapper(void *func, unsigned long va_num, ...);
+#endif
 #define EFI_FUNCTION __attribute__((ms_abi))
 
 #ifdef _MSC_EXTENSIONS

+ 4 - 0
gnu-efi-3.0/inc/x86_64/pe.h

@@ -98,8 +98,12 @@ typedef struct _IMAGE_FILE_HEADER {
 #define IMAGE_FILE_MACHINE_R3000             0x162   // MIPS little-endian, 0540 big-endian
 #define IMAGE_FILE_MACHINE_R4000             0x166   // MIPS little-endian
 #define IMAGE_FILE_MACHINE_ALPHA             0x184   // Alpha_AXP
+#define IMAGE_FILE_MACHINE_ARMTHUMB_MIXED    0x1c2   // Arm/Thumb
 #define IMAGE_FILE_MACHINE_POWERPC           0x1F0   // IBM PowerPC Little-Endian
+#define IMAGE_FILE_MACHINE_IA64              0x200   // IA-64
 #define IMAGE_FILE_MACHINE_TAHOE             0x7cc   // Intel EM machine
+#define IMAGE_FILE_MACHINE_EBC               0xebc   // EFI Byte Code
+#define IMAGE_FILE_MACHINE_X64               0x8664  // x86_64
 //
 // Directory format.
 //

+ 3 - 3
gnu-efi-3.0/lib/lib.h

@@ -44,21 +44,21 @@ InitializeGuid (
     VOID
     );
 
-INTN
+INTN EFIAPI
 LibStubStriCmp (
     IN EFI_UNICODE_COLLATION_INTERFACE  *This,
     IN CHAR16                           *S1,
     IN CHAR16                           *S2
     );
 
-BOOLEAN
+BOOLEAN EFIAPI
 LibStubMetaiMatch (
     IN EFI_UNICODE_COLLATION_INTERFACE  *This,
     IN CHAR16                           *String,
     IN CHAR16                           *Pattern
     );
 
-VOID
+VOID EFIAPI
 LibStubStrLwrUpr (
     IN EFI_UNICODE_COLLATION_INTERFACE  *This,
     IN CHAR16                           *Str

+ 15 - 13
gnu-efi-3.0/lib/print.c

@@ -95,8 +95,8 @@ typedef struct _pstate {
     UINTN       AttrHighlight;
     UINTN       AttrError;
 
-    INTN        (*Output)(VOID *context, CHAR16 *str);
-    INTN        (*SetAttr)(VOID *context, UINTN attr);
+    INTN EFIAPI       (*Output)(VOID *context, CHAR16 *str);
+    INTN EFIAPI       (*SetAttr)(VOID *context, UINTN attr);
     VOID        *Context;    
 
     // Current item being formatted
@@ -125,7 +125,7 @@ _IPrint (
     );
 
 STATIC
-INTN
+INTN EFIAPI
 _DbgOut (
     IN VOID     *Context,
     IN CHAR16   *Buffer
@@ -167,13 +167,13 @@ PSETATTR (
 //
 //
 
-INTN
+INTN EFIAPI
 _SPrint (
     IN VOID     *Context,
     IN CHAR16   *Buffer
     );
 
-INTN
+INTN EFIAPI
 _PoolPrint (
     IN VOID     *Context,
     IN CHAR16   *Buffer
@@ -235,7 +235,7 @@ Returns:
     if (DbgOut) {
         ps.Attr = DbgOut->Mode->Attribute;
         ps.Context = DbgOut;
-        ps.SetAttr = (INTN (*)(VOID *, UINTN))  DbgOut->SetAttribute;
+        ps.SetAttr = (INTN EFIAPI (*)(VOID *, UINTN))  DbgOut->SetAttribute;
     }
 
     SavedAttribute = ps.Attr;
@@ -276,7 +276,9 @@ Returns:
     return 0;
 }
 
-STATIC IsLocalPrint(void *func)
+STATIC
+INTN
+IsLocalPrint(void *func)
 {
 	if (func == _DbgOut || func == _SPrint || func == _PoolPrint)
 		return 1;
@@ -284,7 +286,7 @@ STATIC IsLocalPrint(void *func)
 }
 
 STATIC
-INTN
+INTN EFIAPI
 _DbgOut (
     IN VOID     *Context,
     IN CHAR16   *Buffer
@@ -308,7 +310,7 @@ _DbgOut (
     return 0;
 }
 
-INTN
+INTN EFIAPI
 _SPrint (
     IN VOID     *Context,
     IN CHAR16   *Buffer
@@ -350,7 +352,7 @@ _SPrint (
 }
 
 
-INTN
+INTN EFIAPI
 _PoolPrint (
     IN VOID     *Context,
     IN CHAR16   *Buffer
@@ -401,7 +403,7 @@ _PoolCatPrint (
     IN CHAR16           *fmt,
     IN va_list          args,
     IN OUT POOL_PRINT   *spc,
-    IN INTN             (*Output)(VOID *context, CHAR16 *str)
+    IN INTN EFIAPI      (*Output)(VOID *context, CHAR16 *str)
     )
 // Dispath function for SPrint, PoolPrint, and CatPrint
 {
@@ -715,8 +717,8 @@ _IPrint (
 
     ZeroMem (&ps, sizeof(ps));
     ps.Context = Out;
-    ps.Output  = (INTN (*)(VOID *, CHAR16 *)) Out->OutputString;
-    ps.SetAttr = (INTN (*)(VOID *, UINTN))  Out->SetAttribute;
+    ps.Output  = (INTN EFIAPI (*)(VOID *, CHAR16 *)) Out->OutputString;
+    ps.SetAttr = (INTN EFIAPI (*)(VOID *, UINTN))  Out->SetAttribute;
     ps.Attr = Out->Mode->Attribute;
    
     back = (ps.Attr >> 4) & 0xF;

+ 3 - 3
gnu-efi-3.0/lib/str.c

@@ -50,7 +50,7 @@ StrnCmp (
 }
 
 
-INTN
+INTN EFIAPI
 LibStubStriCmp (
     IN EFI_UNICODE_COLLATION_INTERFACE  *This,
     IN CHAR16                           *s1,
@@ -60,7 +60,7 @@ LibStubStriCmp (
     return StrCmp (s1, s2);
 }
 
-VOID
+VOID EFIAPI
 LibStubStrLwrUpr (
     IN EFI_UNICODE_COLLATION_INTERFACE  *This,
     IN CHAR16                           *Str
@@ -356,7 +356,7 @@ MetaMatch (
 }
 
 
-BOOLEAN
+BOOLEAN EFIAPI
 LibStubMetaiMatch (
     IN EFI_UNICODE_COLLATION_INTERFACE  *This,
     IN CHAR16                           *String,

+ 2 - 0
gnu-efi-3.0/lib/x86_64/callwrap.c

@@ -40,6 +40,7 @@
 #include "efi.h"
 #include "efistdarg.h"
 
+#if !defined(HAVE_USE_MS_ABI)
 UINT64 efi_call0(void *func);
 UINT64 efi_call1(void *func, UINT64 arg1);
 UINT64 efi_call2(void *func, UINT64 arg1, UINT64 arg2);
@@ -123,3 +124,4 @@ EFI_STATUS uefi_call_wrapper(void *fp, unsigned long va_num, ...)
 		return EFI_LOAD_ERROR;
 	}
 }
+#endif

+ 58 - 143
gnu-efi-3.0/lib/x86_64/efi_stub.S

@@ -4,8 +4,10 @@
  * Copyright (C) 2007 Intel Corp
  *	Bibo Mao <bibo.mao@intel.com>
  *	Huang Ying <ying.huang@intel.com>
+ * Copyright (C) 2012 Felipe Contreras <felipe.contreras@gmail.com>
  */
 
+#if !defined(HAVE_USE_MS_ABI)
 /*
  * EFI calling conventions are documented at:
  *   http://msdn.microsoft.com/en-us/library/ms235286%28v=vs.80%29.aspx
@@ -14,152 +16,94 @@
  *
  * Basically here are the conversion rules:
  * a) our function pointer is in %rdi
- * b) ELF gives us 8-byte aligned %rsp, so we need to pad out to 16-byte
- *    alignment.
- * c) inside each call thunker, we can only adjust the stack by
- *    multiples of 16 bytes. "offset" below refers to however much
- *    we allocate inside a thunker.
- * d) rsi through r8 (elf) aka rcx through r9 (ms) require stack space
+ * b) rsi through r8 (elf) aka rcx through r9 (ms) require stack space
  *    on the MS side even though it's not getting used at all.
- * e) arguments are as follows: (elf -> ms)
+ * c) 8(%rsp) is always aligned to 16 in ELF, so %rsp is shifted 8 bytes extra
+ * d) arguments are as follows: (elf -> ms)
  *   1) rdi -> rcx (32 saved)
  *   2) rsi -> rdx (32 saved)
- *   3) rdx -> r8 ( 32 saved)
+ *   3) rdx -> r8 (32 saved)
  *   4) rcx -> r9 (32 saved)
- *   5) r8 -> 32(%rsp) (48 saved)
+ *   5) r8 -> 32(%rsp) (32 saved)
  *   6) r9 -> 40(%rsp) (48 saved)
- *   7) pad+offset+0(%rsp) -> 48(%rsp) (64 saved)
- *   8) pad+offset+8(%rsp) -> 56(%rsp) (64 saved)
- *   9) pad+offset+16(%rsp) -> 64(%rsp) (80 saved)
- *  10) pad+offset+24(%rsp) -> 72(%rsp) (80 saved)
- *  11) pad+offset+32(%rsp) -> 80(%rsp) (96 saved)
- *  12) pad+offset+40(%rsp) -> 88(%rsp) (96 saved)
- * f) because the first argument we recieve in a thunker is actually the
+ *   7) 8(%rsp) -> 48(%rsp) (48 saved)
+ *   8) 16(%rsp) -> 56(%rsp) (64 saved)
+ *   9) 24(%rsp) -> 64(%rsp) (64 saved)
+ *  10) 32(%rsp) -> 72(%rsp) (80 saved)
+ * e) because the first argument we recieve in a thunker is actually the
  *    function to be called, arguments are offset as such:
  *   0) rdi -> caller
  *   1) rsi -> rcx (32 saved)
  *   2) rdx -> rdx (32 saved)
  *   3) rcx -> r8 (32 saved)
  *   4) r8 -> r9 (32 saved)
- *   5) r9 -> 32(%rsp) (48 saved)
- *   6) pad+offset+0(%rsp) -> 40(%rsp) (48 saved)
- *   7) pad+offset+8(%rsp) -> 48(%rsp) (64 saved)
- *   8) pad+offset+16(%rsp) -> 56(%rsp) (64 saved)
- *   9) pad+offset+24(%rsp) -> 64(%rsp) (80 saved)
- *  10) pad+offset+32(%rsp) -> 72(%rsp) (80 saved)
- *  11) pad+offset+40(%rsp) -> 80(%rsp) (96 saved)
- *  12) pad+offset+48(%rsp) -> 88(%rsp) (96 saved)
- * e) arguments need to be moved in opposite order to avoid clobbering
- * f) pad_stack leaves the amount of padding it added in %r11 for functions
- *    to use
- * g) efi -> elf calls don't need to pad the stack, because the 16-byte
- *    alignment is also always 8-byte aligned.
+ *   5) r9 -> 32(%rsp) (32 saved)
+ *   6) 8(%rsp) -> 40(%rsp) (48 saved)
+ *   7) 16(%rsp) -> 48(%rsp) (48 saved)
+ *   8) 24(%rsp) -> 56(%rsp) (64 saved)
+ *   9) 32(%rsp) -> 64(%rsp) (64 saved)
+ *  10) 40(%rsp) -> 72(%rsp) (80 saved)
+ * f) arguments need to be moved in opposite order to avoid clobbering
  */
 
 #define ENTRY(name)	\
 	.globl name;	\
 	name:
 
-#define out(val)		\
-	push %rax ;		\
-	mov val, %rax ;		\
-	out %al, $128 ;		\
-	pop %rax
-
-#define pad_stack							\
-	subq $8, %rsp ; /* must be a multiple of 16 - sizeof(%rip) */	\
-	/* stash some handy integers */					\
-	mov $0x8, %rax ;						\
-	mov $0x10, %r10 ;						\
-	/* see if we need padding */					\
-	and %rsp, %rax ;						\
-	/* store the pad amount in %r11 */				\
-	cmovnz %rax, %r11 ;						\
-	cmovz %r10, %r11 ;						\
-	/* insert the padding */					\
-	subq %r11, %rsp ;						\
-	/* add the $8 we saved above in %r11 */				\
-	addq $8, %r11 ;							\
-	/* store the pad amount */					\
-	mov %r11, (%rsp) ;						\
-	/* compensate for %rip being stored on the stack by call */	\
-	addq $8, %r11
-
-#define unpad_stack							\
-	/* fetch the pad amount	we saved (%r11 has been clobbered) */	\
-	mov (%rsp), %r11 ;						\
-	/* remove the padding */					\
-	addq %r11, %rsp
-
 ENTRY(efi_call0)
-	pad_stack
-	subq $32, %rsp
+	subq $40, %rsp
 	call *%rdi
-	addq $32, %rsp
-	unpad_stack
+	addq $40, %rsp
 	ret
 
 ENTRY(efi_call1)
-	pad_stack
-	subq $32, %rsp
+	subq $40, %rsp
 	mov  %rsi, %rcx
 	call *%rdi
-	addq $32, %rsp
-	unpad_stack
+	addq $40, %rsp
 	ret
 
 ENTRY(efi_call2)
-	pad_stack
-	subq $32, %rsp
+	subq $40, %rsp
 	/* mov %rdx, %rdx */
 	mov  %rsi, %rcx
 	call *%rdi
-	addq $32, %rsp
-	unpad_stack
+	addq $40, %rsp
 	ret
 
 ENTRY(efi_call3)
-	pad_stack
-	subq $32, %rsp
+	subq $40, %rsp
 	mov  %rcx, %r8
 	/* mov %rdx, %rdx */
 	mov  %rsi, %rcx
 	call *%rdi
-	addq $32, %rsp
-	unpad_stack
+	addq $40, %rsp
 	ret
 
 ENTRY(efi_call4)
-	pad_stack
-	subq $32, %rsp
+	subq $40, %rsp
 	mov %r8, %r9
 	mov %rcx, %r8
 	/* mov %rdx, %rdx */
 	mov %rsi, %rcx
 	call *%rdi
-	addq $32, %rsp
-	unpad_stack
+	addq $40, %rsp
 	ret
 
 ENTRY(efi_call5)
-	pad_stack
-	subq $48, %rsp
+	subq $40, %rsp
 	mov %r9, 32(%rsp)
 	mov %r8, %r9
 	mov %rcx, %r8
 	/* mov %rdx, %rdx */
 	mov %rsi, %rcx
 	call *%rdi
-	addq $48, %rsp
-	unpad_stack
+	addq $40, %rsp
 	ret
 
 ENTRY(efi_call6)
-	pad_stack
-	subq $48, %rsp
-	addq $48, %r11
-	addq %rsp, %r11
-	mov (%r11), %rax
+	subq $56, %rsp
+	mov 56+8(%rsp), %rax
 	mov %rax, 40(%rsp)
 	mov %r9, 32(%rsp)
 	mov %r8, %r9
@@ -167,20 +111,14 @@ ENTRY(efi_call6)
 	/* mov %rdx, %rdx */
 	mov %rsi, %rcx
 	call *%rdi
-	addq $48, %rsp
-	unpad_stack
+	addq $56, %rsp
 	ret
 
 ENTRY(efi_call7)
-	pad_stack
-	subq $64, %rsp
-	addq $64, %r11
-	addq $8, %r11
-	addq %rsp, %r11
-	mov (%r11), %rax
+	subq $56, %rsp
+	mov 56+16(%rsp), %rax
 	mov %rax, 48(%rsp)
-	subq $8, %r11
-	mov (%r11), %rax
+	mov 56+8(%rsp), %rax
 	mov %rax, 40(%rsp)
 	mov %r9, 32(%rsp)
 	mov %r8, %r9
@@ -188,23 +126,16 @@ ENTRY(efi_call7)
 	/* mov %rdx, %rdx */
 	mov %rsi, %rcx
 	call *%rdi
-	addq $64, %rsp
-	unpad_stack
+	addq $56, %rsp
 	ret
 
 ENTRY(efi_call8)
-	pad_stack
-	subq $64, %rsp
-	addq $64, %r11
-	addq $16, %r11
-	addq %rsp, %r11
-	mov (%r11), %rax
+	subq $72, %rsp
+	mov 72+24(%rsp), %rax
 	mov %rax, 56(%rsp)
-	subq $8, %r11
-	mov (%r11), %rax
+	mov 72+16(%rsp), %rax
 	mov %rax, 48(%rsp)
-	subq $8, %r11
-	mov (%r11), %rax
+	mov 72+8(%rsp), %rax
 	mov %rax, 40(%rsp)
 	mov %r9, 32(%rsp)
 	mov %r8, %r9
@@ -212,26 +143,18 @@ ENTRY(efi_call8)
 	/* mov %rdx, %rdx */
 	mov %rsi, %rcx
 	call *%rdi
-	addq $64, %rsp
-	unpad_stack
+	addq $72, %rsp
 	ret
 
 ENTRY(efi_call9)
-	pad_stack
-	subq $80, %rsp
-	addq $80, %r11
-	addq $24, %r11
-	addq %rsp, %r11
-	mov (%r11), %rax
+	subq $72, %rsp
+	mov 72+32(%rsp), %rax
 	mov %rax, 64(%rsp)
-	subq $8, %r11
-	mov (%r11), %rax
+	mov 72+24(%rsp), %rax
 	mov %rax, 56(%rsp)
-	subq $8, %r11
-	mov (%r11), %rax
+	mov 72+16(%rsp), %rax
 	mov %rax, 48(%rsp)
-	subq $8, %r11
-	mov (%r11), %rax
+	mov 72+8(%rsp), %rax
 	mov %rax, 40(%rsp)
 	mov %r9, 32(%rsp)
 	mov %r8, %r9
@@ -239,29 +162,20 @@ ENTRY(efi_call9)
 	/* mov %rdx, %rdx */
 	mov %rsi, %rcx
 	call *%rdi
-	addq $80, %rsp
-	unpad_stack
+	addq $72, %rsp
 	ret
 
 ENTRY(efi_call10)
-	pad_stack
-	subq $80, %rsp
-	addq $80, %r11
-	addq $32, %r11
-	addq %rsp, %r11
-	mov (%r11), %rax
+	subq $88, %rsp
+	mov 88+40(%rsp), %rax
 	mov %rax, 72(%rsp)
-	subq $8, %r11
-	mov (%r11), %rax
+	mov 88+32(%rsp), %rax
 	mov %rax, 64(%rsp)
-	subq $8, %r11
-	mov (%r11), %rax
+	mov 88+24(%rsp), %rax
 	mov %rax, 56(%rsp)
-	subq $8, %r11
-	mov (%r11), %rax
+	mov 88+16(%rsp), %rax
 	mov %rax, 48(%rsp)
-	subq $8, %r11
-	mov (%r11), %rax
+	mov 88+8(%rsp), %rax
 	mov %rax, 40(%rsp)
 	mov %r9, 32(%rsp)
 	mov %r8, %r9
@@ -269,6 +183,7 @@ ENTRY(efi_call10)
 	/* mov %rdx, %rdx */
 	mov %rsi, %rcx
 	call *%rdi
-	addq $80, %rsp
-	unpad_stack
+	addq $88, %rsp
 	ret
+
+#endif