Index: trunk/hal/tsar_mips32/core/hal_kentry.S
===================================================================
--- trunk/hal/tsar_mips32/core/hal_kentry.S	(revision 438)
+++ trunk/hal/tsar_mips32/core/hal_kentry.S	(revision 625)
@@ -4,5 +4,5 @@
  * AUthors   Ghassan Almaless (2007,2008,2009,2010,2011,2012)
  *           Mohamed Lamine Karaoui (2015)
- *           Alain Greiner (2017)
+ *           Alain Greiner (2016,2017,2018,2019)
  *
  * Copyright (c) UPMC Sorbonne Universites
@@ -87,6 +87,6 @@
 #------------------------------------------------------------------------------------
 # Kernel Entry point for Interrupt / Exception / Syscall
-# The c2_dext and c2_iext CP2 registers must have been previously set
-# to "local_cxy", because the kernel run with MMU desactivated.
+# The c2_dext CP2 register must have been previously set
+# to "local_cxy", because the kernel run with data MMU desactivated.
 #------------------------------------------------------------------------------------
 
@@ -96,5 +96,5 @@
 	andi    $26,    $26,  0x10          # test User Mode bit
 	beq     $26,    $0,	  kernel_mode   # jump if core already in kernel
-	ori     $27,    $0,	  0x3           # $27 <= code for MMU OFF
+	ori     $27,    $0,	  0xB           # $27 <= code data MMU OFF
 	
 #------------------------------------------------------------------------------------
@@ -102,12 +102,12 @@
 # to handle a syscall, an interrupt, or an user exception.
 # - save current c2_mode in $26.
-# - set MMU OFF.
+# - set data MMU OFF.
 # - copy user stack pointer in $27 to be saved in uzone.
-# - set kernel stack pointer in $29 == top_kernel_stack(this).
+# - set kernel stack pointer in $29 (kernel stack empty at firts entry).
 
 user_mode:
 
     mfc2    $26,    $1                  # $26 <= c2_mode
-	mtc2    $27,    $1			        # set MMU OFF
+	mtc2    $27,    $1			        # set data MMU OFF
     move    $27,    $29                 # $27 <= user stack pointer
 	mfc0    $29,    $4,   2             # get pointer on thread descriptor from c0_th
@@ -121,5 +121,5 @@
 # after a syscall, to handle an interrupt, or to handle a non-fatal exception.
 # - save current c2_mode in $26.
-# - set MMU OFF.
+# - set data MMU OFF.
 # - copy current kernel stack pointer in $27.
 
@@ -127,5 +127,5 @@
 
     mfc2    $26,    $1                  # $26 <= c2_mode
-	mtc2    $27,    $1			        # set MMU OFF
+	mtc2    $27,    $1			        # set data MMU OFF
     move    $27,    $29                 # $27 <= current kernel stack pointer
 
@@ -133,5 +133,5 @@
 # This code is executed in both modes (user or kernel):
 # The assumptions are:
-# - c2_mode contains the MMU OFF value.
+# - c2_mode contains the data MMU OFF value.
 # - $26 contains the previous c2_mode value.
 # - $27 contains the previous sp value (can be usp or ksp).
@@ -139,6 +139,6 @@
 # We execute the following actions:
 # - decrement $29 to allocate an uzone in kernel stack
-# - save relevant GPR, CP0 and CP2 registers to uzone.
-# - set the SR in kernel mode: IRQ disabled, clear exl.
+# - save GPR, CP0 and CP2 registers to uzone.
+# - set the SR in kernel mode: IRQ disabled, clear EXL.
 
 unified_mode:
@@ -195,5 +195,5 @@
     sw      $26,    (UZ_MODE*4)($29)    # save previous c2_mode (can be user or kernel)
 
-    mfc0    $3,     $12 
+    mfc0    $3,     $12                 # $3 <= c0_sr
 	srl	    $3,     $3,   5
 	sll     $3,	    $3,   5	            # reset 5 LSB bits
@@ -216,4 +216,14 @@
     nop
     move    $4,     $2
+    jal     putd
+    nop
+    la      $4,     msg_crlf
+    jal     puts
+    nop    
+    # display saved CR value
+    la      $4,     msg_cr
+    jal     puts
+    nop
+    lw	    $4,  	(UZ_CR*4)($29)
     jal     putx
     nop
@@ -286,5 +296,5 @@
     
 #------------------------------------------------------------------------------------
-# This code handle the uzone pointers stack, and calls the relevant 
+# This code handle the two-slots uzone pointers stack, and calls the relevant 
 # Interrupt / Exception / Syscall handler, depending on XCODE in CP0_CR.
 # Both the hal_do_syscall() and the hal_do_exception() functions use
@@ -338,6 +348,6 @@
 # - All registers saved in the uzone are restored, using the pointer on uzone,
 #   that is contained in $29.
-# - The "uzone" field in thread descriptor, that has beeen modified at kernel entry
-#   is restored from value contained in the uzone[UZ_SP] slot. 
+# - The "current_uzone" pointer in thread descriptor, that has beeen modified at
+#   kernel entry is restored from value contained in the uzone[UZ_SP] slot. 
 # -----------------------------------------------------------------------------------
 
@@ -365,4 +375,14 @@
     nop
     move    $4,     $2
+    jal     putd
+    nop
+    la      $4,     msg_crlf
+    jal     puts
+    nop    
+    # display saved CR value
+    la      $4,     msg_cr
+    jal     puts
+    nop
+    lw	    $4,  	(UZ_CR*4)($29)
     jal     putx
     nop
@@ -479,5 +499,5 @@
 
 	lw	    $26,    (UZ_MODE*4)($27)    
-    mtc2    $26,    $1                  # restore CP2_MODE from uzone
+    mtc2    $26,    $1                  # restore c2_mode from uzone
 
 # -----------------------------------------------------------------------------------
@@ -494,4 +514,7 @@
     .section .kdata
 
+msg_cr:
+    .align 2
+    .asciiz "- UZ_CR   = " 
 msg_sp:
     .align 2
