ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
board_periph_mstp.c
Go to the documentation of this file.
1
28
29#include <stdint.h>
30#include <stdio.h>
31
32#include "board_periph_block.h"
35#include "ra8_attributes.h"
36
38typedef enum : uint32_t {
41
55RA8_INTERNAL static uint64_t internal_mstp_read(uc_engine* uc, uint64_t addr, unsigned size)
56{
57 (void)uc;
58 return (uint64_t)priv_board_mstp_read_reg(addr - (uint64_t)k_board_mstp_win_base, size);
59}
60
73RA8_INTERNAL static void
74internal_mstp_write(uc_engine* uc, uint64_t addr, unsigned size, uint64_t value)
75{
76 (void)uc;
77 priv_board_mstp_apply_write(addr - (uint64_t)k_board_mstp_win_base, size, (uint32_t)value);
78}
79
89{
90 const uint32_t r = priv_board_mstp_gated_read_count();
91 const uint32_t w = priv_board_mstp_gated_write_count();
92 if ((r == 0U) && (w == 0U)) {
93 return; /* Clean: every peripheral the firmware touched was clocked. */
94 }
95 /* Loud: firmware read/wrote a module-stopped peripheral. On silicon those
96 * reads return 0 and writes vanish -- the exact masked-pass this block ends. */
97 (void)priv_emu_io_errf(" MSTP-GATING : DROPPED %u read(s)+%u write(s) to module-stopped "
98 "peripheral(s) (last: %s) -- firmware forgot to cancel module-stop\n",
99 r,
100 w,
102}
103
106 .base = (uint64_t)k_board_mstp_win_base,
107 .span = (uint64_t)k_board_mstp_win_span,
108 .order = (uint32_t)k_mstp_block_order,
109 .read = internal_mstp_read,
111 .tick = nullptr,
112 .reset = priv_board_mstp_reset,
113 .report = internal_mstp_report,
114 .name = "MSTP",
115};
116
Decentralized peripheral-block registry for the board emulator core.
void board_periph_register_block(const board_periph_block_t *block)
Register a peripheral block's descriptor with the core registry.
static uint64_t internal_mstp_read(uc_engine *uc, uint64_t addr, unsigned size)
MMIO read of MSTPCRA..E: answer from the tracked shadow.
mstp_order_t
Per-tick order slot for the MSTP block (just before SYSC-PRCR).
@ k_mstp_block_order
Groups with the PRCR / power-domain blocks.
static void internal_mstp_block_register(void)
Register the MSTP block before main (host constructor).
static const board_periph_block_t s_k_mstp_block
MSTP block descriptor (owns MSTPCRA..E; self-registered).
static void internal_mstp_write(uc_engine *uc, uint64_t addr, unsigned size, uint64_t value)
MMIO write of MSTPCRA..E: fold into the shadow (ungate/re-gate).
static void internal_mstp_report(void)
End-of-run section: make any access to an unclocked block LOUD.
Module-private module-stop (MSTP) gate state shared with the core.
@ k_board_mstp_win_span
MSTPCRA..E = 5 x uint32 = 20 B.
@ k_board_mstp_win_base
R_MSTP base (Secure alias).
uint32_t priv_board_mstp_read_reg(uint64_t off, unsigned size)
Read the tracked MSTPCRA..MSTPCRE shadow (the read-back path).
uint32_t priv_board_mstp_gated_write_count(void)
Number of writes dropped because their peripheral was module-stopped.
uint32_t priv_board_mstp_gated_read_count(void)
Number of reads zeroed because their peripheral was module-stopped.
const char * priv_board_mstp_last_gated_name(void)
Label of the peripheral whose access was most recently gated off.
void priv_board_mstp_reset(void)
Restore MSTPCRA..MSTPCRE to their all-stopped reset values.
void priv_board_mstp_apply_write(uint64_t off, unsigned size, uint32_t value)
Apply a firmware write to the MSTPCRA..MSTPCRE shadow.
Bounded raw-descriptor I/O seam for the RA8 emulator.
emu_io_result_t priv_emu_io_errf(const char *format,...)
Format bounded text and write it to the injected error descriptor.
-proof
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
A modelled peripheral block's self-description for the core registry.