Index: soft/giet_vm/giet_drivers/xcu_driver.c
===================================================================
--- soft/giet_vm/giet_drivers/xcu_driver.c	(revision 295)
+++ soft/giet_vm/giet_drivers/xcu_driver.c	(revision 320)
@@ -5,5 +5,10 @@
 // Copyright (c) UPMC-LIP6
 ///////////////////////////////////////////////////////////////////////////////////
-
+// This peripheral is replicated in aall clusters containing processors.
+//
+// SEG_XCU_BASE and VSEG_CLUSTER_INCREMENT must be defined in hard_config.h file.
+///////////////////////////////////////////////////////////////////////////////////
+
+#include <hard_config.h>
 #include <giet_config.h>
 #include <xcu_driver.h>
@@ -32,6 +37,14 @@
 #endif
 
-#if !defined( USE_XICU )
-# error: You must define USE_XICU in the hard_config.h file
+#if !defined( USE_XCU )
+# error: You must define USE_XCU in the hard_config.h file
+#endif
+
+#if !defined( SEG_XCU_BASE )
+# error: You must define SEG_XCU_BASE in the hard_config.h file
+#endif
+
+#if !defined( VSEG_CLUSTER_INCREMENT )
+# error: You must define VSEG_CLUSTER_INCREMENT in the hard_config.h file
 #endif
 
@@ -47,5 +60,5 @@
                     unsigned int irq_type ) 
 {
-#if USE_XICU
+#if USE_XCU
     // parameters checking 
     unsigned int x = cluster_xy >> Y_WIDTH;
@@ -55,12 +68,11 @@
     if (channel >= (NB_PROCS_MAX * IRQ_PER_PROCESSOR)) _exit(); 
 
-    volatile unsigned int* xcu_address =
-        (unsigned int *) ((unsigned int)&seg_xcu_base + 
-        (cluster_xy * (unsigned int)&vseg_cluster_increment));
+    unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE +
+                                (cluster_xy * VSEG_CLUSTER_INCREMENT) );
 
     unsigned int func;
-    if      (irq_type == IRQ_TYPE_PTI) func = XICU_MSK_PTI_ENABLE;
-    else if (irq_type == IRQ_TYPE_WTI) func = XICU_MSK_WTI_ENABLE;
-    else if (irq_type == IRQ_TYPE_HWI) func = XICU_MSK_HWI_ENABLE;
+    if      (irq_type == IRQ_TYPE_PTI) func = XCU_MSK_PTI_ENABLE;
+    else if (irq_type == IRQ_TYPE_WTI) func = XCU_MSK_WTI_ENABLE;
+    else if (irq_type == IRQ_TYPE_HWI) func = XCU_MSK_HWI_ENABLE;
     else
     { 
@@ -69,8 +81,8 @@
     }
 
-    xcu_address[XICU_REG(func,channel)] = value;
-
-#else
-    _printf("[GIET ERROR] _xcu_set_mask() should not be used if USE_XICU not set\n");
+    xcu_address[XCU_REG(func,channel)] = value;
+
+#else
+    _printf("[GIET ERROR] _xcu_set_mask() should not be used if USE_XCU not set\n");
     _exit();
 #endif
@@ -90,5 +102,5 @@
                      unsigned int * irq_type )
 {
-#if USE_XICU
+#if USE_XCU
     // parameters checking 
     unsigned int x = cluster_xy >> Y_WIDTH;
@@ -98,9 +110,8 @@
     if (channel >= (NB_PROCS_MAX * IRQ_PER_PROCESSOR)) _exit(); 
 
-    volatile unsigned int* xcu_address =
-        (unsigned int *) ((unsigned int)&seg_xcu_base + 
-        (cluster_xy * (unsigned int)&vseg_cluster_increment));
-
-    unsigned int prio = xcu_address[XICU_REG(XICU_PRIO,channel)];
+    unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE +
+                                (cluster_xy * VSEG_CLUSTER_INCREMENT) );
+
+    unsigned int prio = xcu_address[XCU_REG(XCU_PRIO,channel)];
     unsigned int pti_ok = (prio & 0x00000001);
     unsigned int hwi_ok = (prio & 0x00000002);
@@ -130,5 +141,5 @@
  
 #else
-    _printf("[GIET ERROR] _xcu_get_index should not be used if USE_XICU is not set\n");
+    _printf("[GIET ERROR] _xcu_get_index should not be used if USE_XCU is not set\n");
     _exit();
 #endif
