Index: trunk/kernel/syscalls/sys_read.c
===================================================================
--- trunk/kernel/syscalls/sys_read.c	(revision 433)
+++ trunk/kernel/syscalls/sys_read.c	(revision 435)
@@ -36,5 +36,4 @@
 // TODO: concurrent user page(s) munmap need to be handled [AG] 
 
-// TODO : remove these debug variables
 extern uint32_t enter_sys_read;
 extern uint32_t enter_devfs_move;
@@ -64,5 +63,5 @@
     reg_t        save_sr;     // required to enable IRQs during syscall
 
-#if CONFIG_READ_DEBUG
+#if (CONFIG_DEBUG_SYS_READ & 1)
 enter_sys_read = (uint32_t)tm_start;
 #endif
@@ -76,5 +75,5 @@
 tm_start = hal_get_cycles();
 if( CONFIG_DEBUG_SYS_READ < tm_start )
-printk("\n[DBG] %s : thread %d enter / process %x / vaddr = %x / count %d / cycle %d\n",
+printk("\n[DBG] %s : thread %x enter / process %x / vaddr = %x / count %d / cycle %d\n",
 __FUNCTION__, this, process->pid, vaddr, count, (uint32_t)tm_start );
 #endif
@@ -83,6 +82,8 @@
 	if( file_id >= CONFIG_PROCESS_FILE_MAX_NR )
 	{
-        printk("\n[ERROR] in %s : illegal file descriptor index = %d\n",
-        __FUNCTION__ , file_id );
+
+#if CONFIG_DEBUG_SYSCALLS_ERROR
+printk("\n[ERROR] in %s : illegal file descriptor index = %d\n", __FUNCTION__ , file_id );
+#endif
 		this->errno = EBADFD;
 		return -1;
@@ -94,6 +95,9 @@
     if ( error )
     {
-        printk("\n[ERROR] in %s : user buffer unmapped = %x\n",
-        __FUNCTION__ , (intptr_t)vaddr );
+
+#if CONFIG_DEBUG_SYSCALLS_ERROR
+printk("\n[ERROR] in %s : user buffer unmapped = %x\n", 
+__FUNCTION__ , (intptr_t)vaddr );
+#endif
 		this->errno = EINVAL;
 		return -1;
@@ -108,6 +112,9 @@
     if( file_xp == XPTR_NULL )
     {
-        printk("\n[ERROR] in %s : undefined file descriptor index = %d in process %x\n",
-        __FUNCTION__ , file_id , process->pid );
+
+#if CONFIG_DEBUG_SYSCALLS_ERROR
+printk("\n[ERROR] in %s : undefined fd_id %d in process %x\n",
+__FUNCTION__ , file_id , process->pid );
+#endif
         this->errno = EBADFD;
         return -1;
@@ -122,6 +129,9 @@
     if( (attr & FD_ATTR_READ_ENABLE) == 0 )
 	{
-        printk("\n[ERROR] in %s : file %d not readable in process %x\n",
-        __FUNCTION__ , file_id , process->pid );
+
+#if CONFIG_DEBUG_SYSCALLS_ERROR
+printk("\n[ERROR] in %s : file %d not readable in process %x\n",
+__FUNCTION__ , file_id , process->pid );
+#endif
 		this->errno = EBADFD;
 		return -1;
@@ -138,6 +148,9 @@
         if( (attr & FD_ATTR_READ_ENABLE) == 0 )
 	    {
-            printk("\n[ERROR] in %s : file %d not readable in process %x\n",
-            __FUNCTION__ , file_id , process->pid );
+
+#if CONFIG_DEBUG_SYSCALLS_ERROR
+printk("\n[ERROR] in %s : file %d not readable in process %x\n",
+__FUNCTION__ , file_id , process->pid );
+#endif
 		    this->errno = EBADFD;
 		    return -1;
@@ -166,6 +179,9 @@
         if( XPTR( local_cxy , process ) != owner_xp )
         {
-            printk("\n[ERROR] in %s : process %x not in foreground for TXT%d\n",
-            __FUNCTION__, process->pid, hal_remote_lw( XPTR(chdev_cxy,&chdev_ptr->channel) ) );
+
+#if CONFIG_DEBUG_SYSCALLS_ERROR
+printk("\n[ERROR] in %s : process %x not in foreground for TXT%d\n",
+__FUNCTION__, process->pid, hal_remote_lw( XPTR(chdev_cxy,&chdev_ptr->channel) ) );
+#endif
 		    this->errno = EBADFD;
 		    return -1;
@@ -180,6 +196,9 @@
     if( nbytes != count )
     {
-        printk("\n[ERROR] in %s cannot read data from file %d in process %x\n",
-        __FUNCTION__ , file_id , process->pid );
+
+#if CONFIG_DEBUG_SYSCALLS_ERROR
+printk("\n[ERROR] in %s cannot read data from file %d in process %x\n",
+__FUNCTION__ , file_id , process->pid );
+#endif
         this->errno = error;
         return -1;
@@ -194,5 +213,5 @@
 tm_end = hal_get_cycles();
 if( CONFIG_DEBUG_SYS_READ < tm_end )
-printk("\n[DBG] %s : thread %x / process %x / cycle %d\n"
+printk("\n[DBG] %s : thread %x exit / process %x / cycle %d\n"
 "nbytes = %d / first byte = %c / file_id = %d / cost = %d\n",
 __FUNCTION__ , local_cxy , this->core->lid , this->trdid , this->process->pid ,
@@ -201,37 +220,37 @@
 #endif
 
-#if (CONFIG_READ_DEBUG & 0x1) 
+#if (CONFIG_DEBUG_SYS_READ & 1) 
 exit_sys_read = (uint32_t)tm_end;
 
 printk("\n@@@@@@@@@@@@ timing to read character %c\n"
-" - enter_sys_read     = %d / delta %d\n"
-" - enter_devfs_move   = %d / delta %d\n"
-" - enter_txt_read     = %d / delta %d\n"
-" - enter_chdev_cmd    = %d / delta %d\n"
-" - enter_chdev_server = %d / delta %d\n"
-" - enter_tty_cmd      = %d / delta %d\n"
-" - enter_tty_isr      = %d / delta %d\n"
-" - exit_tty_isr       = %d / delta %d\n"
-" - exit_tty_cmd       = %d / delta %d\n"
-" - exit_chdev_server  = %d / delta %d\n"
-" - exit_chdev_cmd     = %d / delta %d\n"
-" - exit_txt_read      = %d / delta %d\n"
-" - exit_devfs_move    = %d / delta %d\n"
-" - exit_sys_read      = %d / delta %d\n",
+" - enter_sys_read          = %d / delta %d\n"
+" - enter_devfs_read        = %d / delta %d\n"
+" - enter_txt_read          = %d / delta %d\n"
+" - enter_chdev_cmd_read    = %d / delta %d\n"
+" - enter_chdev_server_read = %d / delta %d\n"
+" - enter_tty_cmd_read      = %d / delta %d\n"
+" - enter_tty_isr_read      = %d / delta %d\n"
+" - exit_tty_isr_read       = %d / delta %d\n"
+" - exit_tty_cmd_read       = %d / delta %d\n"
+" - exit_chdev_server_read  = %d / delta %d\n"
+" - exit_chdev_cmd_read     = %d / delta %d\n"
+" - exit_txt_read           = %d / delta %d\n"
+" - exit_devfs_read         = %d / delta %d\n"
+" - exit_sys_read           = %d / delta %d\n",
 *((char *)(intptr_t)paddr) ,
-enter_sys_read     , 0 ,
-enter_devfs_move   , enter_devfs_move   - enter_sys_read     ,
-enter_txt_read     , enter_txt_read     - enter_devfs_move   ,
-enter_chdev_cmd    , enter_chdev_cmd    - enter_txt_read     ,
-enter_chdev_server , enter_chdev_server - enter_chdev_cmd    ,
-enter_tty_cmd      , enter_tty_cmd      - enter_chdev_server ,
-enter_tty_isr      , enter_tty_isr      - enter_tty_cmd      ,
-exit_tty_isr       , exit_tty_isr       - enter_tty_isr      ,
-exit_tty_cmd       , exit_tty_cmd       - exit_tty_isr       ,
-exit_chdev_server  , exit_chdev_server  - exit_tty_cmd       ,
-exit_chdev_cmd     , exit_chdev_cmd     - exit_chdev_server  ,
-exit_txt_read      , exit_txt_read      - exit_chdev_cmd     ,
-exit_devfs_move    , exit_devfs_move    - exit_txt_read      ,
-exit_sys_read      , exit_sys_read      - exit_devfs_move    );
+enter_sys_read          , 0 ,
+enter_devfs_read        , enter_devfs_read        - enter_sys_read          ,
+enter_txt_read          , enter_txt_read          - enter_devfs_read        ,
+enter_chdev_cmd_read    , enter_chdev_cmd_read    - enter_txt_read          ,
+enter_chdev_server_read , enter_chdev_server_read - enter_chdev_cmd_read    ,
+enter_tty_cmd_read      , enter_tty_cmd_read      - enter_chdev_server_read ,
+enter_tty_isr_read      , enter_tty_isr_read      - enter_tty_cmd_read      ,
+exit_tty_isr_read       , exit_tty_isr_read       - enter_tty_isr_read      ,
+exit_tty_cmd_read       , exit_tty_cmd_read       - exit_tty_isr_read       ,
+exit_chdev_server_read  , exit_chdev_server_read  - exit_tty_cmd_read       ,
+exit_chdev_cmd_read     , exit_chdev_cmd_read     - exit_chdev_server_read  ,
+exit_txt_read           , exit_txt_read           - exit_chdev_cmd_read     ,
+exit_devfs_read         , exit_devfs_read         - exit_txt_read           ,
+exit_sys_read           , exit_sys_read           - exit_devfs_read         );
 #endif
  
