|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
ra8_io block-device backend over the on-chip extra/data MRAM region. More...
Go to the source code of this file.
Data Structures | |
| struct | ra8_io_blockdev_mram_state_t |
| Caller-owned private state for an MRAM block device. More... | |
Functions | |
| ra8_err_t | ra8_io_blockdev_mram_init (ra8_io_blockdev_t *bd, ra8_io_blockdev_mram_state_t *state, uintptr_t base_addr, uint32_t block_count, bool read_only) |
| Bind a hard-fenced MRAM block-device backend into a caller handle. | |
ra8_io block-device backend over the on-chip extra/data MRAM region.
The MRAM backend exposes a hard-fenced window of the on-chip MRAM data region as an array of 512-byte logical blocks on top of the ra8_io_blockdev_iface fabric. It wraps the ra8_flash HAL driver: reads memcpy directly from the memory-mapped MRAM array, writes route through ra8_flash_write (chunked into the 32-byte MRAM program unit), and erases route through ra8_flash_erase (mapping each 512-byte logical block onto sixteen 32-byte MRAM erase blocks).
MRAM also holds the running firmware's .text, so this backend is dangerous: ra8_io_blockdev_mram_init refuses any window that is not wholly contained in the extra/data MRAM region ([k_ra8_flash_extra_start, k_ra8_flash_extra_start + k_ra8_flash_extra_size)) or that overlaps the code-MRAM region ([k_ra8_flash_code_start, k_ra8_flash_code_start + k_ra8_flash_code_size)). The fence is enforced at bind time and the per-call bounds check keeps every access inside the bound window, so no operation can ever reach code MRAM.
MRAM erases to all-ones (0xFF) and requires an erase before a program can change a bit from 0 to 1, so the reported capabilities advertise must_erase_before_write = true and erase_value = 0xFF.
Definition in file ra8_io_blockdev_mram.h.
|
nodiscard |
Bind a hard-fenced MRAM block-device backend into a caller handle.
Validates the requested window aggressively, records it in state, marks it read-only per read_only, and points bd at the MRAM vtable with state as its context. No allocation occurs; the caller owns both bd and state.
The window [base_addr, base_addr + block_count * 512) must be erase-block aligned, an integral number of erase blocks, wholly inside the extra/data MRAM region, and must not overlap the code-MRAM .text region. Any violation leaves bd and state untouched and returns k_ra8_err_invalid_arg.
| [out] | bd | Handle to bind (zero-initialised by the caller). |
| [out] | state | Caller-owned backend state to populate. |
| [in] | base_addr | First MRAM byte address of the window (erase aligned). |
| [in] | block_count | Number of 512-byte logical blocks (>= 1). |
| [in] | read_only | true to reject writes and erases on this device. |
| k_ra8_ok | Backend bound; bd is usable. |
| k_ra8_err_null_ptr | bd or state was NULL. |
| k_ra8_err_invalid_arg | block_count was zero, the window was misaligned, not a whole number of erase blocks, outside the extra/data MRAM region, or overlapped code MRAM. |
Definition at line 355 of file ra8_io_blockdev_mram.c.
References ra8_io_blockdev_mram_state_t::base, ra8_io_blockdev_mram_state_t::block_count, ra8_io_blockdev_t::ctx, ra8_io_blockdev_t::iface, internal_mram_window_ok(), k_ra8_err_invalid_arg, k_ra8_io_mram_min_blocks, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_io_blockdev_mram_state_t::read_only, s_mram_iface, and s_tag.
Referenced by demo_open(), and internal_demo_open().