Changeset 408 for trunk/hal/tsar_mips32/core/hal_exception.c
- Timestamp:
- Dec 5, 2017, 4:20:07 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/tsar_mips32/core/hal_exception.c
r407 r408 99 99 xcode_values_t; 100 100 101 //////////////////////////////////////////////////// 102 static char * hal_mmu_exception_str( uint32_t code ) 103 { 104 if ( code == MMU_WRITE_PT1_UNMAPPED ) return "WRITE_PT1_UNMAPPED"; 105 else if( code == MMU_WRITE_PT2_UNMAPPED ) return "WRITE_PT2_UNMAPPED"; 106 else if( code == MMU_WRITE_PRIVILEGE_VIOLATION ) return "WRITE_PRIVILEGE_VIOLATION"; 107 else if( code == MMU_WRITE_ACCESS_VIOLATION ) return "WRITE_ACCESS_VIOLATION"; 108 else if( code == MMU_WRITE_UNDEFINED_XTN ) return "WRITE_UNDEFINED_XTN"; 109 else if( code == MMU_WRITE_PT1_ILLEGAL_ACCESS ) return "WRITE_PT1_ILLEGAL_ACCESS"; 110 else if( code == MMU_WRITE_PT2_ILLEGAL_ACCESS ) return "WRITE_PT2_ILLEGAL_ACCESS"; 111 else if( code == MMU_WRITE_DATA_ILLEGAL_ACCESS ) return "WRITE_DATA_ILLEGAL_ACCESS"; 112 else if( code == MMU_READ_PT1_UNMAPPED ) return "READ_PT1_UNMAPPED"; 113 else if( code == MMU_READ_PT2_UNMAPPED ) return "READ_PT2_UNMAPPED"; 114 else if( code == MMU_READ_PRIVILEGE_VIOLATION ) return "READ_PRIVILEGE_VIOLATION"; 115 else if( code == MMU_READ_EXEC_VIOLATION ) return "READ_EXEC_VIOLATION"; 116 else if( code == MMU_READ_UNDEFINED_XTN ) return "READ_UNDEFINED_XTN"; 117 else if( code == MMU_READ_PT1_ILLEGAL_ACCESS ) return "READ_PT1_ILLEGAL_ACCESS"; 118 else if( code == MMU_READ_PT2_ILLEGAL_ACCESS ) return "READ_PT2_ILLEGAL_ACCESS"; 119 else if( code == MMU_READ_DATA_ILLEGAL_ACCESS ) return "READ_DATA_ILLEGAL_ACCESS"; 120 else return "undefined"; 121 } 122 101 123 ////////////////////////////////////////////////////////////////////////////////////////// 102 124 // This function is called when a FPU Coprocessor Unavailable exception has been … … 120 142 if( core->fpu_owner != this ) 121 143 { 122 hal_fpu_context_save ( core->fpu_owner->fpu_context);144 hal_fpu_context_save( XPTR( local_cxy , core->fpu_owner ) ); 123 145 } 124 146 } … … 179 201 } 180 202 181 excp_dmsg("\n[DBG] %s : core[%x,%d] / is_ins %d / code %x / vaddr %x\n", 182 __FUNCTION__ , local_cxy , this->core->lid , is_ins, excp_code, bad_vaddr ); 203 // @@@ 204 thread_t * parent = (thread_t *)0xa4000; 205 uint32_t cond = (this == 0xe0000) && (hal_time_stamp() > 5380000); 206 207 if( cond ) hal_gpt_display( this->process ); 208 if( cond ) hal_gpt_display( parent->process ); 209 if( cond ) printk("\n[DBG] %s : core[%x,%d] / is_ins %d / %s / vaddr %x\n", 210 __FUNCTION__ , local_cxy , this->core->lid , is_ins, 211 hal_mmu_exception_str(excp_code) , bad_vaddr ); 183 212 184 213 // analyse exception code … … 217 246 return EXCP_USER_ERROR; 218 247 } 219 case MMU_WRITE_ACCESS_VIOLATION: // user error or Copy-on-Write248 case MMU_WRITE_ACCESS_VIOLATION: // user error, or Copy-on-Write 220 249 { 221 250 // access page table to get GPT_COW flag 222 251 bool_t cow = hal_gpt_pte_is_cow( &(process->vmm.gpt), 223 bad_vaddr >> CONFIG_PPM_PAGE_SHIFT ); // vpn252 bad_vaddr >> CONFIG_PPM_PAGE_SHIFT ); 224 253 225 254 if( cow ) // Copy-on-Write 226 255 { 227 256 // try to allocate and copy the page 228 error = vmm_ copy_on_write( process,229 bad_vaddr >> CONFIG_PPM_PAGE_SHIFT ); // vpn257 error = vmm_handle_cow( process, 258 bad_vaddr >> CONFIG_PPM_PAGE_SHIFT ); 230 259 if( error ) 231 260 { … … 238 267 { 239 268 240 excp_dmsg("\n[DBG] %s : core[%x,%d] / copy-on-write handled for vaddr = %x\n",269 if( cond ) printk("\n[DBG] %s : core[%x,%d] / copy-on-write handled for vaddr = %x\n", 241 270 __FUNCTION__ , local_cxy , this->core->lid , bad_vaddr ); 242 271 … … 274 303 ////////////////////////////////////////////////////////////////////////////////////////// 275 304 // @ this : pointer on faulty thread descriptor. 276 // @ regs_tbl: pointer on register array.305 // @ uzone : pointer on register array. 277 306 // @ error : EXCP_USER_ERROR or EXCP_KERNEL_PANIC 278 307 ////////////////////////////////////////////////////////////////////////////////////////// 279 308 static void hal_exception_dump( thread_t * this, 280 reg_t * regs_tbl,309 reg_t * uzone, 281 310 error_t error ) 282 311 { 283 uint32_t save_sr; 284 core_t * core = this->core; 312 uint32_t save_sr; 313 core_t * core = this->core; 314 process_t * process = this->process; 285 315 286 316 // get pointers on TXT0 chdev … … 297 327 if( error == EXCP_USER_ERROR ) 298 328 { 299 nolock_printk("\n=== ====== USER ERROR / core[%x,%d] / cycle %d ==============\n",300 local_cxy, core->lid , (uint32_t)hal_get_cycles() );329 nolock_printk("\n=== USER ERROR / trdid %x / pid %x / core[%x,%d] / cycle %d ===\n", 330 this->trdid, process->pid, local_cxy, core->lid , (uint32_t)hal_get_cycles() ); 301 331 } 302 332 else 303 333 { 304 nolock_printk("\n=== ==== KERNEL PANIC / core[%x,%d] / cycle %d ==============\n",305 local_cxy, core->lid , (uint32_t)hal_get_cycles() );334 nolock_printk("\n=== KERNEL PANIC / trdid %x / pid %x / core[%x,%d] / cycle %d ===\n", 335 this->trdid, process->pid, local_cxy, core->lid , (uint32_t)hal_get_cycles() ); 306 336 } 307 337 308 nolock_printk(" thread type = %s / trdid = %x / pid %x / core[%x,%d]\n" 309 " local locks = %d / remote locks = %d / blocked_vector = %X\n\n", 310 thread_type_str(this->type), this->trdid, this->process->pid, local_cxy, 311 this->core->lid, this->local_locks, this->remote_locks, this->blocked ); 312 313 nolock_printk("cp0_cr %X cp0_epc %X cp0_sr %X cp2_mode %X\n", 314 regs_tbl[UZ_CR], regs_tbl[UZ_EPC], regs_tbl[UZ_SR], regs_tbl[UZ_MODE]); 315 316 nolock_printk("at_01 %X v0_2 %X v1_3 %X a0_4 %X a1_5 %X\n", 317 regs_tbl[UZ_AT],regs_tbl[UZ_V0],regs_tbl[UZ_V1],regs_tbl[UZ_A0],regs_tbl[UZ_A1]); 318 319 nolock_printk("a2_6 %X a3_7 %X t0_8 %X t1_9 %X t2_10 %X\n", 320 regs_tbl[UZ_A2],regs_tbl[UZ_A3],regs_tbl[UZ_T0],regs_tbl[UZ_T1],regs_tbl[UZ_T2]); 338 nolock_printk("local locks = %d / remote locks = %d / blocked_vector = %X\n\n", 339 this->local_locks, this->remote_locks, this->blocked ); 340 341 nolock_printk("c0_cr %X c0_epc %X c0_sr %X c0_th %X\n", 342 uzone[UZ_CR], uzone[UZ_EPC], uzone[UZ_SR], uzone[UZ_TH] ); 343 344 nolock_printk("c2_mode %X c2_ptpr %X\n", 345 uzone[UZ_MODE], uzone[UZ_PTPR] ); 346 347 nolock_printk("at_01 %X v0_2 %X v1_3 %X a0_4 %X a1_5 %X\n", 348 uzone[UZ_AT], uzone[UZ_V0], uzone[UZ_V1], uzone[UZ_A0], uzone[UZ_A1] ); 349 350 nolock_printk("a2_6 %X a3_7 %X t0_8 %X t1_9 %X t2_10 %X\n", 351 uzone[UZ_A2], uzone[UZ_A3], uzone[UZ_T0], uzone[UZ_T1], uzone[UZ_T2] ); 321 352 322 nolock_printk("t3_11 %X t4_12 %X t5_13%X t6_14 %X t7_15 %X\n",323 regs_tbl[UZ_T3],regs_tbl[UZ_T4],regs_tbl[UZ_T5],regs_tbl[UZ_T6],regs_tbl[UZ_T7]);324 325 nolock_printk("s0_16 %X s1_17 %X s2_18%X s3_19 %X s4_20 %X\n",326 regs_tbl[UZ_S0],regs_tbl[UZ_S1],regs_tbl[UZ_S2],regs_tbl[UZ_S3],regs_tbl[UZ_S4]);353 nolock_printk("t3_11 %X t4_12 %X t5_13 %X t6_14 %X t7_15 %X\n", 354 uzone[UZ_T3], uzone[UZ_T4], uzone[UZ_T5], uzone[UZ_T6], uzone[UZ_T7] ); 355 356 nolock_printk("s0_16 %X s1_17 %X s2_18 %X s3_19 %X s4_20 %X\n", 357 uzone[UZ_S0], uzone[UZ_S1], uzone[UZ_S2], uzone[UZ_S3], uzone[UZ_S4] ); 327 358 328 nolock_printk("s5_21 %X s6_22 %X s7_23%X s8_24 %X ra_25 %X\n",329 regs_tbl[UZ_S5],regs_tbl[UZ_S6],regs_tbl[UZ_S7],regs_tbl[UZ_T8],regs_tbl[UZ_T9]);330 331 nolock_printk("gp_28 %X sp_29 %X S8_30%X ra_31 %X\n",332 regs_tbl[UZ_GP],regs_tbl[UZ_SP],regs_tbl[UZ_S8],regs_tbl[UZ_RA]);359 nolock_printk("s5_21 %X s6_22 %X s7_23 %X s8_24 %X ra_25 %X\n", 360 uzone[UZ_S5], uzone[UZ_S6], uzone[UZ_S7], uzone[UZ_T8], uzone[UZ_T9] ); 361 362 nolock_printk("gp_28 %X sp_29 %X S8_30 %X ra_31 %X\n", 363 uzone[UZ_GP], uzone[UZ_SP], uzone[UZ_S8], uzone[UZ_RA] ); 333 364 334 365 // release the lock … … 337 368 } // end hal_exception_dump() 338 369 339 340 /////////////////////////////////////////////////////////////////////////////// 341 // TODO replace the hal_core_sleep() by the generic panic() function. 342 /////////////////////////////////////////////////////////////////////////////// 343 void hal_do_exception( thread_t * this, 344 reg_t * regs_tbl ) 345 { 346 error_t error; 347 uint32_t excCode; // 4 bits XCODE from CP0_CR 370 /////////////////////// 371 void hal_do_exception() 372 { 373 uint32_t * uzone; 374 thread_t * this; 375 error_t error; 376 uint32_t excCode; // 4 bits XCODE from CP0_CR 377 378 // get pointer on faulty thread uzone 379 this = CURRENT_THREAD; 380 uzone = (uint32_t *)CURRENT_THREAD->uzone; 348 381 349 382 // get 4 bits XCODE from CP0_CR register 350 excCode = ( regs_tbl[UZ_CR] >> 2) & 0xF;383 excCode = (uzone[UZ_CR] >> 2) & 0xF; 351 384 352 385 excp_dmsg("\n[DBG] %s : core[%x,%d] / thread %x in process %x / xcode %x / cycle %d\n", 353 386 __FUNCTION__, local_cxy, this->core->lid, this->trdid, 354 this->process->pid, excCode, (uint32_t)hal_get_cycle () );387 this->process->pid, excCode, (uint32_t)hal_get_cycles() ); 355 388 356 389 switch(excCode) … … 368 401 case XCODE_CPU: // can be non fatal 369 402 { 370 if( (( regs_tbl[UZ_CR] >> 28) & 0x3) == 1 )// unavailable FPU403 if( ((uzone[UZ_CR] >> 28) & 0x3) == 1 ) // unavailable FPU 371 404 { 372 405 error = hal_fpu_exception( this ); … … 395 428 if( error == EXCP_USER_ERROR ) // user error => kill user process 396 429 { 397 hal_exception_dump( this , regs_tbl, error );430 hal_exception_dump( this , uzone , error ); 398 431 399 432 // FIXME : replace this loop by sys_kill() … … 403 436 else if( error == EXCP_KERNEL_PANIC ) // kernel error => kernel panic 404 437 { 405 hal_exception_dump( this , regs_tbl , error ); 406 hal_core_sleep(); 438 hal_exception_dump( this , uzone , error ); 439 panic( "KERNEL_PANIC for thread %x in process %x on core [%x,%d]/n", 440 this->trdid , this->process->pid , local_cxy , this->core->lid ); 407 441 } 408 442 409 443 excp_dmsg("\n[DBG] %s : core[%x,%d] exit / thread %x in process %x / cycle %d\n", 410 __FUNCTION__, local_cxy, this->core->lid, this->trdid, this->process->pid, hal_time_stamp() ); 444 __FUNCTION__, local_cxy, this->core->lid, this->trdid, this->process->pid, 445 (uint32_t)hal_get_cycles() ); 411 446 412 447 } // end hal_do_exception()
Note: See TracChangeset
for help on using the changeset viewer.