Index: trunk/hal/tsar_mips32/drivers/soclib_tty.c
===================================================================
--- trunk/hal/tsar_mips32/drivers/soclib_tty.c	(revision 432)
+++ trunk/hal/tsar_mips32/drivers/soclib_tty.c	(revision 435)
@@ -30,10 +30,18 @@
 #include <hal_special.h>
 
-#if CONFIG_READ_DEBUG
-extern uint32_t  enter_tty_cmd;
-extern uint32_t  exit_tty_cmd;
-
-extern uint32_t  enter_tty_isr;
-extern uint32_t  exit_tty_isr;
+#if (CONFIG_DEBUG_SYS_READ & 1)
+extern uint32_t  enter_tty_cmd_read;
+extern uint32_t  exit_tty_cmd_read;
+
+extern uint32_t  enter_tty_isr_read;
+extern uint32_t  exit_tty_isr_read;
+#endif
+
+#if (CONFIG_DEBUG_SYS_WRITE & 1)
+extern uint32_t  enter_tty_cmd_write;
+extern uint32_t  exit_tty_cmd_write;
+
+extern uint32_t  enter_tty_isr_write;
+extern uint32_t  exit_tty_isr_write;
 #endif
 
@@ -53,9 +61,9 @@
     // get SOCLIB_TTY device cluster and local pointer
     cxy_t      tty_cxy = GET_CXY( tty_xp );
-    uint32_t * tty_ptr = (uint32_t *)GET_PTR( tty_xp );
-
-    // reset TTY_RX_IRQ_ENABLE 
+    uint32_t * tty_ptr = GET_PTR( tty_xp );
+
+    // set TTY_RX_IRQ_ENABLE 
     reg_xp = XPTR( tty_cxy , tty_ptr + (channel * TTY_SPAN) + TTY_RX_IRQ_ENABLE );
-    hal_remote_sw( reg_xp , 0 );
+    hal_remote_sw( reg_xp , 1 );
 
     // reset TTY_TX_IRQ_ENABLE
