[lib][uefi] Support 5 arguments for switch stack call
Some functions have >4 arguments, bump support to 5 arguments
This commit is contained in:
@@ -17,23 +17,24 @@
|
||||
|
||||
#include <lk/asm.h>
|
||||
|
||||
// int call_with_stack_asm(void *stack, int (*fp)(), int arg1, int arg2, int arg3, int arg4);
|
||||
// int call_with_stack_asm(void *stack, int (*fp)(), int arg1, int arg2, int arg3, int arg4, int arg5);
|
||||
FUNCTION(call_with_stack_asm)
|
||||
stp fp, lr, [sp, #-16]!
|
||||
mov fp, sp
|
||||
|
||||
sub x0,x0,16
|
||||
mov x7,sp
|
||||
str x7,[x0]
|
||||
mov x8,sp
|
||||
str x8,[x0]
|
||||
mov sp,x0
|
||||
mov x6,x1
|
||||
mov x7,x1
|
||||
mov x0,x2
|
||||
mov x1,x3
|
||||
mov x2,x4
|
||||
mov x3,x5
|
||||
blr x6
|
||||
ldr x7,[sp]
|
||||
mov sp,x7
|
||||
mov x4,x6
|
||||
blr x7
|
||||
ldr x8,[sp]
|
||||
mov sp,x8
|
||||
|
||||
ldp fp, lr, [sp], 16
|
||||
ret lr
|
||||
|
||||
@@ -24,34 +24,46 @@
|
||||
__BEGIN_CDECLS
|
||||
|
||||
size_t call_with_stack_asm(void *stack, const void *function, void *param1,
|
||||
void *param2, void *param3, void *param4);
|
||||
void *param2, void *param3, void *param4,
|
||||
void *param5);
|
||||
|
||||
__END_CDECLS
|
||||
|
||||
#ifdef __cplusplus
|
||||
template <typename Function, typename P1, typename P2, typename P3, typename P4>
|
||||
template <typename Function, typename P1, typename P2, typename P3, typename P4,
|
||||
typename P5>
|
||||
size_t call_with_stack(void *stack, Function &&fp, P1 &¶m1, P2 &¶m2,
|
||||
P3 &¶m3, P4 &¶m4) {
|
||||
P3 &¶m3, P4 &¶m4, P5 &¶m5) {
|
||||
return call_with_stack_asm(
|
||||
stack, reinterpret_cast<const void *>(fp),
|
||||
reinterpret_cast<void *>(param1), reinterpret_cast<void *>(param2),
|
||||
reinterpret_cast<void *>(param3), reinterpret_cast<void *>(param4));
|
||||
reinterpret_cast<void *>(param3), reinterpret_cast<void *>(param4),
|
||||
reinterpret_cast<void *>(param5));
|
||||
}
|
||||
template <typename Function, typename P1, typename P2, typename P3, typename P4>
|
||||
size_t call_with_stack(void *stack, Function &&fp, P1 &¶m1, P2 &¶m2,
|
||||
P3 &¶m3, P4 &¶m4) {
|
||||
return call_with_stack_asm(stack, reinterpret_cast<const void *>(fp),
|
||||
reinterpret_cast<void *>(param1),
|
||||
reinterpret_cast<void *>(param2),
|
||||
reinterpret_cast<void *>(param3),
|
||||
reinterpret_cast<void *>(param4), nullptr);
|
||||
}
|
||||
|
||||
template <typename Function, typename P1, typename P2, typename P3>
|
||||
size_t call_with_stack(void *stack, Function &&fp, P1 &¶m1, P2 &¶m2,
|
||||
P3 &¶m3) {
|
||||
return call_with_stack_asm(stack, reinterpret_cast<const void *>(fp),
|
||||
reinterpret_cast<void *>(param1),
|
||||
reinterpret_cast<void *>(param2),
|
||||
reinterpret_cast<void *>(param3), nullptr);
|
||||
return call_with_stack_asm(
|
||||
stack, reinterpret_cast<const void *>(fp),
|
||||
reinterpret_cast<void *>(param1), reinterpret_cast<void *>(param2),
|
||||
reinterpret_cast<void *>(param3), nullptr, nullptr);
|
||||
}
|
||||
|
||||
template <typename Function, typename P1, typename P2>
|
||||
size_t call_with_stack(void *stack, Function &&fp, P1 &¶m1, P2 &¶m2) {
|
||||
return call_with_stack_asm(stack, reinterpret_cast<const void *>(fp),
|
||||
reinterpret_cast<void *>(param1),
|
||||
reinterpret_cast<void *>(param2), nullptr,
|
||||
reinterpret_cast<void *>(param2), nullptr, nullptr,
|
||||
nullptr);
|
||||
}
|
||||
|
||||
@@ -59,7 +71,7 @@ template <typename Function, typename P1>
|
||||
size_t call_with_stack(void *stack, Function &&fp, P1 &¶m1) {
|
||||
return call_with_stack_asm(stack, reinterpret_cast<const void *>(fp),
|
||||
reinterpret_cast<void *>(param1), nullptr, nullptr,
|
||||
nullptr);
|
||||
nullptr, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user