|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Capture Engine Unit (CEU) peripheral-block model for ra8_emulator. More...
#include <stdint.h>#include <stdio.h>#include "board_console.h"#include "board_periph_block.h"#include "emu_host_io_internal.h"Go to the source code of this file.
Data Structures | |
| struct | ceu_state_t |
| CEU model state: register backing store + capture observability. More... | |
Enumerations | |
| enum | ceu_map_t : uint64_t { k_ceu_base = 0x40348000UL , k_ceu_span = 0x100UL , k_ceu_words = 0x100UL / 4UL , k_ceu_off_capsr = 0x00UL , k_ceu_off_cmcyr = 0x0CUL , k_ceu_off_capwr = 0x14UL , k_ceu_off_cdwdr = 0x38UL , k_ceu_off_cdayr = 0x3CUL , k_ceu_off_cetcr = 0x74UL , k_ceu_off_cstsr = 0x7CUL , k_ceu_off_cdssr = 0x84UL } |
| CEU register-window geometry (ra8_ceu_regs.h, Plane A view). More... | |
| enum | ceu_field_t : uint32_t { k_ceu_capsr_ce = 0x00000001U , k_ceu_capsr_cpkil = 0x00010000U , k_ceu_cetcr_cpe = 0x00000001U , k_ceu_cmcyr_hcyl = 0x00003FFFU , k_ceu_field_14bit = 0x00003FFFU , k_ceu_capwr_hwdth = 0x00001FFFU , k_ceu_field_12bit = 0x00000FFFU , k_ceu_pattern_mask = 0x000000FFU } |
| CEU register bit fields (ra8_ceu_regs.h). More... | |
| enum | ceu_bound_t : uint32_t { k_ceu_shift_vert = 16U , k_ceu_max_line = 8192U , k_ceu_max_lines = 4096U } |
| Field shift + fill bounds. More... | |
| enum | ceu_console_t : uint32_t { k_ceu_console_line_cap = 56U } |
| Console anti-flood cadence for the CEU (DMA/transfer) tab. More... | |
Functions | |
| static RA8_INTERNAL uint32_t | internal_ceu_word (uint64_t off) |
| Word index into the backing store for an in-window byte offset. | |
| static RA8_INTERNAL uint32_t | internal_ceu_line_bytes (void) |
| Destination line width (bytes): CDWDR stride, else CMCYR.HCYL. | |
| static RA8_INTERNAL uint32_t | internal_ceu_line_count (void) |
| Destination line count: CAPWR.VWDTH, else CMCYR.VCYL. | |
| static RA8_INTERNAL bool | internal_ceu_do_capture (uc_engine *uc) |
| Synthesise one frame into the CDAYR buffer and latch CETCR.CPE. | |
| static RA8_INTERNAL uint64_t | internal_ceu_read (uc_engine *uc, uint64_t addr, unsigned size) |
| MMIO read inside the CEU window. | |
| static RA8_INTERNAL void | internal_ceu_write (uc_engine *uc, uint64_t addr, unsigned size, uint64_t value) |
| MMIO write inside the CEU window: latch, then act on CAPSR. | |
| static RA8_INTERNAL void | internal_ceu_reset (void) |
| Clear the CEU model to power-on state. | |
| static RA8_INTERNAL void | internal_ceu_report (void) |
| Print the CEU capture summary if any frame was synthesised. | |
| static RA8_INTERNAL void | internal_board_periph_ceu_register (void) |
| Self-register the CEU block before main runs (decentralized). | |
Variables | |
| static ceu_state_t | s_ceu |
| static uint8_t | s_ceu_line [k_ceu_max_line] |
| One-line fill scratch. | |
| static const board_periph_block_t | s_k_ceu_block |
| This block's descriptor (static lifetime; the core keeps the pointer). | |
Capture Engine Unit (CEU) peripheral-block model for ra8_emulator.
Models the RA8D2 Capture Engine Unit at 0x4034_8000 (ra8_ceu_regs.h / ra8_ceu.c, the real HUM Ch 60 parallel-camera capture path). The firmware (camera_capture via cam_ceu.c) initialises the CEU, arms a single-shot capture with ra8_ceu_capture_arm (which programs the destination address register CDAYR then sets CAPSR.CE), and polls the event register CETCR.CPE for one-frame-end. On silicon that end is raised by the sensor's VD edge; in ra8_emulator the capture is instantaneous.
On the CAPSR.CE arm this block synthesises the frame: it derives the destination byte geometry from the capture registers (CDWDR destination stride x CAPWR.VWDTH lines, falling back to CMCYR), writes a deterministic diagonal-gradient test pattern into the firmware's frame buffer at CDAYR through the Unicorn engine, latches CETCR.CPE (and the data size CDSSR), and clears CAPSR.CE (single-shot end). The status register CSTSR reads idle (capture is instantaneous) and CAPSR.CPKIL self-clears, so ra8_ceu_init's idle wait and the arm path both complete. The result: camera_capture reaches frame=OK with a plausible non-degenerate min/max/mean and runs its capture -> stats -> verdict path headless.
Honest-model boundaries: a capture with no destination address or no valid geometry raises no CPE (no faked frame). And ra8_emulator cannot reproduce the real board's J1/TFT VIO_HD pin conflict (issue #119) – this exercises the register/capture flow, it is not a claim the silicon captures. Self-registers with the board_periph core from a file-scope constructor – see board_periph_block.h.
Definition in file board_periph_ceu.c.
| enum ceu_bound_t : uint32_t |
Field shift + fill bounds.
| Enumerator | |
|---|---|
| k_ceu_shift_vert | Vertical field shift (VCYL / VWDTH). |
| k_ceu_max_line | Max modelled line width (bytes) – QVGA=640. |
| k_ceu_max_lines | Max modelled line count – QVGA=240. |
Definition at line 73 of file board_periph_ceu.c.
| enum ceu_console_t : uint32_t |
Console anti-flood cadence for the CEU (DMA/transfer) tab.
| Enumerator | |
|---|---|
| k_ceu_console_line_cap | Max chars in a "CEU frame .." line. |
Definition at line 80 of file board_periph_ceu.c.
| enum ceu_field_t : uint32_t |
CEU register bit fields (ra8_ceu_regs.h).
Definition at line 61 of file board_periph_ceu.c.
| enum ceu_map_t : uint64_t |
CEU register-window geometry (ra8_ceu_regs.h, Plane A view).
Definition at line 46 of file board_periph_ceu.c.
|
static |
Self-register the CEU block before main runs (decentralized).
Definition at line 338 of file board_periph_ceu.c.
References board_periph_register_block(), RA8_INTERNAL, and s_k_ceu_block.
|
static |
Synthesise one frame into the CDAYR buffer and latch CETCR.CPE.
Derives the destination geometry from the capture registers, clamps it to the modelled bounds, and writes a diagonal-gradient test pattern ((x + y) & 0xFF – black..white so a real grab always varies) line-by-line into emulated memory at CDAYR. Raises CETCR.CPE + records CDSSR on success. No CDAYR or no geometry -> no frame is written and CPE stays clear (honest).
| [in,out] | uc | Unicorn engine (the pattern is written to guest memory). |
| true | The ceu do capture condition holds or completed successfully; false otherwise. |
Definition at line 175 of file board_periph_ceu.c.
References board_console_push(), board_periph_trace(), emu_mem_write(), internal_ceu_line_bytes(), internal_ceu_line_count(), internal_ceu_word(), k_board_console_ch_dma, k_ceu_capsr_ce, k_ceu_cetcr_cpe, k_ceu_console_line_cap, k_ceu_max_line, k_ceu_max_lines, k_ceu_off_capsr, k_ceu_off_cdayr, k_ceu_off_cdssr, k_ceu_off_cetcr, k_ceu_pattern_mask, priv_emu_io_errf(), RA8_INTERNAL, s_ceu, and s_ceu_line.
Referenced by internal_ceu_write().
|
static |
Destination line width (bytes): CDWDR stride, else CMCYR.HCYL.
Destination line width (bytes): cdwdr stride, else cmcyr.hcyl; this step is contained within the board periph ceu model and uses bounded caller or module-owned storage.
| value | The operation-specific ceu line bytes value. |
Definition at line 122 of file board_periph_ceu.c.
References internal_ceu_word(), k_ceu_capwr_hwdth, k_ceu_cmcyr_hcyl, k_ceu_off_cdwdr, k_ceu_off_cmcyr, RA8_INTERNAL, and s_ceu.
Referenced by internal_ceu_do_capture().
|
static |
Destination line count: CAPWR.VWDTH, else CMCYR.VCYL.
Destination line count: capwr.vwdth, else cmcyr.vcyl; this step is contained within the board periph ceu model and uses bounded caller or module-owned storage.
| value | The operation-specific ceu line count value. |
Definition at line 142 of file board_periph_ceu.c.
References internal_ceu_word(), k_ceu_field_12bit, k_ceu_field_14bit, k_ceu_off_capwr, k_ceu_off_cmcyr, k_ceu_shift_vert, RA8_INTERNAL, and s_ceu.
Referenced by internal_ceu_do_capture().
|
static |
MMIO read inside the CEU window.
MMIO read inside the ceu window; this step is contained within the board periph ceu model and uses bounded caller or module-owned storage.
| [in,out] | uc | Unicorn engine whose emulated state is read or updated. |
| [in] | addr | Guest address involved in the operation. |
| [in] | size | Size of the requested region or access in bytes. |
| value | The operation-specific ceu read value. |
Definition at line 237 of file board_periph_ceu.c.
References internal_ceu_word(), k_ceu_base, k_ceu_capsr_cpkil, k_ceu_off_capsr, k_ceu_off_cstsr, k_ceu_span, RA8_INTERNAL, and s_ceu.
|
static |
Print the CEU capture summary if any frame was synthesised.
Print the ceu capture summary if any frame was synthesised; this step is contained within the board periph ceu model and uses bounded caller or module-owned storage.
Definition at line 312 of file board_periph_ceu.c.
References priv_emu_io_errf(), RA8_INTERNAL, and s_ceu.
|
static |
Clear the CEU model to power-on state.
Clear the ceu model to power-on state; this step is contained within the board periph ceu model and uses bounded caller or module-owned storage.
Definition at line 299 of file board_periph_ceu.c.
References RA8_INTERNAL, and s_ceu.
|
static |
Word index into the backing store for an in-window byte offset.
Word index into the backing store for an in-window byte offset; this step is contained within the board periph ceu model and uses bounded caller or module-owned storage.
| [in] | off | Register or byte offset addressed by the operation. |
| value | The operation-specific ceu word value. |
Definition at line 107 of file board_periph_ceu.c.
References RA8_INTERNAL.
Referenced by internal_ceu_do_capture(), internal_ceu_line_bytes(), internal_ceu_line_count(), internal_ceu_read(), and internal_ceu_write().
|
static |
MMIO write inside the CEU window: latch, then act on CAPSR.
MMIO write inside the ceu window: latch, then act on capsr; this step is contained within the board periph ceu model and uses bounded caller or module-owned storage.
| [in,out] | uc | Unicorn engine whose emulated state is read or updated. |
| [in] | addr | Guest address involved in the operation. |
| [in] | size | Size of the requested region or access in bytes. |
| [in] | value | Register or payload value involved in the operation. |
Definition at line 268 of file board_periph_ceu.c.
References internal_ceu_do_capture(), internal_ceu_word(), k_ceu_base, k_ceu_capsr_ce, k_ceu_capsr_cpkil, k_ceu_off_capsr, k_ceu_off_cetcr, k_ceu_span, and s_ceu.
|
static |
Definition at line 93 of file board_periph_ceu.c.
Referenced by internal_ceu_do_capture(), internal_ceu_line_bytes(), internal_ceu_line_count(), internal_ceu_read(), internal_ceu_report(), internal_ceu_reset(), and internal_ceu_write().
|
static |
One-line fill scratch.
Definition at line 94 of file board_periph_ceu.c.
Referenced by internal_ceu_do_capture().
|
static |
This block's descriptor (static lifetime; the core keeps the pointer).
Definition at line 325 of file board_periph_ceu.c.
Referenced by internal_board_periph_ceu_register().