Add call32_params() helper function.
Add helper function for calling 32bit functions with more than just
one parameter.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
diff --git a/src/stacks.c b/src/stacks.c
index 9c528f5..de71c1d 100644
--- a/src/stacks.c
+++ b/src/stacks.c
@@ -501,3 +501,30 @@
if (CONFIG_THREAD_OPTIONROMS && GET_GLOBAL(CanPreempt) && have_threads())
call32(_cfunc32flat_yield_preempt, 0, 0);
}
+
+
+/****************************************************************
+ * call32 helper
+ ****************************************************************/
+
+struct call32_params_s {
+ void *func;
+ u32 eax, edx, ecx;
+};
+
+u32 VISIBLE32FLAT
+call32_params_helper(struct call32_params_s *params)
+{
+ return ((u32 (*)(u32, u32, u32))params->func)(
+ params->eax, params->edx, params->ecx);
+}
+
+u32
+call32_params(void *func, u32 eax, u32 edx, u32 ecx, u32 errret)
+{
+ ASSERT16();
+ struct call32_params_s params = {func, eax, edx, ecx};
+ extern void _cfunc32flat_call32_params_helper(void);
+ return call32(_cfunc32flat_call32_params_helper
+ , (u32)MAKE_FLATPTR(GET_SEG(SS), ¶ms), errret);
+}
diff --git a/src/stacks.h b/src/stacks.h
index 5ee4adc..9fe8761 100644
--- a/src/stacks.h
+++ b/src/stacks.h
@@ -30,5 +30,6 @@
void finish_preempt(void);
int wait_preempt(void);
void check_preempt(void);
+u32 call32_params(void *func, u32 eax, u32 edx, u32 ecx, u32 errret);
#endif // stacks.h