Safe API Framework
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
Loading...
Searching...
No Matches
sapi_safestate.c File Reference

Implementation of the safe-state transition facility (ADR-004). More...

Include dependency graph for sapi_safestate.c:

Go to the source code of this file.

Functions

static bool sapi_safestate_level_to_index (sapi_safestate_level_t level, size_t *out_index)
 Maps a level enumerator to its handler-array index.
sapi_status_t sapi_safestate_register_handler (sapi_safestate_level_t level, sapi_safestate_handler_t handler)
 Registers the reaction handler for one safe-state level. This is how an integrator supplies their own implementation of "what happens when this level is entered" (ADR-004 section 2.2).
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_SAFE and SAPI_SAFESTATE_LEVEL_REBOOT, guarantees the call never returns (REQ-COMMON-SAFESTATE-002) even if no handler was registered or the handler itself returns.

Variables

static sapi_safestate_handler_t s_handlers [3] = { NULL, NULL, NULL }

Detailed Description

Implementation of the safe-state transition facility (ADR-004).

Definition in file sapi_safestate.c.

Function Documentation

◆ sapi_safestate_level_to_index()

bool sapi_safestate_level_to_index ( sapi_safestate_level_t level,
size_t * out_index )
static

Maps a level enumerator to its handler-array index.

Global variables declarations Local function declarations

Parameters
levelLevel to map.
out_indexReceives the handler-array index. Must not be NULL.
Returns
true and sets *out_index if level is a known value; false (index left unset) otherwise.

Definition at line 96 of file sapi_safestate.c.

Variable Documentation

◆ s_handlers

sapi_safestate_handler_t s_handlers[3] = { NULL, NULL, NULL }
static

Local makros Local types declarations Local variables declarations One handler slot per sapi_safestate_level_t value; no dynamic allocation.

Definition at line 15 of file sapi_safestate.c.