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

NSC veneer: external XSPI flash read + status. More...

#include <stdint.h>
#include "ra8_check.h"
#include "ra8_err.h"
#include "ra8_nsc.h"
#include "ra8_nsc_veneer.h"
#include "ra8_xspi.h"
Include dependency graph for ra8_nsc_xspi.c:

Go to the source code of this file.

Enumerations

enum  ra8_nsc_xspi_instance_t : uint8_t { k_ra8_nsc_xspi_instance = 0U }

Functions

ra8_err_t ra8_nsc_xspi_read (uint32_t flash_off, uint8_t *ns_dst, uint32_t len)
 NSC veneer: read len bytes from external XSPI flash.
ra8_err_t ra8_nsc_xspi_status (uint8_t instance, uint32_t *out_mask)
 NSC veneer: query secure-side XSPI status.

Variables

static const char * s_tag = "NSCXSPI"

Detailed Description

NSC veneer: external XSPI flash read + status.

Tag
[Ring 4 / NSC] {World: NSC}

veneer over the secure-side ra8_xspi driver. Runs as ordinary code in the single-world build; the RA8_NSC_VENEER attribute expands to __attribute__((cmse_nonsecure_entry)) when the TrustZone build is turned on, and the RA8_NSC_CHECK_NS_RANGE_RW macro becomes a real cmse_check_address_range at that point too.

Definition in file ra8_nsc_xspi.c.

Enumeration Type Documentation

◆ ra8_nsc_xspi_instance_t

enum ra8_nsc_xspi_instance_t : uint8_t
Enumerator
k_ra8_nsc_xspi_instance 

Only one xspi instance today.

Definition at line 31 of file ra8_nsc_xspi.c.

Function Documentation

◆ ra8_nsc_xspi_read()

ra8_err_t ra8_nsc_xspi_read ( uint32_t flash_off,
uint8_t * ns_dst,
uint32_t len )
nodiscard

NSC veneer: read len bytes from external XSPI flash.

Validates len is in (0, k_ra8_nsc_xspi_max_read] and that the NS destination buffer is in writable NS memory, then forwards to ra8_xspi_flash_read for the single configured instance.

Parameters
[in]flash_offByte offset into XSPI flash.
[out]ns_dstNon-Secure destination buffer.
[in]lenBytes to read; 1..k_ra8_nsc_xspi_max_read.
Returns
ra8_err_t outcome.
Return values
k_ra8_okBytes copied to ns_dst.
k_ra8_err_null_ptrns_dst was NULL.
k_ra8_err_invalid_arglen zero / too large or range outside NS.
Precondition
TrustZone substrate up.
[ns_dst, ns_dst+len) lies in NS data region.
Postcondition
On success ns_dst holds len flash bytes from flash_off.
On failure ns_dst content is undefined.
TrustZone:
NS->S boundary via cmse_nonsecure_entry. The destination buffer is cmse_check_address_range-validated so the secure XSPI driver cannot be tricked into writing into secure memory.
Note
Thread-safe: serialised by the secure XSPI driver lock.
Since
0.1.0

Definition at line 64 of file ra8_nsc_xspi.c.

References k_ra8_err_invalid_arg, k_ra8_nsc_xspi_instance, k_ra8_nsc_xspi_max_read, RA8_CHECK_NULL_PTR, RA8_NSC_CHECK_NS_RANGE_RW, RA8_NSC_VENEER, ra8_xspi_flash_read(), and s_tag.

◆ ra8_nsc_xspi_status()

ra8_err_t ra8_nsc_xspi_status ( uint8_t instance,
uint32_t * out_mask )
nodiscard

NSC veneer: query secure-side XSPI status.

Range-checks out_mask in NS memory and forwards to ra8_xspi_get_status.

Parameters
[in]instanceXSPI instance index.
[out]out_maskNS destination for the status mask.
Returns
ra8_err_t outcome.
Return values
k_ra8_okStatus copied to *out_mask.
k_ra8_err_null_ptrout_mask was NULL.
k_ra8_err_invalid_argRange outside NS region or bad instance.
Precondition
TrustZone substrate up.
out_mask lies in NS data region.
Postcondition
On success *out_mask reflects the live status bits.
On failure *out_mask unchanged.
TrustZone:
NS->S boundary via cmse_nonsecure_entry. out_mask is range-checked.
Note
Thread-safe: serialised by the secure XSPI driver lock.
Since
0.1.0

Definition at line 100 of file ra8_nsc_xspi.c.

References RA8_CHECK_NULL_PTR, RA8_NSC_CHECK_NS_RANGE_RW, RA8_NSC_VENEER, ra8_xspi_get_status(), and s_tag.

Variable Documentation

◆ s_tag

const char* s_tag = "NSCXSPI"
static

Definition at line 29 of file ra8_nsc_xspi.c.