43#include "font_fixture.h"
52#include "rabook_fixture.h"
57typedef enum : uint32_t {
83static const uint8_t
k_msg_boot[] =
"ereader-rabook-hil: boot\r\n";
84static const uint8_t
k_msg_fail[] =
"ereader-rabook-hil: FAIL init\r\n";
85static const uint8_t
k_msg_berr[] =
"ereader-rabook-hil: FAIL book\r\n";
86static const uint8_t
k_msg_lerr[] =
"ereader-rabook-hil: FAIL layout\r\n";
87static const uint8_t
k_msg_pre[] =
"ereader-rabook-hil: chapters=";
97typedef enum : uint32_t {
113 __asm__
volatile(
"bkpt #0");
115 __asm__
volatile(
"wfi");
146 for (uint32_t i = 0U; i < n; i++) {
161 for (
size_t i = 0U; i < nbytes; i++) {
177 for (uint32_t p = 0U; p < pages; p++) {
189 uint32_t cpuclk0_hz = 0U;
237 uint32_t distinct = 0U;
239 for (uint32_t i = 0U; i < lim; i++) {
275 const uint32_t npx = (uint32_t)im->
width * (uint32_t)im->
height;
339 for (uint32_t ci = 0U; ci < chapters; ci++) {
346 __asm__
volatile(
"wfi");
void main(void)
Secure fallback main entry point.
Flat, execute-in-place container for a build-time "compiled" e-book.
static const book_image_t * book_images(const void *base)
Base of the image table.
ra8_err_t book_chapter_to_xhtml(const void *base, uint32_t chapter_idx, char *out, size_t cap, size_t *out_len)
Serialize one chapter's DOM subtree back to XHTML for the renderer.
static const book_header_t * book_header(const void *base)
View the blob base as its header.
@ k_book_image_gray4
4bpp gray, 2px/byte; pixel (x,y) is at flat index y*width + x.
static book_image_pixfmt_t book_image_pixfmt(const book_image_t *img)
Declared pixel depth of one image descriptor.
@ k_book_pixfmt_gray8
8bpp grayscale, 1px/byte (lossless against any grey panel).
static const uint8_t * book_image_data(const void *base, const book_image_t *img)
Image-pool pointer to one image's compressed pixel data.
ra8_err_t book_validate(const void *base, size_t size)
Validate that a byte buffer is a well-formed, intact .rabook blob.
static const uint8_t k_msg_pre[]
static const uint8_t k_msg_ok[]
static const uint8_t k_msg_crc[]
static const uint8_t k_msg_boot[]
static const uint8_t k_msg_fail[]
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).
static reflow_t s_engine
Reflow engine (glyph / page / token / text pools live inside).
static const uint8_t k_msg_x[]
static const uint8_t k_msg_ch[]
static const uint8_t k_msg_lerr[]
static const uint8_t k_msg_g8[]
static void erb_render_chapter(const void *book, uint32_t chapter_idx)
Lay out + render one chapter; emit chN p=<pages> crc=<hash>.
static const uint8_t k_msg_berr[]
static uint32_t erb_distinct_levels(const uint8_t *px, uint32_t n)
Count the distinct gray8 tone levels in px[0..n) (bounded scan).
static void erb_panic_halt(const uint8_t *msg, uint32_t len)
Print the fail banner and trap (ra8_emulator halts on the BKPT).
static void erb_print_hex(uint32_t value)
Print a 32-bit value as 8 upper-case hex digits.
static uint32_t erb_hash_fb(uint32_t seed)
Fold the whole RGB565 framebuffer into a running FNV-1a-32.
static void erb_setup_or_halt(void)
Bring up clocks/MSTP/time + the SCI8 console; halt on failure.
static void erb_print(const uint8_t *msg, uint32_t len)
Emit a byte run on the SCI8 console.
erb_img_const_t
Full-resolution gray8 figure check bounds (#476).
@ k_erb_img_max_px
Fixture image pixel cap (bounds the scan).
@ k_erb_gray4_levels
Distinct tones a 4bpp store can ever show.
@ k_erb_level_count
gray8 value space (presence bitmap size).
static void erb_render_image(void)
Render the retained full-resolution gray8 figure and check it (#476).
static const uint8_t k_msg_img[]
static const uint8_t k_msg_p[]
static uint32_t erb_render_all(uint32_t *out_hash)
Render every laid-out page of the current chapter; fold an FNV over it.
erb_consts_t
Framebuffer / console / hash / buffer knobs.
@ k_erb_bg
Page background (0x00RRGGBB).
@ k_erb_fnv_prime
FNV-1a-32 prime.
@ k_erb_xhtml_cap
Per-chapter serialized XHTML cap.
@ k_erb_fb_h
Framebuffer height, pixels.
@ k_erb_fb_w
Framebuffer width, pixels.
@ k_erb_ink
Body ink colour (ARGB).
@ k_erb_hex_nibbles
Hex digits in a 32-bit value.
@ k_erb_link_col
Anchor colour (ARGB).
@ k_erb_nibble_bits
Bits per hex nibble.
@ k_erb_fnv_offset
FNV-1a-32 offset basis.
@ k_erb_dec_ten
Hex digit / decimal split.
@ k_erb_uart_baud
Console baud.
@ k_erb_nibble_mask
Low-nibble mask.
@ k_erb_font_px
Body font size, pixels.
static void erb_print_uint(uint32_t value)
Print a small unsigned integer in decimal.
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 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.
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_init(void *fb, uint16_t width, uint16_t height, ra8_gfx_format_t format)
Bind ra8_gfx to a caller-owned framebuffer.
ra8_err_t ra8_gfx_blit_gray8(const uint8_t *src, int32_t w, int32_t h, int32_t dst_x, int32_t dst_y)
Blit an 8-bit grayscale image to a framebuffer rectangle.
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.
@ k_rabook_gray8_fixture_len
Inflated flat-blob length.
static const uint8_t k_rabook_gray8_fixture[4785U]
Baked, inflated gray8-image .rabook blob (validate + walk).
HTML / CSS reflow + paginate engine for the ra8d2 ereader.
ra8_err_t reflow_render_page(const reflow_t *engine, uint32_t page_idx, void *framebuffer)
Render one page into the active ra8_gfx framebuffer.
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_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.
ra8_err_t reflow_get_page_count(const reflow_t *engine, uint32_t *out_count)
Report the laid-out page count.
static uint8_t s_xhtml[k_sh_xhtml_cap]
Descriptor for one transcoded image in the image pool.
uint16_t height
Pixel height.
uint32_t raw_size
Inflated length in bytes.
uint8_t format
book_image_format_t.
uint16_t width
Pixel width.
Reflow / pagination engine state.