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, write to the Free Software
17 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20/* This is stolen from libc/x86/setjmp.S in the OSKit */
21/*
22 * Mach Operating System
23 * Copyright (c) 1991,1990,1989 Carnegie Mellon University
24 * All Rights Reserved.
25 *
26 * Permission to use, copy, modify and distribute this software and its
27 * documentation is hereby granted, provided that both the copyright
28 * notice and this permission notice appear in all copies of the
29 * software, derivative works or modified versions, and any portions
30 * thereof, and that both notices appear in supporting documentation.
31 *
32 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
33 * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
34 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
35 *
36 * Carnegie Mellon requests users of this software to return to
37 *
38 *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
39 *  School of Computer Science
40 *  Carnegie Mellon University
41 *  Pittsburgh PA 15213-3890
42 *
43 * any improvements or extensions that they make and grant Carnegie Mellon
44 * the rights to redistribute these changes.
45 */
46/*
47 * C library -- _setjmp, _longjmp
48 *
49 *      _longjmp(a,v)
50 * will generate a "return(v)" from
51 * the last call to
52 *      _setjmp(a)
53 * by restoring registers from the stack,
54 * The previous signal state is NOT restored.
55 *
56 */
57
58ENTRY(grub_setjmp)
59	movl	4(%esp), %ecx		/* fetch buffer */
60	movl	%ebx, 0(%ecx)
61	movl	%esi, 4(%ecx)
62	movl	%edi, 8(%ecx)
63	movl	%ebp, 12(%ecx)		/* save frame pointer of caller */
64	popl	%edx
65	movl	%esp, 16(%ecx)		/* save stack pointer of caller */
66	movl	%edx, 20(%ecx)		/* save pc of caller */
67	xorl	%eax, %eax
68        jmp     *%edx
69
70ENTRY(grub_longjmp)
71	movl	8(%esp), %eax		/* return(v) */
72	movl	4(%esp), %ecx		/* fetch buffer */
73	movl	0(%ecx), %ebx
74	movl	4(%ecx), %esi
75	movl	8(%ecx), %edi
76	movl	12(%ecx), %ebp
77	movl	16(%ecx), %esp
78	orl	%eax, %eax
79	jnz	0f
80	incl	%eax
810:	jmp	*20(%ecx)		/* done, return.... */
82