|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Fixed bump arena with refcount auto-reset for stb_truetype. More...
Go to the source code of this file.
Enumerations | |
| enum | ra8_stbtt_alloc_consts_t : uint32_t { k_ra8_stbtt_align = 16U , k_ra8_stbtt_align_mask = 15U , k_ra8_stbtt_arena_bytes = 96U * 1024U } |
| Arena sizing knobs (no magic numbers). More... | |
Functions | |
| void * | ra8_stbtt_malloc (size_t n) |
| Allocate n bytes of glyph scratch from the static arena. | |
| void | ra8_stbtt_free (void *p) |
| Release a block previously returned by ra8_stbtt_malloc(). | |
| size_t | ra8_stbtt_alloc_high_water (void) |
| Worst-case arena high-water mark observed since boot, in bytes. | |
Variables | |
| static uint8_t | s_arena [k_ra8_stbtt_arena_bytes] |
| Backing store for all stb_truetype scratch (NASA P10 Rule 3). | |
| static size_t | s_offset = 0U |
| Current bump offset into s_arena, bytes. | |
| static size_t | s_live = 0U |
| Count of live (allocated, not yet freed) blocks. | |
| static size_t | s_high_water = 0U |
| Peak s_offset observed since boot (diagnostic). | |
Fixed bump arena with refcount auto-reset for stb_truetype.
See ra8_stbtt_alloc.h for the rationale. The capacity is sized from the measured worst case: the densest printable-ASCII glyph ('@') of the bundled Literata face at the library's maximum font size (k_reflow_max_font_px = 96 px) accumulates ~32 KiB of stb scratch within a single rasterisation. The arena is provisioned at 3x that so a heavier face or a larger glyph still fits with margin.
[Ring 4 / Reflow] {World: NS}
Definition in file ra8_stbtt_alloc.c.
| enum ra8_stbtt_alloc_consts_t : uint32_t |
Arena sizing knobs (no magic numbers).
| Enumerator | |
|---|---|
| k_ra8_stbtt_align | Allocation alignment, bytes. |
| k_ra8_stbtt_align_mask | k_ra8_stbtt_align - 1. |
| k_ra8_stbtt_arena_bytes | 3x the 32 KiB worst case. |
Definition at line 31 of file ra8_stbtt_alloc.c.
| size_t ra8_stbtt_alloc_high_water | ( | void | ) |
Worst-case arena high-water mark observed since boot, in bytes.
Diagnostic hook for sizing/regression: lets a host test or an on-target probe confirm the configured capacity has headroom.
| 0 | No allocation has been made yet. |
Definition at line 83 of file ra8_stbtt_alloc.c.
References s_high_water.
| void ra8_stbtt_free | ( | void * | p | ) |
Release a block previously returned by ra8_stbtt_malloc().
Decrements the live-block count; the bump offset is not tracked per block. When the count reaches zero the arena is fully drained, so the offset rewinds to the base. A nullptr argument is ignored.
| [in] | p | Pointer to release; nullptr is ignored. |
Definition at line 70 of file ra8_stbtt_alloc.c.
| void * ra8_stbtt_malloc | ( | size_t | n | ) |
Allocate n bytes of glyph scratch from the static arena.
Bumps the arena offset by n rounded up to the 16-byte alignment and increments the live-block count. Requests larger than the arena, or that do not fit the remaining capacity, fail with nullptr.
| [in] | n | Byte count requested by stb_truetype. |
| nullptr | The request exceeds the arena or remaining capacity. |
Definition at line 50 of file ra8_stbtt_alloc.c.
References k_ra8_stbtt_align_mask, k_ra8_stbtt_arena_bytes, s_arena, s_high_water, s_live, and s_offset.
|
static |
Backing store for all stb_truetype scratch (NASA P10 Rule 3).
Aligned so every 16-byte-rounded offset yields a 16-byte-aligned pointer.
Definition at line 39 of file ra8_stbtt_alloc.c.
|
static |
Peak s_offset observed since boot (diagnostic).
Definition at line 48 of file ra8_stbtt_alloc.c.
Referenced by ra8_stbtt_alloc_high_water(), and ra8_stbtt_malloc().
|
static |
Count of live (allocated, not yet freed) blocks.
Definition at line 45 of file ra8_stbtt_alloc.c.
Referenced by ra8_stbtt_free(), and ra8_stbtt_malloc().
|
static |
Current bump offset into s_arena, bytes.
Definition at line 42 of file ra8_stbtt_alloc.c.
Referenced by ra8_stbtt_free(), and ra8_stbtt_malloc().