Index: soft/giet_vm/giet_kernel/sys_handler.c
===================================================================
--- soft/giet_vm/giet_kernel/sys_handler.c	(revision 494)
+++ soft/giet_vm/giet_kernel/sys_handler.c	(revision 505)
@@ -198,6 +198,4 @@
     // get a new TTY terminal index
     unsigned int channel = _atomic_increment( &_tty_channel_allocator, 1 );
-    unsigned int thread  = _get_context_slot( CTX_TRDID_ID );
-    unsigned int vspace  = _get_context_slot( CTX_VSID_ID );
 
     if ( channel >= NB_TTY_CHANNELS )
@@ -208,6 +206,4 @@
     else
     {
-        _printf("\n[GIET WARNING] TTY channel %d allocated "
-                " to thread %d in vspace %d\n", channel, thread, vspace );
         _set_context_slot( CTX_TTY_ID, channel );
         return 0;
@@ -298,6 +294,4 @@
     // get a new timer index 
     unsigned int channel = _atomic_increment( &_tim_channel_allocator, 1 );
-    unsigned int thread  = _get_context_slot( CTX_TRDID_ID );
-    unsigned int vspace  = _get_context_slot( CTX_VSID_ID );
 
     if ( channel >= NB_TIM_CHANNELS )
@@ -308,6 +302,4 @@
     else
     {
-        _printf("\n[GIET WARNING] TIM channel %d allocated "
-                " to thread %d in vspace %d\n", channel, thread, vspace );
         _set_context_slot( CTX_TIM_ID, channel );
         return 0;
@@ -577,5 +569,5 @@
     // start CMA transfer
     _cma_set_register( cma_channel, CHBUF_BUF_SIZE , NIC_CONTAINER_SIZE );
-    _cma_set_register( cma_channel, CHBUF_PERIOD   , 0 );                   // OUT_OF_ORDER mode
+    _cma_set_register( cma_channel, CHBUF_PERIOD   , 0 );     // OUT_OF_ORDER 
     _cma_set_register( cma_channel, CHBUF_RUN      , 1 );
 
@@ -589,5 +581,5 @@
 
     return 0;
-}  // end sys_nic_start()
+}  // end _sys_nic_start()
 
 
@@ -790,5 +782,5 @@
 
     // desactivates the CMA channel
-    _cma_channel_stop( cma_channel );
+    _cma_set_register( cma_channel, CHBUF_RUN , 0 );
 
     return 0;
@@ -938,6 +930,4 @@
    // get a new CMA channel index 
     unsigned int channel = _atomic_increment( &_cma_channel_allocator, 1 );
-    unsigned int thread  = _get_context_slot( CTX_TRDID_ID );
-    unsigned int vspace  = _get_context_slot( CTX_VSID_ID );
 
     if ( channel >= NB_CMA_CHANNELS )
@@ -948,6 +938,4 @@
     else
     {
-        _printf("\n[GIET WARNING] FBF_CMA channel %d allocated "
-                " to thread %d in vspace %d\n", channel, thread, vspace );
         _set_context_slot( CTX_CMA_FB_ID, channel );
         return 0;
@@ -966,5 +954,4 @@
     unsigned int       flags;           // protection flags
     unsigned int       ppn;             // physical page number
-    unsigned long long chbuf_paddr;     // physical address of source chbuf descriptor
 
     // get channel index
@@ -1039,5 +1026,5 @@
     _fbf_chbuf[channel].length = length;
 
-    // Compute and register physical adress of the chbuf descriptor
+    // Compute and register physical adress of the fbf_chbuf descriptor
     vaddr = (unsigned int)(&_fbf_chbuf[channel]);
     _v2p_translate( (page_table_t*) ptab, 
@@ -1046,13 +1033,10 @@
                     &flags );
  
-    chbuf_paddr = (((paddr_t)ppn) << 12) | (vaddr & 0x00000FFF);
-
-    _fbf_chbuf_paddr[channel] = chbuf_paddr;
-
+    _fbf_chbuf_paddr[channel] = (((paddr_t)ppn) << 12) | (vaddr & 0x00000FFF);
 
     if ( USE_IOB )
     {
-        // SYNC request for channel descriptor
-        _mmc_sync( chbuf_paddr, 32 );
+        // SYNC request for fbf_chbuf descriptor
+        _mmc_sync( _fbf_chbuf_paddr[channel] , sizeof( fbf_chbuf_t ) );
     }
 
@@ -1065,14 +1049,24 @@
         _fbf_chbuf[channel].buf0.desc,
         _fbf_chbuf[channel].buf1.desc,
-        chbuf_paddr );
-#endif
-
-    // call CMA driver to start transfer
-    _cma_channel_start( channel, 
-                        chbuf_paddr,
-                        2,
-                        chbuf_paddr + 128,
-                        1,
-                        length );
+        _fbf_chbuf_paddr[channel] );
+#endif
+
+    // start CMA transfer
+    unsigned long long paddr = _fbf_chbuf_paddr[channel];
+    unsigned int src_chbuf_paddr_lsb = (unsigned int)(paddr & 0xFFFFFFFF);
+    unsigned int src_chbuf_paddr_ext = (unsigned int)(paddr >> 32);
+    unsigned int dst_chbuf_paddr_lsb = src_chbuf_paddr_lsb + 128;
+    unsigned int dst_chbuf_paddr_ext = src_chbuf_paddr_ext;
+
+    _cma_set_register( channel, CHBUF_SRC_DESC , src_chbuf_paddr_lsb );
+    _cma_set_register( channel, CHBUF_SRC_EXT  , src_chbuf_paddr_ext );
+    _cma_set_register( channel, CHBUF_SRC_NBUFS, 2 );
+    _cma_set_register( channel, CHBUF_DST_DESC , dst_chbuf_paddr_lsb );
+    _cma_set_register( channel, CHBUF_DST_EXT  , dst_chbuf_paddr_ext );
+    _cma_set_register( channel, CHBUF_DST_NBUFS, 1 );
+    _cma_set_register( channel, CHBUF_BUF_SIZE , length );
+    _cma_set_register( channel, CHBUF_PERIOD   , 300 );
+    _cma_set_register( channel, CHBUF_RUN      , 1 );
+
     return 0;
 
