call_with_stack.S 577 B

1234567891011121314151617181920212223242526272829303132
  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. #include <linux/linkage.h>
  9. #include <asm/assembler.h>
  10. /*
  11. * void call_with_stack(void (*fn)(void *), void *arg, void *sp)
  12. *
  13. * Change the stack to that pointed at by sp, then invoke fn(arg) with
  14. * the new stack.
  15. */
  16. ENTRY(call_with_stack)
  17. str sp, [r2, #-4]!
  18. str lr, [r2, #-4]!
  19. mov sp, r2
  20. mov r2, r0
  21. mov r0, r1
  22. badr lr, 1f
  23. ret r2
  24. 1: ldr lr, [sp]
  25. ldr sp, [sp, #4]
  26. ret lr
  27. ENDPROC(call_with_stack)