1/*	$NetBSD: setjmp.S,v 1.1.1.1 2018/08/16 18:17:47 jmcneill Exp $	*/
2
3/*
4 * Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
5 * This program and the accompanying materials are licensed and made
6available
7 * under the terms and conditions of the BSD License which accompanies
8this
9 * distribution.  The full text of the license may be found at
10 * http://opensource.org/licenses/bsd-license.php.
11 *
12 * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
13BASIS,
14 * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR
15 * IMPLIED.
16 */
17	.text
18	.p2align 3
19
20#define GPR_LAYOUT			\
21	REG_PAIR (x19, x20, 0);		\
22	REG_PAIR (x21, x22, 16);	\
23	REG_PAIR (x23, x24, 32);	\
24	REG_PAIR (x25, x26, 48);	\
25	REG_PAIR (x27, x28, 64);	\
26	REG_PAIR (x29, x30, 80);	\
27	REG_ONE (x16, 96)
28
29#define FPR_LAYOUT			\
30	REG_PAIR(d8, d9, 112);		\
31	REG_PAIR(d10, d11, 128);	\
32	REG_PAIR(d12, d13, 144);	\
33	REG_PAIR(d14, d15, 160);
34
35#define REG_PAIR(REG1, REG2, OFFS)      stp REG1, REG2, [x0, OFFS]
36#define REG_ONE(REG1, OFFS)             str REG1, [x0, OFFS]
37
38	.globl	setjmp
39	.type	setjmp, @function
40setjmp:
41	mov	x16, sp
42	GPR_LAYOUT
43	FPR_LAYOUT
44	mov	w0, #0
45	ret
46
47#undef REG_PAIR
48#undef REG_ONE
49
50#define REG_PAIR(REG1, REG2, OFFS)      ldp REG1, REG2, [x0, OFFS]
51#define REG_ONE(REG1, OFFS)             ldr REG1, [x0, OFFS]
52
53	.globl	longjmp
54	.type	longjmp, @function
55longjmp:
56	GPR_LAYOUT
57	FPR_LAYOUT
58	mov	sp, x16
59	cmp	w1, #0
60	mov	w0, #1
61	csel	w0, w1, w0, ne
62	br	x30
63