removed accidental commit
[grub2/phcoder.git] / lib / x86_64 / setjmp.S
blob621b09b93ec818ab1171a79b06ea2cd3ab950a81
1 /*
2  *  GRUB  --  GRand Unified Bootloader
3  *  Copyright (C) 2003,2007  Free Software Foundation, Inc.
4  *
5  *  GRUB 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 3 of the License, or
8  *  (at your option) any later version.
9  *
10  *  GRUB 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 GRUB.  If not, see <http://www.gnu.org/licenses/>.
17  */
19 #include <grub/symbol.h>
21         .file   "setjmp.S"
23         .text
26  *  jmp_buf:
27  *   rbx rsp rbp r12 r13 r14 r15 rip
28  *   0   8   16  24  32  40  48  56
29  */
32  * int grub_setjmp (grub_jmp_buf env)
33  */
34 FUNCTION(grub_setjmp)
35         pop     %rsi            /* Return address, and adjust the stack */
36         xorq    %rax, %rax
37         movq    %rbx, 0(%rdi)   /* RBX */
38         movq    %rsp, 8(%rdi)   /* RSP */
39         push    %rsi
40         movq    %rbp, 16(%rdi)  /* RBP */
41         movq    %r12, 24(%rdi)  /* R12 */
42         movq    %r13, 32(%rdi)  /* R13 */
43         movq    %r14, 40(%rdi)  /* R14 */
44         movq    %r15, 48(%rdi)  /* R15 */
45         movq    %rsi, 56(%rdi)  /* RSI */
46         ret
49  * int grub_longjmp (grub_jmp_buf env, int val)
50  */
51 FUNCTION(grub_longjmp)
52         movl    %esi, %eax
53         orl     %eax, %eax
54         jnz     1f
55         incl    %eax
58         movq    (%rdi), %rbx
59         movq    8(%rdi), %rsp
60         movq    16(%rdi), %rbp
61         movq    24(%rdi), %r12
62         movq    32(%rdi), %r13
63         movq    40(%rdi), %r14
64         movq    48(%rdi), %r15
65         jmp     *56(%rdi)