|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Caller-owned bump arena backing xz-embedded's allocator seam. More...
Go to the source code of this file.
Enumerations | |
| enum | unarch_xz_pool_dims_t : uint32_t { k_unarch_xz_pool_align = 8U } |
| Alignment and sizing constants for the XZ bump arena. More... | |
Functions | |
| ra8_err_t | unarch_xz_pool_install (void *base, uint32_t len) |
| Install a caller-owned scratch buffer as the XZ allocation arena. | |
| void | unarch_xz_pool_reset (void) |
| Release the installed arena (invalidates every pool allocation). | |
| void * | unarch_xz_pool_alloc (uint32_t size) |
Bump-allocate size bytes from the installed arena. | |
| uint32_t | unarch_xz_pool_used (void) |
| Bytes currently bump-allocated from the installed arena. | |
Caller-owned bump arena backing xz-embedded's allocator seam.
The vendored xz-embedded decoder (SOUP, apps/shared_libs/third_party/xz_embedded/) allocates its state through the kernel-style kmalloc / vmalloc seam that its porting header (xz_config.h, first-party) maps onto this pool. This firmware traps the allocator (_sbrk, NASA P10 Rule 3), so the pool is a deterministic bump arena over a caller-provided scratch buffer: the XZ wrapper installs the caller's buffer before xz_dec_init, the decoder's fixed set of init-time allocations bump from it, and the wrapper resets the pool when the decode ends. Frees are no-ops (arena semantics – xz-embedded only frees at xz_dec_end, right before the wrapper resets).
The pool is intentionally module-static and single-client: the e-reader's single-threaded content loop opens one XZ stream at a time, and the wrapper install/reset pairs are strictly nested. A second concurrent install is refused fail-closed.
Definition in file unarch_xz_pool.h.
| enum unarch_xz_pool_dims_t : uint32_t |
Alignment and sizing constants for the XZ bump arena.
Every allocation is rounded up to k_unarch_xz_pool_align so the decoder's structs (which hold uint64_t fields) are always correctly aligned regardless of request order.
| Enumerator | |
|---|---|
| k_unarch_xz_pool_align | Bump-allocation alignment, bytes. |
Definition at line 54 of file unarch_xz_pool.h.
|
nodiscard |
Bump-allocate size bytes from the installed arena.
The kmalloc / vmalloc target for the vendored decoder (via the first-party xz_config.h). Returns 8-aligned storage carved from the installed scratch, or NULL when no arena is installed, the request is zero, or the remaining space is too small – xz-embedded treats a NULL return as allocation failure and aborts its init cleanly (the wrapper maps that to a bounded ra8_err_t), so exhaustion fails closed.
| [in] | size | Bytes requested (> 0). |
size bytes of 8-aligned storage, or NULL. | NULL | No arena installed, zero size, or arena exhausted. |
size is non-zero (else NULL is returned). Definition at line 84 of file unarch_xz_pool.c.
References k_unarch_xz_pool_align, s_pool_base, s_pool_len, and s_pool_off.
|
nodiscard |
Install a caller-owned scratch buffer as the XZ allocation arena.
Binds [base, base + len) as the arena xz-embedded's kmalloc / vmalloc calls bump from. Refused when an arena is already installed (strictly nested wrapper usage) so two concurrent XZ decodes cannot silently share state.
| [in] | base | Scratch buffer start (non-NULL, 8-byte aligned). |
| [in] | len | Scratch buffer length in bytes (> 0). |
| k_ra8_ok | Arena installed; allocations may begin. |
| k_ra8_err_null_ptr | base was NULL. |
| k_ra8_err_invalid_size | len was 0 or base was misaligned. |
| k_ra8_err_busy | An arena is already installed. |
base is aligned to k_unarch_xz_pool_align. Definition at line 57 of file unarch_xz_pool.c.
References k_ra8_err_busy, k_ra8_err_invalid_size, k_ra8_ok, k_unarch_xz_pool_align, RA8_CHECK_NULL_PTR, s_pool_base, s_pool_len, and s_pool_off.
Referenced by unarch_xz_stream_begin().
| void unarch_xz_pool_reset | ( | void | ) |
Release the installed arena (invalidates every pool allocation).
Unbinds the arena and zeroes the bump cursor. Idempotent: calling with no arena installed is a no-op, so teardown paths may call it unconditionally.
Definition at line 77 of file unarch_xz_pool.c.
References s_pool_base, s_pool_len, and s_pool_off.
Referenced by unarch_xz_stream_begin(), and unarch_xz_stream_end().
|
nodiscard |
Bytes currently bump-allocated from the installed arena.
Introspection for tests and RAM-high-water assertions: the exact number of scratch bytes the current decode has consumed. Zero when no arena is installed.
| 0 | No arena installed or nothing allocated yet. |
Definition at line 105 of file unarch_xz_pool.c.
References s_pool_base, and s_pool_off.