61 if (table_buf[0] != 0U) {
64 uint64_t max_clen = 0U;
66 if (table_buf[i + 1U] <= table_buf[i]) {
69 const uint64_t clen = table_buf[i + 1U] - table_buf[i];
70 if (clen > max_clen) {
120 uint32_t table_cap_entries)
122 const uint64_t entries = (uint64_t)rd->
chunk_count + 1U;
124 if (entries > (uint64_t)table_cap_entries) {
127 if (table_bytes > (uint64_t)UINT32_MAX) {
136 (uint32_t)table_bytes);
145 rd->
table = table_buf;
184 uint32_t table_cap_entries)
208 uint32_t table_cap_entries,
210 uint32_t staging_cap)
260 const uint64_t clen = rd->
table[idx + 1U] - rd->
table[idx];
266 size_t produced = 0U;
271 if (produced != (
size_t)len) {
282 if (rd->
table ==
nullptr) {
295 if ((uint64_t)len != expected) {
ra8_err_t priv_book_container_header_fields(const uint8_t *hdr, uint32_t *out_chunk_bytes, uint64_t *out_total, uint32_t *out_count)
Implementation of priv_book_container_header_fields() – memcpy field decode.
@ k_book_container_header_len
Fixed header bytes ahead of the chunk table.
@ k_book_container_entry_len
One chunk-table entry (uint64 LE offset).
ra8_err_t(* book_inflate_fn)(const void *src, size_t src_len, void *dst, size_t dst_cap, size_t *out_len)
Caller-supplied DEFLATE inflater used by book_open().
static ra8_err_t internal_table_check(const book_chunked_t *rd, const uint64_t *table_buf, uint64_t payload_len)
Validate a loaded chunk table's shape against the payload extent.
static ra8_err_t internal_stage_and_inflate(const book_chunked_t *rd, uint32_t idx, uint8_t *buf, uint32_t len)
Stage one chunk's compressed stream and inflate it into buf.
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.
static ra8_err_t internal_chunked_open_body(book_chunked_t *rd, uint64_t file_len, uint64_t *table_buf, uint32_t table_cap_entries)
The argument-checked body of book_chunked_open.
static ra8_err_t internal_load_table(book_chunked_t *rd, uint64_t file_len, uint64_t *table_buf, uint32_t table_cap_entries)
Load + validate the chunk table through the file reader.
static const char *const s_tag_chunked
Log tag for chunk-reader diagnostics.
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.
Demand-paged chunk reader for the "RBKC" .rabook container.
book DOM-walk helpers shared across the library's translation units.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
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_err_invalid_arg
Invalid function argument.
@ k_ra8_err_invalid_state
Module in wrong state for requested operation.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_invalid_size
Invalid size parameter (too large, too small, or misaligned).
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
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.
One open chunked .rabook file: parsed geometry + caller storage.
uint64_t inflated_total
Served flat-blob length.
ra8_vsource_read_fn file_read
Container byte reader.
uint8_t * staging
Compressed-byte staging.
book_inflate_fn inflate_cb
zlib decompressor.
const uint64_t * table
Chunk offsets.
void * file_ctx
Reader context.
uint32_t chunk_count
Chunk count.
uint32_t table_cap_entries
Table entry capacity.
uint32_t chunk_bytes
Inflated bytes per chunk.
uint64_t payload_off
First stream file offset.
uint32_t staging_cap
Staging byte capacity.