Index: trunk/hal/tsar_mips32/drivers/soclib_tty.c
===================================================================
--- trunk/hal/tsar_mips32/drivers/soclib_tty.c	(revision 492)
+++ trunk/hal/tsar_mips32/drivers/soclib_tty.c	(revision 570)
@@ -6,5 +6,5 @@
  * Copyright (c)  UPMC Sorbonne Universites
  *
- * This file is part of ALMOS-MKH..
+ * This file is part of ALMOS-MKH.
  *
  * ALMOS-MKH. is free software; you can redistribute it and/or modify it
@@ -12,5 +12,5 @@
  * the Free Software Foundation; version 2.0 of the License.
  *
- * ALMOS-MKH. is distributed in the hope that it will be useful, but
+ * ALMOS-MKH is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
@@ -18,5 +18,5 @@
  *
  * 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
  */
@@ -27,5 +27,4 @@
 #include <chdev.h>
 #include <soclib_tty.h>
-#include <remote_spinlock.h>
 #include <thread.h>
 #include <printk.h>
@@ -50,4 +49,11 @@
 ////////////////////////////////////////////////////////////////////////////////////
 // These global variables implement the TTY_RX  FIFOs (one per channel)
+////////////////////////////////////////////////////////////////////////////////////
+// Implementation note:
+// We allocate - in each cluster - two arrays of FIFOs containing as many entries
+// as the total number of TXT channels, but all entries are not used in all
+// clusters: for a given cluster K, a given entry corresponding to a given channel
+// and a given direction is only used if the associated chdev is in cluster K.
+// With this policy, the driver can ignore the actual placement of chdevs.
 ////////////////////////////////////////////////////////////////////////////////////
 
@@ -79,9 +85,9 @@
     // set TTY_RX_IRQ_ENABLE 
     reg_xp = XPTR( tty_cxy , tty_ptr + (channel * TTY_SPAN) + TTY_RX_IRQ_ENABLE );
-    hal_remote_sw( reg_xp , 1 );
+    hal_remote_s32( reg_xp , 1 );
 
     // reset TTY_TX_IRQ_ENABLE
     reg_xp = XPTR( tty_cxy , tty_ptr + (channel * TTY_SPAN) + TTY_TX_IRQ_ENABLE );
-    hal_remote_sw( reg_xp , 0 );
+    hal_remote_s32( reg_xp , 0 );
 
     // reset relevant FIFO
@@ -112,7 +118,7 @@
 
     // get command arguments
-    uint32_t type     = hal_remote_lw ( XPTR( th_cxy , &th_ptr->txt_cmd.type   ) );
-    xptr_t   buf_xp   = hal_remote_lwd( XPTR( th_cxy , &th_ptr->txt_cmd.buf_xp ) );
-    uint32_t count    = hal_remote_lw ( XPTR( th_cxy , &th_ptr->txt_cmd.count  ) );
+    uint32_t type     = hal_remote_l32 ( XPTR( th_cxy , &th_ptr->txt_cmd.type   ) );
+    xptr_t   buf_xp   = hal_remote_l64( XPTR( th_cxy , &th_ptr->txt_cmd.buf_xp ) );
+    uint32_t count    = hal_remote_l32 ( XPTR( th_cxy , &th_ptr->txt_cmd.count  ) );
     xptr_t   error_xp = XPTR( th_cxy , &th_ptr->txt_cmd.error );
 
@@ -126,15 +132,15 @@
 
     // get TXT device cluster and pointers
-    xptr_t     dev_xp = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr->txt_cmd.dev_xp ) );
+    xptr_t     dev_xp = (xptr_t)hal_remote_l64( XPTR( th_cxy , &th_ptr->txt_cmd.dev_xp ) );
     cxy_t      dev_cxy = GET_CXY( dev_xp );
     chdev_t  * dev_ptr = GET_PTR( dev_xp );
 
     // get cluster and pointers for SOCLIB_TTY peripheral base segment
