|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
CRC calculator peripheral-block model for the board emulator. More...
#include <stdint.h>#include <stdio.h>#include "board_periph_block.h"#include "emu_host_io_internal.h"Go to the source code of this file.
Data Structures | |
| struct | crc_state_t |
| CRC register state. More... | |
Enumerations | |
| enum | crc_lit_t : uint32_t { k_u32_all = 0xFFFFFFFFU , k_u16_mask = 0xFFFFU , k_byte_mask = 0xFFU } |
| Bit-width masks for the CRC unit model. More... | |
| enum | crc_map_t : uint64_t { k_crc_base = 0x40310000UL , k_crc_span = 0x20UL , k_crc_off_cr0 = 0x00UL , k_crc_off_cr1 = 0x01UL , k_crc_off_dir = 0x04UL , k_crc_off_dor = 0x08UL } |
| CRC block geometry (ra8_crc_regs.h). More... | |
| enum | crc_cr0_field_t : uint32_t { k_crc_gps_mask = 0x07U , k_crc_dorclr = 0x80U } |
| CRCCR0 fields (ra8_crc_regs.h). More... | |
| enum | crc_gps_t : uint32_t { k_crc_gps_8 = 1U , k_crc_gps_16 = 2U , k_crc_gps_ccitt = 3U , k_crc_gps_32 = 4U , k_crc_gps_32c = 5U } |
| GPS polynomial encodings (CRCCR0.GPS). More... | |
| enum | crc_poly_refl_t : uint32_t { k_crc_poly_16_refl = 0x0000A001U , k_crc_poly_32_refl = 0xEDB88320U , k_crc_poly_32c_refl = 0x82F63B78U } |
| Reflected (LSB-first) polynomials for the reflected GPS modes. More... | |
| enum | crc_poly_fwd_t : uint32_t { k_crc_poly_8_fwd = 0x00000007U , k_crc_poly_ccitt_fwd = 0x00001021U } |
| MSB-first polynomials for the non-reflected GPS modes. More... | |
| enum | crc_order_t : uint32_t { k_crc_block_order = 140U } |
| Per-tick order slot for the CRC block (relative order only). More... | |
Functions | |
| static RA8_INTERNAL uint32_t | internal_crc_step_reflected (uint32_t crc, uint8_t byte, uint32_t poly) |
| Fold one byte into a reflected (LSB-first) CRC of any width. | |
| static RA8_INTERNAL uint32_t | internal_crc_step_forward (uint32_t crc, uint8_t byte, uint32_t poly, uint32_t width) |
Fold one byte into an MSB-first CRC of width bits. | |
| static RA8_INTERNAL void | internal_crc_fold_byte (uint8_t byte) |
| Fold one input byte into CRCDOR using the CRCCR0.GPS polynomial. | |
| static RA8_INTERNAL void | internal_crc_reset (void) |
| Reset the CRC unit to power-on state. | |
| static RA8_INTERNAL uint64_t | internal_crc_read (uc_engine *uc, uint64_t addr, unsigned size) |
| MMIO read inside the CRC window. | |
| static RA8_INTERNAL void | internal_crc_write (uc_engine *uc, uint64_t addr, unsigned size, uint64_t value) |
| MMIO write inside the CRC window. | |
| static RA8_INTERNAL void | internal_crc_report (void) |
| End-of-run CRC section: last result + bytes folded. | |
| static RA8_INTERNAL void | internal_crc_block_register (void) |
| Register the CRC block before main (host constructor). | |
Variables | |
| static crc_state_t | s_crc |
| static const board_periph_block_t | s_k_crc_block |
| CRC block descriptor (self-registered with the core). | |
CRC calculator peripheral-block model for the board emulator.
Models the RA8D2 CRC unit (ra8_crc_regs.h, ra8_crc.c) at 0x40310000 so crc_demo's hardware CRC matches its software reference (it printed "crc: hw=00000000 ... match=N" against the sparse fallback, which returned a constant 0). The unit is a single running-remainder register CRCDOR fed one byte at a time through CRCDIR; this model reproduces that:
ra8_crc's word feed produces – and an 8-bit access (CRC-8 / 16 / CCITT) folds one byte.Reflection follows the RA8D2 polynomial definitions: CRC-32 / CRC-32C and the reflected CRC-16 fold LSB-first; CRC-8 and CRC-CCITT fold MSB-first. Only the CRC-32 path is exercised by an in-tree example (crc_demo, where it now reads match=Y); the others use their standard parameters.
Definition in file board_periph_crc.c.
| enum crc_cr0_field_t : uint32_t |
CRCCR0 fields (ra8_crc_regs.h).
| Enumerator | |
|---|---|
| k_crc_gps_mask | GPS[2:0] polynomial select. |
| k_crc_dorclr | DORCLR: clear CRCDOR (bit 7). |
Definition at line 55 of file board_periph_crc.c.
| enum crc_gps_t : uint32_t |
GPS polynomial encodings (CRCCR0.GPS).
| Enumerator | |
|---|---|
| k_crc_gps_8 | CRC-8 (X^8+X^2+X+1). |
| k_crc_gps_16 | CRC-16 (X^16+X^15+X^2+1). |
| k_crc_gps_ccitt | CRC-CCITT (X^16+X^12+X^5+1). |
| k_crc_gps_32 | CRC-32 (IEEE 802.3). |
| k_crc_gps_32c | CRC-32C (Castagnoli). |
Definition at line 61 of file board_periph_crc.c.
| enum crc_lit_t : uint32_t |
Bit-width masks for the CRC unit model.
| Enumerator | |
|---|---|
| k_u32_all | 32-bit all-ones. |
| k_u16_mask | 16-bit mask. |
| k_byte_mask | 8-bit mask. |
Definition at line 38 of file board_periph_crc.c.
| enum crc_map_t : uint64_t |
CRC block geometry (ra8_crc_regs.h).
Definition at line 45 of file board_periph_crc.c.
| enum crc_order_t : uint32_t |
Per-tick order slot for the CRC block (relative order only).
| Enumerator | |
|---|---|
| k_crc_block_order | After the existing blocks; report order. |
Definition at line 83 of file board_periph_crc.c.
| enum crc_poly_fwd_t : uint32_t |
MSB-first polynomials for the non-reflected GPS modes.
| Enumerator | |
|---|---|
| k_crc_poly_8_fwd | CRC-8 X^8+X^2+X+1. |
| k_crc_poly_ccitt_fwd | CRC-CCITT. |
Definition at line 77 of file board_periph_crc.c.
| enum crc_poly_refl_t : uint32_t |
Reflected (LSB-first) polynomials for the reflected GPS modes.
| Enumerator | |
|---|---|
| k_crc_poly_16_refl | Reflected 0x8005. |
| k_crc_poly_32_refl | Reflected 0x04C11DB7. |
| k_crc_poly_32c_refl | Reflected 0x1EDC6F41. |
Definition at line 70 of file board_periph_crc.c.
|
static |
Register the CRC block before main (host constructor).
Definition at line 318 of file board_periph_crc.c.
References board_periph_register_block(), RA8_INTERNAL, and s_k_crc_block.
|
static |
Fold one input byte into CRCDOR using the CRCCR0.GPS polynomial.
Fold one input byte into crcdor using the crccr0.gps polynomial; this step is contained within the board periph CRC model and uses bounded caller or module-owned storage.
| [in] | byte | One data byte received from or sent to the emulated interface. |
Definition at line 158 of file board_periph_crc.c.
References internal_crc_step_forward(), internal_crc_step_reflected(), k_crc_gps_16, k_crc_gps_32, k_crc_gps_32c, k_crc_gps_8, k_crc_gps_ccitt, k_crc_gps_mask, k_crc_poly_16_refl, k_crc_poly_32_refl, k_crc_poly_32c_refl, k_crc_poly_8_fwd, k_crc_poly_ccitt_fwd, RA8_INTERNAL, and s_crc.
Referenced by internal_crc_write().
|
static |
MMIO read inside the CRC window.
MMIO read inside the crc window; this step is contained within the board periph CRC 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 CRC read value. |
Definition at line 211 of file board_periph_crc.c.
References k_crc_base, k_crc_off_cr0, k_crc_off_cr1, k_crc_off_dor, RA8_INTERNAL, and s_crc.
|
static |
End-of-run CRC section: last result + bytes folded.
End-of-run crc section: last result + bytes folded; this step is contained within the board periph CRC model and uses bounded caller or module-owned storage.
Definition at line 293 of file board_periph_crc.c.
References k_crc_gps_mask, priv_emu_io_errf(), RA8_INTERNAL, and s_crc.
|
static |
Reset the CRC unit to power-on state.
Reset the crc unit to power-on state; this step is contained within the board periph CRC model and uses bounded caller or module-owned storage.
Definition at line 190 of file board_periph_crc.c.
References RA8_INTERNAL, and s_crc.
|
static |
Fold one byte into an MSB-first CRC of width bits.
Fold one byte into an msb-first crc of width bits; this step is contained within the board periph CRC model and uses bounded caller or module-owned storage.
| [in] | crc | Crc input used by the operation. |
| [in] | byte | One data byte received from or sent to the emulated interface. |
| [in] | poly | Poly input used by the operation. |
| [in] | width | Width of the affected region in pixels. |
| value | The operation-specific CRC step forward value. |
Definition at line 134 of file board_periph_crc.c.
References k_u32_all.
Referenced by internal_crc_fold_byte().
|
static |
Fold one byte into a reflected (LSB-first) CRC of any width.
Fold one byte into a reflected (lsb-first) crc of any width; this step is contained within the board periph CRC model and uses bounded caller or module-owned storage.
| [in] | crc | Crc input used by the operation. |
| [in] | byte | One data byte received from or sent to the emulated interface. |
| [in] | poly | Poly input used by the operation. |
| value | The operation-specific CRC step reflected value. |
Definition at line 110 of file board_periph_crc.c.
References RA8_INTERNAL.
Referenced by internal_crc_fold_byte().
|
static |
MMIO write inside the CRC window.
MMIO write inside the crc window; this step is contained within the board periph CRC 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 243 of file board_periph_crc.c.
References internal_crc_fold_byte(), k_byte_mask, k_crc_base, k_crc_dorclr, k_crc_off_cr0, k_crc_off_cr1, k_crc_off_dir, k_crc_off_dor, k_u16_mask, and s_crc.
|
static |
Definition at line 95 of file board_periph_crc.c.
Referenced by internal_crc_fold_byte(), internal_crc_read(), internal_crc_report(), internal_crc_reset(), and internal_crc_write().
|
static |
CRC block descriptor (self-registered with the core).
Definition at line 305 of file board_periph_crc.c.
Referenced by internal_crc_block_register().