ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_cache_store_internal.h
Go to the documentation of this file.
1
35#pragma once
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41#include <stdint.h>
42
43#include "ra8_attributes.h"
44#include "ra8_cache_store.h"
45#include "ra8_err.h"
46
61
67typedef enum : uint32_t {
71
83typedef struct {
84 uint32_t magic;
85 uint32_t version;
86 uint32_t seq;
87 uint32_t clean;
88 uint32_t entry_count;
89 uint32_t live_sectors;
90 uint32_t next_seq;
91 uint32_t log_start;
92 uint32_t data_capacity;
93 uint32_t logical_sectors;
94 uint32_t crc;
96
108typedef struct {
109 uint32_t magic;
110 uint32_t seq;
111 uint32_t key;
112 uint32_t byte_len;
113 uint32_t start_sector;
114 uint16_t sector_count;
115 uint16_t flags;
116 uint32_t hdr_crc;
118
125typedef struct {
126 uint32_t key;
127 uint32_t start_sector;
128 uint32_t byte_len;
129 uint16_t sector_count;
130 uint16_t flags;
132
133static_assert(sizeof(ra8_cs_dir_ent_t) == (uint32_t)k_ra8_cs_dir_ent_bytes,
134 "directory entry layout pinned at 16 bytes");
135static_assert(sizeof(ra8_cs_entry_hdr_t) <= (uint32_t)k_ra8_cache_store_sector_bytes,
136 "entry header must fit one sector");
137static_assert(sizeof(ra8_cs_super_t) <= (uint32_t)k_ra8_cache_store_sector_bytes,
138 "superblock must fit one sector");
139
160RA8_PRIV uint32_t priv_cache_store_crc32(const uint8_t* data, uint32_t len);
161
182 uint32_t sector,
183 uint8_t* out512);
184
204 uint32_t sector,
205 const uint8_t* in512);
206
225
242RA8_PRIV int32_t priv_cache_store_index_find(const ra8_cache_store_t* store, uint32_t key);
243
265 uint32_t key,
266 uint32_t start_sector,
267 uint16_t sector_count,
268 uint32_t byte_len,
269 bool pinned);
270
292
313RA8_PRIV ra8_err_t priv_cache_store_dir_save(ra8_cache_store_t* store, uint32_t* out_entry_count);
314
315#ifdef __cplusplus
316}
317#endif
Annotation-attribute framework macros for ra8-firmware.
#define RA8_PRIV
Module-private helper: shared across TUs but only inside one library.
Persistent key(CRC32)->blob cache for compiled .rabook containers,built on the vendored,...
@ k_ra8_cache_store_sector_bytes
LevelX logical-sector size (bytes).
uint32_t priv_cache_store_crc32(const uint8_t *data, uint32_t len)
Fold a byte block into a CRC-32/ISO-HDLC value (seeded + finalised).
ra8_cs_media_const_t
Magics + serialization sizing for the on-flash records.
@ k_ra8_cs_format_version
On-flash layout revision.
@ k_ra8_cs_crc32_poly
Reflected CRC-32/ISO-HDLC polynomial.
@ k_ra8_cs_dir_per_sector
Directory entries per 512-byte sector.
@ k_ra8_cs_crc32_seed
CRC-32 pre/post conditioning.
@ k_ra8_cs_entry_magic
Entry-header tag 'R','C','S','E'.
@ k_ra8_cs_super_magic
Superblock tag 'R','C','S','1'.
@ k_ra8_cs_dir_ent_bytes
Serialized ra8_cs_dir_ent_t size.
int32_t priv_cache_store_index_add(ra8_cache_store_t *store, uint32_t key, uint32_t start_sector, uint16_t sector_count, uint32_t byte_len, bool pinned)
Claim a free index slot and populate it for key.
ra8_cs_clean_t
Values of ra8_cs_super_t::clean (the shutdown marker).
@ k_ra8_cs_dirty
Session open or crashed -> mount must replay the log.
@ k_ra8_cs_clean
Clean shutdown -> the checkpoint directory is valid.
ra8_err_t priv_cache_store_dir_save(ra8_cache_store_t *store, uint32_t *out_entry_count)
Serialize the live index into the on-flash checkpoint directory.
ra8_err_t priv_cache_store_sector_read(const ra8_cache_store_t *store, uint32_t sector, uint8_t *out512)
Read one LevelX logical sector into the store staging buffer region.
int32_t priv_cache_store_index_find(const ra8_cache_store_t *store, uint32_t key)
Find the index slot holding key.
ra8_err_t priv_cache_store_super_write(ra8_cache_store_t *store, uint32_t clean)
Write the superblock (sector 0) with the given clean marker.
ra8_err_t priv_cache_store_sector_write(ra8_cache_store_t *store, uint32_t sector, const uint8_t *in512)
Write one LevelX logical sector from a one-sector source buffer.
ra8_err_t priv_cache_store_sector_release(ra8_cache_store_t *store, uint32_t sector)
Release a LevelX logical sector back to the free pool.
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
Caller-owned store handle.
One serialized directory entry in the checkpoint region (16 bytes).
uint16_t flags
Persisted flags (pinned bit).
uint32_t key
Content key.
uint32_t start_sector
Entry header logical sector.
uint32_t byte_len
Payload length in bytes.
uint16_t sector_count
Run length (header + payload).
On-flash entry header at a run's first logical sector.
uint16_t flags
Persisted flags (pinned bit).
uint32_t magic
k_ra8_cs_entry_magic.
uint32_t start_sector
This header's own logical sector (self-anchor).
uint32_t seq
Append sequence number (monotonic).
uint32_t byte_len
Payload length in bytes.
uint32_t key
Content key (source CRC-32).
uint32_t hdr_crc
CRC-32 over the six fields above.
uint16_t sector_count
Run length (header + payload sectors).
On-flash superblock at logical sector 0 (also the checkpoint commit).
uint32_t version
k_ra8_cs_format_version.
uint32_t entry_count
Directory entries in the checkpoint.
uint32_t log_start
First append-log logical sector.
uint32_t logical_sectors
Usable logical-sector span.
uint32_t live_sectors
Live sector count at checkpoint time.
uint32_t crc
CRC-32 over the ten fields above.
uint32_t clean
ra8_cs_clean_t shutdown marker.
uint32_t data_capacity
Overprovisioned live-sector budget.
uint32_t next_seq
Next append sequence number.
uint32_t magic
k_ra8_cs_super_magic.
uint32_t seq
Checkpoint sequence (monotonic).