30#ifndef SAPI_WATCHDOG_MAX_COUNT
34#define SAPI_WATCHDOG_MAX_COUNT 8U
176 return lifecycle_status;
sapi_status_t sapi_lifecycle_check_setup_allowed(void)
Convenience check for a setup-only constructor: call this as one of the first checks in any function ...
void sapi_log_write(sapi_log_level_t level, const char *tag, const char *message)
Emits one log message. Non-blocking; never fails the caller's control flow even if the message is dro...
#define SAPI_SAFESTATE_REASON_UNSPECIFIED
void sapi_safestate_enter(sapi_safestate_level_t level, sapi_safestate_reason_t reason, const char *file, int32_t line, const char *message)
Enters a safe-state level: invokes the registered handler (if any), then, for SAPI_SAFESTATE_LEVEL_SA...
@ SAPI_SAFESTATE_LEVEL_REBOOT
@ SAPI_SAFESTATE_LEVEL_SAFE
sapi_status_t
Common result/status codes.
@ SAPI_STATUS_INTERNAL_ERROR
@ SAPI_STATUS_INVALID_PARAM
@ SAPI_STATUS_RESOURCE_EXHAUSTED
@ SAPI_STATUS_NOT_INITIALIZED
sapi_status_t sapi_timer_now(sapi_timestamp_ms_t *out_now_ms)
Returns the current monotonic time base used by all timers.
uint32_t sapi_duration_ms_t
uint64_t sapi_timestamp_ms_t
sapi_status_t sapi_watchdog_stop(sapi_watchdog_t watchdog)
Stop watchdog timer.
sapi_status_t sapi_watchdog_manager_initialize(void)
Initialize watchdog manager (call once at startup).
sapi_status_t sapi_watchdog_get_status(sapi_watchdog_t watchdog, sapi_watchdog_status_t *status_out)
Get watchdog status.
sapi_status_t sapi_watchdog_destroy(sapi_watchdog_t watchdog)
Destroy watchdog.
void sapi_watchdog_timeout_handler(uint32_t watchdog_id)
Watchdog timeout handler (INTERNAL - called by framework).
sapi_watchdog_action_t
Recovery action when watchdog fires.
sapi_status_t sapi_watchdog_create(sapi_watchdog_t *handle_out, const sapi_watchdog_config_t *config)
Create a watchdog.
sapi_status_t sapi_watchdog_manager_shutdown(void)
Shutdown watchdog manager (call once at shutdown).
sapi_status_t sapi_watchdog_kick(sapi_watchdog_t watchdog)
Kick (pet) watchdog - prove liveness.
sapi_status_t sapi_watchdog_start(sapi_watchdog_t watchdog)
Start watchdog timer.
void sapi_watchdog_timer_tick(void)
Poll all active watchdogs for expiry (call periodically).
@ SAPI_WATCHDOG_ACTION_LOG
@ SAPI_WATCHDOG_ACTION_REBOOT
@ SAPI_WATCHDOG_ACTION_SAFESTATE
@ SAPI_WATCHDOG_ACTION_FAILOVER
@ SAPI_WATCHDOG_ACTION_CUSTOM
Process-wide application setup-phase lock (ADR-026).
OS Abstraction Layer - Logging/diagnostics service.
Safe-state transitions and checked assertions (ADR-004).
OS Abstraction Layer - Timer service.
static sapi_watchdog_s g_watchdog_pool[SAPI_WATCHDOG_MAX_COUNT]
Fixed-size static pool backing every sapi_watchdog_t handle.
static bool is_valid_handle(sapi_watchdog_t watchdog)
Defensive check that handle actually points at one of this module's own live pool slots,...
#define SAPI_WATCHDOG_MAX_COUNT
static uint8_t g_manager_initialized
1 once sapi_watchdog_manager_initialize() has been called.
static bool is_valid_action(sapi_watchdog_action_t action)
Checks whether action is one of the defined sapi_watchdog_action_t enumerators.
Watchdog mechanism for detecting system/task hang conditions.
sapi_watchdog_action_t action
void(*) custom_action(void *ctx)
sapi_duration_ms_t timeout_ms
Watchdog handle (opaque).
sapi_timestamp_ms_t last_kick_ms
sapi_watchdog_config_t config
sapi_timestamp_ms_t deadline_ms
Watchdog health/status information.
sapi_duration_ms_t time_since_last_kick
sapi_duration_ms_t time_until_fire