Changeset 294 for soft/giet_vm/giet_kernel/sys_handler.c
- Timestamp:
- Mar 26, 2014, 6:10:01 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_kernel/sys_handler.c
r267 r294 35 35 &_timer_start, /* 0x04 */ 36 36 &_timer_stop, /* 0x05 */ 37 &_ sys_ukn,/* 0x06 */38 &_ sys_ukn,/* 0x07 */37 &_tty_get_lock, /* 0x06 */ 38 &_tty_release_lock, /* 0x07 */ 39 39 &_heap_info, /* 0x08 */ 40 40 &_local_task_id, /* 0x09 */ … … 49 49 &_fb_sync_read, /* 0x11 */ 50 50 &_thread_id, /* 0x12 */ 51 &_ tty_get_release_lock,/* 0x13 */51 &_sys_ukn, /* 0x13 */ 52 52 &_sys_ukn, /* 0x14 */ 53 53 &_sys_ukn, /* 0x15 */ … … 103 103 void _sys_ukn() 104 104 { 105 unsigned int epc; 106 asm volatile("mfc0 %0, $14" : "=r" (epc)); 107 108 _tty_get_lock( 0 ); 109 _puts("\n\n!!! Undefined System Call !!!\n"); 110 _puts("\nEPC = "); 111 _putx(epc); 112 _tty_release_lock( 0 ); 105 _printf("\n\n[GIET ERROR] Undefined System Call / EPC = %x\n", _get_epc() ); 113 106 _exit(); 114 107 } 115 108 116 109 //////////////////////////////////////////////////////////////////////////// 117 // _exit()118 110 // Task suicide... after printing a death message. 119 111 //////////////////////////////////////////////////////////////////////////// 120 void _task_exit() 121 { 122 unsigned int date = _get_proctime(); 123 unsigned int proc_id = _get_procid(); 124 unsigned int task_id = _get_context_slot(CTX_LTID_ID); 112 void _task_exit( char* string ) 113 { 114 unsigned int date = _get_proctime(); 115 unsigned int proc_id = _get_procid(); 116 unsigned int cluster_xy = proc_id / NB_PROCS_MAX; 117 unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1); 118 unsigned int x = cluster_xy >> Y_WIDTH; 119 unsigned int lpid = proc_id % NB_PROCS_MAX; 120 unsigned int task_id = _get_context_slot(CTX_LTID_ID); 125 121 126 122 // print death message 127 _tty_get_lock( 0 ); 128 _puts("\n[GIET] Exit task "); 129 _putd(task_id); 130 _puts(" on processor "); 131 _putd(proc_id); 132 _puts(" at cycle "); 133 _putd(date); 134 _puts("\n\n"); 135 _tty_release_lock( 0 ); 123 _printf("\n[GIET] Exit task %d on processor[%d,%d,%d] at cycle %d" 124 "\n Cause : %s\n\n", 125 task_id, x, y, lpid, date, string ); 136 126 137 127 // goes to sleeping state … … 143 133 144 134 ////////////////////////////////////////////////////////////////////////////// 145 // _procnumber()146 135 // returns in buffer argument the number of processors in the cluster 147 136 // specified by the cluster_id argument. … … 165 154 166 155 ///////////////////////////////////////////////////////////////////////////// 167 // _local_task_id()168 156 // Returns current task local index. 169 157 ///////////////////////////////////////////////////////////////////////////// … … 174 162 175 163 ///////////////////////////////////////////////////////////////////////////// 176 // _global_task_id()177 164 // Returns current task global index. 178 165 ///////////////////////////////////////////////////////////////////////////// … … 183 170 184 171 ///////////////////////////////////////////////////////////////////////////// 185 // _thread_id()186 172 // Returns current thread index. 187 173 ///////////////////////////////////////////////////////////////////////////// … … 192 178 193 179 ///////////////////////////////////////////////////////////////////////////// 194 // _tty_get_release_lock(int val)195 // Get or release the hardware TTY lock depending on val (0: get,1: release)196 /////////////////////////////////////////////////////////////////////////////197 int _tty_get_release_lock(unsigned int val)198 {199 unsigned int channel = _get_context_slot(CTX_TTY_ID);200 201 if ( val == 0 ) _tty_get_lock(channel);202 else if ( val == 1 ) _tty_release_lock(channel);203 else return -1; // Wrong action204 205 return 0;206 }207 208 /////////////////////////////////////////////////////////////////////////////209 // _get_vobj()210 180 // This function writes in res_vobj a pointer on a vobj 211 181 // identified by the (vspace_name / vobj_name ) couple. 212 // The vobj_type argument is here only for the purpose of checking . 213 // returns 0: success, else: failed. 182 // returns 0 if success, >0 if not found 214 183 ///////////////////////////////////////////////////////////////////////////// 215 184 int _get_vobj( char* vspace_name, 216 185 char* vobj_name, 217 unsigned int vobj_type,218 186 mapping_vobj_t** res_vobj ) 219 187 { … … 237 205 if (_strncmp(vobj[vobj_id].name, vobj_name, 31) == 0) 238 206 { 239 if (vobj[vobj_id].type != vobj_type)240 {241 _tty_get_lock( 0 );242 _puts("*** Error in _get_obj: wrong type\n");243 _tty_release_lock( 0 );244 return -1; // wrong type245 }246 207 *res_vobj = &vobj[vobj_id]; 247 208 return 0; … … 250 211 } 251 212 } 252 _tty_get_lock( 0 ); 253 _puts("*** Error in _get_obj: object not found\n"); 254 _tty_release_lock( 0 ); 255 256 return -2; //not found 257 } 258 259 ///////////////////////////////////////////////////////////////////////////// 260 // _vobj_get_vbase() 213 return 1; //not found 214 } 215 216 ///////////////////////////////////////////////////////////////////////////// 261 217 // This function writes in vobj_vaddr the virtual base address of a vobj 262 218 // identified by the (vspace_name / vobj_name ) couple. 263 // The vobj_type argument is here only for the purpose of checking . 264 // returns 0: success, else: failed. 219 // returns 0 if success, >0 if not found 265 220 ///////////////////////////////////////////////////////////////////////////// 266 221 unsigned int _vobj_get_vbase( char* vspace_name, 267 222 char* vobj_name, 268 unsigned int vobj_type, 269 unsigned int* vobj_vaddr ) 223 unsigned int* vobj_vbase ) 270 224 { 271 225 mapping_vobj_t* res_vobj; 272 226 unsigned int ret; 273 if ((ret = _get_vobj(vspace_name, vobj_name, vobj_type,&res_vobj)))227 if ((ret = _get_vobj(vspace_name, vobj_name, &res_vobj))) 274 228 { 275 229 return ret; 276 230 } 277 *vobj_v addr= res_vobj->vaddr;231 *vobj_vbase = res_vobj->vaddr; 278 232 return 0; 279 233 } 280 234 281 235 ///////////////////////////////////////////////////////////////////////////// 282 // _vobj_get_length() 283 // This function writes in vobj_length the virtual base address of a vobj 236 // This function writes in vobj_length the length of a vobj 284 237 // identified by the (vspace_name / vobj_name ) couple. 285 // The vobj_type argument is here only for the purpose of checking . 286 // returns 0: success, else: failed. 238 // returns 0 if success, >0 if not found 287 239 ///////////////////////////////////////////////////////////////////////////// 288 240 unsigned int _vobj_get_length( char* vspace_name, 289 241 char* vobj_name, 290 unsigned int vobj_type,291 242 unsigned int* vobj_length ) 292 243 { 293 244 mapping_vobj_t * res_vobj; 294 245 unsigned int ret; 295 if ((ret = _get_vobj(vspace_name, vobj_name, vobj_type,&res_vobj)))246 if ((ret = _get_vobj(vspace_name, vobj_name, &res_vobj))) 296 247 { 297 248 return ret; … … 301 252 } 302 253 303 304 //////////////////////////////////////////////////////////////// 305 // _context_switch() 306 // This functions masks interruptions before calling _ctx_switch 307 // (They are usually masked when we receive a isr_switch interrupt 308 // because we execute ISRs with interrupt masked) 309 //////////////////////////////////////////////////////////////// 254 //////////////////////////////////////////////////////////////////////////// 255 // This sysrem function deschedule the requestint task. 256 // It mask interrupts before calling the _ctx_switch, and restore it 257 // when the task is rescheduled. 258 //////////////////////////////////////////////////////////////////////////// 310 259 void _context_switch() 311 260 { 312 _it_disable(); 261 unsigned int save_sr; 262 263 _it_disable( &save_sr ); 313 264 _ctx_switch(); 314 } 315 265 _it_restore( &save_sr ); 266 } 316 267 317 268 // Local Variables:
Note: See TracChangeset
for help on using the changeset viewer.