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_watchdog.h
Go to the documentation of this file.
1
16
17
#ifndef RTE_WATCHDOG_H
18
#define RTE_WATCHDOG_H
19
20
#include "
rte/utils/status/rte_status.h
"
21
#include "
rte/utils/types/rte_types.h
"
22
23
#ifdef __cplusplus
24
extern
"C"
{
25
#endif
26
27
/* ============================================================================
28
* Types & Constants
29
* ========================================================================== */
30
34
typedef
struct
rte_watchdog_s
*rte_watchdog_t;
35
41
typedef
enum
{
42
RTE_WATCHDOG_SYSTEM
,
43
RTE_WATCHDOG_TASK
,
44
RTE_WATCHDOG_CHANNEL
,
45
RTE_WATCHDOG_CHECKPOINT
46
}
rte_watchdog_type_t
;
47
53
typedef
enum
{
54
RTE_WATCHDOG_ACTION_LOG
,
55
RTE_WATCHDOG_ACTION_SAFESTATE
,
56
RTE_WATCHDOG_ACTION_REBOOT
,
57
RTE_WATCHDOG_ACTION_FAILOVER
,
67
RTE_WATCHDOG_ACTION_CUSTOM
68
}
rte_watchdog_action_t
;
69
75
typedef
struct
{
76
rte_watchdog_type_t
type
;
77
const
char
*
name
;
78
rte_duration_ms_t
timeout_ms
;
79
rte_watchdog_action_t
action
;
80
void (*
custom_action
)(
void
*ctx);
85
void
*
context
;
86
}
rte_watchdog_config_t
;
87
93
typedef
struct
{
94
uint8_t
active
;
95
uint32_t
kicks
;
96
uint32_t
fires
;
97
uint32_t
recoveries
;
98
rte_duration_ms_t
time_since_last_kick
;
99
rte_duration_ms_t
time_until_fire
;
100
}
rte_watchdog_status_t
;
101
102
/* ============================================================================
103
* API: Core Watchdog Operations
104
* ========================================================================== */
105
134
rte_status_t
rte_watchdog_create
(rte_watchdog_t *handle_out,
135
const
rte_watchdog_config_t
*config);
136
161
rte_status_t
rte_watchdog_start
(rte_watchdog_t watchdog);
162
177
rte_status_t
rte_watchdog_stop
(rte_watchdog_t watchdog);
178
213
rte_status_t
rte_watchdog_kick
(rte_watchdog_t watchdog);
214
247
rte_status_t
rte_watchdog_get_status
(rte_watchdog_t watchdog,
248
rte_watchdog_status_t
*status_out);
249
263
rte_status_t
rte_watchdog_destroy
(rte_watchdog_t watchdog);
264
265
/* ============================================================================
266
* API: Watchdog Manager (Global)
267
* ========================================================================== */
268
281
rte_status_t
rte_watchdog_manager_initialize
(
void
);
282
295
rte_status_t
rte_watchdog_manager_shutdown
(
void
);
296
297
/* ============================================================================
298
* Watchdog Timeout Callback (Invoked by Framework)
299
* ========================================================================== */
300
316
void
rte_watchdog_timeout_handler
(uint32_t watchdog_id);
317
346
void
rte_watchdog_timer_tick
(
void
);
347
348
#ifdef __cplusplus
349
}
350
#endif
351
352
#endif
/* RTE_WATCHDOG_H */
353
/* WATCHDOG */
rte_status_t
rte_status_t
Common result/status codes.
Definition
rte_status.h:27
rte_duration_ms_t
uint32_t rte_duration_ms_t
Definition
rte_types.h:27
rte_watchdog_start
rte_status_t rte_watchdog_start(rte_watchdog_t watchdog)
Start watchdog timer.
Definition
rte_watchdog.c:240
rte_watchdog_manager_shutdown
rte_status_t rte_watchdog_manager_shutdown(void)
Shutdown watchdog manager (call once at shutdown).
Definition
rte_watchdog.c:174
rte_watchdog_timeout_handler
void rte_watchdog_timeout_handler(uint32_t watchdog_id)
Watchdog timeout handler (INTERNAL - called by framework).
Definition
rte_watchdog.c:363
rte_watchdog_type_t
rte_watchdog_type_t
Watchdog type.
Definition
rte_watchdog.h:41
rte_watchdog_kick
rte_status_t rte_watchdog_kick(rte_watchdog_t watchdog)
Kick (pet) watchdog - prove liveness.
Definition
rte_watchdog.c:280
rte_watchdog_destroy
rte_status_t rte_watchdog_destroy(rte_watchdog_t watchdog)
Destroy watchdog.
Definition
rte_watchdog.c:346
rte_watchdog_manager_initialize
rte_status_t rte_watchdog_manager_initialize(void)
Initialize watchdog manager (call once at startup).
Definition
rte_watchdog.c:163
rte_watchdog_action_t
rte_watchdog_action_t
Recovery action when watchdog fires.
Definition
rte_watchdog.h:53
rte_watchdog_get_status
rte_status_t rte_watchdog_get_status(rte_watchdog_t watchdog, rte_watchdog_status_t *status_out)
Get watchdog status.
Definition
rte_watchdog.c:315
rte_watchdog_stop
rte_status_t rte_watchdog_stop(rte_watchdog_t watchdog)
Stop watchdog timer.
Definition
rte_watchdog.c:268
rte_watchdog_timer_tick
void rte_watchdog_timer_tick(void)
Poll all active watchdogs for expiry (call periodically).
Definition
rte_watchdog.c:446
rte_watchdog_create
rte_status_t rte_watchdog_create(rte_watchdog_t *handle_out, const rte_watchdog_config_t *config)
Create a watchdog.
Definition
rte_watchdog.c:191
RTE_WATCHDOG_SYSTEM
@ RTE_WATCHDOG_SYSTEM
Definition
rte_watchdog.h:42
RTE_WATCHDOG_CHANNEL
@ RTE_WATCHDOG_CHANNEL
Definition
rte_watchdog.h:44
RTE_WATCHDOG_CHECKPOINT
@ RTE_WATCHDOG_CHECKPOINT
Definition
rte_watchdog.h:45
RTE_WATCHDOG_TASK
@ RTE_WATCHDOG_TASK
Definition
rte_watchdog.h:43
RTE_WATCHDOG_ACTION_REBOOT
@ RTE_WATCHDOG_ACTION_REBOOT
Definition
rte_watchdog.h:56
RTE_WATCHDOG_ACTION_SAFESTATE
@ RTE_WATCHDOG_ACTION_SAFESTATE
Definition
rte_watchdog.h:55
RTE_WATCHDOG_ACTION_LOG
@ RTE_WATCHDOG_ACTION_LOG
Definition
rte_watchdog.h:54
RTE_WATCHDOG_ACTION_FAILOVER
@ RTE_WATCHDOG_ACTION_FAILOVER
Definition
rte_watchdog.h:57
RTE_WATCHDOG_ACTION_CUSTOM
@ RTE_WATCHDOG_ACTION_CUSTOM
Definition
rte_watchdog.h:67
rte_status.h
Common status/error codes returned by every Safe API Framework function. Shared across all OS Abstrac...
rte_types.h
Common fixed-width types and the caller-owned-storage handle pattern used by every OAL service (see A...
rte_watchdog_config_t
Watchdog configuration.
Definition
rte_watchdog.h:75
rte_watchdog_config_t::context
void * context
Definition
rte_watchdog.h:85
rte_watchdog_config_t::timeout_ms
rte_duration_ms_t timeout_ms
Definition
rte_watchdog.h:78
rte_watchdog_config_t::type
rte_watchdog_type_t type
Definition
rte_watchdog.h:76
rte_watchdog_config_t::action
rte_watchdog_action_t action
Definition
rte_watchdog.h:79
rte_watchdog_config_t::custom_action
void(*) custom_action(void *ctx)
Definition
rte_watchdog.h:80
rte_watchdog_config_t::name
const char * name
Definition
rte_watchdog.h:77
rte_watchdog_s
Watchdog handle (opaque).
Definition
rte_watchdog.c:56
rte_watchdog_status_t
Watchdog health/status information.
Definition
rte_watchdog.h:93
rte_watchdog_status_t::fires
uint32_t fires
Definition
rte_watchdog.h:96
rte_watchdog_status_t::time_since_last_kick
rte_duration_ms_t time_since_last_kick
Definition
rte_watchdog.h:98
rte_watchdog_status_t::time_until_fire
rte_duration_ms_t time_until_fire
Definition
rte_watchdog.h:99
rte_watchdog_status_t::active
uint8_t active
Definition
rte_watchdog.h:94
rte_watchdog_status_t::recoveries
uint32_t recoveries
Definition
rte_watchdog.h:97
rte_watchdog_status_t::kicks
uint32_t kicks
Definition
rte_watchdog.h:95
include
rte
redundancy
watchdog
rte_watchdog.h
Generated by
1.18.0