48 lines
901 B
C
48 lines
901 B
C
#include "ipc.h"
|
|
#include "IPC_msg.h"
|
|
#include <sys/ksys.h>
|
|
|
|
inline static void define_ipc(ksys_ipc_buffer* buffer, size_t bufLen)
|
|
{
|
|
asm_inline(
|
|
"int $0x40"
|
|
::"a"(60), "b"(1), "c"(buffer), "d"(bufLen)
|
|
);
|
|
}
|
|
|
|
inline static enum SendIPCErrors send_ipc(int pid, ksys_ipc_msg* msg)
|
|
{
|
|
enum SendIPCErrors ret;
|
|
|
|
asm_inline(
|
|
"int $0x40"
|
|
: "=a"(ret)
|
|
: "a"(60), "b"(2), "c"(pid), "d"(msg), "S"(sizeof(ksys_ipc_msg) + msg->datalen)
|
|
);
|
|
|
|
return ret;
|
|
}
|
|
|
|
int syscalls_DefineIPCBuffer(lua_State* L)
|
|
{
|
|
uint32_t len = luaL_checkinteger(L, 1);
|
|
ksys_ipc_buffer* buffer;
|
|
|
|
define_ipc(buffer, len);
|
|
|
|
return 0;
|
|
}
|
|
|
|
int syscalls_SendIPCMessage(lua_State* L)
|
|
{
|
|
lua_pushinteger(
|
|
L,
|
|
send_ipc(
|
|
luaL_checkinteger(L, 1),
|
|
luaL_checkudata(L, 1, syscalls_IPC_msg_metatable_name)
|
|
)
|
|
);
|
|
|
|
return 1;
|
|
}
|