From 97f10d22f516cff5032a6bbc009ab20c30e113e2 Mon Sep 17 00:00:00 2001 From: aramya <22577625+thamugadi@users.noreply.github.com> Date: Sat, 1 Jul 2023 17:15:06 +0100 Subject: [PATCH] call-method --- entry/ofw/tree.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/entry/ofw/tree.c b/entry/ofw/tree.c index 5c9a6ca..784e885 100644 --- a/entry/ofw/tree.c +++ b/entry/ofw/tree.c @@ -246,7 +246,41 @@ int32_t package_to_path(phandle package, void* buf, int32_t buflen) } -void* call_method(char* method, ihandle instance, ...) +void* call_method(char* method, ihandle instance, int32_t* stack_args, int32_t n_stack_args) { + struct + { + char* service; + int32_t n_args; + int32_t n_rets; + char* arg1; + ihandle arg2; + int32_t argN[n_stack_args]; + int32_t ret1; + int32_t retN[16]; + } ofw_arg; + + SERVICE("call-method", 12, 2+n_stack_args, 16); + + ofw_arg.arg1 = method; + ofw_arg.arg2 = instance; + + int i; + for (i = 0; i < n_stack_args; i++) + { + ofw_arg.argN[i] = stack_args[i]; + } + + ofw(&ofw_arg); + + int32_t* addr = claim((int32_t*)0x04000000, 17, 1); + + *addr = ofw_arg.ret1; + for (i = 1; i < 17; i++) + { + addr[i] = ofw_arg.retN[i]; + } + + return addr; }