Home | History | Annotate | Download | only in gnuefi
      1 /*
      2  *  GRUB  --  GRand Unified Bootloader
      3  *  Copyright (C) 2000 Free Software Foundation, Inc.
      4  *
      5  *  This program is free software; you can redistribute it and/or modify
      6  *  it under the terms of the GNU General Public License as published by
      7  *  the Free Software Foundation; either version 2 of the License, or
      8  *  (at your option) any later version.
      9  *
     10  *  This program is distributed in the hope that it will be useful,
     11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13  *  GNU General Public License for more details.
     14  *
     15  *  You should have received a copy of the GNU General Public License
     16  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
     17  */
     18 
     19 /* This is stolen from libc/x86/setjmp.S in the OSKit */
     20 /*
     21  * Mach Operating System
     22  * Copyright (c) 1991,1990,1989 Carnegie Mellon University
     23  * All Rights Reserved.
     24  *
     25  * Permission to use, copy, modify and distribute this software and its
     26  * documentation is hereby granted, provided that both the copyright
     27  * notice and this permission notice appear in all copies of the
     28  * software, derivative works or modified versions, and any portions
     29  * thereof, and that both notices appear in supporting documentation.
     30  *
     31  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     32  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
     33  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     34  *
     35  * Carnegie Mellon requests users of this software to return to
     36  *
     37  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     38  *  School of Computer Science
     39  *  Carnegie Mellon University
     40  *  Pittsburgh PA 15213-3890
     41  *
     42  * any improvements or extensions that they make and grant Carnegie Mellon
     43  * the rights to redistribute these changes.
     44  */
     45 /*
     46  * C library -- _setjmp, _longjmp
     47  *
     48  *      _longjmp(a,v)
     49  * will generate a "return(v)" from
     50  * the last call to
     51  *      _setjmp(a)
     52  * by restoring registers from the stack,
     53  * The previous signal state is NOT restored.
     54  *
     55  */
     56 
     57 #define EXT_C(sym) sym
     58 #define FUNCTION(x)     .globl EXT_C(x) ; .type EXT_C(x), @function ; EXT_C(x):
     59 
     60 	.file	"setjmp.S"
     61 
     62 	.text
     63 
     64 FUNCTION(setjmp)
     65 	movl	4(%esp), %ecx		/* fetch buffer */
     66 	movl	%ebx, 0(%ecx)
     67 	movl	%esi, 4(%ecx)
     68 	movl	%edi, 8(%ecx)
     69 	movl	%ebp, 12(%ecx)		/* save frame pointer of caller */
     70 	popl	%edx
     71 	movl	%esp, 16(%ecx)		/* save stack pointer of caller */
     72 	movl	%edx, 20(%ecx)		/* save pc of caller */
     73 	xorl	%eax, %eax
     74         jmp     *%edx
     75 
     76 FUNCTION(longjmp)
     77 	movl	8(%esp), %eax		/* return(v) */
     78 	movl	4(%esp), %ecx		/* fetch buffer */
     79 	movl	0(%ecx), %ebx
     80 	movl	4(%ecx), %esi
     81 	movl	8(%ecx), %edi
     82 	movl	12(%ecx), %ebp
     83 	movl	16(%ecx), %esp
     84 	orl	%eax, %eax
     85 	jnz	0f
     86 	incl	%eax
     87 0:	jmp	*20(%ecx)		/* done, return.... */
     88