Index: trunk/kernel/fs/devfs.c
===================================================================
--- trunk/kernel/fs/devfs.c	(revision 568)
+++ trunk/kernel/fs/devfs.c	(revision 598)
@@ -104,8 +104,9 @@
 
 #if DEBUG_DEVFS_INIT
-uint32_t cycle = (uint32_t)hal_get_cycles();
-if( DEBUG_DEVFS_INIT < cycle )
-printk("\n[DBG] %s : thread %x in process %x created <dev> inode / cycle %d\n",
-__FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid ,cycle );
+uint32_t   cycle = (uint32_t)hal_get_cycles();
+thread_t * this  = CURRENT_THREAD;
+if( DEBUG_DEVFS_INIT < cycle )
+printk("\n[%s] thread[%x,%x] created <dev> inode / cycle %d\n",
+__FUNCTION__, this->process->pid, this->trdid, cycle );
 #endif
 
@@ -124,6 +125,6 @@
 cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_DEVFS_INIT < cycle )
-printk("\n[DBG] %s : thread %x in process %x created <external> inode / cycle %d\n",
-__FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid , cycle );
+printk("\n[%s] thread[%x,%x] created <external> inode / cycle %d\n",
+__FUNCTION__, this->process->pid, this->trdid, cycle );
 #endif
 
@@ -152,10 +153,9 @@
                              devfs_internal_inode_xp );
 #if DEBUG_DEVFS_INIT 
-uint32_t cycle = (uint32_t)hal_get_cycles();
-trdid_t  trdid = CURRENT_THREAD->trdid;
-pid_t    pid   = CURRENT_THREAD->process->pid;
-if( DEBUG_DEVFS_INIT < cycle )
-printk("\n[DBG] %s : thread %x in process %x created <%s> in cluster %x / cycle %d\n",
-__FUNCTION__, trdid, pid, node_name, local_cxy, cycle );
+uint32_t   cycle = (uint32_t)hal_get_cycles();
+thread_t * this  = CURRENT_THREAD;
+if( DEBUG_DEVFS_INIT < cycle )
+printk("\n[%s] thread[%x,%x] created <%s> inode in cluster %x / cycle %d\n",
+__FUNCTION__, this->process->pid, this->trdid, node_name, local_cxy, cycle );
 #endif
 
@@ -175,6 +175,6 @@
 cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_DEVFS_INIT < cycle )
-printk("\n[DBG] %s : thread %x in process %x created <mmc> inode in cluster %x\n",
-__FUNCTION__, trdid, pid, local_cxy, cycle );
+printk("\n[%s] thread[%x,%x] created <mmc> inode in cluster %x\n",
+__FUNCTION__, this->process->pid, this->trdid, local_cxy, cycle );
 #endif
 
@@ -198,6 +198,6 @@
 cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_DEVFS_INIT < cycle )
-printk("\n[DBG] %s : thread %x in process %x created <dma[%d]> inode in cluster %x\n",
-__FUNCTION__, trdid, pid, channel, local_cxy, cycle );
+printk("\n[%s] thread [%x,%x] created <dma[%d]> inode in cluster %x\n",
+__FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle );
 #endif
         }
@@ -222,6 +222,6 @@
 cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_DEVFS_INIT < cycle )
-printk("\n[DBG] %s : thread %x in process %x created <iob> inode in cluster %x\n",
-__FUNCTION__, trdid, pid, local_cxy, cycle );
+printk("\n[%s] thread[%x,%x] created <iob> inode in cluster %x\n",
+__FUNCTION__, this->process->pid, this->trdid, local_cxy, cycle );
 #endif
         }
@@ -246,6 +246,6 @@
 cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_DEVFS_INIT < cycle )
-printk("\n[DBG] %s : thread %x in process %x created <pic> inode in cluster %x\n",
-__FUNCTION__, trdid, pid, local_cxy, cycle );
+printk("\n[%s] thread[%x,%x] created <pic> inode in cluster %x\n",
+__FUNCTION__, this->process->pid, this->trdid, local_cxy, cycle );
 #endif
         }
@@ -272,6 +272,6 @@
 cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_DEVFS_INIT < cycle )
