@@ -151,6 +151,9 @@ void OS::on_panic(on_panic_func func)
151151 panic_handler = std::move (func);
152152}
153153
154+ extern " C" __attribute__((noreturn)) void panic_epilogue (const char *);
155+
156+
154157/* *
155158 * panic:
156159 * Display reason for kernel panic
@@ -193,21 +196,37 @@ asm("panic_begin:");
193196 fflush (stderr);
194197 SMP::global_unlock ();
195198
196- // call custom on panic handler (if present)
197- if (panic_handler) panic_handler (why);
199+ panic_epilogue (why);
200+ }
198201
199- #if defined(ARCH_x86)
202+ extern " C"
203+ void double_fault (const char * why)
204+ {
200205 SMP::global_lock ();
201- // Signal End-Of-Transmission
202- kprint ( " \x04 " );
206+ fprintf (stderr, " \n %s \n CPU: %d, Reason: %s \n " ,
207+ panic_signature, SMP::cpu_id (), why );
203208 SMP::global_unlock ();
204209
205- // .. if we return from the panic handler, go to permanent sleep
206- while (1 ) asm (" cli; hlt" );
210+ panic_epilogue (why);
211+ }
212+
213+ void panic_epilogue (const char * why)
214+ {
215+ // call custom on panic handler (if present)
216+ if (panic_handler) panic_handler (why);
217+
218+ #if defined(ARCH_x86)
219+ SMP::global_lock ();
220+ // Signal End-Of-Transmission
221+ kprint (" \x04 " );
222+ SMP::global_unlock ();
223+
224+ // .. if we return from the panic handler, go to permanent sleep
225+ while (1 ) asm (" cli; hlt" );
226+ #else
227+ #warning "panic() handler not implemented for selected arch"
228+ #endif
207229 __builtin_unreachable ();
208- #else
209- #warning "panic() handler not implemented for selected arch"
210- #endif
211230}
212231
213232// Shutdown the machine when one of the exit functions are called
0 commit comments