ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_bkup_internal.h File Reference

Cross-TU shared surface for the ra8_bkup driver split. More...

#include <stdint.h>
#include "ra8_attributes.h"
Include dependency graph for ra8_bkup_internal.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void priv_ra8_bkup_internal_rmw8 (volatile uint8_t *reg, uint8_t mask, bool enable, uint16_t unlock_val)
 Set or clear a bit in an 8-bit PRCR-protected RMW register.

Variables

const char * g_bkup_tag
 Log tag used for this driver's diagnostics.
bool s_bkup_initialized
 true once any of the lifecycle init helpers have run.

Detailed Description

Cross-TU shared surface for the ra8_bkup driver split.

Tag
[Ring 3 / HAL] {World: NS}

The ra8_bkup driver is split across three translation units to stay under the per-file line-count cap, one per responsibility:

  • ra8_bkup.c – power-supply lifecycle, status registers, the VBTBKRn backup store, the VBATT analog voltage monitor, and the interrupt path.
  • ra8_bkup_tamper.c – tamper detection and RTCIC pad wiring.
  • ra8_bkup_security.c – the TrustZone attribution registers.

This src/-local header carries the handful of symbols those TUs share: the driver-wide log tag, the init latch that gates the ISR, and the protected read-modify-write helper. Everything else stayed private to the TU that owns it – the tamper channel-bit helper and per-channel validator are used nowhere else, and the security TU borrows nothing but the log tag. It is NOT part of the public ABI; production code outside this driver must use ra8_bkup.h.

Definition in file ra8_bkup_internal.h.

Function Documentation

◆ priv_ra8_bkup_internal_rmw8()

void priv_ra8_bkup_internal_rmw8 ( volatile uint8_t * reg,
uint8_t mask,
bool enable,
uint16_t unlock_val )

Set or clear a bit in an 8-bit PRCR-protected RMW register.

The read half needs no unlock (PRCR gates writes only, HUM Ch 13.1 p 520), so only the store runs inside the protection window. The caller supplies the window because this driver spans three groups: PRC1 for the VBT* file and PRC3 for VBATTMNSELR.

Shared by both register-touching TUs of the driver: ra8_bkup.c uses it for the status W0C paths and the voltage-monitor select, and ra8_bkup_tamper.c uses it for the per-channel input enable.

Parameters
[in,out]regPointer to the live 8-bit register.
[in]maskBit mask to manipulate.
[in]enabletrue to set, false to clear.
[in]unlock_valk_ra8_prcr_unlock_* for reg's group.
Precondition
reg != nullptr.
mask != 0.
unlock_val names the PRCR group that owns reg (HUM Table 13.1).
Postcondition
Bits in mask reflect enable; other bits unchanged.
PRCR is relocked.
Warning
The store is only durable inside the unlock window: a write issued while reg's PRCR group is locked is discarded silently, with no bus fault and no status flag (issue #131). Do not separate the write from its unlock.
Note
Thread safety: not thread-safe; caller must serialise.
Since
0.1.0

Definition at line 172 of file ra8_bkup.c.

References RA8_PROTECTED_WRITE.

Referenced by ra8_bkup_clear_status(), ra8_bkup_isr_handle(), ra8_bkup_set_input_enable(), and ra8_bkup_set_voltage_monitor().

Variable Documentation

◆ g_bkup_tag

const char* g_bkup_tag
extern

Log tag used for this driver's diagnostics.

Log tag every TU of this driver logs under.

Defined once here and shared with the tamper and security TUs through ra8_bkup_internal.h, so the whole driver logs under one identity.

Note
Read-only after definition.
Since
0.1.0

Defined once in ra8_bkup.c. The tamper and security TUs reference it through this declaration rather than each defining their own copy, so the driver has a single logging identity and a single object.

Note
Read-only after definition; never reassigned.
Since
0.1.0

Definition at line 88 of file ra8_bkup.c.

Referenced by internal_validate_security_cfg(), internal_validate_tamper_channels(), ra8_bkup_cold_start_init(), ra8_bkup_deinit(), ra8_bkup_get_status(), ra8_bkup_get_voltage_monitor_enabled(), ra8_bkup_init(), ra8_bkup_no_switch_init(), ra8_bkup_read_byte(), ra8_bkup_read_input(), ra8_bkup_read_word(), ra8_bkup_security_apply(), ra8_bkup_security_get(), ra8_bkup_tamper_init(), ra8_bkup_warm_start_check(), ra8_bkup_write_byte(), and ra8_bkup_write_word().

◆ s_bkup_initialized

bool s_bkup_initialized
extern

true once any of the lifecycle init helpers have run.

Defined here and referenced from ra8_bkup_tamper.c through ra8_bkup_internal.h: ra8_bkup_tamper_init is an init entry point in its own right, so it sets the flag too.

Note
Strictly used to gate ra8_bkup_isr_handle with the k_ra8_err_not_initialized return – everything else is state-less so the flag is set generously.
Warning
File-scope state, not thread-safe.
Since
0.1.0

Defined once in ra8_bkup.c and referenced from ra8_bkup_tamper.c through this declaration: ra8_bkup_tamper_init is an init entry point in its own right, so it sets the latch too. Read only by ra8_bkup_isr_handle, which returns k_ra8_err_not_initialized while the latch is clear.

Note
Everything else in the driver is state-less, so the flag is set generously rather than tracking a full lifecycle.
Warning
File-scope state, not thread-safe. Mutate only from single-threaded init or with IRQs masked.
Since
0.1.0

Definition at line 120 of file ra8_bkup.c.

Referenced by ra8_bkup_cold_start_init(), ra8_bkup_deinit(), ra8_bkup_init(), ra8_bkup_isr_handle(), ra8_bkup_no_switch_init(), and ra8_bkup_tamper_init().