|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Oversized-page tile self-check for ereader_comic (#344). More...
#include "cm_tiled_check.h"#include <stddef.h>#include <stdint.h>#include <string.h>#include "comic.h"#include "comic_large_fixture.h"#include "comic_tiles.h"#include "jof.h"#include "jof_produce.h"#include "ra8_err.h"#include "ra8_tile_cache.h"Go to the source code of this file.
Data Structures | |
| struct | cm_ct_blob_t |
| Resident-buffer backing for the comic reader's seek+read seam. More... | |
Enumerations | |
| enum | cm_tiled_cfg_t : uint32_t { k_ct_tile = 256U , k_ct_bpp_gray = 1U , k_ct_cell_bytes = k_ct_tile * k_ct_tile * k_ct_bpp_gray , k_ct_cells = 8U , k_ct_buckets = 16U , k_ct_budget = 2U * 1024U * 1024U , k_ct_pagebuf = 64U * 1024U , k_ct_work = 2U * 1024U * 1024U , k_ct_atlas = 2U * 1024U * 1024U , k_ct_scratch = 96U * 1024U , k_ct_page_cap = 4U , k_ct_name_cap = 64U , k_ct_fnv_offset = 2166136261U , k_ct_fnv_prime = 16777619U } |
| Tile geometry, cache budget, and hashing constants for the self-check. More... | |
Functions | |
| static size_t | cm_ct_read (void *ctx, uint64_t off, void *buf, size_t len) |
| comic_read_fn over the resident CBZ blob (bounds-clamped). | |
| static uint32_t | cm_ct_fnv (uint32_t h, const uint8_t *p, size_t n) |
FNV-1a-32 folding n bytes of p into the running hash h. | |
| static bool | cm_ct_open (size_t *out_got) |
| Open the baked oversized CBZ and read page 0's encoded bytes. | |
| static bool | cm_ct_hash_tiles (const jof_info_t *info, uint32_t *out_crc) |
| Decode every tile of the bound atlas, FNV-hashing the pixels. | |
| static ra8_tile_cache_cfg_t | cm_ct_cache_cfg (void) |
| Tile-cache storage config over the file-static cache buffers. | |
| cm_tiled_result_t | cm_comic_tiled_selfcheck (void) |
| Open the baked oversized page through the tile path and digest it. | |
Variables | |
| static uint8_t | s_ct_pagebuf [k_ct_pagebuf] |
| SDRAM: encoded page scratch (the tile producer's input). | |
| static uint8_t | s_ct_work [k_ct_work] |
| SDRAM: producer streaming work arena. | |
| static uint8_t | s_ct_atlas [k_ct_atlas] |
| SDRAM: produced JOF atlas backing store. | |
| static uint8_t | s_ct_cells [(size_t) k_ct_cells *(size_t) k_ct_cell_bytes] |
| SDRAM: tile-cache cell storage. | |
| static uint8_t | s_ct_scratch [k_ct_scratch] |
| SDRAM: stored-tile staging for deflate tiles. | |
| static comic_page_t | s_ct_pages [k_ct_page_cap] |
| SDRAM: comic page-index storage. | |
| static char | s_ct_names [k_ct_name_cap] |
| SDRAM: comic name arena. | |
| static comic_t | s_ct_comic |
| SDRAM: the open comic reader. | |
| static comic_tile_reader_t | s_ct_reader |
| SDRAM: the comic tile reader. | |
| static ra8_tile_key_t | s_ct_keys [k_ct_cells] |
| Tile-cache key storage. | |
| static ra8_tile_dims_t | s_ct_dims [k_ct_cells] |
| Tile-cache dimension descriptors. | |
| static ra8_keycache_cell_t | s_ct_meta [k_ct_cells] |
| Tile-cache link metadata. | |
| static int32_t | s_ct_buckets [k_ct_buckets] |
| Tile-cache hash buckets. | |
| static cm_ct_blob_t | s_ct_blob |
| Blob backing bound into the read seam. | |
Oversized-page tile self-check for ereader_comic (#344).
Opens the baked oversized single-page CBZ (k_comic_large_cbz), confirms its decoded footprint overruns the whole-decode budget, transcodes the page to a JOF atlas through comic_tiles_import, and decodes every tile of the atlas in bounded RAM, FNV-hashing the decoded pixels. The result feeds a deterministic boot banner field that pins the fix on device (ra8_emulator / silicon). Every buffer is file-static SDRAM – no heap (NASA P10 Rule 3) – and the panel framebuffer is never touched, so the reader's page-1 render is undisturbed.
Definition in file cm_tiled_check.c.
| enum cm_tiled_cfg_t : uint32_t |
Tile geometry, cache budget, and hashing constants for the self-check.
Grayscale 256x256 tiles (1 bpp -> 64 KiB cells); an 8-cell cache is far smaller than the multi-MiB decoded page, so decode-on-demand paging is genuinely exercised. The budget matches the reader's whole-decode arena so the footprint decision mirrors the live path.
Definition at line 46 of file cm_tiled_check.c.
| cm_tiled_result_t cm_comic_tiled_selfcheck | ( | void | ) |
Open the baked oversized page through the tile path and digest it.
Opens k_comic_large_cbz with comic, confirms page 0's decoded footprint exceeds the whole-decode budget, transcodes it to a JOF atlas via comic_tiles_import, and decodes every tile through the owned tile cache, FNV-hashing the decoded pixels. All storage is file-static SDRAM (no heap); the panel framebuffer is never touched, so the reader's page-1 render is undisturbed.
| {.ok=true,...} | The oversized page opened + tiled + decoded cleanly. |
| {.ok=false,...} | The archive, footprint, import, or a tile decode failed. |
ok is true and the digest is deterministic.Definition at line 213 of file cm_tiled_check.c.
References cm_ct_cache_cfg(), cm_ct_hash_tiles(), cm_ct_open(), comic_close(), comic_tiles_footprint(), comic_tiles_import(), comic_tiles_info(), comic_tiles_init(), comic_tiles_over_budget(), cm_tiled_result_t::crc, cm_tiled_result_t::h, jof_info_t::height, k_comic_large_h, k_comic_large_w, k_ct_budget, k_ct_scratch, k_ct_tile, k_jof_codec_deflate, k_ra8_ok, cm_tiled_result_t::ok, s_ct_atlas, s_ct_comic, s_ct_pagebuf, s_ct_reader, s_ct_scratch, s_ct_work, jof_info_t::tile_count, cm_tiled_result_t::tiles, cm_tiled_result_t::w, and jof_info_t::width.
Referenced by main().
|
static |
Tile-cache storage config over the file-static cache buffers.
Definition at line 197 of file cm_tiled_check.c.
References k_ct_buckets, k_ct_cell_bytes, k_ct_cells, s_ct_buckets, s_ct_cells, s_ct_dims, s_ct_keys, and s_ct_meta.
Referenced by cm_comic_tiled_selfcheck().
|
static |
FNV-1a-32 folding n bytes of p into the running hash h.
Definition at line 120 of file cm_tiled_check.c.
References k_ct_fnv_prime.
Referenced by cm_ct_hash_tiles().
|
static |
Decode every tile of the bound atlas, FNV-hashing the pixels.
| [in] | info | Parsed atlas geometry of the imported page. |
| [out] | out_crc | Receives the digest over all tile payloads. |
| true | All tiles decoded; *out_crc holds the digest. |
| false | A tile fetch failed (digest not trustworthy). |
info is its geometry. out_crc is writable. Definition at line 176 of file cm_tiled_check.c.
References jof_info_t::bpp, cm_ct_fnv(), comic_tiles_release(), comic_tiles_tile(), ra8_tile_t::height, k_ct_fnv_offset, k_ra8_ok, ra8_tile_t::pixels, s_ct_reader, jof_info_t::tile_cols, jof_info_t::tile_rows, and ra8_tile_t::width.
Referenced by cm_comic_tiled_selfcheck().
|
static |
Open the baked oversized CBZ and read page 0's encoded bytes.
| [out] | out_got | Receives the encoded page length. |
| true | s_ct_comic is open and s_ct_pagebuf holds the encoded page. |
| false | The archive failed to open or extract. |
out_got is writable. Definition at line 141 of file cm_tiled_check.c.
References cm_ct_read(), comic_open(), comic_page_count(), comic_page_read(), k_comic_large_cbz, k_comic_large_cbz_len, k_ct_name_cap, k_ct_page_cap, k_ra8_ok, s_ct_blob, s_ct_comic, s_ct_names, s_ct_pagebuf, and s_ct_pages.
Referenced by cm_comic_tiled_selfcheck().
|
static |
comic_read_fn over the resident CBZ blob (bounds-clamped).
Definition at line 107 of file cm_tiled_check.c.
References cm_ct_blob_t::d, memcpy(), and cm_ct_blob_t::n.
Referenced by cm_ct_open().
|
static |
SDRAM: produced JOF atlas backing store.
Definition at line 80 of file cm_tiled_check.c.
Referenced by cm_comic_tiled_selfcheck().
|
static |
Blob backing bound into the read seam.
Definition at line 103 of file cm_tiled_check.c.
Referenced by cm_ct_open().
|
static |
Tile-cache hash buckets.
Definition at line 101 of file cm_tiled_check.c.
Referenced by cm_ct_cache_cfg().
|
static |
SDRAM: tile-cache cell storage.
Definition at line 83 of file cm_tiled_check.c.
Referenced by cm_ct_cache_cfg().
|
static |
SDRAM: the open comic reader.
Definition at line 91 of file cm_tiled_check.c.
Referenced by cm_comic_tiled_selfcheck(), and cm_ct_open().
|
static |
Tile-cache dimension descriptors.
Definition at line 97 of file cm_tiled_check.c.
Referenced by cm_ct_cache_cfg().
|
static |
Tile-cache key storage.
Definition at line 95 of file cm_tiled_check.c.
Referenced by cm_ct_cache_cfg().
|
static |
Tile-cache link metadata.
Definition at line 99 of file cm_tiled_check.c.
Referenced by cm_ct_cache_cfg().
|
static |
SDRAM: comic name arena.
Definition at line 89 of file cm_tiled_check.c.
Referenced by cm_ct_open().
|
static |
SDRAM: encoded page scratch (the tile producer's input).
Definition at line 76 of file cm_tiled_check.c.
Referenced by cm_comic_tiled_selfcheck(), and cm_ct_open().
|
static |
SDRAM: comic page-index storage.
Definition at line 87 of file cm_tiled_check.c.
Referenced by cm_ct_open().
|
static |
SDRAM: the comic tile reader.
Definition at line 93 of file cm_tiled_check.c.
Referenced by cm_comic_tiled_selfcheck(), and cm_ct_hash_tiles().
|
static |
SDRAM: stored-tile staging for deflate tiles.
Definition at line 85 of file cm_tiled_check.c.
Referenced by cm_comic_tiled_selfcheck().
|
static |
SDRAM: producer streaming work arena.
Definition at line 78 of file cm_tiled_check.c.
Referenced by cm_comic_tiled_selfcheck().