-printk("\n[DBG] %s : thread %x in process %x created <txt_rx[%d]> inode in cluster %x\n",
-__FUNCTION__, trdid, pid, channel, local_cxy, cycle );
+printk("\n[%s] thread[%x,%x] created <txt_rx[%d]> inode in cluster %x\n",
+__FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle );
 #endif
             }
@@ -299,6 +299,6 @@
 cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_DEVFS_INIT < cycle )
-printk("\n[DBG] %s : thread %x in process %x created <txt_tx[%d]> inode in cluster %x\n",
-__FUNCTION__, trdid, pid, channel, local_cxy, cycle );
+printk("\n[%s] thread[%x,%x] created <txt_tx[%d]> inode in cluster %x\n",
+__FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle );
 #endif
             }
@@ -326,6 +326,6 @@
 cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_DEVFS_INIT < cycle )
-printk("\n[DBG] %s : thread %x in process %x created <ioc[%d]> inode in cluster %x\n",
-__FUNCTION__, trdid, pid, channel, local_cxy, cycle );
+printk("\n[%s] thread[%x,%x] created <ioc[%d]> inode in cluster %x\n",
+__FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle );
 #endif
             }
@@ -353,6 +353,6 @@
 cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_DEVFS_INIT < cycle )
-printk("\n[DBG] %s : thread %x in process %x created <fbf[%d]> inode in cluster %x\n",
-__FUNCTION__, trdid, pid, channel, local_cxy, cycle );
+printk("\n[%s] thread[%x,%x] created <fbf[%d]> inode in cluster %x\n",
+__FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle );
 #endif
             }
@@ -380,6 +380,6 @@
 cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_DEVFS_INIT < cycle )
-printk("\n[DBG] %s : thread %x in process %x created <nic_rx[%d]> inode in cluster %x\n",
-__FUNCTION__, trdid, pid, channel, local_cxy, cycle );
+printk("\n[%s] thread[%x,%x] created <nic_rx[%d]> inode in cluster %x\n",
+__FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle );
 #endif
             }
@@ -407,6 +407,6 @@
 cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_DEVFS_INIT < cycle )
-printk("\n[DBG] %s : thread %x in process %x created <nic_tx[%d]> inode in cluster %x\n",
-__FUNCTION__, trdid, pid, channel, local_cxy, cycle );
+printk("\n[%s] thread[%x,%x] created <nic_tx[%d]> inode in cluster %x\n",
+__FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle );
 #endif
             }
