Safe API Framework
0.1.0 build 384e6ae
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
Toggle main menu visibility
Loading...
Searching...
No Matches
rte_lifecycle.c
Go to the documentation of this file.
1
7
#include "
rte/utils/lifecycle/rte_lifecycle.h
"
8
#include "
rte/utils/safestate/rte_safestate.h
"
9
11
13
18
static
bool
g_setup_locked
=
false
;
19
21
23
24
26
void
rte_lifecycle_lock
(
void
)
27
{
28
g_setup_locked
=
true
;
29
}
30
31
void
rte_lifecycle_unlock
(
void
)
32
{
33
g_setup_locked
=
false
;
34
}
35
36
bool
rte_lifecycle_is_locked
(
void
)
37
{
38
return
g_setup_locked
;
39
}
40
41
rte_status_t
rte_lifecycle_check_setup_allowed
(
void
)
42
{
43
rte_status_t
status =
RTE_STATUS_OK
;
44
45
if
(
g_setup_locked
)
46
{
47
/* REQ-LIFECYCLE-003: report the violation (DEGRADED returns; the caller still gets INVALID_STATE and
48
* the integrator's DEGRADED handler decides what it means). */
49
rte_safestate_enter
(
RTE_SAFESTATE_LEVEL_DEGRADED
,
RTE_SAFESTATE_REASON_SETUP_AFTER_INIT
, __FILE__,
50
(int32_t)__LINE__,
"setup-only resource requested after the setup phase was locked"
);
51
status =
RTE_STATUS_INVALID_STATE
;
52
}
53
return
status;
54
}
rte_lifecycle_check_setup_allowed
rte_status_t rte_lifecycle_check_setup_allowed(void)
Convenience check for a setup-only constructor: call this as one of the first checks in any function ...
Definition
rte_lifecycle.c:41
rte_lifecycle_lock
void rte_lifecycle_lock(void)
Locks the application's setup phase.
Definition
rte_lifecycle.c:26
rte_lifecycle_unlock
void rte_lifecycle_unlock(void)
Unlocks the application's setup phase (setup is allowed again).
Definition
rte_lifecycle.c:31
rte_lifecycle_is_locked
bool rte_lifecycle_is_locked(void)
Definition
rte_lifecycle.c:36
RTE_SAFESTATE_REASON_SETUP_AFTER_INIT
#define RTE_SAFESTATE_REASON_SETUP_AFTER_INIT
Definition
rte_safestate.h:75
rte_safestate_enter
void rte_safestate_enter(rte_safestate_level_t level, rte_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 RTE_SAFESTATE_LEVEL_SAF...
Definition
rte_safestate.c:52
RTE_SAFESTATE_LEVEL_DEGRADED
@ RTE_SAFESTATE_LEVEL_DEGRADED
Definition
rte_safestate.h:45
rte_status_t
rte_status_t
Common result/status codes.
Definition
rte_status.h:27
RTE_STATUS_INVALID_STATE
@ RTE_STATUS_INVALID_STATE
Definition
rte_status.h:40
RTE_STATUS_OK
@ RTE_STATUS_OK
Definition
rte_status.h:28
g_setup_locked
static bool g_setup_locked
Single, process-wide setup-phase flag (single instance; no dynamic allocation - same posture as rte_a...
Definition
rte_lifecycle.c:18
rte_lifecycle.h
Process-wide application setup-phase lock (ADR-026).
rte_safestate.h
Safe-state transitions and checked assertions (ADR-004).
src
utils
lifecycle
rte_lifecycle.c
Generated by
1.18.0