From f4deea529804bc0ca2405f58d5288d653f6c0859 Mon Sep 17 00:00:00 2001 From: aramya <22577625+thamugadi@users.noreply.github.com> Date: Sat, 1 Jul 2023 16:22:55 +0100 Subject: [PATCH] control --- entry/boot.c | 2 +- entry/ofw/common.c | 2 +- entry/ofw/control.c | 73 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 entry/ofw/control.c diff --git a/entry/boot.c b/entry/boot.c index f5013fe..61a7de9 100644 --- a/entry/boot.c +++ b/entry/boot.c @@ -10,7 +10,7 @@ void __eabi(void) void main(void) { - if (ofw_test("open")) + if (test("open")) { asm("mr 27, 28"); asm("b $"); diff --git a/entry/ofw/common.c b/entry/ofw/common.c index 906b99b..55a48d6 100644 --- a/entry/ofw/common.c +++ b/entry/ofw/common.c @@ -2,7 +2,7 @@ extern void (*ofw)(); -int32_t ofw_test(char* name) +int32_t test(char* name) { struct { diff --git a/entry/ofw/control.c b/entry/ofw/control.c new file mode 100644 index 0000000..6342f36 --- /dev/null +++ b/entry/ofw/control.c @@ -0,0 +1,73 @@ +#include + +extern void (*ofw)(); + +void boot(char* bootspec) +{ + struct + { + char* service; + int32_t n_args; + int32_t n_rets; + char* arg; + } ofw_arg; + + SERVICE("boot", 5, 1, 0); + + ofw_arg.arg = bootspec; + + ofw(&ofw_arg); +} + +void enter(void) +{ + struct + { + char* service; + int32_t n_args; + int32_t n_rets; + } ofw_arg; + + SERVICE("enter", 6, 0, 0); + + ofw(&ofw_arg); +} + +void ofw_exit(void) +{ + struct + { + char* service; + int32_t n_args; + int32_t n_rets; + } ofw_arg; + + SERVICE("exit", 5, 0, 0); + + ofw(&ofw_arg); +} + +void chain(void* virt, int32_t size, void* entry, void* args, int32_t len) +{ + struct + { + char* service; + int32_t n_args; + int32_t n_rets; + void* arg1; + int32_t arg2; + void* arg3; + void* arg4; + int32_t arg5; + } ofw_arg; + + SERVICE("chain", 6, 5, 0); + + ofw_arg.arg1 = virt; + ofw_arg.arg2 = size; + ofw_arg.arg3 = entry; + ofw_arg.arg4 = args; + ofw_arg.arg5 = len; + + ofw(&ofw_arg); +}