Index: trunk/kernel/mm/vmm.c
===================================================================
--- trunk/kernel/mm/vmm.c	(revision 14)
+++ trunk/kernel/mm/vmm.c	(revision 21)
@@ -5,5 +5,5 @@
  *           Mohamed Lamine Karaoui (2015)
  *           Alain Greiner (2016)
- * 
+ *
  * Copyright (c) UPMC Sorbonne Universites
  *
@@ -52,5 +52,5 @@
 ////////////////////////////////////
 void vmm_init( process_t * process )
-{  
+{
     error_t   error;
     vseg_t  * vseg_kentry;
@@ -72,9 +72,9 @@
         hal_core_sleep();
     }
-    
+
     // check max number of stacks slots
     if( CONFIG_THREAD_MAX_PER_CLUSTER > 32 )
     {
-        printk("\n[PANIC] in %s : max number ot threads per cluster for a sihgle process"
+        printk("\n[PANIC] in %s : max number of threads per cluster for a single process"
                " cannot be larger than 32\n", __FUNCTION__ );
         hal_core_sleep();
@@ -82,5 +82,5 @@
 
     // check STACK zone size
-    if( (CONFIG_VMM_STACK_SIZE * CONFIG_THREAD_MAX_PER_CLUSTER) > 
+    if( (CONFIG_VMM_STACK_SIZE * CONFIG_THREAD_MAX_PER_CLUSTER) >
         (CONFIG_VMM_VSPACE_SIZE - CONFIG_VMM_STACK_BASE) )
     {
@@ -90,5 +90,5 @@
     }
 
-    // initialise the rwlock protecting the vsegs list
+    // initialize the rwlock protecting the vsegs list
 	rwlock_init( &vmm->vsegs_lock );
 
@@ -102,5 +102,5 @@
     if( error )
     {
-        printk("\n[PANIC] in %s : cannot initialise radix tree for process %x\n",
+        printk("\n[PANIC] in %s : cannot initialize radix tree for process %x\n",
                __FUNCTION__ , process->pid );
         hal_core_sleep();
@@ -111,5 +111,5 @@
     size = CONFIG_VMM_KENTRY_SIZE << CONFIG_PPM_PAGE_SHIFT;
     vseg_kentry = vmm_create_vseg( process , base , size , VSEG_TYPE_CODE );
-    if( vseg_kentry == NULL ) 
+    if( vseg_kentry == NULL )
     {
         printk("\n[PANIC] in %s : cannot register kent vseg for process %x\n",
@@ -123,5 +123,5 @@
     size = CONFIG_VMM_ARGS_SIZE << CONFIG_PPM_PAGE_SHIFT;
     vseg_args = vmm_create_vseg( process , base , size , VSEG_TYPE_DATA );
-    if( vseg_args == NULL ) 
+    if( vseg_args == NULL )
     {
         printk("\n[PANIC] in %s : cannot register args vseg for process %x\n",
@@ -135,5 +135,5 @@
     size = CONFIG_VMM_ENVS_SIZE << CONFIG_PPM_PAGE_SHIFT;
     vseg_envs = vmm_create_vseg( process , base , size , VSEG_TYPE_DATA );
-    if( vseg_envs == NULL ) 
+    if( vseg_envs == NULL )
     {
         printk("\n[PANIC] in %s : cannot register envs vseg for process %x\n",
@@ -147,5 +147,5 @@
     size = (CONFIG_VMM_MMAP_BASE-CONFIG_VMM_HEAP_BASE) << CONFIG_PPM_PAGE_SHIFT;
     vseg_heap = vmm_create_vseg( process , base , size , VSEG_TYPE_HEAP );
-    if( vseg_heap == NULL ) 
+    if( vseg_heap == NULL )
     {
         printk("\n[PANIC] in %s : cannot register heap vseg in for process %x\n",
@@ -174,5 +174,5 @@
     for( i = 0 ; i < 32 ; i++ ) list_root_init( &vmm->mmap_mgr.zombi_list[i] );
 
-    // initialise instrumentation counters
+    // initialize instrumentation counters
 	vmm->pgfault_nr          = 0;
 	vmm->u_err_nr            = 0;
@@ -227,5 +227,5 @@
 /////////////////////////////////////////////////
 vseg_t * vmm_check_conflict( process_t * process,
-                             vpn_t       vpn_base, 
+                             vpn_t       vpn_base,
                              vpn_t       vpn_size )
 {
@@ -238,6 +238,6 @@
 	{
 		vseg = LIST_ELEMENT( iter , vseg_t , list );
-		if( ((vpn_base + vpn_size) > vseg->vpn_base) && 
-             (vpn_base < (vseg->vpn_base + vseg->vpn_size)) ) return vseg; 
+		if( ((vpn_base + vpn_size) > vseg->vpn_base) &&
+             (vpn_base < (vseg->vpn_base + vseg->vpn_size)) ) return vseg;
 	}
     return NULL;
@@ -249,5 +249,5 @@
 ////////////////////////////////////////////////////////////////////////////////////////////
 // @ vmm      : pointer on VMM.
-// @ vpn_base : (return value) first alocated page 
+// @ vpn_base : (return value) first allocated page
 // @ vpn_size : (return value) number of allocated pages
 ////////////////////////////////////////////////////////////////////////////////////////////
@@ -268,9 +268,9 @@
     // update bitmap
     bitmap_set( &mgr->bitmap , index );
-            
+
     // release lock on stack allocator
     spinlock_unlock( &mgr->lock );
 
-    // returns vpn_base, vpn_size (one page non allocated) 
+    // returns vpn_base, vpn_size (one page non allocated)
     *vpn_base = mgr->vpn_base + index * CONFIG_VMM_STACK_SIZE + 1;
     *vpn_size = CONFIG_VMM_STACK_SIZE - 1;
@@ -285,5 +285,5 @@
 // @ vmm      : [in] pointer on VMM.
 // @ npages   : [in] requested number of pages.
-// @ vpn_base : [out] first allocated page. 
+// @ vpn_base : [out] first allocated page.
 // @ vpn_size : [out] actual number of allocated pages.
 ////////////////////////////////////////////////////////////////////////////////////////////
@@ -297,7 +297,7 @@
     vpn_t      base;
     vpn_t      size;
-    vpn_t      free;    
-
-    // mmap vseg size must be power of 2 
+    vpn_t      free;
+
+    // mmap vseg size must be power of 2
     // compute actual size and index in zombi_list array
     size  = POW2_ROUNDUP( npages );
@@ -333,6 +333,6 @@
         // compute base
         base = vseg->vpn_base;
-    }    
-            
+    }
+
     // release lock on mmap allocator
     spinlock_unlock( &mgr->lock );
@@ -343,14 +343,14 @@
     return 0;
 
-}  // end vmm_mmap_allocator()
+}  // end vmm_mmap_alloc()
 
 //////////////////////////////////////////////
 vseg_t * vmm_create_vseg( process_t * process,
-                          intptr_t    base, 
-	                      intptr_t    size, 
+                          intptr_t    base,
+	                      intptr_t    size,
 	                      uint32_t    type )
 {
     vseg_t     * vseg;          // created vseg pointer
-    vpn_t        vpn_base;      // vseg first page 
+    vpn_t        vpn_base;      // vseg first page
     vpn_t        vpn_size;      // number of pages
 	error_t      error;
@@ -358,8 +358,8 @@
     // get pointer on VMM
 	vmm_t * vmm = &process->vmm;
-  
+
 	vmm_dmsg("\n[INFO] %s enter for process %x / base = %x / size = %x / type = %s\n",
 		     __FUNCTION__ , process->pid , base , size , vseg_type_name[type] );
-   
+
     // compute base, size, vpn_base, vpn_size, depending on type
     // we use the VMM specific allocators for STACK and MMAP vsegs
@@ -379,6 +379,6 @@
         size = vpn_size << CONFIG_PPM_PAGE_SHIFT;
     }
-    else if( (type == VSEG_TYPE_ANON) || 
-             (type == VSEG_TYPE_FILE) || 
+    else if( (type == VSEG_TYPE_ANON) ||
+             (type == VSEG_TYPE_FILE) ||
              (type == VSEG_TYPE_REMOTE) )
     {
@@ -407,8 +407,8 @@
     if( vseg != NULL )
     {
-        printk("\n[ERROR] in %s for process %x : new vseg [vpn_base = %x / vpn_size = %x]\n" 
+        printk("\n[ERROR] in %s for process %x : new vseg [vpn_base = %x / vpn_size = %x]\n"
                "  overlap existing vseg [vpn_base = %x / vpn_size = %x]\n",
-               __FUNCTION__ , process->pid, vpn_base, vpn_size, 
-               vseg->vpn_base, vseg->vpn_size ); 
+               __FUNCTION__ , process->pid, vpn_base, vpn_size,
+               vseg->vpn_base, vseg->vpn_size );
         return NULL;
     }
@@ -434,7 +434,7 @@
 	rwlock_wr_unlock( &vmm->vsegs_lock );
 
-	vmm_dmsg("\n[INFO] : %s exit for process %x, vseg [%x, %x] has been mapped\n", 
+	vmm_dmsg("\n[INFO] : %s exit for process %x, vseg [%x, %x] has been mapped\n",
 		     __FUNCTION__ , process->pid , vseg->min , vseg->max );
-  
+
 	return vseg;
 
@@ -517,5 +517,5 @@
     gpt_t * gpt = &process_zero.vmm.gpt;
 
-    // define number of small pages per PTE 
+    // define number of small pages per PTE
 	if( attr & GPT_SMALL ) order = 0;   // 1 small page
 	else                   order = 9;   // 512 small pages
@@ -531,5 +531,5 @@
 	    req.flags = AF_KERNEL | AF_ZERO;
 	    page      = (page_t *)kmem_alloc( &req );
-		if( page == NULL ) 
+		if( page == NULL )
         {
             printk("\n[ERROR] in %s : cannot allocate physical memory\n", __FUNCTION__ );
@@ -540,5 +540,5 @@
         ppn = ppm_page2ppn( page );
         error = hal_gpt_set_pte( gpt , vpn , ppn , attr );
-		if( error ) 
+		if( error )
         {
             printk("\n[ERROR] in %s : cannot register PPE\n", __FUNCTION__ );
@@ -546,5 +546,5 @@
         }
 	}
- 
+
 	return 0;
 } // end vmm_map_vseg()
@@ -554,6 +554,6 @@
                      vseg_t    * vseg )
 {
-    vpn_t       vpn;        // VPN of current PTE 
-    vpn_t       vpn_min;    // VPN of first PTE 
+    vpn_t       vpn;        // VPN of current PTE
+    vpn_t       vpn_min;    // VPN of first PTE
     vpn_t       vpn_max;    // VPN of last PTE (excluded)
 
@@ -583,5 +583,5 @@
     intptr_t addr_min = base;
 	intptr_t addr_max = base + size;
-    uint32_t shift    = CONFIG_PPM_PAGE_SHIFT;       
+    uint32_t shift    = CONFIG_PPM_PAGE_SHIFT;
 
     // get pointer on vseg
@@ -589,8 +589,8 @@
 
 	if( vseg == NULL)  return EINVAL;
-  
+
     // get VMM lock protecting vsegs list
 	rwlock_wr_lock( &vmm->vsegs_lock );
-  
+
 	if( (vseg->min > addr_min) || (vseg->max < addr_max) )   // region not included in vseg
     {
@@ -659,5 +659,5 @@
     error_t   error;
 
-    // this function must be called by in the reference cluster 
+    // this function must be called by in the reference cluster
     if( process->is_ref == false );
     {
@@ -673,5 +673,5 @@
 
     // if PTE unmapped => allocate one small physical page to map it
-    if( (attr & GPT_MAPPED) == 0 )  
+    if( (attr & GPT_MAPPED) == 0 )
     {
         // get vseg pointer
@@ -702,5 +702,5 @@
         page_t     * page;
         if( target_cxy == local_cxy )        // target cluster is the local cluster
-        { 
+        {
             req.type  = KMEM_PAGE;
             req.size  = 0;
@@ -723,5 +723,5 @@
         }
 
-        // defineg GPT attributes from vseg flags
+        // define GPT attributes from vseg flags
         attr = GPT_MAPPED | GPT_SMALL;
         if( vseg->flags & VSEG_USER  ) attr |= GPT_USER;
@@ -741,5 +741,5 @@
 
     *ret_ppn  = ppn;
-    *ret_attr = attr;  
+    *ret_attr = attr;
     return 0;
 }  // end vmm_get_pte()
@@ -751,5 +751,5 @@
 {
     uint32_t         attr;          // missing page attributes
-    ppn_t            ppn;           // missing page PPN 
+    ppn_t            ppn;           // missing page PPN
     error_t          error;         // return value
 
@@ -766,5 +766,5 @@
         rpc_vmm_get_pte_client( ref_cxy , ref_ptr , vpn , &attr , &ppn , &error );
     }
-    else                              // local cluster is the reference cluster       
+    else                              // local cluster is the reference cluster
     {
         error = vmm_get_pte( process , vpn , &attr , &ppn );
@@ -775,5 +775,5 @@
     {
         printk("\n[ERROR] in %s : cannot allocate memory / process = %x / vpn = %x\n",
-               __FUNCTION__ , process->pid , vpn ); 
+               __FUNCTION__ , process->pid , vpn );
 	    return ENOMEM;
     }
@@ -784,8 +784,8 @@
     {
         printk("\n[ERROR] in %s : cannot register PTE / process = %x / vpn = %x\n",
-               __FUNCTION__ , process->pid , vpn ); 
+               __FUNCTION__ , process->pid , vpn );
         return ENOMEM;
     }
- 
+
     return 0;
 }  // end vmm_handle_page_fault()
@@ -807,5 +807,5 @@
     }
 
-    // access page table 
+    // access page table
     error_t  error;
     vpn_t    vpn;
@@ -834,9 +834,9 @@
         return error;
     }
-  
+
     // return paddr
     *paddr = (((paddr_t)ppn) << CONFIG_PPM_PAGE_SHIFT) | offset;
     return 0;
- 
+
 }  // end vmm_v2p_translate()
 