@@ -143,5 +154,5 @@
                     unsigned int wdata )
 { 
-#if USE_XICU
+#if USE_XCU
     // parameters checking 
     unsigned int x = cluster_xy >> Y_WIDTH;
@@ -151,12 +162,11 @@
     if (wti_index >= 32)           _exit(); 
 
-    volatile unsigned int* xcu_address =
-        (unsigned int *) ((unsigned int)&seg_xcu_base + 
-        (cluster_xy * (unsigned int)&vseg_cluster_increment));
-
-    xcu_address[XICU_REG(XICU_WTI_REG,wti_index)] = wdata;
-
-#else
-    _printf("[GIET ERROR] _xcu_send_ipi should not be used if USE_XICU is not set\n");
+    unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE +
+                                (cluster_xy * VSEG_CLUSTER_INCREMENT) );
+
+    xcu_address[XCU_REG(XCU_WTI_REG,wti_index)] = wdata;
+
+#else
+    _printf("[GIET ERROR] _xcu_send_ipi should not be used if USE_XCU is not set\n");
     _exit();
 #endif
@@ -173,5 +183,5 @@
                          unsigned int * value )
 {
-#if USE_XICU
+#if USE_XCU
     // parameters checking 
     unsigned int x = cluster_xy >> Y_WIDTH;
@@ -181,12 +191,11 @@
     if (wti_index >= 32)           _exit(); 
  
-    volatile unsigned int* xcu_address =
-        (unsigned int *) ((unsigned int)&seg_xcu_base + 
-        (cluster_xy * (unsigned int)&vseg_cluster_increment));
-
-    *value = xcu_address[XICU_REG(XICU_WTI_REG, wti_index)]; 
-
-#else
-    _printf("[GIET ERROR] in _xcu_get_wti_value() USE_XICU is not set\n");
+    unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE +
+                                (cluster_xy * VSEG_CLUSTER_INCREMENT) );
+
+    *value = xcu_address[XCU_REG(XCU_WTI_REG, wti_index)]; 
+
+#else
+    _printf("[GIET ERROR] in _xcu_get_wti_value() USE_XCU is not set\n");
     _exit();
 #endif
@@ -203,18 +212,18 @@
                            unsigned int * address )
 {
-#if USE_XICU
+#if USE_XCU
     if (wti_index >= 32)           _exit(); 
  
-    unsigned int xcu_address = (unsigned int)&seg_xcu_base;
-    *address = xcu_address + (XICU_REG(XICU_WTI_REG, wti_index)<<2); 
-
-#else
-    _printf("[GIET ERROR] in _xcu_get_wti_address() USE_XICU is not set\n");
-    _exit();
-#endif
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// This function activates a timer contained in XICU by writing in the
+    unsigned int xcu_address = (unsigned int)SEG_XCU_BASE;
+    *address = xcu_address + (XCU_REG(XCU_WTI_REG, wti_index)<<2); 
+
+#else
+    _printf("[GIET ERROR] in _xcu_get_wti_address() USE_XCU is not set\n");
+    _exit();
+#endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// This function activates a timer contained in XCU by writing in the
 // proper register the period value.
 ////////////////////////////////////////////////////////////////////////////////
@@ -223,5 +232,5 @@
                        unsigned int period )
 {
-#if USE_XICU
+#if USE_XCU
     // parameters checking 
     unsigned int x = cluster_xy >> Y_WIDTH;
@@ -230,18 +239,17 @@
     if (y >= Y_SIZE)             _exit(); 
 
-    volatile unsigned int* xcu_address =
-        (unsigned int *) ((unsigned int)&seg_xcu_base + 
-        (cluster_xy * (unsigned int)&vseg_cluster_increment));
-
-    xcu_address[XICU_REG(XICU_PTI_PER, pti_index)] = period;
-
-#else
-    _printf("[GIET ERROR] in _xcu_timer_start() USE_XICU is not set\n");
-    _exit();
-#endif
-}
-
-//////////////////////////////////////////////////////////////////////////////
-// This function desactivates a timer in XICU component
+    unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE +
+                                (cluster_xy * VSEG_CLUSTER_INCREMENT) );
+
+    xcu_address[XCU_REG(XCU_PTI_PER, pti_index)] = period;
+
+#else
+    _printf("[GIET ERROR] in _xcu_timer_start() USE_XCU is not set\n");
+    _exit();
+#endif
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// This function desactivates a timer in XCU component
 // by writing in the proper register.
 //////////////////////////////////////////////////////////////////////////////
