2015-07-10 06:01:56 -07:00
|
|
|
/**
|
|
|
|
* @file error_handling.cpp
|
|
|
|
*
|
|
|
|
* @date Apr 1, 2014
|
2020-01-07 21:02:40 -08:00
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2020
|
2015-07-10 06:01:56 -07:00
|
|
|
*/
|
|
|
|
|
2021-07-25 22:05:17 -07:00
|
|
|
#include "pch.h"
|
2023-08-08 20:53:59 -07:00
|
|
|
#include "rusefi/efistringutil.h"
|
2024-06-17 17:37:28 -07:00
|
|
|
#include "os_util.h"
|
2022-07-07 12:14:31 -07:00
|
|
|
#include "backup_ram.h"
|
2023-06-15 19:01:50 -07:00
|
|
|
#include "error_handling_led.h"
|
2024-08-08 08:33:25 -07:00
|
|
|
#include "error_handling_c.h"
|
2023-11-01 19:54:24 -07:00
|
|
|
#include "log_hard_fault.h"
|
2024-07-23 10:35:21 -07:00
|
|
|
#include "rusefi/critical_error.h"
|
2017-01-02 12:03:26 -08:00
|
|
|
|
2021-03-14 06:31:11 -07:00
|
|
|
static critical_msg_t warningBuffer;
|
2020-05-03 07:58:52 -07:00
|
|
|
static critical_msg_t criticalErrorMessageBuffer;
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
extern int warningEnabled;
|
2017-01-02 12:03:26 -08:00
|
|
|
|
|
|
|
bool hasFirmwareErrorFlag = false;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
const char *dbg_panic_file;
|
|
|
|
int dbg_panic_line;
|
|
|
|
|
2024-07-23 10:35:21 -07:00
|
|
|
// todo: need vararg version of 'firmwareError' to make this method vararg?
|
|
|
|
void efiCriticalError(const char *message) {
|
|
|
|
criticalError(message);
|
|
|
|
}
|
|
|
|
|
2022-04-16 14:35:59 -07:00
|
|
|
const char* getCriticalErrorMessage(void) {
|
2021-03-14 06:31:11 -07:00
|
|
|
return criticalErrorMessageBuffer;
|
2017-01-02 12:03:26 -08:00
|
|
|
}
|
|
|
|
|
2019-09-09 18:44:48 -07:00
|
|
|
#if EFI_PROD_CODE
|
2022-07-07 12:14:31 -07:00
|
|
|
void checkLastBootError() {
|
2023-05-24 05:57:01 -07:00
|
|
|
#if EFI_BACKUP_SRAM
|
2022-07-07 12:14:31 -07:00
|
|
|
auto sramState = getBackupSram();
|
2024-01-29 17:39:17 -08:00
|
|
|
|
2024-02-08 19:03:35 -08:00
|
|
|
switch (sramState->Err.Cookie) {
|
2022-07-07 12:14:31 -07:00
|
|
|
case ErrorCookie::FirmwareError:
|
2024-02-08 19:03:35 -08:00
|
|
|
efiPrintf("Last boot had firmware error: %s", sramState->Err.ErrorString);
|
2022-07-07 12:14:31 -07:00
|
|
|
break;
|
|
|
|
case ErrorCookie::HardFault: {
|
2024-02-08 19:03:35 -08:00
|
|
|
efiPrintf("Last boot had raw: %s", sramState->Err.rawMsg);
|
|
|
|
efiPrintf("Last boot had hardFile: %s", sramState->Err.hardFile);
|
|
|
|
efiPrintf("Last boot had line: %d", sramState->Err.hardLine);
|
|
|
|
efiPrintf("Last boot had check: %d", sramState->Err.check);
|
|
|
|
efiPrintf("Last boot had error: %s", sramState->Err.ErrorString);
|
2024-06-10 18:22:56 -07:00
|
|
|
efiPrintf("Last boot had hard fault type: %lx addr: %lx CSFR: %lx", sramState->Err.FaultType, sramState->Err.FaultAddress, sramState->Err.Csfr);
|
2023-06-14 15:40:03 -07:00
|
|
|
if (engineConfiguration->rethrowHardFault) {
|
2024-06-10 18:22:56 -07:00
|
|
|
criticalError("Last boot had hard fault type: %lx addr: %lx CSFR: %lx", sramState->Err.FaultType, sramState->Err.FaultAddress, sramState->Err.Csfr);
|
2023-06-14 15:40:03 -07:00
|
|
|
}
|
2022-07-07 12:14:31 -07:00
|
|
|
|
2024-02-08 19:03:35 -08:00
|
|
|
auto ctx = &sramState->Err.FaultCtx;
|
2024-06-10 18:22:56 -07:00
|
|
|
efiPrintf("r0 0x%lx", ctx->r0);
|
|
|
|
efiPrintf("r1 0x%lx", ctx->r1);
|
|
|
|
efiPrintf("r2 0x%lx", ctx->r2);
|
|
|
|
efiPrintf("r3 0x%lx", ctx->r3);
|
|
|
|
efiPrintf("r12 0x%lx", ctx->r12);
|
|
|
|
efiPrintf("lr (thread) 0x%lx", ctx->lr_thd);
|
|
|
|
efiPrintf("pc 0x%lx", ctx->pc);
|
|
|
|
efiPrintf("xpsr 0x%lx", ctx->xpsr);
|
2023-07-01 08:47:42 -07:00
|
|
|
|
|
|
|
/* FPU registers - not very usefull for debug */
|
|
|
|
if (0) {
|
|
|
|
// Print rest the context as a sequence of uintptr
|
2024-02-08 19:03:35 -08:00
|
|
|
uintptr_t* data = reinterpret_cast<uintptr_t*>(&sramState->Err.FaultCtx);
|
2023-07-01 08:47:42 -07:00
|
|
|
for (size_t i = 8; i < sizeof(port_extctx) / sizeof(uintptr_t); i++) {
|
|
|
|
efiPrintf("Fault ctx %d: %x", i, data[i]);
|
|
|
|
}
|
2022-07-07 12:14:31 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
// No cookie stored or invalid cookie (ie, backup RAM contains random garbage)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reset cookie so we don't print it again.
|
2024-02-08 19:03:35 -08:00
|
|
|
sramState->Err.Cookie = ErrorCookie::None;
|
2022-07-07 12:14:31 -07:00
|
|
|
|
2024-02-08 19:03:35 -08:00
|
|
|
if (sramState->Err.BootCountCookie != 0xdeadbeef) {
|
|
|
|
sramState->Err.BootCountCookie = 0xdeadbeef;
|
|
|
|
sramState->Err.BootCount = 0;
|
2022-07-07 12:14:31 -07:00
|
|
|
}
|
|
|
|
|
2024-06-10 00:51:14 -07:00
|
|
|
efiPrintf("Power cycle count: %lu", sramState->Err.BootCount);
|
2024-02-08 19:03:35 -08:00
|
|
|
sramState->Err.BootCount++;
|
2023-05-24 05:57:01 -07:00
|
|
|
#endif // EFI_BACKUP_SRAM
|
2022-07-07 12:14:31 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void logHardFault(uint32_t type, uintptr_t faultAddress, port_extctx* ctx, uint32_t csfr) {
|
2023-07-21 18:37:41 -07:00
|
|
|
criticalShutdown();
|
2023-05-24 05:57:01 -07:00
|
|
|
#if EFI_BACKUP_SRAM
|
2022-07-07 12:14:31 -07:00
|
|
|
auto sramState = getBackupSram();
|
2024-02-08 19:03:35 -08:00
|
|
|
sramState->Err.Cookie = ErrorCookie::HardFault;
|
|
|
|
sramState->Err.check = 321;
|
|
|
|
sramState->Err.FaultType = type;
|
|
|
|
sramState->Err.FaultAddress = faultAddress;
|
|
|
|
sramState->Err.Csfr = csfr;
|
|
|
|
memcpy(&sramState->Err.FaultCtx, ctx, sizeof(port_extctx));
|
2023-05-24 05:57:01 -07:00
|
|
|
#endif // EFI_BACKUP_SRAM
|
2022-07-07 12:14:31 -07:00
|
|
|
}
|
2019-09-09 18:44:48 -07:00
|
|
|
|
|
|
|
#endif /* EFI_PROD_CODE */
|
|
|
|
|
2017-01-02 12:03:26 -08:00
|
|
|
#if EFI_SIMULATOR || EFI_PROD_CODE
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
void chDbgPanic3(const char *msg, const char * file, int line) {
|
2022-08-02 09:19:50 -07:00
|
|
|
#if EFI_PROD_CODE
|
|
|
|
// Attempt to break in to the debugger, if attached
|
|
|
|
__asm volatile("BKPT #0\n");
|
|
|
|
#endif
|
|
|
|
|
2023-10-21 13:24:38 -07:00
|
|
|
#if EFI_BACKUP_SRAM
|
|
|
|
auto sramState = getBackupSram();
|
2024-02-08 19:03:35 -08:00
|
|
|
strncpy(sramState->Err.hardFile, file, efi::size(sramState->Err.hardFile) - 1);
|
|
|
|
sramState->Err.hardLine = line;
|
|
|
|
sramState->Err.check = 123;
|
|
|
|
strncpy(sramState->Err.rawMsg, msg, efi::size(sramState->Err.rawMsg) - 1);
|
2023-10-21 13:24:38 -07:00
|
|
|
#endif // EFI_BACKUP_SRAM
|
|
|
|
|
2020-03-28 18:28:32 -07:00
|
|
|
if (hasOsPanicError())
|
2015-07-10 06:01:56 -07:00
|
|
|
return;
|
|
|
|
dbg_panic_file = file;
|
|
|
|
dbg_panic_line = line;
|
2019-04-12 19:07:03 -07:00
|
|
|
#if CH_DBG_SYSTEM_STATE_CHECK
|
2024-06-17 17:37:28 -07:00
|
|
|
ch0.dbg.panic_msg = msg;
|
2015-07-10 06:01:56 -07:00
|
|
|
#endif /* CH_DBG_SYSTEM_STATE_CHECK */
|
|
|
|
|
2022-07-07 20:49:02 -07:00
|
|
|
#if !EFI_PROD_CODE
|
2016-07-23 10:03:57 -07:00
|
|
|
printf("chDbgPanic3 %s %s%d", msg, file, line);
|
|
|
|
exit(-1);
|
2022-07-07 20:49:02 -07:00
|
|
|
#else // EFI_PROD_CODE
|
2016-07-23 10:03:57 -07:00
|
|
|
|
2023-08-20 19:23:44 -07:00
|
|
|
criticalError("assert fail %s %s:%d", msg, file, line);
|
2021-07-05 15:18:58 -07:00
|
|
|
|
|
|
|
// If on the main thread, longjmp back to the init process so we can keep USB alive
|
|
|
|
if (chThdGetSelfX()->threadId == 0) {
|
2022-07-07 20:49:02 -07:00
|
|
|
// Force unlock, since we may be throwing-under-lock
|
|
|
|
chSysUnconditionalUnlock();
|
|
|
|
|
|
|
|
// there was a port_disable in chSysHalt, reenable interrupts so USB works
|
|
|
|
port_enable();
|
|
|
|
|
|
|
|
__NO_RETURN void onAssertionFailure();
|
2021-07-05 15:18:58 -07:00
|
|
|
onAssertionFailure();
|
|
|
|
} else {
|
2022-07-07 20:49:02 -07:00
|
|
|
// Not the main thread.
|
|
|
|
// All hope is now lost.
|
2022-08-02 09:19:50 -07:00
|
|
|
|
2022-07-07 20:49:02 -07:00
|
|
|
// Reboot!
|
|
|
|
NVIC_SystemReset();
|
2021-07-05 15:18:58 -07:00
|
|
|
}
|
2022-07-07 20:49:02 -07:00
|
|
|
|
|
|
|
#endif // EFI_PROD_CODE
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2018-01-22 16:53:13 -08:00
|
|
|
#else
|
2019-01-12 05:34:38 -08:00
|
|
|
WarningCodeState unitTestWarningCodeState;
|
2018-01-22 16:53:13 -08:00
|
|
|
|
|
|
|
#endif /* EFI_SIMULATOR || EFI_PROD_CODE */
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
/**
|
2023-04-11 17:01:34 -07:00
|
|
|
* ObdCode::OBD_PCM_Processor_Fault is the general error code for now
|
2015-07-10 06:01:56 -07:00
|
|
|
*
|
2019-01-11 06:58:48 -08:00
|
|
|
* @returns TRUE in case there were warnings recently
|
2015-07-10 06:01:56 -07:00
|
|
|
*/
|
2023-04-11 16:32:47 -07:00
|
|
|
bool warning(ObdCode code, const char *fmt, ...) {
|
2016-10-10 12:02:10 -07:00
|
|
|
if (hasFirmwareErrorFlag)
|
|
|
|
return true;
|
2016-09-26 17:02:24 -07:00
|
|
|
|
2019-04-12 19:07:03 -07:00
|
|
|
#if EFI_SIMULATOR || EFI_PROD_CODE
|
2024-01-08 08:39:08 -08:00
|
|
|
bool known = engine->engineState.warnings.isWarningNow(code);
|
|
|
|
|
|
|
|
// if known - just reset timer
|
|
|
|
engine->engineState.warnings.addWarningCode(code);
|
|
|
|
|
2022-08-16 22:12:25 -07:00
|
|
|
// we just had this same warning, let's not spam
|
2024-01-08 08:39:08 -08:00
|
|
|
if (known) {
|
2022-08-16 22:12:25 -07:00
|
|
|
return true;
|
|
|
|
}
|
2016-11-23 14:01:59 -08:00
|
|
|
|
2024-01-08 11:56:02 -08:00
|
|
|
// print Pxxxx (for standard OBD) or Cxxxx (for custom) prefix
|
|
|
|
size_t size = snprintf(warningBuffer, sizeof(warningBuffer), "%s%04d: ",
|
|
|
|
code < ObdCode::CUSTOM_NAN_ENGINE_LOAD ? "P" : "C", (int) code);
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
va_list ap;
|
|
|
|
va_start(ap, fmt);
|
2024-01-08 11:56:02 -08:00
|
|
|
chvsnprintf(warningBuffer + size, sizeof(warningBuffer) - size, fmt, ap);
|
2015-07-10 06:01:56 -07:00
|
|
|
va_end(ap);
|
2021-03-14 06:31:11 -07:00
|
|
|
|
2021-11-17 00:54:21 -08:00
|
|
|
if (engineConfiguration->showHumanReadableWarning) {
|
2021-03-14 06:31:11 -07:00
|
|
|
#if EFI_TUNER_STUDIO
|
2024-01-08 11:56:02 -08:00
|
|
|
// TODO: does this work? Fix or remove
|
|
|
|
memcpy(persistentState.persistentConfiguration.warning_message, warningBuffer, sizeof(warningBuffer));
|
2021-03-14 06:31:11 -07:00
|
|
|
#endif /* EFI_TUNER_STUDIO */
|
|
|
|
}
|
|
|
|
|
2021-04-19 05:11:59 -07:00
|
|
|
efiPrintf("WARNING: %s", warningBuffer);
|
2017-01-02 12:03:26 -08:00
|
|
|
#else
|
2019-05-10 19:10:40 -07:00
|
|
|
// todo: we need access to 'engine' here so that we can migrate to real 'engine->engineState.warnings'
|
2019-01-12 05:34:38 -08:00
|
|
|
unitTestWarningCodeState.addWarningCode(code);
|
2017-03-03 18:33:49 -08:00
|
|
|
printf("unit_test_warning: ");
|
2017-01-02 12:03:26 -08:00
|
|
|
va_list ap;
|
|
|
|
va_start(ap, fmt);
|
|
|
|
vprintf(fmt, ap);
|
|
|
|
va_end(ap);
|
|
|
|
printf("\r\n");
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2017-05-21 07:46:43 -07:00
|
|
|
#endif /* EFI_SIMULATOR || EFI_PROD_CODE */
|
2017-01-02 12:03:26 -08:00
|
|
|
return false;
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2021-03-14 06:31:11 -07:00
|
|
|
const char* getWarningMessage(void) {
|
2015-07-10 06:01:56 -07:00
|
|
|
return warningBuffer;
|
|
|
|
}
|
|
|
|
|
2017-05-21 07:46:43 -07:00
|
|
|
|
2019-04-12 19:07:03 -07:00
|
|
|
#if EFI_CLOCK_LOCKS
|
2015-07-10 06:01:56 -07:00
|
|
|
uint32_t lastLockTime;
|
2017-05-21 07:25:35 -07:00
|
|
|
/**
|
|
|
|
* Maximum time before requesting lock and releasing lock at the end of critical section
|
|
|
|
*/
|
|
|
|
uint32_t maxLockedDuration = 0;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2018-01-23 10:18:59 -08:00
|
|
|
/**
|
|
|
|
* this depends on chdebug.h patch
|
|
|
|
#if CH_DBG_SYSTEM_STATE_CHECK == TRUE
|
|
|
|
-#define _dbg_enter_lock() (ch.dbg.lock_cnt = (cnt_t)1)
|
|
|
|
-#define _dbg_leave_lock() (ch.dbg.lock_cnt = (cnt_t)0)
|
|
|
|
+#define _dbg_enter_lock() {(ch.dbg.lock_cnt = (cnt_t)1); ON_LOCK_HOOK;}
|
|
|
|
+#define _dbg_leave_lock() {ON_UNLOCK_HOOK;(ch.dbg.lock_cnt = (cnt_t)0);}
|
|
|
|
#endif
|
|
|
|
*/
|
2020-07-10 20:27:27 -07:00
|
|
|
#endif /* EFI_CLOCK_LOCKS */
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
void onLockHook(void) {
|
2020-07-10 21:16:36 -07:00
|
|
|
#if ENABLE_PERF_TRACE
|
2020-07-10 20:27:27 -07:00
|
|
|
perfEventInstantGlobal(PE::GlobalLock);
|
2020-07-10 21:16:36 -07:00
|
|
|
#endif /* ENABLE_PERF_TRACE */
|
2020-07-10 20:27:27 -07:00
|
|
|
|
|
|
|
#if EFI_CLOCK_LOCKS
|
2019-05-07 16:32:08 -07:00
|
|
|
lastLockTime = getTimeNowLowerNt();
|
2020-07-10 20:27:27 -07:00
|
|
|
#endif /* EFI_CLOCK_LOCKS */
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void onUnlockHook(void) {
|
2020-07-10 20:27:27 -07:00
|
|
|
#if EFI_CLOCK_LOCKS
|
2019-05-07 16:32:08 -07:00
|
|
|
uint32_t lockedDuration = getTimeNowLowerNt() - lastLockTime;
|
2017-05-21 07:25:35 -07:00
|
|
|
if (lockedDuration > maxLockedDuration) {
|
|
|
|
maxLockedDuration = lockedDuration;
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
2017-06-03 19:43:05 -07:00
|
|
|
// if (lockedDuration > 2800) {
|
2015-07-10 06:01:56 -07:00
|
|
|
// // un-comment this if you want a nice stop for a breakpoint
|
2017-06-03 19:43:05 -07:00
|
|
|
// maxLockedDuration = lockedDuration + 1;
|
2015-07-10 06:01:56 -07:00
|
|
|
// }
|
2017-05-21 07:46:43 -07:00
|
|
|
#endif /* EFI_CLOCK_LOCKS */
|
|
|
|
|
2020-07-10 21:16:36 -07:00
|
|
|
#if ENABLE_PERF_TRACE
|
2020-07-10 20:27:27 -07:00
|
|
|
perfEventInstantGlobal(PE::GlobalUnlock);
|
2020-07-10 21:16:36 -07:00
|
|
|
#endif /* ENABLE_PERF_TRACE */
|
2020-07-10 20:27:27 -07:00
|
|
|
}
|
|
|
|
|
2020-10-08 11:12:03 -07:00
|
|
|
#if EFI_SIMULATOR || EFI_UNIT_TEST
|
|
|
|
#include <stdexcept>
|
|
|
|
#endif
|
|
|
|
|
2023-04-11 16:32:47 -07:00
|
|
|
void firmwareError(ObdCode code, const char *fmt, ...) {
|
2019-04-12 19:07:03 -07:00
|
|
|
#if EFI_PROD_CODE
|
2017-01-02 12:03:26 -08:00
|
|
|
if (hasFirmwareErrorFlag)
|
|
|
|
return;
|
2024-03-11 15:13:06 -07:00
|
|
|
hasFirmwareErrorFlag = true;
|
2023-11-05 09:09:25 -08:00
|
|
|
#if EFI_ENGINE_CONTROL
|
2022-10-04 17:36:03 -07:00
|
|
|
getLimpManager()->fatalError();
|
2023-11-05 09:09:25 -08:00
|
|
|
#endif // EFI_ENGINE_CONTROL
|
2019-01-11 06:58:48 -08:00
|
|
|
engine->engineState.warnings.addWarningCode(code);
|
2018-01-22 14:45:43 -08:00
|
|
|
#ifdef EFI_PRINT_ERRORS_AS_WARNINGS
|
2023-11-01 16:47:19 -07:00
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
va_start(ap, fmt);
|
|
|
|
chvsnprintf(warningBuffer, sizeof(warningBuffer), fmt, ap);
|
|
|
|
va_end(ap);
|
|
|
|
}
|
2023-11-04 21:55:38 -07:00
|
|
|
#endif // EFI_PRINT_ERRORS_AS_WARNINGS
|
2023-07-21 18:37:41 -07:00
|
|
|
criticalShutdown();
|
2023-08-28 21:24:46 -07:00
|
|
|
enginePins.communicationLedPin.setValue(1, /*force*/true);
|
2022-07-07 20:49:02 -07:00
|
|
|
|
2017-01-02 12:03:26 -08:00
|
|
|
if (indexOf(fmt, '%') == -1) {
|
|
|
|
/**
|
|
|
|
* in case of simple error message let's reduce stack usage
|
2021-03-14 06:31:11 -07:00
|
|
|
* chvsnprintf could cause an overflow if we're already low
|
2017-01-02 12:03:26 -08:00
|
|
|
*/
|
2020-03-28 17:14:17 -07:00
|
|
|
strncpy((char*) criticalErrorMessageBuffer, fmt, sizeof(criticalErrorMessageBuffer) - 1);
|
|
|
|
criticalErrorMessageBuffer[sizeof(criticalErrorMessageBuffer) - 1] = 0; // just to be sure
|
2017-01-02 12:03:26 -08:00
|
|
|
} else {
|
|
|
|
va_list ap;
|
|
|
|
va_start(ap, fmt);
|
2021-03-14 06:31:11 -07:00
|
|
|
chvsnprintf(criticalErrorMessageBuffer, sizeof(criticalErrorMessageBuffer), fmt, ap);
|
2017-01-02 12:03:26 -08:00
|
|
|
va_end(ap);
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
2021-03-14 06:31:11 -07:00
|
|
|
|
2022-04-16 14:35:59 -07:00
|
|
|
int errorMessageSize = strlen((char*)criticalErrorMessageBuffer);
|
2020-05-22 13:45:13 -07:00
|
|
|
static char versionBuffer[32];
|
|
|
|
chsnprintf(versionBuffer, sizeof(versionBuffer), " %d@%s", getRusEfiVersion(), FIRMWARE_ID);
|
|
|
|
|
2022-04-16 14:35:59 -07:00
|
|
|
if (errorMessageSize + strlen(versionBuffer) < sizeof(criticalErrorMessageBuffer)) {
|
|
|
|
strcpy((char*)(criticalErrorMessageBuffer) + errorMessageSize, versionBuffer);
|
2020-05-22 13:45:13 -07:00
|
|
|
}
|
2020-03-28 17:14:17 -07:00
|
|
|
|
2023-05-24 05:57:01 -07:00
|
|
|
#if EFI_BACKUP_SRAM
|
2022-07-07 12:14:31 -07:00
|
|
|
auto sramState = getBackupSram();
|
2024-02-08 19:03:35 -08:00
|
|
|
strncpy(sramState->Err.ErrorString, criticalErrorMessageBuffer, efi::size(sramState->Err.ErrorString));
|
|
|
|
sramState->Err.Cookie = ErrorCookie::FirmwareError;
|
2023-05-24 05:57:01 -07:00
|
|
|
#endif // EFI_BACKUP_SRAM
|
2017-01-02 12:03:26 -08:00
|
|
|
#else
|
2020-12-18 05:48:19 -08:00
|
|
|
|
2024-01-29 17:39:17 -08:00
|
|
|
// large buffer on stack is risky we better use normal memory
|
|
|
|
static char errorBuffer[200];
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2017-01-02 12:03:26 -08:00
|
|
|
va_list ap;
|
|
|
|
va_start(ap, fmt);
|
2020-12-18 05:48:19 -08:00
|
|
|
vsnprintf(errorBuffer, sizeof(errorBuffer), fmt, ap);
|
2017-01-02 12:03:26 -08:00
|
|
|
va_end(ap);
|
2020-12-18 05:48:19 -08:00
|
|
|
|
|
|
|
printf("\x1B[31m>>>>>>>>>> firmwareError [%s]\r\n\x1B[0m\r\n", errorBuffer);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2019-04-12 19:07:03 -07:00
|
|
|
#if EFI_SIMULATOR || EFI_UNIT_TEST
|
2020-12-18 05:48:19 -08:00
|
|
|
throw std::logic_error(errorBuffer);
|
2017-01-02 12:03:26 -08:00
|
|
|
#endif /* EFI_SIMULATOR */
|
|
|
|
#endif
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
2024-08-08 08:33:25 -07:00
|
|
|
|
|
|
|
void criticalErrorM(const char *msg) {
|
|
|
|
criticalError(msg);
|
|
|
|
}
|