OrionLibC
Barry Importing existing Orion LibC 03048a9 (2 years, 2 months ago)diff --git a/sys/ipc.c b/sys/ipc.c new file mode 100644 index 0000000..3a563fe --- /dev/null +++ b/sys/ipc.c @@ -0,0 +1,43 @@ +#include <stdint.h> +#include <sys/ipc.h> +#include <sys/syscall.h> + +/* Send a message without blocking */ +Message * +nb_send_msg(pid_t to, uint16_t type, MessageContent *msg) +{ + int ret; + asm volatile("int $0x80" : "=a" (ret) : "0" (SYSCALL_NB_SEND_MSG), + "c" (3), "S" (&to)); + return (Message *) ret; +} + +/* Send a message and block until delivery */ +Message * +send_msg(pid_t to, uint16_t type, MessageContent *msg) +{ + int ret; + asm volatile("int $0x80" : "=a" (ret) : "0" (SYSCALL_SEND_MSG), + "c" (3), "S" (&to)); + return (Message *) ret; +} + +/* Receive a message if available */ +pid_t +nb_recv_msg(Message *buf, pid_t from) +{ + int ret; + asm volatile("int $0x80" : "=a" (ret) : "0" (SYSCALL_NB_RECV_MSG), + "c" (2), "S" (&buf)); + return (pid_t) ret; +} + +/* Block until a message is received */ +pid_t +recv_msg(Message *buf, pid_t from) +{ + int ret; + asm volatile("int $0x80" : "=a" (ret) : "0" (SYSCALL_RECV_MSG), + "c" (2), "S" (&buf)); + return (pid_t) ret; +}