@@ -68,68 +76,80 @@
 {
 
-#if CONFIG_READ_DEBUG
-enter_tty_cmd = hal_time_stamp();
-#endif
+#if (CONFIG_DEBUG_SYS_READ & 1)
+if( type == TXT_READ) enter_tty_cmd_read = (uint32_t)hal_get_cycles();
+#endif
+
+#if (CONFIG_DEBUG_SYS_WRITE & 1)
+if( type == TXT_WRITE) enter_tty_cmd_write = (uint32_t)hal_get_cycles();
+#endif
+
+    // get client thread cluster and local pointer
+    cxy_t      th_cxy = GET_CXY( th_xp );
+    thread_t * th_ptr = GET_PTR( th_xp );
+
+    // get command type and extended pointer on TXT device
+    uint32_t type = hal_remote_lw ( XPTR( th_cxy , &th_ptr->txt_cmd.type ) );
 
 #if CONFIG_DEBUG_HAL_TXT
 uint32_t cycle = (uint32_t)hal_get_cycles();
 if (CONFIG_DEBUG_HAL_TXT < cycle )
-printk("\n[DBG] %s : thread %x enter / cycle %d\n",
-__FUNCTION__ , CURRENT_THREAD , cycle );
-#endif
-
-    // get client thread cluster and local pointer
-    cxy_t      th_cxy = GET_CXY( th_xp );
-    thread_t * th_ptr = (thread_t *)GET_PTR( th_xp );
-
-    // get command type and extended pointer on TXT device
-    uint32_t type   =         hal_remote_lw ( XPTR( th_cxy , &th_ptr->txt_cmd.type ) );
-    xptr_t   dev_xp = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr->txt_cmd.dev_xp ) );
-
-    assert( (type == TXT_READ) || (type == TXT_WRITE) , __FUNCTION__, "illegal command type");
-
-    // get TXT device cluster and local pointer
-    cxy_t     dev_cxy = GET_CXY( dev_xp );
-    chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );
-
-    // get extended pointer on SOCLIB_TTY base segment
-    xptr_t tty_xp = (xptr_t)hal_remote_lwd( XPTR( dev_cxy , &dev_ptr->base ) );
-
-    // get SOCLIB_TTY base segment cluster and local pointer
-    cxy_t      tty_cxy = GET_CXY( tty_xp );
-    uint32_t * tty_ptr = (uint32_t *)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 * base    = tty_ptr + TTY_SPAN * channel;
-
-    // compute extended pointer on relevant TTY register
-    xptr_t reg_xp; 
-    if( type == TXT_READ )  reg_xp = XPTR( tty_cxy , base + TTY_RX_IRQ_ENABLE );
-    else                    reg_xp = XPTR( tty_cxy , base + TTY_TX_IRQ_ENABLE );
-
-    // enable relevant IRQ : data transfer will be done by the TTY_RX ISR)
-    hal_remote_sw( reg_xp , 1 );
+printk("\n[DBG] %s : thread %x enter for %s / cycle %d\n",
+__FUNCTION__ , CURRENT_THREAD , dev_txt_type_str(type) , cycle );
+#endif
+
+    if( type == TXT_WRITE )         // block, enable TX_IRQ, and dechedule for a WRITE
+    {
+        xptr_t dev_xp = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr->txt_cmd.dev_xp ) );
+
+        // get TXT device cluster and local pointer
+        cxy_t     dev_cxy = GET_CXY( dev_xp );
+        chdev_t * dev_ptr = GET_PTR( dev_xp );
+
+        // get extended pointer on SOCLIB_TTY base segment
+        xptr_t tty_xp = (xptr_t)hal_remote_lwd( XPTR( dev_cxy , &dev_ptr->base ) );
+
+        // get SOCLIB_TTY base segment cluster and local pointer
+        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 * base    = tty_ptr + TTY_SPAN * channel;
+
+        // block server thread 
+        thread_block( CURRENT_THREAD , THREAD_BLOCKED_DEV_ISR );
+
+        // enable relevant TX_IRQ for a WRITE
+        hal_remote_sw( XPTR( tty_cxy , base + TTY_TX_IRQ_ENABLE ) , 1 );
+
+        // deschedule
+        sched_yield( "waiting TXT_TX_ISR completion" );
+    }
+    else if( type == TXT_READ )        // block, and deschedule for a READ
+    {
+        // block server thread
+        thread_block( CURRENT_THREAD , THREAD_BLOCKED_DEV_ISR );
+
+        // deschedule
+        sched_yield( "waiting TXT_RX_ISR completion" );
+    }
+    else
+    {
+        assert( false , __FUNCTION__ , "illegal TXT command\n" );
+    }
 
 #if CONFIG_DEBUG_HAL_TXT
 cycle = (uint32_t)hal_get_cycles();
 if (CONFIG_DEBUG_HAL_TXT < cycle )
-printk("\n[DBG] %s : thread %x deschedule / cycle %d\n", 
-__FUNCTION__ , CURRENT_THREAD , cycle );
-#endif
-
-    // Block and deschedule server thread
-    thread_block( CURRENT_THREAD , THREAD_BLOCKED_DEV_ISR );
-    sched_yield("blocked on ISR");
-
-#if CONFIG_DEBUG_HAL_TXT
-cycle = (uint32_t)hal_get_cycles();
-if (CONFIG_DEBUG_HAL_TXT < cycle )
-printk("\n[DBG] %s : thread %x resume / cycle %d\n", 
-__FUNCTION__ , CURRENT_THREAD , cycle );
-#endif
-
-#if CONFIG_READ_DEBUG
-exit_tty_cmd = hal_time_stamp();
+printk("\n[DBG] %s : thread %x exit after %s / cycle %d\n", 
+__FUNCTION__ , CURRENT_THREAD , dev_txt_type_str( type ) , cycle );
+#endif
+
+#if (CONFIG_DEBUG_SYS_READ & 1)
+if( type == TXT_READ ) exit_tty_cmd_read = (uint32_t)hal_get_cycles();
+#endif
+
+#if (CONFIG_DEBUG_SYS_WRITE & 1)
+if( type == TXT_WRITE ) exit_tty_cmd_write = (uint32_t)hal_get_cycles();
 #endif
 
@@ -143,7 +163,7 @@
     uint32_t   i;
 
-    xptr_t     dev_xp = ((txt_aux_t *)args)->dev_xp;
-    char     * buffer = ((txt_aux_t *)args)->buffer;
-    uint32_t   count  = ((txt_aux_t *)args)->count;
+    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;
     
     // get TXT0 chdev cluster and local pointer
