xref: /openbmc/u-boot/arch/x86/cpu/x86_64/setjmp.S (revision 3eae864a)
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright (C) 2018 Intel Corporation
4 *
5 * See arch/x86/include/asm/setjmp.h for jmp_buf format
6 */
7
8#include <linux/linkage.h>
9
10.text
11.align 8
12
13ENTRY(setjmp)
14
15	pop	%rcx
16	movq	%rcx, (%rdi)	/* Return address */
17	movq	%rsp, 8(%rdi)
18	movq	%rbp, 16(%rdi)
19	movq	%rbx, 24(%rdi)
20	movq	%r12, 32(%rdi)
21	movq	%r13, 40(%rdi)
22	movq	%r14, 48(%rdi)
23	movq	%r15, 56(%rdi)
24	xorq	%rax, %rax	/* Direct invocation returns 0 */
25	jmpq	*%rcx
26
27ENDPROC(setjmp)
28
29.align 8
30
31ENTRY(longjmp)
32
33	movq	(%rdi), %rcx	/* Return address */
34	movq	8(%rdi), %rsp
35	movq	16(%rdi), %rbp
36	movq	24(%rdi), %rbx
37	movq	32(%rdi), %r12
38	movq	40(%rdi), %r13
39	movq	48(%rdi), %r14
40	movq	56(%rdi), %r15
41
42	movq	%rsi, %rax	/* Value to be returned by setjmp() */
43	testq	%rax, %rax	/* cannot be 0 in this case */
44	jnz	1f
45	incq	%rax		/* Return 1 instead */
461:
47	jmpq	*%rcx
48
49ENDPROC(longjmp)
50