aboutsummaryrefslogtreecommitdiff
path: root/arch/arm64/lib/call_with_stack.S
blob: 6f527fe5095c8a20384411c0ecd82cc98aef4b3f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
 * arch/arm64/lib/call_with_stack.S
 *
 */

#include <linux/linkage.h>
#include <asm/assembler.h>

/*
 * void call_with_stack(void (*fn)(void *), void *arg, void *sp)
 *
 * Change the stack to that pointed at by sp, then invoke fn(arg) with
 * the new stack.
 */
ENTRY(call_with_stack)
        mov     x3, sp
	str	x3, [x2, #-8]!
	str	lr, [x2, #-8]!

	mov	sp, x2
	mov	x2, x0
	mov	x0, x1

	adr	lr, 1f
	br	x2

1:	ldr	lr, [sp]
	ldr	x3, [sp, #8]
        mov     sp, x3
	br	lr
ENDPROC(call_with_stack)