Home | History | Annotate | Line # | Download | only in gen
      1  1.5  skrll /* $NetBSD: _setjmp.S,v 1.5 2021/10/07 06:44:18 skrll Exp $ */
      2  1.1   matt 
      3  1.1   matt /*-
      4  1.1   matt  * Copyright (c) 2014 The NetBSD Foundation, Inc.
      5  1.1   matt  * All rights reserved.
      6  1.1   matt  *
      7  1.1   matt  * This code is derived from software contributed to The NetBSD Foundation
      8  1.1   matt  * by Matt Thomas of 3am Software Foundry.
      9  1.1   matt  *
     10  1.1   matt  * Redistribution and use in source and binary forms, with or without
     11  1.1   matt  * modification, are permitted provided that the following conditions
     12  1.1   matt  * are met:
     13  1.1   matt  * 1. Redistributions of source code must retain the above copyright
     14  1.1   matt  *    notice, this list of conditions and the following disclaimer.
     15  1.1   matt  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.1   matt  *    notice, this list of conditions and the following disclaimer in the
     17  1.1   matt  *    documentation and/or other materials provided with the distribution.
     18  1.1   matt  *
     19  1.1   matt  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  1.1   matt  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  1.1   matt  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  1.1   matt  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  1.1   matt  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  1.1   matt  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  1.1   matt  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  1.1   matt  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  1.1   matt  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  1.1   matt  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  1.1   matt  * POSSIBILITY OF SUCH DAMAGE.
     30  1.1   matt  */
     31  1.1   matt 
     32  1.1   matt #include <machine/asm.h>
     33  1.1   matt #include "assym.h"
     34  1.1   matt 
     35  1.1   matt /*
     36  1.1   matt  * C library -- _setjmp, _longjmp
     37  1.1   matt  *
     38  1.1   matt  *	_longjmp(a, v)
     39  1.1   matt  * will generate a "return v;" from the last call to
     40  1.1   matt  *	_setjmp(a)
     41  1.1   matt  * by restoring registers from the stack.
     42  1.1   matt  * The previous signal state is NOT restored.
     43  1.1   matt  *
     44  1.1   matt  * Note: x0 is the return value
     45  1.1   matt  */
     46  1.1   matt 	.section	.rodata.cst8,"aM",@progbits,8
     47  1.1   matt 	.align	3
     48  1.1   matt .L_MAGIC:
     49  1.1   matt 	.xword	_JB_MAGIC_AARCH64__SETJMP
     50  1.1   matt 
     51  1.1   matt ENTRY(_setjmp)
     52  1.1   matt 	adrp	x7, .L_MAGIC
     53  1.1   matt 	ldr	x7, [x7, #:lo12:.L_MAGIC]
     54  1.1   matt 
     55  1.1   matt 	mov	x3, sp
     56  1.1   matt 
     57  1.1   matt 	stp	x7, x3, [x0, #_JB_MAGIC]
     58  1.1   matt 
     59  1.1   matt 	stp	x19, x20, [x0, #_JB_X19]
     60  1.1   matt 	stp	x21, x22, [x0, #_JB_X21]
     61  1.1   matt 	stp	x23, x24, [x0, #_JB_X23]
     62  1.1   matt 	stp	x25, x26, [x0, #_JB_X25]
     63  1.1   matt 	stp	x27, x28, [x0, #_JB_X27]
     64  1.1   matt 	stp	x29, x30, [x0, #_JB_X29]
     65  1.1   matt 
     66  1.1   matt 	stp	d8,  d9,  [x0, #_JB_D8]
     67  1.1   matt 	stp	d10, d11, [x0, #_JB_D10]
     68  1.1   matt 	stp	d12, d13, [x0, #_JB_D12]
     69  1.1   matt 	stp	d14, d15, [x0, #_JB_D14]
     70  1.1   matt 
     71  1.2    ryo 	mov	x0, xzr
     72  1.2    ryo 	ret
     73  1.1   matt END(_setjmp)
     74  1.1   matt 
     75  1.1   matt ENTRY(_longjmp)
     76  1.1   matt 	adrp	x7, .L_MAGIC
     77  1.1   matt 	ldr	x7, [x7, #:lo12:.L_MAGIC]
     78  1.1   matt 
     79  1.1   matt 	ldp	x2, x3, [x0, #_JB_MAGIC]
     80  1.1   matt 	ldp	x4, x5, [x0, #_JB_X29]
     81  1.1   matt 
     82  1.1   matt 	cbz	x3, .Lbotch
     83  1.1   matt 	cbz	x5, .Lbotch
     84  1.1   matt 	cmp	x2, x7
     85  1.1   matt 	b.ne	.Lbotch
     86  1.1   matt 
     87  1.1   matt 	ldp	x19, x20, [x0, #_JB_X19]
     88  1.1   matt 	ldp	x21, x22, [x0, #_JB_X21]
     89  1.1   matt 	ldp	x23, x24, [x0, #_JB_X23]
     90  1.1   matt 	ldp	x25, x26, [x0, #_JB_X25]
     91  1.1   matt 	ldp	x27, x28, [x0, #_JB_X27]
     92  1.1   matt 
     93  1.1   matt 	ldp	d8,  d9,  [x0, #_JB_D8]
     94  1.1   matt 	ldp	d10, d11, [x0, #_JB_D10]
     95  1.1   matt 	ldp	d12, d13, [x0, #_JB_D12]
     96  1.1   matt 	ldp	d14, d15, [x0, #_JB_D14]
     97  1.1   matt 
     98  1.1   matt 	mov	sp, x3
     99  1.1   matt 	mov	x29, x4
    100  1.1   matt 	mov	x30, x5
    101  1.1   matt 
    102  1.5  skrll 	cmp     x1, #0
    103  1.5  skrll 	csinc   x0, x1, xzr, ne
    104  1.2    ryo 	ret
    105  1.1   matt 
    106  1.1   matt 	/* validation failed, die die die. */
    107  1.1   matt .Lbotch:
    108  1.1   matt 	bl	_C_LABEL(longjmperror)
    109  1.1   matt 	bl	_C_LABEL(abort)
    110  1.1   matt 1:	b	1b		/* Cannot get here */
    111  1.1   matt END(_longjmp)
    112