@@ -182,16 +202,28 @@
 void __attribute__ ((noinline)) soclib_tty_isr( chdev_t * chdev )
 {
-    uint32_t   type;         // command type
-    uint32_t   count;        // number of bytes in buffer
-    xptr_t     buf_xp;       // extended pointer on buffer
-    xptr_t     status_xp;    // extended pointer on TTY_STATUS register
-    xptr_t     write_xp;     // extended pointer on TTY_WRITE register
-    xptr_t     read_xp;      // extended pointer on TTY_READ register
-    uint32_t   status;       // TTY terminal status
-    char       byte;         // read byte
-    uint32_t   i;
-
-#if (CONFIG_READ_DEBUG & 0x1) || (CONFIG_WRITE_DEBUG & 0x1)
-enter_tty_isr = hal_time_stamp();
+    uint32_t    type;         // command type
+    uint32_t    count;        // number of bytes in buffer
+    xptr_t      buf_xp;       // extended pointer on buffer
+    xptr_t      error_xp;     // extended pointer on error field in command
+    xptr_t      status_xp;    // extended pointer on TTY_STATUS register
+    xptr_t      write_xp;     // extended pointer on TTY_WRITE register
+    xptr_t      read_xp;      // extended pointer on TTY_READ register
+    uint32_t    status;       // TTY terminal status
+    char        byte;         // read byte
+    xptr_t      client_xp;    // first client thread in waiting queue
+    cxy_t       client_cxy;   // firts client thread cluster
+    thread_t  * client_ptr;   // first client thread pointer
+    pid_t       pid;          // foreground process identifier
+    xptr_t      owner_xp;     // extended pointer on foreground process in owner cluster
+    cxy_t       owner_cxy;   
+    process_t * owner_ptr;
+    uint32_t    i;
+
+#if (CONFIG_DEBUG_SYS_READ & 1)
+enter_tty_isr_read = (uint32_t)hal_get_cycles();
+#endif
+
+#if (CONFIG_DEBUG_SYS_WRITE & 1)
+enter_tty_isr_write = (uint32_t)hal_get_cycles();
 #endif
 
@@ -202,20 +234,41 @@
 #endif
 
-    // get extended pointer on client thread
-    xptr_t root      = XPTR( local_cxy , &chdev->wait_root );
-    xptr_t client_xp = XLIST_FIRST_ELEMENT( root , thread_t , wait_list );
-
-    // get client thread cluster and local pointer
-    cxy_t      client_cxy = GET_CXY( client_xp );
-    thread_t * client_ptr = (thread_t *)GET_PTR( client_xp );
-
-    // get command arguments
-    type    = hal_remote_lw ( XPTR( client_cxy , &client_ptr->txt_cmd.type   ) );
-    count   = hal_remote_lw ( XPTR( client_cxy , &client_ptr->txt_cmd.count  ) );
-    buf_xp  = hal_remote_lwd( XPTR( client_cxy , &client_ptr->txt_cmd.buf_xp ) );
+    // get extended pointer on chdev queue root
+    xptr_t root_xp   = XPTR( local_cxy , &chdev->wait_root );
+
+    // get chdev channel 
+    uint32_t channel = chdev->channel;
+
+    // get first command if queue non empty
+    if( xlist_is_empty( root_xp ) == false )
+    {
+        // get extended pointer on first client thread
+        client_xp = XLIST_FIRST_ELEMENT( root_xp , thread_t , wait_list );
+
+        // get client thread cluster and local pointer
+        client_cxy = GET_CXY( client_xp );
+        client_ptr = GET_PTR( client_xp );
+
+        // get command arguments
+        type     = hal_remote_lw ( XPTR( client_cxy , &client_ptr->txt_cmd.type   ) );
+        count    = hal_remote_lw ( XPTR( client_cxy , &client_ptr->txt_cmd.count  ) );
+        buf_xp   = hal_remote_lwd( XPTR( client_cxy , &client_ptr->txt_cmd.buf_xp ) );
+        error_xp =                 XPTR( client_cxy , &client_ptr->txt_cmd.error  );
+    }
+    else
+    {
+        type     = 0xFFFFFFFF;
+
+        // these lines to avoid a GCC warning
+        count      = 0;
+        buf_xp     = XPTR_NULL;
+        error_xp   = XPTR_NULL;
+        client_cxy = 0;
+        client_ptr = NULL;
+    }
 
     // get SOCLIB_TTY peripheral cluster and local pointer
     cxy_t      tty_cxy = GET_CXY( chdev->base );
-    uint32_t * tty_ptr = (uint32_t *)GET_PTR( chdev->base );
+    uint32_t * tty_ptr = GET_PTR( chdev->base );
 
     // get channel base address
@@ -227,27 +280,65 @@
     read_xp   = XPTR( tty_cxy , base + TTY_READ );
 
-    if( type == TXT_READ )              // read one single character
-    {
-        // get TTY_STATUS
-        status = hal_remote_lw( status_xp );
-
-        if( status & TTY_STATUS_RX_FULL )   // TTY_RX full => move one byte
-        {
-            // get a byte from TTY_READ, and acknowledge RX_IRQ
-            byte = (char)hal_remote_lb( read_xp );
-
-            // write it to command buffer
+    // get TTY_STATUS register value
+    status = hal_remote_lw( status_xp );
+
+    // 1. handle RX if TTY_READ buffer full
+    if( status & TTY_STATUS_RX_FULL )   
+    {
+        // get a byte from TTY_READ / acknowledge RX_IRQ
+        byte = (char)hal_remote_lb( read_xp );
+
+        // check character value
+        if( byte == 0x1A )          // ^Z  =>  stop onwner process
+        {
+            // get pid of terminal owner process
+            pid = process_get_txt_owner( channel );
+
+            // get cluster and pointers on owner process descriptor
+            owner_xp  = cluster_get_owner_process_from_pid( pid );
+            owner_cxy = GET_CXY( owner_xp );
+            owner_ptr = GET_PTR( owner_xp );
+
+            // send stop signal to owner process
+            process_sigaction( pid , BLOCK_ALL_THREADS );
+                
+            // atomically update owner process termination state
+            hal_remote_atomic_or( XPTR( owner_cxy , &owner_ptr->term_state ) ,
+                                  PROCESS_TERM_STOP );
+            return;
+        }
+        else if( byte == 0x03 )     // ^C  => kill owner process
+        {
+            // get pid of terminal owner process
+            pid = process_get_txt_owner( channel );
+
+            // get cluster and pointers on owner process descriptor
+            owner_xp  = cluster_get_owner_process_from_pid( pid );
+            owner_cxy = GET_CXY( owner_xp );
+            owner_ptr = GET_PTR( owner_xp );
+
+            // send kill signal to owner process
+            process_sigaction( pid , DELETE_ALL_THREADS );
+                
+            // atomically update owner process termination state
+            hal_remote_atomic_or( XPTR( owner_cxy , &owner_ptr->term_state ) ,
+                                  PROCESS_TERM_KILL );
+            return;
+        }
+        else if( type == TXT_READ ) // pending TXT_READ
+        {
+            // write character to command buffer
             hal_remote_sb( buf_xp , byte );
-        }
-        else                               // buffer empty => exit ISR for retry
-        {
-            return;
-        }
-
-        // disable RX_IRQ 
-        xptr_t reg_xp = XPTR( tty_cxy , base + TTY_RX_IRQ_ENABLE );
-        hal_remote_sw( reg_xp , 0 );
-    }
-    else   // type == TXT_WRITE           // write all characters in string
+
+            // set I/O operation status in command
+            hal_remote_sw( error_xp , 0 );
+
+            // unblock server thread
+            thread_unblock( XPTR( local_cxy , chdev->server ) , THREAD_BLOCKED_DEV_ISR );
+        }
+    }
+
+    // 3. handle TX if TXT_WRITE
+    if( type == TXT_WRITE )
     {
         // loop on characters
@@ -262,5 +353,5 @@
                 byte = (char)hal_remote_lb( buf_xp + i );
 
-                // write byte to TTY_WRITE, and acknowledge TX_IRQ
+                // write byte to TTY_WRITE / acknowledge TX_IRQ
                 hal_remote_sb( write_xp , byte );
             }
@@ -273,19 +364,13 @@
         }
 
