ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_io_blockdev_ram.h File Reference

ra8_io block-device backend over a caller-owned RAM buffer. More...

#include <stdint.h>
#include "ra8_err.h"
#include "ra8_io_blockdev.h"
Include dependency graph for ra8_io_blockdev_ram.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ra8_io_blockdev_ram_state_t
 Caller-owned private state for a RAM block device. More...

Functions

ra8_err_t ra8_io_blockdev_ram_init (ra8_io_blockdev_t *bd, ra8_io_blockdev_ram_state_t *state, uint8_t *storage, uint32_t block_count, bool read_only)
 Bind a RAM block-device backend into a caller-owned handle.

Detailed Description

ra8_io block-device backend over a caller-owned RAM buffer.

Tag
[Ring 4 / PAL] {World: NS}

The RAM backend treats a flat caller-owned byte buffer as an array of 512-byte logical blocks. It is the reference backend (the simplest correct implementation of ra8_io_blockdev_iface), the substrate for host unit tests, and a usable scratch/ramdisk volume on target (e.g. a small staging area in SRAM, or – via the SDRAM backend's identical model – the 64 MiB external SDRAM window). It erases to zero and needs no erase-before-write.

Since
0.1.0

Definition in file ra8_io_blockdev_ram.h.

Function Documentation

◆ ra8_io_blockdev_ram_init()

ra8_err_t ra8_io_blockdev_ram_init ( ra8_io_blockdev_t * bd,
ra8_io_blockdev_ram_state_t * state,
uint8_t * storage,
uint32_t block_count,
bool read_only )
nodiscard

Bind a RAM block-device backend into a caller-owned handle.

Records storage/block_count in state, marks it read-only per read_only, and points bd at the RAM vtable with state as its context. No allocation occurs; the caller owns both bd and state.

Parameters
[out]bdHandle to bind (zero-initialised by the caller).
[out]stateCaller-owned backend state to populate.
[in]storageBacking buffer of block_count * 512 bytes.
[in]block_countNumber of 512-byte logical blocks (>= 1).
[in]read_onlytrue to reject writes and erases on this device.
Returns
ra8_err_t Error code.
Return values
k_ra8_okBackend bound; bd is usable.
k_ra8_err_null_ptrbd, state, or storage was NULL.
k_ra8_err_invalid_sizeblock_count was zero.
Precondition
storage covers at least block_count * 512 bytes.
bd and state out-live every call made through the device.
Postcondition
On success bd dispatches to the RAM backend over storage.
On any non-ok return bd and state are left unbound/untouched.
Note
Not thread-safe with respect to the same device.
Since
0.1.0

Definition at line 262 of file ra8_io_blockdev_ram.c.

References ra8_io_blockdev_ram_state_t::block_count, ra8_io_blockdev_t::ctx, ra8_io_blockdev_t::iface, k_ra8_err_invalid_size, k_ra8_io_ram_min_blocks, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_io_blockdev_ram_state_t::read_only, s_ram_iface, s_tag, and ra8_io_blockdev_ram_state_t::storage.

Referenced by internal_demo_mount(), internal_demo_probe_fat(), internal_demo_probe_foreign(), internal_demo_run(), internal_demo_run(), internal_swap_run_all(), and ra8_io_blockdev_sdram_init().