Index: soft/giet_vm/giet_drivers/xcu_driver.c
===================================================================
--- soft/giet_vm/giet_drivers/xcu_driver.c	(revision 258)
+++ soft/giet_vm/giet_drivers/xcu_driver.c	(revision 263)
@@ -16,5 +16,5 @@
 // The virtual base address of the segment associated to the component is:
 //
-//      seg_xcu_base + cluster_id * vseg_cluster_increment
+//      seg_xcu_base + cluster_xy * vseg_cluster_increment
 //
 // The seg_xcu_base and vseg_cluster_increment values must be defined 
@@ -24,20 +24,26 @@
 #include <giet_config.h>
 #include <xcu_driver.h>
+#include <tty_driver.h>
+#include <mapping_info.h>
 #include <utils.h>
 
-#if !defined(NB_CLUSTERS) 
-# error: You must define NB_CLUSTERS in the hard_config.h file
-#endif
-
-#if (NB_CLUSTERS > 256)
-# error: NB_CLUSTERS cannot be larger than 256!
+#if !defined(X_SIZE) 
+# error: You must define X_SIZE in the hard_config.h file
+#endif
+
+#if !defined(Y_SIZE) 
+# error: You must define X_SIZE in the hard_config.h file
+#endif
+
+#if !defined(X_WIDTH) 
+# error: You must define X_WIDTH in the hard_config.h file
+#endif
+
+#if !defined(Y_WIDTH) 
+# error: You must define X_WIDTH in the hard_config.h file
 #endif
 
 #if !defined(NB_PROCS_MAX) 
 # error: You must define NB_PROCS_MAX in the hard_config.h file
-#endif
-
-#if (NB_PROCS_MAX > 8)
-# error: NB_PROCS_MAX cannot be larger than 8!
 #endif
 
@@ -53,19 +59,24 @@
 // Returns 0 if success, > 0 if error.
 ////////////////////////////////////////////////////////////////////////////////
