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_fsou.c
Go to the documentation of this file.
1
6
#include "
rte/oal/fsou/rte_fsou.h
"
7
#include "
rte/oal/log/rte_log.h
"
8
#include "
rte/utils/lifecycle/rte_lifecycle.h
"
9
#include "
rte_osadapter/fsou/rte_osadapter_fsou.h
"
10
12
14
#define RTE_FSOU_LOG_TAG "FSOU"
15
17
21
static
const
rte_osadapter_fsou_t
*
s_osadapter
= NULL;
22
24
26
27
29
rte_status_t
rte_osadapter_fsou_register
(
const
rte_osadapter_fsou_t
*adapter)
30
{
31
rte_status_t
status =
RTE_STATUS_OK
;
32
33
/* REQ-FSOU-001 */
34
if
(adapter == NULL)
35
{
36
status =
RTE_STATUS_INVALID_PARAM
;
37
}
38
else
39
{
40
/* REQ-LIFECYCLE-001 (ADR-026): registering an OSAdapter is a setup-only
41
* action - refuse once the application's setup phase has been locked. */
42
status =
rte_lifecycle_check_setup_allowed
();
43
if
(status ==
RTE_STATUS_OK
)
44
{
45
s_osadapter
= adapter;
46
}
47
}
48
49
return
status;
50
}
51
52
rte_status_t
rte_fsou_grant
(uint32_t cycle_id)
53
{
54
rte_status_t
status =
RTE_STATUS_OK
;
55
56
/* REQ-FSOU-002 */
57
if
(
s_osadapter
== NULL)
58
{
59
status =
RTE_STATUS_NOT_INITIALIZED
;
60
}
61
else
if
(
s_osadapter
->
grant
== NULL)
62
{
63
status =
RTE_STATUS_NOT_SUPPORTED
;
64
}
65
else
66
{
67
status =
s_osadapter
->
grant
(cycle_id);
68
}
69
70
return
status;
71
}
72
73
rte_status_t
rte_fsou_revoke
(
rte_safestate_reason_t
reason)
74
{
75
rte_status_t
status =
RTE_STATUS_OK
;
76
77
/* REQ-FSOU-002 */
78
if
(
s_osadapter
== NULL)
79
{
80
status =
RTE_STATUS_NOT_INITIALIZED
;
81
}
82
else
if
(
s_osadapter
->
revoke
== NULL)
83
{
84
status =
RTE_STATUS_NOT_SUPPORTED
;
85
}
86
else
87
{
88
status =
s_osadapter
->
revoke
(reason);
89
}
90
91
return
status;
92
}
93
94
bool
rte_fsou_is_present
(
void
)
95
{
96
return
(
s_osadapter
!= NULL);
97
}
98
99
void
rte_fsou_report_presence
(
void
)
100
{
102
static
bool
s_presence_reported =
false
;
103
104
/* REQ-FSOU-003: one line per process, latched. */
105
if
(!s_presence_reported)
106
{
107
s_presence_reported =
true
;
108
if
(
s_osadapter
!= NULL)
109
{
110
rte_log_write
(
RTE_LOG_LEVEL_INFO
,
RTE_FSOU_LOG_TAG
,
"FSOU present"
);
111
}
112
else
113
{
114
rte_log_write
(
RTE_LOG_LEVEL_INFO
,
RTE_FSOU_LOG_TAG
,
"no FSOU registered"
);
115
}
116
}
117
}
rte_fsou_report_presence
void rte_fsou_report_presence(void)
Logs once whether an FSOU is present (REQ-FSOU-003).
Definition
rte_fsou.c:99
rte_fsou_grant
rte_status_t rte_fsou_grant(uint32_t cycle_id)
Grants this channel's output permission to the FSOU for one cycle (REQ-FSOU-002).
Definition
rte_fsou.c:52
rte_fsou_is_present
bool rte_fsou_is_present(void)
Tells whether an FSOU OSAdapter is registered.
Definition
rte_fsou.c:94
rte_fsou_revoke
rte_status_t rte_fsou_revoke(rte_safestate_reason_t reason)
Withdraws this channel's output permission from the FSOU (REQ-FSOU-002).
Definition
rte_fsou.c:73
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_log_write
void rte_log_write(rte_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...
Definition
rte_log.c:108
RTE_LOG_LEVEL_INFO
@ RTE_LOG_LEVEL_INFO
Definition
rte_log.h:36
rte_safestate_reason_t
uint16_t rte_safestate_reason_t
Diagnostic reason code accompanying a safe-state transition.
Definition
rte_safestate.h:63
rte_status_t
rte_status_t
Common result/status codes.
Definition
rte_status.h:27
RTE_STATUS_OK
@ RTE_STATUS_OK
Definition
rte_status.h:28
RTE_STATUS_INVALID_PARAM
@ RTE_STATUS_INVALID_PARAM
Definition
rte_status.h:29
RTE_STATUS_NOT_SUPPORTED
@ RTE_STATUS_NOT_SUPPORTED
Definition
rte_status.h:34
RTE_STATUS_NOT_INITIALIZED
@ RTE_STATUS_NOT_INITIALIZED
Definition
rte_status.h:30
s_osadapter
static const rte_osadapter_clocksync_t * s_osadapter
Definition
rte_clocksync.c:18
RTE_FSOU_LOG_TAG
#define RTE_FSOU_LOG_TAG
Definition
rte_fsou.c:14
rte_fsou.h
Fail-Safe Output Unit (FSOU) output permission, optional OSAdapter seam (ADR-041, proposed).
rte_lifecycle.h
Process-wide application setup-phase lock (ADR-026).
rte_log.h
OS Abstraction Layer - Logging/diagnostics service.
rte_osadapter_fsou.h
OSAdapter interface for the Fail-Safe Output Unit (FSOU) output permission (ADR-041).
rte_osadapter_fsou_register
rte_status_t rte_osadapter_fsou_register(const rte_osadapter_fsou_t *adapter)
Registers the OSAdapter FSOU implementation (REQ-FSOU-001).
Definition
rte_fsou.c:29
rte_osadapter_fsou_t
OSAdapter FSOU operations vtable.
Definition
rte_osadapter_fsou.h:31
rte_osadapter_fsou_t::grant
rte_status_t(*) grant(uint32_t cycle_id)
Definition
rte_osadapter_fsou.h:33
rte_osadapter_fsou_t::revoke
rte_status_t(*) revoke(rte_safestate_reason_t reason)
Definition
rte_osadapter_fsou.h:35
src
oal
fsou
rte_fsou.c
Generated by
1.18.0