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

The application layer's one composition seam: the bound working set. More...

#include "mdl_app.h"
#include "mdl_app_internal.h"
Include dependency graph for mdl_app.c:

Go to the source code of this file.

Functions

void mdl_app_bind (mdl_app_context_t *ctx)
 Bind the caller-owned working set every application mode will use.
mdl_app_context_tpriv_mdl_app_context (void)
 The working set the composition root bound with mdl_app_bind.

Variables

static mdl_app_context_ts_app_ctx = nullptr
 The one context every application mode currently reads.

Detailed Description

The application layer's one composition seam: the bound working set.

Holds the pointer a form hands to mdl_app_bind and nothing else. The modes reach their shared bounded state through the accessor here, so the downloader owns no storage of its own and a test can bind a fixture context in place of the production one.

Definition in file mdl_app.c.

Function Documentation

◆ mdl_app_bind()

void mdl_app_bind ( mdl_app_context_t * ctx)

Bind the caller-owned working set every application mode will use.

The composition seam for the application layer. A form declares one mdl_app_context_t in its own storage – static on a host, a reserved SRAM region on the device – initialises the members it owns (the two streams, the storage facade, the exporter workspace) and hands the address here. Every mode then reads that one context through a module-private accessor, so the downloader needs no global of its own and a test can bind a fixture context instead of the production one.

Binding is unconditional and reports nothing: there is exactly one thing it can do and one way to get it wrong, and passing a context the modes cannot dereference is a composition defect rather than a runtime condition – the same contract mdl_export_workspace_init already publishes for the exporter arena.

Parameters
[in,out]ctxCaller-owned context, live until the next bind.
Returns
Nothing.
Precondition
ctx addresses writable storage for one complete context.
No mode call is in progress on another thread.
Postcondition
ctx is the context every subsequent mode reads.
No caller storage is copied and no ownership is transferred.
Note
Not thread-safe: it publishes process-wide composition state.
Since
0.1.0

Definition at line 28 of file mdl_app.c.

References s_app_ctx.

Referenced by internal_main_init().

◆ priv_mdl_app_context()

mdl_app_context_t * priv_mdl_app_context ( void )

The working set the composition root bound with mdl_app_bind.

The one way an application mode reaches shared bounded state. It is a function rather than an extern object so the storage stays owned by the form and this layer keeps no global of its own.

Returns
The bound context.
Return values
non-NULLThe context most recently passed to mdl_app_bind.
nullptrNo form has bound a context yet.
Precondition
A form has called mdl_app_bind for any mode to be usable.
The caller does not retain the pointer past the next bind.
Postcondition
No context state is modified.
Successive calls return the same pointer until the next bind.
Note
Not thread-safe against a concurrent mdl_app_bind.
Since
0.1.0

Definition at line 33 of file mdl_app.c.

References RA8_PRIV, and s_app_ctx.

Referenced by internal_admin_latch(), internal_apply_order(), internal_build_export_metadata(), internal_cover_cached(), internal_cover_current(), internal_cover_finish(), internal_cover_stream(), internal_direct_latch(), internal_direct_pack_failure(), internal_download_page_image(), internal_download_page_images(), internal_export_after(), internal_export_fresh_separate(), internal_extract_cover(), internal_extract_optional_metadata(), internal_extract_page_images(), internal_extract_series_metadata(), internal_fetch_artifact(), internal_finish_artifact_fetch(), internal_init_site_identity(), internal_library_report(), internal_list_cb(), internal_make_ctx(), internal_pack_directory_output(), internal_pack_file_output(), internal_prepare_artifact_path(), internal_prepare_diag3(), internal_prepare_filter_chapters(), internal_prepare_output_dir(), internal_publish_page_image(), internal_reconcile_series_state(), internal_remove_stale_page_variants(), internal_report_cover_failure(), internal_report_stats(), internal_resolve_removal_target(), internal_run_prepared(), internal_run_series_network(), internal_run_series_paths(), internal_save_series_state(), internal_select_run_window(), internal_select_window(), internal_snapshot_prior_metadata(), internal_update_all_cb(), internal_verify_artifact_entry(), internal_verify_artifacts(), internal_verify_library_root(), internal_verify_page_rec(), internal_verify_series_dir(), internal_warn_no_contact(), mdl_app_run_artifact(), mdl_app_run_discover(), mdl_app_run_init_site(), mdl_app_run_list(), mdl_app_run_pack(), mdl_app_run_page(), mdl_app_run_remove(), mdl_app_run_series(), mdl_app_run_update_all(), mdl_app_run_verify(), priv_mdl_app_ensure_series_cover(), priv_mdl_app_prepare_chapters(), priv_mdl_app_prepare_series_dir(), priv_mdl_app_report_cache(), and priv_mdl_app_start_session().

Variable Documentation

◆ s_app_ctx

mdl_app_context_t* s_app_ctx = nullptr
static

The one context every application mode currently reads.

Null until a form calls mdl_app_bind. It is a POINTER rather than the object because the working set is several megabytes and the form – host static storage, or a reserved SRAM region on the device – is the only layer that can decide where those bytes live.

Note
Written only by mdl_app_bind; read only by priv_mdl_app_context.
Warning
Do not name it from another translation unit; use the accessor.
Since
0.1.0

Definition at line 26 of file mdl_app.c.

Referenced by mdl_app_bind(), and priv_mdl_app_context().