Changeset 433 for trunk/kernel/syscalls/sys_write.c
- Timestamp:
- Feb 14, 2018, 3:40:19 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/syscalls/sys_write.c
r421 r433 46 46 reg_t save_sr; // required to enable IRQs during syscall 47 47 48 #if CONFIG_WRITE_DEBUG 48 thread_t * this = CURRENT_THREAD; 49 process_t * process = this->process; 50 51 #if CONFIG_DEBUG_SYS_WRITE 49 52 uint32_t tm_start; 50 53 uint32_t tm_end; 51 54 tm_start = hal_get_cycles(); 55 if( CONFIG_DEBUG_SYS_WRITE < tm_start ) 56 printk("\n[DBG] %s : thread %x / process %x / vaddr %x / count %d / cycle %d\n", 57 __FUNCTION__, this, process->pid, vaddr, count, (uint32_t)tm_start ); 52 58 #endif 53 54 thread_t * this = CURRENT_THREAD;55 process_t * process = this->process;56 59 57 60 // check file_id argument 58 61 if( file_id >= CONFIG_PROCESS_FILE_MAX_NR ) 59 62 { 60 printk("\n[ERROR] in %s : illegal file descriptor index\n", __FUNCTION__ ); 63 64 #if CONFIG_DEBUG_SYSCALLS_ERROR 65 printk("\n[ERROR] in %s : illegal file descriptor index\n", __FUNCTION__ ); 66 #endif 61 67 this->errno = EBADFD; 62 68 return -1; … … 68 74 if ( error ) 69 75 { 70 printk("\n[ERROR] in %s : user buffer unmapped = %x\n", 71 __FUNCTION__ , (intptr_t)vaddr ); 76 77 #if CONFIG_DEBUG_SYSCALLS_ERROR 78 printk("\n[ERROR] in %s : user buffer unmapped = %x\n", __FUNCTION__ , (intptr_t)vaddr ); 79 #endif 72 80 this->errno = EINVAL; 73 81 return -1; … … 82 90 if( file_xp == XPTR_NULL ) 83 91 { 84 printk("\n[ERROR] in %s : undefined file descriptor index = %d in process %x\n", 85 __FUNCTION__ , file_id , process->pid ); 92 93 #if CONFIG_DEBUG_SYSCALLS_ERROR 94 printk("\n[ERROR] in %s : undefined file descriptor index = %d in process %x\n", 95 __FUNCTION__ , file_id , process->pid ); 96 #endif 86 97 this->errno = EBADFD; 87 98 return -1; … … 103 114 if( (attr & FD_ATTR_WRITE_ENABLE) == 0 ) 104 115 { 105 printk("\n[ERROR] in %s : file %d not writable in process %x\n", 106 __FUNCTION__ , file_id , process->pid ); 116 117 #if CONFIG_DEBUG_SYSCALLS_ERROR 118 printk("\n[ERROR] in %s : file %d not writable in process %x\n", 119 __FUNCTION__ , file_id , process->pid ); 120 #endif 107 121 this->errno = EBADFD; 108 122 return -1; … … 131 145 if( nbytes != count ) 132 146 { 133 printk("\n[ERROR] in %s cannot write data to file %d in process %x\n", 134 __FUNCTION__ , file_id , process->pid ); 147 148 #if CONFIG_DEBUG_SYSCALLS_ERROR 149 printk("\n[ERROR] in %s cannot write data to file %d in process %x\n", 150 __FUNCTION__ , file_id , process->pid ); 151 #endif 135 152 this->errno = error; 136 153 return -1; … … 142 159 hal_fence(); 143 160 144 #if CONFIG_ WRITE_DEBUG161 #if CONFIG_DEBUG_SYS_WRITE 145 162 tm_end = hal_get_cycles(); 146 printk("\n[DBG] %s : core[%x,%d] / thread %x in process %x / cycle %d\n" 163 if( CONFIG_DEBUG_SYS_WRITE < tm_end ) 164 printk("\n[DBG] %s : thread %x in process %x / cycle %d\n" 147 165 "nbytes = %d / first byte = %c / file_id = %d / cost = %d\n", 148 __FUNCTION__ , local_cxy , this->core->lid , this->trdid , this->process->pid , 149 (uint32_t)tm_start , nbytes , *((char *)(intptr_t)paddr) , file_id , 150 (uint32_t)(tm_end - tm_start) ); 166 __FUNCTION__, this, process->pid, (uint32_t)tm_start, 167 nbytes, *((char *)(intptr_t)paddr) , file_id , (uint32_t)(tm_end - tm_start) ); 151 168 #endif 152 169 153 #if (CONFIG_WRITE_DEBUG & 0x1)154 printk("\n@@@@@@@@@@@@ timing to write character %c\n"155 " - enter_sys_write = %d\n"156 " - exit_sys_write = %d\n",157 *((char *)(intptr_t)paddr) , (uint32_t)tm_start , (uint32_t)tm_end );158 #endif159 160 170 return nbytes; 161 171
Note: See TracChangeset
for help on using the changeset viewer.