56#include "trustzone_init.h"
65typedef enum : uintptr_t {
111 return *(
volatile uint32_t*)addr;
131 *(
volatile uint32_t*)addr = value;
150#ifndef RA8_OFF_TARGET
151 __asm__
volatile(
"dsb 0xF" :::
"memory");
170#ifndef RA8_OFF_TARGET
171 __asm__
volatile(
"isb 0xF" :::
"memory");
190#ifndef RA8_OFF_TARGET
191 __asm__
volatile(
"cpsid i" :::
"memory");
238 k_ra8_cpacr_cp10_cp11_full_access = 0x00F00000UL,
241 cpacr |= k_ra8_cpacr_cp10_cp11_full_access;
264 k_ra8_fpccr_lspen = 1UL << 30,
265 k_ra8_fpccr_aspen = 1UL << 31,
268 fpccr |= k_ra8_fpccr_lspen | k_ra8_fpccr_aspen;
291 enum : uint32_t { k_ra8_ccr_ic = 1UL << 17 };
317 enum : uint32_t { k_ra8_ccr_dc = 1UL << 16 };
338 enum : uint32_t { k_ra8_ccr_bp = 1UL << 18 };
363 k_ra8_aircr_vectkey = 0x05FA0000UL,
364 k_ra8_aircr_prigroup_4 = 0x00000300UL,
451 k_ra8_mair0_default = 0x000404FFUL,
503 __asm__
volatile(
"wfi");
548#ifdef RA8_TRUSTZONE_ENABLE
static void internal_enable_fpu_lazy_stack(void)
Turn on FPU lazy stacking (FPCCR.LSPEN = 1, ASPEN = 1).
static void internal_dsb(void)
Data Synchronization Barrier (DSB).
static void internal_enable_branch_predictor(void)
Enable branch-target prediction (CCR.BP on Cortex-M85).
static void internal_write32(uintptr_t addr, uint32_t value)
Write a 32-bit value to a core/system register via a volatile store.
static void internal_disable_irq(void)
Mask all maskable IRQs at the core (PRIMASK = 1, cpsid i).
static void internal_set_vtor(void)
Point VTOR at the physical vector table base.
static void internal_enable_dcache(void)
Invalidate and enable the Cortex-M85 D-cache.
static void internal_enable_icache(void)
Invalidate and enable the Cortex-M85 I-cache.
static void internal_mpu_init(void)
Programme and enable the Cortex-M85 core MPU.
static uint32_t internal_read32(uintptr_t addr)
Read a 32-bit core/system register via a volatile load.
void SystemInit(void)
Earliest C code the image runs: bring the core up before RAM init.
static void internal_mpu_set_region(uint32_t region, uint32_t base_attr, uint32_t limit_enable)
Program a single MPU region via RNR/RBAR/RLAR.
static void internal_halt_secure_clock_fault(void)
Park forever after a Secure clock-tree bring-up failure.
static void internal_isb(void)
Instruction Synchronization Barrier (ISB).
static void internal_set_priority_grouping(void)
Set NVIC priority grouping to 4 preempt bits / 0 sub-priority.
static void internal_enable_fpu(void)
Grant full access to CP10 / CP11 (the FPU coprocessors).
@ k_ra8_rbar_attr_device_rw
AP=RW, SH=outer sh, XN=1, MAIR idx = device.
void ra8_trustzone_init(void)
Programme + enable the SAU per the partition.
static void internal_enable_branch_predictor(void)
Enable branch-target prediction (CCR.BP on Cortex-M85).
static void internal_enable_dcache(void)
Invalidate and enable the Cortex-M85 D-cache.
uint32_t g_ra8_ls_stack_top
static void internal_enable_icache(void)
Invalidate and enable the Cortex-M85 I-cache.
@ k_ra8_mpu_sdram_limit
RA8 MPU SDRAM limit.
@ k_ra8_mpu_mram_base
1 MiB MRAM code region.
@ k_ra8_mpu_sram_limit
RA8 MPU SRAM limit.
@ k_ra8_mpu_sram_base
M85 private SRAM0+1, 1 MiB, cacheable.
@ k_ra8_mpu_peri_base
Peripheral bus window base.
@ k_ra8_mpu_mram_limit
RA8 MPU MRAM limit.
@ k_ra8_mpu_peri_limit
RA8 MPU peri limit.
@ k_ra8_mpu_sdram_base
64 MiB external SDRAM.
static void internal_mpu_init(void)
Programme and enable the Cortex-M85 core MPU.
@ k_ra8_rbar_attr_ro_x
AP=RO any-priv, SH=none, XN=0 (executable).
@ k_ra8_mpu_rlar_enable
RA8 MPU rlar enable.
@ k_ra8_rbar_attr_rw_xn
AP=RW any-priv, SH=none, XN=1 (no execute).
@ k_ra8_scb_iciallu
ICIALLU – invalidate I-cache.
@ k_ra8_scb_dcisw
D-cache Invalidate by Set/Way.
@ k_ra8_scb_csselr
Cache Size Selection Register.
@ k_ra8_scb_dciallu
DCIALLU – invalidate D-cache (sets only).
@ k_ra8_mpu_mair0_addr
MPU Attribute Indirection 0.
@ k_ra8_scb_ccsidr
Cache Size ID Register.
@ k_ra8_scb_cpacr_addr
Coprocessor Access Control.
@ k_ra8_scb_shcsr_addr
System Handler Control and State.
@ k_ra8_fpu_fpccr_addr
FPU Context Control Register.
@ k_ra8_scb_ccr_addr
Configuration and Control Register.
@ k_ra8_mpu_type_addr
MPU Type Register.
@ k_ra8_mpu_rnr_addr
MPU Region Number.
@ k_ra8_mpu_rbar_addr
MPU Region Base Address.
@ k_ra8_mpu_mair1_addr
MPU Attribute Indirection 1.
@ k_ra8_mpu_ctrl_addr
MPU Control Register.
@ k_ra8_scb_vtor_addr
Vector Table Offset Register.
@ k_ra8_scb_nsacr_addr
Non-secure Access Control.
@ k_ra8_mpu_rlar_addr
MPU Region Limit Address.
@ k_ra8_nvic_aircr
Application Interrupt and Reset Ctrl.
const uint32_t g_ra8_vector_table_start[]
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Boot entry points shared between a vector table and its startup code.
High-level Clock Generation Circuit driver.
ra8_err_t ra8_cgc_init(void)
Configure the clock tree to a safe default.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_mpu_ctrl_enable
RA8 MPU control enable.
@ k_ra8_mpu_ctrl_privdefena
RA8 MPU control privdefena.