aboutsummaryrefslogtreecommitdiff
path: root/libgui/msg.c
diff options
context:
space:
mode:
authorMarvin Borner2021-03-14 16:12:44 +0100
committerGitHub2021-03-14 16:12:44 +0100
commit268f3ccdb90ab4b9bd70ca176478797aae97ca05 (patch)
tree2dbc3e52d90dab4aae8021773f09b6b72a74b8cb /libgui/msg.c
parent4309322f9d2b3e31421a3cc5399ab1f4368e0652 (diff)
parent6dec7db5158447b66f31a3f786ce2916cab83cec (diff)
Added memory management using paging
This was quite a roller-coaster and most things are slower now, but it works and is way more secure. I still need to implement things like shared memory for the WM/GUI system but other than that everything is supported.
Diffstat (limited to 'libgui/msg.c')
-rw-r--r--libgui/msg.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/libgui/msg.c b/libgui/msg.c
index 8448e73..3f58267 100644
--- a/libgui/msg.c
+++ b/libgui/msg.c
@@ -5,23 +5,23 @@
#include <print.h>
#include <sys.h>
-int msg_send(u32 pid, enum message_type type, void *data)
+int msg_send(u32 pid, enum message_type type, void *data, u32 size)
{
- struct message msg = { 0 };
- assert((signed)pid != -1);
+ assert((signed)pid != -1 && size >= sizeof(struct message_header));
char path[32] = { 0 };
sprintf(path, "/proc/%d/msg", pid);
- msg.magic = MSG_MAGIC;
- msg.src = getpid();
- msg.type = type;
- msg.data = data;
- return write(path, &msg, 0, sizeof(msg));
+ struct message_header *header = data;
+ header->magic = MSG_MAGIC;
+ header->src = getpid();
+ header->type = type;
+ return write(path, data, 0, size);
}
-int msg_receive(struct message *msg)
+int msg_receive(void *buf, u32 size)
{
- int ret = read("/proc/self/msg", msg, 0, sizeof(*msg));
- if (msg->magic == MSG_MAGIC && ret == sizeof(*msg))
+ int ret = read("/proc/self/msg", buf, 0, size);
+ struct message_header *header = buf;
+ if (header->magic == MSG_MAGIC)
return ret;
else
return -1;