+        // set I/O operation status in command
+        hal_remote_sw( error_xp , 0 );
+
         // disable TX_IRQ 
-        xptr_t reg_xp = XPTR( tty_cxy , base + TTY_TX_IRQ_ENABLE );
-        hal_remote_sw( reg_xp , 0 );
-    }
-
-    // The I/O operation completed when we reach this point
-
-    // set I/O operation status in command
-    hal_remote_sw( XPTR( client_cxy , &client_ptr->txt_cmd.error ) , 0 );
-
-    // unblock server thread
-    thread_unblock( XPTR( local_cxy , chdev->server ) , THREAD_BLOCKED_DEV_ISR );
-
-    // unblock client thread
-    // thread_unblock( client_xp , THREAD_BLOCKED_IO );
+        hal_remote_sw( XPTR( tty_cxy , base + TTY_TX_IRQ_ENABLE ) , 0 );
+
+        // unblock server thread
+        thread_unblock( XPTR( local_cxy , chdev->server ) , THREAD_BLOCKED_DEV_ISR );
+    }
 
     hal_fence();
@@ -294,168 +379,16 @@
 cycle = (uint32_t)hal_get_cycles();
 if (CONFIG_DEBUG_HAL_TXT < cycle)
-{
-    if( type == TXT_READ) 
-        printk("\n[DBG] %s : exit after RX / cycle %d\n", __FUNCTION__ , cycle );
-    else
-        printk("\n[DBG] %s : exit after TX / cycle %d\n", __FUNCTION__ , cycle );
-}      
-#endif
-
-#if (CONFIG_READ_DEBUG & 0x1) || (CONFIG_WRITE_DEBUG & 0x1)
-exit_tty_isr = hal_time_stamp();
+printk("\n[DBG] %s : exit after %s / cycle %d\n",
+__FUNCTION__ , dev_txt_type_str( type ) , cycle );
+#endif
+
+#if (CONFIG_DEBUG_SYS_READ & 1)
+if( type == TXT_READ) exit_tty_isr_read = (uint32_t)hal_get_cycles();
+#endif
+
+#if (CONFIG_DEBUG_SYS_WRITE & 1)
+if( type == TXT_WRITE) exit_tty_isr_write = (uint32_t)hal_get_cycles();
 #endif
 
 }  // end soclib_tty_isr()
 
