Index: soft/giet_vm/giet_drivers/dma_driver.c
===================================================================
--- soft/giet_vm/giet_drivers/dma_driver.c	(revision 345)
+++ soft/giet_vm/giet_drivers/dma_driver.c	(revision 437)
@@ -5,24 +5,4 @@
 // Copyright (c) UPMC-LIP6
 ///////////////////////////////////////////////////////////////////////////////////
-// The dma_driver.c and dma_driver.h files are part ot the GIET-VM nano-kernel.
-// This driver supports the SoCLib vci_multi_dma component.
-// 
-// It can exist several DMA controlers in the architecture (one per cluster),
-// and each controller can contain several channels.
-// 
-// There is  (NB_CLUSTERS * NB_DMA_CHANNELS) channels, indexed by a global index:
-//        dma_id = cluster_xy * NB_DMA_CHANNELS + loc_id
-//
-// A DMA channel is a private ressource allocated to a given processor.
-// It is exclusively used by the kernet to speedup data transfers, and
-// there is no lock protecting exclusive access to the channel.
-// As the kernel uses a polling policy on the DMA_STATUS register to detect
-// transfer completion, the DMA IRQ is not used.
-//
-// The virtual base address of the segment associated to a channel is:
-//    SEG_DMA_BASE + cluster_xy * PERI_CLUSTER_INCREMENT + DMA_SPAN * channel_id
-//
-// The SEG_DMA_BASE virtual address mus be defined in the hard_config.h file.
-////////////////////////////////////////////////////////////////////////////////////
 
 #include <giet_config.h>
@@ -101,10 +81,5 @@
 }
 
-//////////////////////////////////////////////////////////////////////////////////
-// AS the GIET-VM uses a polling policy to detect transfer completion,
-// The DMA component initialisation must disable interrupts.
-// This function disables interrupts for one DMA channel in one cluster.
-// Returns 0 if success, returns > 0 if error.
-//////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////
 unsigned int _dma_init( unsigned int cluster_xy,
                         unsigned int channel_id )
@@ -127,8 +102,5 @@
 }
 
-//////////////////////////////////////////////////////////////////////////////////
-// This function re-initialises one DMA channel in one cluster after a transfer
-// completion. It actually forces the channel to return in iDLE state.
-//////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////
 unsigned int _dma_reset( unsigned int cluster_xy, 
                          unsigned int channel_id ) 
@@ -151,7 +123,5 @@
 }
 
-//////////////////////////////////////////////////////////////////////////////////
-// This function returns the status of a DMA channel in a given cluster
-//////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////
 unsigned int _dma_get_status( unsigned int cluster_xy, 
                               unsigned int channel_id ) 
@@ -173,9 +143,5 @@
 }
 
-//////////////////////////////////////////////////////////////////////////////////
-// This function sets the physical address (including 64 bits extension)
-// for the source and destination buffers in a DMA channel in a given cluster
-// and sets the transfer size to lauch the transfer.
-//////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////
 void _dma_start_transfer( unsigned int       cluster_xy,  // DMA cluster
                           unsigned int       channel_id,  // DMA channel
@@ -201,15 +167,5 @@
 }
 
