|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Strict no-heap RBKC validation and reading through the RA8 VFS. More...
#include "mdl_rabook_vfs.h"#include <stdint.h>#include <string.h>#include "book_chunked.h"#include "ra8_attributes.h"#include "ra8_io_vfs.h"Go to the source code of this file.
Functions | |
| static ra8_err_t | internal_rabook_read_exact (void *opaque, uint64_t offset, uint8_t *dst, uint32_t len) |
| Read one exact random range through an already-open VFS stream. | |
| static void | internal_rabook_clear_open (mdl_rabook_vfs_t *ctx) |
| Clear all state derived from an opened artifact. | |
| static ra8_err_t | internal_rabook_close (mdl_rabook_vfs_t *ctx) |
| Close a possibly live facade and clear open-derived state. | |
| static ra8_err_t | internal_rabook_open_reader (mdl_rabook_vfs_t *ctx, const char *path, uint64_t expected_size, bool enforce_size) |
| Open and parse one exact-size RBKC container without strict payload validation. | |
| static ra8_err_t | internal_rabook_validate_open (mdl_rabook_vfs_t *ctx, book_header_t *out_header) |
| Strictly validate the complete inner flat blob of an open reader. | |
| ra8_err_t | mdl_rabook_vfs_init (mdl_rabook_vfs_t *ctx, const mdl_rabook_vfs_config_t *config) |
| Initialize one strict RBKC VFS workspace binding. | |
| ra8_err_t | mdl_rabook_vfs_validate (void *opaque, const char *staging_path, uint64_t total_bytes, const uint8_t sha256[k_ra8_mdl_sha256_bytes]) |
| Strictly validate one closed private RBKC staging object. | |
| ra8_err_t | mdl_rabook_vfs_open (mdl_rabook_vfs_t *ctx, const char *path) |
| Open and strictly revalidate a published RBKC object for consumption. | |
| ra8_err_t | mdl_rabook_vfs_read_chunk (mdl_rabook_vfs_t *ctx, uint64_t offset, uint8_t *dst, uint32_t len) |
| Read one exact chunk-aligned flat-blob span from an open book. | |
| ra8_err_t | mdl_rabook_vfs_info (const mdl_rabook_vfs_t *ctx, book_header_t *out_header, uint64_t *out_flat_size) |
| Copy metadata from an open strictly validated book. | |
| ra8_err_t | mdl_rabook_vfs_close (mdl_rabook_vfs_t *ctx) |
| Close and release an open VFS reader facade. | |
Strict no-heap RBKC validation and reading through the RA8 VFS.
Opens staged or published RBKC data through the named VFS, performs strict streamed validation, and exposes bounded chunk reads to callers.
Definition in file mdl_rabook_vfs.c.
|
static |
Clear all state derived from an opened artifact.
Resets only state authorized by an open operation; initialization bindings and transfer-validation evidence deliberately remain available.
| [in,out] | ctx | Initialized context with no live file facade. |
ctx is non-null and file was already released. ctx. Definition at line 91 of file mdl_rabook_vfs.c.
References mdl_rabook_vfs_t::file, mdl_rabook_vfs_t::file_size, mdl_rabook_vfs_t::header, mdl_rabook_vfs_t::open, and mdl_rabook_vfs_t::reader.
Referenced by internal_rabook_close().
|
static |
Close a possibly live facade and clear open-derived state.
Attempts the VFS close when needed, then clears open state on every result so a reported close failure cannot leave a usable reader facade.
| [in,out] | ctx | Initialized context. |
| k_ra8_ok | No facade was live or the facade closed successfully. |
ctx. ctx is non-null and was initialized by the public initializer. Definition at line 115 of file mdl_rabook_vfs.c.
References mdl_rabook_vfs_t::file, internal_rabook_clear_open(), k_ra8_ok, and ra8_io_vfs_file_close().
Referenced by internal_rabook_open_reader(), mdl_rabook_vfs_close(), mdl_rabook_vfs_open(), and mdl_rabook_vfs_validate().
|
static |
Open and parse one exact-size RBKC container without strict payload validation.
Opens through the existing VFS, enforces the requested size policy, and binds RBKC geometry to the retained read-only facade.
| [in,out] | ctx | Initialized closed context. |
| [in] | path | Named VFS artifact path. |
| [in] | expected_size | Required container length when enforce_size is true. |
| [in] | enforce_size | Whether the observed length must match exactly. |
| k_ra8_ok | The exact-size policy and outer RBKC geometry passed. |
ctx has no live file facade. Definition at line 145 of file mdl_rabook_vfs.c.
References book_chunked_open(), mdl_rabook_vfs_t::compressed, mdl_rabook_vfs_t::compressed_cap, mdl_rabook_vfs_t::file, mdl_rabook_vfs_t::file_size, mdl_rabook_vfs_t::inflate_cb, internal_rabook_close(), internal_rabook_read_exact(), k_ra8_err_invalid_size, k_ra8_fs_mode_read, k_ra8_ok, ra8_io_vfs_file_open(), ra8_io_vfs_file_size(), mdl_rabook_vfs_t::reader, mdl_rabook_vfs_t::table, and mdl_rabook_vfs_t::table_cap.
Referenced by mdl_rabook_vfs_open(), and mdl_rabook_vfs_validate().
|
static |
Read one exact random range through an already-open VFS stream.
Seeks once, then converts permitted VFS short reads into an exact callback contract while rejecting successful zero progress and over-report.
| [in,out] | opaque | Bound mdl_rabook_vfs_t. |
| [in] | offset | Absolute RBKC file offset. |
| [out] | dst | Destination for exactly len bytes. |
| [in] | len | Exact byte count. |
| k_ra8_ok | The complete range was read. |
| k_ra8_err_invalid_state | The VFS stream is not open. |
| k_ra8_err_invalid_size | A successful read made zero progress. |
Definition at line 45 of file mdl_rabook_vfs.c.
References mdl_rabook_vfs_t::file, k_ra8_err_invalid_size, k_ra8_err_invalid_state, k_ra8_err_protocol_error, k_ra8_ok, ra8_io_vfs_file_read(), ra8_io_vfs_file_seek(), and RA8_LOOP_BOUND.
Referenced by internal_rabook_open_reader().
|
static |
Strictly validate the complete inner flat blob of an open reader.
Delegates to the existing strict streamed validator with the same caller-owned chunk and semantic scratch workspaces bound at initialization.
| [in,out] | ctx | Open parsed RBKC context. |
| [out] | out_header | Separate output storage for decoded metadata. |
| k_ra8_ok | Every chunk and the canonical inner RABOOK1 payload passed. |
out_header does not alias the context or any workspace. out_header completely. out_header according to the strict validator contract. Definition at line 197 of file mdl_rabook_vfs.c.
References book_chunked_validate_strict(), mdl_rabook_vfs_t::chunk, mdl_rabook_vfs_t::chunk_cap, mdl_rabook_vfs_t::reader, mdl_rabook_vfs_t::scratch, and mdl_rabook_vfs_t::scratch_cap.
Referenced by mdl_rabook_vfs_open(), and mdl_rabook_vfs_validate().
|
nodiscard |
Close and release an open VFS reader facade.
| [in,out] | ctx | Initialized context. |
ctx. Definition at line 368 of file mdl_rabook_vfs.c.
References internal_rabook_close(), and k_ra8_err_null_ptr.
Referenced by internal_consume().
|
nodiscard |
Copy metadata from an open strictly validated book.
| [in] | ctx | Open validated context. |
| [out] | out_header | Receives the decoded flat RABOOK1 header. |
| [out] | out_flat_size | Receives the inflated flat-blob length. |
| k_ra8_ok | Both outputs were initialized. |
| k_ra8_err_null_ptr | A required pointer is null. |
| k_ra8_err_invalid_state | No validated reader is open. |
ctx. Definition at line 346 of file mdl_rabook_vfs.c.
References mdl_rabook_vfs_t::file, mdl_rabook_vfs_t::header, book_chunked_t::inflated_total, k_ra8_err_invalid_state, k_ra8_err_null_ptr, k_ra8_ok, mdl_rabook_vfs_t::open, and mdl_rabook_vfs_t::reader.
Referenced by internal_consume().
|
nodiscard |
Initialize one strict RBKC VFS workspace binding.
| [out] | ctx | Caller-owned context. |
| [in] | config | Complete inflater and workspace descriptor. |
| k_ra8_ok | The context is ready for validation or open. |
| k_ra8_err_null_ptr | A required pointer is null. |
| k_ra8_err_invalid_size | A workspace capacity is zero or table has fewer than two entries. |
ctx. ctx closed with no retained VFS facade. ctx unchanged. Definition at line 207 of file mdl_rabook_vfs.c.
References mdl_rabook_vfs_config_t::chunk, mdl_rabook_vfs_config_t::chunk_cap, mdl_rabook_vfs_config_t::compressed, mdl_rabook_vfs_config_t::compressed_cap, mdl_rabook_vfs_config_t::inflate_cb, k_ra8_err_invalid_size, k_ra8_err_null_ptr, k_ra8_ok, mdl_rabook_vfs_config_t::scratch, mdl_rabook_vfs_config_t::scratch_cap, mdl_rabook_vfs_config_t::table, and mdl_rabook_vfs_config_t::table_cap.
Referenced by internal_bind_transfer().
|
nodiscard |
Open and strictly revalidate a published RBKC object for consumption.
| [in,out] | ctx | Initialized closed context. |
| [in] | path | Named VFS path of the published .rabook. |
| k_ra8_err_invalid_state | A reader is already open. |
Definition at line 298 of file mdl_rabook_vfs.c.
References mdl_rabook_vfs_t::file, mdl_rabook_vfs_t::header, internal_rabook_close(), internal_rabook_open_reader(), internal_rabook_validate_open(), k_ra8_err_invalid_state, k_ra8_err_null_ptr, k_ra8_ok, and mdl_rabook_vfs_t::open.
Referenced by internal_consume().
|
nodiscard |
Read one exact chunk-aligned flat-blob span from an open book.
| [in,out] | ctx | Open validated context. |
| [in] | offset | Chunk-aligned inflated-blob offset. |
| [out] | dst | Destination for exactly len bytes. |
| [in] | len | Exact inflated span for the selected chunk. |
len bytes in dst. Definition at line 328 of file mdl_rabook_vfs.c.
References book_chunked_read(), mdl_rabook_vfs_t::file, k_ra8_err_invalid_state, k_ra8_err_null_ptr, mdl_rabook_vfs_t::open, and mdl_rabook_vfs_t::reader.
Referenced by internal_consume().
|
nodiscard |
Strictly validate one closed private RBKC staging object.
Opens staging_path read-only, proves its exact size, validates every RBKC stream and the complete canonical RABOOK1 payload, then closes it. This signature directly satisfies mdl_storage_vfs_validate_fn.
| [in,out] | opaque | Initialized mdl_rabook_vfs_t. |
| [in] | staging_path | Named VFS path to the private closed artifact. |
| [in] | total_bytes | Independently verified transfer byte count. |
| [in] | sha256 | Independently verified transfer digest. |
opaque. Definition at line 257 of file mdl_rabook_vfs.c.
References mdl_rabook_vfs_t::digest, mdl_rabook_vfs_t::file, mdl_rabook_vfs_t::file_size, mdl_rabook_vfs_t::header, internal_rabook_close(), internal_rabook_open_reader(), internal_rabook_validate_open(), k_ra8_err_invalid_state, k_ra8_err_null_ptr, k_ra8_mdl_sha256_bytes, k_ra8_ok, memcpy(), memset(), mdl_rabook_vfs_t::open, and mdl_rabook_vfs_t::transfer_validated.
Referenced by internal_bind_transfer().