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_watchdog.h
Go to the documentation of this file.
1
16
17
#ifndef SAPI_WATCHDOG_H
18
#define SAPI_WATCHDOG_H
19
20
#include "
safeapi/utils/status/sapi_status.h
"
21
#include "
safeapi/utils/types/sapi_types.h
"
22
23
#ifdef __cplusplus
24
extern
"C"
{
25
#endif
26
27
/* ============================================================================
28
* Types & Constants
29
* ========================================================================== */
30
34
typedef
struct
sapi_watchdog_s
*sapi_watchdog_t;
35
41
typedef
enum
{
42
SAPI_WATCHDOG_SYSTEM
,
43
SAPI_WATCHDOG_TASK
,
44
SAPI_WATCHDOG_CHANNEL
,
45
SAPI_WATCHDOG_CHECKPOINT
46
}
sapi_watchdog_type_t
;
47
53
typedef
enum
{
54
SAPI_WATCHDOG_ACTION_LOG
,
55
SAPI_WATCHDOG_ACTION_SAFESTATE
,
56
SAPI_WATCHDOG_ACTION_REBOOT
,
57
SAPI_WATCHDOG_ACTION_FAILOVER
,
67
SAPI_WATCHDOG_ACTION_CUSTOM
68
}
sapi_watchdog_action_t
;
69
75
typedef
struct
{
76
sapi_watchdog_type_t
type
;
77
const
char
*
name
;
78
sapi_duration_ms_t
timeout_ms
;
79
sapi_watchdog_action_t
action
;
80
void (*
custom_action
)(
void
*ctx);
85
void
*
context
;
86
}
sapi_watchdog_config_t
;
87
93
typedef
struct
{
94
uint8_t
active
;
95
uint32_t
kicks
;
96
uint32_t
fires
;
97
uint32_t
recoveries
;
98
sapi_duration_ms_t
time_since_last_kick
;
99
sapi_duration_ms_t
time_until_fire
;
100
}
sapi_watchdog_status_t
;
101
102
/* ============================================================================
103
* API: Core Watchdog Operations
104
* ========================================================================== */
105
134
sapi_status_t
sapi_watchdog_create
(sapi_watchdog_t *handle_out,
135
const
sapi_watchdog_config_t
*config);
136
151
sapi_status_t
sapi_watchdog_start
(sapi_watchdog_t watchdog);
152
167
sapi_status_t
sapi_watchdog_stop
(sapi_watchdog_t watchdog);
168
194
sapi_status_t
sapi_watchdog_kick
(sapi_watchdog_t watchdog);
195
219
sapi_status_t
sapi_watchdog_get_status
(sapi_watchdog_t watchdog,
220
sapi_watchdog_status_t
*status_out);
221
235
sapi_status_t
sapi_watchdog_destroy
(sapi_watchdog_t watchdog);
236
237
/* ============================================================================
238
* API: Watchdog Manager (Global)
239
* ========================================================================== */
240
253
sapi_status_t
sapi_watchdog_manager_initialize
(
void
);
254
267
sapi_status_t
sapi_watchdog_manager_shutdown
(
void
);
268
269
/* ============================================================================
270
* Watchdog Timeout Callback (Invoked by Framework)
271
* ========================================================================== */
272
288
void
sapi_watchdog_timeout_handler
(uint32_t watchdog_id);
289
305
void
sapi_watchdog_timer_tick
(
void
);
306
307
#ifdef __cplusplus
308
}
309
#endif
310
311
#endif
/* SAPI_WATCHDOG_H */
312
/* WATCHDOG */
sapi_status_t
sapi_status_t
Common result/status codes.
Definition
sapi_status.h:27
sapi_duration_ms_t
uint32_t sapi_duration_ms_t
Definition
sapi_types.h:27
sapi_watchdog_stop
sapi_status_t sapi_watchdog_stop(sapi_watchdog_t watchdog)
Stop watchdog timer.
Definition
sapi_watchdog.c:212
sapi_watchdog_manager_initialize
sapi_status_t sapi_watchdog_manager_initialize(void)
Initialize watchdog manager (call once at startup).
Definition
sapi_watchdog.c:118
sapi_watchdog_get_status
sapi_status_t sapi_watchdog_get_status(sapi_watchdog_t watchdog, sapi_watchdog_status_t *status_out)
Get watchdog status.
Definition
sapi_watchdog.c:249
sapi_watchdog_destroy
sapi_status_t sapi_watchdog_destroy(sapi_watchdog_t watchdog)
Destroy watchdog.
Definition
sapi_watchdog.c:269
sapi_watchdog_timeout_handler
void sapi_watchdog_timeout_handler(uint32_t watchdog_id)
Watchdog timeout handler (INTERNAL - called by framework).
Definition
sapi_watchdog.c:286
sapi_watchdog_type_t
sapi_watchdog_type_t
Watchdog type.
Definition
sapi_watchdog.h:41
sapi_watchdog_action_t
sapi_watchdog_action_t
Recovery action when watchdog fires.
Definition
sapi_watchdog.h:53
sapi_watchdog_create
sapi_status_t sapi_watchdog_create(sapi_watchdog_t *handle_out, const sapi_watchdog_config_t *config)
Create a watchdog.
Definition
sapi_watchdog.c:146
sapi_watchdog_manager_shutdown
sapi_status_t sapi_watchdog_manager_shutdown(void)
Shutdown watchdog manager (call once at shutdown).
Definition
sapi_watchdog.c:129
sapi_watchdog_kick
sapi_status_t sapi_watchdog_kick(sapi_watchdog_t watchdog)
Kick (pet) watchdog - prove liveness.
Definition
sapi_watchdog.c:224
sapi_watchdog_start
sapi_status_t sapi_watchdog_start(sapi_watchdog_t watchdog)
Start watchdog timer.
Definition
sapi_watchdog.c:195
sapi_watchdog_timer_tick
void sapi_watchdog_timer_tick(void)
Poll all active watchdogs for expiry (call periodically).
Definition
sapi_watchdog.c:369
SAPI_WATCHDOG_CHECKPOINT
@ SAPI_WATCHDOG_CHECKPOINT
Definition
sapi_watchdog.h:45
SAPI_WATCHDOG_CHANNEL
@ SAPI_WATCHDOG_CHANNEL
Definition
sapi_watchdog.h:44
SAPI_WATCHDOG_SYSTEM
@ SAPI_WATCHDOG_SYSTEM
Definition
sapi_watchdog.h:42
SAPI_WATCHDOG_TASK
@ SAPI_WATCHDOG_TASK
Definition
sapi_watchdog.h:43
SAPI_WATCHDOG_ACTION_LOG
@ SAPI_WATCHDOG_ACTION_LOG
Definition
sapi_watchdog.h:54
SAPI_WATCHDOG_ACTION_REBOOT
@ SAPI_WATCHDOG_ACTION_REBOOT
Definition
sapi_watchdog.h:56
SAPI_WATCHDOG_ACTION_SAFESTATE
@ SAPI_WATCHDOG_ACTION_SAFESTATE
Definition
sapi_watchdog.h:55
SAPI_WATCHDOG_ACTION_FAILOVER
@ SAPI_WATCHDOG_ACTION_FAILOVER
Definition
sapi_watchdog.h:57
SAPI_WATCHDOG_ACTION_CUSTOM
@ SAPI_WATCHDOG_ACTION_CUSTOM
Definition
sapi_watchdog.h:67
sapi_status.h
Common status/error codes returned by every Safe API Framework function. Shared across all OS Abstrac...
sapi_types.h
Common fixed-width types and the caller-owned-storage handle pattern used by every OAL service (see A...
sapi_watchdog_config_t
Watchdog configuration.
Definition
sapi_watchdog.h:75
sapi_watchdog_config_t::action
sapi_watchdog_action_t action
Definition
sapi_watchdog.h:79
sapi_watchdog_config_t::custom_action
void(*) custom_action(void *ctx)
Definition
sapi_watchdog.h:80
sapi_watchdog_config_t::timeout_ms
sapi_duration_ms_t timeout_ms
Definition
sapi_watchdog.h:78
sapi_watchdog_config_t::type
sapi_watchdog_type_t type
Definition
sapi_watchdog.h:76
sapi_watchdog_config_t::name
const char * name
Definition
sapi_watchdog.h:77
sapi_watchdog_config_t::context
void * context
Definition
sapi_watchdog.h:85
sapi_watchdog_s
Watchdog handle (opaque).
Definition
sapi_watchdog.c:49
sapi_watchdog_status_t
Watchdog health/status information.
Definition
sapi_watchdog.h:93
sapi_watchdog_status_t::kicks
uint32_t kicks
Definition
sapi_watchdog.h:95
sapi_watchdog_status_t::recoveries
uint32_t recoveries
Definition
sapi_watchdog.h:97
sapi_watchdog_status_t::active
uint8_t active
Definition
sapi_watchdog.h:94
sapi_watchdog_status_t::time_since_last_kick
sapi_duration_ms_t time_since_last_kick
Definition
sapi_watchdog.h:98
sapi_watchdog_status_t::time_until_fire
sapi_duration_ms_t time_until_fire
Definition
sapi_watchdog.h:99
sapi_watchdog_status_t::fires
uint32_t fires
Definition
sapi_watchdog.h:96
include
safeapi
redundancy
watchdog
sapi_watchdog.h
Generated by
1.18.0