Index: trunk/hal/tsar_mips32/drivers/soclib_mmc.c
===================================================================
--- trunk/hal/tsar_mips32/drivers/soclib_mmc.c	(revision 654)
+++ trunk/hal/tsar_mips32/drivers/soclib_mmc.c	(revision 657)
@@ -2,5 +2,5 @@
  * soclib_mmc.c - soclib L2 cache driver implementation.
  *
- * Author     Alain Greiner (2016,2017,2018,2019)
+ * Author     Alain Greiner (2016,2017,2018,2019,2020)
  *
  * Copyright (c) UPMC Sorbonne Universites
@@ -18,8 +18,7 @@
  *
  * You should have received a copy of the GNU General Public License
- * along with ALMOS-MKH.; 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_kernel_types.h>
@@ -29,5 +28,4 @@
 #include <thread.h>
 #include <printk.h>
-
 
 ///////////////////////////////////////
@@ -44,5 +42,4 @@
     *(base + (SOCLIB_MMC_ERROR_FUNC << 7) + SOCLIB_MMC_ERROR_IRQ_ENABLE) = 1;
 } 
-
 
 //////////////////////////////////////////////////////////////
@@ -85,25 +82,44 @@
 
         // set SOCLIB_MMC registers to start INVAL/SYNC operation
-        hal_remote_s32( XPTR( seg_cxy , seg_ptr + SOCLIB_MMC_ADDR_LO    ) , (uint32_t)buf_ptr );
-        hal_remote_s32( XPTR( seg_cxy , seg_ptr + SOCLIB_MMC_ADDR_HI    ) , (uint32_t)dev_cxy );
-        hal_remote_s32( XPTR( seg_cxy , seg_ptr + SOCLIB_MMC_BUF_LENGTH ) , buf_size ); 
-        hal_remote_s32( XPTR( seg_cxy , seg_ptr + SOCLIB_MMC_CMD_TYPE   ) , cc_cmd ); 
+        hal_remote_s32( XPTR( seg_cxy , seg_ptr +
+        MMC_REG( SOCLIB_MMC_CC_FUNC , SOCLIB_MMC_ADDR_LO) ) , (uint32_t)buf_ptr );
+
+        hal_remote_s32( XPTR( seg_cxy , seg_ptr +
+        MMC_REG( SOCLIB_MMC_CC_FUNC , SOCLIB_MMC_ADDR_HI) ) , dev_cxy );
+
+        hal_remote_s32( XPTR( seg_cxy , seg_ptr +
+        MMC_REG( SOCLIB_MMC_CC_FUNC , SOCLIB_MMC_BUF_LENGTH) ) , buf_size );
+
+        hal_remote_s32( XPTR( seg_cxy , seg_ptr +
+        MMC_REG( SOCLIB_MMC_CC_FUNC , SOCLIB_MMC_CMD_TYPE) ) , cc_cmd );
     }
-    else  // (type == MMC_GET_ERROR) or (type == MMC_GET_ERROR) pr (type == MMC_GET_INSTRU )
+    else if( (type == MMC_ERROR_GET) || (type == MMC_ERROR_SET) )
     {
         // get src/dst buffer local pointer and register index
         reg_ptr   = (uint32_t *)hal_remote_lpt( XPTR( th_cxy , &th_ptr->mmc_cmd.reg_ptr ) );
-        reg_index = hal_remote_l32( XPTR( th_cxy , &th_ptr->mmc_cmd.reg_index ) );
+        reg_index =             hal_remote_l32( XPTR( th_cxy , &th_ptr->mmc_cmd.reg_index ) );
 
-        // move register to/from local buffer 
-        if( (type == MMC_GET_ERROR) || (type == MMC_GET_INSTRU) )
-        {
-            *reg_ptr =  hal_remote_l32( XPTR( seg_cxy , seg_ptr + reg_index ) );
-        }
-        else  // type == MMC_SET_ERROR
-        {
-            hal_remote_s32( XPTR( seg_cxy , seg_ptr + reg_index ) , *reg_ptr );
-        }
+        // build extended pointer on relevant MMC register
+        xptr_t mmc_reg_xp = XPTR( seg_cxy , seg_ptr +
+                                  MMC_REG( SOCLIB_MMC_ERROR_FUNC , reg_index ) );
+
+        // move MMC register to/from local buffer 
+        if( type == MMC_ERROR_GET ) *reg_ptr = hal_remote_l32( mmc_reg_xp );
+        else                        hal_remote_s32( mmc_reg_xp , *reg_ptr );
     }
+    else  // type == MMC_INSTRU_GET
+    {
+        // get dst buffer local pointer and register index
+        reg_ptr   = (uint32_t *)hal_remote_lpt( XPTR( th_cxy , &th_ptr->mmc_cmd.reg_ptr ) );
+        reg_index =             hal_remote_l32( XPTR( th_cxy , &th_ptr->mmc_cmd.reg_index ) );
+
+        // build extended pointer on relevant MMC register
+        xptr_t mmc_reg_xp = XPTR( seg_cxy , seg_ptr +
+                                  MMC_REG( SOCLIB_MMC_INSTR_FUNC , reg_index ) );
+
+        // move MMC register to local buffer  
+        *reg_ptr = hal_remote_l32( mmc_reg_xp );
+    }
+
 } // end soclib_mmc_cmd()
 
@@ -121,6 +137,6 @@
 
     // print an error message on kernel terminal 
-    printk("\n[ERROR] reported from MMC : cxy %x / cycle %d / bad address [%x,%x] / srcid %x\n",
-    local_cxy , (uint32_t)hal_get_cycles() , paddr_hi , paddr_lo , srcid );
+    printk("\n[ERROR] reported from MMC : bad address [%x,%x] / srcid %x / cycle %d\n",
+    paddr_hi , paddr_lo , srcid , (uint32_t)hal_get_cycles() );
 
     // reset MMC IRQ
@@ -128,5 +144,2 @@
     
 } // end soclib_mmc_isr()
-
-
-
