2N/A/*
2N/A * GRUB -- GRand Unified Bootloader
2N/A * Copyright (C) 2003,2007 Free Software Foundation, Inc.
2N/A *
2N/A * GRUB is free software: you can redistribute it and/or modify
2N/A * it under the terms of the GNU General Public License as published by
2N/A * the Free Software Foundation, either version 3 of the License, or
2N/A * (at your option) any later version.
2N/A *
2N/A * GRUB is distributed in the hope that it will be useful,
2N/A * but WITHOUT ANY WARRANTY; without even the implied warranty of
2N/A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2N/A * GNU General Public License for more details.
2N/A *
2N/A * You should have received a copy of the GNU General Public License
2N/A * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
2N/A */
2N/A
2N/A#include <grub/symbol.h>
2N/A#include <grub/dl.h>
2N/A
2N/A .file "setjmp.S"
2N/A
2N/AGRUB_MOD_LICENSE ("GPLv3+")
2N/A
2N/A .text
2N/A
2N/A/*
2N/A * jmp_buf:
2N/A * rbx rsp rbp r12 r13 r14 r15 rip
2N/A * 0 8 16 24 32 40 48 56
2N/A */
2N/A
2N/A/*
2N/A * int grub_setjmp (grub_jmp_buf env)
2N/A */
2N/AFUNCTION(grub_setjmp)
2N/A pop %rsi /* Return address, and adjust the stack */
2N/A xorq %rax, %rax
2N/A movq %rbx, 0(%rdi) /* RBX */
2N/A movq %rsp, 8(%rdi) /* RSP */
2N/A push %rsi
2N/A movq %rbp, 16(%rdi) /* RBP */
2N/A movq %r12, 24(%rdi) /* R12 */
2N/A movq %r13, 32(%rdi) /* R13 */
2N/A movq %r14, 40(%rdi) /* R14 */
2N/A movq %r15, 48(%rdi) /* R15 */
2N/A movq %rsi, 56(%rdi) /* RSI */
2N/A ret
2N/A
2N/A/*
2N/A * int grub_longjmp (grub_jmp_buf env, int val)
2N/A */
2N/AFUNCTION(grub_longjmp)
2N/A movl %esi, %eax
2N/A orl %eax, %eax
2N/A jnz 1f
2N/A incl %eax
2N/A1:
2N/A
2N/A movq (%rdi), %rbx
2N/A movq 8(%rdi), %rsp
2N/A movq 16(%rdi), %rbp
2N/A movq 24(%rdi), %r12
2N/A movq 32(%rdi), %r13
2N/A movq 40(%rdi), %r14
2N/A movq 48(%rdi), %r15
2N/A jmp *56(%rdi)