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_reboot.c
Go to the documentation of this file.
1
7
#include "
safeapi/oal/reboot/sapi_reboot.h
"
8
#include "
safeapi/utils/lifecycle/sapi_lifecycle.h
"
9
#include "
safeapi_backend/reboot/sapi_reboot_backend.h
"
10
12
14
17
static
const
sapi_reboot_backend_t
*
s_backend
= NULL;
18
20
22
23
25
sapi_status_t
sapi_reboot_register_backend
(
const
sapi_reboot_backend_t
*backend)
26
{
27
sapi_status_t
lifecycle_status;
28
29
if
(backend == NULL)
30
{
31
return
SAPI_STATUS_INVALID_PARAM
;
32
}
33
/* REQ-LIFECYCLE-001 (ADR-026): registering a backend is a setup-only
34
* action - refuse once the application's setup phase has been locked. */
35
lifecycle_status =
sapi_lifecycle_check_setup_allowed
();
36
if
(lifecycle_status !=
SAPI_STATUS_OK
)
37
{
38
return
lifecycle_status;
39
}
40
s_backend
= backend;
41
return
SAPI_STATUS_OK
;
42
}
43
44
sapi_status_t
sapi_reboot_request
(uint16_t reason_code)
45
{
46
if
(
s_backend
== NULL)
47
{
48
return
SAPI_STATUS_NOT_INITIALIZED
;
49
}
50
if
(
s_backend
->
request
== NULL)
51
{
52
return
SAPI_STATUS_NOT_SUPPORTED
;
53
}
54
return
s_backend
->
request
(reason_code);
55
}
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_reboot_register_backend
sapi_status_t sapi_reboot_register_backend(const sapi_reboot_backend_t *backend)
Registers the backend implementation used by sapi_reboot_request() (ADR-005 section 2....
Definition
sapi_reboot.c:25
sapi_reboot_request
sapi_status_t sapi_reboot_request(uint16_t reason_code)
Requests a controlled system restart.
Definition
sapi_reboot.c:44
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_reboot.h
OS Abstraction Layer - Controlled reboot service (ADR-004 section 3).
sapi_reboot_backend.h
OS-backend adaptation surface for the Controlled Reboot service (ADR-004 section 3,...
sapi_reboot_backend_t
Backend vtable: an integrator's implementation of the reboot mechanism for a specific target (ADR-005...
Definition
sapi_reboot_backend.h:31
sapi_reboot_backend_t::request
sapi_status_t(*) request(uint16_t reason_code)
Backend implementation of sapi_reboot_request(). May be NULL.
Definition
sapi_reboot_backend.h:33
src
oal
reboot
sapi_reboot.c
Generated by
1.18.0