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

End-to-end on-import EPUB -> .rabook compile + cache + read (#151). More...

#include <stddef.h>
#include <stdint.h>
#include "book.h"
#include "epub.h"
#include "ra8_board_ek_ra8d2.h"
#include "ra8_boot_entry.h"
#include "ra8_cgc.h"
#include "ra8_err.h"
#include "ra8_fs.h"
#include "ra8_isr.h"
#include "ra8_log.h"
#include "ra8_rabook_pipeline.h"
#include "ra8_sdmmc_spi.h"
#include "ra8_time.h"
#include "ra8_vmem.h"
#include "rabook_compile.h"
#include "rabook_import.h"
#include "rabook_import_compiler.h"
Include dependency graph for main.c:

Go to the source code of this file.

Macros

#define IMP_PUTS(lit)
 Emit a NUL-terminated literal (length via sizeof at the call site).

Enumerations

enum  imp_config_t : uint32_t {
  k_imp_uart_baud = 115200U ,
  k_imp_spi_channel = 0U ,
  k_imp_format_version = 1U ,
  k_imp_importer_version = 1U ,
  k_imp_scratch_cap = 4096U ,
  k_imp_path_cap = 16U ,
  k_imp_dec_base = 10U ,
  k_imp_str_max = 256U
}
 Compile-time settings for the on-import compile + cache + read demo. More...
enum  imp_buf_cap_t : uint32_t {
  k_imp_cache_frame_bytes = 4096U ,
  k_imp_cache_frames = 64U ,
  k_imp_cache_buckets = 128U ,
  k_imp_chapter_cap = 32U ,
  k_imp_node_cap = 2048U ,
  k_imp_attr_cap = 512U ,
  k_imp_style_cap = 16U ,
  k_imp_image_cap = 32U ,
  k_imp_string_cap = 64U * 1024U ,
  k_imp_imgpool_cap = 1024U * 1024U ,
  k_imp_out_cap = 512U * 1024U ,
  k_imp_xhtml_cap = 64U * 1024U ,
  k_imp_css_cap = 16U * 1024U ,
  k_imp_imgraw_cap = 2U * 1024U * 1024U ,
  k_imp_arena_cap = 4U * 1024U * 1024U ,
  k_imp_gray_cap = 2U * 1024U * 1024U ,
  k_imp_readback_cap = 512U * 1024U
}
 SDRAM working-arena capacities (sized for a small text book). More...

Functions

static void imp_print (const uint8_t *msg, uint32_t len)
 Write a byte run on the J-Link OB console.
static void imp_print_cstr (const char *str)
 Emit a NUL-terminated C-string, bounded to k_imp_str_max bytes.
static void imp_print_uint (uint32_t value)
 Print a small unsigned integer in decimal.
static void imp_panic (const char *stage)
 Print the FAIL banner with a stage tag, then trap and park.
static void imp_setup_or_halt (uint32_t *out_pclka_hz)
 Bring up CGC + SysTick + console SCI; panic on failure.
static void imp_init_card_or_halt (uint32_t pclka_hz)
 Build the SCI-SPI transport, run SD identification; panic on failure.
static void imp_mount_or_halt (ra8_fs_mount_t **out_mount)
 Bind the SD-over-SPI block device into ra8_fs and mount the volume.
static void imp_build_cookie (void)
 Populate the builder/scratch views + the production compile cookie.
static rabook_import_cfg_t imp_make_cfg (ra8_fs_mount_t *mount)
 Build the import config that injects the production compile adapter.
static ra8_err_t imp_read_cache (ra8_fs_mount_t *mount, const char *path, uint32_t *out_len)
 Read the whole cached .rabook at path into s_imp_readback.
static ra8_err_t imp_walk_book (uint32_t len)
 Validate the cached blob and log its title, chapter count, and the plain-text length of every chapter.
static void imp_run (ra8_fs_mount_t *mount)
 Run the import twice (miss then hit), confirm the cache, read + walk.
void main (void)
 App entry: bring up the SD card, mount, import + cache + read, PASS.

Variables

static const ra8_port_pin_t k_imp_pin_sck = (ra8_port_pin_t)k_ra8_board_pmod2_spi_sck
 Pmod2 SPI pins (J25) – SCI0 Simple-SPI; CS held by GPIO.
static const ra8_port_pin_t k_imp_pin_cipo = (ra8_port_pin_t)k_ra8_board_pmod2_spi_cipo
static const ra8_port_pin_t k_imp_pin_copi = (ra8_port_pin_t)k_ra8_board_pmod2_spi_copi
static const ra8_port_pin_t k_imp_pin_cs = (ra8_port_pin_t)k_ra8_board_pmod2_spi_cs
static const char k_imp_epub_path [] = "BOOK.EPB"
 Root-level 8.3 source name the appliance imports.
static uint8_t s_imp_scratch [k_imp_scratch_cap]
 Streaming CRC chunk for the source-key pass.
static uint8_t s_imp_cache_frames [k_imp_cache_frames *k_imp_cache_frame_bytes]
 Fixed frame pool the streamed source is paged through (#230).
static ra8_vmem_frame_t s_imp_cache_meta [k_imp_cache_frames]
 Per-frame metadata for the source page cache.
static ra8_vmem_key_t s_imp_cache_keys [k_imp_cache_frames]
 Per-frame key storage for the source page cache.
static int32_t s_imp_cache_buckets [k_imp_cache_buckets]
 Hash-bucket heads for the source page cache.
static ra8_vmem_t s_imp_cache
 Source page cache; re-initialised by the adapter per compile.
static epub_book_t s_imp_epub
 Open-book storage owned across the compile.
static book_chapter_t s_imp_chapters [k_imp_chapter_cap]
 RABOOK1 builder arenas (one per table + the two pools + output).
static book_node_t s_imp_nodes [k_imp_node_cap]
static book_attr_t s_imp_attrs [k_imp_attr_cap]
static book_stylesheet_t s_imp_styles [k_imp_style_cap]
static book_image_t s_imp_images [k_imp_image_cap]
static char s_imp_strpool [k_imp_string_cap]
static uint8_t s_imp_imgpool [k_imp_imgpool_cap]
static uint8_t s_imp_out [k_imp_out_cap]
static uint8_t s_imp_xhtml [k_imp_xhtml_cap]
 Pipeline scratch (XHTML load + stylesheet load + image decode + gray downscale).
static ra8_rabook_xml_workspace_t s_imp_xml_workspace
static uint8_t s_imp_image_raw [k_imp_imgraw_cap]
static uint8_t s_imp_img_scratch [k_imp_arena_cap]
static uint8_t s_imp_gray [k_imp_gray_cap]
static char s_imp_css [k_imp_css_cap]
static uint8_t s_imp_readback [k_imp_readback_cap]
 Cached-.rabook read-back buffer (4-byte aligned for the accessors).
static const uint8_t k_msg_boot [] = "import_reader: boot\r\n"
static const uint8_t k_msg_card_ok [] = "import_reader: card ready\r\n"
static const uint8_t k_msg_mounted [] = "import_reader: volume mounted\r\n"
static const uint8_t k_msg_miss [] = "import_reader: first open MISS -> compiled, cache="
static const uint8_t k_msg_hit [] = "import_reader: second open HIT (no recompile), cache="
static const uint8_t k_msg_cbytes [] = "import_reader: cache bytes="
static const uint8_t k_msg_title [] = "import_reader: title="
static const uint8_t k_msg_chaps [] = " chapters="
static const uint8_t k_msg_ch [] = "import_reader: ch"
static const uint8_t k_msg_textlen [] = " textlen="
static const uint8_t k_msg_eol [] = "\r\n"
static const uint8_t k_msg_pass [] = "import_reader: miss->compile->cache->hit->read PASS\r\n"
static const uint8_t k_msg_fail [] = "import_reader: FAIL "
static ra8_rabook_buffers_t s_imp_bufs
 Builder arenas, pipeline scratch, stb arena, and the compiler cookie.
static ra8_rabook_pipeline_scratch_t s_imp_scr
static ra8_img_arena_t s_imp_arena
static rabook_import_compiler_ctx_t s_imp_cookie

Detailed Description

End-to-end on-import EPUB -> .rabook compile + cache + read (#151).

Tag
[Ring 6 / APP] {World: S}

The on-silicon proof of the self-contained-appliance flow specified in issue #151: drop a raw .epub on the SD card and the device "just works." This app mounts a FAT volume on a micro-SD over ra8_sdmmc_spi, then drives the rabook_import cache manager wired to its PRODUCTION compile adapter (rabook_import_compile_adapter, which STREAMS the source through a bounded ra8_vmem page cache – no whole-file load buffer, #230 – into rabook_compile_from_epub):

  1. First open of BOOK.EPB is a cache MISS -> the importer streams the source through CRC-32 to stamp its freshness, compiles the EPUB into the flat RABOOK1 body, and writes it crash-safely (temp + rename) to the cache named after the source, BOOK.rabook, plus a freshness marker BOOK.rabook.mrk. The outcome reads back compiled.
  2. The app confirms the cache file now exists on the card (the .rabook appeared).
  3. A second open of the SAME source is a cache HIT -> the freshness marker matches, so the importer returns the cached path WITHOUT recompiling (outcome hit, the compiler seam is never invoked).
  4. The reader then reads the cached .rabook back off the card and walks it: book_validate accepts the bare (uncompressed) blob, and the app logs the book title, chapter count, and each chapter's plain-text length.

On success it prints exactly import_reader: miss->compile->cache->hit->read PASS; any failed step prints import_reader: FAIL <stage> and parks the core. The ra8_emulator headless gate (and a future HIL runner) scrape for that PASS line.

Note
The cache lives in the FAT root, named after the source (BOOK.rabook for BOOK.EPB) now that ra8_fs writes VFAT long names (#600/#633). A dedicated /RABOOK/ subdirectory layout is a possible future increment – do not attempt it here.
The compile working arenas live in external SDRAM (the issue's conversion-arena tenant of #147); they are sized for a small text book. A worst-case (image-heavy) book needs the larger ~24-32 MiB budget the issue specifies, also carved from SDRAM.

Required external hardware (on-bench): Digilent PMOD MicroSD (part 410-380) in Pmod2 (J25) with a microSD card carrying a BOOK.EPB text EPUB. Under ra8_emulator attach an image with --sd <image> (build one with tools/mkfontimg <book.epub> card.img BOOK.EPB).

Since
0.1.0

Definition in file main.c.

Macro Definition Documentation

◆ IMP_PUTS

#define IMP_PUTS ( lit)
Value:
imp_print((lit), (uint32_t)sizeof(lit) - 1U)
static void imp_print(const uint8_t *msg, uint32_t len)
Write a byte run on the J-Link OB console.
Definition main.c:219

Emit a NUL-terminated literal (length via sizeof at the call site).

Definition at line 225 of file main.c.

Referenced by imp_init_card_or_halt(), imp_mount_or_halt(), imp_panic(), imp_run(), imp_walk_book(), and main().

Enumeration Type Documentation

◆ imp_buf_cap_t

enum imp_buf_cap_t : uint32_t

SDRAM working-arena capacities (sized for a small text book).

Enumerator
k_imp_cache_frame_bytes 

Source page-cache frame size (bytes).

k_imp_cache_frames 

Fixed frame budget: 64 x 4 KiB = 256 KiB.

k_imp_cache_buckets 

Page-cache hash buckets (~2x frames).

k_imp_chapter_cap 

Max chapters.

k_imp_node_cap 

Max DOM nodes.

k_imp_attr_cap 

Max attribute records.

k_imp_style_cap 

Max stylesheets.

k_imp_image_cap 

Max image descriptors.

k_imp_string_cap 

String-pool capacity (bytes).

k_imp_imgpool_cap 

Image-pool capacity (bytes).

k_imp_out_cap 

Output-blob capacity (bytes).

k_imp_xhtml_cap 

Chapter XHTML scratch (bytes).

k_imp_css_cap 

Stylesheet load scratch (bytes).

k_imp_imgraw_cap 

Raw cover/image scratch (bytes).

k_imp_arena_cap 

stb_image bump arena (bytes).

k_imp_gray_cap 

Gray downscale scratch (pixels).

k_imp_readback_cap 

Cached-.rabook read buffer.

Definition at line 99 of file main.c.

◆ imp_config_t

enum imp_config_t : uint32_t

Compile-time settings for the on-import compile + cache + read demo.

Enumerator
k_imp_uart_baud 

J-Link OB CDC console baud.

k_imp_spi_channel 

Pmod2 / J25 SCI0 Simple-SPI.

k_imp_format_version 

RABOOK1 on-disk format stamp.

k_imp_importer_version 

Importer/compiler version stamp.

k_imp_scratch_cap 

Source-CRC streaming chunk (bytes).

k_imp_path_cap 

Cache-path buffer (holds "BOOK.rabook").

k_imp_dec_base 

Radix for integer-to-ASCII.

k_imp_str_max 

Bound on a logged C-string (Rule 2).

Definition at line 84 of file main.c.

Function Documentation

◆ imp_build_cookie()

void imp_build_cookie ( void )
static

Populate the builder/scratch views + the production compile cookie.

Binds every caller-owned SDRAM arena into the views the real compiler needs and the cookie the import adapter forwards – including the fixed source page-cache storage the adapter streams the .epub through (#230). No buffer is aliased: image_raw is distinct from the img_arena / gray source the transcode stage reads (a contract

Warning
of the scratch struct).
Returns
Nothing.
Precondition
The file-scope SDRAM arenas are defined (always true at TU scope).
This is called once before the first import.
Postcondition
s_imp_bufs, s_imp_scr, s_imp_arena and s_imp_cookie reference the static SDRAM storage.
No state beyond those four file-scope views is mutated.
Note
Not thread-safe; single-owner views over shared file-scope arenas.
Since
0.1.0

Definition at line 417 of file main.c.

References k_imp_attr_cap, k_imp_cache_buckets, k_imp_cache_frame_bytes, k_imp_cache_frames, k_imp_chapter_cap, k_imp_gray_cap, k_imp_image_cap, k_imp_imgpool_cap, k_imp_node_cap, k_imp_out_cap, k_imp_string_cap, k_imp_style_cap, s_imp_arena, s_imp_attrs, s_imp_bufs, s_imp_cache, s_imp_cache_buckets, s_imp_cache_frames, s_imp_cache_keys, s_imp_cache_meta, s_imp_chapters, s_imp_cookie, s_imp_css, s_imp_epub, s_imp_gray, s_imp_image_raw, s_imp_images, s_imp_img_scratch, s_imp_imgpool, s_imp_nodes, s_imp_out, s_imp_scr, s_imp_strpool, s_imp_styles, s_imp_xhtml, and s_imp_xml_workspace.

Referenced by main().

◆ imp_init_card_or_halt()

void imp_init_card_or_halt ( uint32_t pclka_hz)
static

Build the SCI-SPI transport, run SD identification; panic on failure.

Parameters
[in]pclka_hzLive PCLKA rate (Hz) feeding the SCI baud divider.
Returns
Nothing (panic-halts on failure).
Precondition
ra8_cgc_init has run and the console SCI is up.
pclka_hz is the live PCLKA rate.
Postcondition
On success the SD card is in SPI mode and card ready is printed.
On failure a diagnostic is printed and the CPU is parked.
Note
Not thread-safe; call once after the clocks + console are up.
Since
0.1.0

Definition at line 346 of file main.c.

References imp_panic(), IMP_PUTS, k_imp_pin_cipo, k_imp_pin_copi, k_imp_pin_cs, k_imp_pin_sck, k_imp_spi_channel, k_msg_card_ok, k_ra8_ok, ra8_sdmmc_spi_init(), and ra8_sdmmc_spi_transport_sci().

Referenced by main().

◆ imp_make_cfg()

rabook_import_cfg_t imp_make_cfg ( ra8_fs_mount_t * mount)
static

Build the import config that injects the production compile adapter.

Parameters
[in]mountMounted volume holding the source and the cache.
Returns
A fully-populated config (compile seam = the production adapter).
Precondition
mount is a live mount.
imp_build_cookie has populated s_imp_cookie.
Postcondition
The returned config's compile is the real compiler adapter and its version stamps gate cache reuse for this firmware build.
No global state is mutated.
Note
Not thread-safe; single-threaded init path only.
Since
0.1.0

Definition at line 477 of file main.c.

References rabook_import_cfg_t::compile, rabook_import_cfg_t::compile_ctx, rabook_import_cfg_t::format_version, rabook_import_cfg_t::importer_version, k_imp_format_version, k_imp_importer_version, k_imp_scratch_cap, rabook_import_cfg_t::mount, rabook_import_compile_adapter(), s_imp_cookie, s_imp_scratch, rabook_import_cfg_t::scratch, and rabook_import_cfg_t::scratch_cap.

Referenced by imp_run().

◆ imp_mount_or_halt()

void imp_mount_or_halt ( ra8_fs_mount_t ** out_mount)
static

Bind the SD-over-SPI block device into ra8_fs and mount the volume.

Parameters
[out]out_mountReceives the mounted-volume handle on success.
Returns
Nothing (panic-halts on failure).
Precondition
The SD card is initialised (ra8_sdmmc_spi_init succeeded).
out_mount is writable.
Postcondition
On success *out_mount is a live mount of the card's existing FAT volume (the card is NOT reformatted – the source .epub is preserved).
On failure a diagnostic is printed and the CPU is parked.
Note
Not thread-safe; single-threaded init path only.
Since
0.1.0

Definition at line 377 of file main.c.

References imp_panic(), IMP_PUTS, k_msg_mounted, k_ra8_ok, ra8_fs_mount(), and ra8_sdmmc_spi_bind_fs_backend().

Referenced by main().

◆ imp_panic()

void imp_panic ( const char * stage)
static

Print the FAIL banner with a stage tag, then trap and park.

Parameters
[in]stageNUL-terminated stage label (non-NULL).
Returns
Never returns.
Precondition
The console is initialised.
stage is NUL-terminated.
Postcondition
The FAIL line is queued; the CPU traps then spins in WFI.
No further application code runs.
Note
Not thread-safe; terminal panic path. ra8_emulator halts on the BKPT.
Since
0.1.0

Definition at line 285 of file main.c.

References imp_print(), imp_print_cstr(), IMP_PUTS, k_msg_eol, k_msg_fail, and ra8_board_uart_console_flush().

Referenced by imp_init_card_or_halt(), imp_mount_or_halt(), imp_run(), and imp_setup_or_halt().

◆ imp_print()

void imp_print ( const uint8_t * msg,
uint32_t len )
static

Write a byte run on the J-Link OB console.

Parameters
[in]msgBytes to emit (non-NULL, length len).
[in]lenByte count to emit.
Precondition
The BSP console is initialised.
msg points to at least len readable bytes.
Postcondition
The bytes are queued to the console.
No other state is modified.
Note
Not thread-safe; single-threaded app context.
Since
0.1.0

Definition at line 219 of file main.c.

References ra8_board_uart_console_write().

Referenced by imp_panic(), imp_print_cstr(), imp_print_uint(), imp_run(), and imp_walk_book().

◆ imp_print_cstr()

void imp_print_cstr ( const char * str)
static

Emit a NUL-terminated C-string, bounded to k_imp_str_max bytes.

Parameters
[in]strNUL-terminated string to emit (non-NULL).
Precondition
The console is initialised.
str is NUL-terminated.
Postcondition
At most k_imp_str_max bytes are queued to the console.
No other state is modified.
Note
Not thread-safe; single-threaded app context.
Since
0.1.0

Definition at line 237 of file main.c.

References imp_print(), and k_imp_str_max.

Referenced by imp_panic(), imp_run(), and imp_walk_book().

◆ imp_print_uint()

void imp_print_uint ( uint32_t value)
static

Print a small unsigned integer in decimal.

Parameters
[in]valueValue to print (0 .. UINT32_MAX).
Precondition
The console is initialised.
value fits a uint32_t (always true).
Postcondition
The decimal digits are queued to the console.
No other state is modified.
Note
Not thread-safe; single-threaded app context.
Since
0.1.0

Definition at line 256 of file main.c.

References imp_print(), and k_imp_dec_base.

Referenced by imp_run(), and imp_walk_book().

◆ imp_read_cache()

ra8_err_t imp_read_cache ( ra8_fs_mount_t * mount,
const char * path,
uint32_t * out_len )
staticnodiscard

Read the whole cached .rabook at path into s_imp_readback.

Parameters
[in]mountMounted volume.
[in]pathRoot-level cache path (non-NULL).
[out]out_lenReceives the byte length read.
Returns
Error code (first failing ra8_fs step's code, or k_ra8_ok).
Return values
k_ra8_okThe cache was read fully into the buffer.
k_ra8_err_no_memThe cache is larger than the read-back buffer.
k_ra8_err_*An ra8_fs open/size/read failure.
Precondition
mount is mounted and path names a present cache file.
out_len is writable.
Postcondition
On k_ra8_ok, s_imp_readback[0..*out_len) holds the bare RABOOK1 blob.
The ra8_fs file handle is closed on every return path.
Note
Not thread-safe; single-threaded app context.
Since
0.1.0

Definition at line 512 of file main.c.

References k_ra8_err_no_mem, k_ra8_fs_mode_read, k_ra8_ok, ra8_fs_close(), ra8_fs_open(), ra8_fs_read(), ra8_fs_size(), and s_imp_readback.

Referenced by imp_run().

◆ imp_run()

void imp_run ( ra8_fs_mount_t * mount)
static

Run the import twice (miss then hit), confirm the cache, read + walk.

Parameters
[in]mountMounted volume carrying the source .epub.
Returns
Nothing (panic-halts on any failed stage).
Precondition
mount is mounted and carries k_imp_epub_path.
imp_build_cookie and the SD bring-up have completed.
Postcondition
On success the PASS banner is printed; on failure the CPU is parked.
The source .epub is never modified; the cache .rabook is present.
Note
Not thread-safe; single-threaded app context.
Since
0.1.0

Definition at line 598 of file main.c.

References imp_make_cfg(), imp_panic(), imp_print(), imp_print_cstr(), imp_print_uint(), IMP_PUTS, imp_read_cache(), imp_walk_book(), k_imp_epub_path, k_imp_path_cap, k_msg_cbytes, k_msg_eol, k_msg_hit, k_msg_miss, k_ra8_ok, k_rabook_import_compiled, k_rabook_import_hit, and rabook_import_open().

Referenced by main().

◆ imp_setup_or_halt()

void imp_setup_or_halt ( uint32_t * out_pclka_hz)
static

Bring up CGC + SysTick + console SCI; panic on failure.

Parameters
[out]out_pclka_hzCached PCLKA rate (Hz) for the SD transport factory.
Returns
Nothing (panic-halts on failure).
Precondition
Reset_Handler initialised .data/.bss.
out_pclka_hz is writable.
Postcondition
On success the console prints and *out_pclka_hz holds the PCLKA rate.
On any failure the CPU is parked after a FAIL diagnostic.
Note
Not thread-safe; call once from the single-threaded init path.
Since
0.1.0

Definition at line 313 of file main.c.

References imp_panic(), k_imp_uart_baud, k_ra8_clock_id_cpuclk0, k_ra8_clock_id_pclka, k_ra8_ok, ra8_board_uart_console_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), and ra8_time_init().

Referenced by main().

◆ imp_walk_book()

ra8_err_t imp_walk_book ( uint32_t len)
staticnodiscard

Validate the cached blob and log its title, chapter count, and the plain-text length of every chapter.

Parameters
[in]lenByte length of the blob in s_imp_readback.
Returns
Error code.
Return values
k_ra8_okBlob validated and walked.
k_ra8_err_*book_validate / per-chapter walk error.
Precondition
s_imp_readback[0..len) was filled by imp_read_cache.
len is the true readable length.
Postcondition
On k_ra8_ok the book's title + chapter summary are logged.
The immutable blob is never modified.
Note
Not thread-safe; single-threaded app context.
Since
0.1.0

Definition at line 553 of file main.c.

References book_chapter_text(), book_header(), book_string(), book_validate(), book_header_t::chapter_count, imp_print(), imp_print_cstr(), imp_print_uint(), IMP_PUTS, k_msg_ch, k_msg_chaps, k_msg_eol, k_msg_textlen, k_msg_title, k_ra8_ok, s_imp_readback, s_imp_xhtml, and book_header_t::title_off.

Referenced by imp_run().

◆ main()

void main ( void )

App entry: bring up the SD card, mount, import + cache + read, PASS.

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler has copied .data and zeroed .bss.
SystemInit has set VTOR, FPU, and priority grouping.
Postcondition
On a clean run the PASS banner is printed and the CPU loops in WFI.
On any failure the function prints a FAIL line and halts.
Note
Not thread-safe; single-threaded app entry.
Since
0.1.0

Definition at line 659 of file main.c.

References imp_build_cookie(), imp_init_card_or_halt(), imp_mount_or_halt(), IMP_PUTS, imp_run(), imp_setup_or_halt(), k_msg_boot, k_msg_pass, ra8_board_uart_console_flush(), ra8_isr_globals_enable(), and ra8_log_init().

Variable Documentation

◆ k_imp_epub_path

const char k_imp_epub_path[] = "BOOK.EPB"
static

Root-level 8.3 source name the appliance imports.

Definition at line 131 of file main.c.

Referenced by imp_run().

◆ k_imp_pin_cipo

Definition at line 126 of file main.c.

Referenced by imp_init_card_or_halt().

◆ k_imp_pin_copi

Definition at line 127 of file main.c.

Referenced by imp_init_card_or_halt().

◆ k_imp_pin_cs

Definition at line 128 of file main.c.

Referenced by imp_init_card_or_halt().

◆ k_imp_pin_sck

Pmod2 SPI pins (J25) – SCI0 Simple-SPI; CS held by GPIO.

Definition at line 125 of file main.c.

Referenced by imp_init_card_or_halt().

◆ k_msg_boot

const uint8_t k_msg_boot[] = "import_reader: boot\r\n"
static

Definition at line 189 of file main.c.

◆ k_msg_card_ok

const uint8_t k_msg_card_ok[] = "import_reader: card ready\r\n"
static

◆ k_msg_cbytes

const uint8_t k_msg_cbytes[] = "import_reader: cache bytes="
static

Definition at line 194 of file main.c.

Referenced by imp_run().

◆ k_msg_ch

const uint8_t k_msg_ch[] = "import_reader: ch"
static

Definition at line 197 of file main.c.

Referenced by erb_render_chapter(), and imp_walk_book().

◆ k_msg_chaps

const uint8_t k_msg_chaps[] = " chapters="
static

Definition at line 196 of file main.c.

Referenced by imp_walk_book().

◆ k_msg_eol

const uint8_t k_msg_eol[] = "\r\n"
static

Definition at line 199 of file main.c.

◆ k_msg_fail

const uint8_t k_msg_fail[] = "import_reader: FAIL "
static

Definition at line 201 of file main.c.

◆ k_msg_hit

const uint8_t k_msg_hit[] = "import_reader: second open HIT (no recompile), cache="
static

Definition at line 193 of file main.c.

◆ k_msg_miss

const uint8_t k_msg_miss[] = "import_reader: first open MISS -> compiled, cache="
static

Definition at line 192 of file main.c.

◆ k_msg_mounted

const uint8_t k_msg_mounted[] = "import_reader: volume mounted\r\n"
static

Definition at line 191 of file main.c.

Referenced by imp_mount_or_halt().

◆ k_msg_pass

const uint8_t k_msg_pass[] = "import_reader: miss->compile->cache->hit->read PASS\r\n"
static

Definition at line 200 of file main.c.

Referenced by main().

◆ k_msg_textlen

const uint8_t k_msg_textlen[] = " textlen="
static

Definition at line 198 of file main.c.

Referenced by imp_walk_book().

◆ k_msg_title

const uint8_t k_msg_title[] = "import_reader: title="
static

Definition at line 195 of file main.c.

Referenced by imp_walk_book().

◆ s_imp_arena

ra8_img_arena_t s_imp_arena
static

Definition at line 397 of file main.c.

Referenced by imp_build_cookie().

◆ s_imp_attrs

book_attr_t s_imp_attrs[k_imp_attr_cap]
static

Definition at line 164 of file main.c.

Referenced by imp_build_cookie().

◆ s_imp_bufs

ra8_rabook_buffers_t s_imp_bufs
static

Builder arenas, pipeline scratch, stb arena, and the compiler cookie.

Definition at line 395 of file main.c.

Referenced by imp_build_cookie().

◆ s_imp_cache

ra8_vmem_t s_imp_cache
static

Source page cache; re-initialised by the adapter per compile.

Definition at line 155 of file main.c.

Referenced by imp_build_cookie().

◆ s_imp_cache_buckets

int32_t s_imp_cache_buckets[k_imp_cache_buckets]
static

Hash-bucket heads for the source page cache.

Definition at line 152 of file main.c.

Referenced by imp_build_cookie().

◆ s_imp_cache_frames

uint8_t s_imp_cache_frames[k_imp_cache_frames *k_imp_cache_frame_bytes]
static

Fixed frame pool the streamed source is paged through (#230).

Definition at line 143 of file main.c.

Referenced by imp_build_cookie().

◆ s_imp_cache_keys

ra8_vmem_key_t s_imp_cache_keys[k_imp_cache_frames]
static

Per-frame key storage for the source page cache.

Definition at line 149 of file main.c.

Referenced by imp_build_cookie().

◆ s_imp_cache_meta

ra8_vmem_frame_t s_imp_cache_meta[k_imp_cache_frames]
static

Per-frame metadata for the source page cache.

Definition at line 146 of file main.c.

Referenced by imp_build_cookie().

◆ s_imp_chapters

book_chapter_t s_imp_chapters[k_imp_chapter_cap]
static

RABOOK1 builder arenas (one per table + the two pools + output).

Definition at line 162 of file main.c.

Referenced by imp_build_cookie().

◆ s_imp_cookie

rabook_import_compiler_ctx_t s_imp_cookie
static

Definition at line 398 of file main.c.

Referenced by imp_build_cookie(), and imp_make_cfg().

◆ s_imp_css

char s_imp_css[k_imp_css_cap]
static

Definition at line 179 of file main.c.

Referenced by imp_build_cookie().

◆ s_imp_epub

epub_book_t s_imp_epub
static

Open-book storage owned across the compile.

Definition at line 158 of file main.c.

Referenced by imp_build_cookie().

◆ s_imp_gray

uint8_t s_imp_gray[k_imp_gray_cap]
static

Definition at line 178 of file main.c.

Referenced by imp_build_cookie().

◆ s_imp_image_raw

uint8_t s_imp_image_raw[k_imp_imgraw_cap]
static

Definition at line 176 of file main.c.

Referenced by imp_build_cookie().

◆ s_imp_images

book_image_t s_imp_images[k_imp_image_cap]
static

Definition at line 167 of file main.c.

Referenced by imp_build_cookie().

◆ s_imp_img_scratch

uint8_t s_imp_img_scratch[k_imp_arena_cap]
static

Definition at line 177 of file main.c.

Referenced by imp_build_cookie().

◆ s_imp_imgpool

uint8_t s_imp_imgpool[k_imp_imgpool_cap]
static

Definition at line 169 of file main.c.

Referenced by imp_build_cookie().

◆ s_imp_nodes

book_node_t s_imp_nodes[k_imp_node_cap]
static

Definition at line 163 of file main.c.

Referenced by imp_build_cookie().

◆ s_imp_out

uint8_t s_imp_out[k_imp_out_cap]
static

Definition at line 170 of file main.c.

Referenced by imp_build_cookie().

◆ s_imp_readback

uint8_t s_imp_readback[k_imp_readback_cap]
static

Cached-.rabook read-back buffer (4-byte aligned for the accessors).

Definition at line 182 of file main.c.

Referenced by imp_read_cache(), and imp_walk_book().

◆ s_imp_scr

Definition at line 396 of file main.c.

Referenced by imp_build_cookie().

◆ s_imp_scratch

uint8_t s_imp_scratch[k_imp_scratch_cap]
static

Streaming CRC chunk for the source-key pass.

Definition at line 139 of file main.c.

Referenced by imp_make_cfg().

◆ s_imp_strpool

char s_imp_strpool[k_imp_string_cap]
static

Definition at line 168 of file main.c.

Referenced by imp_build_cookie().

◆ s_imp_styles

book_stylesheet_t s_imp_styles[k_imp_style_cap]
static

Definition at line 166 of file main.c.

Referenced by imp_build_cookie().

◆ s_imp_xhtml

uint8_t s_imp_xhtml[k_imp_xhtml_cap]
static

Pipeline scratch (XHTML load + stylesheet load + image decode + gray downscale).

Definition at line 173 of file main.c.

Referenced by imp_build_cookie(), and imp_walk_book().

◆ s_imp_xml_workspace

ra8_rabook_xml_workspace_t s_imp_xml_workspace
static

Definition at line 175 of file main.c.

Referenced by imp_build_cookie().