|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Raw-descriptor composition root for caller-workspace JOF conversion. More...
#include <stddef.h>#include <stdint.h>#include <string.h>#include <unistd.h>#include "ra8_attributes.h"#include "ra8_fmt_host_fd_internal.h"#include "ra8_fmt_portable_main_internal.h"#include "ra8_fmt_stream.h"Go to the source code of this file.
Data Structures | |
| struct | convert_cli_args_t |
| Parsed arguments accepted by the portable convert composition. More... | |
Enumerations | |
| enum | convert_cli_const_t : uint32_t { k_convert_cli_ok = 0U , k_convert_cli_fail = 1U , k_convert_cli_usage = 2U , k_convert_cli_input = 268435456U , k_convert_cli_decimal = 20U , k_convert_cli_radix = 10U , k_convert_cli_align = 16U } |
| CLI status, input, and decimal formatting bounds. More... | |
Functions | |
| static ra8_err_t | internal_text (const ra8_fmt_sink_t *sink, const char *text) |
| Append one NUL-terminated diagnostic fragment. | |
| static ra8_err_t | internal_u64 (const ra8_fmt_sink_t *sink, uint64_t value) |
| Append one unsigned decimal diagnostic field. | |
| static void | internal_field (const ra8_fmt_sink_t *sink, uint64_t value, const char *suffix, ra8_err_t *status) |
| Append one numeric field and suffix while status remains successful. | |
| static void | internal_status (const ra8_fmt_sink_t *errors, const char *prefix, ra8_err_t status) |
| Emit one canonical status diagnostic through fixed local formatting. | |
| static bool | internal_parse (int argc, char **argv, convert_cli_args_t *args) |
| Parse the options accepted by the legacy convert command. | |
| static bool | internal_align (size_t value, size_t *aligned) |
| Round one byte count up to the composition arena alignment. | |
| static bool | internal_high_water (const ra8_fmt_jof_convert_requirements_t *requirements, size_t *webp_offset, size_t *total) |
| Compute the exact shared-arena high-water for one conversion. | |
| static void | internal_capacity (const ra8_fmt_sink_t *errors, const ra8_fmt_jof_convert_requirements_t *requirements, size_t required, size_t supplied) |
| Emit exact required/supplied workspace evidence. | |
| static ra8_err_t | internal_size_input (const ra8_fmt_source_t *source, size_t arena_cap, const ra8_fmt_sink_t *errors, ra8_fmt_jof_convert_requirements_t *requirements, size_t *webp_offset, size_t *high_water, bool *sized) |
| Probe exact producer requirements and confirm the caller arena fits. | |
| static ra8_err_t | internal_run (const ra8_fmt_source_t *source, const char *output, const ra8_fmt_jof_convert_requirements_t *requirements, uint8_t *arena, size_t webp_offset, const ra8_fmt_sink_t *report) |
| Bind exact work slices and execute one already-open conversion. | |
| static void | internal_report_run_failure (const ra8_fmt_sink_t *errors, ra8_err_t rc, bool sized, size_t high_water, size_t arena_cap) |
| Emit the one diagnostic matching how a failed conversion failed. | |
| int | priv_fmt_try_portable_convert (int argc, char **argv, uint8_t *arena, size_t arena_cap, bool *handled) |
| Try the caller-workspace JOF-convert command path. | |
Raw-descriptor composition root for caller-workspace JOF conversion.
Parses the JOF-convert subset, derives exact producer requirements, binds slices of an explicit caller arena, and publishes through a durable same-directory transaction. Over-budget inputs fail before stage creation.
Definition in file ra8_fmt_portable_convert.c.
| enum convert_cli_const_t : uint32_t |
CLI status, input, and decimal formatting bounds.
Definition at line 23 of file ra8_fmt_portable_convert.c.
|
static |
Round one byte count up to the composition arena alignment.
Applies checked power-of-two alignment without wrapping size_t.
| [in] | value | Unaligned byte count. |
| [out] | aligned | Receives the rounded byte count. |
| true | aligned contains the exact rounded value. |
| false | Adding alignment padding would overflow. |
aligned is writable. value. aligned unspecified and performs no I/O. Definition at line 194 of file ra8_fmt_portable_convert.c.
References k_convert_cli_align.
Referenced by internal_high_water(), and internal_layout().
|
static |
Emit exact required/supplied workspace evidence.
Reports total high-water and both component arena requirements.
| [in] | errors | Diagnostic sink. |
| [in] | requirements | Exact producer requirements. |
| [in] | required | Shared-arena high-water including alignment. |
| [in] | supplied | Caller arena capacity. |
errors and its write callback are non-null. requirements describes a successfully probed source. Definition at line 250 of file ra8_fmt_portable_convert.c.
References internal_field(), internal_text(), ra8_fmt_jof_convert_requirements_t::webp_work_bytes, and ra8_fmt_jof_convert_requirements_t::work_bytes.
Referenced by internal_size_input().
|
static |
Append one numeric field and suffix while status remains successful.
Centralizes fail-fast report composition without a local formatting macro.
| [in] | sink | Bound diagnostic sink. |
| [in] | value | Unsigned field value. |
| [in] | suffix | NUL-terminated text following the number. |
| [in,out] | status | Current and resulting sink status. |
suffix is NUL-terminated and *status is a canonical status. Definition at line 106 of file ra8_fmt_portable_convert.c.
References internal_text(), internal_u64(), and k_ra8_ok.
Referenced by internal_capacity().
|
static |
Compute the exact shared-arena high-water for one conversion.
Adds the aligned producer slice and optional WebP slice with overflow checks.
| [in] | requirements | Per-producer arena requirements. |
| [out] | webp_offset | Aligned offset of optional WebP arena. |
| [out] | total | Exact shared arena high-water. |
| true | Both outputs contain exact representable byte counts. |
| false | Alignment or addition would overflow size_t. |
requirements was produced by the requirements API. total. Definition at line 221 of file ra8_fmt_portable_convert.c.
References internal_align(), ra8_fmt_jof_convert_requirements_t::webp_work_bytes, and ra8_fmt_jof_convert_requirements_t::work_bytes.
Referenced by internal_size_input().
|
static |
Parse the options accepted by the legacy convert command.
Recognizes the same bounded convert spellings before selecting JOF.
| [in] | argc | Argument count. |
| [in] | argv | Argument vector. |
| [out] | args | Receives input, output, and format selections. |
| true | All arguments were consumed into args. |
| false | An unknown, duplicate positional, or incomplete option occurred. |
argv holds argc NUL-terminated argument pointers. args is writable and initially zeroed. argv. Definition at line 158 of file ra8_fmt_portable_convert.c.
References convert_cli_args_t::format, convert_cli_args_t::input, convert_cli_args_t::output, and strcmp().
Referenced by priv_fmt_try_portable_convert().
|
static |
Emit the one diagnostic matching how a failed conversion failed.
Distinguishes an in-budget engine failure from an unsized or over-budget source so the operator sees the correct rc-bearing line.
| [in] | errors | Diagnostic sink. |
| [in] | rc | Canonical status returned by the conversion attempt. |
| [in] | sized | Whether sizing produced a representable high-water. |
| [in] | high_water | Exact shared arena high-water, if sized. |
| [in] | arena_cap | Caller-supplied composition arena capacity. |
errors and its write callback are non-null. high_water is meaningful only when sized is true. rc emits no diagnostic. rc emits exactly one diagnostic line. Definition at line 363 of file ra8_fmt_portable_convert.c.
References internal_status(), and k_ra8_ok.
Referenced by priv_fmt_try_portable_convert().
|
static |
Bind exact work slices and execute one already-open conversion.
Begins the sibling transaction only after sizing, then delegates the full engine.
| [in] | source | Open host source. |
| [in] | output | Destination path. |
| [in] | requirements | Exact producer requirements. |
| [in,out] | arena | Caller composition workspace. |
| [in] | webp_offset | Aligned WebP arena offset. |
| [in] | report | Standard-output report sink. |
| k_ra8_ok | A complete atlas was durably published and reported. |
| other | Transaction creation or the portable engine failed. |
source and report remain bound for the complete call. arena spans both exact slices at webp_offset. Definition at line 323 of file ra8_fmt_portable_convert.c.
References k_ra8_ok, priv_fmt_host_transaction_begin(), ra8_fmt_jof_convert_stream(), ra8_fmt_jof_convert_requirements_t::webp_work_bytes, and ra8_fmt_jof_convert_requirements_t::work_bytes.
Referenced by priv_fmt_try_portable_convert().
|
static |
Probe exact producer requirements and confirm the caller arena fits.
Delegates to the requirements API and the alignment-checked high-water sum, then reports and converts a too-small arena into a canonical sizing failure so the caller need not repeat that branch.
| [in] | source | Open host source already positioned for probing. |
| [in] | arena_cap | Caller-supplied composition arena capacity. |
| [in] | errors | Diagnostic sink. |
| [out] | requirements | Receives the exact producer requirements. |
| [out] | webp_offset | Receives the aligned optional WebP arena offset. |
| [out] | high_water | Receives the exact shared arena high-water. |
| [out] | sized | Receives whether high_water is representable. |
| k_ra8_ok | The arena is large enough for the probed source. |
| k_ra8_err_invalid_size | Sizing overflowed or exceeded arena_cap. |
| other | The requirements probe itself failed. |
source remains valid and positioned for the complete probe. errors before returning. Definition at line 286 of file ra8_fmt_portable_convert.c.
References internal_capacity(), internal_high_water(), k_ra8_err_invalid_size, k_ra8_ok, and ra8_fmt_jof_convert_requirements().
Referenced by priv_fmt_try_portable_convert().
|
static |
Emit one canonical status diagnostic through fixed local formatting.
Appends a caller prefix, numeric status, and closing line delimiter.
| [in] | errors | Bound diagnostic sink. |
| [in] | prefix | NUL-terminated prefix including an opening delimiter. |
| [in] | status | Canonical status value. |
errors and its callback are non-null. prefix is non-null and NUL-terminated. Definition at line 130 of file ra8_fmt_portable_convert.c.
References internal_text(), internal_u64(), and k_ra8_ok.
Referenced by internal_report_run_failure(), and priv_fmt_try_portable_convert().
|
static |
Append one NUL-terminated diagnostic fragment.
Measures the complete fragment and delegates one exact write.
| [in] | sink | Bound diagnostic sink. |
| [in] | text | NUL-terminated text fragment. |
| k_ra8_ok | Complete text was accepted. |
sink and its callback are non-null. text is non-null and NUL-terminated. Definition at line 55 of file ra8_fmt_portable_convert.c.
References ra8_fmt_sink_t::ctx, strlen(), and ra8_fmt_sink_t::write.
Referenced by internal_capacity(), internal_field(), internal_status(), and priv_fmt_try_portable_convert().
|
static |
Append one unsigned decimal diagnostic field.
Converts without locale or formatting streams through fixed buffers.
| [in] | sink | Bound diagnostic sink. |
| [in] | value | Unsigned value to render. |
| k_ra8_ok | Every decimal digit was accepted. |
sink and its callback are non-null. Definition at line 75 of file ra8_fmt_portable_convert.c.
References ra8_fmt_sink_t::ctx, k_convert_cli_decimal, k_convert_cli_radix, and ra8_fmt_sink_t::write.
Referenced by internal_field(), and internal_status().
|
nodiscard |
Try the caller-workspace JOF-convert command path.
| [in] | argc | Process argument count. |
| [in] | argv | Process argument vector. |
| [in,out] | arena | Explicit caller-owned producer workspace. |
| [in] | arena_cap | Exact bytes supplied at arena. |
| [out] | handled | Set when this function owns the exit status. |
arena is aligned for max_align_t and spans arena_cap bytes. Definition at line 379 of file ra8_fmt_portable_convert.c.
References convert_cli_args_t::format, convert_cli_args_t::input, internal_parse(), internal_report_run_failure(), internal_run(), internal_size_input(), internal_status(), internal_text(), k_convert_cli_fail, k_convert_cli_input, k_convert_cli_ok, k_convert_cli_usage, k_ra8_ok, convert_cli_args_t::output, priv_fmt_host_fd_sink(), priv_fmt_host_source_close(), priv_fmt_host_source_open(), RA8_PRIV, ra8_fmt_host_source_t::source, and strcmp().
Referenced by internal_dispatch().