2022-10-24 13:50:34 +03:00
|
|
|
/**
|
|
|
|
* @file check.h
|
|
|
|
*
|
|
|
|
* Furi crash and assert functions.
|
|
|
|
*
|
|
|
|
* The main problem with crashing is that you can't do anything without disturbing registers,
|
|
|
|
* and if you disturb registers, you won't be able to see the correct register values in the debugger.
|
|
|
|
*
|
|
|
|
* Current solution works around it by passing the message through r12 and doing some magic with registers in crash function.
|
|
|
|
* r0-r10 are stored in the ram2 on crash routine start and restored at the end.
|
|
|
|
* The only register that is going to be lost is r11.
|
|
|
|
*
|
|
|
|
*/
|
2020-10-29 09:27:17 +03:00
|
|
|
#pragma once
|
2022-06-20 17:54:48 +03:00
|
|
|
|
2023-06-30 12:52:43 +03:00
|
|
|
#include <m-core.h>
|
|
|
|
|
[FL-140] Core api dynamic records (#296)
* SYSTEM: tickless mode with deep sleep.
* Move FreeRTOS ticks to lptim2
* API: move all sumbodules init routines to one place. Timebase: working lptim2 at tick source.
* API Timebase: lp-timer routines, timer access safe zones prediction and synchronization. FreeRTOS: adjust configuration for tickless mode.
* NFC: support for tickless mode.
* API Timebase: improve tick error handling in IRQ. Apploader: use insomnia mode to run applications.
* BLE: prevent sleep while core2 starting
* HAL: nap while in insomnia mode
* init records work
* try to implement record delete
* tests and flapp
* flapp subsystem
* new core functions to get app stat, simplify core code
* fix thread termination
* add strdup to core
* fix tests
* Refactoring: remove all unusued parts, update API usage, aggreagate API sources and headers, new record storage
* Refactoring: update furi record api usage, cleanup code
* Fix broken merge for freertos apps
* Core, Target: fix compilation warnings
* Drop firmware target local
* HAL Timebase, Power, Clock: semaphore guarded access to clock and power modes, better sleep mode.
* SD-Filesystem: wait for all deps to arrive before adding widget. Core, BLE: disable debug dump to serial.
* delete old app example-ipc
* delete old app fatfs list
* fix strobe app, add input header
* delete old display driver
* comment old app qr-code
* fix sd-card test, add forced widget update
* remove unused new core test
* increase heap to 128k
* comment and assert old core tests
* fix syntax
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-01-20 19:09:26 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
2022-04-13 23:50:25 +03:00
|
|
|
#define FURI_NORETURN [[noreturn]]
|
|
|
|
#else
|
|
|
|
#include <stdnoreturn.h>
|
|
|
|
#define FURI_NORETURN noreturn
|
[FL-140] Core api dynamic records (#296)
* SYSTEM: tickless mode with deep sleep.
* Move FreeRTOS ticks to lptim2
* API: move all sumbodules init routines to one place. Timebase: working lptim2 at tick source.
* API Timebase: lp-timer routines, timer access safe zones prediction and synchronization. FreeRTOS: adjust configuration for tickless mode.
* NFC: support for tickless mode.
* API Timebase: improve tick error handling in IRQ. Apploader: use insomnia mode to run applications.
* BLE: prevent sleep while core2 starting
* HAL: nap while in insomnia mode
* init records work
* try to implement record delete
* tests and flapp
* flapp subsystem
* new core functions to get app stat, simplify core code
* fix thread termination
* add strdup to core
* fix tests
* Refactoring: remove all unusued parts, update API usage, aggreagate API sources and headers, new record storage
* Refactoring: update furi record api usage, cleanup code
* Fix broken merge for freertos apps
* Core, Target: fix compilation warnings
* Drop firmware target local
* HAL Timebase, Power, Clock: semaphore guarded access to clock and power modes, better sleep mode.
* SD-Filesystem: wait for all deps to arrive before adding widget. Core, BLE: disable debug dump to serial.
* delete old app example-ipc
* delete old app fatfs list
* fix strobe app, add input header
* delete old display driver
* comment old app qr-code
* fix sd-card test, add forced widget update
* remove unused new core test
* increase heap to 128k
* comment and assert old core tests
* fix syntax
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-01-20 19:09:26 +03:00
|
|
|
#endif
|
2020-10-29 09:27:17 +03:00
|
|
|
|
2023-04-25 19:33:13 +03:00
|
|
|
// Flags instead of pointers will save ~4 bytes on furi_assert and furi_check calls.
|
|
|
|
#define __FURI_ASSERT_MESSAGE_FLAG (0x01)
|
|
|
|
#define __FURI_CHECK_MESSAGE_FLAG (0x02)
|
|
|
|
|
2022-10-22 18:21:10 +03:00
|
|
|
/** Crash system */
|
2023-10-31 13:40:32 +03:00
|
|
|
FURI_NORETURN void __furi_crash_implementation();
|
2022-10-22 18:21:10 +03:00
|
|
|
|
|
|
|
/** Halt system */
|
2023-10-31 13:40:32 +03:00
|
|
|
FURI_NORETURN void __furi_halt_implementation();
|
2022-10-22 18:21:10 +03:00
|
|
|
|
|
|
|
/** Crash system with message. Show message after reboot. */
|
2023-10-31 13:40:32 +03:00
|
|
|
#define __furi_crash(message) \
|
2022-10-24 13:50:34 +03:00
|
|
|
do { \
|
|
|
|
register const void* r12 asm("r12") = (void*)message; \
|
|
|
|
asm volatile("sukima%=:" : : "r"(r12)); \
|
2023-10-31 13:40:32 +03:00
|
|
|
__furi_crash_implementation(); \
|
2022-10-22 18:21:10 +03:00
|
|
|
} while(0)
|
|
|
|
|
2023-10-31 13:40:32 +03:00
|
|
|
/** Crash system
|
|
|
|
*
|
|
|
|
* @param optional message (const char*)
|
|
|
|
*/
|
|
|
|
#define furi_crash(...) M_APPLY(__furi_crash, M_IF_EMPTY(__VA_ARGS__)((NULL), (__VA_ARGS__)))
|
|
|
|
|
2022-10-22 18:21:10 +03:00
|
|
|
/** Halt system with message. */
|
2023-10-31 13:40:32 +03:00
|
|
|
#define __furi_halt(message) \
|
2022-10-24 13:50:34 +03:00
|
|
|
do { \
|
|
|
|
register const void* r12 asm("r12") = (void*)message; \
|
|
|
|
asm volatile("sukima%=:" : : "r"(r12)); \
|
2023-10-31 13:40:32 +03:00
|
|
|
__furi_halt_implementation(); \
|
2022-10-22 18:21:10 +03:00
|
|
|
} while(0)
|
|
|
|
|
2023-10-31 13:40:32 +03:00
|
|
|
/** Halt system
|
|
|
|
*
|
|
|
|
* @param optional message (const char*)
|
|
|
|
*/
|
|
|
|
#define furi_halt(...) M_APPLY(__furi_halt, M_IF_EMPTY(__VA_ARGS__)((NULL), (__VA_ARGS__)))
|
|
|
|
|
2021-09-15 12:59:49 +03:00
|
|
|
/** Check condition and crash if check failed */
|
2023-06-30 12:52:43 +03:00
|
|
|
#define __furi_check(__e, __m) \
|
|
|
|
do { \
|
|
|
|
if(!(__e)) { \
|
2023-10-31 13:40:32 +03:00
|
|
|
__furi_crash(__m); \
|
2023-06-30 12:52:43 +03:00
|
|
|
} \
|
2022-10-22 18:21:10 +03:00
|
|
|
} while(0)
|
2023-04-25 23:11:42 +03:00
|
|
|
|
2023-06-30 12:52:43 +03:00
|
|
|
/** Check condition and crash if failed
|
|
|
|
*
|
|
|
|
* @param condition to check
|
2023-10-31 13:40:32 +03:00
|
|
|
* @param optional message (const char*)
|
2023-06-30 12:52:43 +03:00
|
|
|
*/
|
|
|
|
#define furi_check(...) \
|
|
|
|
M_APPLY(__furi_check, M_DEFAULT_ARGS(2, (__FURI_CHECK_MESSAGE_FLAG), __VA_ARGS__))
|
|
|
|
|
2023-04-25 23:11:42 +03:00
|
|
|
/** Only in debug build: Assert condition and crash if assert failed */
|
|
|
|
#ifdef FURI_DEBUG
|
2023-06-30 12:52:43 +03:00
|
|
|
#define __furi_assert(__e, __m) \
|
|
|
|
do { \
|
|
|
|
if(!(__e)) { \
|
2023-10-31 13:40:32 +03:00
|
|
|
__furi_crash(__m); \
|
2023-06-30 12:52:43 +03:00
|
|
|
} \
|
2023-04-25 23:11:42 +03:00
|
|
|
} while(0)
|
2021-10-13 20:33:09 +03:00
|
|
|
#else
|
2023-06-30 12:52:43 +03:00
|
|
|
#define __furi_assert(__e, __m) \
|
|
|
|
do { \
|
|
|
|
((void)(__e)); \
|
|
|
|
((void)(__m)); \
|
2022-05-06 16:37:10 +03:00
|
|
|
} while(0)
|
2020-10-29 09:27:17 +03:00
|
|
|
#endif
|
|
|
|
|
2023-06-30 12:52:43 +03:00
|
|
|
/** Assert condition and crash if failed
|
|
|
|
*
|
|
|
|
* @warning only will do check if firmware compiled in debug mode
|
|
|
|
*
|
|
|
|
* @param condition to check
|
2023-10-31 13:40:32 +03:00
|
|
|
* @param optional message (const char*)
|
2023-06-30 12:52:43 +03:00
|
|
|
*/
|
|
|
|
#define furi_assert(...) \
|
|
|
|
M_APPLY(__furi_assert, M_DEFAULT_ARGS(2, (__FURI_ASSERT_MESSAGE_FLAG), __VA_ARGS__))
|
|
|
|
|
[FL-140] Core api dynamic records (#296)
* SYSTEM: tickless mode with deep sleep.
* Move FreeRTOS ticks to lptim2
* API: move all sumbodules init routines to one place. Timebase: working lptim2 at tick source.
* API Timebase: lp-timer routines, timer access safe zones prediction and synchronization. FreeRTOS: adjust configuration for tickless mode.
* NFC: support for tickless mode.
* API Timebase: improve tick error handling in IRQ. Apploader: use insomnia mode to run applications.
* BLE: prevent sleep while core2 starting
* HAL: nap while in insomnia mode
* init records work
* try to implement record delete
* tests and flapp
* flapp subsystem
* new core functions to get app stat, simplify core code
* fix thread termination
* add strdup to core
* fix tests
* Refactoring: remove all unusued parts, update API usage, aggreagate API sources and headers, new record storage
* Refactoring: update furi record api usage, cleanup code
* Fix broken merge for freertos apps
* Core, Target: fix compilation warnings
* Drop firmware target local
* HAL Timebase, Power, Clock: semaphore guarded access to clock and power modes, better sleep mode.
* SD-Filesystem: wait for all deps to arrive before adding widget. Core, BLE: disable debug dump to serial.
* delete old app example-ipc
* delete old app fatfs list
* fix strobe app, add input header
* delete old display driver
* comment old app qr-code
* fix sd-card test, add forced widget update
* remove unused new core test
* increase heap to 128k
* comment and assert old core tests
* fix syntax
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-01-20 19:09:26 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|