gnu-efi/gnu-efi-3.0d-callwrap.patch
2009-02-13 21:19:50 +00:00

519 lines
17 KiB
Diff

diff -urpN /dev/null gnu-efi-3.0d/gnuefi/callwrap_ia32.c
--- /dev/null 2008-04-24 00:20:49.271011245 -0400
+++ gnu-efi-3.0d/gnuefi/callwrap_ia32.c 2008-04-29 15:40:43.000000000 -0400
@@ -0,0 +1,103 @@
+
+typedef unsigned long EFI_STATUS;
+
+typedef EFI_STATUS (*func0)(void);
+typedef EFI_STATUS (*func1)(unsigned long);
+typedef EFI_STATUS (*func2)(unsigned long, unsigned long);
+typedef EFI_STATUS (*func3)(unsigned long, unsigned long, unsigned long);
+typedef EFI_STATUS (*func4)(unsigned long, unsigned long, unsigned long,
+ unsigned long);
+typedef EFI_STATUS (*func5)(unsigned long, unsigned long, unsigned long,
+ unsigned long, unsigned long);
+typedef EFI_STATUS (*func6)(unsigned long, unsigned long, unsigned long,
+ unsigned long, unsigned long, unsigned long);
+typedef EFI_STATUS (*func7)(unsigned long, unsigned long, unsigned long,
+ unsigned long, unsigned long, unsigned long,
+ unsigned long);
+typedef EFI_STATUS (*func8)(unsigned long, unsigned long, unsigned long,
+ unsigned long, unsigned long, unsigned long,
+ unsigned long, unsigned long);
+typedef EFI_STATUS (*func9)(unsigned long, unsigned long, unsigned long,
+ unsigned long, unsigned long, unsigned long,
+ unsigned long, unsigned long, unsigned long);
+typedef EFI_STATUS (*func10)(unsigned long, unsigned long, unsigned long,
+ unsigned long, unsigned long, unsigned long,
+ unsigned long, unsigned long, unsigned long,
+ unsigned long);
+
+EFI_STATUS gnuefi_call0 (unsigned long func)
+{
+ return ((func0)func)();
+}
+
+EFI_STATUS gnuefi_call1 (unsigned long func, unsigned long a)
+{
+ return ((func1)func)(a);
+}
+
+EFI_STATUS gnuefi_call2 (unsigned long func, unsigned long a, unsigned long b)
+{
+ return ((func2)func)(a, b);
+}
+
+EFI_STATUS gnuefi_call3 (unsigned long func, unsigned long a,
+ unsigned long b, unsigned long c)
+{
+ return ((func3)func)(a, b, c);
+}
+
+EFI_STATUS gnuefi_call4 (unsigned long func, unsigned long a,
+ unsigned long b, unsigned long c, unsigned long d)
+{
+ return ((func4)func)(a, b, c, d);
+}
+
+EFI_STATUS gnuefi_call5 (unsigned long func, unsigned long a,
+ unsigned long b, unsigned long c,
+ unsigned long d, unsigned long e)
+{
+ return ((func5)func)(a, b, c, d, e);
+}
+
+EFI_STATUS gnuefi_call6 (unsigned long func, unsigned long a,
+ unsigned long b, unsigned long c,
+ unsigned long d, unsigned long e, unsigned long f)
+{
+ return ((func6)func)(a, b, c, d, e, f);
+}
+
+EFI_STATUS gnuefi_call7 (unsigned long func, unsigned long a,
+ unsigned long b, unsigned long c,
+ unsigned long d, unsigned long e,
+ unsigned long f, unsigned long g)
+{
+ return ((func7)func)(a, b, c, d, e, f, g);
+}
+
+EFI_STATUS gnuefi_call8 (unsigned long func, unsigned long a,
+ unsigned long b, unsigned long c,
+ unsigned long d, unsigned long e,
+ unsigned long f, unsigned long g,
+ unsigned long h)
+{
+ return ((func8)func)(a, b, c, d, e, f, g, h);
+}
+
+EFI_STATUS gnuefi_call9 (unsigned long func, unsigned long a,
+ unsigned long b, unsigned long c,
+ unsigned long d, unsigned long e,
+ unsigned long f, unsigned long g,
+ unsigned long h, unsigned long i)
+{
+ return ((func9)func)(a, b, c, d, e, f, g, h, i);
+}
+
+EFI_STATUS gnuefi_call10(unsigned long func, unsigned long a,
+ unsigned long b, unsigned long c,
+ unsigned long d, unsigned long e,
+ unsigned long f, unsigned long g,
+ unsigned long h, unsigned long i,
+ unsigned long j)
+{
+ return ((func10)func)(a, b, c, d, e, f, g, h, i, j);
+}
diff -urpN /dev/null gnu-efi-3.0d/gnuefi/callwrap_x86_64.c
--- /dev/null 2008-04-24 00:20:49.271011245 -0400
+++ gnu-efi-3.0d/gnuefi/callwrap_x86_64.c 2008-04-29 15:40:07.000000000 -0400
@@ -0,0 +1,395 @@
+/*
+ * Copyright (C) 2006 Giridhar Pemmasani
+ * Copyright (C) 2007-2010 Intel Corp
+ * Contributed by Chandramouli Narayanan<mouli@linux.intel.com>
+ * Adapted wrapper macros for Linux to windows calls from
+ * NDIS wrapper project (http:/ndiswrapper.sourceforge.net)
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#define alloc_win_stack_frame(argc) \
+ "subq $" #argc "*8, %%rsp\n\t"
+#define free_win_stack_frame(argc) \
+ "addq $" #argc "*8, %%rsp\n\t"
+
+/* m is index of Windows arg required, n is total number of args to
+ * function Windows arg 1 should be at 0(%rsp), arg 2 at 8(%rsp) and
+ * so on, after stack frame is allocated, which starts at -n*8(%rsp)
+ * when stack frame is allocated. 4 > m >= n.
+*/
+
+#define lin2win_win_arg(m,n) "(" #m "-1-" #n ")*8(%%rsp)"
+
+/* volatile args for Windows function must be in clobber / output list */
+extern unsigned long long gnuefi_call0(void *func);
+extern unsigned long long gnuefi_call1(void *func, unsigned long long arg1);
+extern unsigned long long gnuefi_call2(void *func, unsigned long long arg1, unsigned long long arg2);
+extern unsigned long long gnuefi_call3(
+ void *func,
+ unsigned long long arg1,
+ unsigned long long arg2,
+ unsigned long long arg3);
+extern unsigned long long gnuefi_call4(
+ void *func,
+ unsigned long long arg1,
+ unsigned long long arg2,
+ unsigned long long arg3,
+ unsigned long long arg4);
+extern unsigned long long gnuefi_call5(
+ void *func,
+ unsigned long long arg1,
+ unsigned long long arg2,
+ unsigned long long arg3,
+ unsigned long long arg4,
+ unsigned long long arg5);
+extern unsigned long long gnuefi_call6(
+ void *func,
+ unsigned long long arg1,
+ unsigned long long arg2,
+ unsigned long long arg3,
+ unsigned long long arg4,
+ unsigned long long arg5,
+ unsigned long long arg6);
+extern unsigned long long gnuefi_call7(
+ void *func,
+ unsigned long long arg1,
+ unsigned long long arg2,
+ unsigned long long arg3,
+ unsigned long long arg4,
+ unsigned long long arg5,
+ unsigned long long arg6,
+ unsigned long long arg7);
+extern unsigned long long gnuefi_call8(
+ void *func,
+ unsigned long long arg1,
+ unsigned long long arg2,
+ unsigned long long arg3,
+ unsigned long long arg4,
+ unsigned long long arg5,
+ unsigned long long arg6,
+ unsigned long long arg7,
+ unsigned long long arg8);
+extern unsigned long long gnuefi_call9(
+ void *func,
+ unsigned long long arg1,
+ unsigned long long arg2,
+ unsigned long long arg3,
+ unsigned long long arg4,
+ unsigned long long arg5,
+ unsigned long long arg6,
+ unsigned long long arg7,
+ unsigned long long arg8,
+ unsigned long long arg9);
+extern unsigned long long gnuefi_call10(
+ void *func,
+ unsigned long long arg1,
+ unsigned long long arg2,
+ unsigned long long arg3,
+ unsigned long long arg4,
+ unsigned long long arg5,
+ unsigned long long arg6,
+ unsigned long long arg7,
+ unsigned long long arg8,
+ unsigned long long arg9,
+ unsigned long long arg10);
+
+
+unsigned long long gnuefi_call0(void *func)
+{
+ unsigned long long ret, dummy;
+ register unsigned long long r8 __asm__("r8");
+ register unsigned long long r9 __asm__("r9");
+ register unsigned long long r10 __asm__("r10");
+ register unsigned long long r11 __asm__("r11");
+ __asm__ __volatile__(
+ alloc_win_stack_frame(4)
+ "call *%[fptr]\n\t"
+ free_win_stack_frame(4)
+ : "=a" (ret), "=c" (dummy), "=d" (dummy),
+ "=r" (r8), "=r" (r9), "=r" (r10), "=r" (r11)
+ : [fptr] "r" (func));
+ return ret;
+}
+
+unsigned long long gnuefi_call1(void *func, unsigned long long arg1)
+{
+ unsigned long long ret, dummy;
+ register unsigned long long r8 __asm__("r8");
+ register unsigned long long r9 __asm__("r9");
+ register unsigned long long r10 __asm__("r10");
+ register unsigned long long r11 __asm__("r11");
+ __asm__ __volatile__(
+ alloc_win_stack_frame(4)
+ "call *%[fptr]\n\t"
+ free_win_stack_frame(4)
+ : "=a" (ret), "=c" (dummy), "=d" (dummy),
+ "=r" (r8), "=r" (r9), "=r" (r10), "=r" (r11)
+ : "c" (arg1),
+ [fptr] "r" (func));
+ return ret;
+}
+
+unsigned long long gnuefi_call2(void *func, unsigned long long arg1, unsigned long long arg2)
+{
+ unsigned long long ret, dummy;
+ register unsigned long long r8 __asm__("r8");
+ register unsigned long long r9 __asm__("r9");
+ register unsigned long long r10 __asm__("r10");
+ register unsigned long long r11 __asm__("r11");
+ __asm__ __volatile__(
+ alloc_win_stack_frame(4)
+ "call *%[fptr]\n\t"
+ free_win_stack_frame(4)
+ : "=a" (ret), "=c" (dummy), "=d" (dummy),
+ "=r" (r8), "=r" (r9), "=r" (r10), "=r" (r11)
+ : "c" (arg1), "d" (arg2),
+ [fptr] "r" (func));
+ return ret;
+}
+
+unsigned long long gnuefi_call3(
+ void *func,
+ unsigned long long arg1,
+ unsigned long long arg2,
+ unsigned long long arg3)
+{
+ unsigned long long ret, dummy;
+ register unsigned long long r8 __asm__("r8") = (unsigned long long)arg3;
+ register unsigned long long r9 __asm__("r9");
+ register unsigned long long r10 __asm__("r10");
+ register unsigned long long r11 __asm__("r11");
+ __asm__ __volatile__(
+ alloc_win_stack_frame(4)
+ "call *%[fptr]\n\t"
+ free_win_stack_frame(4)
+ : "=a" (ret), "=c" (dummy), "=d" (dummy),
+ "=r" (r8), "=r" (r9), "=r" (r10), "=r" (r11)
+ : "c" (arg1), "d" (arg2), "r" (r8),
+ [fptr] "r" (func));
+ return ret;
+}
+
+unsigned long long gnuefi_call4(
+ void *func,
+ unsigned long long arg1,
+ unsigned long long arg2,
+ unsigned long long arg3,
+ unsigned long long arg4)
+{
+ unsigned long long ret, dummy;
+ register unsigned long long r8 __asm__("r8") = (unsigned long long)arg3;
+ register unsigned long long r9 __asm__("r9") = (unsigned long long)arg4;
+ register unsigned long long r10 __asm__("r10");
+ register unsigned long long r11 __asm__("r11");
+ __asm__ __volatile__(
+ alloc_win_stack_frame(4)
+ "call *%[fptr]\n\t"
+ free_win_stack_frame(4)
+ : "=a" (ret), "=c" (dummy), "=d" (dummy),
+ "=r" (r8), "=r" (r9), "=r" (r10), "=r" (r11)
+ : "c" (arg1), "d" (arg2), "r" (r8), "r" (r9),
+ [fptr] "r" (func));
+ return ret;
+}
+
+unsigned long long gnuefi_call5(
+ void *func,
+ unsigned long long arg1,
+ unsigned long long arg2,
+ unsigned long long arg3,
+ unsigned long long arg4,
+ unsigned long long arg5)
+{
+ unsigned long long ret, dummy;
+ register unsigned long long r8 __asm__("r8") = (unsigned long long)arg3;
+ register unsigned long long r9 __asm__("r9") = (unsigned long long)arg4;
+ register unsigned long long r10 __asm__("r10");
+ register unsigned long long r11 __asm__("r11");
+ __asm__ __volatile__(
+ "mov %[rarg5], " lin2win_win_arg(5,6) "\n\t"
+ alloc_win_stack_frame(6)
+ "call *%[fptr]\n\t"
+ free_win_stack_frame(6)
+ : "=a" (ret), "=c" (dummy), "=d" (dummy),
+ "=r" (r8), "=r" (r9), "=r" (r10), "=r" (r11)
+ : "c" (arg1), "d" (arg2), "r" (r8), "r" (r9),
+ [rarg5] "r" ((unsigned long long)arg5),
+ [fptr] "r" (func));
+ return ret;
+}
+
+unsigned long long gnuefi_call6(
+ void *func,
+ unsigned long long arg1,
+ unsigned long long arg2,
+ unsigned long long arg3,
+ unsigned long long arg4,
+ unsigned long long arg5,
+ unsigned long long arg6)
+{
+ unsigned long long ret, dummy;
+ register unsigned long long r8 __asm__("r8") = (unsigned long long)arg3;
+ register unsigned long long r9 __asm__("r9") = (unsigned long long)arg4;
+ register unsigned long long r10 __asm__("r10");
+ register unsigned long long r11 __asm__("r11");
+ __asm__ __volatile__(
+ "movq %[rarg5], " lin2win_win_arg(5,6) "\n\t"
+ "movq %[rarg6], " lin2win_win_arg(6,6) "\n\t"
+ alloc_win_stack_frame(6)
+ "call *%[fptr]\n\t"
+ free_win_stack_frame(6)
+ : "=a" (ret), "=c" (dummy), "=d" (dummy),
+ "=r" (r8), "=r" (r9), "=r" (r10), "=r" (r11)
+ : "c" (arg1), "d" (arg2), "r" (r8), "r" (r9),
+ [rarg5] "r" ((unsigned long long)arg5), [rarg6] "r" ((unsigned long long)arg6),
+ [fptr] "r" (func));
+ return ret;
+}
+
+unsigned long long gnuefi_call7(
+ void *func,
+ unsigned long long arg1,
+ unsigned long long arg2,
+ unsigned long long arg3,
+ unsigned long long arg4,
+ unsigned long long arg5,
+ unsigned long long arg6,
+ unsigned long long arg7)
+{
+ unsigned long long ret, dummy;
+ register unsigned long long r8 __asm__("r8") = (unsigned long long)arg3;
+ register unsigned long long r9 __asm__("r9") = (unsigned long long)arg4;
+ register unsigned long long r10 __asm__("r10");
+ register unsigned long long r11 __asm__("r11");
+ __asm__ __volatile__(
+ "movq %[rarg5], " lin2win_win_arg(5,7) "\n\t"
+ "movq %[rarg6], " lin2win_win_arg(6,7) "\n\t"
+ "movq %[rarg7], " lin2win_win_arg(7,7) "\n\t"
+ alloc_win_stack_frame(7)
+ "call *%[fptr]\n\t"
+ free_win_stack_frame(7)
+ : "=a" (ret), "=c" (dummy), "=d" (dummy),
+ "=r" (r8), "=r" (r9), "=r" (r10), "=r" (r11)
+ : "c" (arg1), "d" (arg2), "r" (r8), "r" (r9),
+ [rarg5] "r" ((unsigned long long)arg5), [rarg6] "r" ((unsigned long long)arg6),
+ [rarg7] "r" ((unsigned long long)arg7), [fptr] "r" (func));
+ return ret;
+}
+
+unsigned long long gnuefi_call8(
+ void *func,
+ unsigned long long arg1,
+ unsigned long long arg2,
+ unsigned long long arg3,
+ unsigned long long arg4,
+ unsigned long long arg5,
+ unsigned long long arg6,
+ unsigned long long arg7,
+ unsigned long long arg8)
+{
+ unsigned long long ret, dummy;
+ register unsigned long long r8 __asm__("r8") = (unsigned long long)arg3;
+ register unsigned long long r9 __asm__("r9") = (unsigned long long)arg4;
+ register unsigned long long r10 __asm__("r10");
+ register unsigned long long r11 __asm__("r11");
+ __asm__ __volatile__(
+ "movq %[rarg5], " lin2win_win_arg(5,8) "\n\t"
+ "movq %[rarg6], " lin2win_win_arg(6,8) "\n\t"
+ "movq %[rarg7], " lin2win_win_arg(7,8) "\n\t"
+ "movq %[rarg8], " lin2win_win_arg(8,8) "\n\t"
+ alloc_win_stack_frame(8)
+ "call *%[fptr]\n\t"
+ free_win_stack_frame(8)
+ : "=a" (ret), "=c" (dummy), "=d" (dummy),
+ "=r" (r8), "=r" (r9), "=r" (r10), "=r" (r11)
+ : "c" (arg1), "d" (arg2), "r" (r8), "r" (r9),
+ [rarg5] "r" ((unsigned long long)arg5), [rarg6] "r" ((unsigned long long)arg6),
+ [rarg7] "r" ((unsigned long long)arg7), [rarg8] "r" ((unsigned long long)arg8),
+ [fptr] "r" (func));
+ return ret;
+}
+
+unsigned long long gnuefi_call9(
+ void *func,
+ unsigned long long arg1,
+ unsigned long long arg2,
+ unsigned long long arg3,
+ unsigned long long arg4,
+ unsigned long long arg5,
+ unsigned long long arg6,
+ unsigned long long arg7,
+ unsigned long long arg8,
+ unsigned long long arg9)
+{
+ unsigned long long ret, dummy;
+ register unsigned long long r8 __asm__("r8") = (unsigned long long)arg3;
+ register unsigned long long r9 __asm__("r9") = (unsigned long long)arg4;
+ register unsigned long long r10 __asm__("r10");
+ register unsigned long long r11 __asm__("r11");
+ __asm__ __volatile__(
+ "movq %[rarg5], " lin2win_win_arg(5,9) "\n\t"
+ "movq %[rarg6], " lin2win_win_arg(6,9) "\n\t"
+ "movq %[rarg7], " lin2win_win_arg(7,9) "\n\t"
+ "movq %[rarg8], " lin2win_win_arg(8,9) "\n\t"
+ "movq %[rarg9], " lin2win_win_arg(9,9) "\n\t"
+ alloc_win_stack_frame(9)
+ "call *%[fptr]\n\t"
+ free_win_stack_frame(9)
+ : "=a" (ret), "=c" (dummy), "=d" (dummy),
+ "=r" (r8), "=r" (r9), "=r" (r10), "=r" (r11)
+ : "c" (arg1), "d" (arg2), "r" (r8), "r" (r9),
+ [rarg5] "r" ((unsigned long long)arg5), [rarg6] "r" ((unsigned long long)arg6),
+ [rarg7] "r" ((unsigned long long)arg7), [rarg8] "r" ((unsigned long long)arg8),
+ [rarg9] "r" ((unsigned long long)arg9), [fptr] "r" (func));
+ return ret;
+}
+
+unsigned long long gnuefi_call10(
+ void *func,
+ unsigned long long arg1,
+ unsigned long long arg2,
+ unsigned long long arg3,
+ unsigned long long arg4,
+ unsigned long long arg5,
+ unsigned long long arg6,
+ unsigned long long arg7,
+ unsigned long long arg8,
+ unsigned long long arg9,
+ unsigned long long arg10)
+{
+ unsigned long long ret, dummy;
+ register unsigned long long r8 __asm__("r8") = (unsigned long long)arg3;
+ register unsigned long long r9 __asm__("r9") = (unsigned long long)arg4;
+ register unsigned long long r10 __asm__("r10");
+ register unsigned long long r11 __asm__("r11");
+ __asm__ __volatile__(
+ "movq %[rarg5], " lin2win_win_arg(5,10) "\n\t"
+ "movq %[rarg6], " lin2win_win_arg(6,10) "\n\t"
+ "movq %[rarg7], " lin2win_win_arg(7,10) "\n\t"
+ "movq %[rarg8], " lin2win_win_arg(8,10) "\n\t"
+ "movq %[rarg9], " lin2win_win_arg(9,10) "\n\t"
+ "movq %[rarg10], " lin2win_win_arg(10,10) "\n\t"
+ alloc_win_stack_frame(10)
+ "call *%[fptr]\n\t"
+ free_win_stack_frame(10)
+ : "=a" (ret), "=c" (dummy), "=d" (dummy),
+ "=r" (r8), "=r" (r9), "=r" (r10), "=r" (r11)
+ : "c" (arg1), "d" (arg2), "r" (r8), "r" (r9),
+ [rarg5] "r" ((unsigned long long)arg5), [rarg6] "r" ((unsigned long long)arg6),
+ [rarg7] "r" ((unsigned long long)arg7), [rarg8] "r" ((unsigned long long)arg8),
+ [rarg9] "r" ((unsigned long long)arg9), [rarg10] "r" ((unsigned long long)arg10),
+ [fptr] "r" (func));
+ return ret;
+}
+
diff -urpN gnu-efi-3.0d/gnuefi/Makefile.callwrap gnu-efi-3.0d/gnuefi/Makefile
--- gnu-efi-3.0d/gnuefi/Makefile.callwrap 2008-04-29 15:40:07.000000000 -0400
+++ gnu-efi-3.0d/gnuefi/Makefile 2008-04-29 15:40:07.000000000 -0400
@@ -23,7 +23,7 @@
include ../Make.defaults
CDIR=$(TOPDIR)/..
-FILES = reloc_$(ARCH) setjmp_$(ARCH)
+FILES = reloc_$(ARCH) setjmp_$(ARCH) callwrap_$(ARCH)
OBJS = $(FILES:%=%.o)