2b933a
diff -urpN gnu-efi-3.0d/gnuefi/Makefile.setjmp gnu-efi-3.0d/gnuefi/Makefile
2b933a
--- gnu-efi-3.0d/gnuefi/Makefile.setjmp	2008-04-29 13:18:19.000000000 -0400
2b933a
+++ gnu-efi-3.0d/gnuefi/Makefile	2008-04-29 13:18:43.000000000 -0400
2b933a
@@ -23,7 +23,7 @@
2b933a
 
2b933a
 include ../Make.defaults
2b933a
 CDIR=$(TOPDIR)/..
2b933a
-FILES	= reloc_$(ARCH)
2b933a
+FILES	= reloc_$(ARCH) setjmp_$(ARCH)
2b933a
 
2b933a
 OBJS	= $(FILES:%=%.o)
2b933a
 
2b933a
diff -urpN gnu-efi-3.0d/gnuefi/setjmp_ia32.S.setjmp gnu-efi-3.0d/gnuefi/setjmp_ia32.S
2b933a
--- gnu-efi-3.0d/gnuefi/setjmp_ia32.S.setjmp	2008-04-29 13:13:05.000000000 -0400
2b933a
+++ gnu-efi-3.0d/gnuefi/setjmp_ia32.S	2008-04-29 13:22:04.000000000 -0400
2b933a
@@ -0,0 +1,87 @@
2b933a
+/*
2b933a
+ *  GRUB  --  GRand Unified Bootloader
2b933a
+ *  Copyright (C) 2000 Free Software Foundation, Inc.
2b933a
+ *
2b933a
+ *  This program is free software; you can redistribute it and/or modify
2b933a
+ *  it under the terms of the GNU General Public License as published by
2b933a
+ *  the Free Software Foundation; either version 2 of the License, or
2b933a
+ *  (at your option) any later version.
2b933a
+ *
2b933a
+ *  This program is distributed in the hope that it will be useful,
2b933a
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
2b933a
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2b933a
+ *  GNU General Public License for more details.
2b933a
+ *
2b933a
+ *  You should have received a copy of the GNU General Public License
2b933a
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
2b933a
+ */
2b933a
+
2b933a
+/* This is stolen from libc/x86/setjmp.S in the OSKit */
2b933a
+/* 
2b933a
+ * Mach Operating System
2b933a
+ * Copyright (c) 1991,1990,1989 Carnegie Mellon University
2b933a
+ * All Rights Reserved.
2b933a
+ * 
2b933a
+ * Permission to use, copy, modify and distribute this software and its
2b933a
+ * documentation is hereby granted, provided that both the copyright
2b933a
+ * notice and this permission notice appear in all copies of the
2b933a
+ * software, derivative works or modified versions, and any portions
2b933a
+ * thereof, and that both notices appear in supporting documentation.
2b933a
+ * 
2b933a
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
2b933a
+ * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
2b933a
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
2b933a
+ * 
2b933a
+ * Carnegie Mellon requests users of this software to return to
2b933a
+ * 
2b933a
+ *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
2b933a
+ *  School of Computer Science
2b933a
+ *  Carnegie Mellon University
2b933a
+ *  Pittsburgh PA 15213-3890
2b933a
+ * 
2b933a
+ * any improvements or extensions that they make and grant Carnegie Mellon
2b933a
+ * the rights to redistribute these changes.
2b933a
+ */
2b933a
+/*
2b933a
+ * C library -- _setjmp, _longjmp
2b933a
+ *
2b933a
+ *      _longjmp(a,v)
2b933a
+ * will generate a "return(v)" from
2b933a
+ * the last call to
2b933a
+ *      _setjmp(a)
2b933a
+ * by restoring registers from the stack,
2b933a
+ * The previous signal state is NOT restored.
2b933a
+ *
2b933a
+ */
2b933a
+
2b933a
+#define EXT_C(sym) sym
2b933a
+#define FUNCTION(x)     .globl EXT_C(x) ; .type EXT_C(x), "function" ; EXT_C(x):
2b933a
+
2b933a
+	.file	"setjmp.S"
2b933a
+
2b933a
+	.text
2b933a
+	
2b933a
+FUNCTION(setjmp)
2b933a
+	movl	4(%esp), %ecx		/* fetch buffer */
2b933a
+	movl	%ebx, 0(%ecx)
2b933a
+	movl	%esi, 4(%ecx)
2b933a
+	movl	%edi, 8(%ecx)
2b933a
+	movl	%ebp, 12(%ecx)		/* save frame pointer of caller */
2b933a
+	popl	%edx
2b933a
+	movl	%esp, 16(%ecx)		/* save stack pointer of caller */
2b933a
+	movl	%edx, 20(%ecx)		/* save pc of caller */
2b933a
+	xorl	%eax, %eax
2b933a
+        jmp     *%edx
2b933a
+
2b933a
+FUNCTION(longjmp)
2b933a
+	movl	8(%esp), %eax		/* return(v) */
2b933a
+	movl	4(%esp), %ecx		/* fetch buffer */
2b933a
+	movl	0(%ecx), %ebx
2b933a
+	movl	4(%ecx), %esi
2b933a
+	movl	8(%ecx), %edi
2b933a
+	movl	12(%ecx), %ebp
2b933a
+	movl	16(%ecx), %esp
2b933a
+	orl	%eax, %eax
2b933a
+	jnz	0f
2b933a
+	incl	%eax
2b933a
+0:	jmp	*20(%ecx)		/* done, return.... */
2b933a
diff -urpN gnu-efi-3.0d/gnuefi/setjmp_ia64.S.setjmp gnu-efi-3.0d/gnuefi/setjmp_ia64.S
2b933a
--- gnu-efi-3.0d/gnuefi/setjmp_ia64.S.setjmp	2008-04-29 13:19:34.000000000 -0400
2b933a
+++ gnu-efi-3.0d/gnuefi/setjmp_ia64.S	2008-04-29 13:19:44.000000000 -0400
2b933a
@@ -0,0 +1,2 @@
2b933a
+
2b933a
+#warning not implemented
2b933a
diff -urpN gnu-efi-3.0d/gnuefi/setjmp_x86_64.S.setjmp gnu-efi-3.0d/gnuefi/setjmp_x86_64.S
2b933a
--- gnu-efi-3.0d/gnuefi/setjmp_x86_64.S.setjmp	2008-04-29 13:18:12.000000000 -0400
2b933a
+++ gnu-efi-3.0d/gnuefi/setjmp_x86_64.S	2008-04-29 13:22:04.000000000 -0400
2b933a
@@ -0,0 +1,56 @@
2b933a
+/*
2b933a
+ *  GRUB  --  GRand Unified Bootloader
2b933a
+ *  Copyright (C) 2003  Free Software Foundation, Inc.
2b933a
+ *
2b933a
+ *  This program is free software; you can redistribute it and/or modify
2b933a
+ *  it under the terms of the GNU General Public License as published by
2b933a
+ *  the Free Software Foundation; either version 2 of the License, or
2b933a
+ *  (at your option) any later version.
2b933a
+ *
2b933a
+ *  This program is distributed in the hope that it will be useful,
2b933a
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
2b933a
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2b933a
+ *  GNU General Public License for more details.
2b933a
+ *
2b933a
+ *  You should have received a copy of the GNU General Public License
2b933a
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
2b933a
+ */
2b933a
+
2b933a
+#define EXT_C(sym) sym
2b933a
+#define FUNCTION(x)     .globl EXT_C(x) ; .type EXT_C(x), "function" ; EXT_C(x):
2b933a
+
2b933a
+	.file	"setjmp.S"
2b933a
+
2b933a
+	.text
2b933a
+
2b933a
+/*
2b933a
+ * int setjmp (jmp_buf env)
2b933a
+ */
2b933a
+FUNCTION(setjmp)
2b933a
+	pop	%rsi		/* Return address, and adjust the stack */
2b933a
+	xor	%rax, %rax
2b933a
+	movq	%rbx, 0(%rdi)	/* RBX */
2b933a
+	movq	%rsp, 8(%rdi)   /* RSP */
2b933a
+	push	%rsi
2b933a
+	movq	%rbp, 16(%rdi)	/* RBP */
2b933a
+	movq	%r12, 24(%rdi)	/* R12 */
2b933a
+	movq	%r13, 32(%rdi)	/* R13 */
2b933a
+	movq	%r14, 40(%rdi)	/* R14 */
2b933a
+	movq	%r15, 48(%rdi)	/* R15 */
2b933a
+	movq	%rsi, 56(%rdi)	/* RSI */
2b933a
+	ret
2b933a
+
2b933a
+/*
2b933a
+ * int longjmp (jmp_buf env, int val)
2b933a
+ */
2b933a
+FUNCTION(longjmp)
2b933a
+	movl	%esi, %eax
2b933a
+	movq	(%rdi), %rbx
2b933a
+	movq	8(%rdi), %rsp
2b933a
+	movq	16(%rdi), %rbp
2b933a
+	movq	24(%rdi), %r12
2b933a
+	movq    32(%rdi), %r13
2b933a
+	movq    40(%rdi), %r14
2b933a
+	movq    48(%rdi), %r15
2b933a
+	jmp	*56(%rdi)
2b933a
+
2b933a
diff -urpN gnu-efi-3.0d/Make.rules.setjmp gnu-efi-3.0d/Make.rules