[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tyndur-devel] [PATCH v2 1/7] kernel2: SHM-Funktionen bekommen Prozess als Parameter



* kernel2: Bis jetzt haben die SHM-Funktionen immer angenommen, dass
  fuer den aktuellen Prozess geoeffnet/geschlossen wird. Den Prozess
  wird jetzt als Parameter uebergeben.

Signed-off-by: Kevin Wolf <kevin@xxxxxxxxxx>
---
 src/kernel2/include/mm.h        |    4 ++--
 src/kernel2/include/tasks.h     |    2 +-
 src/kernel2/src/arch/i386/gdt.c |    1 +
 src/kernel2/src/mm/shm.c        |   13 +++++++------
 src/kernel2/src/syscalls/pm.c   |    1 +
 src/kernel2/src/syscalls/rpc.c  |    1 +
 src/kernel2/src/syscalls/shm.c  |    4 ++--
 src/kernel2/src/tasks/pm.c      |    1 +
 8 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/src/kernel2/include/mm.h b/src/kernel2/include/mm.h
index 0144aca..617713c 100644
--- a/src/kernel2/include/mm.h
+++ b/src/kernel2/include/mm.h
@@ -140,10 +140,10 @@ void shm_init(void);
 uint32_t shm_create(size_t size);
 
 /// Bestehenden Shared Memory oeffnen.
-void* shm_attach(uint32_t id);
+void* shm_attach(pm_process_t* process, uint32_t id);
 
 /// Shared Memory schliessen.
-void shm_detach(uint32_t id);
+void shm_detach(pm_process_t* process, uint32_t id);
 
 #endif
 
diff --git a/src/kernel2/include/tasks.h b/src/kernel2/include/tasks.h
index 1aedbec..c8370f4 100644
--- a/src/kernel2/include/tasks.h
+++ b/src/kernel2/include/tasks.h
@@ -39,7 +39,7 @@
 #include <types.h>
 #include <collections.h>
 
-#include "mm.h"
+#include "mm_arch.h"
 #include "lock.h"
 
 #define PM_STATUS_READY 0
diff --git a/src/kernel2/src/arch/i386/gdt.c b/src/kernel2/src/arch/i386/gdt.c
index e42c973..3dcdd3b 100644
--- a/src/kernel2/src/arch/i386/gdt.c
+++ b/src/kernel2/src/arch/i386/gdt.c
@@ -35,6 +35,7 @@
 
 #include <types.h>
 
+#include "mm.h"
 #include "cpu.h"
 #include "lock.h"
 
diff --git a/src/kernel2/src/mm/shm.c b/src/kernel2/src/mm/shm.c
index 67b4831..d05de0e 100644
--- a/src/kernel2/src/mm/shm.c
+++ b/src/kernel2/src/mm/shm.c
@@ -94,11 +94,12 @@ uint32_t shm_create(size_t size)
 /**
  * Bestehenden Shared Memory oeffnen.
  *
+ * @param process Prozess, der den Shared Memory oeffnet
  * @param id ID des zu oeffnenden Shared Memory
  * @return Virtuelle Adresse des geoeffneten Shared Memory; NULL, wenn der
  * Shared Memory mit der angegebenen ID nicht existiert.
  */
-void* shm_attach(uint32_t id)
+void* shm_attach(pm_process_t* process, uint32_t id)
 {
     struct shm_desc* shm = tree_search(shms, id);
     void* ret;
@@ -115,7 +116,7 @@ void* shm_attach(uint32_t id)
     } else {
         // Ansonsten Mapping von einem anderen Prozess uebernehmen
         struct shm_process* first = list_get_element_at(shm->processes, 0);
-        ret = mmc_automap_user(&mmc_current_context(),
+        ret = mmc_automap_user(&process->context,
             &first->process->context, first->vaddr, shm->num_pages,
             MM_USER_START, MM_USER_END, MM_FLAGS_USER_DATA);
     }
@@ -125,7 +126,7 @@ void* shm_attach(uint32_t id)
     }
 
     shm_proc = calloc(1, sizeof(*shm_proc));
-    shm_proc->process = current_process;
+    shm_proc->process = process;
     shm_proc->vaddr = ret;
     list_push(shm->processes, shm_proc);
 
@@ -136,13 +137,13 @@ void* shm_attach(uint32_t id)
  * Shared Memory schliessen. Wenn keine Prozesse den Shared Memory mehr
  * geoeffnet haben, wird er geloescht.
  *
+ * @param process Prozess, der den Shared Memory schliesst
  * @param id ID des zu schliessenden Shared Memory
  */
-void shm_detach(uint32_t id)
+void shm_detach(pm_process_t* process, uint32_t id)
 {
     struct shm_desc* shm = tree_search(shms, id);
     struct shm_process* shm_proc;
-    pm_process_t* current_proc = current_process;
     int i;
 
     if (shm == NULL) {
@@ -150,7 +151,7 @@ void shm_detach(uint32_t id)
     }
 
     for (i = 0; (shm_proc = list_get_element_at(shm->processes, i)); i++) {
-        if (shm_proc->process == current_proc) {
+        if (shm_proc->process == process) {
             list_remove(shm->processes, i);
             goto found;
         }
diff --git a/src/kernel2/src/syscalls/pm.c b/src/kernel2/src/syscalls/pm.c
index 8826a50..486b030 100644
--- a/src/kernel2/src/syscalls/pm.c
+++ b/src/kernel2/src/syscalls/pm.c
@@ -39,6 +39,7 @@
 
 #include "syscall.h"
 #include "syscall_structs.h"
+#include "mm.h"
 #include "tasks.h"
 #include "cpu.h"
 
diff --git a/src/kernel2/src/syscalls/rpc.c b/src/kernel2/src/syscalls/rpc.c
index 3c51ec6..515ad80 100644
--- a/src/kernel2/src/syscalls/rpc.c
+++ b/src/kernel2/src/syscalls/rpc.c
@@ -41,6 +41,7 @@
 
 #include "kernel.h"
 #include "syscall.h"
+#include "mm.h"
 #include "tasks.h"
 #include "cpu.h"
 #include "im.h"
diff --git a/src/kernel2/src/syscalls/shm.c b/src/kernel2/src/syscalls/shm.c
index c3aed63..0892622 100644
--- a/src/kernel2/src/syscalls/shm.c
+++ b/src/kernel2/src/syscalls/shm.c
@@ -56,7 +56,7 @@ uint32_t syscall_shm_create(size_t size)
  */
 void* syscall_shm_attach(uint32_t id)
 {
-    return shm_attach(id);
+    return shm_attach(current_process, id);
 }
 
 /**
@@ -67,6 +67,6 @@ void* syscall_shm_attach(uint32_t id)
  */
 void syscall_shm_detach(uint32_t id)
 {
-    shm_detach(id);
+    shm_detach(current_process, id);
 }
 
diff --git a/src/kernel2/src/tasks/pm.c b/src/kernel2/src/tasks/pm.c
index e5c4b9f..8dc8f2b 100644
--- a/src/kernel2/src/tasks/pm.c
+++ b/src/kernel2/src/tasks/pm.c
@@ -39,6 +39,7 @@
 #include <string.h>
 #include <collections.h>
 
+#include "mm.h"
 #include "tasks.h"
 #include "lock.h"
 #include "timer.h"
-- 
1.6.0.2