| 1 | #pragma once |
| 2 | #include <console/crash.h> |
| 3 | #include <stdbool.h> |
| 4 | #include <stddef.h> |
| 5 | #include <time/time.h> |
| 6 | #include <watchdog.h> |
| 7 | |
| 8 | #define watchdog_panic(fmt, ...) \ |
| 9 | do { \ |
| 10 | char _wd_msg[CRASH_MSG_MAX]; \ |
| 11 | snprintf(_wd_msg, sizeof(_wd_msg), fmt, ##__VA_ARGS__); \ |
| 12 | crash_full(&(struct crash_context) { \ |
| 13 | .source = CRASH_SOURCE_NMI_WATCHDOG, \ |
| 14 | .formats = CRASH_FMT_DEFAULT, \ |
| 15 | .file = __FILE__, \ |
| 16 | .line = __LINE__, \ |
| 17 | .func = __func__, \ |
| 18 | .msg = _wd_msg, \ |
| 19 | }); \ |
| 20 | } while (0) |
| 21 | |
| 22 | bool watchdog_count_heartbeats_at(const struct watchdog_buckets *buckets, |
| 23 | size_t window_buckets, time_ms_t now, |
| 24 | time_ms_t bucket_interval_ms, |
| 25 | size_t expected_per_bucket, |
| 26 | size_t *out_heartbeats, size_t *out_expected, |
| 27 | fx32_32_t *out_score); |
| 28 | |