-/*
-/////////////////////////////////////////////////////////////////
-void __attribute__ ((noinline)) soclib_tty_isr( chdev_t * chdev )
-{
-    xptr_t     root_xp;      // extended pointer on command list root
-    xptr_t     client_xp;    // extended pointer on client thread
-    cxy_t      client_cxy;   // client thread cluster
-    thread_t * client_ptr;   // client_thread local pointer
-    uint32_t   type;         // command type
-    uint32_t   count;        // number of bytes in buffer
-    xptr_t     buf_xp;       // extended pointer on buffer
-    xptr_t     status_xp;    // extended pointer on TTY_STATUS register
-    xptr_t     write_xp;     // extended pointer on TTY_WRITE register
-    xptr_t     read_xp;      // extended pointer on TTY_READ register
-    uint32_t   status;       // TTY terminal status
-    char       byte;         // read byte
-    uint32_t   i;
-
-#if (CONFIG_READ_DEBUG & 0x1) || (CONFIG_WRITE_DEBUG & 0x1)
-enter_tty_isr = hal_time_stamp();
-#endif
-
-txt_dmsg("\n[DBG] %s : core[%x,%d] enter / cycle %d\n", 
-__FUNCTION__ , local_cxy, CURRENT_THREAD->core->lid , hal_time_stamp() );
-
-    // get SOCLIB_TTY peripheral cluster and local pointer
-    cxy_t      tty_cxy = GET_CXY( chdev->base );
-    uint32_t * tty_ptr = (uint32_t *)GET_PTR( chdev->base );
-
-    // get channel base address
-    uint32_t * base = tty_ptr + TTY_SPAN * chdev->channel;
-
-    // get extended pointer on TTY registers
-    status_xp = XPTR( tty_cxy , base + TTY_STATUS );
-    write_xp  = XPTR( tty_cxy , base + TTY_WRITE );
-    read_xp   = XPTR( tty_cxy , base + TTY_READ );
-
-    // get TTY_STATUS
-    status = hal_remote_lw( status_xp );
-
-    // get extended pointer on the command list root
-    root_xp = XPTR( local_cxy , &chdev->wait_root );
-
-    // get extended pointer on client thread
-    if(xlist_is_empty(root_xp)) client_xp = XLIST_FIRST_ELEMENT(root, thread_t, wait_list);
-    else                        client_xp = XPTR_NULL;
-
-    if( client_xp )
-    {
-        // get client thread cluster and local pointer
-        client_cxy = GET_CXY( client_xp );
-        client_ptr = (thread_t *)GET_PTR( client_xp );
-
-        // get command arguments
-        type    = hal_remote_lw ( XPTR( client_cxy , &client_ptr->txt_cmd.type   ) );
-        count   = hal_remote_lw ( XPTR( client_cxy , &client_ptr->txt_cmd.count  ) );
-        buf_xp  = hal_remote_lwd( XPTR( client_cxy , &client_ptr->txt_cmd.buf_xp ) );
-    }
-
-    ///////////// handle RX if TTY_RX full
-    if( status & TTY_STATUS_RX_FULL )   
-    {
-        // get a byte from TTY_READ, and acknowledge RX_IRQ
-        byte = (char)hal_remote_lb( read_xp );
-
-        // FIXME The RX_IRQ must be always enabled !!!  
-        // xptr_t reg_xp = XPTR( tty_cxy , base + TTY_RX_IRQ_ENABLE );
-        // hal_remote_sw( reg_xp , 0 );
-
-        // analyse received character 
-        switch( byte )
-        {
-            case CONTROL_C:          // SIGINT to process
-            case CONTROL_D:
-            {
-                // TODO SIGINT
-                return
-            }
-            break;
-            default:                 
-            { 
-                if( (type == TXT_READ) && (client_xp != XPTR_NULL) )  
-                {
-                    // write byte to command buffer
-                    hal_remote_sb( buf_xp , byte );
-
-                    // set status in command
-                    hal_remote_sw( XPTR( client_cxy , &client_ptr->txt_cmd.error ) , 0 );
-
-                    hal_fence();
-
-                    // unblock server thread
-                    thread_unblock( XPTR(local_cxy,chdev->server), THREAD_BLOCKED_DEV_ISR );
-                }
-                else                    // discard byte
-                {
-                    // TODO WARNING
-                    return
-                }
-            }
-        }
-    } // end RX handling
-
-    //////////////// handle TX if WRITE command pending
-    if( (type == TXT_WRITE) && (client_xp != XPTR_NULL) ) 
-    {
-        // loop on characters
-        for( i = 0 ; i < count ; i++ )
-        {
-            // get TTY_STATUS
-            status = hal_remote_lw( status_xp );
-
-            if( (status & TTY_STATUS_TX_FULL) == 0 ) // TTY_TX empty => move one byte
-            {
-                // get one byte from command buffer
-                byte = (char)hal_remote_lb( buf_xp + i );
-
-                // write byte to TTY_WRITE, and acknowledge TX_IRQ
-                hal_remote_sb( write_xp , byte );
-            }
-            else         // TTY_TX full => update command arguments and exit ISR for retry
-            {
-                hal_remote_sw ( XPTR( client_cxy , &client_ptr->txt_cmd.count ), count-i );
-                hal_remote_swd( XPTR( client_cxy , &client_ptr->txt_cmd.buf_xp ), buf_xp+i );
-                return;
-            }
-        }
-
-        // disable TX_IRQ 
-        xptr_t reg_xp = XPTR( tty_cxy , base + TTY_TX_IRQ_ENABLE );
-        hal_remote_sw( reg_xp , 0 );
-
-        // set I/O operation status in command
-        hal_remote_sw( XPTR( client_cxy , &client_ptr->txt_cmd.error ) , 0 );
-
-        hal_fence();
-
-        // unblock server thread
-        thread_unblock( XPTR( local_cxy , chdev->server ) , THREAD_BLOCKED_DEV_ISR );
-
-    }  // end TX handling
-
-txt_dmsg("\n[DBG] %s : core[%x,%d] exit / cycle %d\n", 
-__FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , hal_time_stamp() );
-
-#if (CONFIG_READ_DEBUG & 0x1) || (CONFIG_WRITE_DEBUG & 0x1)
-exit_tty_isr = hal_time_stamp();
-#endif
-
-}  // end soclib_tty_isr()
-
-*/
