2020-04-24 08:36:29 +02:00
|
|
|
//#ifdef CLOVER_BUILD
|
2020-04-24 11:30:09 +02:00
|
|
|
//#include "../../Platform/BootLog.h"
|
2020-03-13 14:11:58 +01:00
|
|
|
|
|
|
|
#include <Platform.h>
|
|
|
|
|
2020-04-24 08:36:29 +02:00
|
|
|
//
|
|
|
|
//#ifdef __cplusplus
|
|
|
|
//extern "C" {
|
|
|
|
//#endif
|
|
|
|
//
|
|
|
|
//#include <Library/BaseLib.h> // for CpuDeadLoop
|
|
|
|
//
|
|
|
|
//#ifdef __cplusplus
|
|
|
|
//} // extern "C"
|
|
|
|
//#endif
|
|
|
|
//
|
|
|
|
//#else
|
|
|
|
//
|
|
|
|
//#include <Platform.h>
|
|
|
|
//
|
|
|
|
//#endif
|
2020-03-13 14:11:58 +01:00
|
|
|
|
2020-04-25 11:59:07 +02:00
|
|
|
#if defined(CLOVER_BUILD) || !defined(_MSC_VER)
|
2020-03-13 14:11:58 +01:00
|
|
|
void abort(void)
|
|
|
|
{
|
2020-04-24 11:30:09 +02:00
|
|
|
printf("A fatal error happened. System halted\n");
|
2020-04-16 11:09:22 +02:00
|
|
|
while (1) { // tis will avoid warning : Function declared 'noreturn' should not return
|
2020-03-13 14:11:58 +01:00
|
|
|
CpuDeadLoop();
|
2020-04-16 11:09:22 +02:00
|
|
|
}
|
2020-03-21 14:12:26 +01:00
|
|
|
}
|
2020-04-25 11:59:07 +02:00
|
|
|
#endif
|
2020-04-24 08:36:29 +02:00
|
|
|
|
|
|
|
bool stop_at_panic = true;
|
|
|
|
bool i_have_panicked = false;
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Function panic_ seems useless. It's same as panic(). It's to be able to put a breakpoint in gdb with br panic_(). This is done in gdb_launch script in Qemu
|
|
|
|
*/
|
|
|
|
static void panic_(const char* format, VA_LIST va)
|
|
|
|
{
|
|
|
|
if ( format ) {
|
|
|
|
vprintf(format, va);
|
|
|
|
}
|
|
|
|
printf("A fatal error happened. System halted\n");
|
|
|
|
while (1) { // this will avoid warning : Function declared 'noreturn' should not return
|
|
|
|
CpuDeadLoop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void panic(const char* format, ...)
|
|
|
|
{
|
|
|
|
if ( stop_at_panic ) {
|
|
|
|
VA_LIST va;
|
|
|
|
VA_START(va, format);
|
2020-04-24 12:37:50 +02:00
|
|
|
panic_(format, va); // panic doesn't return
|
2020-04-24 17:26:27 +02:00
|
|
|
// VA_END(va);
|
2020-04-24 08:36:29 +02:00
|
|
|
}else{
|
|
|
|
i_have_panicked = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void panic(void)
|
|
|
|
{
|
|
|
|
panic(nullptr);
|
|
|
|
}
|