1// SPDX-License-Identifier: BSD-2-Clause 2/*- 3 * Copyright 2022 Han Gao <gaohan@uniontech.com> 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 */ 27 28#if __loongarch_lp64 29 30#define ENTRY(symbol) \ 31 .text; \ 32 .globl symbol; \ 33 .align 3; \ 34 .type symbol, @function; \ 35 symbol: 36 37#define END(function) \ 38 .size function, .- function; 39 40ENTRY(setjmp) 41 st.d $ra, $a0, 0*8 42 st.d $sp, $a0, 1*8 43 st.d $r21, $a0, 2*8 44 st.d $fp, $a0, 3*8 45 st.d $s0, $a0, 4*8 46 st.d $s1, $a0, 5*8 47 st.d $s2, $a0, 6*8 48 st.d $s3, $a0, 7*8 49 st.d $s4, $a0, 8*8 50 st.d $s5, $a0, 9*8 51 st.d $s6, $a0, 10*8 52 st.d $s7, $a0, 11*8 53 st.d $s8, $a0, 12*8 54 55 li.w $a0, 0 56 jr $ra 57END(setjmp) 58 59ENTRY(longjmp) 60 ld.d $ra, $a0, 0*8 61 ld.d $sp, $a0, 1*8 62 ld.d $r21, $a0, 2*8 63 ld.d $fp, $a0, 3*8 64 ld.d $s0, $a0, 4*8 65 ld.d $s1, $a0, 5*8 66 ld.d $s2, $a0, 6*8 67 ld.d $s3, $a0, 7*8 68 ld.d $s4, $a0, 8*8 69 ld.d $s5, $a0, 9*8 70 ld.d $s6, $a0, 10*8 71 ld.d $s7, $a0, 11*8 72 ld.d $s8, $a0, 12*8 73 74 sltui $a0, $a1, 1 75 add.d $a0, $a0, $a1 // a0 = (a1 == 0) ? 1 : a1 76 jr $ra 77END(longjmp) 78 79#ifdef __ELF__ 80.section .note.GNU-stack,"",%progbits 81#endif 82 83#endif 84