ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
rabook_import_compiler.h File Reference

Production adapter binding the import seam to the real compiler (#151). More...

#include <stddef.h>
#include <stdint.h>
#include "epub.h"
#include "ra8_dual_core_job.h"
#include "ra8_err.h"
#include "ra8_fs.h"
#include "ra8_rabook_pipeline.h"
#include "ra8_vmem.h"
Include dependency graph for rabook_import_compiler.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  rabook_import_compiler_ctx_t
 Cookie carrying the storage rabook_import_compile_adapter needs. More...
struct  rabook_import_compiler_m33_ctx_t
 Cookie for rabook_import_compile_adapter_m33 (the M33-offload binding). More...

Functions

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.
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).

Detailed Description

Production adapter binding the import seam to the real compiler (#151).

rabook_import.h keeps the cache manager decoupled from the EPUB parser and the RABOOK1 emitter by reaching the compile step through the injected rabook_import_compile_fn seam. This adapter is the production binding of that seam: it STREAMS the source .epub off the filesystem through a bounded ra8_vmem page cache (#230 – no whole-file load buffer, so a source far larger than RAM compiles inside a fixed frame-pool budget), drives rabook_compile_from_epub, and closes the book – matching the seam's exact signature so an app passes rabook_import_compile_adapter (with a rabook_import_compiler_ctx_t cookie) straight into rabook_import_cfg_t.

Host tests bypass this adapter entirely with a lightweight compile spy, which is the whole point of the seam – they need neither the parser nor the multi-megabyte builder arenas.

Note
Not thread-safe; the cookie's storage is single-owner.
See also
rabook_import.h The cache manager that calls this seam.
rabook_compile_from_epub The compiler this wraps.
Since
Version 0.1.0

[Ring 4 / EPUB Import] {World: NS}

Definition in file rabook_import_compiler.h.

Function Documentation

◆ rabook_import_compile_adapter()

ra8_err_t rabook_import_compile_adapter ( void * compile_ctx,
ra8_fs_mount_t * mount,
const char * epub_path,
const char * out_path )
nodiscard

Import-seam adapter: stream a .epub off mount and compile it.

Signature matches rabook_import_compile_fn. Opens the source file, fronts it with the cookie's bounded ra8_vmem page cache, opens the book with epub_open_streamed (no whole-file residency, #230), runs rabook_compile_from_epub to out_path, and closes the book and the source file on every path.

Parameters
[in]compile_ctxPointer to a rabook_import_compiler_ctx_t.
[in,out]mountMounted volume holding the source and the output.
[in]epub_pathRoot-level path of the source .epub.
[in]out_pathPath to write the RABOOK1 body to (the importer's temp name).
Returns
Error code.
Return values
k_ra8_okBook compiled and written to out_path.
k_ra8_err_null_ptrA required pointer (incl. a cookie field) is NULL.
k_ra8_err_*Propagated open / cache-bind / compile error.
Precondition
compile_ctx points at a fully-populated cookie.
mount, epub_path, and out_path are non-NULL.
Postcondition
On k_ra8_ok, out_path holds a valid RABOOK1 blob and the book is closed.
The source file handle is closed on every return path.
Note
Not thread-safe.
Since
Version 0.1.0

Definition at line 213 of file rabook_import_compiler.c.

References rabook_import_compiler_ctx_t::bufs, rabook_import_compiler_ctx_t::epub, epub_close(), import_stream_t::file, internal_stream_open(), k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_fs_close(), rabook_compile_from_epub(), s_tag, and rabook_import_compiler_ctx_t::scr.

Referenced by imp_make_cfg(), and internal_fallback_or_propagate().

◆ rabook_import_compile_adapter_m33()

ra8_err_t rabook_import_compile_adapter_m33 ( void * compile_ctx,
ra8_fs_mount_t * mount,
const char * epub_path,
const char * out_path )
nodiscard

Import-seam adapter that offloads the compile to the Cortex-M33 (#149).

Signature matches rabook_import_compile_fn. Reads the source .epub off mount, dispatches the compile to the secondary core via the cookie's ra8_dual_core_compile_dispatch_fn, validates the returned blob with book_validate, then writes it to out_path (the manager renames it into the cache). The M85 owns the filesystem; the M33 only produces the blob in shared memory.

If the offload fails with a TIMEOUT/FAULT (k_ra8_err_hw_error) or a transport overflow (k_ra8_err_no_mem) and the cookie carries a rabook_import_compiler_ctx_t.fallback, the compile is retried IN-CORE so a transient secondary-core failure never fails the import. A clean offload result is used directly; other errors propagate.

Parameters
[in]compile_ctxPointer to a rabook_import_compiler_m33_ctx_t.
[in,out]mountMounted volume holding the source and the output.
[in]epub_pathRoot-level path of the source .epub.
[in]out_pathPath to write the RABOOK1 body to (importer temp name).
Returns
Error code.
Return values
k_ra8_okBlob produced (on the M33, or in-core on fallback), validated, and written to out_path.
k_ra8_err_null_ptrA required pointer (incl. a cookie field) is NULL.
k_ra8_err_*Propagated read / dispatch / validate / write error (the in-core fallback error when that path is taken).
Precondition
compile_ctx points at a fully-populated cookie with a non-NULL dispatch.
mount, epub_path, and out_path are non-NULL.
Postcondition
On k_ra8_ok, out_path holds a book_validate-clean RABOOK1 blob.
On any error, out_path is not written.
Note
Not thread-safe.
See also
ra8_dual_core_compile_dispatch_fn
rabook_import_compile_adapter
Since
Version 0.1.0

Definition at line 450 of file rabook_import_compiler.c.

References rabook_import_compiler_m33_ctx_t::dispatch, rabook_import_compiler_m33_ctx_t::epub_load_buf, rabook_import_compiler_m33_ctx_t::epub_load_cap, internal_fallback_or_propagate(), internal_offload_or_fallback(), internal_read_whole_file(), k_ra8_ok, RA8_CHECK_NULL_PTR, and s_tag.