|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Cortex-M85 / RA8D2 core bring-up (called from Reset_Handler). More...
Go to the source code of this file.
Enumerations | |
| enum | ra8_core_addr_t : uintptr_t { k_ra8_scb_vtor_addr = 0xE000ED08UL , k_ra8_scb_ccr_addr = 0xE000ED14UL , k_ra8_scb_shcsr_addr = 0xE000ED24UL , k_ra8_scb_cpacr_addr = 0xE000ED88UL , k_ra8_scb_nsacr_addr = 0xE000ED8CUL , k_ra8_scb_iciallu = 0xE000EF50UL , k_ra8_scb_dciallu = 0xE000EF58UL , k_ra8_scb_csselr = 0xE000ED84UL , k_ra8_scb_ccsidr = 0xE000ED80UL , k_ra8_scb_dcisw = 0xE000EF60UL , k_ra8_fpu_fpccr_addr = 0xE000EF34UL , k_ra8_nvic_aircr = 0xE000ED0CUL , k_ra8_mpu_type_addr = 0xE000ED90UL , k_ra8_mpu_ctrl_addr = 0xE000ED94UL , k_ra8_mpu_rnr_addr = 0xE000ED98UL , k_ra8_mpu_rbar_addr = 0xE000ED9CUL , k_ra8_mpu_rlar_addr = 0xE000EDA0UL , k_ra8_mpu_mair0_addr = 0xE000EDC0UL , k_ra8_mpu_mair1_addr = 0xE000EDC4UL } |
| enum | : uint32_t { k_ra8_rbar_attr_ro_x = 0x02U , k_ra8_rbar_attr_rw_xn = 0x03U , k_ra8_rbar_attr_device_rw = 0x23U , k_ra8_mpu_rlar_enable = 1UL << 0 } |
| Programme and enable the Cortex-M85 core MPU. More... | |
| enum | : uint32_t { k_ra8_mpu_mram_base = 0x02000000UL , k_ra8_mpu_mram_limit = 0x020FFFE0UL , k_ra8_mpu_sram_base = 0x22000000UL , k_ra8_mpu_sram_limit = 0x221FFFE0UL , k_ra8_mpu_sdram_base = 0x68000000UL , k_ra8_mpu_sdram_limit = 0x6BFFFFE0UL , k_ra8_mpu_peri_base = 0x40000000UL , k_ra8_mpu_peri_limit = 0x47FFFFE0UL } |
Functions | |
| static uint32_t | internal_read32 (uintptr_t addr) |
| static void | internal_write32 (uintptr_t addr, uint32_t value) |
| static void | internal_dsb (void) |
| static void | internal_isb (void) |
| static void | internal_disable_irq (void) |
| static void | internal_set_vtor (void) |
| Point VTOR at the physical vector table base. | |
| static void | internal_enable_fpu (void) |
| Grant full access to CP10 / CP11 (the FPU coprocessors). | |
| static void | internal_enable_fpu_lazy_stack (void) |
| Turn on FPU lazy stacking (FPCCR.LSPEN = 1, ASPEN = 1). | |
| static void | internal_enable_icache (void) |
| Invalidate and enable the Cortex-M85 I-cache. | |
| static void | internal_enable_dcache (void) |
| Invalidate and enable the Cortex-M85 D-cache. | |
| static void | internal_enable_branch_predictor (void) |
| Enable branch-target prediction (CCR.BP on Cortex-M85). | |
| static void | internal_set_priority_grouping (void) |
| Set NVIC priority grouping to 4 preempt bits / 0 sub-priority. | |
| 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_mpu_init (void) |
| Programme and enable the Cortex-M85 core MPU. | |
| static void | internal_halt_secure_clock_fault (void) |
| Park forever after a Secure clock-tree bring-up failure. | |
| void | SystemInit (void) |
| Earliest C code the image runs: bring the core up before RAM init. | |
Variables | |
| const uint32_t | g_ra8_vector_table_start [] |
| uint32_t | g_ra8_ls_stack_top |
Cortex-M85 / RA8D2 core bring-up (called from Reset_Handler).
SystemInit() follows the CMSIS naming convention and runs as the first C function out of reset, before Reset_Handler copies .data or zeroes .bss. Its responsibilities are strictly CPU-core level – anything peripheral-bus-side belongs in ra8_infrastructure_init() called from main() after the C runtime is live.
The function is C, not naked asm, so stack, .data and .bss must already be usable. Reset_Handler loads SP from the vector table before calling SystemInit(), and now copies .data + zeroes .bss BEFORE the SystemInit() call, so any global state this function establishes survives into main(). This ordering is load-bearing: ra8_cgc_init() (called below) publishes the settled clock rates into a .data-resident cache in ra8_cgc; if the .data copy ran after SystemInit() it would clobber that cache back to the MOCO boot default and the SCI8 console would then read a stale ~8 MHz PCLKA and refuse to initialise.
Definition in file system_init.c.
| anonymous enum : uint32_t |
Programme and enable the Cortex-M85 core MPU.
Installs four regions and enables the MPU with PRIVDEFENA so privileged mode still sees the default memory map for anything not explicitly covered:
Attribute indirection table:
Region base + limit addresses are encoded per ARMv8-M main-profile PMSAv8 rules: low 5 bits of RBAR hold AP[2:0] / SH[4:3] / XN, and RLAR holds the upper bound OR the enable flag in bit 0.
Definition at line 259 of file system_init.c.
| anonymous enum : uint32_t |
Definition at line 268 of file system_init.c.
| enum ra8_core_addr_t : uintptr_t |
Definition at line 67 of file system_init.c.
|
inlinestatic |
Definition at line 120 of file system_init.c.
|
inlinestatic |
Definition at line 106 of file system_init.c.
|
static |
Enable branch-target prediction (CCR.BP on Cortex-M85).
< RA8 ccr bp.
Definition at line 213 of file system_init.c.
References internal_dsb(), internal_isb(), internal_read32(), internal_write32(), and k_ra8_scb_ccr_addr.
|
static |
Invalidate and enable the Cortex-M85 D-cache.
The invalidate-by-set/way loop is omitted here for brevity – on the RA8D2 the boot ROM leaves the D-cache with all lines marked invalid, so a bulk CCR.DC = 1 write is safe. A production build should add a real CCSIDR-driven loop.
< RA8 ccr dc.
Definition at line 200 of file system_init.c.
References internal_dsb(), internal_isb(), internal_read32(), internal_write32(), and k_ra8_scb_ccr_addr.
|
static |
Grant full access to CP10 / CP11 (the FPU coprocessors).
< RA8 cpacr cp10 cp11 full access.
Definition at line 146 of file system_init.c.
References internal_dsb(), internal_isb(), internal_read32(), internal_write32(), and k_ra8_scb_cpacr_addr.
|
static |
Turn on FPU lazy stacking (FPCCR.LSPEN = 1, ASPEN = 1).
< RA8 fpccr lspen.
< RA8 fpccr aspen.
Definition at line 161 of file system_init.c.
References internal_read32(), internal_write32(), and k_ra8_fpu_fpccr_addr.
|
static |
Invalidate and enable the Cortex-M85 I-cache.
< RA8 ccr ic.
Definition at line 175 of file system_init.c.
References internal_dsb(), internal_isb(), internal_read32(), internal_write32(), k_ra8_scb_ccr_addr, and k_ra8_scb_iciallu.
|
static |
Park forever after a Secure clock-tree bring-up failure.
Reached only when ra8_cgc_init fails inside SystemInit. The NS-side NSC CGC veneers require PLL1 locked, and ra8_trustzone_init BLXNS-es into the NS world without returning – so a failed clock bring-up must NOT proceed to the world switch, which would run NS code on a dead clock tree. Parks in a wfi loop at this named, non-inlined symbol so a debugger or HIL probe can pin the secure-boot clock failure; the only escape is a watchdog or debugger reset.
Definition at line 346 of file system_init.c.
|
inlinestatic |
Definition at line 113 of file system_init.c.
|
static |
Programme and enable the Cortex-M85 core MPU.
< RA8 MPU control enable.
< RA8 MPU control privdefena.
< RA8 mair0 default.
Definition at line 292 of file system_init.c.
References internal_dsb(), internal_isb(), internal_mpu_set_region(), internal_write32(), k_ra8_mpu_ctrl_addr, k_ra8_mpu_ctrl_enable, k_ra8_mpu_ctrl_privdefena, k_ra8_mpu_mair0_addr, k_ra8_mpu_mair1_addr, k_ra8_mpu_mram_base, k_ra8_mpu_mram_limit, k_ra8_mpu_peri_base, k_ra8_mpu_peri_limit, k_ra8_mpu_rlar_enable, k_ra8_mpu_sdram_base, k_ra8_mpu_sdram_limit, k_ra8_mpu_sram_base, k_ra8_mpu_sram_limit, k_ra8_rbar_attr_device_rw, k_ra8_rbar_attr_ro_x, and k_ra8_rbar_attr_rw_xn.
|
static |
Program a single MPU region via RNR/RBAR/RLAR.
Definition at line 282 of file system_init.c.
References internal_write32(), k_ra8_mpu_rbar_addr, k_ra8_mpu_rlar_addr, and k_ra8_mpu_rnr_addr.
|
inlinestatic |
Definition at line 96 of file system_init.c.
|
static |
Set NVIC priority grouping to 4 preempt bits / 0 sub-priority.
< Required write key.
< PRIGROUP = 3 -> 4 bits.
Definition at line 226 of file system_init.c.
References internal_write32(), and k_ra8_nvic_aircr.
|
static |
Point VTOR at the physical vector table base.
Definition at line 135 of file system_init.c.
References g_ra8_vector_table_start, internal_write32(), and k_ra8_scb_vtor_addr.
|
inlinestatic |
Definition at line 101 of file system_init.c.
| void SystemInit | ( | void | ) |
Earliest C code the image runs: bring the core up before RAM init.
Called by Reset_Handler before .data is copied and .bss is zeroed, so it must not touch initialised or zero-initialised statics. Each image supplies its own definition – the shared board one under the board boot directories, or an application-local system_init.c where the clock tree or memory map diverges.
The name is the CMSIS convention; the startup code reaches it by that name, which is why it has external linkage.
Definition at line 362 of file system_init.c.
References internal_disable_irq(), internal_enable_branch_predictor(), internal_enable_dcache(), internal_enable_fpu(), internal_enable_fpu_lazy_stack(), internal_enable_icache(), internal_halt_secure_clock_fault(), internal_mpu_init(), internal_set_priority_grouping(), internal_set_vtor(), k_ra8_ok, ra8_cgc_init(), and ra8_trustzone_init().
|
extern |
|
extern |
Definition at line 294 of file vector_table.c.