xref: /netbsd-src/sys/arch/usermode/usermode/cpufunc.S (revision e4b9cc03699f99f3701263d923f2215502045c1d)
1
2#include <machine/asm.h>
3#include "assym.h"
4
5#if defined(__i386__)
6
7ENTRY(breakpoint)
8	pushl	%ebp
9	movl	%esp, %ebp
10	int	$0x03		/* paranoid, not 'int3' */
11	popl	%ebp
12	ret
13END(breakpoint)
14
15//#error TODO implement setjmp/longjmp for i386?
16
17#elif defined(__amd64__)
18ENTRY(breakpoint)
19	.byte 0xcc	// BKPT_INST, int3
20	ret
21
22/*
23 * int setjmp(label_t *)
24 *
25 * Used primarily by DDB.
26 */
27ENTRY(setjmp)
28	/*
29	 * Only save registers that must be preserved across function
30	 * calls according to the ABI (%rbx, %rsp, %rbp, %r12-%r15)
31	 * and %rip.
32	 */
33	movq	%rdi,%rax
34	movq	%rbx,(%rax)
35	movq	%rsp,8(%rax)
36	movq	%rbp,16(%rax)
37	movq	%r12,24(%rax)
38	movq	%r13,32(%rax)
39	movq	%r14,40(%rax)
40	movq	%r15,48(%rax)
41	movq	(%rsp),%rdx
42	movq	%rdx,56(%rax)
43	xorl	%eax,%eax
44	ret
45END(setjmp)
46
47/*
48 * int longjmp(label_t *)
49 *
50 * Used primarily by DDB.
51 */
52ENTRY(longjmp)
53	movq	%rdi,%rax
54	movq	(%rax),%rbx
55	movq	8(%rax),%rsp
56	movq	16(%rax),%rbp
57	movq	24(%rax),%r12
58	movq	32(%rax),%r13
59	movq	40(%rax),%r14
60	movq	48(%rax),%r15
61	movq	56(%rax),%rdx
62	movq	%rdx,(%rsp)
63	movl	$1,%eax
64	ret
65END(longjmp)
66#elif defined(__arm__)
67
68ENTRY(breakpoint)
69	BKPT_ASM
70	mov pc, lr
71
72#error implement setjmp/longjmp for arm32
73
74#else
75
76#error port me
77
78#endif
79
80