80 lines
1.6 KiB
C
80 lines
1.6 KiB
C
#include <stdint.h>
|
|
#include <stddef.h>
|
|
#include "syscall/syscall.h"
|
|
#include "syscall/ipcmbus.h"
|
|
#include "ipc/mbus/mbus.h"
|
|
#include "errors.h"
|
|
|
|
int32_t SYSCALL3(sys_ipc_mbusmake, name1, objsize1, objmax1) {
|
|
const char *name = (const char *)name1;
|
|
size_t objsize = objsize1;
|
|
size_t objmax = objmax1;
|
|
|
|
if (name == NULL) {
|
|
return E_INVALIDARGUMENT;
|
|
}
|
|
|
|
IpcMBus *mbus = ipc_mbusmake(name, objsize, objmax);
|
|
if (mbus == NULL) {
|
|
return E_NOMEMORY;
|
|
}
|
|
|
|
return E_OK;
|
|
}
|
|
|
|
int32_t SYSCALL1(sys_ipc_mbusdelete, name1) {
|
|
const char *name = (const char *)name1;
|
|
|
|
return ipc_mbusdelete(name);
|
|
}
|
|
|
|
int32_t SYSCALL2(sys_ipc_mbuspublish, name1, buffer1) {
|
|
const char *name = (const char *)name1;
|
|
const uint8_t *const buffer = (const uint8_t *const)buffer1;
|
|
|
|
if (name == NULL) {
|
|
return E_INVALIDARGUMENT;
|
|
}
|
|
|
|
if (buffer == NULL) {
|
|
return E_INVALIDARGUMENT;
|
|
}
|
|
|
|
return ipc_mbuspublish(name, buffer);
|
|
}
|
|
|
|
int32_t SYSCALL2(sys_ipc_mbusconsume, name1, buffer1) {
|
|
const char *name = (const char *)name1;
|
|
uint8_t *const buffer = (int8_t *const)buffer1;
|
|
|
|
if (name == NULL) {
|
|
return E_INVALIDARGUMENT;
|
|
}
|
|
|
|
if (buffer == NULL) {
|
|
return E_INVALIDARGUMENT;
|
|
}
|
|
|
|
return ipc_mbusconsume(name, buffer, _caller_pid);
|
|
}
|
|
|
|
int32_t SYSCALL1(sys_ipc_mbusattch, name1) {
|
|
const char *name = (const char *)name1;
|
|
|
|
if (name == NULL) {
|
|
return E_INVALIDARGUMENT;
|
|
}
|
|
|
|
return ipc_mbusattch(name, _caller_pid);
|
|
}
|
|
|
|
int32_t SYSCALL1(sys_ipc_mbusdttch, name1) {
|
|
const char *name = (const char *)name1;
|
|
|
|
if (name == NULL) {
|
|
return E_INVALIDARGUMENT;
|
|
}
|
|
|
|
return ipc_mbusattch(name, _caller_pid);
|
|
}
|