Changeset 433 for trunk/kernel/syscalls/sys_display.c
- Timestamp:
- Feb 14, 2018, 3:40:19 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/syscalls/sys_display.c
r421 r433 25 25 #include <hal_uspace.h> 26 26 #include <errno.h> 27 #include <vmm.h> 27 28 #include <cluster.h> 28 29 #include <thread.h> 29 30 #include <process.h> 31 #include <string.h> 30 32 31 33 … … 35 37 reg_t arg1 ) 36 38 { 39 // get thread, process and core 40 thread_t * this = CURRENT_THREAD; 41 process_t * process = this->process; 42 core_t * core = this->core; 43 44 #if CONFIG_DEBUG_SYS_DISPLAY 45 uint64_t tm_start; 46 uint64_t tm_end; 47 tm_start = hal_get_cycles(); 48 if( CONFIG_DEBUG_SYS_DISPLAY < tm_start ) 49 printk("\n[DBG] %s : thread %d enter / process %x / cycle = %d\n", 50 __FUNCTION__, this, process->pid, (uint32_t)tm_start ); 51 #endif 52 37 53 if( type == DISPLAY_STRING ) 38 54 { 39 55 paddr_t paddr; 40 56 char kbuf[256]; 57 uint32_t length; 41 58 42 59 char * string = (char *)arg0; 43 60 44 61 // check string in user space 45 if( vmm_v2p_translate( false , string , &paddr ) ) return -1; 62 if( vmm_v2p_translate( false , string , &paddr ) ) 63 { 64 printk("\n[ERROR] in %s : string buffer %x unmapped\n", 65 __FUNCTION__ , string ); 66 return -1; 67 } 46 68 47 69 // ckeck string length 48 if( hal_strlen_from_uspace( string ) >= 256 ) return -1; 70 length = hal_strlen_from_uspace( string ); 71 if( length >= 256 ) 72 { 73 printk("\n[ERROR] in %s : string length %d too large\n", 74 __FUNCTION__ , length ); 75 return -1; 76 } 49 77 50 78 // copy string in kernel space 51 79 hal_strcpy_from_uspace( kbuf , string , 256 ); 52 53 // get thread, process and core54 thread_t * this = CURRENT_THREAD;55 process_t * process = this->process;56 core_t * core = this->core;57 80 58 81 // print message on TXT0 kernel terminal … … 60 83 this->trdid , process->pid , local_cxy, core->lid , 61 84 (uint32_t)hal_get_cycles() , kbuf ); 62 63 return 0;64 85 } 65 86 else if( type == DISPLAY_VMM ) … … 70 91 xptr_t process_xp = cluster_get_reference_process_from_pid( pid ); 71 92 72 if( process_xp == XPTR_NULL ) return -1; 93 if( process_xp == XPTR_NULL ) 94 { 95 printk("\n[ERROR] in %s : undefined PID %x\n", 96 __FUNCTION__ , pid ); 97 return -1; 98 } 73 99 74 100 // get cluster and local pointer on process … … 85 111 rpc_vmm_display_client( process_cxy , process_ptr , true ); 86 112 } 87 88 return 0;89 113 } 90 114 else if( type == DISPLAY_SCHED ) … … 94 118 95 119 // check cluster argument 96 if( cluster_is_undefined( cxy ) ) return -1; 120 if( cluster_is_undefined( cxy ) ) 121 { 122 printk("\n[ERROR] in %s : undefined cluster identifier %x\n", 123 __FUNCTION__ , cxy ); 124 return -1; 125 } 97 126 98 127 // check core argument 99 if( lid >= LOCAL_CLUSTER->cores_nr ) return -1; 128 if( lid >= LOCAL_CLUSTER->cores_nr ) 129 { 130 printk("\n[ERROR] in %s : undefined local index %d\n", 131 __FUNCTION__ , lid ); 132 return -1; 133 } 100 134 101 // call kernel function102 135 if( cxy == local_cxy ) 103 136 { … … 108 141 rpc_sched_display_client( cxy , lid ); 109 142 } 110 111 return 0;112 143 } 113 144 else if( type == DISPLAY_PROCESS ) … … 116 147 117 148 // check cluster argument 118 if( cluster_is_undefined( cxy ) ) return -1; 149 if( cluster_is_undefined( cxy ) ) 150 { 151 printk("\n[ERROR] in %s : undefined cluster identifier %x\n", 152 __FUNCTION__ , cxy ); 153 return -1; 154 } 119 155 120 // call kernel function121 156 cluster_processes_display( cxy ); 122 123 return 0;124 157 } 125 158 else if( type == DISPLAY_VFS ) … … 128 161 process_t * process = CURRENT_THREAD->process; 129 162 vfs_display( process->vfs_root_xp ); 130 131 return 0;132 163 } 133 164 else if( type == DISPLAY_CHDEV ) 134 165 { 135 // call kernel function136 166 chdev_dir_display(); 167 } 168 else 169 { 170 printk("\n[ERROR] in %s : undefined display type %x\n", 171 __FUNCTION__ , type ); 172 return -1; 173 } 137 174 138 return 0; 139 } 140 else return -1; 175 #if CONFIG_DEBUG_SYS_DISPLAY 176 tm_end = hal_get_cycles(); 177 if( CONFIG_DEBUG_SYS_DISPLAY < tm_end ) 178 printk("\n[DBG] %s : thread %x exit / process %x / cost = %d / cycle %d\n", 179 __FUNCTION__, this, process->pid, (uint32_t)(tm_end - tm_start) , (uint32_t)tm_end ); 180 #endif 141 181 142 } // end sys_get_sched() 182 return 0; 183 184 } // end sys_display()
Note: See TracChangeset
for help on using the changeset viewer.