37#include "font_fixture.h"
48typedef enum : uint32_t {
68 "<html><body><h1>Chapter One</h1>"
69 "<p>Jump to the <a href=\"ch2.xhtml\">next chapter</a> or skip to the "
70 "<a href=\"#foot\">footnote</a> below for the citation.</p>"
71 "<p>Body paragraph with enough words to occupy a couple of lines so the "
72 "layout has real content to paginate around the links.</p>"
73 "<p id=\"foot\">Footnote: this is the cited reference text.</p></body></html>";
75static const uint8_t
k_msg_boot[] =
"ereader-link-hil: boot\r\n";
76static const uint8_t
k_msg_fail[] =
"ereader-link-hil: FAIL init\r\n";
77static const uint8_t
k_msg_lerr[] =
"ereader-link-hil: FAIL layout\r\n";
78static const uint8_t
k_msg_pre[] =
"ereader-link-hil: links=";
88static void lk_print(
const uint8_t* msg, uint32_t len)
97 __asm__
volatile(
"bkpt #0");
99 __asm__
volatile(
"wfi");
125 buf[n] = (uint8_t)(
'0' + (value % (uint32_t)
k_lk_dec_ten));
129 for (uint32_t i = 0U; i < n; i++) {
147 const uint8_t* p = (
const uint8_t*)
s_engine.link_rects;
148 const size_t n = (size_t)
s_engine.link_rect_count *
sizeof(
s_engine.link_rects[0]);
150 for (
size_t i = 0U; i < n; i++) {
167 const int32_t cx = rect->
x + (rect->
w / 2);
168 const int32_t cy = rect->
y + (rect->
h / 2);
193 uint32_t cpuclk0_hz = 0U;
243 for (uint32_t i = 0U; i <
s_engine.link_rect_count; ++i) {
266 __asm__
volatile(
"wfi");
void main(void)
Secure fallback main entry point.
static const uint8_t k_msg_pre[]
static const uint8_t k_msg_boot[]
static const uint8_t k_msg_fail[]
static reflow_t s_engine
Reflow engine (glyph / page / token / text pools live inside).
static const uint8_t k_msg_eol[]
static const uint8_t k_msg_geom[]
static const uint8_t k_msg_lerr[]
static void lk_print(const uint8_t *msg, uint32_t len)
Emit a byte run on the SCI8 console.
static void lk_print_bool(bool yes)
Print "Y" or "N".
static void lk_setup_or_halt(void)
Bring up clocks/MSTP/time + the SCI8 console; halt on failure.
static const uint8_t k_msg_yes[]
static void lk_panic_halt(const uint8_t *msg, uint32_t len)
Print the fail banner and trap (ra8_emulator halts on the BKPT).
static const uint8_t k_msg_no[]
static void lk_print_hex(uint32_t value)
Print a 32-bit value as 8 upper-case hex digits.
static const uint8_t k_msg_cross[]
static void lk_probe_rect(uint32_t idx, bool *out_cross, bool *out_frag)
Classify the href at a link rect's centre via the public nav API.
static uint32_t lk_geom_hash(void)
FNV-1a-32 over the laid-out link-rectangle geometry.
static const uint8_t k_msg_frag[]
lk_consts_t
Viewport / console / hash knobs (no magic numbers).
@ k_lk_link_col
Anchor colour (ARGB).
@ k_lk_view_h
Layout viewport height, pixels.
@ k_lk_font_px
Body font size, pixels.
@ k_lk_nibble_mask
Low-nibble mask.
@ k_lk_dec_ten
Hex digit / decimal split.
@ k_lk_ink
Body ink colour (ARGB).
@ k_lk_hex_nibbles
Hex digits in a 32-bit value.
@ k_lk_fnv_offset
FNV-1a-32 offset basis.
@ k_lk_view_w
Layout viewport width, pixels.
@ k_lk_uart_baud
Console baud.
@ k_lk_nibble_bits
Bits per hex nibble.
@ k_lk_fnv_prime
FNV-1a-32 prime.
static const char k_lk_chapter[]
Baked chapter: two links (cross-chapter + fragment) and an anchor.
static void lk_print_uint(uint32_t value)
Print a small unsigned integer in decimal.
static const uint8_t k_msg_apage[]
static const uint8_t k_ahem_ttf[]
Ahem TTF bytes.
static const uint32_t k_ahem_ttf_len
Length of k_ahem_ttf in bytes.
Board-support layer for the Renesas EK-RA8D2 v1 evaluation kit.
ra8_err_t ra8_board_uart_console_write(const uint8_t *data, size_t len)
Polled blocking write to the J-Link OB VCOM console.
ra8_err_t ra8_board_uart_console_init(uint32_t baud)
Configure SCI8 + PD02/PD03 as the debug-console UART.
Boot entry points shared between a vector table and its startup code.
High-level Clock Generation Circuit driver.
ra8_err_t ra8_cgc_get_clock_hz(ra8_clock_id_t id, uint32_t *out_hz)
Query the current frequency of a clock-tree domain.
@ k_ra8_clock_id_cpuclk0
Cortex-M85 CPUCLK0.
ra8_err_t ra8_cgc_init(void)
Configure the clock tree to a safe default.
Error Code Definitions for ra8-firmware.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
NVIC + ICU IELSR allocator.
void ra8_isr_globals_enable(void)
Globally enable maskable interrupts (PRIMASK = 0).
Ref-counted Module Stop Control wrapper for the RA8D2.
ra8_err_t ra8_mstp_init(void)
Re-establish the ra8_mstp ref-count table from current hardware state.
SysTick-based tick counter, delay and timestamp helpers.
ra8_err_t ra8_time_init(uint32_t cpu_hz)
Initialise SysTick for a 1 kHz tick interrupt.
HTML / CSS reflow + paginate engine for the ra8d2 ereader.
ra8_err_t reflow_hit_test_link(const reflow_t *engine, uint32_t page_idx, int32_t x, int32_t y, uint32_t *out_href_off, uint32_t *out_href_len)
Hit-test a point on a page against the laid-out <a> link rectangles.
ra8_err_t reflow_layout_chapter(reflow_t *engine, const uint8_t *xhtml_buf, size_t xhtml_len, uint32_t *out_total_pages)
Parse + lay out one chapter of XHTML.
ra8_err_t reflow_find_anchor(const reflow_t *engine, const char *id, uint32_t id_len, uint32_t *out_page)
Find the page of a same-chapter id anchor (for #fragment jumps).
ra8_err_t reflow_href_split(const char *href, uint32_t len, reflow_href_kind_t *out_kind, uint32_t *out_path_len, uint32_t *out_frag_off, uint32_t *out_frag_len)
Split + classify an <a href> into a path part and a #fragment.
ra8_err_t reflow_init(uint16_t viewport_w, uint16_t viewport_h, const uint8_t *font_data, size_t font_len, uint16_t font_px, uint32_t body_color, uint32_t link_color, reflow_t *out_engine)
Initialise a reflow engine for a given viewport / font.
reflow_href_kind_t
Classification of an in-content <a href> target.
@ k_reflow_href_fragment
"#id" – same-chapter anchor.
@ k_reflow_href_chapter_fragment
"path#id" – chapter + anchor.
@ k_reflow_href_empty
Empty / whitespace-only href.
@ k_reflow_href_chapter
"path" – another chapter, no frag.
One tappable rectangle covering a run of <a> glyphs on a page.
int32_t w
Rect width, pixels.
uint32_t page_index
Page this rect belongs to.
int32_t x
Page-local left edge, pixels.
int32_t h
Rect height, pixels.
int32_t y
Page-local top edge, pixels.
Reflow / pagination engine state.