|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
SRAM HAL: TrustZone security attribution + ECC error callbacks. More...
#include <stdint.h>#include "ra8_check.h"#include "ra8_err.h"#include "ra8_log.h"#include "ra8_sram.h"#include "ra8_sram_internal.h"#include "ra8_sram_regs.h"Go to the source code of this file.
Functions | |
| ra8_err_t | ra8_sram_set_security (uint32_t sa_mask) |
| Write SRAMSAR (per-bank register security + WTSC security). | |
| ra8_err_t | ra8_sram_set_ecc_security (bool non_secure) |
| Write SRAMESAR (ECC region security). | |
| ra8_err_t | ra8_sram_set_boundary (uint8_t bank, uint32_t offset) |
| Write SRAMSABARn (per-bank Secure/Non-Secure boundary). | |
| ra8_err_t | ra8_sram_attach_handler (ra8_sram_error_fn_t fn, void *ctx) |
| Attach the global ECC error callback. | |
| ra8_err_t | ra8_sram_attach_bank_handler (uint8_t bank, ra8_sram_error_fn_t fn, void *ctx) |
| Attach a per-bank ECC error callback. | |
| void | ra8_sram_dispatch (uint8_t bank, bool is_2bit, uintptr_t err_addr) |
| Dispatch an ECC error event to the registered handler. | |
| uint16_t | ra8_sram_dispatch_from_esr (ra8_sram_status_t *out_status) |
| Read SRAMESR + EAR and dispatch every latched flag. | |
Variables | |
| static const char * | s_tag = "SRAM" |
| Module log tag. | |
| ra8_sram_error_fn_t | g_sram_on_error = nullptr |
| Registered global ECC error callback (NULL until attach). | |
| void * | g_sram_on_error_ctx = nullptr |
| Caller context forwarded to g_sram_on_error. | |
| ra8_sram_error_fn_t | g_sram_on_error_bank [k_ra8_sram_bank_count] |
| Per-bank ECC error callback (NULL until attach). | |
| void * | g_sram_on_error_bank_ctx [k_ra8_sram_bank_count] |
| Per-bank context forwarded to g_sram_on_error_bank. | |
SRAM HAL: TrustZone security attribution + ECC error callbacks.
Split out of ra8_sram.c (file-size cap). Owns:
The callback state defined here (g_sram_on_error*) is also referenced by ra8_sram_deinit in ra8_sram.c via the extern declarations in ra8_sram_internal.h so teardown can drop every registration.
Definition in file ra8_sram_security.c.
|
nodiscard |
Attach a per-bank ECC error callback.
| [in] | bank | Bank index 0..3. |
| [in] | fn | Non-NULL handler. |
| [in] | ctx | Opaque context pointer. |
| k_ra8_ok | Handler installed for this bank only. |
| k_ra8_err_null_ptr | fn was NULL. |
| k_ra8_err_invalid_arg | Bank out of range. |
Definition at line 128 of file ra8_sram_security.c.
References g_sram_on_error_bank, g_sram_on_error_bank_ctx, k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_sram_bank_count, RA8_CHECK_NULL_PTR, and s_tag.
|
nodiscard |
Attach the global ECC error callback.
| [in] | fn | Non-NULL handler invoked from the NMI ISR (or test code). |
| [in] | ctx | Opaque context pointer forwarded to the handler. |
| k_ra8_ok | Handler installed. |
| k_ra8_err_null_ptr | fn was NULL. |
Definition at line 119 of file ra8_sram_security.c.
References g_sram_on_error, g_sram_on_error_ctx, k_ra8_ok, RA8_CHECK_NULL_PTR, and s_tag.
| void ra8_sram_dispatch | ( | uint8_t | bank, |
| bool | is_2bit, | ||
| uintptr_t | err_addr ) |
Dispatch an ECC error event to the registered handler.
| [in] | bank | Bank index 0..3 (out-of-range silently ignored). |
| [in] | is_2bit | true for uncorrectable, false for 1-bit. |
| [in] | err_addr | Faulting offset (from SRAMEARnm). |
Fires both the global handler (if attached) and the per-bank handler (if attached). Out-of-range bank is silently ignored so the caller can blindly walk SRAMESR bits.
Definition at line 139 of file ra8_sram_security.c.
References g_sram_on_error, g_sram_on_error_bank, g_sram_on_error_bank_ctx, g_sram_on_error_ctx, and k_ra8_sram_bank_count.
Referenced by ra8_sram_dispatch_from_esr().
| uint16_t ra8_sram_dispatch_from_esr | ( | ra8_sram_status_t * | out_status | ) |
Read SRAMESR + EAR and dispatch every latched flag.
The intended NMI path: snapshots SRAMESR once, walks each of the 8 defined error bits, calls ra8_sram_dispatch for every set bit with the corresponding EAR address, and returns the OR of all dispatched flags so the caller can clear them in a single SRAMESCLR write.
| [out] | out_status | Optional snapshot of the SRAMESR / EAR state (may be NULL if the caller does not need it). |
| k_ra8_ok | Operation succeeded. |
Definition at line 156 of file ra8_sram_security.c.
References ra8_sram_status_t::addr_1bit, ra8_sram_status_t::addr_2bit, k_ra8_ok, k_ra8_sram_bank_count, ra8_sram_dispatch(), ra8_sram_get_status(), and ra8_sram_status_t::raw_esr.
|
nodiscard |
Write SRAMSABARn (per-bank Secure/Non-Secure boundary).
| [in] | bank | Bank index 0..3. |
| [in] | offset | Boundary offset inside the bank's 0x80000-byte slot (must be 4 KB aligned per HUM 58.2.1 p 3527). |
| k_ra8_ok | SABAR updated. |
| k_ra8_err_invalid_arg | Bank or offset rejected. |
Definition at line 99 of file ra8_sram_security.c.
References k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_sram_bank_count, k_ra8_sram_sabar_align_mask, ra8_sram_cpscu_regs(), and r_sram_cpscu_regs_t::SRAMSABAR.
|
nodiscard |
Write SRAMESAR (ECC region security).
| [in] | non_secure | true -> SRAMESA=1 (NS); false -> Secure. |
| k_ra8_ok | Always. |
Definition at line 86 of file ra8_sram_security.c.
References k_ra8_ok, k_ra8_sram_esar_bit_esa, ra8_sram_cpscu_regs(), and r_sram_cpscu_regs_t::SRAMESAR.
|
nodiscard |
Write SRAMSAR (per-bank register security + WTSC security).
| [in] | sa_mask | Bitmask of ra8_sram_sar_bit_t values. |
| k_ra8_ok | SAR register updated. |
| k_ra8_err_invalid_arg | sa_mask includes undefined bits. |
Definition at line 74 of file ra8_sram_security.c.
References k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_sram_sar_writable, ra8_sram_cpscu_regs(), and r_sram_cpscu_regs_t::SRAMSAR.
| ra8_sram_error_fn_t g_sram_on_error = nullptr |
Registered global ECC error callback (NULL until attach).
Defined in ra8_sram_security.c. Referenced by ra8_sram_deinit in ra8_sram.c to drop the registration on teardown.
Definition at line 48 of file ra8_sram_security.c.
Referenced by ra8_sram_attach_handler(), ra8_sram_deinit(), and ra8_sram_dispatch().
| ra8_sram_error_fn_t g_sram_on_error_bank[k_ra8_sram_bank_count] |
Per-bank ECC error callback (NULL until attach).
Per-bank ECC error callback table (NULL until attach).
Definition at line 54 of file ra8_sram_security.c.
Referenced by ra8_sram_attach_bank_handler(), ra8_sram_deinit(), and ra8_sram_dispatch().
| void* g_sram_on_error_bank_ctx[k_ra8_sram_bank_count] |
Per-bank context forwarded to g_sram_on_error_bank.
Defined in ra8_sram_security.c.
Definition at line 62 of file ra8_sram_security.c.
Referenced by ra8_sram_attach_bank_handler(), ra8_sram_deinit(), and ra8_sram_dispatch().
| void* g_sram_on_error_ctx = nullptr |
Caller context forwarded to g_sram_on_error.
Defined in ra8_sram_security.c.
Definition at line 51 of file ra8_sram_security.c.
Referenced by ra8_sram_attach_handler(), ra8_sram_deinit(), and ra8_sram_dispatch().
|
static |
Module log tag.
Definition at line 40 of file ra8_sram_security.c.