create IPC folder && create IPC_msg class
This commit is contained in:
48
src/IPC/ipc.c
Normal file
48
src/IPC/ipc.c
Normal file
@@ -0,0 +1,48 @@
|
||||
#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"(1), "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 1;
|
||||
}
|
||||
|
||||
int syscalls_SendIPCMessage(lua_State* L)
|
||||
{
|
||||
lua_pushinteger(
|
||||
L,
|
||||
send_ipc(
|
||||
lua_checkinteger(L, 1),
|
||||
luaL_checkudata(L, 1, syscalls_IPC_msg_metatable_name)
|
||||
)
|
||||
);
|
||||
|
||||
return 1;
|
||||
}
|
Reference in New Issue
Block a user