69 v = (uint8_t)(v | bit);
71 v = (uint8_t)(v & (uint8_t)~bit);
214 .fault_addr = fault_addr,
215 .status_word = status_word,
250 uint16_t ted_addr_off,
251 uint16_t dec_addr_off,
255 uint32_t delivered = 0U;
275 uint32_t delivered = 0U;
345 if (low == 0U && high == 0U) {
387 const uint64_t end_excl = (uint64_t)address + total_len;
403 if (num_blocks == 0U) {
419 uintptr_t cur = address;
420 for (uint32_t i = 0U; i < num_blocks; ++i) {
446 for (uint32_t i = 0U; i < pages; ++i) {
448 const uintptr_t page_addr = address + offset;
461typedef enum : uint8_t {
475 const uint64_t end_excl = (uint64_t)address + (uint64_t)len;
479 const bool in_extra =
487 if (!in_code && !in_extra && !in_ofs) {
491 const volatile uint8_t* p = (
const volatile uint8_t*)address;
492 bool is_blank =
true;
494 for (uint32_t i = 0U; i < len; ++i) {
500 *out_blank = is_blank;
531 out->
sector_protected = ((mrcbprot0 & 0x0001U) == 0U) || ((mrcbprot1 & 0x0001U) == 0U);
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_RETURN_ON_ERROR(err, tag, message)
Early return on error, propagating the code upward.
#define RA8_VALIDATE_INIT(initialized, tag, message)
Precondition: module must be initialized.
#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_out_of_range
Sensor or peripheral output out of valid range.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ 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.
ra8_flash_runtime_t g_flash_rt
Single shared ra8_flash runtime-state instance.
bool priv_ra8_flash_internal_window_allows(uintptr_t addr, uint32_t len)
Test whether [addr, addr+len) lies inside the configured soft window.
const char * g_flash_tag
Shared log tag string for the ra8_flash module.
Code MRAM + Extra MRAM + Option-Setting driver – DANGEROUS, brick-capable.
ra8_err_t ra8_flash_init(const ra8_flash_cfg_t *cfg)
Initialise the MRAM controller for safe read access.
ra8_err_t ra8_flash_write_block(uint32_t mram_addr, const uint8_t *src, uint32_t len, ra8_flash_world_t world)
Program 1..32 contiguous bytes into one MRAM page.
ra8_err_t ra8_flash_erase_block(uint32_t mram_addr, ra8_flash_world_t world)
Erase (= program to all 0xFF) one 32-byte MRAM block.
ra8_err_t ra8_flash_deinit(void)
Deinitialise: lock all program gates and re-enable prefetch.
Test-access surface for ra8_flash internal helpers (MC/DC).
ra8_err_t ra8_flash_status(ra8_flash_status_t *out)
Decode the controller status into a flat ra8_flash_status_t.
static void internal_apply_ecc_irq(uint16_t off, bool is_ted, bool enable)
Apply enable/disable to an MRCRAEINT-style ECC IRQ.
ra8_err_t ra8_flash_set_window(uintptr_t low, uintptr_t high)
Configure the soft access window enforced by write/erase.
static void internal_apply_extra_err_irq(bool err_kind, bool enable)
Apply enable/disable to an MPAEINT bit.
ra8_err_t ra8_flash_set_irq_enable(ra8_flash_irq_src_t src, bool enable)
Enable or disable MRAM-controller IRQs by source.
ra8_err_t ra8_flash_open(const ra8_flash_cfg_t *cfg)
FSP-parity bring-up: equivalent to ra8_flash_init.
uint32_t ra8_flash_dispatch_isr(void)
Run the MRAM IRQ dispatcher (call from the BSP vector).
ra8_err_t ra8_flash_callback_set(ra8_flash_callback_t cb, void *user_ctx)
Register the unified IRQ callback.
ra8_flash_blank_const_t
Erase-pattern constants used by ra8_flash_blank_check.
@ k_ra8_flash_blank_byte
Erased state byte value (HUM Ch 59 p 3548).
ra8_err_t ra8_flash_write(uintptr_t address, const uint8_t *src, uint32_t len)
Program len bytes into code-MRAM starting at address.
static void internal_deliver(ra8_flash_irq_src_t src, uint32_t fault_addr, uint32_t status_word)
Deliver one IRQ event to the registered callback.
static uint32_t internal_dispatch_ecc(uint16_t status_off, uint16_t ted_addr_off, uint16_t dec_addr_off, ra8_flash_irq_src_t ted_src, ra8_flash_irq_src_t dec_src)
Dispatch ECC TED/DEC events for one of the two MRAM regions.
ra8_err_t ra8_flash_erase(uintptr_t address, uint32_t num_blocks)
Erase num_blocks consecutive 32-byte MRAM blocks.
static ra8_err_t internal_validate_range(uintptr_t address, uint64_t total_len)
Validate a multi-block erase / multi-page write range.
ra8_err_t ra8_flash_blank_check(uintptr_t address, uint32_t len, bool *out_blank)
Check whether a region holds the erase pattern (all 0xFF).
static void internal_irq_rmw8(uint16_t off, uint8_t bit, bool enable)
Read-modify-write a single bit in an 8-bit register.
ra8_err_t ra8_flash_close(void)
FSP-parity tear-down: equivalent to ra8_flash_deinit.
Flash / MRAM controller register layout for the Renesas RA8D2.
static volatile uint8_t * ra8_mram_reg8(uint16_t off)
Pointer to a byte-wide MRMS register at offset off.
@ k_ra8_mrcraes_mask_decerrc
2-bit DEC error.
@ k_ra8_mrcraes_mask_tederrc
1-bit TED error.
@ k_ra8_mrcpaeint_mask_mrcaeie
Code program-error IRQ enable.
@ k_ra8_mastat_mask_cmdlk
Command lock latched.
@ k_ra8_mastat_mask_mreae
Extra MRAM access error.
@ k_ra8_flash_code_size
1 MiB of code MRAM.
@ k_ra8_flash_extra_start
First legal Program target (FSBL setting).
@ k_ra8_flash_extra_size
Covers through 0x02E179F0 (last, reserved).
@ k_ra8_flash_code_start
Start of code MRAM region.
@ k_ra8_flash_ofs_start
Start of OFS config_set window.
@ k_ra8_flash_ofs_size
4 KiB OFS block.
static volatile uint16_t * ra8_mram_reg16(uint16_t off)
Pointer to a halfword-wide MRMS register at offset off.
@ k_ra8_mstatr_mask_mrdy
MRE ready.
@ k_ra8_mstatr_mask_oterr
Other error.
@ k_ra8_mstatr_mask_ilgcomerr
Illegal command error.
@ k_ra8_mpaeint_mask_cmdlkie
Command-lock IRQ enable.
@ k_ra8_mpaeint_mask_mreaeie
Access-error IRQ enable.
@ k_ra8_mrdyie_mask_mrdyie
MRDY IRQ enable.
@ k_ra8_mentryr_mask_pe_mode
MENTRY status bit.
static volatile uint32_t * ra8_mram_reg32(uint16_t off)
Pointer to a word-wide MRMS register at offset off.
@ k_ra8_mram_block_size_bytes
One programmable block.
@ k_ra8_mram_write_size_bytes
Minimum programmable unit.
@ k_ra8_mram_off_mentryr
RA8 MRAM off mentryr.
@ k_ra8_mram_off_mrcrtea
RA8 MRAM off mrcrtea.
@ k_ra8_mram_off_mrcps
RA8 MRAM off mrcps.
@ k_ra8_mram_off_mrertea
RA8 MRAM off mrertea.
@ k_ra8_mram_off_mrdyie
RA8 MRAM off mrdyie.
@ k_ra8_mram_off_mrcbprot1
RA8 MRAM off mrcbprot1.
@ k_ra8_mram_off_mpaeint
RA8 MRAM off mpaeint.
@ k_ra8_mram_off_mrcpea
RA8 MRAM off mrcpea.
@ k_ra8_mram_off_mrcraes
RA8 MRAM off mrcraes.
@ k_ra8_mram_off_mrcraeint
RA8 MRAM off mrcraeint.
@ k_ra8_mram_off_mrerdea
RA8 MRAM off mrerdea.
@ k_ra8_mram_off_mreraint
RA8 MRAM off mreraint.
@ k_ra8_mram_off_mrcpaeint
RA8 MRAM off mrcpaeint.
@ k_ra8_mram_off_mrcbprot0
RA8 MRAM off mrcbprot0.
@ k_ra8_mram_off_mastat
RA8 MRAM off mastat.
@ k_ra8_mram_off_mstatr
RA8 MRAM off mstatr.
@ k_ra8_mram_off_mreraes
RA8 MRAM off mreraes.
@ k_ra8_mram_off_mrcrdea
RA8 MRAM off mrcrdea.
@ k_ra8_mrcps_mask_errors
W1C: PRGERRC + ECCERRC.
@ k_ra8_mrcps_mask_prgbsyc
Code MRAM program busy.
@ k_ra8_mrcps_mask_prgerrc
Programming error.
@ k_ra8_mrcps_mask_eccerrc
ECC error.
@ k_ra8_mrcraeint_mask_intenbtc
TED error IRQ enable.
@ k_ra8_mrcraeint_mask_intenbdc
DEC error IRQ enable.
ra8_flash_irq_src_t
Source identifier for unified flash IRQ dispatcher.
@ k_ra8_flash_irq_extra_ready
Extra MRAM ready.
@ k_ra8_flash_irq_code_ecc_ted
Code MRAM 1-bit ECC TED.
@ k_ra8_flash_irq_extra_cmdlk
Extra MRAM command-lock.
@ k_ra8_flash_irq_extra_ecc_dec
Extra MRAM 2-bit ECC DEC.
@ k_ra8_flash_irq_extra_err
Extra MRAM access error.
@ k_ra8_flash_irq_program_err
Code MRAM program/erase error.
@ k_ra8_flash_irq_extra_ecc_ted
Extra MRAM 1-bit ECC TED.
@ k_ra8_flash_irq_count
Sentinel: number of sources.
@ k_ra8_flash_irq_code_ecc_dec
Code MRAM 2-bit ECC DEC.
ra8_flash_world_t
Which secure-attribution gate to open for a write.
@ k_ra8_flash_world_ns
Open MRCPC0 (non-secure half).
void(* ra8_flash_callback_t)(const ra8_flash_isr_event_t *ev)
Callback signature for the unified flash IRQ dispatcher.
Lightweight Logging Interface for ra8-firmware.
Initialisation descriptor for ra8_flash_init.
One IRQ event delivered to ra8_flash_callback_t.
Decoded status snapshot, FSP-parity surface.
bool program_error
MRCPS.PRGERRC.
bool sector_protected
MRCBPROT0/1 lock observed.
bool ecc_error
MRCPS.ECCERRC.
bool illegal_command
MASTAT.CMDLK or MSTATR.ILGCOMERR.
bool programming_busy
MRCPS.PRGBSYC or MENTRYR.MENTRY set.
bool erase_busy
Same as programming_busy on MRAM.
bool voltage_error
MSTATR.OTERR (other / supply error).