42#ifdef RA8_EREADER_NS_XIP
46extern uint32_t g_ra8_ls_ns_data_load_start;
47extern uint32_t g_ra8_ls_ns_data_start;
48extern uint32_t g_ra8_ls_ns_data_end;
52typedef enum : uintptr_t {
61typedef enum : uint32_t {
81typedef enum : uint32_t {
94typedef enum : uint32_t {
107typedef enum : uint32_t {
123typedef enum : uint32_t {
138typedef enum : uint32_t {
242 __asm__
volatile(
"wfi");
300 (void)
ra8_nsc_log_emit(
"SYS",
"System thread started (storage + supervisor)");
372 (void)first_unused_memory;
385 (
CHAR*)(uintptr_t)
"UI Thread",
399 (
CHAR*)(uintptr_t)
"System Thread",
433#ifdef RA8_EREADER_NS_XIP
437 const uintptr_t data_src = (uintptr_t)&g_ra8_ls_ns_data_load_start;
438 const uintptr_t data_dst = (uintptr_t)&g_ra8_ls_ns_data_start;
439 const uintptr_t data_end = (uintptr_t)&g_ra8_ls_ns_data_end;
440 for (uintptr_t off = 0U; (data_dst + off) < data_end; off +=
sizeof(uint32_t)) {
441 *(
volatile uint32_t*)(data_dst + off) = *(
const volatile uint32_t*)(data_src + off);
448 for (uintptr_t addr = bss_start; addr < bss_end; addr +=
sizeof(uint32_t)) {
449 *(
volatile uint32_t*)addr = 0U;
494 __asm__
volatile(
"wfi");
static uint8_t s_sys_wdt_handle
Supervisor check-in handle for the system thread.
@ k_ns_ui_heartbeat_frames
UI heartbeat every ~60 frames (~1 s).
@ k_ns_sys_heartbeat_iters
System heartbeat every ~10 loops (~1 s).
ns_thread_sleep_t
Per-thread loop sleep period, in ThreadX ticks.
@ k_ns_sys_poll_ticks
System loop sleep (~100 ms cadence).
@ k_ns_ui_frame_ticks
UI loop sleep (~16 ms, ~60 FPS).
static uint8_t s_ui_wdt_handle
Supervisor check-in handle for the UI thread.
void PendSV_Handler(void)
Perform the ThreadX Non-Secure context switch requested by PendSV.
static uint8_t s_sys_thread_stack[k_ns_sys_thread_stack_size]
ns_wdt_prio_t
ThreadX priority for the watchdog supervisor thread.
@ k_ns_wdt_sup_priority
Supervisor thread priority.
static void internal_nmi_halt(void)
Default Non-Secure fault/NMI handler: park the CPU in a wfi halt.
static TX_THREAD s_sys_thread
void _tx_timer_interrupt(void)
Advance the ThreadX kernel timer by one hardware tick.
static void internal_panic_halt(void)
Park the CPU in an idle loop if a fatal startup error occurs.
static void internal_wdt_setup(void)
Arm the watchdog and start the ThreadX check-in supervisor.
@ k_ns_sys_thread_stack_size
Stack size for System thread.
volatile uint32_t g_ns_sys_ticks
HIL liveness probe: system-thread iteration count.
static void internal_sys_thread_entry(ULONG thread_input)
System supervisor and storage background thread.
static void internal_systick_handler(void)
SysTick exception handler for the Non-Secure ThreadX OS.
void ns_reset_handler(void)
Non-Secure Reset handler: entered via Secure-to-NS transition.
ns_wdt_param_t
Watchdog-supervisor sizing and timing parameters.
@ k_ns_wdt_ui_deadline_ms
UI worker check-in deadline (ms).
@ k_ns_wdt_refresh_ms
Supervisor refresh / poll cadence (ms).
@ k_ns_wdt_sys_deadline_ms
System worker check-in deadline (ms).
@ k_ns_wdt_sup_stack_size
Supervisor thread stack size (bytes).
ns_thread_prio_t
ThreadX priority + preemption threshold for each Non-Secure thread.
@ k_ns_ui_priority
UI thread priority + preemption threshold.
@ k_ns_sys_priority
System thread priority + preemption threshold.
volatile uint32_t g_ns_ui_frames
HIL liveness probe: UI-thread iteration count.
void tx_application_define(void *first_unused_memory)
Setup ThreadX threads and resources.
static void internal_ui_thread_entry(ULONG thread_input)
UI thread entry: runs the e-reader UI frame loop.
const uint32_t g_ra8_ns_vector_table[8]
NS-world ARMv8-M vector table.
uint32_t g_ra8_ls_ns_stack_top
uint32_t g_ra8_ls_ns_bss_start
NS world reset handler – entry point of the BLXNS branch.
void ns_reset_handler(void)
uint32_t g_ra8_ls_ns_bss_end
ns_scb_addr_t
NS-state VTOR (0xE000ED08 is the current-domain alias in NS).
@ k_ns_scb_vtor_addr
Ns scb vtor address.
void(* ns_exc_handler_t)(void)
Function-pointer type for entries in the NS vector table.
uint32_t g_ra8_ls_ns_run_start
Linker symbol: NS vector table base.
ns_log_cadence_t
Heartbeat-log cadence per thread (iterations between log lines).
static TX_THREAD s_ui_thread
ns_thread_stack_t
Stack sizes for Non-Secure ThreadX threads.
@ k_ns_ui_thread_stack_size
Stack size for UI thread.
static uint8_t s_ui_thread_stack[k_ns_ui_thread_stack_size]
static uint8_t s_sup_stack[k_wdt_sup_demo_stack_bytes]
void PendSV_Handler(void)
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_ok
Success – operation completed with all postconditions satisfied.
Non-Secure Callable veneers – the only NS->S gateway.
ra8_err_t ra8_nsc_wdt_start(void)
NSC veneer: arm the Secure WDT with the e-reader configuration.
ra8_err_t ra8_nsc_log_emit(const char *tag, const char *message)
NSC veneer: emit a log line via the secure ITM channel.
void ra8_nsc_wdt_refresh(void)
NSC veneer: refresh the Secure WDT down-counter.
ra8_err_t ra8_nsc_periph_init(void)
NSC veneer: bring up the secure-side peripheral substrate.
volatile uint32_t g_ra8_threadx_systick_ready
0 until _tx_initialize_low_level has armed ThreadX's SysTick + timer state; 1 afterwards.
char CHAR
ThreadX-compatible CHAR (host stub).
unsigned long ULONG
ThreadX-compatible unsigned long (host stub).
ThreadX-aware watchdog supervisor (per-thread check-in registry).
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_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.
@ k_ra8_wdt_sup_handle_invalid
Invalid / unregistered handle.
ra8_err_t ra8_wdt_supervisor_set_refresh_hook(ra8_wdt_sup_refresh_fn_t refresh)
Override the WDT-refresh hook (test injection point).
ra8_err_t ra8_wdt_supervisor_start(void)
Spawn the supervisor thread.
Opaque thread stand-in for the host build.
One-shot supervisor configuration block.