Index: trunk/hal/tsar_mips32/core/hal_vmm.c
===================================================================
--- trunk/hal/tsar_mips32/core/hal_vmm.c	(revision 633)
+++ trunk/hal/tsar_mips32/core/hal_vmm.c	(revision 635)
@@ -44,10 +44,12 @@
 extern process_t            process_zero;
 extern chdev_directory_t    chdev_dir;
+extern char               * lock_type_str[];
 
 //////////////////////////////////////////////////////////////////////////////////////////
 // This function is called by the process_zero_init() function during kernel_init.
 // It initializes the VMM of the kernel proces_zero (containing all kernel threads)
-// in the local cluster: For TSAR, it registers one "kcode" vseg in kernel VSL, 
-// and registers one big page in slot[0] of kernel GPT.
+// in the local cluster.
+// For TSAR, it registers one "kcode" vseg in kernel VSL, and registers one big page 
+// in slot[0] of kernel GPT.
 //////////////////////////////////////////////////////////////////////////////////////////
 error_t  hal_vmm_kernel_init( boot_info_t * info )
@@ -58,6 +60,9 @@
     gpt_t * gpt = &process_zero.vmm.gpt;
 
-    // get cluster identifier
-    cxy_t cxy = local_cxy;
+#if DEBUG_HAL_VMM
+thread_t * this = CURRENT_THREAD;
+printk("\n[%s] thread[%x,%x] enter in cluster %x\n", 
+__FUNCTION__, this->process->pid, this->trdid, local_cxy );
+#endif
 
     // allocate memory for kernel GPT
@@ -67,11 +72,10 @@
     {
         printk("\n[PANIC] in %s : cannot allocate kernel GPT in cluster %x\n",
-        __FUNCTION__ , cxy );
+        __FUNCTION__ , local_cxy );
         hal_core_sleep();
     }
 
 #if DEBUG_HAL_VMM
-thread_t * this = CURRENT_THREAD;
-printk("\n[%s] thread[%x,%x] enter in cluster %x / gpt %x\n", 
+printk("\n[%s] thread[%x,%x] created GPT PT1 in cluster %x / gpt %x\n", 
 __FUNCTION__, this->process->pid, this->trdid, local_cxy, gpt );
 #endif
@@ -79,12 +83,12 @@
     // compute attr and ppn for one PTE1
     uint32_t attr = GPT_MAPPED | GPT_READABLE | GPT_CACHABLE | GPT_EXECUTABLE | GPT_GLOBAL;
-    uint32_t ppn  = cxy << 20;    
+    uint32_t ppn  = local_cxy << 20;    
 
     // set PT1[0]
-    hal_gpt_set_pte( XPTR( cxy , gpt ) , 0 , attr , ppn );
-
-#if DEBUG_HAL_VMM
-printk("\n[%s] thread[%x,%x] created PT1[0] : ppn %x / attr %x\n", 
-__FUNCTION__, this->process->pid, this->trdid, ppn, attr );
+    hal_gpt_set_pte( XPTR( local_cxy , gpt ) , 0 , attr , ppn );
+
+#if DEBUG_HAL_VMM
+printk("\n[%s] thread[%x,%x] mapped PT1[0] in cluster %d : ppn %x / attr %x\n", 
+__FUNCTION__, this->process->pid, this->trdid, local_cxy, ppn, attr );
 #endif
 
@@ -94,17 +98,17 @@
                                      info->kcode_base,
                                      info->kcode_size,
-                                     0, 0,                  // file ofset and file size (unused)
-                                     XPTR_NULL,             // no mapper
+                                     0, 0,               // file ofset and file size (unused)
+                                     XPTR_NULL,          // no mapper
                                      local_cxy );
     if( vseg == NULL )
     {
         printk("\n[PANIC] in %s : cannot register vseg to VSL in cluster %x\n",
-        __FUNCTION__ , cxy );
+        __FUNCTION__ , local_cxy );
         hal_core_sleep();
     }
 
 #if DEBUG_HAL_VMM
-printk("\n[%s] thread[%x,%x] registered kcode vseg[%x,%x]\n",
-__FUNCTION__, this->process->pid, this->trdid, info->kcode_base, info->kcode_size );
+printk("\n[%s] thread[%x,%x] registered kcode vseg[%x,%x] in cluster %x\n",
+__FUNCTION__, this->process->pid, this->trdid, info->kcode_base, info->kcode_size, local_cxy );
 hal_vmm_display( &process_zero , true );
 #endif
@@ -194,9 +198,13 @@
 
 //////////////////////////////////////////
