ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_error_handler.c
Go to the documentation of this file.
1
24
25#include "ra8_error_handler.h"
26
27#include <stdint.h>
28
29#include "ra8_attributes.h"
30#include "ra8_log.h"
31
51RA8_INTERNAL static inline void internal_disable_irq(void)
52{
53#ifndef RA8_OFF_TARGET
54 __asm__ volatile("cpsid i" ::: "memory");
55#endif
56}
57
76RA8_INTERNAL static inline void internal_bkpt(void)
77{
78#ifndef RA8_OFF_TARGET
79 __asm__ volatile("bkpt #0");
80#endif
81}
82
83#ifndef RA8_OFF_TARGET
106RA8_INTERNAL static inline void internal_wfi(void)
107{
108 __asm__ volatile("wfi");
109}
110#endif
111
133[[gnu::weak]] void ra8_fatal_error(const char* tag, const char* message, uint32_t err)
134{
136
137 /* Best-effort log. If the log backend itself is broken we still
138 * halt -- logging must never prevent the halt. */
139 ra8_log_error(tag, message);
140 ra8_log_error_val(tag, "err=", err);
141
143
144#ifdef RA8_OFF_TARGET
145 /* On the host we cannot actually halt; abort makes the unit test
146 * runner fail loudly instead of spinning. */
147 __builtin_trap();
148#else
149 while (1) {
150 internal_wfi();
151 }
152#endif
153}
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
void ra8_fatal_error(const char *tag, const char *message, uint32_t err)
Fatal-error trap: log and halt the system.
static void internal_wfi(void)
Architectural __WFI wrapper used inside the halt loop.
static void internal_disable_irq(void)
Architectural __disable_irq: PRIMASK write.
static void internal_bkpt(void)
Architectural __BKPT(0) wrapper.
Centralised fatal-error sink.
Lightweight Logging Interface for ra8-firmware.
#define ra8_log_error_val(tag, message, value)
RA8 log error val.
Definition ra8_log.h:337
#define ra8_log_error(tag, message)
RA8 log error.
Definition ra8_log.h:335