33static const char*
s_tag =
"IPC";
87#if defined(RA8_OFF_TARGET) && defined(UNIT_TEST)
126#if defined(RA8_OFF_TARGET) && defined(UNIT_TEST)
168 if (max_spins == 0U) {
177 for (uint16_t i = 0U; i < max_spins; ++i) {
215 *out_locked = (prev != 0U);
234 if (nmi ==
nullptr) {
246 if (nmi ==
nullptr) {
259 if (nmi ==
nullptr) {
277 if (nmi ==
nullptr) {
362 const uint32_t head = *ring->
head;
363 const uint32_t tail = *ring->
tail;
364 if ((head - tail) >= ring->
capacity) {
371 *ring->
head = head + 1U;
388 const uint32_t head = *ring->
head;
389 const uint32_t tail = *ring->
tail;
395 *ring->
tail = tail + 1U;
403 *out_empty = (*ring->
head == *ring->
tail);
static const char * s_tag
Logging / check tag.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_ISR_SAFE
The function is callable from interrupt context.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_busy
Resource busy – blocking operation cannot proceed.
@ k_ra8_err_no_data
No application data available (e.g.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_err_hw_timeout
Hardware timed out waiting for a flag or handshake.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Bounded wait-flag primitives for RA8D2 HAL drivers.
Inter-Processor Communication (IPC) HAL driver – public API.
Inter-Processor Communication (IPC) register layout for the RA8D2.
static volatile r_ipc_nmi_regs_t * ra8_ipc_nmi(uint8_t unit)
Get a pointer to one IPC NMI unit register window.
@ k_ra8_ipc_nmi_mask_bit
Single-bit NMI request / status.
static volatile uint32_t * ra8_ipc_sem(uint8_t sem_id)
Get a pointer to one IPCSEM hardware semaphore register.
@ k_ra8_ipc_sem_count
IPCSEM0..IPCSEM15.
@ k_ra8_ipc_irq_event_count
8 IRQ event lines per channel.
@ k_ra8_ipc_nmi_unit_count
IPC0 + IPC1 NMI units.
@ k_ra8_ipc_channel_count
Total FIFO channels: 2 per unit x 2.
@ k_ra8_ipc_sem_mask_lock
LOCK bit (read-to-acquire).
ra8_err_t ra8_ipc_attach_nmi_handler(ra8_ipc_nmi_fn_t fn, void *ctx)
Attach a callback for inter-processor NMI dispatch.
ra8_err_t ra8_ipc_ring_consume(ra8_ipc_ring_t *ring, uint32_t *out_payload)
Pop one word from the shared-memory ring (consumer side).
static ra8_ipc_nmi_fn_t s_ipc_nmi_callback
ra8_err_t ra8_ipc_nmi_send(uint8_t unit)
Issue an inter-processor NMI to the peer core.
static uint32_t internal_ra8_ipc_sem_read_take(volatile uint32_t *sem)
Test-and-set on IPCSEMn – a 32-bit read takes the lock and returns the previous LOCK value.
ra8_err_t ra8_ipc_ring_init(ra8_ipc_ring_t *ring)
Initialise a producer/consumer ring backed by shared SRAM.
static volatile r_ipc_nmi_regs_t * internal_ra8_ipc_get_nmi(uint8_t unit)
Validate NMI unit id and return the NMI reg pointer.
ra8_err_t ra8_ipc_ring_is_empty(const ra8_ipc_ring_t *ring, bool *out_empty)
Predicate: ring empty?
void ra8_ipc_dispatch_nmi(uint8_t unit)
Drive the NMI dispatch path for one unit.
ra8_err_t ra8_ipc_nmi_clear(uint8_t unit)
Acknowledge an inter-processor NMI on the local core.
static void internal_ra8_ipc_sem_release_write(volatile uint32_t *sem)
Write the IPCSEMn write-1-to-clear release command.
ra8_err_t ra8_ipc_sem_try_take(uint8_t sem_id)
Test-and-set acquire on one IPC hardware semaphore.
ra8_err_t ra8_ipc_sem_take_timeout(uint8_t sem_id, uint16_t max_spins)
Bounded-spin take on one IPC hardware semaphore.
static void * s_ipc_nmi_context
ra8_err_t ra8_ipc_ring_is_full(const ra8_ipc_ring_t *ring, bool *out_full)
Predicate: ring full?
ra8_err_t ra8_ipc_sem_release(uint8_t sem_id)
Release one IPC hardware semaphore.
ra8_err_t ra8_ipc_nmi_get_status(uint8_t unit, bool *out_pending)
Read NMISTA.NMI for one IPC NMI unit.
ra8_err_t ra8_ipc_sem_is_locked(uint8_t sem_id, bool *out_locked)
Predicate: is the semaphore currently locked?
ra8_err_t ra8_ipc_ring_produce(ra8_ipc_ring_t *ring, uint32_t payload)
Push one word into the shared-memory ring (producer side).
static ra8_err_t internal_ra8_ipc_ring_validate(const ra8_ipc_ring_t *ring)
Validate the scalar fields of an ra8_ipc_ring_t descriptor.
static void ra8_ipc_barrier(void)
Cross-core data-memory barrier for IPC publish + lock ordering.
@ k_ra8_ipc_sem_take_max
Hard cap on semaphore-take spins.
void(* ra8_ipc_nmi_fn_t)(void *ctx, uint8_t unit)
NMI dispatch callback signature.
ra8_err_t ra8_ipc_send_event(uint8_t channel, ra8_ipc_irq_event_id_t event_id)
Generate a maskable IRQ event on the peer core.
Per-NMI-unit register window (3 x 32-bit at +0x10 stride).
volatile uint32_t NMICLR
+0x08 NMI clear (W).
volatile uint32_t NMISTA
+0x00 NMI status (R).
volatile uint32_t NMISET
+0x04 NMI set (W).
Shared-memory ring-buffer descriptor used by the producer / consumer protocol primitives.
uint8_t channel
IPC channel used for notification.
uint8_t sem_id
IPCSEM index used for exclusion.
volatile uint32_t * head
Producer write index (shared).
volatile uint32_t * tail
Consumer read index (shared).
volatile uint32_t * slots
Backing SRAM array (caller-owned).
uint32_t capacity
Number of 32-bit slots in slots.
ra8_ipc_irq_event_id_t notify_id
IRQ event line used for notify.