|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Strict callback-driven RBKC and RABOOK1 inspection. More...
#include <stddef.h>#include <stdint.h>#include <string.h>#include "book_chunked.h"#include "miniz.h"#include "ra8_attributes.h"#include "ra8_fmt_stream.h"Go to the source code of this file.
Data Structures | |
| struct | source_adapter_t |
| Positioned-source binding for the exact book-reader callback. More... | |
Enumerations | |
| enum | report_constant_t : uint32_t { k_report_radix = 10U , k_report_digits = 20U , k_report_rows = 4096U , k_report_idx_width = 5U , k_report_num_width = 10U } |
| Bounded report formatting constants. More... | |
Functions | |
| static ra8_err_t | internal_text (const ra8_fmt_sink_t *report, const char *text) |
| Append one NUL-terminated literal to the report sink. | |
| static ra8_err_t | internal_u64 (const ra8_fmt_sink_t *report, uint64_t value, uint32_t width) |
| Render one unsigned value with optional left padding. | |
| static ra8_err_t | internal_field (const ra8_fmt_sink_t *report, const char *label, uint64_t value) |
| Emit a labelled unsigned field and its terminating newline. | |
| static ra8_err_t | internal_exact_read (void *opaque, uint64_t offset, uint8_t *bytes, uint32_t len) |
| Adapt legal short positioned reads to one exact book read. | |
| static ra8_err_t | internal_inflate (const void *src, size_t src_len, void *dst, size_t dst_cap, size_t *out_len) |
| Inflate one RFC 1950 stream through miniz caller storage. | |
| static ra8_err_t | internal_header (const ra8_fmt_sink_t *report, const ra8_fmt_source_t *source, const book_chunked_t *reader) |
| Emit the established RBKC header block. | |
| static ra8_err_t | internal_row (const ra8_fmt_sink_t *report, uint32_t idx, uint64_t begin, uint64_t end) |
| Emit one established-width chunk inventory row. | |
| static ra8_err_t | internal_table (const ra8_fmt_sink_t *report, const book_chunked_t *reader, bool verbose) |
| Emit the bounded chunk inventory when verbose output is enabled. | |
| static ra8_err_t | internal_report (const ra8_fmt_sink_t *report, const ra8_fmt_source_t *source, const book_chunked_t *reader, bool verbose) |
| Emit a validated header, optional inventory, and stable verdict. | |
| ra8_err_t | ra8_fmt_rabook_inspect_stream (const ra8_fmt_source_t *source, bool verbose, ra8_fmt_rabook_inspect_workspace_t *workspace, const ra8_fmt_sink_t *report) |
| Strictly inspect one streamed RBKC container and its RABOOK1 payload. | |
Strict callback-driven RBKC and RABOOK1 inspection.
Opens the container through positioned reads, validates every zlib stream and the complete inner book, then emits the established inventory.
Definition in file ra8_fmt_stream_rabook.c.
| enum report_constant_t : uint32_t |
Bounded report formatting constants.
Definition at line 21 of file ra8_fmt_stream_rabook.c.
|
static |
Adapt legal short positioned reads to one exact book read.
Bounds the complete requested range, then loops over positive short reads until the strict book-reader contract is satisfied.
| [in,out] | opaque | Bound source_adapter_t context. |
| [in] | offset | Absolute container byte offset. |
| [out] | bytes | Destination for exactly len bytes. |
| [in] | len | Exact requested byte count. |
| k_ra8_ok | Exactly len bytes were copied. |
| k_ra8_err_invalid_size | The range exceeds the captured source. |
opaque resolves to a live immutable source. bytes spans len bytes when len is nonzero. Definition at line 140 of file ra8_fmt_stream_rabook.c.
References ra8_fmt_source_t::ctx, k_ra8_err_invalid_size, k_ra8_err_null_ptr, k_ra8_ok, ra8_fmt_source_t::read_at, ra8_fmt_source_t::size, and source_adapter_t::source.
Referenced by ra8_fmt_rabook_inspect_stream().
|
static |
Emit a labelled unsigned field and its terminating newline.
Writes the label, decimal value, and line ending fail-fast.
| [in] | report | Bound injected text sink. |
| [in] | label | NUL-terminated field label. |
| [in] | value | Unsigned value to render. |
| k_ra8_ok | The complete field line was accepted. |
| other | The first rejected sink span stopped output. |
report and its callback are non-null. label is non-null and NUL-terminated. Definition at line 112 of file ra8_fmt_stream_rabook.c.
References internal_text(), internal_u64(), and k_ra8_ok.
Referenced by internal_header().
|
static |
Emit the established RBKC header block.
Preserves the original field labels and ordering for compatible CLI output after the strict reader has accepted the container.
| [in] | report | Bound injected text sink. |
| [in] | source | Validated immutable container source. |
| [in] | reader | Open strict chunk reader. |
| k_ra8_ok | The complete header block was accepted. |
| other | The first rejected sink span stopped output. |
reader describes source after a successful open. Definition at line 222 of file ra8_fmt_stream_rabook.c.
References book_chunked_t::chunk_bytes, book_chunked_t::chunk_count, book_chunked_t::inflated_total, internal_field(), internal_text(), internal_u64(), k_ra8_ok, and ra8_fmt_source_t::size.
Referenced by internal_report().
|
static |
Inflate one RFC 1950 stream through miniz caller storage.
Parses the zlib wrapper and requires a non-wrapping output buffer.
| [in] | src | Complete compressed stream bytes. |
| [in] | src_len | Compressed byte length. |
| [out] | dst | Caller-owned inflated destination. |
| [in] | dst_cap | Destination byte capacity. |
| [out] | out_len | Receives the inflated byte length. |
| k_ra8_ok | One complete stream was inflated. |
| k_ra8_err_validation_failed | The stream was malformed or oversized. |
out_len is non-null and writable. out_len and its destination prefix. Definition at line 186 of file ra8_fmt_stream_rabook.c.
References k_ra8_err_null_ptr, k_ra8_err_validation_failed, and k_ra8_ok.
|
static |
Emit a validated header, optional inventory, and stable verdict.
Sequences the established report sections fail-fast after strict outer and inner validation has completed.
| [in] | report | Bound injected text sink. |
| [in] | source | Validated immutable container source. |
| [in] | reader | Open validated chunk reader. |
| [in] | verbose | Whether to include the bounded chunk inventory. |
| k_ra8_ok | The complete requested report was accepted. |
| other | The first rejected sink span stopped output. |
Definition at line 338 of file ra8_fmt_stream_rabook.c.
References internal_header(), internal_table(), internal_text(), and k_ra8_ok.
Referenced by ra8_fmt_rabook_inspect_stream().
|
static |
Emit one established-width chunk inventory row.
Renders index, absolute start, absolute end, and compressed length with the column widths used by the prior inspector.
| [in] | report | Bound injected text sink. |
| [in] | idx | Zero-based chunk index. |
| [in] | begin | Absolute compressed-stream start. |
| [in] | end | Absolute exclusive compressed-stream end. |
| k_ra8_ok | The complete row was accepted. |
| other | The first rejected sink span stopped output. |
report and its callback are non-null. end is not less than begin. Definition at line 265 of file ra8_fmt_stream_rabook.c.
References internal_text(), internal_u64(), k_ra8_ok, k_report_idx_width, and k_report_num_width.
Referenced by internal_table().
|
static |
Emit the bounded chunk inventory when verbose output is enabled.
Walks validated table entries and reports at most 4096 rows.
| [in] | report | Bound injected text sink. |
| [in] | reader | Open validated chunk reader. |
| [in] | verbose | Whether inventory output is enabled. |
| k_ra8_ok | Output was disabled or every selected row was accepted. |
| other | The first rejected sink span stopped output. |
report and reader are non-null. Definition at line 301 of file ra8_fmt_stream_rabook.c.
References book_chunked_t::chunk_count, internal_row(), internal_text(), k_ra8_ok, k_report_rows, book_chunked_t::payload_off, and book_chunked_t::table.
Referenced by internal_report().
|
static |
Append one NUL-terminated literal to the report sink.
Measures the literal once and delegates its exact payload span.
| [in] | report | Bound injected text sink. |
| [in] | text | NUL-terminated source text. |
| k_ra8_ok | The complete literal was accepted. |
| other | The injected sink rejected the span. |
report and its callback are non-null. text is non-null and NUL-terminated. Definition at line 50 of file ra8_fmt_stream_rabook.c.
References strlen().
Referenced by internal_field(), internal_header(), internal_report(), internal_row(), internal_table(), internal_u64(), and ra8_fmt_rabook_inspect_stream().
|
static |
Render one unsigned value with optional left padding.
Converts through fixed local buffers and emits spaces before digits when the requested field is wider than the decimal spelling.
| [in] | report | Bound injected text sink. |
| [in] | value | Unsigned value to render. |
| [in] | width | Minimum output field width. |
| k_ra8_ok | Every padding and digit byte was accepted. |
| other | The injected sink rejected a span. |
report and its callback are non-null. Definition at line 73 of file ra8_fmt_stream_rabook.c.
References internal_text(), k_ra8_ok, k_report_digits, and k_report_radix.
Referenced by internal_field(), internal_header(), and internal_row().
|
nodiscard |
Strictly inspect one streamed RBKC container and its RABOOK1 payload.
| [in] | source | Immutable positioned container source. |
| [in] | verbose | Emit the bounded chunk inventory. |
| [in,out] | workspace | Exact-or-larger table and validator buffers. |
| [in,out] | report | Human-readable injected text sink. |
Definition at line 352 of file ra8_fmt_stream_rabook.c.
References book_chunked_open(), book_chunked_validate_strict(), ra8_fmt_rabook_inspect_workspace_t::chunk, ra8_fmt_rabook_inspect_workspace_t::chunk_cap, ra8_fmt_rabook_inspect_workspace_t::compressed, ra8_fmt_rabook_inspect_workspace_t::compressed_cap, ra8_fmt_source_t::ctx, internal_exact_read(), internal_inflate(), internal_report(), internal_text(), k_ra8_err_null_ptr, k_ra8_ok, ra8_fmt_source_t::read_at, ra8_fmt_rabook_inspect_workspace_t::scratch, ra8_fmt_rabook_inspect_workspace_t::scratch_cap, ra8_fmt_source_t::size, ra8_fmt_rabook_inspect_workspace_t::table, ra8_fmt_rabook_inspect_workspace_t::table_cap, and ra8_fmt_source_t::validate.
Referenced by internal_run_rabook().