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

Portable command entry for JOF and RBKC content tooling. More...

#include <stddef.h>
#include <stdint.h>
#include <unistd.h>
#include "ra8_attributes.h"
#include "ra8_fmt_host_fd_internal.h"
#include "ra8_fmt_portable_main_internal.h"
#include "ra8_log.h"
Include dependency graph for main.c:

Go to the source code of this file.

Enumerations

enum  main_exit_t : uint8_t { k_main_exit_usage = 2U }
 Process status returned when no supported command owns the input. More...

Functions

static void internal_usage (const ra8_fmt_sink_t *errors)
 Offer the complete usage banner to the injected diagnostic sink.
static int internal_dispatch (int argc, char **argv, bool *handled)
 Try every portable dispatcher in stable command order.
int main (int argc, char **argv)

Variables

static ra8_fmt_cli_workspace_t s_cli_workspace
 Existing explicit high-water shared by mutually exclusive CLI verbs.
static const char s_usage []
 Established usage banner and supported-format inventory.

Detailed Description

Portable command entry for JOF and RBKC content tooling.

Dispatches the three JOF verbs and strict RBKC inspection through raw descriptors, injected callbacks, and one named caller workspace.

Since
0.1.0

Definition in file main.c.

Enumeration Type Documentation

◆ main_exit_t

enum main_exit_t : uint8_t

Process status returned when no supported command owns the input.

Enumerator
k_main_exit_usage 

Invalid or unsupported command line.

Definition at line 21 of file main.c.

Function Documentation

◆ internal_dispatch()

int internal_dispatch ( int argc,
char ** argv,
bool * handled )
static

Try every portable dispatcher in stable command order.

Offers the command to convert, verify, and inspect until one path claims ownership of the returned process status.

Parameters
[in]argcProcess argument count.
[in]argvProcess argument vector.
[out]handledReceives whether a dispatcher owns the result.
Returns
Process status from the selected dispatcher, or zero when unmatched.
Return values
0A command succeeded or no dispatcher matched.
1A selected command failed.
Precondition
argv spans argc argument pointers.
handled is non-null and writable.
Postcondition
At most one dispatcher executed a command.
handled identifies whether the return value is authoritative.
Note
Uses the single named CLI workspace and is not reentrant.
Since
0.1.0

Definition at line 84 of file main.c.

References k_ra8_fmt_cli_convert_arena_bytes, priv_fmt_try_portable_convert(), priv_fmt_try_portable_inspect(), priv_fmt_try_portable_verify(), and s_cli_workspace.

Referenced by main().

◆ internal_usage()

void internal_usage ( const ra8_fmt_sink_t * errors)
static

Offer the complete usage banner to the injected diagnostic sink.

Sends the immutable banner as one exact byte span and deliberately drops a diagnostic-only sink error.

Parameters
[in]errorsBound raw-descriptor diagnostic sink.
Precondition
errors is non-null.
errors->write remains callable for the operation.
Postcondition
The complete banner was offered exactly once.
No descriptor ownership or workspace state changed.
Note
The command exit status, not banner delivery, owns error reporting.
Since
0.1.0

Definition at line 61 of file main.c.

References s_usage.

◆ main()

int main ( int argc,
char ** argv )

Variable Documentation

◆ s_cli_workspace

ra8_fmt_cli_workspace_t s_cli_workspace
static

Existing explicit high-water shared by mutually exclusive CLI verbs.

JOF conversion uses its first 8 MiB; JOF and RBKC inspection bind disjoint typed views over the same 10,486,016-byte object.

Note
The command is single-threaded; tests bind independent workspaces.
Since
0.1.0

Definition at line 33 of file main.c.

Referenced by internal_dispatch().

◆ s_usage

const char s_usage[]
static
Initial value:
=
"usage:\n"
" ra8_fmt convert --format <fmt> --in <file> --out <file>\n"
" ra8_fmt inspect <container> [--verbose]\n"
" ra8_fmt verify --format <fmt> --in <file> [--out <dump.ppm>]\n"
"\nformats:\n"
" jof .jof [convert] [inspect] [verify] band-tile atlas (JOF): "
"display-native, O(1) random access per tile\n"
" rabook .rabook [inspect] chunked book container (RBKC): compiled "
"book, "
"one unit = one book\n"

Established usage banner and supported-format inventory.

Definition at line 36 of file main.c.

Referenced by internal_usage().