30static const char*
const s_tag =
"rabook_import_compiler";
80 if (offset > (uint64_t)UINT32_MAX) {
145 .loader_ctx = &ss->
vsrc,
180 const char* epub_path,
192 uint64_t size64 = 0U;
196 const uint32_t size = (size64 <= (uint64_t)UINT32_MAX) ? (uint32_t)size64 : 0U;
202 .
size = (uint64_t)size,
215 const char* epub_path,
216 const char* out_path)
284 uint64_t size64 = 0U;
286 const uint32_t size = (size64 <= (uint64_t)UINT32_MAX) ? (uint32_t)size64 : UINT32_MAX;
327 const char* out_path)
329 uint32_t blob_len = 0U;
404 const char* epub_path,
405 const char* out_path)
440 const char* epub_path,
441 const char* out_path)
452 const char* epub_path,
453 const char* out_path)
471 uint32_t epub_len = 0U;
Flat, execute-in-place container for a build-time "compiled" e-book.
ra8_err_t book_validate(const void *base, size_t size)
Validate that a byte buffer is a well-formed, intact .rabook blob.
static cb_io_status_t internal_source_read(void *ctx, uint64_t offset, uint8_t *dst, size_t capacity, size_t *out_read)
Read a bounded fragment from a snapshotted host source.
EPUB (.epub) reader and chapter iterator for ra8-firmware.
ra8_err_t epub_close(epub_book_t *book)
Close a previously opened EPUB book.
ra8_err_t epub_open_streamed(const epub_stream_media_t *media, const char *path, epub_book_t *out_book)
Open an EPUB book from a seekable stream, with no whole-file residency (#151).
static const char * s_tag
Logging / check tag.
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.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_no_mem
Static buffer exhausted (no dynamic memory on this project).
@ k_ra8_err_out_of_range
Sensor or peripheral output out of valid range.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_hw_error
Generic hardware fault detected (error flag set, fault interrupt).
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Minimal FAT12/FAT16/FAT32 filesystem adapter (read + write).
ra8_err_t ra8_fs_size(const ra8_fs_file_t *file, uint64_t *out_bytes)
Report the file's size in bytes (64-bit on exFAT, #676).
ra8_err_t ra8_fs_read(ra8_fs_file_t *file, uint8_t *buf, uint32_t max_len, uint32_t *got_len)
Read up to max_len bytes; advance the cluster chain on cluster crossings.
ra8_err_t ra8_fs_open(ra8_fs_mount_t *handle, const char *path, ra8_fs_mode_t mode, ra8_fs_file_t **out_file)
Open or create a file by path, 8.3 or long.
ra8_err_t ra8_fs_close(ra8_fs_file_t *file)
Close an open file, stamping its final modification time.
ra8_err_t ra8_fs_seek(ra8_fs_file_t *file, uint64_t offset_bytes)
Move the file offset to offset_bytes (clamped to size).
ra8_err_t ra8_fs_write_file(ra8_fs_mount_t *handle, const char *path, const uint8_t *data, uint32_t len)
Create a whole file in one call (provisioning helper).
@ k_ra8_fs_mode_read
Read-only, must exist.
#define ra8_log_warn(tag, message)
RA8 log warn.
End-to-end EPUB -> RABOOK1 compile pipeline (#149).
ra8_err_t rabook_compile_from_epub(epub_book_t *epub, const ra8_rabook_buffers_t *buffers, const ra8_rabook_pipeline_scratch_t *scratch, ra8_fs_mount_t *mount, const char *out_path)
Compile an open EPUB into a RABOOK1 blob written to out_path on the SD filesystem.
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.
Read a page-cached object as a seekable byte stream (Layer 2 helper, #147/#151).
ra8_err_t ra8_vmem_stream_init(ra8_vmem_stream_t *st, ra8_vmem_t *vm, uint32_t object_id, uint64_t size)
Bind a page-cached paged object to the byte-stream reader.
size_t ra8_vmem_stream_read(void *ctx, uint64_t offset, void *buf, size_t len)
Read len bytes at absolute offset through the page cache.
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_init(ra8_vsource_t *vs, ra8_vsource_obj_t *objs, uint32_t cap)
Initialise an empty source registry over a caller-owned object array.
ra8_err_t rabook_import_compile_adapter_m33(void *compile_ctx, ra8_fs_mount_t *mount, const char *epub_path, const char *out_path)
Import-seam adapter that offloads the compile to the Cortex-M33 (#149).
static ra8_err_t internal_source_read(void *ctx, uint64_t offset, uint8_t *buf, uint32_t len)
ra8_vsource_read_fn over the open source file: seek + full read.
ra8_err_t rabook_import_compile_adapter(void *compile_ctx, ra8_fs_mount_t *mount, const char *epub_path, const char *out_path)
Import-seam adapter: stream a .epub off mount and compile it.
static ra8_err_t internal_cache_bind(const rabook_import_compiler_ctx_t *ctx, import_stream_t *ss, uint32_t size)
Rebuild the cookie's page cache over the open source file.
static ra8_err_t internal_offload_or_fallback(const rabook_import_compiler_m33_ctx_t *ctx, uint32_t epub_len, ra8_fs_mount_t *mount, const char *epub_path, const char *out_path)
Run the M33 offload, retrying in-core when the offload itself failed.
static ra8_err_t internal_read_whole_file(ra8_fs_mount_t *mount, const char *path, uint8_t *buf, uint32_t cap, uint32_t *out_len)
Read a whole file off mount into buf, closing it on every path.
static ra8_err_t internal_fallback_or_propagate(const rabook_import_compiler_m33_ctx_t *ctx, ra8_err_t err, ra8_fs_mount_t *mount, const char *epub_path, const char *out_path)
Retry a failed offload in-core, or propagate the offload error.
static bool internal_is_dispatch_failure(ra8_err_t err)
Classify an offload result: does err warrant an in-core retry?
static ra8_err_t internal_stream_open(const rabook_import_compiler_ctx_t *ctx, ra8_fs_mount_t *mount, const char *epub_path, import_stream_t *ss)
Open the source .epub as a cache-fronted stream (no residency).
static ra8_err_t internal_dispatch_and_cache(const rabook_import_compiler_m33_ctx_t *ctx, uint32_t epub_len, ra8_fs_mount_t *mount, const char *out_path)
Dispatch the staged compile to the secondary core, validate, cache it.
Production adapter binding the import seam to the real compiler (#151).
Per-compile streaming state living in the adapter's stack frame.
ra8_vsource_t vsrc
Source registry the cache's loader reads through.
ra8_fs_file_t * file
Open source .epub (owned until the compile ends).
ra8_vsource_obj_t obj
The registry's single object slot.
ra8_vmem_stream_t st
Byte-stream binding handed to the EPUB reader.
Cached parse of one mounted FAT volume.
Caller-supplied storage + loader for ra8_vmem_init.
Binds one page-cached object to the byte-stream read adapter.
uint64_t size
Object length in bytes.
Page-cache state (caller-owned; treat as private).
One registered object's backing (paged or XIP).
Object-source registry (caller-owned; treat as private).
Cookie carrying the storage rabook_import_compile_adapter needs.
epub_book_t * epub
Caller-owned open-book storage.
ra8_vmem_t * cache
Page cache re-initialised per compile.
ra8_vmem_key_t * cache_keys
Per-frame key-storage array.
const ra8_rabook_buffers_t * bufs
RABOOK1 builder arenas.
uint32_t cache_frame_bytes
Bytes per cache frame (e.g.
uint32_t cache_frame_count
Frames in the pool (the RAM budget).
int32_t * cache_buckets
Cache hash-bucket heads.
uint8_t * cache_frames
Frame pool backing the cache.
uint32_t cache_bucket_count
Number of hash buckets (>= 1).
ra8_vmem_frame_t * cache_meta
Per-frame metadata array.
const ra8_rabook_pipeline_scratch_t * scr
XHTML + image decode scratch.
Cookie for rabook_import_compile_adapter_m33 (the M33-offload binding).
uint32_t blob_cap
Capacity of blob_buf in bytes.
uint8_t * blob_buf
Buffer the dispatched RABOOK1 blob lands in.
ra8_dual_core_compile_dispatch_fn dispatch
Cross-core compile seam (non-NULL).
uint8_t * epub_load_buf
Buffer the source .epub is read into.
void * dispatch_ctx
Cookie forwarded to dispatch.
rabook_import_compiler_ctx_t * fallback
In-core retry cookie used if the offload fails; NULL = offload-only.
uint32_t epub_load_cap
Capacity of epub_load_buf in bytes.