Safe API Framework 0.1.0 build 384e6ae
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
Loading...
Searching...
No Matches
rte_ipc.c
Go to the documentation of this file.
1
10
12
14
17static const rte_osadapter_ipc_t *s_osadapter = NULL;
18
20
22
23
26{
27 rte_status_t lifecycle_status;
28
29 if (osadapter == NULL)
30 {
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
44rte_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 {
51 }
52 if ((config->message_size == 0U) || (config->queue_depth == 0U))
53 {
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 {
60
61 if (lifecycle_status != RTE_STATUS_OK)
62 {
63 return lifecycle_status;
64 }
65 }
66 if (s_osadapter == NULL)
67 {
69 }
70 if (s_osadapter->create == NULL)
71 {
73 }
74 return s_osadapter->create(storage, config, out_handle);
75}
76
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 {
85 }
86 if (s_osadapter == NULL)
87 {
89 }
90 if (s_osadapter->send == NULL)
91 {
93 }
94 return s_osadapter->send(handle, message, message_size, timeout_ms);
95}
96
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 {
105 }
106 if (s_osadapter == NULL)
107 {
109 }
110 if (s_osadapter->receive == NULL)
111 {
113 }
114 return s_osadapter->receive(handle, out_message, buffer_size, timeout_ms);
115}
116
118{
119 if (handle == NULL)
120 {
122 }
123 if (s_osadapter == NULL)
124 {
126 }
127 if (s_osadapter->destroy == NULL)
128 {
130 }
131 return s_osadapter->destroy(handle);
132}
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
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_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_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_status_t rte_ipc_destroy(rte_ipc_handle_t handle)
Destroys a message channel.
Definition rte_ipc.c:117
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 ...
rte_status_t
Common result/status codes.
Definition rte_status.h:27
@ RTE_STATUS_OK
Definition rte_status.h:28
@ RTE_STATUS_INVALID_PARAM
Definition rte_status.h:29
@ RTE_STATUS_NOT_SUPPORTED
Definition rte_status.h:34
@ RTE_STATUS_NOT_INITIALIZED
Definition rte_status.h:30
uint32_t rte_duration_ms_t
Definition rte_types.h:27
static const rte_osadapter_clocksync_t * s_osadapter
OS Abstraction Layer - Inter-process/inter-task communication service.
Process-wide application setup-phase lock (ADR-026).
OSAdapter interface for inter-process communication.
rte_status_t rte_osadapter_ipc_register(const rte_osadapter_ipc_t *adapter)
Registers the OSAdapter IPC implementation.
Definition rte_ipc.c:25
Configuration for rte_ipc_create().
Definition rte_ipc.h:38
size_t message_size
Definition rte_ipc.h:40
size_t queue_depth
Definition rte_ipc.h:41
OSAdapter IPC operations vtable.