-unsigned int _xcu_set_mask( unsigned int cluster_id, unsigned int proc_id,
+unsigned int _xcu_set_mask( unsigned int cluster_xy, 
+                            unsigned int proc_id,
                             unsigned int value,
-                            unsigned int is_PTI) 
-{
-    // parameters checking 
-    if (cluster_id >= NB_CLUSTERS) return 1; 
-    if (proc_id >= NB_PROCS_MAX)   return 1; 
+                            unsigned int irq_type ) 
+{
+    // parameters checking 
+    unsigned int x = cluster_xy >> Y_WIDTH;
+    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
+    if (x >= X_SIZE)             return 1; 
+    if (y >= Y_SIZE)             return 1; 
+    if (proc_id >= NB_PROCS_MAX) return 1; 
 
 #if USE_XICU
     unsigned int* xcu_address = (unsigned int *) ((unsigned int)&seg_xcu_base + 
-                                (cluster_id * (unsigned int)&vseg_cluster_increment));
-    if (is_PTI) 
-        xcu_address[XICU_REG(XICU_MSK_PTI_ENABLE, proc_id)] = value;
-    else 
-        xcu_address[XICU_REG(XICU_MSK_HWI_ENABLE, proc_id)] = value;
+                                (cluster_xy * (unsigned int)&vseg_cluster_increment));
+    unsigned int func;
+    if      (irq_type == IRQ_TYPE_PTI) func = XICU_MSK_PTI_ENABLE;
+    else if (irq_type == IRQ_TYPE_SWI) func = XICU_MSK_WTI_ENABLE;
+    else                               func = XICU_MSK_HWI_ENABLE;
+    xcu_address[XICU_REG(func,proc_id)] = value;
     return 0;
 #else
@@ -86,15 +97,18 @@
 // Returns 0 if success, > 0 if error.
 ////////////////////////////////////////////////////////////////////////////////
-unsigned int _xcu_get_index( unsigned int cluster_id, 
+unsigned int _xcu_get_index( unsigned int cluster_xy, 
                              unsigned int proc_id, 
                              unsigned int * buffer) 
 {
     // parameters checking 
-    if (cluster_id >= NB_CLUSTERS)  return 1;
-    if (proc_id >= NB_PROCS_MAX)    return 1;
+    unsigned int x = cluster_xy >> Y_WIDTH;
+    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
+    if (x >= X_SIZE)             return 1; 
+    if (y >= Y_SIZE)             return 1; 
+    if (proc_id >= NB_PROCS_MAX) return 1; 
 
 #if USE_XICU
     unsigned int* xcu_address = (unsigned int *) ((unsigned int)&seg_xcu_base + 
-                                (cluster_id * (unsigned int)&vseg_cluster_increment));
+                                (cluster_xy * (unsigned int)&vseg_cluster_increment));
 
     unsigned int prio = xcu_address[XICU_REG(XICU_PRIO, proc_id)];
@@ -125,15 +139,18 @@
 // Returns 0 if success, > 0 if error.
 ////////////////////////////////////////////////////////////////////////////////
-unsigned int _xcu_send_ipi( unsigned int cluster_id,
+unsigned int _xcu_send_ipi( unsigned int cluster_xy,
                             unsigned int proc_id,
                             unsigned int wdata )
 { 
     // parameters checking 
-    if (cluster_id >= NB_CLUSTERS)  return 1;
-    if (proc_id >= NB_PROCS_MAX)    return 1;
+    unsigned int x = cluster_xy >> Y_WIDTH;
+    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
+    if (x >= X_SIZE)             return 1; 
+    if (y >= Y_SIZE)             return 1; 
+    if (proc_id >= NB_PROCS_MAX) return 1; 
 
 #if USE_XICU
     unsigned int* xcu_address = (unsigned int *) ((unsigned int)&seg_xcu_base + 
-                                 (cluster_id * (unsigned int)&vseg_cluster_increment));
+                                 (cluster_xy * (unsigned int)&vseg_cluster_increment));
     xcu_address[XICU_REG(XICU_WTI_REG, proc_id)] = wdata;
     return 0; 
@@ -152,16 +169,19 @@
 // Returns 0 if success, > 0 if error.
 ////////////////////////////////////////////////////////////////////////////////
-unsigned int _xcu_timer_start( unsigned int cluster_id,
-                               unsigned int local_id,
+unsigned int _xcu_timer_start( unsigned int cluster_xy,
+                               unsigned int proc_id,
                                unsigned int period )
 {
     // parameters checking 
-    if (cluster_id >= NB_CLUSTERS)    return 1;
-    if (local_id >= NB_TIM_CHANNELS)  return 1;
+    unsigned int x = cluster_xy >> Y_WIDTH;
+    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
+    if (x >= X_SIZE)             return 1; 
+    if (y >= Y_SIZE)             return 1; 
+    if (proc_id >= NB_PROCS_MAX) return 1; 
 
 #if USE_XICU
     unsigned int* xcu_address = (unsigned int *) ((unsigned int)&seg_xcu_base + 
-                                (cluster_id * (unsigned int)&vseg_cluster_increment));
-    xcu_address[XICU_REG(XICU_PTI_PER, local_id)] = period;
+                                (cluster_xy * (unsigned int)&vseg_cluster_increment));
+    xcu_address[XICU_REG(XICU_PTI_PER, proc_id)] = period;
     return 0;
 #else
@@ -179,15 +199,18 @@
 // Returns 0 if success, > 0 if error.
 //////////////////////////////////////////////////////////////////////////////
-unsigned int _xcu_timer_stop( unsigned int cluster_id, 
-                              unsigned int local_id) 
-{
-    // parameters checking 
-    if (cluster_id >= NB_CLUSTERS)    return 1;
-    if (local_id >= NB_TIM_CHANNELS)  return 1;
+unsigned int _xcu_timer_stop( unsigned int cluster_xy, 
+                              unsigned int proc_id) 
+{
+    // parameters checking 
+    unsigned int x = cluster_xy >> Y_WIDTH;
+    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
+    if (x >= X_SIZE)             return 1; 
+    if (y >= Y_SIZE)             return 1; 
+    if (proc_id >= NB_PROCS_MAX) return 1; 
 
 #if USE_XICU
     unsigned int * xcu_address = (unsigned int *) ((unsigned int)&seg_xcu_base + 
-                                 (cluster_id * (unsigned int)&vseg_cluster_increment));
-    xcu_address[XICU_REG(XICU_PTI_PER, local_id)] = 0;
+                                 (cluster_xy * (unsigned int)&vseg_cluster_increment));
+    xcu_address[XICU_REG(XICU_PTI_PER, proc_id)] = 0;
     return 0;
 #else
@@ -207,16 +230,19 @@
 // Returns 0 if success, > 0 if error.
 //////////////////////////////////////////////////////////////////////////////
-unsigned int _xcu_timer_reset_irq( unsigned int cluster_id, 
-                                   unsigned int local_id ) 
-{
-    // parameters checking 
-    if (cluster_id >= NB_CLUSTERS)    return 1;
-    if (local_id >= NB_TIM_CHANNELS)  return 1;
+unsigned int _xcu_timer_reset_irq( unsigned int cluster_xy, 
+                                   unsigned int proc_id ) 
+{
+    // parameters checking 
+    unsigned int x = cluster_xy >> Y_WIDTH;
+    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
+    if (x >= X_SIZE)             return 1; 
+    if (y >= Y_SIZE)             return 1; 
+    if (proc_id >= NB_PROCS_MAX) return 1; 
 
 #if USE_XICU
     unsigned int * xcu_address = (unsigned int *) ((unsigned int)&seg_xcu_base +
-                                 (cluster_id * (unsigned int)&vseg_cluster_increment));
-
-    unsigned int bloup = xcu_address[XICU_REG(XICU_PTI_ACK, local_id)];
+                                 (cluster_xy * (unsigned int)&vseg_cluster_increment));
+
+    unsigned int bloup = xcu_address[XICU_REG(XICU_PTI_ACK, proc_id)];
     bloup++; // to avoid a warning 
     return 0;
@@ -238,21 +264,24 @@
 // This function is called during a context switch (user or preemptive)
 /////////////////////////////////////////////////////////////////////////////
-unsigned int _xcu_timer_reset_cpt( unsigned int cluster_id, 
-                                   unsigned int local_id ) 
-{
-    // parameters checking 
-    if (cluster_id >= NB_CLUSTERS)   return 1;
-    if (local_id >= NB_TIM_CHANNELS) return 1;
+unsigned int _xcu_timer_reset_cpt( unsigned int cluster_xy, 
+                                   unsigned int proc_id ) 
+{
+    // parameters checking 
+    unsigned int x = cluster_xy >> Y_WIDTH;
+    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
+    if (x >= X_SIZE)             return 1; 
+    if (y >= Y_SIZE)             return 1; 
+    if (proc_id >= NB_PROCS_MAX) return 1; 
 
 #if USE_XICU
     unsigned int * xcu_address = (unsigned int *) ((unsigned int) &seg_xcu_base + 
-                                 (cluster_id * (unsigned int)&vseg_cluster_increment));
-
-    unsigned int period = xcu_address[XICU_REG(XICU_PTI_PER, local_id)];
+                                 (cluster_xy * (unsigned int)&vseg_cluster_increment));
+
+    unsigned int period = xcu_address[XICU_REG(XICU_PTI_PER, proc_id)];
 
     // 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, local_id)] = 0;
-    xcu_address[XICU_REG(XICU_PTI_PER, local_id)] = period;
+    xcu_address[XICU_REG(XICU_PTI_PER, proc_id)] = 0;
+    xcu_address[XICU_REG(XICU_PTI_PER, proc_id)] = period;
     return 0;
 #else
