Merge branch 'drm-fixes-5.2' of git://people.freedesktop.org/~agd5f/linux into drm...
[sfrench/cifs-2.6.git] / arch / arm / lib / call_with_stack.S
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * arch/arm/lib/call_with_stack.S
4  *
5  * Copyright (C) 2011 ARM Ltd.
6  * Written by Will Deacon <will.deacon@arm.com>
7  */
8
9 #include <linux/linkage.h>
10 #include <asm/assembler.h>
11
12 /*
13  * void call_with_stack(void (*fn)(void *), void *arg, void *sp)
14  *
15  * Change the stack to that pointed at by sp, then invoke fn(arg) with
16  * the new stack.
17  */
18 ENTRY(call_with_stack)
19         str     sp, [r2, #-4]!
20         str     lr, [r2, #-4]!
21
22         mov     sp, r2
23         mov     r2, r0
24         mov     r0, r1
25
26         badr    lr, 1f
27         ret     r2
28
29 1:      ldr     lr, [sp]
30         ldr     sp, [sp, #4]
31         ret     lr
32 ENDPROC(call_with_stack)