34#include "epub_fixture.h"
44typedef enum : uint32_t {
62static const uint8_t
k_msg_boot[] =
"epub-parse-hil: boot\r\n";
63static const uint8_t
k_msg_fail[] =
"epub-parse-hil: FAIL init\r\n";
64static const uint8_t
k_msg_open[] =
"epub: FAIL open\r\n";
65static const uint8_t
k_msg_chap[] =
"epub: FAIL chapters\r\n";
66static const uint8_t
k_msg_load[] =
"epub: FAIL load\r\n";
67static const uint8_t
k_msg_meta[] =
"epub: FAIL meta\r\n";
68static const uint8_t
k_msg_pre[] =
"epub: chapters=";
73static void ep_print(
const uint8_t* msg, uint32_t len)
82 __asm__
volatile(
"bkpt #0");
84 __asm__
volatile(
"wfi");
89static uint32_t
ep_crc32(
const uint8_t* data,
size_t len)
92 for (
size_t i = 0U; i < len; i++) {
93 crc ^= (uint32_t)data[i];
94 for (uint32_t bit = 0U; bit < (uint32_t)
k_ep_crc_bits; bit++) {
95 const uint32_t mask = (uint32_t)(-(int32_t)(crc & 1U));
124 buf[n] = (uint8_t)(
'0' + (value % (uint32_t)
k_ep_dec_ten));
128 for (uint32_t i = 0U; i < n; i++) {
136 uint32_t cpuclk0_hz = 0U;
168 uint16_t chapters = 0U;
200 uint32_t ch0_crc = 0U;
210 __asm__
volatile(
"wfi");
void main(void)
Secure fallback main entry point.
EPUB (.epub) reader and chapter iterator for ra8-firmware.
ra8_err_t epub_get_metadata(const epub_book_t *book, epub_metadata_t *out_meta)
Return Dublin Core metadata strings.
ra8_err_t epub_load_chapter(epub_book_t *book, uint16_t idx, uint8_t *out_xhtml, size_t max_len, size_t *got_len)
Extract the raw XHTML bytes of one chapter into the caller's buffer.
ra8_err_t epub_open(const void *media, const char *path, epub_book_t *out_book)
Open an EPUB book from an opaque media handle.
ra8_err_t epub_get_chapter_count(const epub_book_t *book, uint16_t *out_count)
Report how many chapters the spine contains.
static const uint8_t k_epub_fixture[k_epub_fixture_len]
Baked seed_two_chapters.epub byte stream.
@ k_epub_fixture_len
EPUB fixture length.
static epub_book_t s_book
Opened book (large – file-scope, not on the stack).
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 uint8_t s_chapter[k_eoh_chap_cap]
Chapter-0 XHTML scratch (file-scope to keep the stack small).
static uint32_t ep_crc32(const uint8_t *data, size_t len)
CRC-32 (reflected, poly 0xEDB88320) over data.
ep_consts_t
Console / parse knobs (no magic numbers).
@ k_ep_hex_nibbles
Hex digits in a 32-bit value.
@ k_ep_expect_chap
Spine length of the baked seed.
@ k_ep_crc_init
CRC-32 initial value.
@ k_ep_crc_poly
CRC-32 reflected polynomial.
@ k_ep_uart_baud
Console baud.
@ k_ep_nibble_bits
Bits per hex nibble.
@ k_ep_crc_bits
Bits folded per byte.
@ k_ep_nibble_mask
Low-nibble mask.
@ k_ep_dec_ten
Hex digit / decimal split.
@ k_ep_chap_cap
Chapter XHTML scratch capacity.
static const uint8_t k_msg_load[]
static void ep_print_hex(uint32_t value)
Print a 32-bit value as 8 upper-case hex digits.
static const uint8_t k_msg_chap[]
static void ep_print(const uint8_t *msg, uint32_t len)
Emit a byte run on the SCI8 console.
static const uint8_t k_msg_meta[]
static void ep_print_uint(uint32_t value)
Print a small unsigned integer in decimal.
static const uint8_t k_msg_open[]
static void ep_setup_or_halt(void)
Bring up clocks/MSTP/time + the SCI8 console; halt on failure.
static uint16_t ep_parse_or_halt(uint32_t *out_crc)
Open the baked EPUB, verify the spine, load + CRC chapter 0.
static const uint8_t k_msg_fail[]
static void ep_panic_halt(void)
Halt forever with the red board LED on.
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.