18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * arch/arm/lib/call_with_stack.S 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2011 ARM Ltd. 68c2ecf20Sopenharmony_ci * Written by Will Deacon <will.deacon@arm.com> 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include <linux/linkage.h> 108c2ecf20Sopenharmony_ci#include <asm/assembler.h> 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci/* 138c2ecf20Sopenharmony_ci * void call_with_stack(void (*fn)(void *), void *arg, void *sp) 148c2ecf20Sopenharmony_ci * 158c2ecf20Sopenharmony_ci * Change the stack to that pointed at by sp, then invoke fn(arg) with 168c2ecf20Sopenharmony_ci * the new stack. 178c2ecf20Sopenharmony_ci */ 188c2ecf20Sopenharmony_ciENTRY(call_with_stack) 198c2ecf20Sopenharmony_ci str sp, [r2, #-4]! 208c2ecf20Sopenharmony_ci str lr, [r2, #-4]! 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci mov sp, r2 238c2ecf20Sopenharmony_ci mov r2, r0 248c2ecf20Sopenharmony_ci mov r0, r1 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci badr lr, 1f 278c2ecf20Sopenharmony_ci ret r2 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci1: ldr lr, [sp] 308c2ecf20Sopenharmony_ci ldr sp, [sp, #4] 318c2ecf20Sopenharmony_ci ret lr 328c2ecf20Sopenharmony_ciENDPROC(call_with_stack) 33