@@ -1090,6 +1084,5 @@
 #if NB_CMA_CHANNELS > 0
 
-    volatile unsigned int long long user_buffer_desc;
-    volatile unsigned int           full = 1;
+    volatile unsigned int full = 1;
 
     // get channel index
@@ -1098,85 +1091,88 @@
     if ( channel >= NB_CMA_CHANNELS )
     {
-        _printf("\n[GIET ERROR] in _sys_fbf_cma_display() : CMA channel index too large\n");
-        return -1;
-    }
+        _printf("\n[GIET ERROR] in _sys_fbf_cma_display() : "
+                "CMA channel index too large\n");
+        return -1;
+    }
+
+    // get fbf_chbuf descriptor pointer
+    fbf_chbuf_t* pdesc = &_fbf_chbuf[channel];     
 
 #if GIET_DEBUG_FBF_CMA
 _printf("\n[FBF_CMA DEBUG] enters _sys_fb_cma_display()\n"
-        " - channel      = %d\n"
-        " - buffer       = %d\n",
-        channel, buffer_index );
+        " - cma channel     = %d\n"
+        " - buffer index    = %d\n"
+        " - buf0_desc value = %l\n"
+        " - buf1_desc value = %l\n"
+        " - fbf_desc  value = %l\n",
+        channel , buffer_index,
+        _fbf_chbuf[channel].buf0.desc,
+        _fbf_chbuf[channel].buf1.desc,
+        _fbf_chbuf[channel].fbf.desc );
 #endif
 
     if ( buffer_index == 0 )    // user buffer 0
     {
+        // INVAL L1 and L2 cache copies of user buffer descriptor,
+        // because it has been modified in RAM by the CMA component 
+        _dcache_buf_invalidate( (unsigned int)pdesc , sizeof(buffer_descriptor_t) );
+        _mmc_inval( _fbf_chbuf_paddr[channel] , sizeof(buffer_descriptor_t) );
+
         // waiting user buffer released by the CMA component)
         while ( full )
         {  
-            // INVAL L1 and L2 cache copies of user buffer descriptor, because
-            // it has been modified in RAM by the CMA component 
-            _dcache_buf_invalidate( (unsigned int)&_fbf_chbuf[channel].buf0.desc , 8 );
-            _mmc_inval( _fbf_chbuf_paddr[channel] , 8 );
-
-            // get user buffer descriptor
-            user_buffer_desc = _fbf_chbuf[channel].buf0.desc;
-
-            // get user buffer descriptor status
-            full = ( (unsigned int)(user_buffer_desc>>63) );
+            full = (unsigned int)(pdesc->buf0.desc >> 63);
         }
 
         // SYNC request for the user buffer, because 
         // it will be read from XRAM by the CMA component
-        _mmc_sync( user_buffer_desc, _fbf_chbuf[channel].length );
-
-        // set user buffer status, and SYNC request, because this buffer
-        // descriptor will be read from XRAM by the CMA component
-        _fbf_chbuf[channel].buf0.desc = user_buffer_desc | 0x8000000000000000ULL;
-        _mmc_sync( _fbf_chbuf_paddr[channel] , 8 );
-
-        // reset fbf buffer status, and SYNC request, because this buffer
-        // descriptor will be read from XRAM by the CMA component
-        _fbf_chbuf[channel].fbf.desc  = _fbf_chbuf[channel].fbf.desc & 0x7FFFFFFFFFFFFFFFULL;
-        _mmc_sync( _fbf_chbuf_paddr[channel] + 128 , 8 );
+        _mmc_sync( pdesc->buf0.desc , pdesc->length );
+
+        // set user buffer status
+        pdesc->buf0.desc = pdesc->buf0.desc | 0x8000000000000000ULL;
+
+        // reset fbf buffer status
+        pdesc->fbf.desc  = pdesc->fbf.desc  & 0x7FFFFFFFFFFFFFFFULL;
+
+        // SYNC request, because these buffer descriptors
+        // will be read from XRAM by the CMA component
+        _mmc_sync( _fbf_chbuf_paddr[channel] , sizeof(fbf_chbuf_t) );
     }
     else                        // user buffer 1
     {
+        // INVAL L1 and L2 cache copies of user buffer descriptor, 
+        // because it has been modified in RAM by the CMA component 
+        _dcache_buf_invalidate( (unsigned int)pdesc + 64, sizeof(buffer_descriptor_t) );
+        _mmc_inval( _fbf_chbuf_paddr[channel] + 64, sizeof(buffer_descriptor_t) );
+
         // waiting user buffer released by the CMA component)
         while ( full )
         {  
-            // INVAL L1 and L2 cache copies of user buffer descriptor, because
-            // it has been modified in RAM by the CMA component 
-            _dcache_buf_invalidate( (unsigned int)&_fbf_chbuf[channel].buf1.desc , 8 );
-            _mmc_inval( _fbf_chbuf_paddr[channel] + 64 , 8 );
-
-            // get user buffer descriptor
-            user_buffer_desc = _fbf_chbuf[channel].buf1.desc;
-
-            // get user buffer descriptor status
-            full = ( (unsigned int)(user_buffer_desc>>63) );
+            full = (unsigned int)(pdesc->buf1.desc >> 63);
         }
 
         // SYNC request for the user buffer, because 
         // it will be read from XRAM by the CMA component
-        _mmc_sync( user_buffer_desc, _fbf_chbuf[channel].length );
-
-        // set user buffer status, and SYNC request, because this buffer
-        // descriptor will be read from XRAM by the CMA component
-        _fbf_chbuf[channel].buf1.desc = user_buffer_desc | 0x8000000000000000ULL;
-        _mmc_sync( _fbf_chbuf_paddr[channel] , 8 );
-
-        // reset fbf buffer status, and SYNC request, because this buffer
-        // descriptor will be read from XRAM by the CMA component
-        _fbf_chbuf[channel].fbf.desc  = _fbf_chbuf[channel].fbf.desc & 0x7FFFFFFFFFFFFFFFULL;
-        _mmc_sync( _fbf_chbuf_paddr[channel] + 128 , 8 );
+        _mmc_sync( pdesc->buf1.desc , pdesc->length );
+
+        // set user buffer status
+        pdesc->buf1.desc = pdesc->buf1.desc | 0x8000000000000000ULL;
+
+        // reset fbf buffer status
+        pdesc->fbf.desc  = pdesc->fbf.desc  & 0x7FFFFFFFFFFFFFFFULL;
+
+        // SYNC request, because these buffer descriptors
+        // will be read from XRAM by the CMA component
+        _mmc_sync( _fbf_chbuf_paddr[channel] , sizeof(fbf_chbuf_t) );
     }
 
 #if GIET_DEBUG_FBF_CMA
-_printf(" - fbf    desc = %l\n"
-        " - buf0   desc = %l\n"
-        " - buf1   desc = %l\n",
-        _fbf_chbuf[channel].fbf.desc,
+_printf("\n[FBF_CMA DEBUG] exit _sys_fb_cma_display()\n"
+        " - buf0_desc value = %l\n"
+        " - buf1_desc value = %l\n"
+        " - fbf_desc  value = %l\n",
         _fbf_chbuf[channel].buf0.desc,
-        _fbf_chbuf[channel].buf1.desc );
+        _fbf_chbuf[channel].buf1.desc,
+        _fbf_chbuf[channel].fbf.desc );
 #endif
 
@@ -1207,5 +1203,5 @@
 
     // Desactivate CMA channel
-    _cma_channel_stop( channel );
+    _cma_set_register( channel, CHBUF_RUN, 0 );
 
     return 0;
