35typedef enum : uint32_t {
143 if (cfg ==
nullptr) {
146 if (cfg->
stack ==
nullptr) {
186 const uint32_t gap = now - last_checkin;
187 return gap > deadline;
215 bool refreshed =
false;
291 s_state.slots[idx].deadline_ms = deadline_ms;
296 for (
size_t k = 0U; k < cap; ++k) {
297 const char ch = name[k];
301 s_state.slots[idx].name[k] = ch;
308 if (out_handle ==
nullptr) {
313 if (name ==
nullptr) {
316 if (deadline_ms == 0U) {
376 (
CHAR*)(uintptr_t)
"ra8_wdt_sup",
396 if (out_did_refresh !=
nullptr) {
397 *out_did_refresh =
false;
405 if (out_did_refresh !=
nullptr) {
406 *out_did_refresh =
false;
412 bool all_alive =
true;
413 bool any_present =
false;
414 const uint32_t now_ms =
s_state.now();
421 s_state.slots[i].last_checkin_ms,
422 s_state.slots[i].deadline_ms)) {
433 const bool will_refresh = any_present && all_alive;
435 if (will_refresh && (
s_state.refresh !=
nullptr)) {
438 if (out_did_refresh !=
nullptr) {
439 *out_did_refresh = will_refresh;
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Error Code Definitions for ra8-firmware.
@ k_ra8_err_no_mem
Static buffer exhausted (no dynamic memory on this project).
@ k_ra8_err_busy
Resource busy – blocking operation cannot proceed.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_err_not_initialized
Module not initialized – _init() not yet called successfully.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_null_ptr
Pointer was NULL where a valid pointer was required.
@ k_ra8_err_rtos_error
Generic RTOS error (reserved for future use).
@ k_ra8_err_not_found
Requested item not found (lookup / search missed).
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
void * memset(void *dst, int value, size_t n)
Fill memory with a constant byte value.
Software Watchdog Timer (WDT) driver header.
void ra8_wdt_refresh_deferred(void)
Refresh the software WDT counter (WDT0).
ThreadX shim for ra8_wdt_supervisor (host unit-test build only).
unsigned int UINT
ThreadX-compatible unsigned int (host stub).
#define tx_thread_terminate
char CHAR
ThreadX-compatible CHAR (host stub).
unsigned long ULONG
ThreadX-compatible unsigned long (host stub).
static void internal_fill_slot(uint8_t idx, const char *name, uint32_t deadline_ms)
Initialise an unused slot with the caller's parameters.
ra8_err_t ra8_wdt_supervisor_deinit(void)
Reset the supervisor to its uninitialized state (test helper).
static void internal_default_refresh(void)
Default WDT-refresh hook.
ra8_err_t ra8_wdt_supervisor_tick(bool *out_did_refresh)
Run one supervisor tick synchronously (test / introspection hook).
static ra8_err_t internal_validate_cfg(const ra8_wdt_sup_cfg_t *cfg)
Validate the public configuration block.
ra8_err_t ra8_wdt_supervisor_set_now_hook(ra8_wdt_sup_now_fn_t now)
Override the monotonic-time hook (test injection point).
ra8_err_t ra8_wdt_supervisor_register_thread(const char *name, uint32_t deadline_ms, uint8_t *out_handle)
Register a worker thread with the supervisor.
ra8_wdt_sup_internal_t
Internal numeric constants used by the implementation.
@ k_ra8_wdt_sup_mutex_id
'WDSS' marker for the mutex.
@ k_ra8_wdt_sup_thread_id
'WDST' marker for the thread.
@ k_ra8_wdt_sup_max_priority
Highest legal ThreadX priority.
@ k_ra8_wdt_sup_slot_used
Slot tag: registered.
@ k_ra8_wdt_sup_min_stack
Minimum acceptable stack size.
@ k_ra8_wdt_sup_slot_free
Slot tag: empty.
@ k_ra8_wdt_sup_default_tick_ms
Default tick: 1 kHz kernel.
static bool internal_is_overdue(uint32_t now, uint32_t last_checkin, uint32_t deadline)
Compute whether now - last_checkin exceeds deadline.
ra8_err_t ra8_wdt_supervisor_checkin(uint8_t handle)
Record a thread check-in, resetting its deadline window.
ra8_err_t ra8_wdt_supervisor_init(const ra8_wdt_sup_cfg_t *cfg)
Initialise the supervisor registry and runtime hooks.
uint8_t ra8_wdt_supervisor_thread_count(void)
Read the number of currently-registered worker threads.
static uint32_t internal_default_now(void)
Default monotonic-time hook – scales tx_time_get to ms.
ra8_err_t ra8_wdt_supervisor_set_refresh_hook(ra8_wdt_sup_refresh_fn_t refresh)
Override the WDT-refresh hook (test injection point).
static void internal_thread_entry(ULONG arg)
The supervisor thread's entry point.
ra8_err_t ra8_wdt_supervisor_start(void)
Spawn the supervisor thread.
ThreadX-aware watchdog supervisor (per-thread check-in registry).
uint32_t(* ra8_wdt_sup_now_fn_t)(void)
Hook used by tests to inject monotonic-time readings.
@ k_ra8_wdt_sup_handle_invalid
Invalid / unregistered handle.
void(* ra8_wdt_sup_refresh_fn_t)(void)
Hook used to call into ra8_wdt_refresh_deferred.
@ k_ra8_wdt_sup_max_threads
Max simultaneously registered threads.
@ k_ra8_wdt_sup_name_max
Max bytes (incl.
Opaque mutex stand-in for the host build.
Opaque thread stand-in for the host build.
One-shot supervisor configuration block.
uint32_t stack_size_bytes
Size of stack in bytes (>= 512).
uint32_t refresh_period_ms
Tick period of the supervisor's loop.
uint32_t priority
ThreadX priority for the supervisor thread.
void * stack
Caller-owned byte region for the supervisor's stack.
One row of the supervisor registry.
char name[k_ra8_wdt_sup_name_max]
Diagnostic name (NUL-terminated).
uint32_t deadline_ms
Max gap between check-ins.
uint32_t last_checkin_ms
Monotonic time of last check-in.
uint8_t state
slot_free or slot_used.
Module state – entirely static.
TX_THREAD thread
Supervisor thread control block.
bool started
True once the thread is spawned.
ra8_wdt_sup_slot_t slots[k_ra8_wdt_sup_max_threads]
Registry.
ra8_wdt_sup_now_fn_t now
Monotonic-time hook.
ra8_wdt_sup_refresh_fn_t refresh
WDT-refresh hook.
TX_MUTEX mutex
Guards slots.
ra8_wdt_sup_cfg_t cfg
Cached configuration.
bool initialized
True after successful init.