This commit is contained in:
aramya 2023-07-01 16:03:33 +01:00
parent 511d46db9b
commit a987a24e4a
2 changed files with 120 additions and 0 deletions

View File

@ -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;
}

47
entry/ofw/mem.c Normal file
View File

@ -0,0 +1,47 @@
#include <ofw.h>
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);
}