|
20 | 20 | #include <sys/printk.h> |
21 | 21 | #include <logging/log_ctrl.h> |
22 | 22 |
|
23 | | -/** |
24 | | - * |
25 | | - * @brief Kernel fatal error handler |
26 | | - * |
27 | | - * This routine is called when fatal error conditions are detected by software |
28 | | - * and is responsible only for reporting the error. Once reported, it then |
29 | | - * invokes the user provided routine z_SysFatalErrorHandler() which is |
30 | | - * responsible for implementing the error handling policy. |
31 | | - * |
32 | | - * The caller is expected to always provide a usable ESF. In the event that the |
33 | | - * fatal error does not have a hardware generated ESF, the caller should either |
34 | | - * create its own or use a pointer to the global default ESF <_default_esf>. |
35 | | - * |
36 | | - * Unlike other arches, this function may return if z_SysFatalErrorHandler |
37 | | - * determines that only the current thread should be aborted and the CPU |
38 | | - * was in handler mode. PendSV will be asserted in this case and the current |
39 | | - * thread taken off the run queue. Leaving the exception will immediately |
40 | | - * trigger a context switch. |
41 | | - * |
42 | | - * @param reason the reason that the handler was called |
43 | | - * @param pEsf pointer to the exception stack frame |
44 | | - * |
45 | | - * @return This function does not return. |
46 | | - */ |
47 | | -void z_NanoFatalErrorHandler(unsigned int reason, |
48 | | - const NANO_ESF *pEsf) |
| 23 | +void z_arm_fatal_error(unsigned int reason, const NANO_ESF *esf) |
49 | 24 | { |
50 | | -#ifdef CONFIG_THREAD_NAME |
51 | | - const char *thread_name = k_thread_name_get(k_current_get()); |
52 | | -#endif |
53 | | - |
54 | | - LOG_PANIC(); |
55 | | - |
56 | | - switch (reason) { |
57 | | - case _NANO_ERR_HW_EXCEPTION: |
58 | | - printk("***** Hardware exception *****\n"); |
59 | | - break; |
60 | | -#if defined(CONFIG_STACK_CANARIES) || defined(CONFIG_STACK_SENTINEL) || \ |
61 | | - defined(CONFIG_HW_STACK_PROTECTION) || \ |
62 | | - defined(CONFIG_USERSPACE) |
63 | | - case _NANO_ERR_STACK_CHK_FAIL: |
64 | | - printk("***** Stack Check Fail! *****\n"); |
65 | | - break; |
66 | | -#endif /* CONFIG_STACK_CANARIES */ |
67 | | - |
68 | | - case _NANO_ERR_ALLOCATION_FAIL: |
69 | | - printk("**** Kernel Allocation Failure! ****\n"); |
70 | | - break; |
71 | | - |
72 | | - case _NANO_ERR_KERNEL_OOPS: |
73 | | - printk("***** Kernel OOPS! *****\n"); |
74 | | - break; |
75 | | - |
76 | | - case _NANO_ERR_KERNEL_PANIC: |
77 | | - printk("***** Kernel Panic! *****\n"); |
78 | | - break; |
79 | | - |
80 | | - default: |
81 | | - printk("**** Unknown Fatal Error %d! ****\n", reason); |
82 | | - break; |
83 | | - } |
84 | | - printk("Current thread ID = %p" |
85 | | -#ifdef CONFIG_THREAD_NAME |
86 | | - " (%s)" |
87 | | -#endif |
88 | | - "\n" |
89 | | - "Faulting instruction address = 0x%x\n", |
90 | | - k_current_get(), |
91 | | -#ifdef CONFIG_THREAD_NAME |
92 | | - thread_name ? thread_name : "unknown", |
93 | | -#endif |
94 | | - pEsf->basic.pc); |
95 | | - |
96 | | - /* |
97 | | - * Now that the error has been reported, call the user implemented |
98 | | - * policy |
99 | | - * to respond to the error. The decisions as to what responses are |
100 | | - * appropriate to the various errors are something the customer must |
101 | | - * decide. |
102 | | - */ |
103 | | - |
104 | | - z_SysFatalErrorHandler(reason, pEsf); |
| 25 | + printk("Faulting instruction address = 0x%x\n", |
| 26 | + esf->basic.pc); |
| 27 | + z_fatal_error(reason, esf); |
105 | 28 | } |
106 | 29 |
|
107 | 30 | void z_do_kernel_oops(const NANO_ESF *esf) |
108 | 31 | { |
109 | | - z_NanoFatalErrorHandler(esf->basic.r0, esf); |
| 32 | + z_arm_fatal_error(esf->basic.r0, esf); |
110 | 33 | } |
111 | 34 |
|
112 | 35 | FUNC_NORETURN void z_arch_syscall_oops(void *ssf_ptr) |
113 | 36 | { |
114 | 37 | u32_t *ssf_contents = ssf_ptr; |
115 | 38 | NANO_ESF oops_esf = { 0 }; |
116 | 39 |
|
117 | | - LOG_PANIC(); |
118 | | - |
119 | 40 | oops_esf.basic.pc = ssf_contents[3]; |
120 | 41 |
|
121 | 42 | z_do_kernel_oops(&oops_esf); |
|
0 commit comments