ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_cache_store.h
Go to the documentation of this file.
1
62#pragma once
63
64#ifdef __cplusplus
65extern "C" {
66#endif
67
68#include <stdint.h>
69
70#include "ra8_err.h"
71
79struct LX_NOR_FLASH_STRUCT;
80
95typedef unsigned int (*ra8_cache_store_nor_init_fn)(struct LX_NOR_FLASH_STRUCT* nor_flash);
96
111
122
136typedef struct {
137 uint32_t key;
138 uint32_t start_sector;
139 uint32_t byte_len;
140 uint16_t sector_count;
141 uint8_t flags;
142 uint8_t reserved;
144
156typedef struct {
157 struct LX_NOR_FLASH_STRUCT* flash;
159 uint8_t* staging;
160 uint16_t index_cap;
163 uint32_t log_start;
164 uint32_t data_capacity;
165 uint32_t live_sectors;
166 uint32_t next_seq;
167 uint8_t flash_state;
168 bool inited;
170
183typedef struct {
185 uint32_t data_start;
186 uint32_t data_sectors;
187 uint32_t byte_len;
189
216
251 const ra8_cache_store_cfg_t* cfg);
252
286[[nodiscard]] ra8_err_t
287ra8_cache_store_put(ra8_cache_store_t* store, uint32_t key, const uint8_t* data, uint32_t len);
288
315[[nodiscard]] ra8_err_t ra8_cache_store_get(const ra8_cache_store_t* store,
316 uint32_t key,
317 ra8_cache_store_reader_t* out_reader);
318
346ra8_err_t ra8_cache_store_read(void* ctx, uint64_t offset, uint8_t* buf, uint32_t len);
347
377[[nodiscard]] ra8_err_t ra8_cache_store_evict(ra8_cache_store_t* store, uint32_t key);
378
405[[nodiscard]] ra8_err_t ra8_cache_store_pin(ra8_cache_store_t* store, uint32_t key, bool pin);
406
432
459
460#ifdef __cplusplus
461}
462#endif
ra8_board_eth_pin_t pin
Pin.
unsigned int(* ra8_cache_store_nor_init_fn)(struct LX_NOR_FLASH_STRUCT *nor_flash)
LevelX NOR driver-initialise seam (the injected physical-flash bind).
ra8_err_t ra8_cache_store_close(ra8_cache_store_t *store)
Checkpoint, set the clean-shutdown marker, and close the store.
ra8_err_t ra8_cache_store_init(ra8_cache_store_t *store, const ra8_cache_store_cfg_t *cfg)
Bind a LevelX NOR flash instance and mount (or format) the store.
ra8_err_t ra8_cache_store_sync(ra8_cache_store_t *store)
Checkpoint the index to flash (directory + clean marker not set).
ra8_cache_store_flag_t
Per-entry index-slot flag bits.
@ k_ra8_cache_store_flag_pinned
Never-evict (open book / metadata).
@ k_ra8_cache_store_flag_none
Empty slot.
@ k_ra8_cache_store_flag_in_use
Slot holds a live entry.
ra8_cache_store_geom_t
Fixed geometry + tuning constants for the store.
@ k_ra8_cache_store_sector_bytes
LevelX logical-sector size (bytes).
@ k_ra8_cache_store_overprov_pct
Default GC headroom margin (%).
@ k_ra8_cache_store_min_sectors
Minimum usable logical-sector span.
@ k_ra8_cache_store_max_overprov
Reject nonsensical margins above.
ra8_err_t ra8_cache_store_pin(ra8_cache_store_t *store, uint32_t key, bool pin)
Pin or unpin an entry (pinned entries are never evicted).
ra8_err_t ra8_cache_store_read(void *ctx, uint64_t offset, uint8_t *buf, uint32_t len)
ra8_vsource_read_fn-shaped random read over an open entry.
ra8_err_t ra8_cache_store_get(const ra8_cache_store_t *store, uint32_t key, ra8_cache_store_reader_t *out_reader)
Open a sealed entry for random reads through ra8_cache_store_read.
ra8_err_t ra8_cache_store_put(ra8_cache_store_t *store, uint32_t key, const uint8_t *data, uint32_t len)
Seal a new entry once: append data under key, atomically.
ra8_err_t ra8_cache_store_evict(ra8_cache_store_t *store, uint32_t key)
Drop an entry and reclaim its sectors (no write-back).
Error Code Definitions for ra8-firmware.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
Injected dependencies + geometry for ra8_cache_store_init.
ra8_cache_store_nor_init_fn nor_driver_init
Injected physical-flash bind.
uint8_t * staging
Caller-owned >=1-sector scratch.
bool format
Format (wipe) before open.
uint32_t staging_bytes
Bytes at staging (>= sector).
struct LX_NOR_FLASH_STRUCT * nor_flash
Caller-owned LevelX control block.
const char * name
LevelX partition name (may be NULL).
ra8_cache_store_entry_t * index
Caller-owned index array.
uint16_t index_cap
Index slots (max live entries).
uint8_t overprovision_pct
GC headroom margin (0 => default).
uint32_t logical_sectors
Usable LevelX logical-sector span.
One RAM index slot: key -> {header sector, run length, payload len}.
uint8_t reserved
Padding; keeps the slot 16 bytes.
uint32_t byte_len
Payload length in bytes.
uint32_t start_sector
Logical sector of the entry header.
uint8_t flags
ra8_cache_store_flag_t bit set.
uint16_t sector_count
Run length (header + payload sectors).
uint32_t key
Content key (source CRC-32); valid iff in-use.
Handle to an open entry that streams through ra8_cache_store_read.
uint32_t byte_len
Payload length (== vsource size).
const ra8_cache_store_t * store
Parent store (flash + staging).
uint32_t data_start
First payload logical sector.
uint32_t data_sectors
Payload sector count.
Caller-owned store handle.
bool inited
True between init and close.
uint32_t data_capacity
Overprovisioned live-sector budget.
uint32_t log_start
First append-log sector.
uint16_t checkpoint_dirs
Directory sectors for the checkpoint.
uint32_t live_sectors
Sectors currently held by live entries.
uint8_t * staging
Caller-owned >=1-sector scratch.
ra8_cache_store_entry_t * index
Caller-owned index slot array.
uint16_t index_cap
Number of index slots.
uint32_t next_seq
Monotonic append sequence number.
struct LX_NOR_FLASH_STRUCT * flash
LevelX control block (borrowed).
uint8_t flash_state
RAM shadow of sector 0 (dirty/clean).
uint32_t logical_sectors
Usable LevelX logical-sector span.