fix dependency check logic cause config always disabled
[lunaix-os.git] / lunaix-os / kernel / debug / failsafe.c
1 #include <lunaix/failsafe.h>
2 #include <lunaix/spike.h>
3 #include <lunaix/syslog.h>
4 #include <lunaix/trace.h>
5 #include <lunaix/sched.h>
6
7 LOG_MODULE("NMM")
8
9 void
10 do_failsafe_unrecoverable(ptr_t frame_link, ptr_t stack_link)
11 {
12     ERROR("------- [cut here] ------- \n");
13     ERROR("diagnositic mode");
14     ERROR("check: init stack: %s", 
15             check_bootstack_sanity() ? "ok" : "smashing");
16
17     // TODO ...check other invariants
18     if (current_thread && current_thread->hstate)
19     {
20         struct hart_state* hstate = current_thread->hstate;
21     
22         trace_print_transition_full(hstate);
23         ERROR("++++++");
24
25         trace_dump_state(hstate);
26         ERROR("++++++");
27     }
28
29     trace_printstack();
30     ERROR("++++++");
31     
32     ERROR("non recoverable: Nightmare Moon arrival.");
33     spin();
34 }