|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
ra8_io caching block device – an LRU sector cache over any backend. More...
Go to the source code of this file.
Data Structures | |
| struct | ra8_io_blockdev_cache_slot_t |
| Per-sector cache metadata (one caller-owned array entry per slot). More... | |
| struct | ra8_io_blockdev_cache_state_t |
| Caller-owned private state for a caching block device. More... | |
Functions | |
| ra8_err_t | ra8_io_blockdev_cache_init (ra8_io_blockdev_t *bd, ra8_io_blockdev_cache_state_t *state, const ra8_io_blockdev_t *under, uint8_t *data, ra8_io_blockdev_cache_slot_t *slots, uint32_t n_slots) |
| Bind a caching block device over an existing backend. | |
| ra8_err_t | ra8_io_blockdev_cache_stats (const ra8_io_blockdev_cache_state_t *state, uint32_t *out_hits, uint32_t *out_misses) |
| Report the cache hit/miss counters. | |
ra8_io caching block device – an LRU sector cache over any backend.
A decorator block device: it wraps another ra8_io_blockdev_t and keeps a fixed set of recently-used 512-byte sectors in a caller-owned cache, so repeated reads of the same blocks (filesystem metadata, a re-read EPUB page, a glyph atlas) skip the slow medium. Reads are served from the cache on a hit and fill it on a miss; writes are write-through (committed to the backend immediately and reflected in the cache). Eviction is least-recently-used.
This is the cache layer between the filesystem/VFS and the media. It composes with the unified page-cache design of issue #147 (and the SLRU policy chosen by tools/cache_bench); this first cut uses straightforward write-through LRU and exposes hit/miss counters for observability.
Zero allocation: the caller provides the sector data buffer and the slot metadata array, sized to the chosen number of cached sectors.
Definition in file ra8_io_blockdev_cache.h.
|
nodiscard |
Bind a caching block device over an existing backend.
| [out] | bd | Handle to bind (zero-initialised by the caller). |
| [out] | state | Caller-owned cache state to populate. |
| [in] | under | Backend to wrap (must out-live the cache). |
| [in] | data | Cache data buffer of n_slots * 512 bytes. |
| [in] | slots | Cache metadata array of n_slots entries. |
| [in] | n_slots | Number of cached sectors (>= 1). |
| k_ra8_ok | Cache bound; bd is usable. |
| k_ra8_err_null_ptr | bd, state, under, data, or slots NULL. |
| k_ra8_err_invalid_size | n_slots was zero. |
Definition at line 461 of file ra8_io_blockdev_cache.c.
References ra8_io_blockdev_t::ctx, ra8_io_blockdev_t::iface, internal_cache_reset_slots(), internal_cache_state_init(), k_ra8_err_invalid_size, k_ra8_ok, RA8_CHECK_NULL_PTR, s_cache_iface, and s_tag.
Referenced by internal_demo_mount().
|
nodiscard |
Report the cache hit/miss counters.
| [in] | state | Bound cache state. |
| [out] | out_hits | Read hits so far (may be NULL). |
| [out] | out_misses | Read misses so far (may be NULL). |
| k_ra8_ok | Counters reported. |
| k_ra8_err_null_ptr | state was NULL. |
Definition at line 483 of file ra8_io_blockdev_cache.c.
References ra8_io_blockdev_cache_state_t::hits, k_ra8_ok, ra8_io_blockdev_cache_state_t::misses, RA8_CHECK_NULL_PTR, and s_tag.
Referenced by internal_demo_run().