@@ -418,19 +418,20 @@
 int devfs_user_move( bool_t     to_buffer,
                      xptr_t     file_xp,
-                     void     * u_buf,
+                     char     * u_buf,
                      uint32_t   size )
 {
-    assert( ( file_xp != XPTR_NULL ) , "file_xp == XPTR_NULL" );
-
-    assert( ( size < CONFIG_TXT_KBUF_SIZE ) , "string size too large" );
-
-    xptr_t             chdev_xp;
-    cxy_t              chdev_cxy;
-    chdev_t          * chdev_ptr;    // associated chdev type
-    uint32_t           func;         // chdev functionnal type
-    uint32_t           channel;      // chdev channel index
-    error_t            error;
-
-    char               k_buf[CONFIG_TXT_KBUF_SIZE];  // local kernel buffer
+    xptr_t           chdev_xp;
+    cxy_t            chdev_cxy;
+    chdev_t        * chdev_ptr;                    // associated chdev type
+    uint32_t         func;                         // chdev functionnal type
+    uint32_t         channel;                      // chdev channel index
+    uint32_t         burst;                        // number of bytes in a burst
+    uint32_t         todo;                         // number of bytes not yet moved
+    error_t          error;
+    uint32_t         i;
+
+    char             k_buf[CONFIG_TXT_KBUF_SIZE];  // local kernel buffer
+
+assert( ( file_xp != XPTR_NULL ) , "file_xp == XPTR_NULL" );
 
 #if (DEBUG_SYS_READ & 1)
@@ -443,8 +444,9 @@
 
 #if DEBUG_DEVFS_MOVE
-uint32_t cycle = (uint32_t)hal_get_cycles();
+uint32_t   cycle = (uint32_t)hal_get_cycles();
+thread_t * this  = CURRENT_THREAD;
 if( DEBUG_DEVFS_MOVE < cycle )
-printk("\n[DBG] %s : thread %x enter / to_mem %d / cycle %d\n",
-__FUNCTION__ , CURRENT_THREAD , to_buffer , cycle );
+printk("\n[%s] thread[%x,%x] enter / to_mem %d / cycle %d\n",
+__FUNCTION__, this->process->pid, this->trdid, to_buffer, cycle );
 #endif
 
@@ -460,29 +462,39 @@
     channel = hal_remote_l32( XPTR( chdev_cxy , &chdev_ptr->channel ) );
 
-    // action depends on "func" and "to_buffer" 
-    if( func == DEV_FUNC_TXT )
-    {
-        if( to_buffer )     // TXT read
-        { 
-            uint32_t i;
-            for( i = 0 ; i < size ; i++ )
+assert( ( func == DEV_FUNC_TXT ) , __FUNCTION__, "illegal device func_type");
+
+    // initialise number of bytes to move
+    todo = size;
+
+    /////////////// TXT read
+    if( to_buffer )
+    { 
+        while( todo )
+        {
+            // set burst size
+            if( todo > CONFIG_TXT_KBUF_SIZE ) burst = CONFIG_TXT_KBUF_SIZE;
+            else                              burst = todo;
+
+            // read burst bytes from TXT device to kernel buffer
+            for( i = 0 ; i < burst ; i++ )
             {
                 error = dev_txt_read( channel , &k_buf[i] );
 
-                if( error ) 
-                {
-                    return -1;
-                }
-                else
-                {
-                    hal_strcpy_to_uspace( u_buf , k_buf , size );
-                }
-             }
+                if( error )  return -1;
+            }
+
+            // move burst bytes from k_buf to u_buf                   
+            hal_strcpy_to_uspace( u_buf , k_buf , burst );
+
+            // update loop variables
+            todo  -= burst;
+            u_buf += burst;
+        }
 
 #if DEBUG_DEVFS_MOVE
 cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_DEVFS_MOVE < cycle )
-printk("\n[DBG] %s : thread %x exit / to_mem %d / cycle %d\n",
-__FUNCTION__ , CURRENT_THREAD , to_buffer / cycle );
+printk("\n[%s] thread[%x,%x] exit / to_mem %d / cycle %d\n",
+__FUNCTION__, this->process->pid, this->trdid, to_buffer, cycle );
 #endif
 
@@ -491,22 +503,32 @@
 #endif
             return size;
+    } 
+    ///////////// TXT write  
+    else                
+    {
+        while( todo )
+        {
+            // set burst size
+            if( todo > CONFIG_TXT_KBUF_SIZE ) burst = CONFIG_TXT_KBUF_SIZE;
+            else                              burst = todo;
+
+            // move burst bytes from u_buf to k_buf
+            hal_strcpy_from_uspace( k_buf , u_buf , burst );
+
+            // write burst bytes from kernel buffer to TXT device
+            error = dev_txt_write( channel , k_buf , burst );
+
+            if( error ) return -1;
+
+            // update loop variables
+            todo  -= burst;
+            u_buf += burst;
         } 
-        else                // TXT write  
-        {
-            hal_strcpy_from_uspace( k_buf , u_buf , size );
-
-            error = dev_txt_write( channel , k_buf , size );
-            if( error ) 
-            {
-                return -1;
-            }
-            else
-            {
 
 #if DEBUG_DEVFS_MOVE
 cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_DEVFS_MOVE < cycle )
-printk("\n[DBG] %s : thread %x exit / to_mem %d / cycle %d\n",
-__FUNCTION__ , CURRENT_THREAD , to_buffer / cycle );
+printk("\n[%s] thread[%x,%x] exit / to_mem %d / cycle %d\n",
+__FUNCTION__, this->process->pid, this->trdid, to_buffer, cycle );
 #endif
 
@@ -514,14 +536,5 @@
 exit_devfs_write = hal_time_stamp();
 #endif
-                return size;
-            }
-        }
-    }
-    else
-    {
-        assert( false , "%s does not support direct user access",
-          chdev_func_str(func) );
-
-        return -1;
+            return size;
     }
 
