Changeset 587 for trunk/hal/tsar_mips32/core/hal_exception.c
- Timestamp:
- Nov 1, 2018, 12:39:27 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/tsar_mips32/core/hal_exception.c
r570 r587 46 46 47 47 ////////////////////////////////////////////////////////////////////////////////////////// 48 // This enum defines the global exception types after analysis by the exception handler.49 //////////////////////////////////////////////////////////////////////////////////////////50 51 typedef enum52 {53 EXCP_NON_FATAL,54 EXCP_USER_ERROR,55 EXCP_KERNEL_PANIC,56 }57 exception_handling_type_t;58 59 //////////////////////////////////////////////////////////////////////////////////////////60 48 // This enum defines the mask values for an MMU exception code reported by the mips32. 61 49 ////////////////////////////////////////////////////////////////////////////////////////// … … 219 207 uint32_t cycle = (uint32_t)hal_get_cycles(); 220 208 if( DEBUG_HAL_EXCEPTIONS < cycle ) 221 printk("\n[DBG] %s : thread %x in process %xenter / is_ins %d / %s / vaddr %x / cycle %d\n",222 __FUNCTION__, this->trdid, process->pid,209 printk("\n[DBG] %s : thread[%x,%x] enter / is_ins %d / %s / vaddr %x / cycle %d\n", 210 __FUNCTION__, process->pid, this->trdid, 223 211 is_ins, hal_mmu_exception_str(excp_code), bad_vaddr, cycle); 224 212 #endif … … 234 222 // try to map the unmapped PTE 235 223 error = vmm_handle_page_fault( process, 236 bad_vaddr >> CONFIG_PPM_PAGE_SHIFT, // vpn 237 false ); // not a COW 238 if( error ) 239 { 240 printk("\n[USER ERROR] in %s for thread %x in process %x\n" 241 " cannot map vaddr = %x / is_ins %d / epc %x\n", 242 __FUNCTION__, this->trdid, this->process->pid, bad_vaddr, is_ins, excPC ); 243 244 return EXCP_USER_ERROR; 245 } 246 else // page fault successfull 224 bad_vaddr >> CONFIG_PPM_PAGE_SHIFT ); 225 226 if( error == EXCP_NON_FATAL ) // page-fault successfully handled 247 227 { 248 228 … … 250 230 cycle = (uint32_t)hal_get_cycles(); 251 231 if( DEBUG_HAL_EXCEPTIONS < cycle ) 252 printk("\n[DBG] %s : thread %x in process %xexit / page-fault handled for vaddr = %x\n",253 __FUNCTION__, this->trdid, process->pid, bad_vaddr );232 printk("\n[DBG] %s : thread[%x,%x] exit / page-fault handled for vaddr = %x\n", 233 __FUNCTION__, process->pid, this->trdid, bad_vaddr ); 254 234 #endif 255 235 256 236 return EXCP_NON_FATAL; 257 237 } 238 else if( error == EXCP_USER_ERROR ) // illegal vaddr 239 { 240 printk("\n[USER ERROR] in %s for thread %x in process %x\n" 241 " illegal vaddr = %x / is_ins %d / epc %x\n", 242 __FUNCTION__, this->trdid, this->process->pid, bad_vaddr, is_ins, excPC ); 243 244 return EXCP_USER_ERROR; 245 } 246 else // error == EXCP_KERNEL_PANIC 247 { 248 printk("\n[KERNEL ERROR] in %s for thread %x in process %x\n" 249 " no memory to map vaddr = %x / is_ins %d / epc %x\n", 250 __FUNCTION__, this->trdid, this->process->pid, bad_vaddr, is_ins, excPC ); 251 252 return EXCP_KERNEL_PANIC; 253 } 258 254 } 259 255 case MMU_WRITE_PRIVILEGE_VIOLATION: // illegal access user error 260 256 case MMU_READ_PRIVILEGE_VIOLATION: 261 257 { 262 printk("\n[USER ERROR] in %s forthread %x in process %x\n"258 printk("\n[USER ERROR] in %s : thread %x in process %x\n" 263 259 " illegal user access to vaddr = %x / is_ins %d / epc %x\n", 264 260 __FUNCTION__, this->trdid, this->process->pid, bad_vaddr, is_ins, excPC ); … … 275 271 { 276 272 // try to allocate and copy the page 277 error = vmm_handle_page_fault( process, 278 bad_vaddr >> CONFIG_PPM_PAGE_SHIFT, // vpn 279 true ); // COW 280 if( error ) 281 { 282 printk("\n[USER ERROR] in %s for thread %x in process %x\n" 283 " cannot cow vaddr = %x / is_ins %d / epc %x\n", 284 __FUNCTION__, this->trdid, this->process->pid, bad_vaddr, is_ins, excPC ); 285 286 return EXCP_USER_ERROR; 287 } 288 else // Copy on write successfull 273 error = vmm_handle_cow( process, 274 bad_vaddr >> CONFIG_PPM_PAGE_SHIFT ); 275 276 if( error == EXCP_NON_FATAL ) // Copy on write successfull 289 277 { 290 278 … … 292 280 cycle = (uint32_t)hal_get_cycles(); 293 281 if( DEBUG_HAL_EXCEPTIONS < cycle ) 294 printk("\n[DBG] %s : thread %x in process %xexit / copy-on-write handled for vaddr = %x\n",295 __FUNCTION__, this->trdid, process->pid, bad_vaddr );282 printk("\n[DBG] %s : thread[%x,%x] exit / copy-on-write handled for vaddr = %x\n", 283 __FUNCTION__, process->pid, this->trdid, bad_vaddr ); 296 284 #endif 297 285 298 286 return EXCP_NON_FATAL; 299 287 } 288 else if( error == EXCP_USER_ERROR ) // illegal user access 289 { 290 printk("\n[USER ERROR] in %s : thread %x in process %x\n" 291 " cannot cow vaddr = %x / is_ins %d / epc %x\n", 292 __FUNCTION__, this->trdid, this->process->pid, bad_vaddr, is_ins, excPC ); 293 294 return EXCP_USER_ERROR; 295 } 296 else // error == EXCP_KERNEL_PANIC 297 { 298 printk("\n[KERNEL ERROR] in %s : thread %x in process %x\n" 299 " no memoty to cow vaddr = %x / is_ins %d / epc %x\n", 300 __FUNCTION__, this->trdid, this->process->pid, bad_vaddr, is_ins, excPC ); 301 302 return EXCP_USER_ERROR; 303 } 300 304 } 301 305 else // non writable user error 302 306 { 303 printk("\n[USER ERROR] in %s forthread %x in process %x\n"307 printk("\n[USER ERROR] in %s : thread %x in process %x\n" 304 308 " non-writable vaddr = %x / is_ins %d / epc %x\n", 305 309 __FUNCTION__, this->trdid, this->process->pid, bad_vaddr, is_ins, excPC ); … … 310 314 case MMU_READ_EXEC_VIOLATION: // user error 311 315 { 312 printk("\n[USER_ERROR] in %s forthread %x in process %x\n"316 printk("\n[USER_ERROR] in %s : thread %x in process %x\n" 313 317 " non-executable vaddr = %x / is_ins %d / epc %x\n", 314 318 __FUNCTION__, this->trdid, this->process->pid, bad_vaddr, is_ins, excPC ); … … 318 322 default: // this is a kernel error 319 323 { 320 printk("\n[KERNEL ERROR] in %s forthread %x in process %x\n"324 printk("\n[KERNEL ERROR] in %s : thread %x in process %x\n" 321 325 " epc %x / badvaddr %x / is_ins %d\n", 322 326 __FUNCTION__, this->trdid, this->process->pid, excPC, bad_vaddr, is_ins );
Note: See TracChangeset
for help on using the changeset viewer.