From a987a24e4acefec847654829979312ff7b382c83 Mon Sep 17 00:00:00 2001 From: aramya <22577625+thamugadi@users.noreply.github.com> Date: Sat, 1 Jul 2023 16:03:33 +0100 Subject: [PATCH] io, mem --- entry/ofw/io.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++ entry/ofw/mem.c | 47 +++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 entry/ofw/mem.c diff --git a/entry/ofw/io.c b/entry/ofw/io.c index 3afe999..a65c830 100644 --- a/entry/ofw/io.c +++ b/entry/ofw/io.c @@ -38,3 +38,76 @@ void close(ihandle instance) ofw(&ofw_arg); } +int32_t read(ihandle instance, void* addr, int32_t len) +{ + struct + { + char* service; + int32_t n_args; + int32_t n_rets; + ihandle arg1; + void* arg2; + int32_t arg3; + int32_t ret; + } ofw_arg; + + SERVICE("read", 5, 3, 1); + + ofw_arg.arg1 = instance; + ofw_arg.arg2 = addr; + ofw_arg.arg3 = len; + + ofw(&ofw_arg); + + return ofw_arg.ret; +} + +int32_t write(ihandle instance, void* addr, int32_t len) +{ + struct + { + char* service; + int32_t n_args; + int32_t n_rets; + ihandle arg1; + void* arg2; + int32_t arg3; + int32_t ret; + } ofw_arg; + + SERVICE("write", 6, 3, 1); + + ofw_arg.arg1 = instance; + ofw_arg.arg2 = addr; + ofw_arg.arg3 = len; + + ofw(&ofw_arg); + + return ofw_arg.ret; + +} + +int32_t seek(ihandle instance, int32_t pos_hi, int32_t pos_lo) +{ + struct + { + char* service; + int32_t n_args; + int32_t n_rets; + ihandle arg1; + int32_t* arg2; + int32_t arg3; + int32_t ret; + } ofw_arg; + + SERVICE("seek", 5, 3, 1); + + ofw_arg.arg1 = instance; + ofw_arg.arg2 = pos_hi; + ofw_arg.arg3 = pos_lo; + + ofw(&ofw_arg); + + return ofw_arg.ret; + +} diff --git a/entry/ofw/mem.c b/entry/ofw/mem.c new file mode 100644 index 0000000..a380ad2 --- /dev/null +++ b/entry/ofw/mem.c @@ -0,0 +1,47 @@ +#include + +extern void (*ofw)(); + +void* claim(void* virt, int32_t size, int32_t align) +{ + struct + { + char* service; + int32_t n_args; + int32_t n_rets; + void* arg1; + int32_t arg2; + int32_t arg3; + void* ret; + } ofw_arg; + + SERVICE("claim", 6, 3, 1); + + ofw_arg.arg1 = virt; + ofw_arg.arg2 = size; + ofw_arg.arg3 = align; + + ofw(&ofw_arg); + return ofw_arg.ret; +} + + +void release(void* virt, int32_t size) +{ + struct + { + char* service; + int32_t n_args; + int32_t n_rets; + void* arg1; + int32_t arg2; + } ofw_arg; + + SERVICE("release", 8, 2, 0); + + ofw_arg.arg1 = virt; + ofw_arg.arg2 = size; + + ofw(&ofw_arg); +} +