|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Test-access surface for ra8_flash internal helpers (MC/DC). More...
Go to the source code of this file.
Data Structures | |
| struct | ra8_flash_runtime_t |
| File-scope runtime state shared across the ra8_flash TUs. More... | |
Enumerations | |
| enum | ra8_flash_const_t : uint32_t { k_ra8_flash_max_mrcfreq_mhz = 0x000000FAUL , k_ra8_flash_max_mrefreq_mhz = 0x0000007DUL , k_ra8_flash_busy_spin_limit = 0x00010000UL , k_ra8_flash_maci_spin_limit = 0x00100000UL , k_ra8_flash_pe_spin_limit = 0x00010000UL , k_ra8_flash_zeroize_spin = 0x00400000UL , k_ra8_flash_max_list_select = 0x0000000FUL } |
| Bounds on configuration values + spin limits (cross-TU). More... | |
| enum | ra8_flash_key_t : uint32_t { k_ra8_flash_freq_key_shift = 24U , k_ra8_flash_mrcfreq_key = 0x1EU , k_ra8_flash_mrefreq_key = 0xE1U } |
| KEY-byte shifts and codes that gate writes (cross-TU). More... | |
Functions | |
| void | priv_ra8_flash_internal_set_prefetch (bool enable) |
| Set MRCPFB.MPFBEN to enable/disable the prefetch buffer. | |
| void | priv_ra8_flash_internal_maci_cmd8 (uint8_t byte) |
| Send a single byte through the MACI command-issuing area. | |
| void | priv_ra8_flash_internal_maci_cmd16 (uint16_t half) |
| Send a halfword through the MACI command-issuing area. | |
| ra8_err_t | priv_ra8_flash_internal_wait_mrdy (uint32_t limit) |
| Spin until MSTATR.MRDY rises or limit elapses. | |
| bool | priv_ra8_flash_internal_window_allows (uintptr_t addr, uint32_t len) |
| Test whether [addr, addr+len) lies inside the soft window. | |
| bool | priv_ra8_flash_internal_window_allows_pure (uintptr_t addr, uint32_t len, uintptr_t win_low, uintptr_t win_high) |
Pure (state-free) reimplementation of internal_window_allows. | |
| ra8_err_t | priv_ra8_flash_internal_wait_buffer_ready_call (uint32_t limit) |
Direct-call test access to internal_wait_buffer_ready. | |
| ra8_err_t | priv_ra8_flash_internal_wait_commit_done_call (uint32_t limit) |
Direct-call test access to internal_wait_commit_done. | |
Variables | |
| ra8_flash_runtime_t | g_flash_rt |
| Single shared ra8_flash runtime-state instance. | |
| const char * | g_flash_tag |
| Shared log tag string for the ra8_flash module. | |
Test-access surface for ra8_flash internal helpers (MC/DC).
Not part of the public API. Tests under tests/ MAY include this header to drive compound boolean decisions that sit in TU-private helpers behind the public ra8_flash facade. See CLAUDE.md "Test access to internal symbols (MC/DC scope)".
Definition in file ra8_flash_internal.h.
| enum ra8_flash_const_t : uint32_t |
Bounds on configuration values + spin limits (cross-TU).
HUM Ch 59.5.2 p 3551 limits MRCMHZ to 0x0FA (250 MHz). HUM Ch 59.5.3 p 3552 limits MREMHZ to 0x07D (125 MHz). The MACI commands take tens of microseconds to milliseconds; the spin limit below is generous enough for the worst-case configuration-set (~9 ms) at the slowest clock. Shared by the lifecycle, configuration, and IRQ TUs.
Definition at line 103 of file ra8_flash_internal.h.
| enum ra8_flash_key_t : uint32_t |
KEY-byte shifts and codes that gate writes (cross-TU).
MRCFREQ requires KEY=0x1E in [31:24] (HUM Ch 59.5.2 p 3551 Note 1). MREFREQ requires KEY=0xE1 in [31:24] (HUM Ch 59.5.3 p 3552 Note 1). Shared by the lifecycle and configuration TUs.
| Enumerator | |
|---|---|
| k_ra8_flash_freq_key_shift | KEY[7:0] @ [31:24] in MRCFREQ/MREFREQ. |
| k_ra8_flash_mrcfreq_key | RA8 flash mrcfreq key. |
| k_ra8_flash_mrefreq_key | RA8 flash mrefreq key. |
Definition at line 124 of file ra8_flash_internal.h.
| void priv_ra8_flash_internal_maci_cmd16 | ( | uint16_t | half | ) |
Send a halfword through the MACI command-issuing area.
Promoted from TU-private static linkage so the configuration TU can emit MACI command halfwords. Defined in ra8_flash.c.
| [in] | half | 16-bit data. |
half forms one command word.| [in] | half | 16-bit data. |
See the matching header declaration for the full contract; this site adds no behaviour beyond what the public API documents.
Definition at line 369 of file ra8_flash.c.
References ra8_mram_cmd16().
Referenced by ra8_flash_config_set_write().
| void priv_ra8_flash_internal_maci_cmd8 | ( | uint8_t | byte | ) |
Send a single byte through the MACI command-issuing area.
Promoted from TU-private static linkage so the configuration TU can emit MACI command bytes. Defined in ra8_flash.c.
| [in] | byte | Command byte. |
byte forms one command byte.| [in] | byte | Command byte. |
See the matching header declaration for the full contract; this site adds no behaviour beyond what the public API documents.
Definition at line 341 of file ra8_flash.c.
References ra8_mram_cmd8().
Referenced by internal_arc_cmd(), ra8_flash_config_set_write(), ra8_flash_force_stop(), and ra8_flash_reset().
| void priv_ra8_flash_internal_set_prefetch | ( | bool | enable | ) |
Set MRCPFB.MPFBEN to enable/disable the prefetch buffer.
Promoted from TU-private static linkage so the configuration TU (ra8_flash_config.c) can drive prefetch around the clock-frequency-update sequence. Defined in ra8_flash.c.
| [in] | enable | true => prefetch on. |
enable; g_flash_rt.prefetch_on updated. | [in] | enable | true => prefetch on. |
See the matching header declaration for the full contract; this site adds no behaviour beyond what the public API documents.
Definition at line 296 of file ra8_flash.c.
References g_flash_rt, k_ra8_mram_off_mrcpfb, and ra8_mram_reg8().
Referenced by internal_flash_program_window(), ra8_flash_deinit(), ra8_flash_enter_pe_mode(), ra8_flash_exit_pe_mode(), ra8_flash_init(), ra8_flash_set_rww_disable(), and ra8_flash_update_clock_freq().
| ra8_err_t priv_ra8_flash_internal_wait_buffer_ready_call | ( | uint32_t | limit | ) |
Direct-call test access to internal_wait_buffer_ready.
Promoted from TU-private static linkage so tests can drive the line-150 (s & PRGBSYC == 0) && (s & ABUFFULL == 0) AND-decision under -fcoverage-mcdc on the production source. Tests poke the fake-backed MRCPS register to present each pair of bit values across calls.
| [in] | limit | Maximum spin iterations. |
k_ra8_ok if both bits cleared within limit iterations, else k_ra8_err_hw_timeout. | k_ra8_ok | Both bits observed clear within limit. |
| k_ra8_err_hw_timeout | Limit exhausted without both bits clear. |
Direct-call test access to internal_wait_buffer_ready.
Forwards the call so tests under tests/ can drive the line-150 AND-decision directly on the production source. Production code keeps using the static helper.
| [in] | limit | Maximum spin iterations. |
| k_ra8_ok | Both bits cleared within limit iterations. |
| k_ra8_err_hw_timeout | Limit exhausted without success. |
limit > 0. Definition at line 124 of file ra8_flash.c.
References internal_wait_buffer_ready().
| ra8_err_t priv_ra8_flash_internal_wait_commit_done_call | ( | uint32_t | limit | ) |
Direct-call test access to internal_wait_commit_done.
Promoted from TU-private static linkage so tests can drive the line-181 (s & ABUFEMP) != 0 && (s & PRGBSYC) == 0 AND-decision under -fcoverage-mcdc on the production source. Tests poke the fake-backed MRCPS register to present each pair of bit values across calls.
| [in] | limit | Maximum spin iterations. |
k_ra8_ok if commit observed within limit iterations, else k_ra8_err_hw_timeout. | k_ra8_ok | Commit observed within limit iterations. |
| k_ra8_err_hw_timeout | Limit exhausted without commit observed. |
Direct-call test access to internal_wait_commit_done.
Forwards the call so tests under tests/ can drive the line-181 AND-decision directly on the production source. Production code keeps using the static helper.
| [in] | limit | Maximum spin iterations. |
| k_ra8_ok | Commit observed within limit iterations. |
| k_ra8_err_hw_timeout | Limit exhausted without success. |
limit > 0. Definition at line 179 of file ra8_flash.c.
References internal_wait_commit_done().
| ra8_err_t priv_ra8_flash_internal_wait_mrdy | ( | uint32_t | limit | ) |
Spin until MSTATR.MRDY rises or limit elapses.
Promoted from TU-private static linkage so the configuration TU can wait for MACI completion. Defined in ra8_flash.c.
| [in] | limit | Maximum spin iterations. |
| k_ra8_ok | MRDY observed high within limit. |
| k_ra8_err_hw_timeout | Limit exhausted without MRDY. |
limit > 0. | [in] | limit | Maximum spin iterations. |
See the matching header declaration for the full contract; this site adds no behaviour beyond what the public API documents.
| k_ra8_ok | Success path. |
| k_ra8_err_invalid_arg | Caller violated a precondition. |
Definition at line 203 of file ra8_flash.c.
References k_ra8_err_hw_timeout, k_ra8_mram_off_mstatr, k_ra8_mstatr_mask_mrdy, k_ra8_ok, and ra8_mram_reg32().
Referenced by internal_arc_cmd(), ra8_flash_config_set_write(), ra8_flash_force_stop(), and ra8_flash_reset().
| bool priv_ra8_flash_internal_window_allows | ( | uintptr_t | addr, |
| uint32_t | len ) |
Test whether [addr, addr+len) lies inside the soft window.
Promoted from TU-private static linkage so the FSP-parity / IRQ TU (ra8_flash_irq.c) can run the same range-validation check used by the direct-programming path. Reads g_flash_rt and forwards to priv_ra8_flash_internal_window_allows_pure. Defined in ra8_flash.c.
| [in] | addr | Start address of the candidate operation. |
| [in] | len | Length in bytes. |
| true | Region permitted (or no window installed). |
| false | Region overlaps outside the installed window. |
Test whether [addr, addr+len) lies inside the soft window.
The soft window mirrors the FSP accessWindowSet surface but is stored in driver state rather than in the silicon (RA8D2 has no FAWMON / FAWMR; HUM Ch 59 substitutes block-protect bits). A window with win_low == win_high == 0 is treated as disabled (allow all). Forwards to priv_ra8_flash_internal_window_allows_pure.
| [in] | addr | Start address of the candidate operation. |
| [in] | len | Length in bytes (must be > 0 if the caller is writing). |
| true | Region permitted (or no window installed). |
| false | Region overlaps outside the installed window. |
addr / len and module state.Definition at line 588 of file ra8_flash.c.
References g_flash_rt, and priv_ra8_flash_internal_window_allows_pure().
Referenced by internal_validate_range(), and internal_validate_write_block().
| bool priv_ra8_flash_internal_window_allows_pure | ( | uintptr_t | addr, |
| uint32_t | len, | ||
| uintptr_t | win_low, | ||
| uintptr_t | win_high ) |
Pure (state-free) reimplementation of internal_window_allows.
Returns true iff addr / len falls within the inclusive lower bound win_low and exclusive upper bound win_high. The "no window installed" sentinel is (win_low == 0 && win_high == 0).
Promoted as a pure helper so tests can drive the line-722 win_low == 0 && win_high == 0 AND-decision under -fcoverage-mcdc on the production source. The state-reading wrapper internal_window_allows simply forwards to this function.
| [in] | addr | Start address of the candidate region. |
| [in] | len | Length in bytes of the candidate region. |
| [in] | win_low | Inclusive lower bound of the allow window. |
| [in] | win_high | Exclusive upper bound of the allow window. |
| true | Region is permitted (or no window installed). |
| false | Region overlaps outside the installed window. |
Pure (state-free) reimplementation of internal_window_allows.
Promoted as a pure helper so the win_low == 0U && win_high == 0U AND-decision can be driven directly by host MC/DC tests with synthetic inputs rather than mutating module state. The state-reading wrapper priv_ra8_flash_internal_window_allows simply forwards.
| [in] | addr | Start address of the candidate region. |
| [in] | len | Length in bytes of the candidate region. |
| [in] | win_low | Inclusive lower bound of the allow window. |
| [in] | win_high | Exclusive upper bound of the allow window. |
| true | Region permitted (or no window installed). |
| false | Region overlaps outside the installed window. |
Definition at line 544 of file ra8_flash.c.
Referenced by priv_ra8_flash_internal_window_allows().
|
extern |
Single shared ra8_flash runtime-state instance.
Cleared at init. Used by the IRQ dispatcher to find the registered callback and to detect callers that try to use APIs before init. This is the sole definition of the cross-TU state declared in ra8_flash_internal.h; the configuration and IRQ TUs reference it via the extern there.
Defined exactly once in ra8_flash.c; the configuration and IRQ TUs reference this extern. Module-unique name keeps the symbol link-unique within libra_hal.
Definition at line 67 of file ra8_flash.c.
Referenced by internal_deliver(), priv_ra8_flash_internal_set_prefetch(), priv_ra8_flash_internal_window_allows(), ra8_flash_arc_increment(), ra8_flash_arc_read(), ra8_flash_callback_set(), ra8_flash_deinit(), ra8_flash_erase(), ra8_flash_exit_pe_mode(), ra8_flash_init(), ra8_flash_reset(), ra8_flash_set_window(), ra8_flash_update_clock_freq(), ra8_flash_write(), and ra8_flash_zeroize_huk().
|
extern |
Shared log tag string for the ra8_flash module.
Defined once in ra8_flash.c. Referenced by every ra8_flash TU's logging / validation macros.
Definition at line 50 of file ra8_flash.c.
Referenced by ra8_flash_arc_increment(), ra8_flash_arc_read(), ra8_flash_blank_check(), ra8_flash_block_protect_set(), ra8_flash_config_set_write(), ra8_flash_erase(), ra8_flash_extra_mram_write(), ra8_flash_get_ecc_error_addr(), ra8_flash_get_extended_status(), ra8_flash_get_program_error_addr(), ra8_flash_get_startup_area(), ra8_flash_get_status(), ra8_flash_get_update_status(), ra8_flash_init(), ra8_flash_reset(), ra8_flash_status(), ra8_flash_write(), ra8_flash_write_block(), and ra8_flash_zeroize_huk().