@@ -249,5 +257,5 @@
                       unsigned int pti_index) 
 {
-#if USE_XICU
+#if USE_XCU
     // parameters checking 
     unsigned int x = cluster_xy >> Y_WIDTH;
@@ -256,26 +264,25 @@
     if (y >= Y_SIZE)             _exit(); 
 
-    volatile unsigned int * xcu_address =
-        (unsigned int *) ((unsigned int)&seg_xcu_base + 
-        (cluster_xy * (unsigned int)&vseg_cluster_increment));
-
-    xcu_address[XICU_REG(XICU_PTI_PER, pti_index)] = 0;
-
-#else
-    _printf("[GIET ERROR] in _xcu_timer_stop() USE_XICU is not set\n");
-    _exit();
-#endif
-}
-
-//////////////////////////////////////////////////////////////////////////////
-// This function acknowlegge a timer interrupt in XICU 
-// component by reading in the proper register.
+    unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE +
+                                (cluster_xy * VSEG_CLUSTER_INCREMENT) );
+
+    xcu_address[XCU_REG(XCU_PTI_PER, pti_index)] = 0;
+
+#else
+    _printf("[GIET ERROR] in _xcu_timer_stop() USE_XCU is not set\n");
+    _exit();
+#endif
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// This function acknowlegge a timer interrupt in XCU 
+// component by reading in the proper XCU register.
 // It can be used by both the isr_switch() for a "system" timer, 
 // or by the _isr_timer() for an "user" timer.
 //////////////////////////////////////////////////////////////////////////////
-void _xcu_timer_reset_irq( unsigned int cluster_xy, 
-                           unsigned int pti_index ) 
-{
-#if USE_XICU
+unsigned int _xcu_timer_reset_irq( unsigned int cluster_xy, 
+                                   unsigned int pti_index ) 
+{
+#if USE_XCU
     // parameters checking 
     unsigned int x = cluster_xy >> Y_WIDTH;
@@ -284,13 +291,14 @@
     if (y >= Y_SIZE)             _exit(); 
 
-    volatile unsigned int * xcu_address =
-        (unsigned int *) ((unsigned int)&seg_xcu_base +
-        (cluster_xy * (unsigned int)&vseg_cluster_increment));
-
-    xcu_address[XICU_REG(XICU_PTI_ACK, pti_index)];
-
-#else
-    _printf("[GIET ERROR] in _xcu_timer_reset_irq() USE_XICU is not set\n");
-    _exit();
+    unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE +
+                                (cluster_xy * VSEG_CLUSTER_INCREMENT) );
+
+    // This return value is not used / avoid a compilation warning.
+    return xcu_address[XCU_REG(XCU_PTI_ACK, pti_index)];
+
+#else
+    _printf("[GIET ERROR] in _xcu_timer_reset_irq() USE_XCU is not set\n");
+    _exit();
+    return 0;
 #endif
 }
@@ -307,5 +315,5 @@
                            unsigned int pti_index ) 
 {
-#if USE_XICU
+#if USE_XCU
     // parameters checking 
     unsigned int x = cluster_xy >> Y_WIDTH;
@@ -314,17 +322,16 @@
     if (y >= Y_SIZE)             _exit(); 
 
-    volatile unsigned int * xcu_address =
-        (unsigned int *) ((unsigned int) &seg_xcu_base + 
-        (cluster_xy * (unsigned int)&vseg_cluster_increment));
-
-    unsigned int period = xcu_address[XICU_REG(XICU_PTI_PER, pti_index)];
+    unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE +
+                                (cluster_xy * VSEG_CLUSTER_INCREMENT) );
+
+    unsigned int period = xcu_address[XCU_REG(XCU_PTI_PER, pti_index)];
 
     // we write 0 first because if the timer is currently running, 
     // the corresponding timer counter is not reset
-    xcu_address[XICU_REG(XICU_PTI_PER, pti_index)] = 0;
-    xcu_address[XICU_REG(XICU_PTI_PER, pti_index)] = period;
-
-#else
-    _printf("[GIET ERROR] in _xcu_timer_reset_cpt() USE_XICU is not set\n");
+    xcu_address[XCU_REG(XCU_PTI_PER, pti_index)] = 0;
+    xcu_address[XCU_REG(XCU_PTI_PER, pti_index)] = period;
+
+#else
+    _printf("[GIET ERROR] in _xcu_timer_reset_cpt() USE_XCU is not set\n");
     _exit();
 #endif
