mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-12-27 16:58:09 +01:00
68 lines
1.2 KiB
C++
Executable File
68 lines
1.2 KiB
C++
Executable File
//#ifdef CLOVER_BUILD
|
|
//#include "../../Platform/BootLog.h"
|
|
|
|
#include <Platform.h>
|
|
|
|
//
|
|
//#ifdef __cplusplus
|
|
//extern "C" {
|
|
//#endif
|
|
//
|
|
//#include <Library/BaseLib.h> // for CpuDeadLoop
|
|
//
|
|
//#ifdef __cplusplus
|
|
//} // extern "C"
|
|
//#endif
|
|
//
|
|
//#else
|
|
//
|
|
//#include <Platform.h>
|
|
//
|
|
//#endif
|
|
|
|
#if defined(CLOVER_BUILD) || !defined(_MSC_VER)
|
|
void abort(void)
|
|
{
|
|
printf("A fatal error happened. System halted\n");
|
|
while (1) { // tis will avoid warning : Function declared 'noreturn' should not return
|
|
CpuDeadLoop();
|
|
}
|
|
}
|
|
#endif
|
|
|
|
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);
|
|
panic_(format, va); // panic doesn't return
|
|
// VA_END(va);
|
|
}else{
|
|
i_have_panicked = true;
|
|
}
|
|
}
|
|
|
|
|
|
void panic(void)
|
|
{
|
|
panic(nullptr);
|
|
}
|