-///////////////////////////////////////////////////////////////////////////////////
-// This function copies a source memory buffer to a destination memory buffer,
-// using directly physical addresses.
-// This blocking function is supposed to be used by the kernel only, 
-// and uses a polling policy on DMA_STATUS register to detect completion.
-// Therefore, the DMA_IRQ is NOT used.
-// The source and destination buffers base addresses must be word aligned, 
-// and the buffer's size must be multiple of 4.
-// In case of error (buffer unmapped, unaligned, or DMA_STATUS error), an error 
-// message is displayed on TTY0, and the system crash.
-///////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////
 void _dma_physical_copy( unsigned int       cluster_xy,  // DMA cluster
                          unsigned int       channel_id,  // DMA channel
@@ -225,5 +181,5 @@
     if ( (x >= X_SIZE) || (y >= Y_SIZE) || (channel_id >= NB_DMA_CHANNELS) )
     {
-        _printf("\n[GIET ERROR] in _dma_physical_copy() : illegal DMA channel ");
+        _puts("\n[DMA ERROR] in _dma_physical_copy() : illegal DMA channel ");
         _exit();
     }
@@ -232,14 +188,24 @@
     if ( (dst_paddr & 0x3)   || (src_paddr & 0x3) || (size & 0x3) )
     {
-        _printf("\n[GIET ERROR] in _dma_physical_copy() : buffer unaligned\n");
-        _exit();
-    }
-
-#if GIET_DEBUG_DMA_DRIVER
-_printf("\n[DMA DEBUG] Start a dma_physical_copy on channel[%d,%d,%d] at cycle %d\n"
-        " - src_paddr   = %l\n"
-        " - dst_paddr   = %l\n"
-        " - bytes       = %x\n",
-        x, y, channel_id, _get_proctime(), src_paddr, dst_paddr, size );
+        _puts("\n[DMA ERROR] in _dma_physical_copy() : buffer unaligned\n");
+        _exit();
+    }
+
+#if GIET_DEBUG_DMA_DRIVER
+_puts("\n[DMA DEBUG] enter _dma_physical_copy() for channel[");
+_putd( x );
+_puts(",");
+_putd( y );
+_puts(",");
+_putd( channel_id );
+_puts("] at cycle ");
+_putd( _get_proctime() );
+_puts("\n - src_paddr   = ");
+_putl( src_paddr );
+_puts("\n - dst_paddr   = ");
+_putl( dst_paddr );
+_puts("\n - bytes       = ");
+_putd( size );
+_puts("\n");
 #endif
 
@@ -256,5 +222,5 @@
 
 #if GIET_DEBUG_DMA_DRIVER
-_printf("\n[DMA DEBUG] _dma_physical_copy() : ... waiting on DMA_STATUS register\n");
+_puts("\n[DMA DEBUG] _dma_physical_copy() : ... waiting on DMA_STATUS register\n");
 #endif
 
@@ -264,32 +230,27 @@
     if( status != DMA_SUCCESS )
     {
-        _printf("\n[GIET ERROR] in _dma_physical_copy() : DMA_STATUS = %x\n", status );
-        _exit();
-    }
+        _puts("\n[DMA ERROR] in _dma_physical_copy() : bad DMA_STATUS");
+        _exit();
+    }
+
     // reset dma channel
     _dma_reset( cluster_xy, channel_id );
 
 #if GIET_DEBUG_DMA_DRIVER
-_printf("\n[DMA DEBUG] _dma_physical_copy() completed at cycle %d\n", _get_proctime() );
+_puts("\n[DMA DEBUG] exit _dma_physical_copy() at cycle ");
+_putd( _get_proctime() );
+_puts("\n");
 #endif
 
 #else // NB_DMA_CHANNELS == 0
-    _printf("\n[GIET ERROR] in _dma_physical_copy() : NB_DMA_CHANNELS == 0 / cycle %d\n",
-            _get_proctime );
+
+    _puts("\n[DMA ERROR] in _dma_physical_copy() : NB_DMA_CHANNELS == 0\n");
     _exit();
-#endif
-}
-
-///////////////////////////////////////////////////////////////////////////////////
-// This function copies a source memory buffer to a destination memory buffer,
-// making virtual to physical address translation: the MMU should be activated. 
-// This blocking function is supposed to be used by the kernel only, 
-// and uses a polling policy on DMA_STATUS register to detect completion.
-// Therefore, the DMA_IRQ is NOT used.
-// The source and destination buffers base addresses must be word aligned, 
-// and the buffer's size must be multiple of 4.
-// In case of error (buffer unmapped, unaligned, or DMA_STATUS error), an error 
-// message is displayed on TTY0, and the system crash.
-///////////////////////////////////////////////////////////////////////////////////
+
+#endif
+}
+
+
+////////////////////////////////////////
 void  _dma_copy( unsigned int cluster_xy,    // DMA cluster
                  unsigned int channel_id,    // DMA channel
@@ -306,5 +267,5 @@
     if ( (x >= X_SIZE) || (y >= Y_SIZE) || (channel_id >= NB_DMA_CHANNELS) )
     {
-        _printf("\n[GIET ERROR] in _dma_copy() : illegal DMA channel ");
+        _puts("\n[DMA ERROR] in _dma_copy() : illegal DMA channel ");
         _exit();
     }
@@ -313,5 +274,5 @@
     if ( (dst_vaddr & 0x3)   || (src_vaddr & 0x3) || (size & 0x3) )
     {
-        _printf("\n[GIET ERROR] in _dma_copy() : buffer unaligned\n");
+        _puts("\n[DMA ERROR] in _dma_copy() : buffer unaligned\n");
         _exit();
     }
@@ -322,9 +283,19 @@
 
 #if GIET_DEBUG_DMA_DRIVER
-_printf("\n[DMA DEBUG] Start a dma_copy on channel[%d,%d,%d] at cycle %d\n"
-        " - src_vaddr   = %x\n"
-        " - dst_vaddr   = %x\n"
-        " - bytes       = %x\n",
-        x, y, channel_id, _get_proctime(), src_vaddr, dst_vaddr, size );
+_puts("\n[DMA DEBUG] enter _dma_copy() for channel[");
+_putd( x );
+_puts(",");
+_putd( y );
+_puts(",");
+_putd( channel_id );
+_puts("] at cycle ");
+_putd( _get_proctime() );
+_puts("\n - src_vaddr   = ");
+_putx( src_vaddr );
+_puts("\n - dst_vaddr   = ");
+_putx( dst_vaddr );
+_puts("\n - bytes       = ");
+_putd( size );
+_puts("\n");
 #endif
 
@@ -334,5 +305,5 @@
          (size & 0x3) )
     {
-        _printf("\n[GIET ERROR] in _dma_copy() : buffer unaligned\n");
+        _puts("\n[DMA ERROR] in _dma_copy() : buffer unaligned\n");
         _exit();
     }
