1/* 2 * GRUB -- GRand Unified Bootloader 3 * Copyright (C) 2003 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#define EXT_C(sym) sym 20#define FUNCTION(x) .globl EXT_C(x) ; .type EXT_C(x), @function ; EXT_C(x): 21 22 .file "setjmp.S" 23 24 .text 25 26/* 27 * int setjmp (jmp_buf env) 28 */ 29FUNCTION(setjmp) 30 pop %rsi /* Return address, and adjust the stack */ 31 xor %rax, %rax 32 movq %rbx, 0(%rdi) /* RBX */ 33 movq %rsp, 8(%rdi) /* RSP */ 34 push %rsi 35 movq %rbp, 16(%rdi) /* RBP */ 36 movq %r12, 24(%rdi) /* R12 */ 37 movq %r13, 32(%rdi) /* R13 */ 38 movq %r14, 40(%rdi) /* R14 */ 39 movq %r15, 48(%rdi) /* R15 */ 40 movq %rsi, 56(%rdi) /* RSI */ 41 ret 42 43/* 44 * int longjmp (jmp_buf env, int val) 45 */ 46FUNCTION(longjmp) 47 movl %esi, %eax 48 movq (%rdi), %rbx 49 movq 8(%rdi), %rsp 50 movq 16(%rdi), %rbp 51 movq 24(%rdi), %r12 52 movq 32(%rdi), %r13 53 movq 40(%rdi), %r14 54 movq 48(%rdi), %r15 55 jmp *56(%rdi) 56 57