Safe API Framework
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
Toggle main menu visibility
Loading...
Searching...
No Matches
sapi_platform.c
Go to the documentation of this file.
1
8
#include "
safeapi/oal/platform/sapi_platform.h
"
9
#include "
safeapi/utils/lifecycle/sapi_lifecycle.h
"
10
#include "
safeapi_backend/platform/sapi_platform_backend.h
"
11
14
#define SAPI_PLATFORM_RT_PRIORITY_MAX 99U
15
17
20
static
const
sapi_platform_backend_t
*
s_backend
= NULL;
21
23
25
26
28
sapi_status_t
sapi_platform_register_backend
(
const
sapi_platform_backend_t
*backend)
29
{
30
sapi_status_t
lifecycle_status;
31
32
if
(backend == NULL)
33
{
34
return
SAPI_STATUS_INVALID_PARAM
;
35
}
36
/* REQ-LIFECYCLE-001 (ADR-026): registering a backend is a setup-only
37
* action - refuse once the application's setup phase has been locked. */
38
lifecycle_status =
sapi_lifecycle_check_setup_allowed
();
39
if
(lifecycle_status !=
SAPI_STATUS_OK
)
40
{
41
return
lifecycle_status;
42
}
43
s_backend
= backend;
44
return
SAPI_STATUS_OK
;
45
}
46
47
sapi_status_t
sapi_platform_realtime_init
(uint32_t rt_priority)
48
{
49
if
(rt_priority >
SAPI_PLATFORM_RT_PRIORITY_MAX
)
50
{
51
return
SAPI_STATUS_INVALID_PARAM
;
52
}
53
if
(
s_backend
== NULL)
54
{
55
return
SAPI_STATUS_NOT_INITIALIZED
;
56
}
57
if
(
s_backend
->
realtime_init
== NULL)
58
{
59
return
SAPI_STATUS_NOT_SUPPORTED
;
60
}
61
return
s_backend
->
realtime_init
(rt_priority);
62
}
sapi_lifecycle_check_setup_allowed
sapi_status_t sapi_lifecycle_check_setup_allowed(void)
Convenience check for a setup-only constructor: call this as one of the first checks in any function ...
Definition
sapi_lifecycle.c:40
sapi_platform_register_backend
sapi_status_t sapi_platform_register_backend(const sapi_platform_backend_t *backend)
Registers the backend implementation used by sapi_platform_realtime_init() (ADR-005 section 2....
Definition
sapi_platform.c:28
sapi_platform_realtime_init
sapi_status_t sapi_platform_realtime_init(uint32_t rt_priority)
Applies the registered backend's real-time platform configuration for the calling process/thread....
Definition
sapi_platform.c:47
sapi_status_t
sapi_status_t
Common result/status codes.
Definition
sapi_status.h:27
SAPI_STATUS_NOT_SUPPORTED
@ SAPI_STATUS_NOT_SUPPORTED
Definition
sapi_status.h:34
SAPI_STATUS_INVALID_PARAM
@ SAPI_STATUS_INVALID_PARAM
Definition
sapi_status.h:29
SAPI_STATUS_NOT_INITIALIZED
@ SAPI_STATUS_NOT_INITIALIZED
Definition
sapi_status.h:30
SAPI_STATUS_OK
@ SAPI_STATUS_OK
Definition
sapi_status.h:28
s_backend
static const sapi_clocksync_backend_t * s_backend
Definition
sapi_clocksync.c:18
sapi_lifecycle.h
Process-wide application setup-phase lock (ADR-026).
SAPI_PLATFORM_RT_PRIORITY_MAX
#define SAPI_PLATFORM_RT_PRIORITY_MAX
Highest real-time priority sapi_platform_realtime_init() accepts.
Definition
sapi_platform.c:14
sapi_platform.h
OS Abstraction Layer - Real-time platform configuration service (ADR-035).
sapi_platform_backend.h
OS-backend adaptation surface for the Real-Time Platform Configuration service (ADR-035,...
sapi_platform_backend_t
Backend vtable: an integrator's implementation of the real-time platform bring-up for a specific targ...
Definition
sapi_platform_backend.h:32
sapi_platform_backend_t::realtime_init
sapi_status_t(*) realtime_init(uint32_t rt_priority)
Backend implementation of sapi_platform_realtime_init(). May be NULL (the service then returns SAPI_S...
Definition
sapi_platform_backend.h:42
src
oal
platform
sapi_platform.c
Generated by
1.18.0