55typedef enum : uint32_t {
64[[gnu::section(
".sdram_data"),
116 if ((offset + (uint64_t)len) > m->
len) {
119 (void)
memcpy(buf, &m->
data[offset], (
size_t)len);
126 const uint64_t end = (uint64_t)off + ((uint64_t)count * (uint64_t)elem);
130 return end <= (uint64_t)total;
148 const char k_magic[8] = {
'R',
'A',
'B',
'O',
'O',
'K',
'1',
'\0'};
149 if (
memcmp(hdr->
magic, k_magic,
sizeof k_magic) != 0) {
155 if ((uint64_t)hdr->
total_size != inflated_total) {
174 for (
size_t i = 0U; i < (
sizeof(k_ext) /
sizeof(k_ext[0])); ++i) {
231 if ((file_read ==
nullptr) || (file_len == 0U)) {
256 if (
s_shp_rd.inflated_total > (uint64_t)UINT32_MAX) {
269 if (blob ==
nullptr) {
272 if (blob_len == 0U) {
@ k_book_format_version
Current .rabook layout revision.
Demand-paged chunk reader for the "RBKC" .rabook container.
ra8_err_t book_chunked_read(void *ctx, uint64_t offset, uint8_t *buf, uint32_t len)
Serve one chunk-aligned read of the inflated flat blob.
ra8_err_t book_chunked_open(book_chunked_t *rd, ra8_vsource_read_fn file_read, void *file_ctx, uint64_t file_len, book_inflate_fn inflate, uint64_t *table_buf, uint32_t table_cap_entries, uint8_t *staging, uint32_t staging_cap)
Open a chunked .rabook container for demand-paged chunk reads.
ra8_err_t book_src_paged(book_src_t *out, ra8_vmem_t *vm, uint32_t object_id, uint32_t frame_bytes, uint32_t size)
Bind a paged book source over an ra8_vmem cache + ra8_vsource object.
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
@ k_ra8_err_out_of_range
Sensor or peripheral output out of valid range.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
int memcmp(const void *a, const void *b, size_t n)
Compare bytes in two memory areas.
void * memcpy(void *dst, const void *src, size_t n)
Copy memory area between non-overlapping regions.
Byte-range page cache with SLRU eviction (Layer 2, #147).
ra8_err_t ra8_vmem_init(ra8_vmem_t *vm, const ra8_vmem_cfg_t *cfg)
Initialise a page cache over caller-supplied storage.
ra8_keycache_cell_t ra8_vmem_frame_t
Per-frame cache metadata (one caller-owned array entry per frame).
Virtual-memory object sources – the page-cache storage seam (Layer 1, #147).
ra8_err_t ra8_vsource_loader(void *ctx, uint32_t object_id, uint64_t offset, uint8_t *frame, uint32_t frame_bytes)
Fill a page frame from an object – the ra8_vmem_loader_fn adapter.
ra8_err_t ra8_vsource_add_paged(ra8_vsource_t *vs, ra8_vsource_read_fn read, void *ctx, uint64_t base, uint64_t size, uint32_t *out_id)
Register a storage-paged object; returns its object_id.
ra8_err_t(* ra8_vsource_read_fn)(void *ctx, uint64_t offset, uint8_t *buf, uint32_t len)
Read len bytes at offset from a paged object's backing.
ra8_err_t ra8_vsource_init(ra8_vsource_t *vs, ra8_vsource_obj_t *objs, uint32_t cap)
Initialise an empty source registry over a caller-owned object array.
Shared contract for the ereader_shelf multi-screen e-reader.
ra8_err_t sh_inflate(const void *src, size_t src_len, void *dst, size_t dst_cap, size_t *out_len)
Heap-free zlib inflater matching book_inflate_fn (miniz; main.c).
void sh_sd_book_close(void)
Close the held SD book file (idempotent).
sh_state_t g_sh
The single whole-app state instance (defined in main.c).
static ra8_vmem_key_t s_shp_keys[k_shp_frame_count]
Per-frame cache key storage (parallel to the frame pool).
static ra8_err_t sh_paged_mram_read(void *ctx, uint64_t offset, uint8_t *buf, uint32_t len)
ra8_vsource_read_fn over a memory-mapped (MRAM) container blob.
bool sh_paged_open(ra8_vsource_read_fn file_read, void *file_ctx, uint64_t file_len)
Open a chunked .rabook container as the demand-paged book source.
sh_paged_dim_t
Paged-stack buffer budgets.
@ k_shp_staging_bytes
>= compressBound(chunk) for zlib and miniz.
@ k_shp_table_entries
chunk_count+1 budget: 64 MiB inflated cap.
@ k_shp_frame_count
384 x 64 KiB = 24 MiB SDRAM frame pool.
@ k_shp_bucket_count
Cache hash buckets (~1.3x frames, pow2).
@ k_shp_frame_bytes
ra8_vmem frame size == container chunk_bytes.
bool sh_paged_open_mram(const uint8_t *blob, uint32_t blob_len)
Open a memory-mapped (baked MRAM) RBKC container as the paged source.
static ra8_vmem_t s_shp_vm
The page cache the bound book_src_t reads through.
static uint8_t s_shp_staging[k_shp_staging_bytes]
SDRAM staging buffer for one compressed chunk's zlib stream.
static const char *const s_shp_tag
Log tag for paged-open diagnostics.
static bool sh_paged_extent_ok(uint32_t off, uint32_t count, uint32_t elem, uint32_t total)
Does the header extent [off, off + count*elem) fit inside total?
static bool sh_paged_hdr_ok(const book_header_t *hdr, uint64_t inflated_total)
Validate the paged source's header copy (no whole-blob CRC).
static uint64_t s_shp_table[k_shp_table_entries]
Resident chunk table (chunk_count + 1 stream offsets).
static ra8_vsource_obj_t s_shp_obj
Single-slot object registry: object 0 is the open book.
static bool sh_paged_bind(void)
Register the bound chunk reader, init the cache, bind g_sh.book_src.
static ra8_vsource_t s_shp_vs
Source registry fronting s_shp_obj.
static book_chunked_t s_shp_rd
The open book's chunk reader (unbound when no rabook is open).
static int32_t s_shp_buckets[k_shp_bucket_count]
Cache hash-bucket heads.
static ra8_vmem_frame_t s_shp_meta[k_shp_frame_count]
Per-frame cache metadata (parallel to the frame pool).
static sh_paged_mram_t s_shp_mram
Backing context while an MRAM (baked) book is open.
static uint8_t s_shp_frames[k_shp_frame_count *k_shp_frame_bytes]
SDRAM page-frame pool (the old inflate-scratch budget, repurposed).
void sh_paged_close(void)
Unbind the paged book source and release its SD backing (idempotent).
One name="value" attribute on an element.
One spine document (a renderable chapter) plus its TOC label.
One open chunked .rabook file: parsed geometry + caller storage.
Descriptor for one transcoded image in the image pool.
A book data source: resident (zero-copy) or paged (demand-fetched).
A preserved CSS stylesheet and the chapter it scopes to.
Caller-supplied storage + loader for ra8_vmem_init.
The (object_id, frame-aligned offset) key the page cache hashes on.
Page-cache state (caller-owned; treat as private).
One registered object's backing (paged or XIP).
Object-source registry (caller-owned; treat as private).
Memory-mapped container backing (baked books).
const uint8_t * data
First container byte (MRAM, memory-mapped).
uint64_t len
Container length in bytes.