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_ipc.c
Go to the documentation of this file.
1
7
#include "
rte/oal/ipc/rte_ipc.h
"
8
#include "
rte/utils/lifecycle/rte_lifecycle.h
"
9
#include "
rte_osadapter/ipc/rte_osadapter_ipc.h
"
10
12
14
17
static
const
rte_osadapter_ipc_t
*
s_osadapter
= NULL;
18
20
22
23
25
rte_status_t
rte_osadapter_ipc_register
(
const
rte_osadapter_ipc_t
*osadapter)
26
{
27
rte_status_t
lifecycle_status;
28
29
if
(osadapter == NULL)
30
{
31
return
RTE_STATUS_INVALID_PARAM
;
32
}
33
/* REQ-LIFECYCLE-001 (ADR-026): registering an OSAdapter is a setup-only
34
* action - refuse once the application's setup phase has been locked. */
35
lifecycle_status =
rte_lifecycle_check_setup_allowed
();
36
if
(lifecycle_status !=
RTE_STATUS_OK
)
37
{
38
return
lifecycle_status;
39
}
40
s_osadapter
= osadapter;
41
return
RTE_STATUS_OK
;
42
}
43
44
rte_status_t
rte_ipc_create
(rte_ipc_storage_t *storage,
45
const
rte_ipc_config_t
*config,
46
rte_ipc_handle_t
*out_handle)
47
{
48
if
((storage == NULL) || (config == NULL) || (out_handle == NULL))
49
{
50
return
RTE_STATUS_INVALID_PARAM
;
51
}
52
if
((config->
message_size
== 0U) || (config->
queue_depth
== 0U))
53
{
54
return
RTE_STATUS_INVALID_PARAM
;
55
}
56
*out_handle = NULL;
57
/* REQ-LIFECYCLE-001/003 (ADR-026, OSA rules): setup-only - refused and reported once the setup phase is locked. */
58
{
59
rte_status_t
lifecycle_status =
rte_lifecycle_check_setup_allowed
();
60
61
if
(lifecycle_status !=
RTE_STATUS_OK
)
62
{
63
return
lifecycle_status;
64
}
65
}
66
if
(
s_osadapter
== NULL)
67
{
68
return
RTE_STATUS_NOT_INITIALIZED
;
69
}
70
if
(
s_osadapter
->create == NULL)
71
{
72
return
RTE_STATUS_NOT_SUPPORTED
;
73
}
74
return
s_osadapter
->create(storage, config, out_handle);
75
}
76
77
rte_status_t
rte_ipc_send
(
rte_ipc_handle_t
handle,
78
const
void
*message,
79
size_t
message_size,
80
rte_duration_ms_t
timeout_ms)
81
{
82
if
((handle == NULL) || (message == NULL) || (message_size == 0U))
83
{
84
return
RTE_STATUS_INVALID_PARAM
;
85
}
86
if
(
s_osadapter
== NULL)
87
{
88
return
RTE_STATUS_NOT_INITIALIZED
;
89
}
90
if
(
s_osadapter
->send == NULL)
91
{
92
return
RTE_STATUS_NOT_SUPPORTED
;
93
}
94
return
s_osadapter
->send(handle, message, message_size, timeout_ms);
95
}
96
97
rte_status_t
rte_ipc_receive
(
rte_ipc_handle_t
handle,
98
void
*out_message,
99
size_t
buffer_size,
100
rte_duration_ms_t
timeout_ms)
101
{
102
if
((handle == NULL) || (out_message == NULL) || (buffer_size == 0U))
103
{
104
return
RTE_STATUS_INVALID_PARAM
;
105
}
106
if
(
s_osadapter
== NULL)
107
{
108
return
RTE_STATUS_NOT_INITIALIZED
;
109
}
110
if
(
s_osadapter
->receive == NULL)
111
{
112
return
RTE_STATUS_NOT_SUPPORTED
;
113
}
114
return
s_osadapter
->receive(handle, out_message, buffer_size, timeout_ms);
115
}
116
117
rte_status_t
rte_ipc_destroy
(
rte_ipc_handle_t
handle)
118
{
119
if
(handle == NULL)
120
{
121
return
RTE_STATUS_INVALID_PARAM
;
122
}
123
if
(
s_osadapter
== NULL)
124
{
125
return
RTE_STATUS_NOT_INITIALIZED
;
126
}
127
if
(
s_osadapter
->destroy == NULL)
128
{
129
return
RTE_STATUS_NOT_SUPPORTED
;
130
}
131
return
s_osadapter
->destroy(handle);
132
}
rte_ipc_create
rte_status_t rte_ipc_create(rte_ipc_storage_t *storage, const rte_ipc_config_t *config, rte_ipc_handle_t *out_handle)
Creates a bounded message channel.
Definition
rte_ipc.c:44
rte_ipc_handle_t
struct rte_ipc_impl_s * rte_ipc_handle_t
Opaque handle to a created IPC channel, returned by rte_ipc_create().
Definition
rte_ipc.h:34
rte_ipc_receive
rte_status_t rte_ipc_receive(rte_ipc_handle_t handle, void *out_message, size_t buffer_size, rte_duration_ms_t timeout_ms)
Receives one message, blocking at most timeout_ms.
Definition
rte_ipc.c:97
rte_ipc_send
rte_status_t rte_ipc_send(rte_ipc_handle_t handle, const void *message, size_t message_size, rte_duration_ms_t timeout_ms)
Sends one message, blocking at most timeout_ms.
Definition
rte_ipc.c:77
rte_ipc_destroy
rte_status_t rte_ipc_destroy(rte_ipc_handle_t handle)
Destroys a message channel.
Definition
rte_ipc.c:117
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_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
rte_duration_ms_t
uint32_t rte_duration_ms_t
Definition
rte_types.h:27
s_osadapter
static const rte_osadapter_clocksync_t * s_osadapter
Definition
rte_clocksync.c:18
rte_ipc.h
OS Abstraction Layer - Inter-process/inter-task communication service.
rte_lifecycle.h
Process-wide application setup-phase lock (ADR-026).
rte_osadapter_ipc.h
OSAdapter interface for inter-process communication.
rte_osadapter_ipc_register
rte_status_t rte_osadapter_ipc_register(const rte_osadapter_ipc_t *adapter)
Registers the OSAdapter IPC implementation.
Definition
rte_ipc.c:25
rte_ipc_config_t
Configuration for rte_ipc_create().
Definition
rte_ipc.h:38
rte_ipc_config_t::message_size
size_t message_size
Definition
rte_ipc.h:40
rte_ipc_config_t::queue_depth
size_t queue_depth
Definition
rte_ipc.h:41
rte_osadapter_ipc_t
OSAdapter IPC operations vtable.
Definition
rte_osadapter_ipc.h:23
src
oal
ipc
rte_ipc.c
Generated by
1.18.0