47typedef enum : uint8_t {
62typedef enum : uint32_t {
74typedef enum : uint8_t {
90typedef enum : uint8_t {
362 if (other == channel) {
423 for (uint8_t i = 0U; i < words; ++i) {
507 for (uint8_t i = 0U; i < 8U; ++i) {
533 if (reg ==
nullptr) {
549 if (reg !=
nullptr) {
643 if (handle->
valid == 0U) {
704 const uint32_t* iv_words)
706 if (iv_words !=
nullptr) {
750 if (new_handle->
valid == 0U) {
766 const uint32_t* iv_words)
776 const uint8_t was_enabled = st->
enabled;
784 st->
key = *new_handle;
790 if (was_enabled != 0U) {
894 const uint32_t saved = reg->
REG00;
902 *out_status = reg->
REG00;
924 *out_mask = reg->
REG00;
static const char * s_tag
Logging / check tag.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_ISR_SAFE
The function is callable from interrupt context.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_RETURN_ON_ERROR(err, tag, message)
Early return on error, propagating the code upward.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
ra8_err_t ra8_dotf_deinit(void)
Disable DOTF and gate the OSPI clock.
static ra8_err_t internal_validate_rotate_inputs(uint8_t channel, const ra8_dotf_key_handle_t *new_handle)
Validate the inputs to ra8_dotf_rotate_key.
static uint32_t internal_sca_bits(ra8_dotf_sca_level_t level)
Map an SCA level enum into REG00 SCA bits.
static void internal_state_reset(uint8_t channel)
Wipe all software state for one channel.
ra8_err_t ra8_dotf_clear_status(uint8_t channel)
Clear REG00 (force the channel into bypass).
ra8_dotf_misc_t
Internal small constants (no magic numbers).
@ k_ra8_dotf_no_region
Sentinel for "no region active".
@ k_ra8_dotf_self_test_spin
Bounded poll budget for self-test bit.
static ra8_err_t internal_validate_region(uint8_t channel, const ra8_dotf_region_t *region)
Validate region range / alignment / window.
ra8_dotf_key_word_count_t
Wrapped-key word counts per AES key size.
@ k_ra8_dotf_key_words_128
RA8 dotf key words 128.
@ k_ra8_dotf_key_words_192
RA8 dotf key words 192.
@ k_ra8_dotf_key_words_256
RA8 dotf key words 256.
static void internal_channel_reset(volatile ra8_dotf_regs_t *reg)
Reset one channel's hardware to power-on state.
static uint8_t internal_key_words(ra8_dotf_key_size_t size)
Word count for a given AES key size.
void ra8_dotf_dispatch(uint8_t channel)
Dispatch a DOTF event from the IRQ glue.
static uint32_t internal_assemble_reg00(const ra8_dotf_chan_state_t *st, bool enable)
Assemble the REG00 word for the channel's cached state.
ra8_dotf_bswap_const_t
Byte-extraction masks and shift counts for internal_bswap32.
@ k_ra8_dotf_bswap_byte0
Selects bits [7:0] (byte 0).
@ k_ra8_dotf_bswap_byte3
Selects bits [31:24] (byte 3).
@ k_ra8_dotf_bswap_byte2
Selects bits [23:16] (byte 2).
@ k_ra8_dotf_bswap_byte_mask
Per-byte mask used by all 4 lanes.
@ k_ra8_dotf_bswap_byte1
Selects bits [15:8] (byte 1).
static uint32_t internal_window_lo(uint8_t channel)
XSPI window low bound for a given DOTF channel.
ra8_err_t ra8_dotf_set_sca_level(uint8_t channel, ra8_dotf_sca_level_t level)
Update the side-channel countermeasure level for a channel.
ra8_err_t ra8_dotf_enable(uint8_t channel)
Enable AES decryption for one channel.
ra8_err_t ra8_dotf_attach_handler(ra8_dotf_event_fn_t fn, void *ctx)
Register a fault / event callback (shared across both channels).
static void internal_stage_key(volatile ra8_dotf_regs_t *reg, const ra8_dotf_key_handle_t *h)
Stage a wrapped-key payload into REG03.
ra8_err_t ra8_dotf_get_status(uint8_t channel, uint32_t *out_mask)
Read REG00 (raw control / status snapshot).
static ra8_dotf_event_fn_t s_dotf_fn
Active fault / event callback.
static ra8_err_t internal_check_overlap(uint8_t channel, const ra8_dotf_region_t *region)
Reject a region that overlaps the live region of the OTHER channel.
ra8_err_t ra8_dotf_disable(uint8_t channel)
Disable AES decryption for one channel (transparent bypass).
static uint32_t internal_bswap32(uint32_t v)
Big-endian byte-swap of a 32-bit word.
ra8_err_t ra8_dotf_install_key(uint8_t channel, const ra8_dotf_key_handle_t *handle)
Bind a wrapped AES key handle to a DOTF channel.
ra8_err_t ra8_dotf_rotate_key(uint8_t channel, const ra8_dotf_key_handle_t *new_handle, const uint32_t *iv_words)
Atomically rotate the key bound to a channel.
ra8_err_t ra8_dotf_select_region(uint8_t channel, uint8_t region_id)
Promote a staged region into the live CONVAREAST / CONVAREAD pair.
ra8_err_t ra8_dotf_set_iv(uint8_t channel, const uint32_t *iv_words)
Stage the AES counter-mode IV for a channel via REG03.
static void internal_stage_iv(volatile ra8_dotf_regs_t *reg, const uint32_t *iv)
Stage 4 IV words into REG03 in big-endian order.
ra8_err_t ra8_dotf_set_key_size(uint8_t channel, ra8_dotf_key_size_t size)
Update the cached AES key size for a channel.
ra8_err_t ra8_dotf_init(void)
Power on the DOTF block and reset both channels.
static const ra8_mstp_t s_dotf_mstp_table[k_ra8_dotf_channel_count]
Channel-index -> MSTP id lookup.
static void * s_dotf_ctx
Caller-supplied context handed to s_dotf_fn.
static void internal_rotate_iv(ra8_dotf_chan_state_t *st, volatile ra8_dotf_regs_t *reg, const uint32_t *iv_words)
Re-stage the IV for a rotate-key call.
ra8_err_t ra8_dotf_run_self_test(uint8_t channel, uint32_t *out_status)
Trigger the built-in self-test (REG00 bit 20) for a channel.
ra8_err_t ra8_dotf_get_active_region(uint8_t channel, ra8_dotf_region_t *region)
Read back the active region for a channel.
ra8_dotf_bswap_shift_t
Shift counts used by internal_bswap32.
@ k_ra8_dotf_bswap_shift_word
Shift for byte0 <-> byte3.
@ k_ra8_dotf_bswap_shift_byte
Shift for one-byte slide.
static bool internal_channel_in_range(uint8_t channel)
Bound-check a channel index.
static ra8_dotf_chan_state_t s_dotf_state[k_ra8_dotf_channel_count]
Per-channel state table.
ra8_err_t ra8_dotf_set_region(uint8_t channel, const ra8_dotf_region_t *region)
Stage one DOTF region in the channel's region table.
static uint32_t internal_window_hi(uint8_t channel)
XSPI window high bound for a given DOTF channel.
Decryption On The Fly (DOTF) HAL driver public API.
ra8_dotf_key_size_t
AES key sizes supported by the DOTF AES core.
@ k_ra8_dotf_key_size_128
128-bit AES.
@ k_ra8_dotf_key_size_192
192-bit AES.
@ k_ra8_dotf_key_size_256
256-bit AES.
void(* ra8_dotf_event_fn_t)(void *ctx, uint8_t channel)
DOTF fault / status event callback.
ra8_dotf_sca_level_t
Side-channel countermeasure tuning levels.
@ k_ra8_dotf_sca_max
Maximum level, bits 16 + 17 set.
@ k_ra8_dotf_sca_standard
Default level, bit 16 set.
@ k_ra8_dotf_sca_off
Side-channel countermeasures disabled.
Decryption On The Fly (DOTF) register layout for the Renesas RA8D2.
@ k_ra8_dotf_channel_count
DOTF0 + DOTF1.
@ k_ra8_dotf_max_regions
Max staged regions per channel.
@ k_ra8_dotf_iv_word_count
IV is 128-bit = 4 x 32-bit words.
@ k_ra8_dotf_addr_low_mask
Low 12 bits read as 0/1 (HUM).
@ k_ra8_dotf_addr_mask
High 20 bits are the value.
@ k_ra8_dotf_reg00_self_test
Bit 20 – self-test trigger.
@ k_ra8_dotf_reg00_mode_ctr
CTR mode (HUM 45.1 p 3048).
@ k_ra8_dotf_reg00_aes_enable
Bit 9 – enable AES core.
@ k_ra8_dotf_reg00_sca_mode
Bit 17 – side-channel mode.
@ k_ra8_dotf_reg00_sca_en
Bit 16 – side-channel enable.
@ k_ra8_dotf_reg00_disable_value
Disable – AES bypassed.
@ k_ra8_dotf0_window_hi
Last byte covered by DOTF0.
@ k_ra8_dotf0_window_lo
First byte covered by DOTF0.
@ k_ra8_dotf1_window_lo
First byte covered by DOTF1.
@ k_ra8_dotf1_window_hi
Last byte covered by DOTF1.
static volatile ra8_dotf_regs_t * ra8_dotf_regs(uint8_t channel)
Get pointer to DOTF channel channel.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_hw_init_failed
Hardware peripheral failed to initialise.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_err_invalid_state
Module in wrong state for requested operation.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_conflict
Conflict with concurrent access detected.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Bounded wait-flag primitives for RA8D2 HAL drivers.
static ra8_err_t ra8_hw_wait_flag_clear32(volatile const uint32_t *reg, uint32_t mask, uint32_t budget)
Spin until (*reg & mask) == 0 or budget runs out.
Lightweight Logging Interface for ra8-firmware.
#define ra8_log_warn_val(tag, message, value)
RA8 log warn val.
#define ra8_log_info_val(tag, message, value)
RA8 log info val.
#define ra8_log_info(tag, message)
RA8 log info.
Ref-counted Module Stop Control wrapper for the RA8D2.
ra8_err_t ra8_mstp_enable(ra8_mstp_t id)
Reference-counted "ungate this peripheral" request.
ra8_err_t ra8_mstp_disable(ra8_mstp_t id)
Reference-counted "gate this peripheral" request.
ra8_mstp_t
Packed (reg << 8) | bit module-stop identifier.
@ k_ra8_mstp_ospi0
MSTPB16 OSPI0+DOTF0.
@ k_ra8_mstp_ospi1
MSTPB17 OSPI1+DOTF1.
Per-channel software state.
ra8_dotf_key_handle_t key
Key.
ra8_dotf_sca_level_t cached_sca
Cached sca.
uint32_t iv_cache[k_ra8_dotf_iv_word_count]
Iv cache.
ra8_dotf_region_t regions[k_ra8_dotf_max_regions]
Regions.
uint8_t iv_valid
Iv valid.
uint8_t active_region_id
or k_ra8_dotf_no_region.
ra8_dotf_key_size_t cached_key_size
Cached key size.
uint8_t region_valid[k_ra8_dotf_max_regions]
1 if slot armed.
Wrapped-key handle handed to DOTF by ra8_rsip.
ra8_dotf_key_size_t size
128 / 192 / 256 selector for REG00.
uint32_t words[8]
Wrapped-key payload (up to 256 bits).
uint8_t valid
Non-zero if the wrapped key is real.
uint8_t key_index
RSIP key slot this handle came from.
Conversion-area descriptor for ra8_dotf_set_region.
uint8_t region_id
0..k_ra8_dotf_max_regions-1 staging slot.
uint32_t start_addr
First byte of the encrypted region (incl).
uint8_t key_index
RSIP key index (forwarded to install_key flow).
uint32_t end_addr
Last byte of the encrypted region (incl).
Per-channel DOTF register window.
volatile uint32_t CONVAREAD
+0x004 Conversion area end address.
volatile uint32_t REG03
+0x08C AES IV staging window.
volatile uint32_t REG00
+0x080 AES enable / mode select.
volatile uint32_t CONVAREAST
+0x000 Conversion area start address.