powerpc-ofw-boot/entry/tree.c

253 lines
5.1 KiB
C
Raw Normal View History

2023-07-01 11:07:36 +00:00
#include <ofw.h>
2023-07-01 10:27:07 +00:00
extern void (*ofw)();
2023-07-01 11:08:55 +00:00
phandle child(phandle _child)
2023-07-01 10:27:07 +00:00
{
2023-07-01 11:08:55 +00:00
struct
2023-07-01 10:27:07 +00:00
{
char* service;
2023-07-01 14:07:47 +00:00
int32_t n_args;
int32_t n_rets;
2023-07-01 11:08:55 +00:00
phandle arg;
phandle ret;
2023-07-01 10:27:07 +00:00
} ofw_arg;
2023-07-01 11:23:50 +00:00
SERVICE("child", 6, 1, 1);
2023-07-01 10:27:07 +00:00
2023-07-01 11:08:55 +00:00
ofw_arg.arg = _child;
2023-07-01 10:27:07 +00:00
ofw(&ofw_arg);
return ofw_arg.ret;
}
2023-07-01 11:07:36 +00:00
phandle parent(phandle _parent)
{
struct
{
char* service;
2023-07-01 14:07:47 +00:00
int32_t n_args;
int32_t n_rets;
2023-07-01 11:07:36 +00:00
phandle arg;
phandle ret;
} ofw_arg;
2023-07-01 11:23:50 +00:00
SERVICE("parent", 7, 1, 1);
2023-07-01 11:07:36 +00:00
ofw_arg.arg = _parent;
ofw(&ofw_arg);
return ofw_arg.ret;
}
2023-07-01 11:35:19 +00:00
phandle instance_to_package(ihandle instance)
2023-07-01 11:07:36 +00:00
{
struct
{
char* service;
2023-07-01 14:07:47 +00:00
int32_t n_args;
int32_t n_rets;
2023-07-01 11:07:36 +00:00
ihandle arg;
phandle ret;
} ofw_arg;
2023-07-01 11:23:50 +00:00
SERVICE("instance-to-package", 20, 1, 1);
2023-07-01 11:07:36 +00:00
2023-07-01 11:35:19 +00:00
ofw_arg.arg = instance;
2023-07-01 11:07:36 +00:00
ofw(&ofw_arg);
return ofw_arg.ret;
}
2023-07-01 14:07:47 +00:00
int32_t getproplen(phandle node, char* name)
2023-07-01 11:07:36 +00:00
{
struct
{
char* service;
2023-07-01 14:07:47 +00:00
int32_t n_args;
int32_t n_rets;
2023-07-01 11:07:36 +00:00
phandle arg1;
2023-07-01 11:08:55 +00:00
char* arg2;
2023-07-01 14:07:47 +00:00
int32_t ret;
2023-07-01 11:07:36 +00:00
} ofw_arg;
2023-07-01 11:23:50 +00:00
SERVICE("getproplen", 11, 2, 1);
2023-07-01 11:07:36 +00:00
ofw_arg.arg1 = node;
2023-07-01 11:08:55 +00:00
ofw_arg.arg2 = name;
2023-07-01 11:07:36 +00:00
ofw(&ofw_arg);
return ofw_arg.ret;
}
2023-07-01 14:07:47 +00:00
int32_t getprop(phandle node, char* name, uint8_t* buf, int32_t buflen)
2023-07-01 11:07:36 +00:00
{
struct
{
char* service;
2023-07-01 14:07:47 +00:00
int32_t n_args;
int32_t n_rets;
2023-07-01 11:07:36 +00:00
phandle arg1;
2023-07-01 11:08:55 +00:00
char* arg2;
uint8_t* arg3;
2023-07-01 14:07:47 +00:00
int32_t arg4;
int32_t ret;
2023-07-01 11:07:36 +00:00
} ofw_arg;
2023-07-01 11:23:50 +00:00
SERVICE("getprop", 8, 4, 1);
2023-07-01 11:07:36 +00:00
ofw_arg.arg1 = node;
ofw_arg.arg2 = name;
2023-07-01 11:08:55 +00:00
ofw_arg.arg3 = buf;
ofw_arg.arg4 = buflen;
2023-07-01 11:07:36 +00:00
ofw(&ofw_arg);
return ofw_arg.ret;
}
2023-07-01 14:07:47 +00:00
int32_t nextprop(phandle node, char* previous, uint8_t* buf)
2023-07-01 11:07:36 +00:00
{
struct
{
char* service;
2023-07-01 14:07:47 +00:00
int32_t n_args;
int32_t n_rets;
2023-07-01 11:07:36 +00:00
phandle arg1;
char* arg2;
uint8_t* arg3;
2023-07-01 14:07:47 +00:00
int32_t ret;
2023-07-01 11:07:36 +00:00
} ofw_arg;
2023-07-01 11:23:50 +00:00
SERVICE("nextprop", 9, 3, 1);
2023-07-01 11:07:36 +00:00
ofw_arg.arg1 = node;
ofw_arg.arg2 = previous;
ofw_arg.arg3 = buf;
ofw(&ofw_arg);
return ofw_arg.ret;
}
2023-07-01 14:07:47 +00:00
int32_t setprop(phandle node, char* name, uint8_t* buf, int32_t len)
2023-07-01 11:07:36 +00:00
{
struct
{
char* service;
2023-07-01 14:07:47 +00:00
int32_t n_args;
int32_t n_rets;
2023-07-01 11:07:36 +00:00
phandle arg1;
char* arg2;
uint8_t* arg3;
2023-07-01 14:07:47 +00:00
int32_t arg4;
int32_t ret;
2023-07-01 11:07:36 +00:00
} ofw_arg;
char _service[8] = "setprop";
ofw_arg.service = _service;
ofw_arg.n_args = 4;
ofw_arg.n_rets = 1;
ofw_arg.arg1 = node;
ofw_arg.arg2 = name;
ofw_arg.arg3 = buf;
ofw_arg.arg4 = len;
ofw(&ofw_arg);
return ofw_arg.ret;
}
2023-07-01 14:07:47 +00:00
int32_t canon(char* device, uint8_t* buf, int32_t buflen)
2023-07-01 11:07:36 +00:00
{
struct
{
char* service;
2023-07-01 14:07:47 +00:00
int32_t n_args;
int32_t n_rets;
2023-07-01 11:07:36 +00:00
char* arg1;
uint8_t* arg2;
2023-07-01 14:07:47 +00:00
int32_t arg3;
int32_t ret;
2023-07-01 11:07:36 +00:00
} ofw_arg;
2023-07-01 11:23:50 +00:00
SERVICE("canon", 6, 3, 1);
2023-07-01 11:07:36 +00:00
ofw_arg.arg1 = device;
ofw_arg.arg2 = buf;
ofw_arg.arg3 = buflen;
ofw(&ofw_arg);
return ofw_arg.ret;
}
phandle finddevice(char* device)
{
struct
{
char* service;
2023-07-01 14:07:47 +00:00
int32_t n_args;
int32_t n_rets;
2023-07-01 11:07:36 +00:00
char* arg1;
2023-07-01 14:07:47 +00:00
int32_t ret;
2023-07-01 11:07:36 +00:00
} ofw_arg;
2023-07-01 11:23:50 +00:00
SERVICE("finddevice", 11, 1, 1);
2023-07-01 11:07:36 +00:00
ofw_arg.arg1 = device;
ofw(&ofw_arg);
return ofw_arg.ret;
}
2023-07-01 14:07:47 +00:00
int32_t instance_to_path(ihandle instance, uint8_t* buf, int32_t buflen)
2023-07-01 11:07:36 +00:00
{
struct
{
char* service;
2023-07-01 14:07:47 +00:00
int32_t n_args;
int32_t n_rets;
2023-07-01 11:07:36 +00:00
ihandle arg1;
uint8_t* arg2;
2023-07-01 14:07:47 +00:00
int32_t arg3;
int32_t ret;
2023-07-01 11:07:36 +00:00
} ofw_arg;
2023-07-01 11:23:50 +00:00
SERVICE("instance-to-path", 17, 3, 1);
2023-07-01 11:07:36 +00:00
ofw_arg.arg1 = instance;
ofw_arg.arg2 = buf;
ofw_arg.arg3 = buflen;
ofw(&ofw_arg);
return ofw_arg.ret;
}
2023-07-01 14:07:47 +00:00
int32_t package_to_path(phandle package, uint8_t* buf, int32_t buflen)
2023-07-01 11:07:36 +00:00
{
struct
{
char* service;
2023-07-01 14:07:47 +00:00
int32_t n_args;
int32_t n_rets;
2023-07-01 11:07:36 +00:00
ihandle arg1;
uint8_t* arg2;
2023-07-01 14:07:47 +00:00
int32_t arg3;
int32_t ret;
2023-07-01 11:07:36 +00:00
} ofw_arg;
2023-07-01 11:23:50 +00:00
SERVICE("package-to-path", 16, 3, 1);
2023-07-01 11:07:36 +00:00
ofw_arg.arg1 = package;
ofw_arg.arg2 = buf;
ofw_arg.arg3 = buflen;
ofw(&ofw_arg);
return ofw_arg.ret;
}
void* call_method(char* method, ihandle instance, ...)
{
}
2023-07-01 11:08:55 +00:00