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

Application-layer bring-up (called from main() after SystemInit). More...

#include "ra8_infrastructure.h"
#include <stdint.h>
#include "ra8_attributes.h"
#include "ra8_err.h"
#include "ra8_log.h"
#include "ra8_pin_validator.h"
Include dependency graph for ra8_infrastructure.c:

Go to the source code of this file.

Enumerations

enum  ra8_stack_canary_pattern_t : uint32_t { k_ra8_stack_canary_pattern = 0xDEADBEEFUL }

Functions

static void internal_write_stack_canary (void)
 Fill .stack_canary with the sentinel pattern.
void ra8_infrastructure_init (void)
 Implementation of ra8_infrastructure_init() – bring-up.
ra8_err_t ra8_stack_canary_check (void)
 Implementation of ra8_stack_canary_check() – sentinel check.

Variables

uint32_t g_ra8_ls_stack_canary_start []
uint32_t g_ra8_ls_stack_canary_end []

Detailed Description

Application-layer bring-up (called from main() after SystemInit).

Runs after SystemInit() – which already handled VTOR, FPU, lazy stacking, I-cache, D-cache, branch predictor, and priority grouping. This function only covers the application layer:

  • Log backend initialisation.
  • Pin validator reset.
  • Stack canary sentinel write (so later overflow checks have a reference to compare against).

Anything that depends on a peripheral clock lives in a driver _init() entry point, not here.

Since
0.1.0

Definition in file ra8_infrastructure.c.

Enumeration Type Documentation

◆ ra8_stack_canary_pattern_t

enum ra8_stack_canary_pattern_t : uint32_t
Enumerator
k_ra8_stack_canary_pattern 

RA8 stack canary pattern.

Definition at line 42 of file ra8_infrastructure.c.

Function Documentation

◆ internal_write_stack_canary()

void internal_write_stack_canary ( void )
static

Fill .stack_canary with the sentinel pattern.

Walks the linker-defined region and writes k_ra8_stack_canary_pattern into every word. No-op on the fake host where the linker symbols are absent.

Precondition
Linker-defined symbols are valid (target build only).
Function is called once during early init.
Postcondition
Every 32-bit word in the canary region equals the sentinel.
No other state modified.
Note
Not thread-safe; intended for one-shot init only.
Since
0.1.0

Definition at line 62 of file ra8_infrastructure.c.

References g_ra8_ls_stack_canary_end, g_ra8_ls_stack_canary_start, k_ra8_stack_canary_pattern, and RA8_INTERNAL.

Referenced by ra8_infrastructure_init().

◆ ra8_infrastructure_init()

void ra8_infrastructure_init ( void )

Implementation of ra8_infrastructure_init() – bring-up.

Run every piece of infrastructure init that a driver may assume.

Initialises the log backend, resets the pin validator, and seeds the stack canary region.

Precondition
SystemInit() has executed.
Function is called from a single-threaded context.
Postcondition
Log backend, pin validator, and stack canary are initialized.
Drivers may now be brought up.
Note
Not thread-safe; intended for one-shot init only.
Since
0.1.0

Definition at line 86 of file ra8_infrastructure.c.

References internal_write_stack_canary(), ra8_log_info, ra8_log_init(), and ra8_pin_validator_reset().

◆ ra8_stack_canary_check()

ra8_err_t ra8_stack_canary_check ( void )
nodiscard

Implementation of ra8_stack_canary_check() – sentinel check.

Verify the SRAM stack canary sentinel pattern.

Walks the linker-defined region and compares each word to k_ra8_stack_canary_pattern.

Returns
Error code.
Return values
k_ra8_okSentinel intact.
k_ra8_err_validation_failedAt least one word was corrupted.
Precondition
ra8_infrastructure_init() has run.
Linker-defined sentinel symbols are valid (target build).
Postcondition
No state modified.
Result reflects the canary region at the moment of the call.
Note
Thread-safe (read-only walk). On the off-target host this is a no-op that always returns k_ra8_ok.
Since
0.1.0

Definition at line 120 of file ra8_infrastructure.c.

References g_ra8_ls_stack_canary_end, g_ra8_ls_stack_canary_start, k_ra8_err_validation_failed, k_ra8_ok, and k_ra8_stack_canary_pattern.

Variable Documentation

◆ g_ra8_ls_stack_canary_end

uint32_t g_ra8_ls_stack_canary_end[]
extern

◆ g_ra8_ls_stack_canary_start

uint32_t g_ra8_ls_stack_canary_start[]
extern