68#include "rabook_fixture.h"
87 "published fb_format must equal ra8_gfx RGB565");
92 "framebuffer byte size must equal width*height*bpp");
113typedef enum : uint32_t {
125typedef enum : uint16_t {
140typedef enum : uint32_t {
154typedef enum : uint32_t {
164typedef enum : uint8_t {
176typedef enum : uint8_t {
188typedef enum : uint32_t {
214static void append_run(
char* out, uint32_t* plen, uint32_t cap,
const char* txt)
216 if (out ==
nullptr) {
219 if (plen ==
nullptr) {
222 if (txt ==
nullptr) {
227 const char c = txt[i];
311 if (base ==
nullptr) {
314 if (out ==
nullptr) {
328 if ((st.
sp == 0U) || (len >= cap)) {
331 const uint32_t n = st.
items[--st.
sp];
332 if (n >= node_count) {
370static bool render_page(uint8_t* fb,
const char* text, uint32_t len)
375 if (text ==
nullptr) {
397 line[cols] = text[idx];
439static uint32_t
fb_crc32(
const uint8_t* fb, uint32_t len)
449 for (uint32_t i = 0U; i < len; i++) {
453 crc ^= (uint32_t)fb[i];
456 const uint32_t mask = (uint32_t)(0U - (crc & 1U));
496 __asm
volatile(
"dsb" :::
"memory");
524 if (base ==
nullptr) {
531 static const char expect[] = {
'R',
'A',
'B',
'O',
'O',
'K',
'1'};
533 for (uint32_t i = 0U; i < (uint32_t)
k_magic_len; i++) {
534 if (hdr->
magic[i] != expect[i]) {
581 if (base ==
nullptr) {
584 if (out_crc ==
nullptr) {
587 if (out_glyphs ==
nullptr) {
594 chapters[0].root_node,
601 __asm
volatile(
"dsb" :::
"memory");
603 *out_glyphs = glyphs;
652 volatile uint32_t spin = 0U;
725 if (base ==
nullptr) {
732 __asm
volatile(
"dsb" :::
"memory");
738 uint32_t glyphs = 0U;
743 __asm
volatile(
"dsb" :::
"memory");
764 __asm
volatile(
"nop");
789 __asm
volatile(
"dsb" :::
"memory");
791 __asm
volatile(
"dsb" :::
"memory");
822 __asm
volatile(
"dsb" :::
"memory");
830 uint32_t glyphs = 0U;
837 __asm
volatile(
"dsb" :::
"memory");
839 __asm
volatile(
"dsb" :::
"memory");
908 __asm
volatile(
"nop");
922#ifndef RA8_OFF_TARGET
Flat, execute-in-place container for a build-time "compiled" e-book.
@ k_book_sizeof_header
Bytes in book_header_t.
@ k_book_node_text
A text run: carries a string, no children.
@ k_book_format_version
Current .rabook layout revision.
@ k_book_nil
Absent index / "applies to all chapters".
static const book_chapter_t * book_chapters(const void *base)
Base of the chapter table.
static const book_header_t * book_header(const void *base)
View the blob base as its header.
static const book_node_t * book_nodes(const void *base)
Base of the DOM node table.
static const char * book_node_text(const void *base, const book_node_t *node)
Text of a text node.
Shared contract for the "render a held e-reader page on the M33" demo.
@ k_erm33_page_chars
Characters the held page can carry.
@ k_erm33_status_bad_book
status: baked book failed validation.
@ k_erm33_status_ok
status: page rendered + published.
@ k_erm33_fb_format_rgb565
Published fb_format (RGB565).
@ k_erm33_status_render_fail
status: ra8_gfx render path failed.
@ k_erm33_m33_sig
"RDR3" boot sentinel written by M33.
@ k_erm33_fb_stride
Bytes per pixel row (width * bpp).
@ k_erm33_fb_bpp
Bytes per pixel (RGB565).
@ k_erm33_fb_bytes
Total plane size in bytes (stride * height).
@ k_erm33_fb_cols
Glyph columns (width / 8-px glyph).
@ k_erm33_fb_rows
Glyph rows (height / 16-px glyph).
@ k_erm33_fb_height
Plane height in pixels (4 glyph rows of 16).
@ k_erm33_fb_width
Plane width in pixels.
@ k_erm33_touch_dwell
M33 hold-loop spins per simulated touch wait.
@ k_erm33_max_turns
Page-turn handoffs the cycle exercises.
static volatile erm33_mailbox_t * erm33_mailbox(void)
Typed pointer to the fixed-address shared progress mailbox.
static uint16_t s_framebuffer[(size_t) k_panel_height_px *(size_t) k_panel_width_px]
1024x600 RGB565 framebuffer in external SDRAM (GLCDC scans this).
void cpu1_reset_handler(void)
CPU1 reset handler.
uint32_t g_ra8_ls_cpu1_data_end
uint32_t g_ra8_ls_cpu1_bss_start
uint32_t g_ra8_ls_cpu1_data_load
uint32_t g_ra8_ls_cpu1_bss_end
const uintptr_t g_cpu1_vector_table[]
Minimal Armv8-M vector table for CPU1.
uint32_t g_ra8_ls_cpu1_stack_top
uint32_t g_ra8_ls_cpu1_data_start
static void cpu1_fault_handler(void)
CPU1 default fault handler: park the core.
static void notify_m85(void)
Poke the M85's IPC0 receive line to wake it from WFI.
cpu1_ipc_t
IPC channel the M33 pokes to wake the parked M85.
@ k_cpu1_ipc_wake_channel
IPC0 channel 0 (CPU1 -> CPU0).
static void cpu1_park(void)
Park the M33 forever once the emitter has reported its result.
static const uint8_t k_rabook_fixture[k_rabook_fixture_len]
The baked, inflated .rabook flat blob (validate + walk directly).
@ k_rabook_fixture_len
Inflated flat-blob length.
static void publish_page(volatile erm33_mailbox_t *mb, uint32_t crc, uint32_t glyphs)
Publish the rendered page's base, geometry, format and CRC.
static void walk_push(m33_walk_stack_t *st, uint32_t node)
Push a node index onto the DOM-walk stack if it fits.
m33_crc_t
Constants for the standard reflected CRC-32 over the rendered plane.
@ k_crc32_poly
Reflected CRC-32 polynomial.
@ k_crc32_init
Pre/post-inversion seed.
static bool wait_for_ack(volatile const erm33_mailbox_t *mb, uint32_t turn)
Poll the mailbox until the M85 acks page turn turn (heavy work done).
m33_cycle_bound_t
Static bound for the M33's wait-for-ack poll (NASA Rule 2).
@ k_m33_ack_budget
Max iters waiting for the M85's turn_ack.
static bool render_page(uint8_t *fb, const char *text, uint32_t len)
Render the collected page text into the SDRAM framebuffer via ra8_gfx.
static uint32_t fb_crc32(const uint8_t *fb, uint32_t len)
Fold a reflected CRC-32 over the rendered framebuffer pixels.
m33_walk_bound_t
Static iteration bounds for the M33 DOM walk (NASA Rule 2).
@ k_walk_iter_max
Max DOM-walk pops in the chapter.
@ k_max_run_len
Bounded text-run length cap, bytes.
m33_walk_size_t
Small table / validation sizes for the M33 reader.
@ k_max_nodes
Validation cap on node_count.
@ k_max_chapters
Validation cap on chapter_count.
@ k_magic_len
"RABOOK1" magic length (no NUL).
@ k_walk_stack_depth
Explicit DOM-walk stack depth.
static void simulate_touch_dwell(void)
Spin a bounded page-dwell that stands in for a touch-poll latency.
static bool book_is_valid(const void *base, uint32_t size)
Validate the baked RABOOK1 flat blob before walking it.
m33_render_t
Glyph cell height and page colours for the ra8_gfx blit.
@ k_erm33_glyph_h
ra8_gfx 8x16 font cell height, pixels.
@ k_erm33_paper
Page background colour (white).
@ k_erm33_ink
Glyph foreground colour (black).
static bool render_held_page(const void *base, uint32_t *out_crc, uint32_t *out_glyphs)
Re-render the held page from the validated book and fold its CRC.
m33_crc_bits_t
Bit-fold count for the bitwise CRC-32 inner loop.
@ k_crc32_bits
Bits folded per input byte.
static uint32_t collect_chapter_text(const void *base, uint32_t root, uint32_t node_count, char *out, uint32_t cap)
Collect a chapter's opening text into the page accumulator.
static void append_run(char *out, uint32_t *plen, uint32_t cap, const char *txt)
Append one NUL-terminated text run into the page accumulator.
static void cpu1_run_reader(void)
CPU1 reader entry: validate the book, render the held page, publish.
static void run_page_turns(volatile erm33_mailbox_t *mb, const void *base)
Hold the page and run the #150 page-turn handoff loop for the M85.
static void cpu1_fail(volatile erm33_mailbox_t *mb, uint32_t status)
Mark a failure status, publish done, and park the M33.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_LOOP_BOUND(ceiling)
NASA Power-of-10 Rule 2: bind ONE loop to a compile-time ceiling.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
Software 2D graphics primitives layered on top of a caller-ownedframebuffer (DRW / D/AVE 2D / GLCDC r...
@ k_ra8_gfx_format_rgb565
16-bit RGB565, little-endian in memory.
ra8_err_t ra8_gfx_clear(uint32_t color)
Fill the bound framebuffer's clip region with a single colour.
ra8_err_t ra8_gfx_text_out(int32_t x, int32_t y, const char *str, const ra8_gfx_font_t *font, uint32_t fg_color, uint32_t bg_color)
Render a NUL-terminated ASCII string.
ra8_err_t ra8_gfx_init(void *fb, uint16_t width, uint16_t height, ra8_gfx_format_t format)
Bind ra8_gfx to a caller-owned framebuffer.
const ra8_gfx_font_t ra8_gfx_font_8x16
Bundled 8x16 IBM PC VGA bitmap font, ASCII 0x20..0x7E.
Inter-Processor Communication (IPC) HAL driver – public API.
@ k_ra8_ipc_irq_event_0
RA8 ipc IRQ event 0.
ra8_err_t ra8_ipc_send_event(uint8_t channel, ra8_ipc_irq_event_id_t event_id)
Generate a maskable IRQ event on the peer core.
One spine document (a renderable chapter) plus its TOC label.
uint8_t kind
book_node_kind_t.
uint32_t next_sibling
Index of next sibling node, or nil.
uint32_t first_child
Index of first child node, or nil.
Cross-core progress block backed by a fixed shared-SRAM address.
volatile uint32_t turn_done
M33->M85: re-render published for that turn.
volatile uint32_t fb_base
M33-published SDRAM framebuffer base address.
volatile uint32_t done
Set to 1 by the M33 once the page is published.
volatile uint32_t fb_crc
M33-folded CRC-32 over the rendered pixels.
volatile uint32_t turn_ack
M85->M33: heavy-work ack for the matching turn.
volatile uint32_t fb_format
M33-published ra8_gfx_format_t (RGB565).
volatile uint32_t turn_req
M33->M85: page-turn request, bumped per touch.
volatile uint32_t glyph_count
Characters the M33 laid onto the held page.
volatile uint32_t fb_stride
M33-published framebuffer stride in bytes.
volatile uint32_t m33_sig
M33 stamps k_erm33_m33_sig on boot.
volatile uint32_t status
Render status (erm33_const_t status codes).
volatile uint32_t fb_height
M33-published framebuffer height in pixels.
volatile uint32_t fb_width
M33-published framebuffer width in pixels.
Explicit DOM-walk stack (NASA Rule 1: iteration, never recursion).
uint32_t items[k_walk_stack_depth]
Pending node indices.
uint32_t sp
Count of pending entries.