-    xptr_t     tty_xp = (xptr_t)hal_remote_lwd( XPTR( dev_cxy , &dev_ptr->base ) );
+    xptr_t     tty_xp = (xptr_t)hal_remote_l64( XPTR( dev_cxy , &dev_ptr->base ) );
     cxy_t      tty_cxy = GET_CXY( tty_xp );
     uint32_t * tty_ptr = GET_PTR( tty_xp );
 
     // get TTY channel index and channel base address
-    uint32_t   channel = hal_remote_lw( XPTR( dev_cxy , &dev_ptr->channel ) );
+    uint32_t   channel = hal_remote_l32( XPTR( dev_cxy , &dev_ptr->channel ) );
     uint32_t * base    = tty_ptr + TTY_SPAN * channel;
 
@@ -173,5 +179,5 @@
 
                 // enable TX_IRQ 
-                hal_remote_sw( XPTR( tty_cxy , base + TTY_TX_IRQ_ENABLE ) , 1 );
+                hal_remote_s32( XPTR( tty_cxy , base + TTY_TX_IRQ_ENABLE ) , 1 );
             }
             else                                // block & deschedule if TX_FIFO full
@@ -186,5 +192,5 @@
 
         // set error status in command and return
-        hal_remote_sw( error_xp , 0 );
+        hal_remote_s32( error_xp , 0 );
     }
     ///////////////////////////
@@ -229,5 +235,5 @@
 
         // set error status in command
-        hal_remote_sw( error_xp , 0 );
+        hal_remote_s32( error_xp , 0 );
     }
     else
@@ -268,5 +274,4 @@
     cxy_t        parent_cxy;        // parent process cluster
     process_t  * parent_ptr;        // local pointer on parent process
-    xptr_t       children_lock_xp;  // extended pointer on children processes lock
     thread_t   * parent_main_ptr;   // extended pointer on parent process main thread
     xptr_t       parent_main_xp;    // local pointer on parent process main thread
@@ -312,5 +317,5 @@
 
         // try to move bytes until TTY_READ register empty
