Index: trunk/kernel/syscalls/sys_sem.c
===================================================================
--- trunk/kernel/syscalls/sys_sem.c	(revision 1)
+++ trunk/kernel/syscalls/sys_sem.c	(revision 23)
@@ -2,14 +2,15 @@
  * sys_sem.c - Acces a POSIX unamed semaphore.
  * 
- * Copyright (c) 2008,2009,2010,2011,2012 Ghassan Almaless
- * Copyright (c) 2011,2012 UPMC Sorbonne Universites
+ * Authors     Alain Greiner (2016,2017)
  *
- * This file is part of ALMOS-kernel.
+ * Copyright (c) UPMC Sorbonne Universites
  *
- * ALMOS-kernel is free software; you can redistribute it and/or modify it
+ * This file is part of ALMOS-MKH.
+ *
+ * ALMOS-MKH is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by
  * the Free Software Foundation; version 2.0 of the License.
  *
- * ALMOS-kernel is distributed in the hope that it will be useful, but
+ * ALMOS-MKH is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
@@ -17,11 +18,16 @@
  *
  * You should have received a copy of the GNU General Public License
- * along with ALMOS-kernel; if not, write to the Free Software Foundation,
+ * along with ALMOS-MKH; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <hal_types.h>
-#include <hal_uspace.
+#include <hal_uspace.h>
+#include <errno.h>
+#include <thread.h>
+#include <printk.h>
+#include <vmm.h>
 #include <remote_sem.h>
+#include <syscalls.h>
 
 //////////////////////////////////
@@ -31,13 +37,15 @@
 {
 	uint32_t             data;   
-	error_t              error;
+	paddr_t              paddr;
+    error_t              error;
 
-    thread_t           * this      = CURRENT_THREAD;
-	process_t          * process   = CURRENT_PROCESS;
+    thread_t           * this = CURRENT_THREAD;
 
     // check vaddr in user vspace
-	error = vmm_check_address( process , vaddr , sizeof(unsigned long) );
-	if( error ) 
+	error = vmm_v2p_translate( false , vaddr , &paddr );
+	if( error )
     {
+        printk("\n[ERROR] in %s : illegal semaphore virtual address = %x\n",
+               __FUNCTION__ , (intptr_t)vaddr );
         this->errno = error;
         return -1;
@@ -45,7 +53,9 @@
 
     // check value in user vspace
-    error = vmm_check_address( process , value , sizeof(int*) );
-	if( error ) 
+	error = vmm_v2p_translate( false , value , &paddr );
+	if( error )
     {
+        printk("\n[ERROR] in %s : illegal argument virtual address = %x\n",
+               __FUNCTION__ , (intptr_t)value );
         this->errno = error;
         return -1;   
@@ -62,8 +72,10 @@
 
             // call init function
-            error = remote_sem_init( (intptr_t)vaddr , data );
+            error = remote_sem_create( (intptr_t)vaddr , data );
 
             if ( error )
             {
+                printk("\n[ERROR] in %s : cannot create semaphore = %x\n",
+                       __FUNCTION__ , (intptr_t)value );
                 this->errno = error;
                 return -1;
@@ -79,4 +91,6 @@
             if( sem_xp == XPTR_NULL )     // user error
             {
+                printk("\n[ERROR] in %s : semaphore %x not registered\n",
+                       __FUNCTION__ , (intptr_t)value );
                 this->errno = EINVAL;
                 return -1;
@@ -100,4 +114,6 @@
             if( sem_xp == XPTR_NULL )     // user error
             {
+                printk("\n[ERROR] in %s : semaphore %x not registered\n",
+                       __FUNCTION__ , (intptr_t)value );
                 this->errno = EINVAL;
                 return -1;
@@ -118,4 +134,6 @@
             if( sem_xp == XPTR_NULL )     // user error
             {
+                printk("\n[ERROR] in %s : semaphore %x not registered\n",
+                       __FUNCTION__ , (intptr_t)value );
                 this->errno = EINVAL;
                 return -1;
@@ -136,4 +154,6 @@
             if( sem_xp == XPTR_NULL )     // user error
             {
+                printk("\n[ERROR] in %s : semaphore %x not registered\n",
+                       __FUNCTION__ , (intptr_t)value );
                 this->errno = EINVAL;
                 return -1;
@@ -149,6 +169,6 @@
 	    default:  // undefined operation                       
         {
-		    this->errno = EINVAL;
-            return -1;
+            printk("\n[PANIC] in %s : illegal operation type\n", __FUNCTION__ );
+            hal_core_sleep();
         }
 	}