@@ -348,5 +319,5 @@
     if ( ko ) 
     {
-        _printf("\n[GIET ERROR] in _dma_copy() : source buffer unmapped\n");
+        _puts("\n[DMA ERROR] in _dma_copy() : source buffer unmapped\n");
         _exit();
     }
@@ -361,5 +332,5 @@
     if ( ko ) 
     {
-        _printf("\n[GIET ERROR] in _dma_copy() : dest buffer unmapped\n");
+        _puts("\n[DMA ERROR] in _dma_copy() : dest buffer unmapped\n");
         _exit();
     }
@@ -368,7 +339,9 @@
 
 #if GIET_DEBUG_DMA_DRIVER
-_printf(" - src_paddr   = %l\n"
-        " - dst_paddr   = %l\n",
-        src_paddr, dst_paddr );
+_puts("\n - src_paddr   = ");
+_putl( src_paddr );
+_puts("\n - dst_paddr   = ");
+_putl( dst_paddr );
+_puts("\n");
 #endif
 
@@ -385,5 +358,5 @@
 
 #if GIET_DEBUG_DMA_DRIVER
-_printf("\n[DMA DEBUG] _dma_copy() : ... waiting on DMA_STATUS register\n");
+_puts("\n[DMA DEBUG] _dma_copy() : ... waiting on DMA_STATUS register\n");
 #endif
 
@@ -393,5 +366,5 @@
     if( status != DMA_SUCCESS )
     {
-        _printf("\n[GIET ERROR] in _dma_copy() : DMA_STATUS = %x\n", status );
+        _puts("\n[DMA ERROR] in _dma_copy() : bad DMA_STATUS\n");
         _exit();
     }
@@ -400,23 +373,23 @@
 
 #if GIET_DEBUG_DMA_DRIVER
-_printf("\n[DMA DEBUG] _dma_copy() completed at cycle %d\n", _get_proctime() );
+_puts("\n[DMA DEBUG] exit _dma_copy() at cycle ");
+_putd( _get_proctime() );
+_puts("\n");
 #endif
 
 #else // NB_DMA_CHANNELS == 0
-    _printf("\n[GIET ERROR] in _dma_copy() : NB_DMA_CHANNELS == 0 / cycle %d\n",
-            _get_proctime );
+
+    _puts("\n[DMA ERROR] in _dma_copy() : NB_DMA_CHANNELS == 0\n");
     _exit();
+
 #endif
 } // end _dma_copy
 
-///////////////////////////////////////////////////////////////////////////////
-// This ISR handles the IRQ generated by a DMA channel.
-///////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////
 void _dma_isr( unsigned int irq_type,
                unsigned int irq_id,
                unsigned int channel )
 {
-    _printf("\n[GIET ERROR] _dma_isr() not implemented / cycle %d\n",
-            _get_proctime() );
+    _puts("\n[DMA ERROR] _dma_isr() not implemented\n");
     _exit();
 }
