/*-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)35/* Store the magic value and stack pointer */36ldr x8, .Lmagic37mov x9, sp38stp x8, x9, [x0], #163940/* Store the general purpose registers and lr */41stp x19, x20, [x0], #1642stp x21, x22, [x0], #1643stp x23, x24, [x0], #1644stp x25, x26, [x0], #1645stp x27, x28, [x0], #1646stp x29, lr, [x0], #164748#ifndef _STANDALONE49/* Store the vfp registers */50stp d8, d9, [x0], #1651stp d10, d11, [x0], #1652stp d12, d13, [x0], #1653stp d14, d15, [x0]54#endif5556/* Return value */57mov x0, #058ret59.align 360.Lmagic:61.quad _JB_MAGIC__SETJMP62END(_setjmp)6364ENTRY(_longjmp)65/* Check the magic value */66ldr x8, [x0], #867ldr x9, .Lmagic68cmp x8, x969b.ne botch7071/* Restore the stack pointer */72ldr x8, [x0], #873mov sp, x87475/* Restore the general purpose registers and lr */76ldp x19, x20, [x0], #1677ldp x21, x22, [x0], #1678ldp x23, x24, [x0], #1679ldp x25, x26, [x0], #1680ldp x27, x28, [x0], #1681ldp x29, lr, [x0], #168283#ifndef _STANDALONE84/* Restore the vfp registers */85ldp d8, d9, [x0], #1686ldp d10, d11, [x0], #1687ldp d12, d13, [x0], #1688ldp d14, d15, [x0]89#endif9091/* Load the return value */92cmp x1, #093csinc x0, x1, xzr, ne94ret9596botch:97#ifdef _STANDALONE98b botch99#else100bl _C_LABEL(longjmperror)101bl _C_LABEL(abort)102#endif103END(_longjmp)104105GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL)106107108