/*-1* Copyright (c) 2014 Andrew Turner2* Copyright (c) 2014 The FreeBSD Foundation3*4* Portions of this software were developed by Andrew Turner5* under sponsorship from the FreeBSD Foundation6*7* Redistribution and use in source and binary forms, with or without8* modification, are permitted provided that the following conditions9* are met:10* 1. Redistributions of source code must retain the above copyright11* notice, this list of conditions and the following disclaimer.12* 2. Redistributions in binary form must reproduce the above copyright13* notice, this list of conditions and the following disclaimer in the14* documentation and/or other materials provided with the distribution.15*16* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND17* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE18* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE19* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE20* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL21* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS22* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)23* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT24* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF26* SUCH DAMAGE.27*28*/2930#include <machine/asm.h>31#include <machine/setjmp.h>32#include <sys/elf_common.h>3334ENTRY(setjmp)35sub sp, sp, #1636stp x0, lr, [sp]3738/* Store the signal mask */39add x2, x0, #(_JB_SIGMASK * 8) /* oset */40mov x1, #0 /* set */41mov x0, #1 /* SIG_BLOCK */42bl sigprocmask4344ldp x0, lr, [sp]45add sp, sp, #164647/* Store the magic value and stack pointer */48ldr x8, .Lmagic49mov x9, sp50stp x8, x9, [x0], #165152/* Store the general purpose registers and lr */53stp x19, x20, [x0], #1654stp x21, x22, [x0], #1655stp x23, x24, [x0], #1656stp x25, x26, [x0], #1657stp x27, x28, [x0], #1658stp x29, lr, [x0], #165960/* Store the vfp registers */61stp d8, d9, [x0], #1662stp d10, d11, [x0], #1663stp d12, d13, [x0], #1664stp d14, d15, [x0]6566/* Return value */67mov x0, #068ret69.align 370.Lmagic:71.quad _JB_MAGIC_SETJMP72END(setjmp)7374ENTRY(longjmp)75sub sp, sp, #3276stp x0, lr, [sp]77str x1, [sp, #16]7879/* Restore the signal mask */80mov x2, #0 /* oset */81add x1, x0, #(_JB_SIGMASK * 8) /* set */82mov x0, #3 /* SIG_SETMASK */83bl sigprocmask8485ldr x1, [sp, #16]86ldp x0, lr, [sp]87add sp, sp, #328889/* Check the magic value */90ldr x8, [x0], #891ldr x9, .Lmagic92cmp x8, x993b.ne botch9495/* Restore the stack pointer */96ldr x8, [x0], #897mov sp, x89899/* Restore the general purpose registers and lr */100ldp x19, x20, [x0], #16101ldp x21, x22, [x0], #16102ldp x23, x24, [x0], #16103ldp x25, x26, [x0], #16104ldp x27, x28, [x0], #16105ldp x29, lr, [x0], #16106107/* Restore the vfp registers */108ldp d8, d9, [x0], #16109ldp d10, d11, [x0], #16110ldp d12, d13, [x0], #16111ldp d14, d15, [x0]112113/* Load the return value */114cmp x1, #0115csinc x0, x1, xzr, ne116ret117118botch:119bl _C_LABEL(longjmperror)120bl _C_LABEL(abort)121END(longjmp)122123GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL)124125126