summaryrefslogtreecommitdiff
path: root/src/kernel/ipc/shm.c
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2010-03-23 16:34:36 +0100
committerAlexis211 <alexis211@gmail.com>2010-03-23 16:34:36 +0100
commitcbadacbb881200b601c7b53b29aa0c1b78747692 (patch)
treec3230c4d2dc8f75d126826954b80a37770ad26c7 /src/kernel/ipc/shm.c
parent6266a24cd2f71a0bad0e55c1eedd480790868c0f (diff)
downloadTCE-cbadacbb881200b601c7b53b29aa0c1b78747692.tar.gz
TCE-cbadacbb881200b601c7b53b29aa0c1b78747692.zip
More work on IPC
Diffstat (limited to 'src/kernel/ipc/shm.c')
-rw-r--r--src/kernel/ipc/shm.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/kernel/ipc/shm.c b/src/kernel/ipc/shm.c
index 0a0d3ee..1cdacfb 100644
--- a/src/kernel/ipc/shm.c
+++ b/src/kernel/ipc/shm.c
@@ -1,6 +1,7 @@
#include "shm.h"
#include <mem/mem.h>
#include <mem/seg.h>
+#include <task/task.h>
struct segment* shmseg_make(size_t len, struct process* owner) {
struct shmseg *ss = kmalloc(sizeof(struct shmseg));
@@ -54,3 +55,28 @@ void shmseg_delete(struct segment *seg) {
}
kfree(ss->frames);
}
+
+struct segment_map* shmseg_getByOff(struct process* pr, size_t offset) {
+ struct segment_map* m = pr->pagedir->mappedSegs;
+ while (m != 0) {
+ if (m->start == offset && m->seg->delete == shmseg_delete) return m;
+ m = m->next;
+ }
+ return 0;
+}
+
+// **** **** SHM syscalls **** ****
+int shm_create(size_t offset, size_t len) {
+ if (offset >= 0xE0000000) return -1;
+ if (len >= 0x10000000) return -1;
+ if (offset+len >= 0xE0000000) return -1;
+ seg_map(shmseg_make(len, current_thread->process), current_thread->process->pagedir, offset);
+ return 0;
+}
+
+int shm_delete(size_t offset) {
+ struct segment_map *s = shmseg_getByOff(current_thread->process, offset);
+ if (s == 0) return -1;
+ seg_unmap(s);
+ return 0;
+}