-        while( hal_remote_lw( status_xp ) & TTY_STATUS_RX_FULL )   
+        while( hal_remote_l32( status_xp ) & TTY_STATUS_RX_FULL )   
         {
             // get one byte from TTY_READ register & acknowledge RX_IRQ
@@ -335,5 +340,5 @@
                 owner_cxy = GET_CXY( owner_xp );
                 owner_ptr = GET_PTR( owner_xp );
-                owner_pid = hal_remote_lw( XPTR( owner_cxy , &owner_ptr->pid ) );
+                owner_pid = hal_remote_l32( XPTR( owner_cxy , &owner_ptr->pid ) );
 
                 // block TXT owner process only if it is not the INIT process 
@@ -341,10 +346,7 @@
                 {
                     // get parent process descriptor pointers
-                    parent_xp  = hal_remote_lwd( XPTR( owner_cxy , &owner_ptr->parent_xp ) );
+                    parent_xp  = hal_remote_l64( XPTR( owner_cxy , &owner_ptr->parent_xp ) );
                     parent_cxy = GET_CXY( parent_xp );
                     parent_ptr = GET_PTR( parent_xp );
-
-                    // get extended pointer on lock protecting children list in parent process
-                    children_lock_xp = XPTR( parent_cxy , &parent_ptr->children_lock ); 
 
                     // get pointers on the parent process main thread
@@ -366,8 +368,6 @@
                                           PROCESS_TERM_STOP );
 
-                    // take the children lock and unblock the parent process main thread 
-                    remote_spinlock_lock( children_lock_xp );
+                    // unblock the parent process main thread 
                     thread_unblock( parent_main_xp , THREAD_BLOCKED_WAIT );
-                    remote_spinlock_unlock( children_lock_xp );
 
                     return;
@@ -393,5 +393,5 @@
                 owner_cxy = GET_CXY( owner_xp );
                 owner_ptr = GET_PTR( owner_xp );
-                owner_pid = hal_remote_lw( XPTR( owner_cxy , &owner_ptr->pid ) );
+                owner_pid = hal_remote_l32( XPTR( owner_cxy , &owner_ptr->pid ) );
 
                 // kill TXT owner process only if it is not the INIT process
@@ -399,10 +399,7 @@
                 {
                     // get parent process descriptor pointers
-                    parent_xp  = hal_remote_lwd( XPTR( owner_cxy , &owner_ptr->parent_xp ) );
+                    parent_xp  = hal_remote_l64( XPTR( owner_cxy , &owner_ptr->parent_xp ) );
                     parent_cxy = GET_CXY( parent_xp );
                     parent_ptr = GET_PTR( parent_xp );
-
-                    // get extended pointer on lock protecting children list in parent process
-                    children_lock_xp = XPTR( parent_cxy , &parent_ptr->children_lock ); 
 
                     // get pointers on the parent process main thread
@@ -424,8 +421,6 @@
                                           PROCESS_TERM_KILL );
 
-                    // take the children lock and unblock the parent process main thread 
-                    remote_spinlock_lock( children_lock_xp );
+                    // unblock the parent process main thread 
                     thread_unblock( parent_main_xp , THREAD_BLOCKED_WAIT );
-                    remote_spinlock_unlock( children_lock_xp );
 
                     return;
@@ -479,5 +474,5 @@
         {
             // write one byte to TTY_WRITE register if empty / exit loop if full
-            if( (hal_remote_lw( status_xp ) & TTY_STATUS_TX_FULL) == 0 ) 
+            if( (hal_remote_l32( status_xp ) & TTY_STATUS_TX_FULL) == 0 ) 
             {
                 // get one byte from TX_FIFO
@@ -499,5 +494,5 @@
 
         // disable TX_IRQ 
-        hal_remote_sw( XPTR( tty_cxy , base + TTY_TX_IRQ_ENABLE ) , 0 );
+        hal_remote_s32( XPTR( tty_cxy , base + TTY_TX_IRQ_ENABLE ) , 0 );
 
         // unblock TXT_TX server thread
@@ -531,18 +526,18 @@
     uint32_t   i;
 
-    xptr_t     dev_xp = ((txt_sync_args_t *)args)->dev_xp;
-    char     * buffer = ((txt_sync_args_t *)args)->buffer;
-    uint32_t   count  = ((txt_sync_args_t *)args)->count;
+    xptr_t       dev_xp = ((txt_sync_args_t *)args)->dev_xp;
+    const char * buffer = ((txt_sync_args_t *)args)->buffer;
+    uint32_t     count  = ((txt_sync_args_t *)args)->count;
     
-    // get TXT0 chdev cluster and local pointer
+    // get chdev cluster and local pointer
     cxy_t     dev_cxy = GET_CXY( dev_xp );
-    chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );
+    chdev_t * dev_ptr = GET_PTR( dev_xp );
 
     // get extended pointer on TTY channel base address
-    xptr_t tty_xp = (xptr_t)hal_remote_lwd( XPTR( dev_cxy , &dev_ptr->base ) );
+    xptr_t tty_xp = (xptr_t)hal_remote_l64( XPTR( dev_cxy , &dev_ptr->base ) );
 
     // get TTY channel segment cluster and local pointer
     cxy_t      tty_cxy = GET_CXY( tty_xp );
-    uint32_t * tty_ptr = (uint32_t *)GET_PTR( tty_xp );
+    uint32_t * tty_ptr = GET_PTR( tty_xp );
 
     // get extended pointers on TTY_WRITE & TTY_STATUS registers
@@ -550,11 +545,12 @@
     xptr_t status_xp = XPTR( tty_cxy , tty_ptr + TTY_STATUS );
 
-    // loop on characters (busy waiting policy)
+    // loop on characters 
     for( i = 0 ; i < count ; i++ )
     {
+        // busy waiting policy on TTY_STATUS register
         do
         {
             // get TTY_STATUS
-            status = hal_remote_lw( status_xp );
+            status = hal_remote_l32( status_xp );
             empty  = ( (status & TTY_STATUS_TX_FULL) == 0 );
 
