Changeset 440 for trunk/kernel/syscalls/sys_display.c
- Timestamp:
- May 3, 2018, 5:51:22 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/syscalls/sys_display.c
r438 r440 2 2 * sys_display.c - display the current state of a kernel structure on TXT0 3 3 * 4 * Author Alain Greiner (2016,2017 )4 * Author Alain Greiner (2016,2017,2018) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 38 38 { 39 39 40 error_t error; 41 vseg_t * vseg; 42 43 thread_t * this = CURRENT_THREAD; 44 process_t * process = this->process; 45 40 46 #if DEBUG_SYS_DISPLAY 41 47 uint64_t tm_start; 42 48 uint64_t tm_end; 43 thread_t * this;44 this = CURRENT_THREAD;45 49 tm_start = hal_get_cycles(); 46 50 if( DEBUG_SYS_DISPLAY < tm_start ) … … 49 53 #endif 50 54 55 //////////////////////////// 51 56 if( type == DISPLAY_STRING ) 52 57 { 53 paddr_t paddr;54 58 char kbuf[256]; 55 59 uint32_t length; 56 60 57 61 char * string = (char *)arg0; 58 62 59 63 // check string in user space 60 if( vmm_v2p_translate( false , string , &paddr ) ) 61 { 62 printk("\n[ERROR] in %s : string buffer %x unmapped\n", 63 __FUNCTION__ , string ); 64 error = vmm_get_vseg( process , (intptr_t)arg0 , &vseg ); 65 66 if( error ) 67 { 68 69 #if DEBUG_SYSCALLS_ERROR 70 printk("\n[ERROR] in %s : string buffer %x unmapped / thread %x / process %x\n", 71 __FUNCTION__ , (intptr_t)arg0 , this->trdid , process->pid ); 72 #endif 73 this->errno = EINVAL; 64 74 return -1; 65 75 } … … 67 77 // ckeck string length 68 78 length = hal_strlen_from_uspace( string ); 79 69 80 if( length >= 256 ) 70 81 { 71 printk("\n[ERROR] in %s : string length %d too large\n", 72 __FUNCTION__ , length ); 73 return -1; 74 } 75 76 // copy string in kernel space 82 83 #if DEBUG_SYSCALLS_ERROR 84 printk("\n[ERROR] in %s : string length %d too large / thread %x / process %x\n", 85 __FUNCTION__ , length , this->trdid , process->pid ); 86 #endif 87 this->errno = EINVAL; 88 return -1; 89 } 90 91 // copy string to kernel space 77 92 hal_strcpy_from_uspace( kbuf , string , 256 ); 78 93 79 94 // print message on TXT0 kernel terminal 80 printk("\n[USER] %s / cycle %d\n", kbuf, (uint32_t)hal_get_cycles() ); 81 } 95 printk("\n%s / cycle %d\n", kbuf, (uint32_t)hal_get_cycles() ); 96 } 97 ////////////////////////////// 82 98 else if( type == DISPLAY_VMM ) 83 99 { … … 89 105 if( process_xp == XPTR_NULL ) 90 106 { 91 printk("\n[ERROR] in %s : undefined PID %x\n", 92 __FUNCTION__ , pid ); 107 108 #if DEBUG_SYSCALLS_ERROR 109 printk("\n[ERROR] in %s : undefined pid argument %d / thread %x / process %x\n", 110 __FUNCTION__ , pid , this->trdid , process->pid ); 111 #endif 112 this->errno = EINVAL; 93 113 return -1; 94 114 } … … 108 128 } 109 129 } 130 //////////////////////////////// 110 131 else if( type == DISPLAY_SCHED ) 111 132 { … … 113 134 lid_t lid = (lid_t)arg1; 114 135 115 // check c lusterargument136 // check cxy argument 116 137 if( cluster_is_undefined( cxy ) ) 117 138 { 118 printk("\n[ERROR] in %s : undefined cluster identifier %x\n", 119 __FUNCTION__ , cxy ); 120 return -1; 121 } 122 123 // check core argument 139 140 #if DEBUG_SYSCALLS_ERROR 141 printk("\n[ERROR] in %s : illegal cxy argument %x / thread %x / process %x\n", 142 __FUNCTION__ , cxy , this->trdid , process->pid ); 143 #endif 144 this->errno = EINVAL; 145 return -1; 146 } 147 148 // check lid argument 124 149 if( lid >= LOCAL_CLUSTER->cores_nr ) 125 150 { 126 printk("\n[ERROR] in %s : undefined local index %d\n", 127 __FUNCTION__ , lid ); 151 152 #if DEBUG_SYSCALLS_ERROR 153 printk("\n[ERROR] in %s : illegal lid argument %x / thread %x / process %x\n", 154 __FUNCTION__ , lid , this->trdid , process->pid ); 155 #endif 156 this->errno = EINVAL; 128 157 return -1; 129 158 } … … 138 167 } 139 168 } 169 //////////////////////////////////////////// 140 170 else if( type == DISPLAY_CLUSTER_PROCESSES ) 141 171 { 142 172 cxy_t cxy = (cxy_t)arg0; 143 173 144 // check c lusterargument174 // check cxy argument 145 175 if( cluster_is_undefined( cxy ) ) 146 176 { 147 printk("\n[ERROR] in %s : undefined cluster identifier %x\n", 148 __FUNCTION__ , cxy ); 177 178 #if DEBUG_SYSCALLS_ERROR 179 printk("\n[ERROR] in %s : illegal cxy argument %x / thread %x / process %x\n", 180 __FUNCTION__ , cxy , this->trdid , process->pid ); 181 #endif 182 this->errno = EINVAL; 149 183 return -1; 150 184 } … … 152 186 cluster_processes_display( cxy ); 153 187 } 188 //////////////////////////////////////// 154 189 else if( type == DISPLAY_TXT_PROCESSES ) 155 190 { … … 159 194 if( txt_id >= LOCAL_CLUSTER->nb_txt_channels ) 160 195 { 161 printk("\n[ERROR] in %s : undefined TXT channel %x\n", 162 __FUNCTION__ , txt_id ); 196 197 #if DEBUG_SYSCALLS_ERROR 198 printk("\n[ERROR] in %s : illegal txt_id argument %d / thread %x / process %x\n", 199 __FUNCTION__ , txt_id , this->trdid , process->pid ); 200 #endif 201 this->errno = EINVAL; 163 202 return -1; 164 203 } … … 166 205 process_txt_display( txt_id ); 167 206 } 207 ////////////////////////////// 168 208 else if( type == DISPLAY_VFS ) 169 209 { 170 // call kernel function171 process_t * process = CURRENT_THREAD->process;172 210 vfs_display( process->vfs_root_xp ); 173 211 } 212 //////////////////////////////// 174 213 else if( type == DISPLAY_CHDEV ) 175 214 { 176 215 chdev_dir_display(); 177 216 } 217 //// 178 218 else 179 219 { 180 printk("\n[ERROR] in %s : undefined display type %x\n", 181 __FUNCTION__ , type ); 220 221 #if DEBUG_SYSCALLS_ERROR 222 printk("\n[ERROR] in %s : undefined display type %x / thread %x / process %x\n", 223 __FUNCTION__ , type , this->trdid , process->pid ); 224 #endif 225 this->errno = EINVAL; 182 226 return -1; 183 227 }
Note: See TracChangeset
for help on using the changeset viewer.