-void hal_vmm_display( process_t * process,
-                      bool_t      mapping )
+void hal_vmm_display( xptr_t   process_xp,
+                      bool_t   mapping )
 {
-    // get pointer on process VMM
-    vmm_t * vmm = &process->vmm;
+    // get target process cluster and local pointer
+    process_t * process_ptr = GET_PTR( process_xp );
+    cxy_t       process_cxy = GET_CXY( process_xp );
+
+    // get local pointer on target process VMM
+    vmm_t * vmm = &process_ptr->vmm;
 
     // get pointers on TXT0 chdev
@@ -205,19 +213,23 @@
     chdev_t * txt0_ptr = GET_PTR( txt0_xp );
 
-    // build extended pointer on TXT0 lock and VSL lock
+    // build extended pointer on TXT0 lock
     xptr_t  txt_lock_xp = XPTR( txt0_cxy  , &txt0_ptr->wait_lock );
-    xptr_t  vsl_lock_xp = XPTR( local_cxy , &vmm->vsl_lock );
-
-    // get root of vsegs list
-    xptr_t root_xp = XPTR( local_cxy , &vmm->vsegs_root );
-
-    // get the locks protecting TXT0, VSL, and GPT
+
+    // build extended pointers on VSL lock and VSL root
+    xptr_t vsl_root_xp = XPTR( process_cxy , &vmm->vsegs_root );
+    xptr_t vsl_lock_xp = XPTR( process_cxy , &vmm->vsl_lock );
+
+    // get the locks protecting TXT0 and VSL
     remote_rwlock_rd_acquire( vsl_lock_xp );
     remote_busylock_acquire( txt_lock_xp );
 
-    nolock_printk("\n***** VSL and GPT for process %x in cluster %x / PT1 = %x\n",
-    process->pid , local_cxy , vmm->gpt.ptr );
-
-    if( xlist_is_empty( root_xp ) )
+    // get PID and PT1 values
+    pid_t      pid = hal_remote_l32( XPTR( process_cxy , &process_ptr->pid ) );
+    uint32_t * pt1 = hal_remote_lpt( XPTR( process_cxy , &vmm->gpt.ptr ) );
+
+    nolock_printk("\n***** VSL and GPT / process %x / cluster %x / PT1 %x / cycle %d\n",
+    pid , process_cxy , pt1 , (uint32_t)hal_get_cycles() );
+
+    if( xlist_is_empty( vsl_root_xp ) )
     {
         nolock_printk("   ... no vsegs registered\n");
@@ -227,18 +239,31 @@
         xptr_t         iter_xp;
         xptr_t         vseg_xp;
-        vseg_t       * vseg;
-
-        XLIST_FOREACH( root_xp , iter_xp )
+        vseg_t       * vseg_ptr;
+        cxy_t          vseg_cxy;
+        intptr_t       min;
+        intptr_t       max;
+        uint32_t       type;
+        intptr_t       vpn_base;
+        intptr_t       vpn_size;
+
+        XLIST_FOREACH( vsl_root_xp , iter_xp )
         {
-            vseg_xp = XLIST_ELEMENT( iter_xp , vseg_t , xlist );
-            vseg    = GET_PTR( vseg_xp );
+            vseg_xp  = XLIST_ELEMENT( iter_xp , vseg_t , xlist );
+            vseg_ptr = GET_PTR( vseg_xp );
+            vseg_cxy = GET_CXY( vseg_xp );
+
+            type     =           hal_remote_l32( XPTR( vseg_cxy , &vseg_ptr->type ) );
+            min      = (intptr_t)hal_remote_lpt( XPTR( vseg_cxy , &vseg_ptr->min ) );
+            max      = (intptr_t)hal_remote_lpt( XPTR( vseg_cxy , &vseg_ptr->max ) );
+            vpn_size = (intptr_t)hal_remote_lpt( XPTR( vseg_cxy , &vseg_ptr->vpn_size ) );
+            vpn_base = (intptr_t)hal_remote_lpt( XPTR( vseg_cxy , &vseg_ptr->vpn_base ) );
 
             nolock_printk(" - %s : base = %X / size = %X / npages = %d\n",
-            vseg_type_str(vseg->type), vseg->min, vseg->max - vseg->min, vseg->vpn_size );
+            vseg_type_str(type), min, max - min, vpn_size );
 
             if( mapping )  
             {
-                vpn_t    vpn     = vseg->vpn_base;
-                vpn_t    vpn_max = vpn + vseg->vpn_size;
+                vpn_t    vpn     = vpn_base;
+                vpn_t    vpn_max = vpn_base + vpn_size;
                 ppn_t    ppn;
                 uint32_t attr;
@@ -246,5 +271,5 @@
                 while( vpn < vpn_max )   // scan the PTEs
                 {
-                    hal_gpt_get_pte( XPTR( local_cxy , &vmm->gpt ) , vpn , &attr , &ppn );
+                    hal_gpt_get_pte( XPTR( process_cxy , &vmm->gpt ) , vpn , &attr , &ppn );
 
                     if( attr & GPT_MAPPED )
